[Server] Use consistent arguments for script functions that send packets

Previously, there was a confusing separation between script functions that had a "broadcast" argument and script functions that had a "toOthers" argument.

Those with broadcast sent the packet to all players on the server when broadcast was true. Those with toOthers sent the packet to all players other than the packet's attached player.

The former was based on the pattern of the original SendMessage() script function. The latter more closely resembled RakNet's own broadcast argument as seen here:

https://github.com/TES3MP/CrabNet/blob/master/include/raknet/RakPeer.h#L219

This commit makes it so all sending functions have a sendToOtherPlayers argument that is false by default and a sendToAttachedPlayer that is true by default. This should simultaneously allow sending to be more intuitive, while not breaking previous existing scripts to a significant degree.

Additionally, this commit also reduces some code repetition for all instances of packet-fetching in script functions.
0.6.3
David Cernat 7 years ago
parent 14e4f64296
commit 6a3fbf4e98

@ -45,11 +45,17 @@ const char *BookFunctions::GetBookId(unsigned short pid, unsigned int i) noexcep
return player->bookChanges.books.at(i).bookId.c_str();
}
void BookFunctions::SendBookChanges(unsigned short pid, bool toOthers) noexcept
void BookFunctions::SendBookChanges(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOOK)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOOK)->Send(toOthers);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOOK);
packet->setPlayer(player);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}

@ -56,11 +56,13 @@ public:
* \brief Send a PlayerBook packet with a player's recorded book changes.
*
* \param pid The player ID whose book changes should be used.
* \param toOthers Whether this packet should be sent only to other players or
* only to the player it is about.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendBookChanges(unsigned short pid, bool toOthers = false) noexcept;
static void SendBookChanges(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
private:

@ -120,6 +120,8 @@ void CellFunctions::SendCell(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CELL_CHANGE);
packet->setPlayer(player);
packet->Send(false);
}

@ -151,6 +151,8 @@ void CharClassFunctions::SendClass(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARCLASS)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARCLASS)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARCLASS);
packet->setPlayer(player);
packet->Send(false);
}

@ -1,12 +1,8 @@
//
// Created by koncord on 29.04.16.
//
#include <apps/openmw-mp/Script/ScriptFunctions.hpp>
#include <apps/openmw-mp/Networking.hpp>
#include <components/openmw-mp/NetworkMessages.hpp>
void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept
void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player,);
@ -15,12 +11,13 @@ void ScriptFunctions::SendMessage(unsigned short pid, const char *message, bool
LOG_MESSAGE_SIMPLE(Log::LOG_VERBOSE, "System: %s", message);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE);
packet->setPlayer(player);
if (broadcast)
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(true);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ScriptFunctions::CleanChatForPid(unsigned short pid)
@ -30,9 +27,10 @@ void ScriptFunctions::CleanChatForPid(unsigned short pid)
player->chatMessage.clear();
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE);
packet->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false);
packet->Send(false);
}
void ScriptFunctions::CleanChat()
@ -40,8 +38,10 @@ void ScriptFunctions::CleanChat()
for (auto player : *Players::getPlayers())
{
player.second->chatMessage.clear();
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->setPlayer(player.second);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_CHAT_MESSAGE);
packet->setPlayer(player.second);
packet->Send(false);
}
}

@ -45,13 +45,18 @@ const char *DialogueFunctions::GetTopicId(unsigned short pid, unsigned int i) no
return player->topicChanges.topics.at(i).topicId.c_str();
}
void DialogueFunctions::SendTopicChanges(unsigned short pid, bool toOthers) noexcept
void DialogueFunctions::SendTopicChanges(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC)->Send(toOthers);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_TOPIC);
packet->setPlayer(player);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname, int mode, int count, bool persist) noexcept
@ -66,6 +71,7 @@ void DialogueFunctions::PlayAnimation(unsigned short pid, const char* groupname,
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ANIM_PLAY);
packet->setPlayer(player);
packet->Send(false);
player->sendToLoaded(packet);
}
@ -79,6 +85,7 @@ void DialogueFunctions::PlaySpeech(unsigned short pid, const char* sound) noexce
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPEECH);
packet->setPlayer(player);
packet->Send(false);
player->sendToLoaded(packet);
}

@ -59,11 +59,13 @@ public:
* \brief Send a PlayerTopic packet with a player's recorded topic changes.
*
* \param pid The player ID whose topic changes should be used.
* \param toOthers Whether this packet should be sent only to other players or
* only to the player it is about.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendTopicChanges(unsigned short pid, bool toOthers = false) noexcept;
static void SendTopicChanges(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
static void PlayAnimation(unsigned short pid, const char* groupname, int mode = 0, int count = 1, bool persist = false) noexcept;
static void PlaySpeech(unsigned short pid, const char* sound) noexcept;

@ -108,11 +108,16 @@ void FactionFunctions::AddFaction(unsigned short pid) noexcept
tempFaction = emptyFaction;
}
void FactionFunctions::SendFactionChanges(unsigned short pid, bool toOthers) noexcept
void FactionFunctions::SendFactionChanges(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_FACTION)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_FACTION)->Send(toOthers);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_FACTION);
packet->setPlayer(player);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}

@ -144,11 +144,13 @@ public:
* \brief Send a PlayerFaction packet with a player's recorded faction changes.
*
* \param pid The player ID whose faction changes should be used.
* \param toOthers Whether this packet should be sent only to other players or
* only to the player it is about.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendFactionChanges(unsigned short pid, bool toOthers = false) noexcept;
static void SendFactionChanges(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
private:
};

@ -18,8 +18,10 @@ void GUIFunctions::_MessageBox(unsigned short pid, int id, const char *label) no
player->guiMessageBox.label = label;
player->guiMessageBox.type = Player::GUIMessageBox::MessageBox;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
packet->setPlayer(player);
packet->Send(false);
}
void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *label, const char *buttons) noexcept
@ -32,8 +34,10 @@ void GUIFunctions::CustomMessageBox(unsigned short pid, int id, const char *labe
player->guiMessageBox.buttons = buttons;
player->guiMessageBox.type = Player::GUIMessageBox::CustomMessageBox;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
packet->setPlayer(player);
packet->Send(false);
}
void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label, const char *note) noexcept
@ -46,8 +50,10 @@ void GUIFunctions::InputDialog(unsigned short pid, int id, const char *label, co
player->guiMessageBox.note = note;
player->guiMessageBox.type = Player::GUIMessageBox::InputDialog;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
packet->setPlayer(player);
packet->Send(false);
}
void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label, const char *note) noexcept
@ -60,8 +66,10 @@ void GUIFunctions::PasswordDialog(unsigned short pid, int id, const char *label,
player->guiMessageBox.note = note;
player->guiMessageBox.type = Player::GUIMessageBox::PasswordDialog;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
packet->setPlayer(player);
packet->Send(false);
}
void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const char *items)
@ -74,8 +82,10 @@ void GUIFunctions::ListBox(unsigned short pid, int id, const char *label, const
player->guiMessageBox.data = items;
player->guiMessageBox.type = Player::GUIMessageBox::ListBox;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GUI_MESSAGEBOX);
packet->setPlayer(player);
packet->Send(false);
}
void GUIFunctions::InitializeQuickKeyChanges(unsigned short pid) noexcept

@ -168,18 +168,25 @@ void ItemFunctions::SendEquipment(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_EQUIPMENT)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_EQUIPMENT)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_EQUIPMENT)->Send(true);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_EQUIPMENT);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
player->equipmentIndexChanges.clear();
}
void ItemFunctions::SendInventoryChanges(unsigned short pid, bool toOthers) noexcept
void ItemFunctions::SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_INVENTORY)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_INVENTORY)->Send(toOthers);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_INVENTORY);
packet->setPlayer(player);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}

@ -211,11 +211,13 @@ public:
* \brief Send a PlayerInventory packet with a player's recorded inventory changes.
*
* \param pid The player ID whose inventory changes should be used.
* \param toOthers Whether this packet should be sent only to other players or
* only to the player it is about.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendInventoryChanges(unsigned short pid, bool toOthers = false) noexcept;
static void SendInventoryChanges(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
private:
};

@ -171,8 +171,10 @@ void MechanicsFunctions::SendMarkLocation(unsigned short pid)
player->miscellaneousChangeType = mwmp::MISCELLANEOUS_CHANGE_TYPE::MARK_LOCATION;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MISCELLANEOUS)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MISCELLANEOUS)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MISCELLANEOUS);
packet->setPlayer(player);
packet->Send(false);
}
void MechanicsFunctions::SendSelectedSpell(unsigned short pid)
@ -182,8 +184,10 @@ void MechanicsFunctions::SendSelectedSpell(unsigned short pid)
player->miscellaneousChangeType = mwmp::MISCELLANEOUS_CHANGE_TYPE::SELECTED_SPELL;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MISCELLANEOUS)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MISCELLANEOUS)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MISCELLANEOUS);
packet->setPlayer(player);
packet->Send(false);
}
void MechanicsFunctions::Jail(unsigned short pid, int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases,
@ -198,8 +202,10 @@ void MechanicsFunctions::Jail(unsigned short pid, int jailDays, bool ignoreJailT
player->jailProgressText = jailProgressText;
player->jailEndText = jailEndText;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JAIL)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JAIL)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JAIL);
packet->setPlayer(player);
packet->Send(false);
}
void MechanicsFunctions::Resurrect(unsigned short pid, unsigned int type) noexcept
@ -209,9 +215,11 @@ void MechanicsFunctions::Resurrect(unsigned short pid, unsigned int type) noexce
player->resurrectType = type;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_RESURRECT)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_RESURRECT)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_RESURRECT)->Send(true);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_RESURRECT);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
}
// All methods below are deprecated versions of methods from above

@ -399,123 +399,135 @@ void ObjectFunctions::AddContainerItem() noexcept
tempContainerItem = emptyContainerItem;
}
void ObjectFunctions::SendObjectPlace(bool broadcast) noexcept
void ObjectFunctions::SendObjectPlace(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_PLACE);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendObjectSpawn(bool broadcast) noexcept
void ObjectFunctions::SendObjectSpawn(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_SPAWN);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendObjectDelete(bool broadcast) noexcept
void ObjectFunctions::SendObjectDelete(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_DELETE);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendObjectLock(bool broadcast) noexcept
void ObjectFunctions::SendObjectLock(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_LOCK);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendObjectTrap(bool broadcast) noexcept
void ObjectFunctions::SendObjectTrap(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_TRAP);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendObjectScale(bool broadcast) noexcept
void ObjectFunctions::SendObjectScale(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_SCALE);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendObjectState(bool broadcast) noexcept
void ObjectFunctions::SendObjectState(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_OBJECT_STATE);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendDoorState(bool broadcast) noexcept
void ObjectFunctions::SendDoorState(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_DOOR_STATE);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendDoorDestination(bool broadcast) noexcept
void ObjectFunctions::SendDoorDestination(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_DOOR_DESTINATION);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendContainer(bool broadcast) noexcept
void ObjectFunctions::SendContainer(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONTAINER);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendVideoPlay(bool broadcast) noexcept
void ObjectFunctions::SendVideoPlay(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_VIDEO_PLAY);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void ObjectFunctions::SendConsoleCommand(bool broadcast) noexcept
void ObjectFunctions::SendConsoleCommand(bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
mwmp::ObjectPacket *packet = mwmp::Networking::get().getObjectPacketController()->GetPacket(ID_CONSOLE_COMMAND);
packet->setObjectList(&writeObjectList);
packet->Send(false);
if (broadcast)
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}

@ -779,22 +779,24 @@ public:
/**
* \brief Send an ObjectPlace packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendObjectPlace(bool broadcast = false) noexcept;
static void SendObjectPlace(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send an ObjectSpawn packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendObjectSpawn(bool broadcast = false) noexcept;
static void SendObjectSpawn(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send an ObjectDelete packet.
@ -804,17 +806,18 @@ public:
*
* \return void
*/
static void SendObjectDelete(bool broadcast = false) noexcept;
static void SendObjectDelete(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send an ObjectLock packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendObjectLock(bool broadcast = false) noexcept;
static void SendObjectLock(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send an ObjectTrap packet.
@ -824,77 +827,84 @@ public:
*
* \return void
*/
static void SendObjectTrap(bool broadcast = false) noexcept;
static void SendObjectTrap(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send an ObjectScale packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendObjectScale(bool broadcast = false) noexcept;
static void SendObjectScale(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send an ObjectState packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendObjectState(bool broadcast = false) noexcept;
static void SendObjectState(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send a DoorState packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendDoorState(bool broadcast = false) noexcept;
static void SendDoorState(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send a DoorDestination packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendDoorDestination(bool broadcast = false) noexcept;
static void SendDoorDestination(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send a Container packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendContainer(bool broadcast = false) noexcept;
static void SendContainer(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send a VideoPlay packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendVideoPlay(bool broadcast = false) noexcept;
static void SendVideoPlay(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send a ConsoleCommand packet.
*
* \param broadcast Whether this packet should be sent only to the player for whom the current
* object list was initialized or to everyone on the server.
*
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendConsoleCommand(bool broadcast = false) noexcept;
static void SendConsoleCommand(bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
// All methods below are deprecated versions of methods from above

@ -133,8 +133,10 @@ void PositionFunctions::SendPos(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_POSITION)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_POSITION)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_POSITION);
packet->setPlayer(player);
packet->Send(false);
}
void PositionFunctions::SendMomentum(unsigned short pid) noexcept
@ -142,6 +144,8 @@ void PositionFunctions::SendMomentum(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MOMENTUM)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MOMENTUM)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_MOMENTUM);
packet->setPlayer(player);
packet->Send(false);
}

@ -149,29 +149,44 @@ int QuestFunctions::GetReputation(unsigned short pid) noexcept
return player->npcStats.mReputation;
}
void QuestFunctions::SendJournalChanges(unsigned short pid, bool toOthers) noexcept
void QuestFunctions::SendJournalChanges(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JOURNAL)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JOURNAL)->Send(toOthers);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_JOURNAL);
packet->setPlayer(player);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void QuestFunctions::SendKillChanges(unsigned short pid, bool toOthers) noexcept
void QuestFunctions::SendKillChanges(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT)->Send(toOthers);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_KILL_COUNT);
packet->setPlayer(player);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void QuestFunctions::SendReputation(unsigned short pid, bool toOthers) noexcept
void QuestFunctions::SendReputation(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_REPUTATION)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_REPUTATION)->Send(toOthers);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_REPUTATION);
packet->setPlayer(player);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}

@ -175,31 +175,37 @@ public:
* \brief Send a PlayerJournal packet with a player's recorded journal changes.
*
* \param pid The player ID whose journal changes should be used.
* \param toOthers Whether this packet should be sent only to other players or
* only to the player it is about.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendJournalChanges(unsigned short pid, bool toOthers = false) noexcept;
static void SendJournalChanges(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send a PlayerKillCount packet with a player's recorded kill count changes.
*
* \param pid The player ID whose kill count changes should be used.
* \param toOthers Whether this packet should be sent only to other players or
* only to the player it is about.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendKillChanges(unsigned short pid, bool toOthers = false) noexcept;
static void SendKillChanges(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send a PlayerReputation packet with a player's recorded reputation.
*
* \param pid The player ID whose reputation should be used.
* \param toOthers Whether this packet should be sent only to other players or
* only to the player it is about.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendReputation(unsigned short pid, bool toOthers) noexcept;
static void SendReputation(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
private:

@ -70,6 +70,8 @@ void SettingFunctions::SendSettings(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_GAME_SETTINGS);
packet->setPlayer(player);
packet->Send(false);
}

@ -78,7 +78,9 @@ void ShapeshiftFunctions::SendShapeshift(unsigned short pid)
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT)->Send(true);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SHAPESHIFT);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
}

@ -269,11 +269,16 @@ int SpellFunctions::GetSpellEffectMagnMax(unsigned short pid, unsigned int i, un
return player->spellbookChanges.spells.at(i).mEffects.mList.at(j).mMagnMax;
}
void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool toOthers) noexcept
void SpellFunctions::SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPELLBOOK)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPELLBOOK)->Send(toOthers);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SPELLBOOK);
packet->setPlayer(player);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}

@ -255,11 +255,13 @@ public:
* \brief Send a PlayerSpellbook packet with a player's recorded spellbook changes.
*
* \param pid The player ID whose spellbook changes should be used.
* \param toOthers Whether this packet should be sent only to other players or
* only to the player it is about.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendSpellbookChanges(unsigned short pid, bool toOthers = false) noexcept;
static void SendSpellbookChanges(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
private:

@ -510,8 +510,10 @@ void StatsFunctions::SetCharGenStage(unsigned short pid, int currentStage, int e
player->charGenState.endStage = endStage;
player->charGenState.isFinished = false;
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARGEN)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARGEN)->Send(false);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_CHARGEN);
packet->setPlayer(player);
packet->Send(false);
}
void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
@ -519,9 +521,11 @@ void StatsFunctions::SendBaseInfo(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BASEINFO)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BASEINFO)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BASEINFO)->Send(true);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BASEINFO);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
}
void StatsFunctions::SendStatsDynamic(unsigned short pid) noexcept
@ -529,9 +533,11 @@ void StatsFunctions::SendStatsDynamic(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_STATS_DYNAMIC)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_STATS_DYNAMIC)->Send(true);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_STATS_DYNAMIC);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
player->statsDynamicIndexChanges.clear();
}
@ -541,9 +547,11 @@ void StatsFunctions::SendAttributes(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ATTRIBUTE)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ATTRIBUTE)->Send(true);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_ATTRIBUTE);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
player->attributeIndexChanges.clear();
}
@ -553,9 +561,11 @@ void StatsFunctions::SendSkills(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player,);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SKILL)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SKILL)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SKILL)->Send(true);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_SKILL);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
player->skillIndexChanges.clear();
}
@ -565,9 +575,11 @@ void StatsFunctions::SendLevel(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_LEVEL)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_LEVEL)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_LEVEL)->Send(true);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_LEVEL);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
}
void StatsFunctions::SendBounty(unsigned short pid) noexcept
@ -575,7 +587,9 @@ void StatsFunctions::SendBounty(unsigned short pid) noexcept
Player *player;
GET_PLAYER(pid, player, );
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOUNTY)->setPlayer(player);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOUNTY)->Send(false);
mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOUNTY)->Send(true);
mwmp::PlayerPacket *packet = mwmp::Networking::get().getPlayerPacketController()->GetPacket(ID_PLAYER_BOUNTY);
packet->setPlayer(player);
packet->Send(false);
packet->Send(true);
}

@ -137,44 +137,50 @@ void WorldstateFunctions::LoadMapTileImageFile(int cellX, int cellY, const char*
}
}
void WorldstateFunctions::SendWorldMap(unsigned short pid, bool broadcast) noexcept
void WorldstateFunctions::SendWorldMap(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
writeWorldstate.guid = player->guid;
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_MAP)->setWorldstate(&writeWorldstate);
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_MAP)->Send(false);
mwmp::WorldstatePacket *packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_MAP);
packet->setWorldstate(&writeWorldstate);
if (broadcast)
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_MAP)->Send(true);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void WorldstateFunctions::SendWorldTime(unsigned short pid, bool broadcast) noexcept
void WorldstateFunctions::SendWorldTime(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
writeWorldstate.guid = player->guid;
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->setWorldstate(&writeWorldstate);
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(false);
mwmp::WorldstatePacket *packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME);
packet->setWorldstate(&writeWorldstate);
if (broadcast)
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_TIME)->Send(true);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}
void WorldstateFunctions::SendWorldCollisionOverride(unsigned short pid, bool broadcast) noexcept
void WorldstateFunctions::SendWorldCollisionOverride(unsigned short pid, bool sendToOtherPlayers, bool sendToAttachedPlayer) noexcept
{
Player *player;
GET_PLAYER(pid, player, );
writeWorldstate.guid = player->guid;
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->setWorldstate(&writeWorldstate);
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->Send(false);
mwmp::WorldstatePacket *packet = mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE);
packet->setWorldstate(&writeWorldstate);
if (broadcast)
mwmp::Networking::get().getWorldstatePacketController()->GetPacket(ID_WORLD_COLLISION_OVERRIDE)->Send(true);
if (sendToAttachedPlayer)
packet->Send(false);
if (sendToOtherPlayers)
packet->Send(true);
}

@ -223,29 +223,33 @@ public:
* or to all players on the server.
* \return void
*/
static void SendWorldMap(unsigned short pid, bool broadcast = false) noexcept;
static void SendWorldMap(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send a WorldTime packet with the current time and time scale in the write-only
* worldstate.
*
* \param pid The player ID attached to the packet.
* \param broadcast Whether this packet should be sent only to the attached player
* or to all players on the server.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendWorldTime(unsigned short pid, bool broadcast = false) noexcept;
static void SendWorldTime(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Send a WorldCollisionOverride packet with the current collision overrides in
* the write-only worldstate.
*
* \param pid The player ID attached to the packet.
* \param broadcast Whether this packet should be sent only to the attached player
* or to all players on the server.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendWorldCollisionOverride(unsigned short pid, bool broadcast = false) noexcept;
static void SendWorldCollisionOverride(unsigned short pid, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
};

@ -61,10 +61,13 @@ public:
*
* \param pid The player ID.
* \param message The contents of the message.
* \param broadcast Whether the message should also be sent to other players.
* \param sendToOtherPlayers Whether this packet should be sent to players other than the
* player attached to the packet (false by default).
* \param sendToAttachedPlayer Whether the packet should be sent to the player attached
* to the packet (true by default).
* \return void
*/
static void SendMessage(unsigned short pid, const char *message, bool broadcast) noexcept;
static void SendMessage(unsigned short pid, const char *message, bool sendToOtherPlayers = false, bool sendToAttachedPlayer = true) noexcept;
/**
* \brief Remove all messages from chat for a certain player.

Loading…
Cancel
Save