remove requested blocking
This commit is contained in:
parent
e14c8ec68a
commit
db2886c0c7
@ -25,11 +25,6 @@ public class ClientTerrainCache {
|
|||||||
//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
|
||||||
* @param cacheSize The capacity of the cache
|
* @param cacheSize The capacity of the cache
|
||||||
@ -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));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,33 +113,4 @@ public class ClientTerrainCache {
|
|||||||
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,7 +192,6 @@ 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,
|
||||||
@ -200,7 +199,6 @@ public class ClientTerrainManager {
|
|||||||
stride
|
stride
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks that the cache contains chunk data at a real-space coordinate
|
* Checks that the cache contains chunk data at a real-space coordinate
|
||||||
@ -288,12 +286,4 @@ public class ClientTerrainManager {
|
|||||||
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