ChunkManager

Undocumented in source.

Members

Functions

addCurrentSnapshotUser
TimestampType addCurrentSnapshotUser(ChunkWorldPos cwp, ubyte layer)

Returns timestamp of current chunk snapshot. Store this timestamp to use in removeSnapshotUser

clearModifiedChunks
void clearModifiedChunks()

Used on client to clear modified chunks instead of saving them.

commitSnapshots
void commitSnapshots(TimestampType currentTime)

called at the end of tick

getChunkSnapshot
Nullable!ChunkLayerSnap getChunkSnapshot(ChunkWorldPos cwp, ubyte layer, Flag!"Uncompress" uncompress)

returned value isNull if chunk is not loaded/added If uncompress is Yes then tries to convert snapshot to uncompressed. If has users, then compressed snapshot is returned.

getModifiedChunks
HashSet!ChunkWorldPos getModifiedChunks()
Undocumented in source. Be warned that the author may not have intended to support it.
getOrCreateWriteBuffer
WriteBuffer* getOrCreateWriteBuffer(ChunkWorldPos cwp, ubyte layer, WriteBufferPolicy policy)

Returns writeable copy of current chunk snapshot. This buffer is valid until commit. After commit this buffer becomes next immutable snapshot. Returns null if chunk is not added and/or not loaded. If write buffer was not yet created then it is created based on policy. BUG: returned pointer points inside hash table. If new write buffer is added hash table can reallocate. Do not use more than one write buffer at a time. Reallocation can prevent changes to buffers obtained earlier than reallocation to be invisible.

handleCurrentSnapCommit
void handleCurrentSnapCommit(ChunkWorldPos cwp, ubyte layer, ChunkLayerSnap currentSnapshot)
Undocumented in source. Be warned that the author may not have intended to support it.
isChunkAdded
bool isChunkAdded(ChunkWorldPos cwp)
Undocumented in source. Be warned that the author may not have intended to support it.
isChunkLoaded
bool isChunkLoaded(ChunkWorldPos cwp)
Undocumented in source. Be warned that the author may not have intended to support it.
onSnapshotLoaded
void onSnapshotLoaded(LoadedChunk chunk, bool needsSave)

Internal. Called by code which loads chunks from storage. LoadedChunk is a type that has following memeber: ChunkHeaderItem getHeader() ChunkLayerItem getLayer()

onSnapshotSaved
void onSnapshotSaved(SavedChunk chunk)

Internal. Called by code which saves chunks to storage. SavedChunk is a type that has following memeber: ChunkHeaderItem getHeader() ChunkLayerTimestampItem getLayerTimestamp()

removeSnapshotUser
void removeSnapshotUser(ChunkWorldPos cwp, TimestampType timestamp, ubyte layer)

Generic removal of snapshot user. Removes chunk if numUsers == 0. Use this to remove added snapshot user. Use timestamp returned from addCurrentSnapshotUser.

save
void save()

Performs save of all modified chunks. Modified chunks are those that were committed. Perform save right after commit.

setExternalChunkObservers
void setExternalChunkObservers(ChunkWorldPos cwp, size_t numExternalObservers)

Sets number of users of chunk at cwp. If total chunk users if greater than zero, then chunk is loaded, if equal to zero, chunk will be unloaded.

setup
void setup(ubyte _numLayers)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

endChunkSave
void delegate(size_t headerPos, ChunkHeaderItem header) endChunkSave;
Undocumented in source.
isChunkSavingEnabled
bool isChunkSavingEnabled;
Undocumented in source.
isLoadCancelingEnabled
bool isLoadCancelingEnabled;

Set to true on client to cancel load on unload

loadChunkHandler
void delegate(ChunkWorldPos) loadChunkHandler;
Undocumented in source.
numLayers
ubyte numLayers;
Undocumented in source.
onChunkAddedHandlers
void delegate(ChunkWorldPos)[] onChunkAddedHandlers;
Undocumented in source.
onChunkLoadedHandler
void delegate(ChunkWorldPos) onChunkLoadedHandler;
Undocumented in source.
onChunkRemovedHandlers
void delegate(ChunkWorldPos)[] onChunkRemovedHandlers;
Undocumented in source.
pushLayer
void delegate(ChunkLayerItem layer) pushLayer;
Undocumented in source.
startChunkSave
size_t delegate() startChunkSave;
Undocumented in source.
totalLayerDataBytes
long totalLayerDataBytes;
Undocumented in source.

Meta