1
0

cChunk::SetAlwaysTicked implies cChunk::stay (#3361)

This commit is contained in:
LogicParrot 2016-10-09 15:46:09 +03:00 committed by GitHub
parent cab09f54d3
commit 1e8cae6415
4 changed files with 5 additions and 3 deletions

View File

@ -16211,7 +16211,7 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
Type = "boolean",
},
},
Notes = "Sets the chunk to always be ticked even when it doesn't contain any clients. IsAlwaysTicked set to true turns forced ticking on, set to false turns it off. Every call with 'true' should be paired with a later call with 'false', otherwise the ticking won't stop. Multiple actions can request ticking independently, the ticking will continue until the last call with 'false'. Note that when the chunk unloads, it loses the value of this flag.",
Notes = "Sets the chunk to always be ticked and loaded even when it doesn't contain any clients. IsAlwaysTicked set to true turns forced ticking on, set to false turns it off. Every call with 'true' should be paired with a later call with 'false', otherwise the ticking won't stop. Multiple actions can request ticking independently, the ticking will continue until the last call with 'false'." },
},
SetCommandBlockCommand =
{

View File

@ -1728,10 +1728,12 @@ void cChunk::SetAlwaysTicked(bool a_AlwaysTicked)
if (a_AlwaysTicked)
{
m_AlwaysTicked += 1;
Stay(a_AlwaysTicked);
}
else
{
m_AlwaysTicked -= 1;
Stay(a_AlwaysTicked);
}
}

View File

@ -475,7 +475,7 @@ public:
/** Increments (a_AlwaysTicked == true) or decrements (false) the m_AlwaysTicked counter.
If the m_AlwaysTicked counter is greater than zero, the chunk is ticked in the tick-thread regardless of
whether it has any clients or not.
whether it has any clients or not. When this is set, the chunk never unloads.
This function allows nesting and task-concurrency (multiple separate tasks can request ticking and as long
as at least one requests is active the chunk will be ticked). */
void SetAlwaysTicked(bool a_AlwaysTicked);

View File

@ -2762,7 +2762,7 @@ void cChunkMap::QueueTickBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
void cChunkMap::SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked)
{
cCSLock Lock(m_CSChunks);
cChunkPtr Chunk = GetChunkNoLoad(a_ChunkX, a_ChunkZ);
cChunkPtr Chunk = GetChunk(a_ChunkX, a_ChunkZ);
if (Chunk != nullptr)
{
Chunk->SetAlwaysTicked(a_AlwaysTicked);