[Server] Add broadcast argument to functions for sending WorldPackets

0.6.2
David Cernat 7 years ago
parent 1e2517698d
commit 47a3dc9ff2

@ -18,6 +18,7 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player); mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false); mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false);
if (broadcast) if (broadcast)
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(true); mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(true);
} }

@ -301,64 +301,104 @@ void WorldFunctions::AddContainerItem() noexcept
tempContainerItem = emptyContainerItem; tempContainerItem = emptyContainerItem;
} }
void WorldFunctions::SendObjectPlace() noexcept void WorldFunctions::SendObjectPlace(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_PLACE)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_PLACE);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_PLACE)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SendObjectSpawn() noexcept void WorldFunctions::SendObjectSpawn(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_SPAWN)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_SPAWN);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_SPAWN)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SendObjectDelete() noexcept void WorldFunctions::SendObjectDelete(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_DELETE)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_DELETE);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_DELETE)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SendObjectLock() noexcept void WorldFunctions::SendObjectLock(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_LOCK)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_LOCK);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_LOCK)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SendObjectTrap() noexcept void WorldFunctions::SendObjectTrap(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_TRAP)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_TRAP);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_TRAP)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SendObjectScale() noexcept void WorldFunctions::SendObjectScale(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_SCALE)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_SCALE);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_SCALE)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SendObjectState() noexcept void WorldFunctions::SendObjectState(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_STATE)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_STATE);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_OBJECT_STATE)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SendDoorState() noexcept void WorldFunctions::SendDoorState(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_DOOR_STATE)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_DOOR_STATE);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_DOOR_STATE)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SendContainer() noexcept void WorldFunctions::SendContainer(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_CONTAINER)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_CONTAINER);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_CONTAINER)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SendConsoleCommand() noexcept void WorldFunctions::SendConsoleCommand(bool broadcast) noexcept
{ {
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_CONSOLE_COMMAND)->setEvent(&writeEvent); mwmp::WorldPacket *packet = mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_CONSOLE_COMMAND);
mwmp::Networking::get().getWorldPacketController()->GetPacket(ID_CONSOLE_COMMAND)->Send(writeEvent.guid); packet->setEvent(&writeEvent);
packet->Send(false);
if (broadcast)
packet->Send(true);
} }
void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept void WorldFunctions::SetHour(unsigned short pid, double hour) noexcept

@ -568,92 +568,102 @@ public:
/** /**
* \brief Send an ObjectPlace packet. * \brief Send an ObjectPlace packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendObjectPlace() noexcept; static void SendObjectPlace(bool broadcast = false) noexcept;
/** /**
* \brief Send an ObjectSpawn packet. * \brief Send an ObjectSpawn packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendObjectSpawn() noexcept; static void SendObjectSpawn(bool broadcast = false) noexcept;
/** /**
* \brief Send an ObjectDelete packet. * \brief Send an ObjectDelete packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendObjectDelete() noexcept; static void SendObjectDelete(bool broadcast = false) noexcept;
/** /**
* \brief Send an ObjectLock packet. * \brief Send an ObjectLock packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendObjectLock() noexcept; static void SendObjectLock(bool broadcast = false) noexcept;
/** /**
* \brief Send an ObjectTrap packet. * \brief Send an ObjectTrap packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendObjectTrap() noexcept; static void SendObjectTrap(bool broadcast = false) noexcept;
/** /**
* \brief Send an ObjectScale packet. * \brief Send an ObjectScale packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendObjectScale() noexcept; static void SendObjectScale(bool broadcast = false) noexcept;
/** /**
* \brief Send an ObjectState packet. * \brief Send an ObjectState packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendObjectState() noexcept; static void SendObjectState(bool broadcast = false) noexcept;
/** /**
* \brief Send a DoorState packet. * \brief Send a DoorState packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendDoorState() noexcept; static void SendDoorState(bool broadcast = false) noexcept;
/** /**
* \brief Send a Container packet. * \brief Send a Container packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendContainer() noexcept; static void SendContainer(bool broadcast = false) noexcept;
/** /**
* \brief Send a ConsoleCommand packet. * \brief Send a ConsoleCommand packet.
* *
* It is sent only to the player for whom the current event was initialized. * \param broadcast Whether this packet should be sent only to the player for whom the current
* event was initialized or to everyone on the server.
* *
* \return void * \return void
*/ */
static void SendConsoleCommand() noexcept; static void SendConsoleCommand(bool broadcast = false) noexcept;
/** /**
* \brief Set the game hour for a player and send a GameTime packet to that player. * \brief Set the game hour for a player and send a GameTime packet to that player.

Loading…
Cancel
Save