mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-27 17: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
|
void ActorFunctions::SendActorList() noexcept
|
||||||
{
|
{
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->setActorList(&writeActorList);
|
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST);
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_LIST)->Send(writeActorList.guid);
|
actorPacket->setActorList(&writeActorList);
|
||||||
|
actorPacket->Send(writeActorList.guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorFunctions::SendActorAuthority() noexcept
|
void ActorFunctions::SendActorAuthority() noexcept
|
||||||
|
@ -383,42 +384,58 @@ void ActorFunctions::SendActorAuthority() noexcept
|
||||||
{
|
{
|
||||||
serverCell->setAuthority(writeActorList.guid);
|
serverCell->setAuthority(writeActorList.guid);
|
||||||
|
|
||||||
mwmp::ActorPacket *authorityPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY);
|
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY);
|
||||||
authorityPacket->setActorList(&writeActorList);
|
actorPacket->setActorList(&writeActorList);
|
||||||
authorityPacket->Send(writeActorList.guid);
|
actorPacket->Send(writeActorList.guid);
|
||||||
|
|
||||||
// Also send this to everyone else who has the cell loaded
|
// Also send this to everyone else who has the cell loaded
|
||||||
serverCell->sendToLoaded(authorityPacket, &writeActorList);
|
serverCell->sendToLoaded(actorPacket, &writeActorList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorFunctions::SendActorPosition() noexcept
|
void ActorFunctions::SendActorPosition() noexcept
|
||||||
{
|
{
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_POSITION)->setActorList(&writeActorList);
|
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_POSITION);
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_POSITION)->Send(writeActorList.guid);
|
actorPacket->setActorList(&writeActorList);
|
||||||
|
actorPacket->Send(writeActorList.guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorFunctions::SendActorStatsDynamic() noexcept
|
void ActorFunctions::SendActorStatsDynamic() noexcept
|
||||||
{
|
{
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC)->setActorList(&writeActorList);
|
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC);
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_STATS_DYNAMIC)->Send(writeActorList.guid);
|
actorPacket->setActorList(&writeActorList);
|
||||||
|
actorPacket->Send(writeActorList.guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorFunctions::SendActorEquipment() noexcept
|
void ActorFunctions::SendActorEquipment() noexcept
|
||||||
{
|
{
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_EQUIPMENT)->setActorList(&writeActorList);
|
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_EQUIPMENT);
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_EQUIPMENT)->Send(writeActorList.guid);
|
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::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI);
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AI)->Send(writeActorList.guid);
|
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
|
void ActorFunctions::SendActorCellChange() noexcept
|
||||||
{
|
{
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->setActorList(&writeActorList);
|
mwmp::ActorPacket *actorPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE);
|
||||||
mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_CELL_CHANGE)->Send(writeActorList.guid);
|
actorPacket->setActorList(&writeActorList);
|
||||||
|
actorPacket->Send(writeActorList.guid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -689,11 +689,12 @@ public:
|
||||||
/**
|
/**
|
||||||
* \brief Send an ActorAI packet.
|
* \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
|
* \return void
|
||||||
*/
|
*/
|
||||||
static void SendActorAI() noexcept;
|
static void SendActorAI(bool sendToOtherVisitors) noexcept;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Send an ActorCellChange packet.
|
* \brief Send an ActorCellChange packet.
|
||||||
|
|
Loading…
Reference in a new issue