mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-27 10:09:40 +00:00
[Server] Add sendToOtherVisitors boolean to SendActorAI()
Additionally, avoid repetition in functions that send Actor packets.
This commit is contained in:
parent
25f7a55495
commit
5bb442bbd3
2 changed files with 37 additions and 19 deletions
|
@ -371,8 +371,9 @@ void ActorFunctions::AddActor() noexcept
|
|||
|
||||
void ActorFunctions::SendActorList() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->Send(writeActorList.guid);
|
||||
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST);
|
||||
actorPacket->setActorList(&writeActorList);
|
||||
actorPacket->Send(writeActorList.guid);
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorAuthority() noexcept
|
||||
|
@ -383,42 +384,58 @@ void ActorFunctions::SendActorAuthority() noexcept
|
|||
{
|
||||
serverCell->setAuthority(writeActorList.guid);
|
||||
|
||||
mwmp::ActorPacket *authorityPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY);
|
||||
authorityPacket->setActorList(&writeActorList);
|
||||
authorityPacket->Send(writeActorList.guid);
|
||||
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY);
|
||||
actorPacket->setActorList(&writeActorList);
|
||||
actorPacket->Send(writeActorList.guid);
|
||||
|
||||
// Also send this to everyone else who has the cell loaded
|
||||
serverCell->sendToLoaded(authorityPacket, &writeActorList);
|
||||
serverCell->sendToLoaded(actorPacket, &writeActorList);
|
||||
}
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorPosition() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_POSITION)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_POSITION)->Send(writeActorList.guid);
|
||||
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_POSITION);
|
||||
actorPacket->setActorList(&writeActorList);
|
||||
actorPacket->Send(writeActorList.guid);
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorStatsDynamic() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC)->Send(writeActorList.guid);
|
||||
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC);
|
||||
actorPacket->setActorList(&writeActorList);
|
||||
actorPacket->Send(writeActorList.guid);
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorEquipment() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_EQUIPMENT)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_EQUIPMENT)->Send(writeActorList.guid);
|
||||
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_EQUIPMENT);
|
||||
actorPacket->setActorList(&writeActorList);
|
||||
actorPacket->Send(writeActorList.guid);
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorAI() noexcept
|
||||
void ActorFunctions::SendActorAI(bool sendToOtherVisitors) noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI)->Send(writeActorList.guid);
|
||||
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI);
|
||||
actorPacket->setActorList(&writeActorList);
|
||||
actorPacket->Send(writeActorList.guid);
|
||||
|
||||
if (sendToOtherVisitors)
|
||||
{
|
||||
Cell *serverCell = CellController::get()->getCell(&writeActorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
{
|
||||
// Also send this to everyone else who has the cell loaded
|
||||
serverCell->sendToLoaded(actorPacket, &writeActorList);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorCellChange() noexcept
|
||||
{
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->setActorList(&writeActorList);
|
||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->Send(writeActorList.guid);
|
||||
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE);
|
||||
actorPacket->setActorList(&writeActorList);
|
||||
actorPacket->Send(writeActorList.guid);
|
||||
}
|
||||
|
||||
|
|
|
@ -689,11 +689,12 @@ public:
|
|||
/**
|
||||
* \brief Send an ActorAI 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).
|
||||
*
|
||||
* \return void
|
||||
*/
|
||||
static void SendActorAI() noexcept;
|
||||
static void SendActorAI(bool sendToOtherVisitors) noexcept;
|
||||
|
||||
/**
|
||||
* \brief Send an ActorCellChange packet.
|
||||
|
|
Loading…
Reference in a new issue