remove requested blocking
This commit is contained in:
parent
e14c8ec68a
commit
db2886c0c7
@ -24,11 +24,6 @@ public class ClientTerrainCache {
|
|||||||
List<Long> cacheList = new CopyOnWriteArrayList<Long>();
|
List<Long> cacheList = new CopyOnWriteArrayList<Long>();
|
||||||
//A map of chunk to its world position
|
//A map of chunk to its world position
|
||||||
Map<ChunkData,Vector3i> chunkPositionMap = new ConcurrentHashMap<ChunkData,Vector3i>();
|
Map<ChunkData,Vector3i> chunkPositionMap = new ConcurrentHashMap<ChunkData,Vector3i>();
|
||||||
|
|
||||||
/**
|
|
||||||
* The map tracking chunks that have been requested
|
|
||||||
*/
|
|
||||||
Map<Long,Boolean> requestedChunks = new ConcurrentHashMap<Long,Boolean>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
@ -50,9 +45,7 @@ public class ClientTerrainCache {
|
|||||||
chunkPositionMap.put(chunkData,new Vector3i(worldX,worldY,worldZ));
|
chunkPositionMap.put(chunkData,new Vector3i(worldX,worldY,worldZ));
|
||||||
while(cacheList.size() > cacheSize){
|
while(cacheList.size() > cacheSize){
|
||||||
Long currentChunk = cacheList.remove(0);
|
Long currentChunk = cacheList.remove(0);
|
||||||
ChunkData data = cacheMap.remove(currentChunk);
|
cacheMap.remove(currentChunk);
|
||||||
Vector3i worldPos = data.getWorldPos();
|
|
||||||
requestedChunks.remove(getKey(worldPos.x,worldPos.y,worldPos.z));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,34 +112,5 @@ public class ClientTerrainCache {
|
|||||||
public Vector3i getChunkPosition(ChunkData chunk){
|
public Vector3i getChunkPosition(ChunkData chunk){
|
||||||
return chunkPositionMap.get(chunk);
|
return chunkPositionMap.get(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the number of cells that have been requested
|
|
||||||
* @return The number of cells that have been requested
|
|
||||||
*/
|
|
||||||
public int getRequestedCellCount(){
|
|
||||||
return this.requestedChunks.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a chunk has been requested or not
|
|
||||||
* @param worldX The x coordinate in the world
|
|
||||||
* @param worldY The y coordinate in the world
|
|
||||||
* @param worldZ The z coordinate in the world
|
|
||||||
* @return true if it has been requested, false otherwise
|
|
||||||
*/
|
|
||||||
public boolean hasRequested(int worldX, int worldY, int worldZ){
|
|
||||||
return this.requestedChunks.containsKey(getKey(worldX, worldY, worldZ));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Marks a chunk as requested
|
|
||||||
* @param worldX The x coordinate in the world
|
|
||||||
* @param worldY The y coordinate in the world
|
|
||||||
* @param worldZ The z coordinate in the world
|
|
||||||
*/
|
|
||||||
public void markAsRequested(int worldX, int worldY, int worldZ){
|
|
||||||
this.requestedChunks.put(getKey(worldX, worldY, worldZ),true);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -192,14 +192,12 @@ public class ClientTerrainManager {
|
|||||||
* @param stride The stride of the data
|
* @param stride The stride of the data
|
||||||
*/
|
*/
|
||||||
public void requestChunk(int worldX, int worldY, int worldZ, int stride){
|
public void requestChunk(int worldX, int worldY, int worldZ, int stride){
|
||||||
if(!this.terrainCache.hasRequested(worldX, worldY, worldZ)){
|
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestReducedChunkDataMessage(
|
||||||
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestReducedChunkDataMessage(
|
worldX,
|
||||||
worldX,
|
worldY,
|
||||||
worldY,
|
worldZ,
|
||||||
worldZ,
|
stride
|
||||||
stride
|
));
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -287,13 +285,5 @@ public class ClientTerrainManager {
|
|||||||
public Vector3i getPositionOfChunk(ChunkData chunk){
|
public Vector3i getPositionOfChunk(ChunkData chunk){
|
||||||
return terrainCache.getChunkPosition(chunk);
|
return terrainCache.getChunkPosition(chunk);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the number of chunks that have been requested
|
|
||||||
* @return The number of chunks
|
|
||||||
*/
|
|
||||||
public int getRequestedCellCount(){
|
|
||||||
return this.terrainCache.getRequestedCellCount();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -300,7 +300,7 @@ public class ClientLoading {
|
|||||||
while(blockForInit && Globals.clientDrawCellManager.updatedLastFrame() && Globals.threadManager.shouldKeepRunning()){
|
while(blockForInit && Globals.clientDrawCellManager.updatedLastFrame() && Globals.threadManager.shouldKeepRunning()){
|
||||||
i++;
|
i++;
|
||||||
if(i % DRAW_CELL_UPDATE_RATE == 0){
|
if(i % DRAW_CELL_UPDATE_RATE == 0){
|
||||||
WindowUtils.updateLoadingWindow("WAITING ON SERVER TO SEND TERRAIN (" + Globals.clientTerrainManager.getAllChunks().size() + "/" + Globals.clientTerrainManager.getRequestedCellCount() + ")");
|
WindowUtils.updateLoadingWindow("WAITING ON SERVER TO SEND TERRAIN (" + Globals.clientTerrainManager.getAllChunks().size() + ")");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
TimeUnit.MILLISECONDS.sleep(10);
|
TimeUnit.MILLISECONDS.sleep(10);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user