terrain chunk file dedicated folder
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
4995e06f87
commit
4e6f9243b6
@ -1234,6 +1234,8 @@ Spawn player in center of single player world
|
||||
Elevation fix + use correct voxel generation in SP worlds
|
||||
Fix cache key collision bug
|
||||
Fix homogenous flagging on cell managers
|
||||
Fix more cache key collision cases
|
||||
Store terrain chunk files in dedicated folder
|
||||
|
||||
|
||||
|
||||
|
||||
@ -7,6 +7,7 @@ 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;
|
||||
@ -21,7 +22,6 @@ import electrosphere.net.parser.net.message.TerrainMessage;
|
||||
import electrosphere.renderer.meshgen.BlockMeshgen.BlockMeshData;
|
||||
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||
import io.github.studiorailgun.HashUtils;
|
||||
|
||||
public class ClientBlockManager {
|
||||
//queues messages from server
|
||||
@ -291,6 +291,6 @@ public class ClientBlockManager {
|
||||
* @return The key
|
||||
*/
|
||||
private Long getRequestKey(int worldX, int worldY, int worldZ, int stride){
|
||||
return (long)HashUtils.cantorHash(worldY, worldZ, worldZ);
|
||||
return (long)Objects.hash(worldY, worldZ, worldZ);
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,6 +9,7 @@ import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.Semaphore;
|
||||
|
||||
@ -32,7 +33,6 @@ import electrosphere.renderer.meshgen.TransvoxelModelGeneration;
|
||||
import electrosphere.renderer.model.Model;
|
||||
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||
import io.github.studiorailgun.HashUtils;
|
||||
|
||||
/**
|
||||
* Manages terrain storage and access on the client
|
||||
@ -392,7 +392,7 @@ public class ClientTerrainManager {
|
||||
* @return The key
|
||||
*/
|
||||
private Long getRequestKey(int worldX, int worldY, int worldZ, int stride){
|
||||
return (long)HashUtils.cantorHash(worldY, worldZ, worldZ);
|
||||
return (long)Objects.hash(worldY, worldZ, worldZ);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,6 +6,7 @@ import java.nio.ByteBuffer;
|
||||
import java.nio.ShortBuffer;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.zip.DeflaterOutputStream;
|
||||
import java.util.zip.InflaterOutputStream;
|
||||
@ -15,7 +16,6 @@ import electrosphere.engine.Globals;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.util.FileUtils;
|
||||
import electrosphere.util.annotation.Exclude;
|
||||
import io.github.studiorailgun.HashUtils;
|
||||
|
||||
/**
|
||||
* An interface for accessing the disk map of chunk information
|
||||
@ -48,7 +48,7 @@ public class ServerBlockChunkDiskMap {
|
||||
* @return The key
|
||||
*/
|
||||
private static long getBlockChunkKey(int worldX, int worldY, int worldZ){
|
||||
return HashUtils.cantorHash(worldX, worldY, worldZ);
|
||||
return Objects.hash(worldX, worldY, worldZ);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.server.content;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.joml.Vector3i;
|
||||
|
||||
@ -11,7 +12,6 @@ import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.datacell.ServerDataCell;
|
||||
import electrosphere.server.saves.SaveUtils;
|
||||
import electrosphere.util.FileUtils;
|
||||
import io.github.studiorailgun.HashUtils;
|
||||
|
||||
public class ServerContentManager {
|
||||
|
||||
@ -49,7 +49,7 @@ public class ServerContentManager {
|
||||
contentRaw.hydrateRawContent(realm,cell);
|
||||
} else {
|
||||
//else create from scratch
|
||||
ServerContentGenerator.generateContent(realm, cell, worldPos, HashUtils.cantorHash(worldPos.x, worldPos.y, worldPos.z));
|
||||
ServerContentGenerator.generateContent(realm, cell, worldPos, Objects.hash(worldPos.x, worldPos.y, worldPos.z));
|
||||
}
|
||||
} else {
|
||||
//just because content wasn't generated doesn't mean there isn't data saved under that key
|
||||
|
||||
@ -7,6 +7,7 @@ import java.util.HashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
@ -37,7 +38,6 @@ import electrosphere.server.fluid.manager.ServerFluidChunk;
|
||||
import electrosphere.server.fluid.manager.ServerFluidManager;
|
||||
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||
import electrosphere.server.terrain.models.TerrainModel;
|
||||
import io.github.studiorailgun.HashUtils;
|
||||
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||
|
||||
/**
|
||||
@ -671,7 +671,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
||||
* @return The server data cell if it exists, otherwise null
|
||||
*/
|
||||
private Long getServerDataCellKey(Vector3i worldPos){
|
||||
return (long)HashUtils.cantorHash(worldPos.x, worldPos.y, worldPos.z);
|
||||
return (long)Objects.hash(worldPos.x, worldPos.y, worldPos.z);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -1,10 +1,12 @@
|
||||
package electrosphere.server.terrain.diskmap;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
import java.nio.file.Files;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
@ -14,6 +16,7 @@ import java.util.zip.InflaterOutputStream;
|
||||
import electrosphere.client.terrain.cache.ChunkData;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.server.saves.SaveUtils;
|
||||
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||
import electrosphere.util.FileUtils;
|
||||
import electrosphere.util.annotation.Exclude;
|
||||
@ -73,6 +76,16 @@ public class ChunkDiskMap {
|
||||
if(FileUtils.getSaveFile(saveName, "chunk.map").exists()){
|
||||
rVal = FileUtils.loadObjectFromSavePath(saveName, "chunk.map", ChunkDiskMap.class);
|
||||
LoggerInterface.loggerEngine.DEBUG("POS FILE MAP: " + rVal.worldPosFileMap.keySet());
|
||||
|
||||
//make sure the subfolder for chunk files exists
|
||||
String dirPath = SaveUtils.deriveSaveDirectoryPath(Globals.currentSave.getName());
|
||||
if(!Files.exists(new File(dirPath + "/terrain").toPath())){
|
||||
try {
|
||||
Files.createDirectories(new File(dirPath + "/terrain").toPath());
|
||||
} catch (IOException e) {
|
||||
LoggerInterface.loggerFileIO.ERROR(e);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
rVal = new ChunkDiskMap();
|
||||
}
|
||||
@ -136,7 +149,7 @@ public class ChunkDiskMap {
|
||||
if(containsTerrainAtPosition(worldX, worldY, worldZ)){
|
||||
//read file
|
||||
String fileName = worldPosFileMap.get(getTerrainChunkKey(worldX, worldY, worldZ));
|
||||
byte[] rawDataCompressed = FileUtils.loadBinaryFromSavePath(Globals.currentSave.getName(), fileName);
|
||||
byte[] rawDataCompressed = FileUtils.loadBinaryFromSavePath(Globals.currentSave.getName(), "/terrain/" + fileName);
|
||||
//decompress
|
||||
byte[] rawData = null;
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
@ -232,7 +245,7 @@ public class ChunkDiskMap {
|
||||
deflaterInputStream.flush();
|
||||
deflaterInputStream.close();
|
||||
//write to disk
|
||||
FileUtils.saveBinaryToSavePath(Globals.currentSave.getName(), fileName, out.toByteArray());
|
||||
FileUtils.saveBinaryToSavePath(Globals.currentSave.getName(), "/terrain/" + fileName, out.toByteArray());
|
||||
//save to the map of filenames
|
||||
worldPosFileMap.put(chunkKey,fileName);
|
||||
} catch (IOException e) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user