From ae4c0aa4e54bc4a3c29952f27e584ad4dd31e3de Mon Sep 17 00:00:00 2001 From: austin Date: Thu, 7 Nov 2024 12:25:31 -0500 Subject: [PATCH] add request timeout mechanism --- .../terrain/cells/ClientDrawCellManager.java | 7 ++++--- .../terrain/manager/ClientTerrainManager.java | 20 ++++++++++++++++--- .../TestGenerationChunkGenerator.java | 2 +- 3 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/main/java/electrosphere/client/terrain/cells/ClientDrawCellManager.java b/src/main/java/electrosphere/client/terrain/cells/ClientDrawCellManager.java index d09385c8..b84dd2c6 100644 --- a/src/main/java/electrosphere/client/terrain/cells/ClientDrawCellManager.java +++ b/src/main/java/electrosphere/client/terrain/cells/ClientDrawCellManager.java @@ -53,7 +53,7 @@ public class ClientDrawCellManager { /** * The distance for sixteenth resolution */ - public static final double SIXTEENTH_RES_DIST = 48 * ServerTerrainChunk.CHUNK_DIMENSION; + public static final double SIXTEENTH_RES_DIST = 128 * ServerTerrainChunk.CHUNK_DIMENSION; /** * Lod value for a full res chunk @@ -237,8 +237,9 @@ public class ClientDrawCellManager { List highResFaces = this.solveHighResFace(node); //actually send requests - this.requestChunks(node, highResFaces); - cell.setHasRequested(true); + if(this.requestChunks(node, highResFaces)){ + cell.setHasRequested(true); + } Globals.profiler.endCpuSample(); updated = true; diff --git a/src/main/java/electrosphere/client/terrain/manager/ClientTerrainManager.java b/src/main/java/electrosphere/client/terrain/manager/ClientTerrainManager.java index f253cef0..a8e35170 100644 --- a/src/main/java/electrosphere/client/terrain/manager/ClientTerrainManager.java +++ b/src/main/java/electrosphere/client/terrain/manager/ClientTerrainManager.java @@ -45,7 +45,12 @@ public class ClientTerrainManager { /** * Maximum concurrent terrain requests */ - public static final int MAX_CONCURRENT_REQUESTS = 500; + public static final int MAX_CONCURRENT_REQUESTS = 500; + + /** + * Number of frames to wait before flagging a request as failed + */ + public static final int FAILED_REQUEST_THRESHOLD = 500; //The interpolation ratio of terrain public static final int INTERPOLATION_RATIO = ServerTerrainManager.SERVER_TERRAIN_MANAGER_INTERPOLATION_RATIO; @@ -70,7 +75,7 @@ public class ClientTerrainManager { /** * Tracks what outgoing requests are currently active */ - Map requestedMap = new ConcurrentHashMap(); + Map requestedMap = new ConcurrentHashMap(); /** * Constructor @@ -158,6 +163,15 @@ public class ClientTerrainManager { for(TerrainMessage message : bouncedMessages){ messageQueue.add(message); } + //evaluate if any chunks have failed to request + for(Long key : this.requestedMap.keySet()){ + int duration = this.requestedMap.get(key); + if(duration > FAILED_REQUEST_THRESHOLD){ + this.requestedMap.remove(key); + } else { + this.requestedMap.put(key,duration + 1); + } + } lock.release(); Globals.profiler.endCpuSample(); } @@ -219,7 +233,7 @@ public class ClientTerrainManager { worldZ, stride )); - this.requestedMap.put(this.getRequestKey(worldX, worldY, worldZ, stride), true); + this.requestedMap.put(this.getRequestKey(worldX, worldY, worldZ, stride), 0); rVal = true; } lock.release(); diff --git a/src/main/java/electrosphere/server/terrain/generation/TestGenerationChunkGenerator.java b/src/main/java/electrosphere/server/terrain/generation/TestGenerationChunkGenerator.java index de7bf5c4..5b65606e 100644 --- a/src/main/java/electrosphere/server/terrain/generation/TestGenerationChunkGenerator.java +++ b/src/main/java/electrosphere/server/terrain/generation/TestGenerationChunkGenerator.java @@ -24,7 +24,7 @@ public class TestGenerationChunkGenerator implements ChunkGenerator { /** * The size of the realm for testing generation */ - public static final int GENERATOR_REALM_SIZE = 64; + public static final int GENERATOR_REALM_SIZE = 512; /** * The default biome index