Remove unneeded MarkDirty, SendToClients parameters of SetMeta
Partially reverts #3129, whose addition of these parameters was superseded by #3149 that fixed generated leaves' metas. References: https://github.com/cuberite/cuberite/pull/4417#discussion_r334950513 e0bcd754009f16480437b2c1fa5e7fbedab31496
This commit is contained in:
parent
ecd8f0c0de
commit
b084f1f13f
@ -2801,18 +2801,8 @@ function OnAllChunksAvailable()</pre> All return values from the callbacks are i
|
||||
Name = "BlockMeta",
|
||||
Type = "number",
|
||||
},
|
||||
{
|
||||
Name = "ShouldMarkChunkDirty",
|
||||
Type = "boolean",
|
||||
IsOptional = true,
|
||||
},
|
||||
{
|
||||
Name = "ShouldSendToClients",
|
||||
Type = "boolean",
|
||||
IsOptional = true,
|
||||
},
|
||||
},
|
||||
Notes = "Sets the meta for the block at the specified coords. If ShouldMarkChunkDirty is true (default), the chunk is marked dirty and will be saved later on. If ShouldSendToClients is true (default), the change is broadcast to all clients who have the chunk loaded, if false, the change is kept server-side only.",
|
||||
Notes = "Sets the meta for the block at the specified coords.",
|
||||
},
|
||||
{
|
||||
Params =
|
||||
|
@ -47,7 +47,7 @@ public:
|
||||
|
||||
const auto SoundToPlay = (m_BlockType == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_on" : "block.wood_button.click_on";
|
||||
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta, false);
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockPos, Meta);
|
||||
a_WorldInterface.WakeUpSimulators(a_BlockPos);
|
||||
a_WorldInterface.GetBroadcastManager().BroadcastSoundEffect(SoundToPlay, a_BlockPos, 0.5f, 0.6f, a_Player.GetClientHandle());
|
||||
|
||||
@ -185,7 +185,7 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
a_World.SetBlockMeta(Pos, Meta | 0x08, false);
|
||||
a_World.SetBlockMeta(Pos, Meta | 0x08);
|
||||
a_World.WakeUpSimulators(Pos);
|
||||
|
||||
// sound name is ok to be wood, because only wood gets triggered by arrow
|
||||
@ -228,7 +228,7 @@ private:
|
||||
// Block hasn't change in the meantime; release it
|
||||
const auto SoundToPlayOnRelease = (Type == E_BLOCK_STONE_BUTTON) ? "block.stone_button.click_off" : "block.wood_button.click_off";
|
||||
|
||||
a_World.SetBlockMeta(a_Position, Meta & 0x07, false);
|
||||
a_World.SetBlockMeta(a_Position, Meta & 0x07);
|
||||
a_World.WakeUpSimulators(a_Position);
|
||||
a_World.BroadcastSoundEffect(SoundToPlayOnRelease, a_Position, 0.5f, 0.5f);
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ public:
|
||||
// Set bit 0x08, so this block gets checked for decay:
|
||||
if ((meta & 0x08) == 0)
|
||||
{
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, meta | 0x8, true, false);
|
||||
a_ChunkInterface.SetBlockMeta(a_BlockPos.x, a_BlockPos.y, a_BlockPos.z, meta | 0x8);
|
||||
}
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ public:
|
||||
if (HasNearLog(Area, worldPos))
|
||||
{
|
||||
// Wood found, the leaves stay; unset the check bit
|
||||
a_Chunk.SetMeta(a_RelPos, Meta ^ 0x08, true, false);
|
||||
a_Chunk.SetMeta(a_RelPos, Meta ^ 0x08);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,9 @@ void cChunkInterface::SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBL
|
||||
|
||||
|
||||
|
||||
void cChunkInterface::SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty, bool a_ShouldInformClient)
|
||||
void cChunkInterface::SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData)
|
||||
{
|
||||
m_ChunkMap->SetBlockMeta(a_BlockPos, a_MetaData, a_ShouldMarkDirty, a_ShouldInformClient);
|
||||
m_ChunkMap->SetBlockMeta(a_BlockPos, a_MetaData);
|
||||
}
|
||||
|
||||
|
||||
|
@ -45,19 +45,15 @@ public:
|
||||
}
|
||||
|
||||
/** Sets the meta for the specified block, while keeping the blocktype.
|
||||
If a_ShouldMarkDirty is true, the chunk is marked dirty by this change (false is used eg. by water turning still).
|
||||
If a_ShouldInformClients is true, the change is broadcast to all clients of the chunk.
|
||||
Ignored if the chunk is invalid. */
|
||||
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty = true, bool a_ShouldInformClient = true);
|
||||
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData);
|
||||
|
||||
/** OBSOLETE, Use the Vector3-based overload instead.
|
||||
Sets the meta for the specified block, while keeping the blocktype.
|
||||
If a_ShouldMarkDirty is true, the chunk is marked dirty by this change (false is used eg. by water turning still).
|
||||
If a_ShouldInformClients is true, the change is broadcast to all clients of the chunk.
|
||||
Ignored if the chunk is invalid. */
|
||||
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty = true, bool a_ShouldInformClient = true)
|
||||
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
|
||||
{
|
||||
return SetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}, a_MetaData, a_ShouldMarkDirty, a_ShouldInformClient);
|
||||
return SetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}, a_MetaData);
|
||||
}
|
||||
|
||||
/** Sets the block at the specified coords to the specified value.
|
||||
|
@ -1290,7 +1290,7 @@ void cChunk::SetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_Blo
|
||||
|
||||
|
||||
|
||||
void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients)
|
||||
void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
|
||||
{
|
||||
ASSERT(!((a_RelX < 0) || (a_RelX >= Width) || (a_RelY < 0) || (a_RelY >= Height) || (a_RelZ < 0) || (a_RelZ >= Width)));
|
||||
|
||||
@ -1319,15 +1319,12 @@ void cChunk::FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockT
|
||||
|
||||
// Queue block to be sent only if ...
|
||||
if (
|
||||
a_SendToClients && // ... we are told to do so AND ...
|
||||
!( // ... the old and new blocktypes AREN'T leaves (because the client doesn't need meta updates)
|
||||
((OldBlockType == E_BLOCK_LEAVES) && (a_BlockType == E_BLOCK_LEAVES)) ||
|
||||
((OldBlockType == E_BLOCK_NEW_LEAVES) && (a_BlockType == E_BLOCK_NEW_LEAVES))
|
||||
) && // ... AND ...
|
||||
(
|
||||
!( // ... the old and new blocktypes AREN'T leaves (because the client doesn't need meta updates)
|
||||
((OldBlockType == E_BLOCK_LEAVES) && (a_BlockType == E_BLOCK_LEAVES)) ||
|
||||
((OldBlockType == E_BLOCK_NEW_LEAVES) && (a_BlockType == E_BLOCK_NEW_LEAVES))
|
||||
) && // ... AND ...
|
||||
(
|
||||
(OldBlockMeta != a_BlockMeta) || (!ReplacingLiquids)
|
||||
)
|
||||
(OldBlockMeta != a_BlockMeta) || (!ReplacingLiquids)
|
||||
)
|
||||
)
|
||||
{
|
||||
|
22
src/Chunk.h
22
src/Chunk.h
@ -157,10 +157,10 @@ public:
|
||||
void SetBlock(Vector3i a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||
// SetBlock() does a lot of work (heightmap, tickblocks, blockentities) so a BlockIdx version doesn't make sense
|
||||
|
||||
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc.
|
||||
void FastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta, bool a_SendToClients = true)
|
||||
void FastSetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta); // Doesn't force block updates on neighbors, use for simple changes such as grass growing etc.
|
||||
void FastSetBlock(Vector3i a_RelPos, BLOCKTYPE a_BlockType, BLOCKTYPE a_BlockMeta)
|
||||
{
|
||||
FastSetBlock(a_RelPos.x, a_RelPos.y, a_RelPos.z, a_BlockType, a_BlockMeta, a_SendToClients);
|
||||
FastSetBlock(a_RelPos.x, a_RelPos.y, a_RelPos.z, a_BlockType, a_BlockMeta);
|
||||
}
|
||||
|
||||
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const { return m_ChunkData.GetBlock({ a_RelX, a_RelY, a_RelZ }); }
|
||||
@ -376,27 +376,21 @@ public:
|
||||
|
||||
NIBBLETYPE GetMeta(Vector3i a_RelPos) const { return m_ChunkData.GetMeta(a_RelPos); }
|
||||
|
||||
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta, bool a_ShouldMarkDirty = true, bool a_ShouldInformClients = true)
|
||||
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta)
|
||||
{
|
||||
SetMeta({ a_RelX, a_RelY, a_RelZ }, a_Meta, a_ShouldMarkDirty, a_ShouldInformClients);
|
||||
SetMeta({ a_RelX, a_RelY, a_RelZ }, a_Meta);
|
||||
}
|
||||
|
||||
/** Set a meta value, with the option of not informing the client and / or not marking dirty.
|
||||
Used for setting metas that are of little value for saving to disk and / or for sending to the client,
|
||||
such as leaf decay flags. */
|
||||
inline void SetMeta(Vector3i a_RelPos, NIBBLETYPE a_Meta, bool a_ShouldMarkDirty = true, bool a_ShouldInformClients = true)
|
||||
inline void SetMeta(Vector3i a_RelPos, NIBBLETYPE a_Meta)
|
||||
{
|
||||
bool hasChanged = m_ChunkData.SetMeta(a_RelPos, a_Meta);
|
||||
if (hasChanged)
|
||||
{
|
||||
if (a_ShouldMarkDirty)
|
||||
{
|
||||
MarkDirty();
|
||||
}
|
||||
if (a_ShouldInformClients)
|
||||
{
|
||||
m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelPos.x, a_RelPos.y, a_RelPos.z, GetBlock(a_RelPos), a_Meta));
|
||||
}
|
||||
MarkDirty();
|
||||
m_PendingSendBlocks.push_back(sSetBlock(m_PosX, m_PosZ, a_RelPos.x, a_RelPos.y, a_RelPos.z, GetBlock(a_RelPos), a_Meta));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -562,7 +562,7 @@ NIBBLETYPE cChunkMap::GetBlockBlockLight(Vector3i a_BlockPos)
|
||||
|
||||
|
||||
|
||||
void cChunkMap::SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_BlockMeta, bool a_ShouldMarkDirty, bool a_ShouldInformClients)
|
||||
void cChunkMap::SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_BlockMeta)
|
||||
{
|
||||
auto chunkPos = cChunkDef::BlockToChunk(a_BlockPos);
|
||||
auto relPos = cChunkDef::AbsoluteToRelative(a_BlockPos, chunkPos);
|
||||
@ -572,7 +572,7 @@ void cChunkMap::SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_BlockMeta, bool a
|
||||
auto chunk = GetChunk(chunkPos.m_ChunkX, chunkPos.m_ChunkZ);
|
||||
if ((chunk != nullptr) && chunk->IsValid())
|
||||
{
|
||||
chunk->SetMeta(relPos, a_BlockMeta, a_ShouldMarkDirty, a_ShouldInformClients);
|
||||
chunk->SetMeta(relPos, a_BlockMeta);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,10 +141,8 @@ public:
|
||||
NIBBLETYPE GetBlockBlockLight(Vector3i a_BlockPos);
|
||||
|
||||
/** Sets the meta for the specified block, while keeping the blocktype.
|
||||
If a_ShouldMarkDirty is true, the chunk is marked dirty by this change (false is used eg. by water turning still).
|
||||
If a_ShouldInformClients is true, the change is broadcast to all clients of the chunk.
|
||||
Ignored if the chunk is invalid. */
|
||||
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_BlockMeta, bool a_ShouldMarkDirty, bool a_ShouldInformClients);
|
||||
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_BlockMeta);
|
||||
|
||||
void SetBlock (Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
|
||||
bool GetBlockTypeMeta (Vector3i a_BlockPos, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
|
||||
|
@ -1912,9 +1912,9 @@ void cWorld::SetBlock(Vector3i a_BlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_B
|
||||
|
||||
|
||||
|
||||
void cWorld::SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty, bool a_ShouldInformClients)
|
||||
void cWorld::SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData)
|
||||
{
|
||||
m_ChunkMap->SetBlockMeta(a_BlockPos, a_MetaData, a_ShouldMarkDirty, a_ShouldInformClients);
|
||||
m_ChunkMap->SetBlockMeta(a_BlockPos, a_MetaData);
|
||||
}
|
||||
|
||||
|
||||
|
10
src/World.h
10
src/World.h
@ -456,19 +456,15 @@ public:
|
||||
}
|
||||
|
||||
/** Sets the meta for the specified block, while keeping the blocktype.
|
||||
If a_ShouldMarkDirty is true, the chunk is marked dirty by this change (false is used eg. by water turning still).
|
||||
If a_ShouldInformClients is true, the change is broadcast to all clients of the chunk.
|
||||
Ignored if the chunk is invalid. */
|
||||
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty = true, bool a_ShouldInformClients = true);
|
||||
void SetBlockMeta(Vector3i a_BlockPos, NIBBLETYPE a_MetaData);
|
||||
|
||||
/** OBSOLETE, use the Vector3-based overload instead.
|
||||
Sets the meta for the specified block, while keeping the blocktype.
|
||||
If a_ShouldMarkDirty is true, the chunk is marked dirty by this change (false is used eg. by water turning still).
|
||||
If a_ShouldInformClients is true, the change is broadcast to all clients of the chunk.
|
||||
Ignored if the chunk is invalid. */
|
||||
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData, bool a_ShouldMarkDirty = true, bool a_ShouldInformClients = true)
|
||||
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
|
||||
{
|
||||
return SetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}, a_MetaData, a_ShouldMarkDirty, a_ShouldInformClients);
|
||||
return SetBlockMeta({a_BlockX, a_BlockY, a_BlockZ}, a_MetaData);
|
||||
}
|
||||
|
||||
/** Returns the sky light value at the specified block position.
|
||||
|
Loading…
Reference in New Issue
Block a user