From 448df85e569e85e1b4da4eac685950273f30ae1f Mon Sep 17 00:00:00 2001 From: tycho Date: Sat, 21 Mar 2015 17:17:26 +0000 Subject: Added support for additional data in the ParticleEffect Packet Also started refactoring how broadcasts are handled --- src/Broadcaster.cpp | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/Broadcaster.cpp (limited to 'src/Broadcaster.cpp') diff --git a/src/Broadcaster.cpp b/src/Broadcaster.cpp new file mode 100644 index 000000000..7f2b65d09 --- /dev/null +++ b/src/Broadcaster.cpp @@ -0,0 +1,47 @@ + +#include "Globals.h" +#include "Broadcaster.h" +#include "World.h" +#include "Chunk.h" + +cBroadcaster::cBroadcaster(cWorld * a_World) : + m_World(a_World) +{ +} + + +void cBroadcaster::BroadcastParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude) +{ + m_World->DoWithChunkAt(a_Src, + [=](cChunk & a_Chunk) -> bool + { + for (auto&& client : a_Chunk.GetAllClients()) + { + if (client == a_Exclude) + { + continue; + } + client->SendParticleEffect(a_ParticleName, a_Src.x, a_Src.y, a_Src.z, a_Offset.x, a_Offset.y, a_Offset.z, a_ParticleData, a_ParticleAmount); + }; + return true; + }); +} + + +void cBroadcaster::BroadcastParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array a_Data, cClientHandle * a_Exclude) +{ + m_World->DoWithChunkAt(a_Src, + [=](cChunk & a_Chunk) -> bool + { + for (auto && client : a_Chunk.GetAllClients()) + { + if (client == a_Exclude) + { + continue; + } + client->SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount, a_Data); + }; + return true; + }); +} + -- cgit v1.2.3 From 218010cd96a3e887e7fbd8e18e1b74b7dc481036 Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Fri, 8 May 2015 23:32:02 +0100 Subject: Fixed some Visual Studio warnings --- src/Broadcaster.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/Broadcaster.cpp') diff --git a/src/Broadcaster.cpp b/src/Broadcaster.cpp index 7f2b65d09..594d12208 100644 --- a/src/Broadcaster.cpp +++ b/src/Broadcaster.cpp @@ -15,7 +15,7 @@ void cBroadcaster::BroadcastParticleEffect(const AString & a_ParticleName, const m_World->DoWithChunkAt(a_Src, [=](cChunk & a_Chunk) -> bool { - for (auto&& client : a_Chunk.GetAllClients()) + for (auto && client : a_Chunk.GetAllClients()) { if (client == a_Exclude) { -- cgit v1.2.3