1
0

Added support for additional data in the ParticleEffect Packet

Also started refactoring how broadcasts are handled
This commit is contained in:
tycho 2015-03-21 17:17:26 +00:00
parent bd73dcedd4
commit 448df85e56
22 changed files with 310 additions and 19 deletions

View File

@ -1133,6 +1133,23 @@ void cLuaState::GetStackValue(int a_StackPos, pWorld & a_ReturnedVal)
void cLuaState::GetStackValue(int a_StackPos, pClientHandle & a_ReturnedVal)
{
if (lua_isnil(m_LuaState, a_StackPos))
{
a_ReturnedVal = nullptr;
return;
}
tolua_Error err;
if (tolua_isusertype(m_LuaState, a_StackPos, "cClientHandle", false, &err))
{
a_ReturnedVal = *(reinterpret_cast<cClientHandle **>(lua_touserdata(m_LuaState, a_StackPos)));
}
}
bool cLuaState::CallFunction(int a_NumResults) bool cLuaState::CallFunction(int a_NumResults)
{ {
ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first ASSERT (m_NumCurrentFunctionArgs >= 0); // A function must be pushed to stack first
@ -1415,6 +1432,30 @@ bool cLuaState::CheckParamEnd(int a_Param)
bool cLuaState::IsParamUserType(int a_Param, AString a_UserType)
{
ASSERT(IsValid());
tolua_Error tolua_err;
return tolua_isusertype(m_LuaState, a_Param, a_UserType.c_str(), 0, &tolua_err);
}
bool cLuaState::IsParamNumber(int a_Param)
{
ASSERT(IsValid());
tolua_Error tolua_err;
return tolua_isnumber(m_LuaState, a_Param, 0, &tolua_err);
}
bool cLuaState::ReportErrors(int a_Status) bool cLuaState::ReportErrors(int a_Status)
{ {
return ReportErrors(m_LuaState, a_Status); return ReportErrors(m_LuaState, a_Status);

View File

@ -76,6 +76,7 @@ typedef cPluginManager * pPluginManager;
typedef cRoot * pRoot; typedef cRoot * pRoot;
typedef cScoreboard * pScoreboard; typedef cScoreboard * pScoreboard;
typedef cWorld * pWorld; typedef cWorld * pWorld;
typedef cClientHandle * pClientHandle;
@ -254,6 +255,7 @@ public:
void GetStackValue(int a_StackPos, int & a_Value); void GetStackValue(int a_StackPos, int & a_Value);
void GetStackValue(int a_StackPos, pBlockArea & a_Value); void GetStackValue(int a_StackPos, pBlockArea & a_Value);
void GetStackValue(int a_StackPos, pBoundingBox & a_Value); void GetStackValue(int a_StackPos, pBoundingBox & a_Value);
void GetStackValue(int a_StackPos, pClientHandle & a_Value);
void GetStackValue(int a_StackPos, pMapManager & a_Value); void GetStackValue(int a_StackPos, pMapManager & a_Value);
void GetStackValue(int a_StackPos, pPluginManager & a_Value); void GetStackValue(int a_StackPos, pPluginManager & a_Value);
void GetStackValue(int a_StackPos, pRoot & a_Value); void GetStackValue(int a_StackPos, pRoot & a_Value);
@ -307,6 +309,10 @@ public:
/** Returns true if the specified parameter on the stack is nil (indicating an end-of-parameters) */ /** Returns true if the specified parameter on the stack is nil (indicating an end-of-parameters) */
bool CheckParamEnd(int a_Param); bool CheckParamEnd(int a_Param);
bool IsParamUserType(int a_Param, AString a_UserType);
bool IsParamNumber(int a_Param);
/** If the status is nonzero, prints the text on the top of Lua stack and returns true */ /** If the status is nonzero, prints the text on the top of Lua stack and returns true */
bool ReportErrors(int status); bool ReportErrors(int status);

View File

@ -32,9 +32,10 @@
#include "../WorldStorage/SchematicFileSerializer.h" #include "../WorldStorage/SchematicFileSerializer.h"
#include "../CompositeChat.h" #include "../CompositeChat.h"
#include "../StringCompression.h" #include "../StringCompression.h"
#include "../Broadcaster.h"
#include <array>
// Better error reporting for Lua // Better error reporting for Lua
@ -2009,6 +2010,60 @@ static int tolua_cPluginManager_FindPlugins(lua_State * tolua_S)
static int tolua_cWorld_BroadcastParticleEffect(lua_State * tolua_S)
{
cLuaState L(tolua_S);
if (
!L.CheckParamUserType(1, "cWorld") ||
!L.CheckParamString (2) ||
!L.CheckParamNumber (3, 10)
)
{
return 0;
}
cPluginLua * Plugin = GetLuaPlugin(tolua_S);
if (Plugin == nullptr)
{
return 0;
}
// Read the params:
cWorld * World = nullptr;
AString Name;
double PosX, PosY, PosZ, OffX, OffY, OffZ;
double ParticleData;
int ParticleAmmount;
L.GetStackValues(1, World, Name, PosX, PosY, PosZ, OffX, OffY, OffZ, ParticleData, ParticleAmmount);
if (World == nullptr)
{
LOGWARNING("World:BroadcastParticleEffect(): invalid world parameter");
L.LogStackTrace();
return 0;
}
std::array<int, 2> data;
for (int i = 0; (i < 2) && L.IsParamNumber(11 + i); i++)
{
L.GetStackValue(11 + i, data[i]);
}
cClientHandle * Exclude = nullptr;
if (L.IsParamUserType(11, "cClientHandle"))
{
L.GetStackValue(11, Exclude);
}
World->GetBroadcaster().BroadcastParticleEffect(Name, Vector3f(PosX, PosY, PosZ), Vector3f(OffX, OffY, OffZ), ParticleData, ParticleAmmount, Exclude);
return 0;
}
static int tolua_cWorld_ChunkStay(lua_State * tolua_S) static int tolua_cWorld_ChunkStay(lua_State * tolua_S)
{ {
/* Function signature: /* Function signature:
@ -3792,6 +3847,7 @@ void ManualBindings::Bind(lua_State * tolua_S)
tolua_endmodule(tolua_S); tolua_endmodule(tolua_S);
tolua_beginmodule(tolua_S, "cWorld"); tolua_beginmodule(tolua_S, "cWorld");
tolua_function(tolua_S, "BroadcastParticleEffect", tolua_cWorld_BroadcastParticleEffect);
tolua_function(tolua_S, "ChunkStay", tolua_cWorld_ChunkStay); tolua_function(tolua_S, "ChunkStay", tolua_cWorld_ChunkStay);
tolua_function(tolua_S, "DoWithBlockEntityAt", tolua_DoWithXYZ<cWorld, cBlockEntity, &cWorld::DoWithBlockEntityAt>); tolua_function(tolua_S, "DoWithBlockEntityAt", tolua_DoWithXYZ<cWorld, cBlockEntity, &cWorld::DoWithBlockEntityAt>);
tolua_function(tolua_S, "DoWithBeaconAt", tolua_DoWithXYZ<cWorld, cBeaconEntity, &cWorld::DoWithBeaconAt>); tolua_function(tolua_S, "DoWithBeaconAt", tolua_DoWithXYZ<cWorld, cBeaconEntity, &cWorld::DoWithBeaconAt>);

47
src/Broadcaster.cpp Normal file
View File

@ -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<int, 2> 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;
});
}

20
src/Broadcaster.h Normal file
View File

@ -0,0 +1,20 @@
class cWorld;
#include <array>
class cBroadcaster
{
public:
cBroadcaster(cWorld * a_World);
void BroadcastParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude = nullptr);
void 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, cClientHandle * a_Exclude = nullptr);
private:
cWorld * m_World;
};

View File

@ -18,6 +18,7 @@ SET (SRCS
BlockArea.cpp BlockArea.cpp
BlockID.cpp BlockID.cpp
BlockInfo.cpp BlockInfo.cpp
Broadcaster.cpp
BoundingBox.cpp BoundingBox.cpp
ByteBuffer.cpp ByteBuffer.cpp
ChatColor.cpp ChatColor.cpp
@ -77,6 +78,7 @@ SET (HDRS
BlockInServerPluginInterface.h BlockInServerPluginInterface.h
BlockInfo.h BlockInfo.h
BlockTracer.h BlockTracer.h
Broadcaster.h
BoundingBox.h BoundingBox.h
BuildInfo.h.cmake BuildInfo.h.cmake
ByteBuffer.h ByteBuffer.h

View File

@ -439,6 +439,9 @@ public:
as at least one requests is active the chunk will be ticked). */ as at least one requests is active the chunk will be ticked). */
void SetAlwaysTicked(bool a_AlwaysTicked); void SetAlwaysTicked(bool a_AlwaysTicked);
// Makes a copy of the list
cClientHandleList GetAllClients(void) const {return m_LoadedByClient; }
private: private:
friend class cChunkMap; friend class cChunkMap;
@ -531,9 +534,6 @@ private:
/** Wakes up each simulator for its specific blocks; through all the blocks in the chunk */ /** Wakes up each simulator for its specific blocks; through all the blocks in the chunk */
void WakeUpSimulators(void); void WakeUpSimulators(void);
// Makes a copy of the list
cClientHandleList GetAllClients(void) const {return m_LoadedByClient; }
/** Sends m_PendingSendBlocks to all clients */ /** Sends m_PendingSendBlocks to all clients */
void BroadcastPendingBlockChanges(void); void BroadcastPendingBlockChanges(void);

View File

@ -791,6 +791,28 @@ bool cChunkMap::DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callb
} }
bool cChunkMap::DoWithChunkAt(Vector3i a_BlockPos, std::function<bool(cChunk &)> a_Callback)
{
int ChunkX, ChunkZ;
cChunkDef::BlockToChunk(a_BlockPos.x, a_BlockPos.z, ChunkX, ChunkZ);
struct cCallBackWrapper : cChunkCallback
{
cCallBackWrapper(std::function<bool(cChunk &)> a_InnerCallback) :
m_Callback(a_InnerCallback)
{
}
virtual bool Item(cChunk * a_Chunk)
{
return m_Callback(*a_Chunk);
}
private:
std::function<bool(cChunk &)> m_Callback;
} callback(a_Callback);
return DoWithChunk(ChunkX, ChunkZ, callback);
}

View File

@ -104,6 +104,9 @@ public:
/** Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback */ /** Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback */
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback); bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback);
/** Calls the callback for the chunk at the block position specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback **/
bool DoWithChunkAt(Vector3i a_BlockPos, std::function<bool(cChunk &)> a_Callback);
/** Wakes up simulators for the specified block */ /** Wakes up simulators for the specified block */
void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ); void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ);

View File

@ -2374,6 +2374,15 @@ void cClientHandle::SendParticleEffect(const AString & a_ParticleName, float a_S
void cClientHandle::SendParticleEffect(const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data)
{
m_Protocol->SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount, a_Data);
}
void cClientHandle::SendPickupSpawn(const cPickup & a_Pickup) void cClientHandle::SendPickupSpawn(const cPickup & a_Pickup)
{ {
m_Protocol->SendPickupSpawn(a_Pickup); m_Protocol->SendPickupSpawn(a_Pickup);

View File

@ -22,6 +22,7 @@
#include "ChunkSender.h" #include "ChunkSender.h"
#include <array>
@ -177,6 +178,7 @@ public: // tolua_export
void SendMapInfo (int a_ID, unsigned int a_Scale); void SendMapInfo (int a_ID, unsigned int a_Scale);
void SendPaintingSpawn (const cPainting & a_Painting); void SendPaintingSpawn (const cPainting & a_Painting);
void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount); void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount);
void SendParticleEffect (const AString & a_ParticleName, const Vector3f a_Src, const Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data);
void SendPickupSpawn (const cPickup & a_Pickup); void SendPickupSpawn (const cPickup & a_Pickup);
void SendPlayerAbilities (void); void SendPlayerAbilities (void);
void SendPlayerListAddPlayer (const cPlayer & a_Player); void SendPlayerListAddPlayer (const cPlayer & a_Player);

View File

@ -6,7 +6,7 @@
#include "Floater.h" #include "Floater.h"
#include "Player.h" #include "Player.h"
#include "../ClientHandle.h" #include "../ClientHandle.h"
#include "Broadcaster.h"
@ -145,12 +145,12 @@ void cFloater::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk)
{ {
LOGD("Started producing particles for floater %i", GetUniqueID()); LOGD("Started producing particles for floater %i", GetUniqueID());
m_ParticlePos.Set(GetPosX() + (-4 + m_World->GetTickRandomNumber(8)), GetPosY(), GetPosZ() + (-4 + m_World->GetTickRandomNumber(8))); m_ParticlePos.Set(GetPosX() + (-4 + m_World->GetTickRandomNumber(8)), GetPosY(), GetPosZ() + (-4 + m_World->GetTickRandomNumber(8)));
m_World->BroadcastParticleEffect("splash", (float) m_ParticlePos.x, (float) m_ParticlePos.y, (float) m_ParticlePos.z, 0, 0, 0, 0, 15); m_World->GetBroadcaster().BroadcastParticleEffect("splash", static_cast<Vector3f>(m_ParticlePos), Vector3f{}, 0, 15);
} }
else if (m_CountDownTime < 20) else if (m_CountDownTime < 20)
{ {
m_ParticlePos = (m_ParticlePos + (GetPosition() - m_ParticlePos) / 6); m_ParticlePos = (m_ParticlePos + (GetPosition() - m_ParticlePos) / 6);
m_World->BroadcastParticleEffect("splash", (float) m_ParticlePos.x, (float) m_ParticlePos.y, (float) m_ParticlePos.z, 0, 0, 0, 0, 15); m_World->GetBroadcaster().BroadcastParticleEffect("splash", static_cast<Vector3f>(m_ParticlePos), Vector3f{}, 0, 15);
} }
m_CountDownTime--; m_CountDownTime--;

View File

@ -5,6 +5,7 @@
#include "../World.h" #include "../World.h"
#include "../Entities/Player.h" #include "../Entities/Player.h"
#include "../Items/ItemHandler.h" #include "../Items/ItemHandler.h"
#include "Broadcaster.h"
@ -83,13 +84,13 @@ void cWolf::OnRightClicked(cPlayer & a_Player)
SetIsTame(true); SetIsTame(true);
SetOwner(a_Player.GetName(), a_Player.GetUUID()); SetOwner(a_Player.GetName(), a_Player.GetUUID());
m_World->BroadcastEntityStatus(*this, esWolfTamed); m_World->BroadcastEntityStatus(*this, esWolfTamed);
m_World->BroadcastParticleEffect("heart", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5); m_World->GetBroadcaster().BroadcastParticleEffect("heart", static_cast<Vector3f>(GetPosition()), Vector3f{}, 0, 5);
} }
else else
{ {
// Taming failed // Taming failed
m_World->BroadcastEntityStatus(*this, esWolfTaming); m_World->BroadcastEntityStatus(*this, esWolfTaming);
m_World->BroadcastParticleEffect("smoke", (float) GetPosX(), (float) GetPosY(), (float) GetPosZ(), 0, 0, 0, 0, 5); m_World->GetBroadcaster().BroadcastParticleEffect("smoke", static_cast<Vector3f>(GetPosition()), Vector3f{}, 0, 5);
} }
} }
} }

View File

@ -16,6 +16,8 @@
#include "../Map.h" #include "../Map.h"
#include "../ByteBuffer.h" #include "../ByteBuffer.h"
#include <array>
@ -98,6 +100,7 @@ public:
virtual void SendPlayerAbilities (void) = 0; virtual void SendPlayerAbilities (void) = 0;
virtual void SendEntityAnimation (const cEntity & a_Entity, char a_Animation) = 0; virtual void SendEntityAnimation (const cEntity & a_Entity, char a_Animation) = 0;
virtual void SendParticleEffect (const AString & a_SoundName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) = 0; virtual void SendParticleEffect (const AString & a_SoundName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) = 0;
virtual void SendParticleEffect (const AString & a_SoundName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) = 0;
virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) = 0; virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) = 0;
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) = 0; virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) = 0;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) = 0; virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) = 0;

View File

@ -804,6 +804,16 @@ void cProtocol172::SendParticleEffect(const AString & a_ParticleName, float a_Sr
void cProtocol172::SendParticleEffect(const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data)
{
// 1.72 doesn't support extra data
this->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);
}
void cProtocol172::SendPlayerListAddPlayer(const cPlayer & a_Player) void cProtocol172::SendPlayerListAddPlayer(const cPlayer & a_Player)
{ {
ASSERT(m_State == 3); // In game mode? ASSERT(m_State == 3); // In game mode?

View File

@ -99,6 +99,7 @@ public:
virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override; virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override; virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) override; virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) override;
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;
virtual void SendPickupSpawn (const cPickup & a_Pickup) override; virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendPlayerAbilities (void) override; virtual void SendPlayerAbilities (void) override;
virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) override; virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) override;

View File

@ -802,6 +802,50 @@ void cProtocol180::SendParticleEffect(const AString & a_ParticleName, float a_Sr
void cProtocol180::SendParticleEffect(const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data)
{
ASSERT(m_State == 3); // In game mode?
int ParticleID = GetParticleID(a_ParticleName);
cPacketizer Pkt(*this, 0x2A);
Pkt.WriteBEInt32(ParticleID);
Pkt.WriteBool(false);
Pkt.WriteBEFloat(a_Src.x);
Pkt.WriteBEFloat(a_Src.y);
Pkt.WriteBEFloat(a_Src.z);
Pkt.WriteBEFloat(a_Offset.x);
Pkt.WriteBEFloat(a_Offset.y);
Pkt.WriteBEFloat(a_Offset.z);
Pkt.WriteBEFloat(a_ParticleData);
Pkt.WriteBEInt32(a_ParticleAmount);
switch (ParticleID)
{
// iconcrack
case 36:
{
Pkt.WriteVarInt32(static_cast<UInt32>(a_Data[0]));
Pkt.WriteVarInt32(static_cast<UInt32>(a_Data[1]));
break;
}
// blockcrack
// blockdust
case 37:
case 38:
{
Pkt.WriteVarInt32(static_cast<UInt32>(a_Data[0]));
break;
}
default:
{
break;
}
}
}
void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player) void cProtocol180::SendPlayerListAddPlayer(const cPlayer & a_Player)
{ {
ASSERT(m_State == 3); // In game mode? ASSERT(m_State == 3); // In game mode?

View File

@ -97,6 +97,7 @@ public:
virtual void SendPlayerAbilities (void) override; virtual void SendPlayerAbilities (void) override;
virtual void SendEntityAnimation (const cEntity & a_Entity, char a_Animation) override; virtual void SendEntityAnimation (const cEntity & a_Entity, char a_Animation) override;
virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) override; virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) override;
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;
virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) override; virtual void SendPlayerListAddPlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) override; virtual void SendPlayerListRemovePlayer (const cPlayer & a_Player) override;
virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) override; virtual void SendPlayerListUpdateGameMode (const cPlayer & a_Player) override;

View File

@ -439,6 +439,17 @@ void cProtocolRecognizer::SendParticleEffect(const AString & a_ParticleName, flo
void cProtocolRecognizer::SendParticleEffect(const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data)
{
ASSERT(m_Protocol != nullptr);
m_Protocol->SendParticleEffect(a_ParticleName, a_Src, a_Offset, a_ParticleData, a_ParticleAmount, a_Data);
}
void cProtocolRecognizer::SendPaintingSpawn(const cPainting & a_Painting) void cProtocolRecognizer::SendPaintingSpawn(const cPainting & a_Painting)
{ {
m_Protocol->SendPaintingSpawn(a_Painting); m_Protocol->SendPaintingSpawn(a_Painting);

View File

@ -81,6 +81,7 @@ public:
virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) override; virtual void SendMapDecorators (int a_ID, const cMapDecoratorList & a_Decorators, unsigned int m_Scale) override;
virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override; virtual void SendMapInfo (int a_ID, unsigned int a_Scale) override;
virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) override; virtual void SendParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount) override;
virtual void SendParticleEffect (const AString & a_ParticleName, Vector3f a_Src, Vector3f a_Offset, float a_ParticleData, int a_ParticleAmount, std::array<int, 2> a_Data) override;
virtual void SendPaintingSpawn (const cPainting & a_Painting) override; virtual void SendPaintingSpawn (const cPainting & a_Painting) override;
virtual void SendPickupSpawn (const cPickup & a_Pickup) override; virtual void SendPickupSpawn (const cPickup & a_Pickup) override;
virtual void SendPlayerAbilities (void) override; virtual void SendPlayerAbilities (void) override;

View File

@ -57,7 +57,7 @@
#include <stdlib.h> #include <stdlib.h>
#endif #endif
#include "Broadcaster.h"
@ -1459,6 +1459,15 @@ bool cWorld::DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback
bool cWorld::DoWithChunkAt(Vector3i a_BlockPos, std::function<bool(cChunk &)> a_Callback)
{
return m_ChunkMap->DoWithChunkAt(a_BlockPos, a_Callback);
}
void cWorld::GrowTree(int a_X, int a_Y, int a_Z) void cWorld::GrowTree(int a_X, int a_Y, int a_Z)
{ {
if (GetBlock(a_X, a_Y, a_Z) == E_BLOCK_SAPLING) if (GetBlock(a_X, a_Y, a_Z) == E_BLOCK_SAPLING)
@ -2241,14 +2250,6 @@ void cWorld::BroadcastEntityAnimation(const cEntity & a_Entity, char a_Animation
void cWorld::BroadcastParticleEffect(const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude)
{
m_ChunkMap->BroadcastParticleEffect(a_ParticleName, a_SrcX, a_SrcY, a_SrcZ, a_OffsetX, a_OffsetY, a_OffsetZ, a_ParticleData, a_ParticleAmount, a_Exclude);
}
void cWorld::BroadcastPlayerListAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude) void cWorld::BroadcastPlayerListAddPlayer(const cPlayer & a_Player, const cClientHandle * a_Exclude)
{ {
@ -3770,5 +3771,10 @@ void cWorld::cChunkGeneratorCallbacks::CallHookChunkGenerated (cChunkDesc & a_Ch
cBroadcaster cWorld::GetBroadcaster()
{
return cBroadcaster(this);
}

View File

@ -55,6 +55,7 @@ class cMobHeadEntity;
class cCompositeChat; class cCompositeChat;
class cCuboid; class cCuboid;
class cSetChunkData; class cSetChunkData;
class cBroadcaster;
typedef std::list< cPlayer * > cPlayerList; typedef std::list< cPlayer * > cPlayerList;
@ -243,7 +244,6 @@ public:
void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = nullptr); void BroadcastEntityStatus (const cEntity & a_Entity, char a_Status, const cClientHandle * a_Exclude = nullptr);
void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr); void BroadcastEntityVelocity (const cEntity & a_Entity, const cClientHandle * a_Exclude = nullptr);
virtual void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = nullptr) override; // tolua_export virtual void BroadcastEntityAnimation (const cEntity & a_Entity, char a_Animation, const cClientHandle * a_Exclude = nullptr) override; // tolua_export
void BroadcastParticleEffect (const AString & a_ParticleName, float a_SrcX, float a_SrcY, float a_SrcZ, float a_OffsetX, float a_OffsetY, float a_OffsetZ, float a_ParticleData, int a_ParticleAmount, cClientHandle * a_Exclude = nullptr); // tolua_export
void BroadcastPlayerListAddPlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr); void BroadcastPlayerListAddPlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
void BroadcastPlayerListRemovePlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr); void BroadcastPlayerListRemovePlayer (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
void BroadcastPlayerListUpdateGameMode (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr); void BroadcastPlayerListUpdateGameMode (const cPlayer & a_Player, const cClientHandle * a_Exclude = nullptr);
@ -610,6 +610,9 @@ public:
/** Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback */ /** Calls the callback for the chunk specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback */
bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback); bool DoWithChunk(int a_ChunkX, int a_ChunkZ, cChunkCallback & a_Callback);
/** Calls the callback for the chunk at the block position specified, with ChunkMapCS locked; returns false if the chunk doesn't exist, otherwise returns the same value as the callback **/
bool DoWithChunkAt(Vector3i a_BlockPos, std::function<bool(cChunk &)> a_Callback);
void GrowTreeImage(const sSetBlockVector & a_Blocks); void GrowTreeImage(const sSetBlockVector & a_Blocks);
// tolua_begin // tolua_begin
@ -829,6 +832,8 @@ public:
as at least one requests is active the chunk will be ticked). */ as at least one requests is active the chunk will be ticked). */
void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export void SetChunkAlwaysTicked(int a_ChunkX, int a_ChunkZ, bool a_AlwaysTicked = true); // tolua_export
cBroadcaster GetBroadcaster();
private: private:
friend class cRoot; friend class cRoot;