Fix cache key collision bug
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-12-03 18:13:09 -05:00
parent 9157180e03
commit bff87fa725
4 changed files with 7 additions and 8 deletions

View File

@ -1232,6 +1232,7 @@ Refactoring world menu generators into dedicated class
Fix single player loading
Spawn player in center of single player world
Elevation fix + use correct voxel generation in SP worlds
Fix cache key collision bug

View File

@ -6,10 +6,9 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.locks.ReentrantLock;
import io.github.studiorailgun.HashUtils;
/**
* Caches chunk data on the server
*/
@ -159,7 +158,7 @@ public class BlockChunkCache {
* @return The key
*/
public long getKey(int worldX, int worldY, int worldZ){
return HashUtils.cantorHash(worldX, worldY, worldZ);
return Objects.hash(worldX, worldY, worldZ);
}
/**

View File

@ -5,11 +5,11 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Semaphore;
import org.joml.Vector3i;
import io.github.studiorailgun.HashUtils;
/**
@ -151,7 +151,7 @@ public class ClientTerrainCache {
* @return The cache key
*/
public long getKey(int worldX, int worldY, int worldZ){
return HashUtils.cantorHash(worldX, worldY, worldZ);
return Objects.hash(worldX, worldY, worldZ);
}
/**

View File

@ -6,10 +6,9 @@ import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.concurrent.Semaphore;
import io.github.studiorailgun.HashUtils;
/**
* Caches chunk data on the server
*/
@ -159,7 +158,7 @@ public class ServerChunkCache {
* @return The key
*/
public long getKey(int worldX, int worldY, int worldZ){
return HashUtils.cantorHash(worldX, worldY, worldZ);
return Objects.hash(worldX, worldY, worldZ);
}
/**