From a5a669da90f432a8607372424a24200e613dd94f Mon Sep 17 00:00:00 2001 From: austin Date: Sun, 25 Feb 2024 22:11:41 -0500 Subject: [PATCH] Fix arena mode infinite load --- docs/src/debug/LoadingHalting.md | 13 +++++++++++++ .../client/terrain/cells/DrawCell.java | 6 ++++-- .../client/terrain/cells/DrawCellManager.java | 11 ++++++----- .../game/server/world/ServerWorldData.java | 2 +- .../net/client/protocol/TerrainProtocol.java | 1 + src/main/java/electrosphere/net/server/Server.java | 7 ++++--- 6 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 docs/src/debug/LoadingHalting.md diff --git a/docs/src/debug/LoadingHalting.md b/docs/src/debug/LoadingHalting.md new file mode 100644 index 00000000..6e7eff1c --- /dev/null +++ b/docs/src/debug/LoadingHalting.md @@ -0,0 +1,13 @@ +# Debug Loading Halting + +A very common issue is that the loading for the client never completes for a certain gamemode. +The goal of this doc is to track causes for this so that it can be debugged faster in the future. +(Hint, it's probably under initDrawCellManager in ClientLoading.java) + + +### 02-25-2024 +Arena was not loading because handling of edge-of-world chunks was not being handled correctly +for a world of 2x2x2, when loading the chunk at (1,0,0) you need data for chunk (2,0,0) +(2,0,0) is out of bounds of the world size, but the drawcellmanager would not mark the chunk data as present because it wasn't properly checking for bounds +This was fixed by properly checking for bounds in drawcellmanager; however, it then started failing to fetch data for (2,0,0) and NPEing +Fixed by guarding in the method that generates chunk data \ No newline at end of file diff --git a/src/main/java/electrosphere/client/terrain/cells/DrawCell.java b/src/main/java/electrosphere/client/terrain/cells/DrawCell.java index 3904795d..fd44253c 100644 --- a/src/main/java/electrosphere/client/terrain/cells/DrawCell.java +++ b/src/main/java/electrosphere/client/terrain/cells/DrawCell.java @@ -215,8 +215,10 @@ public class DrawCell { worldPos.z + 1 < Globals.clientWorldData.getWorldDiscreteSize() ){ currentChunk = Globals.clientTerrainManager.getChunkDataAtWorldPoint(worldPos.x + 1, worldPos.y + 1, worldPos.z + 1); - weights[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = currentChunk.getWeight(0, 0, 0); - types[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = currentChunk.getType(0, 0, 0); + if(currentChunk != null){ + weights[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = currentChunk.getWeight(0, 0, 0); + types[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = currentChunk.getType(0, 0, 0); + } } else { weights[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = 0; types[ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE][ChunkData.CHUNK_SIZE] = 0; diff --git a/src/main/java/electrosphere/client/terrain/cells/DrawCellManager.java b/src/main/java/electrosphere/client/terrain/cells/DrawCellManager.java index 4812a01b..4f7c4240 100644 --- a/src/main/java/electrosphere/client/terrain/cells/DrawCellManager.java +++ b/src/main/java/electrosphere/client/terrain/cells/DrawCellManager.java @@ -165,13 +165,14 @@ public class DrawCellManager { for(int k = 0; k < 2; k++){ Vector3i posToCheck = new Vector3i(worldPos).add(i,j,k); if(worldPos.x >= 0 && - worldPos.x < Globals.clientWorldData.getWorldDiscreteSize() && - worldPos.y >= 0 && - worldPos.y < Globals.clientWorldData.getWorldDiscreteSize() && - worldPos.z >= 0 && - worldPos.z < Globals.clientWorldData.getWorldDiscreteSize() && + posToCheck.x < Globals.clientWorldData.getWorldDiscreteSize() && + posToCheck.y >= 0 && + posToCheck.y < Globals.clientWorldData.getWorldDiscreteSize() && + posToCheck.z >= 0 && + posToCheck.z < Globals.clientWorldData.getWorldDiscreteSize() && !containsChunkDataAtWorldPoint(posToCheck.x,posToCheck.y,posToCheck.z) ){ + containsChunkDataAtWorldPoint(posToCheck.x,posToCheck.y,posToCheck.z); containsNecessaryChunks = false; } } diff --git a/src/main/java/electrosphere/game/server/world/ServerWorldData.java b/src/main/java/electrosphere/game/server/world/ServerWorldData.java index dd1c073b..de0240e4 100644 --- a/src/main/java/electrosphere/game/server/world/ServerWorldData.java +++ b/src/main/java/electrosphere/game/server/world/ServerWorldData.java @@ -57,7 +57,7 @@ public class ServerWorldData { rVal.worldMaxPoint = new Vector3f(200,0,200); rVal.dynamicInterpolationRatio = 100; rVal.worldSizeDiscrete = 2; - rVal.worldSizeDiscreteVertical = 1; + rVal.worldSizeDiscreteVertical = 2; rVal.randomDampener = 0.0f; rVal.isArena = true; return rVal; diff --git a/src/main/java/electrosphere/net/client/protocol/TerrainProtocol.java b/src/main/java/electrosphere/net/client/protocol/TerrainProtocol.java index 8cfdaf78..9a3c8028 100644 --- a/src/main/java/electrosphere/net/client/protocol/TerrainProtocol.java +++ b/src/main/java/electrosphere/net/client/protocol/TerrainProtocol.java @@ -17,6 +17,7 @@ public class TerrainProtocol { protected static void handleTerrainMessage(TerrainMessage message){ switch(message.getMessageSubtype()){ case RESPONSEMETADATA: + System.out.println(message.getworldSizeDiscrete()); Globals.clientWorldData = new ClientWorldData( //Vector3f worldMinPoint, Vector3f worldMaxPoint, int dynamicInterpolationRatio, float randomDampener, int worldDiscreteSize new Vector3f(message.getworldMinX(),0,message.getworldMinY()), diff --git a/src/main/java/electrosphere/net/server/Server.java b/src/main/java/electrosphere/net/server/Server.java index 12bfa215..c4abdeac 100644 --- a/src/main/java/electrosphere/net/server/Server.java +++ b/src/main/java/electrosphere/net/server/Server.java @@ -2,6 +2,7 @@ package electrosphere.net.server; import electrosphere.engine.Globals; import electrosphere.engine.Main; +import electrosphere.logger.LoggerInterface; import electrosphere.net.NetUtils; import electrosphere.net.parser.net.message.NetworkMessage; import electrosphere.server.saves.SaveUtils; @@ -54,10 +55,10 @@ public class Server implements Runnable{ NetUtils.setPort(serverSocket.getLocalPort()); } } catch(BindException ex){ - System.err.println("Failed to bind server socket!"); + LoggerInterface.loggerNetworking.ERROR("Failed to bind server socket!",ex); ex.printStackTrace(); } catch (IOException ex) { - System.err.println("Failed to start server socket!"); + LoggerInterface.loggerNetworking.ERROR("Failed to start server socket!",ex); ex.printStackTrace(); System.exit(1); } @@ -69,7 +70,7 @@ public class Server implements Runnable{ clientMap.put(newSocket.getInetAddress().getHostAddress(), newClient); new Thread(newClient).start(); } catch (IOException ex) { - System.err.println("Socket error on client socket!"); + LoggerInterface.loggerNetworking.ERROR("Socket error on client socket!",ex); } } }