fix array error
Some checks failed
studiorailgun/Renderer/pipeline/pr-master There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/pr-master There was a failure building this commit
This commit is contained in:
parent
ae4c0aa4e5
commit
96b65dba46
@ -130,6 +130,17 @@ public class Logger {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Logs an error message.
|
||||||
|
* This should be used every time we throw any kind of error in the engine
|
||||||
|
* @param e The exception to report
|
||||||
|
*/
|
||||||
|
public void ERROR(Error e){
|
||||||
|
if(level == LogLevel.LOOP_DEBUG || level == LogLevel.DEBUG || level == LogLevel.INFO || level == LogLevel.WARNING || level == LogLevel.ERROR){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prints a message at the specified logging level
|
* Prints a message at the specified logging level
|
||||||
* @param level The logging level
|
* @param level The logging level
|
||||||
|
|||||||
@ -68,13 +68,12 @@ public class TestGenerationChunkGenerator implements ChunkGenerator {
|
|||||||
public ServerTerrainChunk generateChunk(int worldX, int worldY, int worldZ, int stride) {
|
public ServerTerrainChunk generateChunk(int worldX, int worldY, int worldZ, int stride) {
|
||||||
Globals.profiler.beginAggregateCpuSample("TestGenerationChunkGenerator.generateChunk");
|
Globals.profiler.beginAggregateCpuSample("TestGenerationChunkGenerator.generateChunk");
|
||||||
ServerTerrainChunk rVal = null;
|
ServerTerrainChunk rVal = null;
|
||||||
float[][][] weights;
|
float[][][] weights = new float[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];;
|
||||||
int[][][] values;
|
int[][][] values = new int[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
||||||
|
|
||||||
|
try {
|
||||||
if(worldX == 0 || worldZ == 0){
|
if(worldX == 0 || worldZ == 0){
|
||||||
//generate flat ground for the player to spawn on
|
//generate flat ground for the player to spawn on
|
||||||
weights = new float[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
|
||||||
values = new int[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
|
||||||
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
for(int x = 0; x < ServerTerrainChunk.CHUNK_DIMENSION; x++){
|
||||||
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
for(int y = 0; y < ServerTerrainChunk.CHUNK_DIMENSION; y++){
|
||||||
Arrays.fill(weights[x][y],-1f);
|
Arrays.fill(weights[x][y],-1f);
|
||||||
@ -93,8 +92,6 @@ public class TestGenerationChunkGenerator implements ChunkGenerator {
|
|||||||
|
|
||||||
} else {
|
} else {
|
||||||
//actual generation algo
|
//actual generation algo
|
||||||
weights = new float[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
|
||||||
values = new int[ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION][ServerTerrainChunk.CHUNK_DIMENSION];
|
|
||||||
|
|
||||||
//biome of the current chunk
|
//biome of the current chunk
|
||||||
BiomeData surfaceBiome = this.terrainModel.getSurfaceBiome(worldX, worldY, worldZ);
|
BiomeData surfaceBiome = this.terrainModel.getSurfaceBiome(worldX, worldY, worldZ);
|
||||||
@ -142,7 +139,9 @@ public class TestGenerationChunkGenerator implements ChunkGenerator {
|
|||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} catch(Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
rVal = new ServerTerrainChunk(worldX, worldY, worldZ, weights, values);
|
rVal = new ServerTerrainChunk(worldX, worldY, worldZ, weights, values);
|
||||||
Globals.profiler.endCpuSample();
|
Globals.profiler.endCpuSample();
|
||||||
return rVal;
|
return rVal;
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.server.terrain.diskmap.ChunkDiskMap;
|
import electrosphere.server.terrain.diskmap.ChunkDiskMap;
|
||||||
import electrosphere.server.terrain.generation.interfaces.ChunkGenerator;
|
import electrosphere.server.terrain.generation.interfaces.ChunkGenerator;
|
||||||
|
|
||||||
@ -95,6 +96,7 @@ public class ChunkGenerationThread implements Runnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
ServerTerrainChunk chunk = null;
|
ServerTerrainChunk chunk = null;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
try {
|
||||||
while(chunk == null && i < MAX_TIME_TO_WAIT && Globals.threadManager.shouldKeepRunning()){
|
while(chunk == null && i < MAX_TIME_TO_WAIT && Globals.threadManager.shouldKeepRunning()){
|
||||||
if(chunkCache.containsChunk(worldX,worldY,worldZ,stride)){
|
if(chunkCache.containsChunk(worldX,worldY,worldZ,stride)){
|
||||||
chunk = chunkCache.get(worldX, worldY, worldZ, stride);
|
chunk = chunkCache.get(worldX, worldY, worldZ, stride);
|
||||||
@ -126,6 +128,9 @@ public class ChunkGenerationThread implements Runnable {
|
|||||||
throw new Error("Failed to resolve chunk!");
|
throw new Error("Failed to resolve chunk!");
|
||||||
}
|
}
|
||||||
this.onLoad.accept(chunk);
|
this.onLoad.accept(chunk);
|
||||||
|
} catch (Error e){
|
||||||
|
LoggerInterface.loggerEngine.ERROR(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -127,11 +127,13 @@ public class TerrainModel {
|
|||||||
TerrainModel rVal = new TerrainModel();
|
TerrainModel rVal = new TerrainModel();
|
||||||
rVal.discreteArrayDimension = TestGenerationChunkGenerator.GENERATOR_REALM_SIZE;
|
rVal.discreteArrayDimension = TestGenerationChunkGenerator.GENERATOR_REALM_SIZE;
|
||||||
rVal.dynamicInterpolationRatio = 1;
|
rVal.dynamicInterpolationRatio = 1;
|
||||||
rVal.biome = new short[2][2];
|
int macroDataImageScale = TestGenerationChunkGenerator.GENERATOR_REALM_SIZE / DEFAULT_MACRO_DATA_SCALE + 1;
|
||||||
rVal.biome[0][0] = TestGenerationChunkGenerator.DEFAULT_BIOME_INDEX;
|
rVal.biome = new short[macroDataImageScale][macroDataImageScale];
|
||||||
rVal.biome[1][0] = TestGenerationChunkGenerator.DEFAULT_BIOME_INDEX;
|
for(int x = 0; x < macroDataImageScale; x++){
|
||||||
rVal.biome[0][1] = TestGenerationChunkGenerator.DEFAULT_BIOME_INDEX;
|
for(int z = 0; z < macroDataImageScale; z++){
|
||||||
rVal.biome[1][1] = TestGenerationChunkGenerator.DEFAULT_BIOME_INDEX;
|
rVal.biome[x][z] = TestGenerationChunkGenerator.DEFAULT_BIOME_INDEX;
|
||||||
|
}
|
||||||
|
}
|
||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user