diff options
Diffstat (limited to '')
-rw-r--r-- | src/Broadcaster.cpp | 549 |
1 files changed, 314 insertions, 235 deletions
diff --git a/src/Broadcaster.cpp b/src/Broadcaster.cpp index 9369b8062..a6a841cf7 100644 --- a/src/Broadcaster.cpp +++ b/src/Broadcaster.cpp @@ -17,90 +17,97 @@ namespace { - /** Calls the function object a_Func for every active client in the world - \param a_World World the clients are in - \param a_Exclude Client for which a_Func should not be called - \param a_Func Function to be called with each non-excluded client */ - template <typename Func> - void ForClientsInWorld(cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func) - { - a_World.ForEachPlayer([&](cPlayer & a_Player) +/** Calls the function object a_Func for every active client in the world +\param a_World World the clients are in +\param a_Exclude Client for which a_Func should not be called +\param a_Func Function to be called with each non-excluded client */ +template <typename Func> void ForClientsInWorld(cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func) +{ + a_World.ForEachPlayer( + [&](cPlayer & a_Player) + { + cClientHandle * Client = a_Player.GetClientHandle(); + if ((Client != a_Exclude) && (Client != nullptr) && Client->IsLoggedIn() && !Client->IsDestroyed()) { - cClientHandle * Client = a_Player.GetClientHandle(); - if ((Client != a_Exclude) && (Client != nullptr) && Client->IsLoggedIn() && !Client->IsDestroyed()) - { - a_Func(*Client); - } - return false; + a_Func(*Client); } - ); - } + return false; + } + ); +} - /** Calls the function object a_Func for every client who has the specified chunk - \param a_ChunkCoords Coords of the chunk to query for clients - \param a_World World that the chunk is in - \param a_Exclude Client for which a_Func should not be called - \param a_Func Function to be called with each non-excluded client */ - template <typename Func> - void ForClientsWithChunk(const cChunkCoords a_ChunkCoords, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func) - { - a_World.DoWithChunk(a_ChunkCoords.m_ChunkX, a_ChunkCoords.m_ChunkZ, - [&](cChunk & a_Chunk) +/** Calls the function object a_Func for every client who has the specified chunk +\param a_ChunkCoords Coords of the chunk to query for clients +\param a_World World that the chunk is in +\param a_Exclude Client for which a_Func should not be called +\param a_Func Function to be called with each non-excluded client */ +template <typename Func> +void ForClientsWithChunk( + const cChunkCoords a_ChunkCoords, + cWorld & a_World, + const cClientHandle * a_Exclude, + Func a_Func +) +{ + a_World.DoWithChunk( + a_ChunkCoords.m_ChunkX, + a_ChunkCoords.m_ChunkZ, + [&](cChunk & a_Chunk) + { + for (auto * Client : a_Chunk.GetAllClients()) { - for (auto * Client : a_Chunk.GetAllClients()) + if (Client != a_Exclude) { - if (Client != a_Exclude) - { - a_Func(*Client); - } + a_Func(*Client); } - return true; } - ); - } + return true; + } + ); +} - /** Calls the function object a_Func for every client who has the chunk at the specified block position - \param a_WorldPos Coordinates of the block to query for clients - \param a_World World that the block is in - \param a_Exclude Client for which a_Func should not be called - \param a_Func Function to be called with each non-excluded client */ - template <typename Func> - void ForClientsWithChunkAtPos(const Vector3i a_WorldPos, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func) - { - ForClientsWithChunk(cChunkDef::BlockToChunk(a_WorldPos), a_World, a_Exclude, std::move(a_Func)); - } +/** Calls the function object a_Func for every client who has the chunk at the specified block position +\param a_WorldPos Coordinates of the block to query for clients +\param a_World World that the block is in +\param a_Exclude Client for which a_Func should not be called +\param a_Func Function to be called with each non-excluded client */ +template <typename Func> +void ForClientsWithChunkAtPos(const Vector3i a_WorldPos, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func) +{ + ForClientsWithChunk(cChunkDef::BlockToChunk(a_WorldPos), a_World, a_Exclude, std::move(a_Func)); +} - /** Calls the function object a_Func for every client who has the specified entity - \param a_Entity Entity to query for clients - \param a_World World that the block is in - \param a_Exclude Client for which a_Func should not be called - \param a_Func Function to be called with each non-excluded client */ - template <typename Func> - void ForClientsWithEntity(const cEntity & a_Entity, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func) +/** Calls the function object a_Func for every client who has the specified entity +\param a_Entity Entity to query for clients +\param a_World World that the block is in +\param a_Exclude Client for which a_Func should not be called +\param a_Func Function to be called with each non-excluded client */ +template <typename Func> +void ForClientsWithEntity(const cEntity & a_Entity, cWorld & a_World, const cClientHandle * a_Exclude, Func a_Func) +{ + cWorld::cLock Lock(a_World); // Lock world before accessing a_Entity + auto Chunk = a_Entity.GetParentChunk(); + if (Chunk != nullptr) { - cWorld::cLock Lock(a_World); // Lock world before accessing a_Entity - auto Chunk = a_Entity.GetParentChunk(); - if (Chunk != nullptr) + for (auto * Client : Chunk->GetAllClients()) { - for (auto * Client : Chunk->GetAllClients()) + if (Client != a_Exclude) { - if (Client != a_Exclude) - { - a_Func(*Client); - } + a_Func(*Client); } } - else // Some broadcasts happen before the entity's first tick sets its ParentChunk - { - ForClientsWithChunk({ a_Entity.GetChunkX(), a_Entity.GetChunkZ() }, a_World, a_Exclude, std::move(a_Func)); - } } -} // namespace (anonymous) + else // Some broadcasts happen before the entity's first tick sets its ParentChunk + { + ForClientsWithChunk({a_Entity.GetChunkX(), a_Entity.GetChunkZ()}, a_World, a_Exclude, std::move(a_Func)); + } +} +} // namespace @@ -108,10 +115,11 @@ namespace void cWorld::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity & a_Vehicle) { - ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendAttachEntity(a_Entity, a_Vehicle); - } + ForClientsWithEntity( + a_Entity, + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendAttachEntity(a_Entity, a_Vehicle); } ); } @@ -119,12 +127,20 @@ void cWorld::BroadcastAttachEntity(const cEntity & a_Entity, const cEntity & a_V -void cWorld::BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte2, BLOCKTYPE a_BlockType, const cClientHandle * a_Exclude) +void cWorld::BroadcastBlockAction( + Vector3i a_BlockPos, + Byte a_Byte1, + Byte a_Byte2, + BLOCKTYPE a_BlockType, + const cClientHandle * a_Exclude +) { - ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendBlockAction(a_BlockPos, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType); - } + ForClientsWithChunkAtPos( + a_BlockPos, + *this, + a_Exclude, + [&](cClientHandle & a_Client) + { a_Client.SendBlockAction(a_BlockPos, static_cast<char>(a_Byte1), static_cast<char>(a_Byte2), a_BlockType); } ); } @@ -132,12 +148,18 @@ void cWorld::BroadcastBlockAction(Vector3i a_BlockPos, Byte a_Byte1, Byte a_Byte -void cWorld::BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos, Int8 a_Stage, const cClientHandle * a_Exclude) +void cWorld::BroadcastBlockBreakAnimation( + UInt32 a_EntityID, + Vector3i a_BlockPos, + Int8 a_Stage, + const cClientHandle * a_Exclude +) { - ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendBlockBreakAnim(a_EntityID, a_BlockPos, a_Stage); - } + ForClientsWithChunkAtPos( + a_BlockPos, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendBlockBreakAnim(a_EntityID, a_BlockPos, a_Stage); } ); } @@ -147,7 +169,9 @@ void cWorld::BroadcastBlockBreakAnimation(UInt32 a_EntityID, Vector3i a_BlockPos void cWorld::BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle * a_Exclude) { - DoWithChunkAt(a_BlockPos, [&](cChunk & a_Chunk) + DoWithChunkAt( + a_BlockPos, + [&](cChunk & a_Chunk) { cBlockEntity * Entity = a_Chunk.GetBlockEntity(a_BlockPos); if (Entity == nullptr) @@ -173,10 +197,11 @@ void cWorld::BroadcastBlockEntity(Vector3i a_BlockPos, const cClientHandle * a_E void cWorld::BroadcastBossBarUpdateHealth(const cEntity & a_Entity, UInt32 a_UniqueID, float a_FractionFilled) { - ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendBossBarUpdateHealth(a_UniqueID, a_FractionFilled); - } + ForClientsWithEntity( + a_Entity, + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendBossBarUpdateHealth(a_UniqueID, a_FractionFilled); } ); } @@ -191,11 +216,7 @@ void cWorld::BroadcastChat(const AString & a_Message, const cClientHandle * a_Ex return; } - ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendChat(a_Message, a_ChatPrefix); - } - ); + ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) { a_Client.SendChat(a_Message, a_ChatPrefix); }); } @@ -204,23 +225,25 @@ void cWorld::BroadcastChat(const AString & a_Message, const cClientHandle * a_Ex void cWorld::BroadcastChat(const cCompositeChat & a_Message, const cClientHandle * a_Exclude) { - ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendChat(a_Message); - } - ); + ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) { a_Client.SendChat(a_Message); }); } -void cWorld::BroadcastCollectEntity(const cEntity & a_Collected, const cEntity & a_Collector, unsigned a_Count, const cClientHandle * a_Exclude) +void cWorld::BroadcastCollectEntity( + const cEntity & a_Collected, + const cEntity & a_Collector, + unsigned a_Count, + const cClientHandle * a_Exclude +) { - ForClientsWithEntity(a_Collected, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendCollectEntity(a_Collected, a_Collector, a_Count); - } + ForClientsWithEntity( + a_Collected, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendCollectEntity(a_Collected, a_Collector, a_Count); } ); } @@ -230,10 +253,11 @@ void cWorld::BroadcastCollectEntity(const cEntity & a_Collected, const cEntity & void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendDestroyEntity(a_Entity); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendDestroyEntity(a_Entity); } ); } @@ -243,10 +267,11 @@ void cWorld::BroadcastDestroyEntity(const cEntity & a_Entity, const cClientHandl void cWorld::BroadcastDetachEntity(const cEntity & a_Entity, const cEntity & a_PreviousVehicle) { - ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendDetachEntity(a_Entity, a_PreviousVehicle); - } + ForClientsWithEntity( + a_Entity, + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendDetachEntity(a_Entity, a_PreviousVehicle); } ); } @@ -256,10 +281,10 @@ void cWorld::BroadcastDetachEntity(const cEntity & a_Entity, const cEntity & a_P void cWorld::BroadcastDisplayObjective(const AString & a_Objective, cScoreboard::eDisplaySlot a_Display) { - ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendDisplayObjective(a_Objective, a_Display); - } + ForClientsInWorld( + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendDisplayObjective(a_Objective, a_Display); } ); } @@ -267,12 +292,19 @@ void cWorld::BroadcastDisplayObjective(const AString & a_Objective, cScoreboard: -void cWorld::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int a_Amplifier, int a_Duration, const cClientHandle * a_Exclude) +void cWorld::BroadcastEntityEffect( + const cEntity & a_Entity, + int a_EffectID, + int a_Amplifier, + int a_Duration, + const cClientHandle * a_Exclude +) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendEntityEffect(a_Entity, a_EffectID, a_Amplifier, a_Duration); } ); } @@ -280,12 +312,18 @@ void cWorld::BroadcastEntityEffect(const cEntity & a_Entity, int a_EffectID, int -void cWorld::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, const cItem & a_Item, const cClientHandle * a_Exclude) +void cWorld::BroadcastEntityEquipment( + const cEntity & a_Entity, + short a_SlotNum, + const cItem & a_Item, + const cClientHandle * a_Exclude +) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendEntityEquipment(a_Entity, a_SlotNum, a_Item); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendEntityEquipment(a_Entity, a_SlotNum, a_Item); } ); } @@ -295,10 +333,11 @@ void cWorld::BroadcastEntityEquipment(const cEntity & a_Entity, short a_SlotNum, void cWorld::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendEntityHeadLook(a_Entity); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendEntityHeadLook(a_Entity); } ); } @@ -308,10 +347,11 @@ void cWorld::BroadcastEntityHeadLook(const cEntity & a_Entity, const cClientHand void cWorld::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendEntityLook(a_Entity); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendEntityLook(a_Entity); } ); } @@ -321,10 +361,11 @@ void cWorld::BroadcastEntityLook(const cEntity & a_Entity, const cClientHandle * void cWorld::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendEntityMetadata(a_Entity); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendEntityMetadata(a_Entity); } ); } @@ -334,10 +375,11 @@ void cWorld::BroadcastEntityMetadata(const cEntity & a_Entity, const cClientHand void cWorld::BroadcastEntityPosition(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendEntityPosition(a_Entity); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendEntityPosition(a_Entity); } ); } @@ -347,10 +389,11 @@ void cWorld::BroadcastEntityPosition(const cEntity & a_Entity, const cClientHand void cWorld::BroadcastEntityProperties(const cEntity & a_Entity) { - ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendEntityProperties(a_Entity); - } + ForClientsWithEntity( + a_Entity, + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendEntityProperties(a_Entity); } ); } @@ -360,10 +403,11 @@ void cWorld::BroadcastEntityProperties(const cEntity & a_Entity) void cWorld::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHandle * a_Exclude) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendEntityVelocity(a_Entity); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendEntityVelocity(a_Entity); } ); } @@ -371,12 +415,17 @@ void cWorld::BroadcastEntityVelocity(const cEntity & a_Entity, const cClientHand -void cWorld::BroadcastEntityAnimation(const cEntity & a_Entity, EntityAnimation a_Animation, const cClientHandle * a_Exclude) +void cWorld::BroadcastEntityAnimation( + const cEntity & a_Entity, + EntityAnimation a_Animation, + const cClientHandle * a_Exclude +) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendEntityAnimation(a_Entity, a_Animation); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendEntityAnimation(a_Entity, a_Animation); } ); } @@ -386,10 +435,11 @@ void cWorld::BroadcastEntityAnimation(const cEntity & a_Entity, EntityAnimation void cWorld::BroadcastLeashEntity(const cEntity & a_Entity, const cEntity & a_EntityLeashedTo) { - ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendLeashEntity(a_Entity, a_EntityLeashedTo); - } + ForClientsWithEntity( + a_Entity, + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendLeashEntity(a_Entity, a_EntityLeashedTo); } ); } @@ -397,12 +447,21 @@ void cWorld::BroadcastLeashEntity(const cEntity & a_Entity, const cEntity & a_En -void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, const cClientHandle * a_Exclude) +void cWorld::BroadcastParticleEffect( + const AString & a_ParticleName, + const Vector3f a_Src, + const Vector3f a_Offset, + float a_ParticleData, + int a_ParticleAmount, + const cClientHandle * a_Exclude +) { - ForClientsWithChunkAtPos(a_Src, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount); - } + ForClientsWithChunkAtPos( + a_Src, + *this, + a_Exclude, + [&](cClientHandle & a_Client) + { a_Client.SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount); } ); } @@ -410,12 +469,22 @@ void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, const Vecto -void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data, const cClientHandle * a_Exclude) +void cWorld::BroadcastParticleEffect( + const AString & a_ParticleName, + const Vector3f a_Src, + const Vector3f a_Offset, + float a_ParticleData, + int a_ParticleAmount, + std::array<int, 2> a_Data, + const cClientHandle * a_Exclude +) { - ForClientsWithChunkAtPos(a_Src, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount, a_Data); - } + ForClientsWithChunkAtPos( + a_Src, + *this, + a_Exclude, + [&](cClientHandle & a_Client) + { a_Client.SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount, a_Data); } ); } @@ -425,11 +494,7 @@ void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, const Vecto void cWorld::BroadcastPlayerListAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude) { - ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendPlayerListAddPlayer(a_Player); - } - ); + ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) { a_Client.SendPlayerListAddPlayer(a_Player); }); } @@ -438,10 +503,10 @@ void cWorld::BroadcastPlayerListAddPlayer(const cPlayer & a_Player, const cClien void cWorld::BroadcastPlayerListHeaderFooter(const cCompositeChat & a_Header, const cCompositeChat & a_Footer) { - ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendPlayerListHeaderFooter(a_Header, a_Footer); - } + ForClientsInWorld( + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendPlayerListHeaderFooter(a_Header, a_Footer); } ); } @@ -451,10 +516,10 @@ void cWorld::BroadcastPlayerListHeaderFooter(const cCompositeChat & a_Header, co void cWorld::BroadcastPlayerListRemovePlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude) { - ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendPlayerListRemovePlayer(a_Player); - } + ForClientsInWorld( + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendPlayerListRemovePlayer(a_Player); } ); } @@ -462,12 +527,16 @@ void cWorld::BroadcastPlayerListRemovePlayer(const cPlayer & a_Player, const cCl -void cWorld::BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, const AString & a_CustomName, const cClientHandle * a_Exclude) +void cWorld::BroadcastPlayerListUpdateDisplayName( + const cPlayer & a_Player, + const AString & a_CustomName, + const cClientHandle * a_Exclude +) { - ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendPlayerListUpdateDisplayName(a_Player, a_CustomName); - } + ForClientsInWorld( + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendPlayerListUpdateDisplayName(a_Player, a_CustomName); } ); } @@ -477,10 +546,10 @@ void cWorld::BroadcastPlayerListUpdateDisplayName(const cPlayer & a_Player, cons void cWorld::BroadcastPlayerListUpdateGameMode(const cPlayer & a_Player, const cClientHandle * a_Exclude) { - ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendPlayerListUpdateGameMode(a_Player); - } + ForClientsInWorld( + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendPlayerListUpdateGameMode(a_Player); } ); } @@ -490,11 +559,7 @@ void cWorld::BroadcastPlayerListUpdateGameMode(const cPlayer & a_Player, const c void cWorld::BroadcastPlayerListUpdatePing() { - ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendPlayerListUpdatePing(); - } - ); + ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client) { a_Client.SendPlayerListUpdatePing(); }); } @@ -503,10 +568,11 @@ void cWorld::BroadcastPlayerListUpdatePing() void cWorld::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectID, const cClientHandle * a_Exclude) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendRemoveEntityEffect(a_Entity, a_EffectID); - } + ForClientsWithEntity( + a_Entity, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendRemoveEntityEffect(a_Entity, a_EffectID); } ); } @@ -516,10 +582,10 @@ void cWorld::BroadcastRemoveEntityEffect(const cEntity & a_Entity, int a_EffectI void cWorld::BroadcastScoreboardObjective(const AString & a_Name, const AString & a_DisplayName, Byte a_Mode) { - ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendScoreboardObjective(a_Name, a_DisplayName, a_Mode); - } + ForClientsInWorld( + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendScoreboardObjective(a_Name, a_DisplayName, a_Mode); } ); } @@ -527,12 +593,17 @@ void cWorld::BroadcastScoreboardObjective(const AString & a_Name, const AString -void cWorld::BroadcastScoreUpdate(const AString & a_Objective, const AString & a_PlayerName, cObjective::Score a_Score, Byte a_Mode) +void cWorld::BroadcastScoreUpdate( + const AString & a_Objective, + const AString & a_PlayerName, + cObjective::Score a_Score, + Byte a_Mode +) { - ForClientsInWorld(*this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendScoreUpdate(a_Objective, a_PlayerName, a_Score, a_Mode); - } + ForClientsInWorld( + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendScoreUpdate(a_Objective, a_PlayerName, a_Score, a_Mode); } ); } @@ -540,12 +611,19 @@ void cWorld::BroadcastScoreUpdate(const AString & a_Objective, const AString & a -void cWorld::BroadcastSoundEffect(const AString & a_SoundName, Vector3d a_Position, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude) +void cWorld::BroadcastSoundEffect( + const AString & a_SoundName, + Vector3d a_Position, + float a_Volume, + float a_Pitch, + const cClientHandle * a_Exclude +) { - ForClientsWithChunkAtPos(a_Position, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendSoundEffect(a_SoundName, a_Position, a_Volume, a_Pitch); - } + ForClientsWithChunkAtPos( + a_Position, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendSoundEffect(a_SoundName, a_Position, a_Volume, a_Pitch); } ); } @@ -553,12 +631,18 @@ void cWorld::BroadcastSoundEffect(const AString & a_SoundName, Vector3d a_Positi -void cWorld::BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_SrcPos, int a_Data, const cClientHandle * a_Exclude) +void cWorld::BroadcastSoundParticleEffect( + const EffectID a_EffectID, + Vector3i a_SrcPos, + int a_Data, + const cClientHandle * a_Exclude +) { - ForClientsWithChunkAtPos(a_SrcPos, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendSoundParticleEffect(a_EffectID, a_SrcPos, a_Data); - } + ForClientsWithChunkAtPos( + a_SrcPos, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendSoundParticleEffect(a_EffectID, a_SrcPos, a_Data); } ); } @@ -568,11 +652,7 @@ void cWorld::BroadcastSoundParticleEffect(const EffectID a_EffectID, Vector3i a_ void cWorld::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Exclude) { - ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Entity.SpawnOn(a_Client); - } - ); + ForClientsWithEntity(a_Entity, *this, a_Exclude, [&](cClientHandle & a_Client) { a_Entity.SpawnOn(a_Client); }); } @@ -581,10 +661,11 @@ void cWorld::BroadcastSpawnEntity(cEntity & a_Entity, const cClientHandle * a_Ex void cWorld::BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_Exclude) { - ForClientsWithChunkAtPos(a_BlockPos, *this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendThunderbolt(a_BlockPos); - } + ForClientsWithChunkAtPos( + a_BlockPos, + *this, + a_Exclude, + [&](cClientHandle & a_Client) { a_Client.SendThunderbolt(a_BlockPos); } ); } @@ -594,10 +675,11 @@ void cWorld::BroadcastThunderbolt(Vector3i a_BlockPos, const cClientHandle * a_E void cWorld::BroadcastTimeUpdate(const cClientHandle * a_Exclude) { - ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendTimeUpdate(GetWorldAge(), GetWorldDate(), IsDaylightCycleEnabled()); - } + ForClientsInWorld( + *this, + a_Exclude, + [&](cClientHandle & a_Client) + { a_Client.SendTimeUpdate(GetWorldAge(), GetWorldDate(), IsDaylightCycleEnabled()); } ); } @@ -607,10 +689,11 @@ void cWorld::BroadcastTimeUpdate(const cClientHandle * a_Exclude) void cWorld::BroadcastUnleashEntity(const cEntity & a_Entity) { - ForClientsWithEntity(a_Entity, *this, nullptr, [&](cClientHandle & a_Client) - { - a_Client.SendUnleashEntity(a_Entity); - } + ForClientsWithEntity( + a_Entity, + *this, + nullptr, + [&](cClientHandle & a_Client) { a_Client.SendUnleashEntity(a_Entity); } ); } @@ -620,9 +703,5 @@ void cWorld::BroadcastUnleashEntity(const cEntity & a_Entity) void cWorld::BroadcastWeather(eWeather a_Weather, const cClientHandle * a_Exclude) { - ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) - { - a_Client.SendWeather(a_Weather); - } - ); + ForClientsInWorld(*this, a_Exclude, [&](cClientHandle & a_Client) { a_Client.SendWeather(a_Weather); }); } |