summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-08-26 22:45:13 +0200
committerTiger Wang <ziwei.tiger@outlook.com>2020-08-28 22:08:06 +0200
commitb084f1f13fdd73e10fe296ef7d48a3c8beb95585 (patch)
tree84f4c6dc62444de0dbf5e89436ab898143bf683b
parent1.13+: Send length-prefixed server Brand string (diff)
downloadcuberite-b084f1f13fdd73e10fe296ef7d48a3c8beb95585.tar
cuberite-b084f1f13fdd73e10fe296ef7d48a3c8beb95585.tar.gz
cuberite-b084f1f13fdd73e10fe296ef7d48a3c8beb95585.tar.bz2
cuberite-b084f1f13fdd73e10fe296ef7d48a3c8beb95585.tar.lz
cuberite-b084f1f13fdd73e10fe296ef7d48a3c8beb95585.tar.xz
cuberite-b084f1f13fdd73e10fe296ef7d48a3c8beb95585.tar.zst
cuberite-b084f1f13fdd73e10fe296ef7d48a3c8beb95585.zip
-rw-r--r--Server/Plugins/APIDump/Classes/World.lua12
-rw-r--r--src/Blocks/BlockButton.h6
-rw-r--r--src/Blocks/BlockLeaves.h4
-rw-r--r--src/Blocks/ChunkInterface.cpp4
-rw-r--r--src/Blocks/ChunkInterface.h10
-rw-r--r--src/Chunk.cpp15
-rw-r--r--src/Chunk.h22
-rw-r--r--src/ChunkMap.cpp4
-rw-r--r--src/ChunkMap.h4
-rw-r--r--src/World.cpp4
-rw-r--r--src/World.h10
11 files changed, 33 insertions, 62 deletions
diff --git a/Server/Plugins/APIDump/Classes/World.lua b/Server/Plugins/APIDump/Classes/World.lua
index 4de9c68f4..62e53ace6 100644
--- a/Server/Plugins/APIDump/Classes/World.lua
+++ b/Server/Plugins/APIDump/Classes/World.lua
@@ -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 =
diff --git a/src/Blocks/BlockButton.h b/src/Blocks/BlockButton.h
index f4994f193..aba20f8a1 100644
--- a/src/Blocks/BlockButton.h
+++ b/src/Blocks/BlockButton.h
@@ -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);
}
diff --git a/src/Blocks/BlockLeaves.h b/src/Blocks/BlockLeaves.h
index c936e0405..cd2b62743 100644
--- a/src/Blocks/BlockLeaves.h
+++ b/src/Blocks/BlockLeaves.h
@@ -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;
}
diff --git a/src/Blocks/ChunkInterface.cpp b/src/Blocks/ChunkInterface.cpp
index 15198dd37..f497b94a0 100644
--- a/src/Blocks/ChunkInterface.cpp
+++ b/src/Blocks/ChunkInterface.cpp
@@ -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);
}
diff --git a/src/Blocks/ChunkInterface.h b/src/Blocks/ChunkInterface.h
index 6ee54b17f..3017df8ab 100644
--- a/src/Blocks/ChunkInterface.h
+++ b/src/Blocks/ChunkInterface.h
@@ -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.
diff --git a/src/Chunk.cpp b/src/Chunk.cpp
index afbc3adca..1d5908c5f 100644
--- a/src/Chunk.cpp
+++ b/src/Chunk.cpp
@@ -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)
)
)
{
diff --git a/src/Chunk.h b/src/Chunk.h
index a9b5bb99a..cb258c7f8 100644
--- a/src/Chunk.h
+++ b/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));
}
}
diff --git a/src/ChunkMap.cpp b/src/ChunkMap.cpp
index dbfd07d45..5d50a96bf 100644
--- a/src/ChunkMap.cpp
+++ b/src/ChunkMap.cpp
@@ -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);
}
}
diff --git a/src/ChunkMap.h b/src/ChunkMap.h
index 3d1a7b7d3..8fc1a57f9 100644
--- a/src/ChunkMap.h
+++ b/src/ChunkMap.h
@@ -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);
diff --git a/src/World.cpp b/src/World.cpp
index 721624790..6a0864410 100644
--- a/src/World.cpp
+++ b/src/World.cpp
@@ -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);
}
diff --git a/src/World.h b/src/World.h
index 263ad6d49..c7485531c 100644
--- a/src/World.h
+++ b/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.