[Server] Bring Actor functions in line with Object functions, part 2

The ActorPacket-sending functions now have sendToOtherVisitors and skipAttachedPlayer arguments, except for the ones for ActorList and ActorAuthority (because such arguments don't make sense for those).
remotes/1728160796594174844/tmp_0.7.0-alpha
David Cernat 7 years ago
parent 837c5369c0
commit aeb2e57444

@ -402,32 +402,70 @@ void ActorFunctions::SendActorAuthority() noexcept
}
}
void ActorFunctions::SendActorPosition() noexcept
void ActorFunctions::SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_POSITION);
actorPacket->setActorList(&writeActorList);
actorPacket->Send(writeActorList.guid);
if (!skipAttachedPlayer)
actorPacket->Send(writeActorList.guid);
if (sendToOtherVisitors)
{
Cell *serverCell = CellController::get()->getCell(&writeActorList.cell);
if (serverCell != nullptr)
{
serverCell->sendToLoaded(actorPacket, &writeActorList);
}
}
}
void ActorFunctions::SendActorStatsDynamic() noexcept
void ActorFunctions::SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC);
actorPacket->setActorList(&writeActorList);
actorPacket->Send(writeActorList.guid);
if (!skipAttachedPlayer)
actorPacket->Send(writeActorList.guid);
if (sendToOtherVisitors)
{
Cell *serverCell = CellController::get()->getCell(&writeActorList.cell);
if (serverCell != nullptr)
{
serverCell->sendToLoaded(actorPacket, &writeActorList);
}
}
}
void ActorFunctions::SendActorEquipment() noexcept
void ActorFunctions::SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_EQUIPMENT);
actorPacket->setActorList(&writeActorList);
actorPacket->Send(writeActorList.guid);
if (!skipAttachedPlayer)
actorPacket->Send(writeActorList.guid);
if (sendToOtherVisitors)
{
Cell *serverCell = CellController::get()->getCell(&writeActorList.cell);
if (serverCell != nullptr)
{
serverCell->sendToLoaded(actorPacket, &writeActorList);
}
}
}
void ActorFunctions::SendActorAI(bool sendToOtherVisitors) noexcept
void ActorFunctions::SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI);
actorPacket->setActorList(&writeActorList);
actorPacket->Send(writeActorList.guid);
if (!skipAttachedPlayer)
actorPacket->Send(writeActorList.guid);
if (sendToOtherVisitors)
{
@ -435,17 +473,28 @@ void ActorFunctions::SendActorAI(bool sendToOtherVisitors) noexcept
if (serverCell != nullptr)
{
// Also send this to everyone else who has the cell loaded
serverCell->sendToLoaded(actorPacket, &writeActorList);
}
}
}
void ActorFunctions::SendActorCellChange() noexcept
void ActorFunctions::SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept
{
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE);
actorPacket->setActorList(&writeActorList);
actorPacket->Send(writeActorList.guid);
if (!skipAttachedPlayer)
actorPacket->Send(writeActorList.guid);
if (sendToOtherVisitors)
{
Cell *serverCell = CellController::get()->getCell(&writeActorList.cell);
if (serverCell != nullptr)
{
serverCell->sendToLoaded(actorPacket, &writeActorList);
}
}
}
// All methods below are deprecated versions of methods from above

@ -682,48 +682,61 @@ public:
/**
* \brief Send an ActorPosition packet.
*
* It is sent only to the player for whom the current actor list was initialized.
* \param sendToOtherVisitors Whether this packet should be sent to cell visitors other
* than the player attached to the packet (false by default).
* \param skipAttachedPlayer Whether the packet should skip being sent to the player attached
* to the packet (false by default).
*
* \return void
*/
static void SendActorPosition() noexcept;
static void SendActorPosition(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorStatsDynamic packet.
*
* It is sent only to the player for whom the current actor list was initialized.
* \param sendToOtherVisitors Whether this packet should be sent to cell visitors other
* than the player attached to the packet (false by default).
* \param skipAttachedPlayer Whether the packet should skip being sent to the player attached
* to the packet (false by default).
*
* \return void
*/
static void SendActorStatsDynamic() noexcept;
static void SendActorStatsDynamic(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorEquipment packet.
*
* It is sent only to the player for whom the current actor list was initialized.
* \param sendToOtherVisitors Whether this packet should be sent to cell visitors other
* than the player attached to the packet (false by default).
* \param skipAttachedPlayer Whether the packet should skip being sent to the player attached
* to the packet (false by default).
*
* \return void
*/
static void SendActorEquipment() noexcept;
static void SendActorEquipment(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorAI packet.
*
* \param sendToOtherVisitors Whether this packet should be sent to cell visitors other
* than the player attached to the packet (false by default).
*
* \param skipAttachedPlayer Whether the packet should skip being sent to the player attached
* to the packet (false by default).
* \return void
*/
static void SendActorAI(bool sendToOtherVisitors) noexcept;
static void SendActorAI(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
/**
* \brief Send an ActorCellChange packet.
*
* It is sent only to the player for whom the current actor list was initialized.
* \param sendToOtherVisitors Whether this packet should be sent to cell visitors other
* than the player attached to the packet (false by default).
* \param skipAttachedPlayer Whether the packet should skip being sent to the player attached
* to the packet (false by default).
*
* \return void
*/
static void SendActorCellChange() noexcept;
static void SendActorCellChange(bool sendToOtherVisitors, bool skipAttachedPlayer) noexcept;
// All methods below are deprecated versions of methods from above

Loading…
Cancel
Save