mirror of
https://github.com/smartcmd/MinecraftConsoles.git
synced 2026-05-13 04:33:52 +00:00
chunk additions
This commit is contained in:
parent
ff7c04f253
commit
6e6697dbc2
19 changed files with 1605 additions and 5 deletions
|
|
@ -12,6 +12,9 @@
|
|||
#include "..\Minecraft.World\compression.h"
|
||||
#include "..\Minecraft.World\OldChunkStorage.h"
|
||||
#include "..\Minecraft.World\Tile.h"
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
#include "..\Minecraft.Server\FourKitBridge.h"
|
||||
#endif
|
||||
|
||||
ServerChunkCache::ServerChunkCache(ServerLevel *level, ChunkStorage *storage, ChunkSource *source)
|
||||
{
|
||||
|
|
@ -152,7 +155,10 @@ LevelChunk *ServerChunkCache::create(int x, int z, bool asyncPostProcess) // 4J
|
|||
{
|
||||
EnterCriticalSection(&m_csLoadCreate);
|
||||
chunk = load(x, z);
|
||||
if (chunk == nullptr)
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
bool isNewChunk = (chunk == nullptr);
|
||||
#endif
|
||||
if (chunk == nullptr)
|
||||
{
|
||||
if (source == nullptr)
|
||||
{
|
||||
|
|
@ -231,6 +237,10 @@ LevelChunk *ServerChunkCache::create(int x, int z, bool asyncPostProcess) // 4J
|
|||
if( hasChunk( x - 1, z ) && hasChunk( x + 1, z ) && hasChunk ( x, z - 1 ) && hasChunk( x, z + 1 ) ) chunk->checkChests( this, x, z );
|
||||
|
||||
LeaveCriticalSection(&m_csLoadCreate);
|
||||
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
FourKitBridge::FireChunkLoad(level->dimension->id, x, z, isNewChunk);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -941,23 +951,30 @@ bool ServerChunkCache::tick()
|
|||
// player's tick is called to remove them from the chunk they used to be in, and add them to their current chunk. This will only be a temporary state and
|
||||
// we should be able to unload the chunk on the next call to this tick.
|
||||
if( !chunk->containsPlayer() )
|
||||
{
|
||||
{
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
if (!FourKitBridge::FireChunkUnload(level->dimension->id, chunk->x, chunk->z))
|
||||
{
|
||||
#endif
|
||||
save(chunk);
|
||||
saveEntities(chunk);
|
||||
chunk->unload(true);
|
||||
|
||||
//loadedChunks.remove(cp);
|
||||
//loadedChunkList.remove(chunk);
|
||||
auto it = std::find(m_loadedChunkList.begin(), m_loadedChunkList.end(), chunk);
|
||||
if(it != m_loadedChunkList.end()) m_loadedChunkList.erase(it);
|
||||
auto it = std::find(m_loadedChunkList.begin(), m_loadedChunkList.end(), chunk);
|
||||
if(it != m_loadedChunkList.end()) m_loadedChunkList.erase(it);
|
||||
|
||||
int ix = chunk->x + XZOFFSET;
|
||||
int iz = chunk->z + XZOFFSET;
|
||||
int idx = ix * XZSIZE + iz;
|
||||
m_unloadedCache[idx] = chunk;
|
||||
cache[idx] = nullptr;
|
||||
}
|
||||
}
|
||||
#ifdef MINECRAFT_SERVER_BUILD
|
||||
}
|
||||
#endif
|
||||
m_toDrop.pop_front();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue