1
0

cWorld::SendBlockTo take player by ref

This commit is contained in:
peterbell10 2017-07-31 20:50:40 +01:00 committed by Lukas Pioch
parent ec08bf6255
commit 8eb5672920
15 changed files with 33 additions and 33 deletions

View File

@ -29,7 +29,7 @@ public:
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{ {
UNUSED(a_ChunkInterface); UNUSED(a_ChunkInterface);
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *a_Player);
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override

View File

@ -87,18 +87,18 @@ void cBlockDoorHandler::OnCancelRightClick(cChunkInterface & a_ChunkInterface, c
{ {
UNUSED(a_ChunkInterface); UNUSED(a_ChunkInterface);
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *a_Player);
NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ); NIBBLETYPE Meta = a_ChunkInterface.GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
if (Meta & 0x8) if (Meta & 0x8)
{ {
// Current block is top of the door // Current block is top of the door
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, a_Player); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, *a_Player);
} }
else else
{ {
// Current block is bottom of the door // Current block is bottom of the door
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, a_Player); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, *a_Player);
} }
} }

View File

@ -56,7 +56,7 @@ public:
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{ {
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *a_Player);
} }
virtual bool IsUseable(void) override virtual bool IsUseable(void) override

View File

@ -39,7 +39,7 @@ public:
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{ {
UNUSED(a_ChunkInterface); UNUSED(a_ChunkInterface);
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *a_Player);
} }
virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override virtual void ConvertToPickups(cItems & a_Pickups, NIBBLETYPE a_BlockMeta) override

View File

@ -104,7 +104,7 @@ public:
} }
// Sends the slab back to the client. It's to refuse a doubleslab placement. */ // Sends the slab back to the client. It's to refuse a doubleslab placement. */
a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); a_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *a_Player);
} }
/** Converts the single-slab blocktype to its equivalent double-slab blocktype */ /** Converts the single-slab blocktype to its equivalent double-slab blocktype */

View File

@ -18,7 +18,7 @@ public:
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{ {
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *a_Player);
} }
virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override virtual ColourID GetMapBaseColourID(NIBBLETYPE a_Meta) override

View File

@ -47,7 +47,7 @@ public:
virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override virtual void OnCancelRightClick(cChunkInterface & a_ChunkInterface, cWorldInterface & a_WorldInterface, cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ, eBlockFace a_BlockFace) override
{ {
UNUSED(a_ChunkInterface); UNUSED(a_ChunkInterface);
a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player); a_WorldInterface.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *a_Player);
} }
virtual bool GetPlacementBlockTypeMeta( virtual bool GetPlacementBlockTypeMeta(

View File

@ -47,7 +47,7 @@ public:
virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) = 0; virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) = 0;
/** Sends the block on those coords to the player */ /** Sends the block on those coords to the player */
virtual void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, cPlayer * a_Player) = 0; virtual void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, cPlayer & a_Player) = 0;
/** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */ /** Calls the callback for each player in the list; returns true if all players processed, false if the callback aborted by returning true */
virtual bool ForEachPlayer(cItemCallback<cPlayer> & a_Callback) = 0; virtual bool ForEachPlayer(cItemCallback<cPlayer> & a_Callback) = 0;

View File

@ -1371,7 +1371,7 @@ bool cChunkMap::DigBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer & a_Player)
{ {
int ChunkX, ChunkZ; int ChunkX, ChunkZ;
cChunkDef::AbsoluteToRelative(a_X, a_Y, a_Z, ChunkX, ChunkZ); cChunkDef::AbsoluteToRelative(a_X, a_Y, a_Z, ChunkX, ChunkZ);
@ -1380,7 +1380,7 @@ void cChunkMap::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player)
cChunkPtr Chunk = GetChunk(ChunkX, ChunkZ); cChunkPtr Chunk = GetChunk(ChunkX, ChunkZ);
if ((Chunk != nullptr) && (Chunk->IsValid())) if ((Chunk != nullptr) && (Chunk->IsValid()))
{ {
Chunk->SendBlockTo(a_X, a_Y, a_Z, a_Player->GetClientHandle()); Chunk->SendBlockTo(a_X, a_Y, a_Z, a_Player.GetClientHandle());
} }
} }

View File

@ -191,7 +191,7 @@ public:
/** Sends the block at the specified coords to the specified player. /** Sends the block at the specified coords to the specified player.
Uses a blockchange packet to send the block. Uses a blockchange packet to send the block.
If the relevant chunk isn't loaded, doesn't do anything. */ If the relevant chunk isn't loaded, doesn't do anything. */
void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, cPlayer * a_Player); void SendBlockTo(int a_BlockX, int a_BlockY, int a_BlockZ, cPlayer & a_Player);
/** Compares clients of two chunks, calls the callback accordingly */ /** Compares clients of two chunks, calls the callback accordingly */
void CompareChunkClients(int a_ChunkX1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkZ2, cClientDiffCallback & a_Callback); void CompareChunkClients(int a_ChunkX1, int a_ChunkZ1, int a_ChunkX2, int a_ChunkZ2, cClientDiffCallback & a_Callback);

View File

@ -1075,7 +1075,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
(Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockZ)) > 6)) (Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockZ)) > 6))
) )
{ {
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player);
return; return;
} }
} }
@ -1084,7 +1084,7 @@ void cClientHandle::HandleLeftClick(int a_BlockX, int a_BlockY, int a_BlockZ, eB
if (m_Player->IsFrozen() || PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, static_cast<char>(a_Status))) if (m_Player->IsFrozen() || PlgMgr->CallHookPlayerLeftClick(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, static_cast<char>(a_Status)))
{ {
// A plugin doesn't agree with the action, replace the block on the client and quit: // A plugin doesn't agree with the action, replace the block on the client and quit:
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player);
SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side. SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side.
return; return;
} }
@ -1211,7 +1211,7 @@ void cClientHandle::HandleBlockDigStarted(int a_BlockX, int a_BlockY, int a_Bloc
(Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockZ)) > 6) (Diff(m_Player->GetPosZ(), static_cast<double>(a_BlockZ)) > 6)
) )
{ {
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player);
return; return;
} }
@ -1296,8 +1296,8 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
{ {
LOGD("Break progress of player %s was less than expected: %f < %f\n", m_Player->GetName().c_str(), m_BreakProgress * 100, FASTBREAK_PERCENTAGE * 100); LOGD("Break progress of player %s was less than expected: %f < %f\n", m_Player->GetName().c_str(), m_BreakProgress * 100, FASTBREAK_PERCENTAGE * 100);
// AntiFastBreak doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows: // AntiFastBreak doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows:
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player);
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // Strange bug with doors m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, *m_Player); // Strange bug with doors
SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side. SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side.
m_Player->SendMessage("FastBreak?"); // TODO Anticheat hook m_Player->SendMessage("FastBreak?"); // TODO Anticheat hook
return; return;
@ -1310,8 +1310,8 @@ void cClientHandle::HandleBlockDigFinished(int a_BlockX, int a_BlockY, int a_Blo
if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta)) if (cRoot::Get()->GetPluginManager()->CallHookPlayerBreakingBlock(*m_Player, a_BlockX, a_BlockY, a_BlockZ, a_BlockFace, a_OldBlock, a_OldMeta))
{ {
// A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows: // A plugin doesn't agree with the breaking. Bail out. Send the block back to the client, so that it knows:
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player);
m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // Strange bug with doors m_Player->GetWorld()->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, *m_Player); // Strange bug with doors
SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side. SendPlayerPosition(); // Prevents the player from falling through the block that was temporarily broken client side.
return; return;
} }
@ -1394,15 +1394,15 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
{ {
if (cChunkDef::IsValidHeight(a_BlockY)) if (cChunkDef::IsValidHeight(a_BlockY))
{ {
World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player);
} }
if (cChunkDef::IsValidHeight(a_BlockY + 1)) if (cChunkDef::IsValidHeight(a_BlockY + 1))
{ {
World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, *m_Player); // 2 block high things
} }
if (cChunkDef::IsValidHeight(a_BlockY - 1)) if (cChunkDef::IsValidHeight(a_BlockY - 1))
{ {
World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, m_Player); // 2 block high things World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, *m_Player); // 2 block high things
} }
} }
m_Player->GetInventory().SendEquippedSlot(); m_Player->GetInventory().SendEquippedSlot();
@ -1430,15 +1430,15 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
if (cChunkDef::IsValidHeight(a_BlockY)) if (cChunkDef::IsValidHeight(a_BlockY))
{ {
World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player);
} }
if (cChunkDef::IsValidHeight(a_BlockY + 1)) if (cChunkDef::IsValidHeight(a_BlockY + 1))
{ {
World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, m_Player); // 2 block high things World->SendBlockTo(a_BlockX, a_BlockY + 1, a_BlockZ, *m_Player); // 2 block high things
} }
if (cChunkDef::IsValidHeight(a_BlockY - 1)) if (cChunkDef::IsValidHeight(a_BlockY - 1))
{ {
World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, m_Player); // 2 block high things World->SendBlockTo(a_BlockX, a_BlockY - 1, a_BlockZ, *m_Player); // 2 block high things
} }
m_Player->GetInventory().SendEquippedSlot(); m_Player->GetInventory().SendEquippedSlot();
} }
@ -1469,7 +1469,7 @@ void cClientHandle::HandleRightClick(int a_BlockX, int a_BlockY, int a_BlockZ, e
if (a_BlockFace != BLOCK_FACE_NONE) if (a_BlockFace != BLOCK_FACE_NONE)
{ {
AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace); AddFaceDirection(a_BlockX, a_BlockY, a_BlockZ, a_BlockFace);
World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, m_Player); World->SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, *m_Player);
} }
return; return;
} }

View File

@ -2733,7 +2733,7 @@ bool cPlayer::PlaceBlocks(const sSetBlockVector & a_Blocks)
// Abort - re-send all the current blocks in the a_Blocks' coords to the client: // Abort - re-send all the current blocks in the a_Blocks' coords to the client:
for (auto blk2: a_Blocks) for (auto blk2: a_Blocks)
{ {
m_World->SendBlockTo(blk2.GetX(), blk2.GetY(), blk2.GetZ(), this); m_World->SendBlockTo(blk2.GetX(), blk2.GetY(), blk2.GetZ(), *this);
} }
return false; return false;
} }
@ -2747,7 +2747,7 @@ bool cPlayer::PlaceBlocks(const sSetBlockVector & a_Blocks)
// Abort - re-send all the current blocks in the a_Blocks' coords to the client: // Abort - re-send all the current blocks in the a_Blocks' coords to the client:
for (auto blk2: a_Blocks) for (auto blk2: a_Blocks)
{ {
m_World->SendBlockTo(blk2.GetX(), blk2.GetY(), blk2.GetZ(), this); m_World->SendBlockTo(blk2.GetX(), blk2.GetY(), blk2.GetZ(), *this);
} }
return false; return false;
} }

View File

@ -395,9 +395,9 @@ bool cItemHandler::OnPlayerPlace(
// Handler refused the placement, send that information back to the client: // Handler refused the placement, send that information back to the client:
for (const auto & blk: blocks) for (const auto & blk: blocks)
{ {
a_World.SendBlockTo(blk.GetX(), blk.GetY(), blk.GetZ(), &a_Player); a_World.SendBlockTo(blk.GetX(), blk.GetY(), blk.GetZ(), a_Player);
} }
a_World.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, &a_Player); a_World.SendBlockTo(a_BlockX, a_BlockY, a_BlockZ, a_Player);
a_Player.GetInventory().SendEquippedSlot(); a_Player.GetInventory().SendEquippedSlot();
return false; return false;
} }

View File

@ -2385,7 +2385,7 @@ bool cWorld::DigBlock(int a_X, int a_Y, int a_Z)
void cWorld::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) void cWorld::SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer & a_Player)
{ {
m_ChunkMap->SendBlockTo(a_X, a_Y, a_Z, a_Player); m_ChunkMap->SendBlockTo(a_X, a_Y, a_Z, a_Player);
} }

View File

@ -482,7 +482,7 @@ public:
// tolua_begin // tolua_begin
bool DigBlock (int a_X, int a_Y, int a_Z); bool DigBlock (int a_X, int a_Y, int a_Z);
virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer * a_Player) override; virtual void SendBlockTo(int a_X, int a_Y, int a_Z, cPlayer & a_Player) override;
/** Set default spawn at the given coordinates. /** Set default spawn at the given coordinates.
Returns false if the new spawn couldn't be stored in the INI file. */ Returns false if the new spawn couldn't be stored in the INI file. */