05-04-2015, 12:27 AM
There's a slight difference between Lua API's cWorld:ChunkStay() function, and the C++'s cChunkStay object:
cChunkStay object basically locks chunks in memory - a chunk that is listed in any active cChunkStay will not get unloaded. When the cChunkStay object is deactivated / destroyed, the chunk is released from this lock, it can be unloaded again. If a chunk is part of multiple cChunkStays, all of them need to be deactivated before the chunk is allowed to unload.
The cWorld:ChunkStay API function queues all the specified chunks to be loaded / generated, and then calls the specified callback; as soon as the callback returns, the chunks are no longer locked in memory and can be unloaded.
cChunkStay object basically locks chunks in memory - a chunk that is listed in any active cChunkStay will not get unloaded. When the cChunkStay object is deactivated / destroyed, the chunk is released from this lock, it can be unloaded again. If a chunk is part of multiple cChunkStays, all of them need to be deactivated before the chunk is allowed to unload.
The cWorld:ChunkStay API function queues all the specified chunks to be loaded / generated, and then calls the specified callback; as soon as the callback returns, the chunks are no longer locked in memory and can be unloaded.