forked from mirror/openmw-tes3mp
[Server] Only read Actor packets from players who are still authorities
This commit is contained in:
parent
206c9cc357
commit
06f3c07116
10 changed files with 30 additions and 12 deletions
|
@ -155,6 +155,16 @@ void Cell::removeActors(const mwmp::BaseActorList *newActorList)
|
|||
cellActorList.count = cellActorList.baseActors.size();
|
||||
}
|
||||
|
||||
RakNet::RakNetGUID *Cell::getAuthority()
|
||||
{
|
||||
return &authorityGuid;
|
||||
}
|
||||
|
||||
void Cell::setAuthority(const RakNet::RakNetGUID& guid)
|
||||
{
|
||||
authorityGuid = guid;
|
||||
}
|
||||
|
||||
mwmp::BaseActorList *Cell::getActorList()
|
||||
{
|
||||
return &cellActorList;
|
||||
|
|
|
@ -34,6 +34,9 @@ public:
|
|||
bool containsActor(int refNumIndex, int mpNum);
|
||||
mwmp::BaseActor *getActor(int refNumIndex, int mpNum);
|
||||
void removeActors(const mwmp::BaseActorList *newActorList);
|
||||
|
||||
RakNet::RakNetGUID *getAuthority();
|
||||
void setAuthority(const RakNet::RakNetGUID& guid);
|
||||
mwmp::BaseActorList *getActorList();
|
||||
|
||||
TPlayers getPlayers() const;
|
||||
|
@ -47,6 +50,7 @@ private:
|
|||
TPlayers players;
|
||||
ESM::Cell cell;
|
||||
|
||||
RakNet::RakNetGUID authorityGuid;
|
||||
mwmp::BaseActorList cellActorList;
|
||||
};
|
||||
|
||||
|
|
|
@ -232,15 +232,19 @@ void ActorFunctions::SendActorList() noexcept
|
|||
|
||||
void ActorFunctions::SendActorAuthority() noexcept
|
||||
{
|
||||
mwmp::ActorPacket *authorityPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY);
|
||||
authorityPacket->setActorList(&writeActorList);
|
||||
authorityPacket->Send(writeActorList.guid);
|
||||
|
||||
// Also send this to everyone else who has the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&writeActorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
{
|
||||
serverCell->setAuthority(writeActorList.guid);
|
||||
|
||||
mwmp::ActorPacket *authorityPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY);
|
||||
authorityPacket->setActorList(&writeActorList);
|
||||
authorityPacket->Send(writeActorList.guid);
|
||||
|
||||
// Also send this to everyone else who has the cell loaded
|
||||
serverCell->sendToLoaded(authorityPacket, &writeActorList);
|
||||
}
|
||||
}
|
||||
|
||||
void ActorFunctions::SendActorPosition() noexcept
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
|||
// Send only to players who have the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||
serverCell->sendToLoaded(&packet, &actorList);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
|||
// Send only to players who have the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||
serverCell->sendToLoaded(&packet, &actorList);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
|||
// Send only to players who have the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||
serverCell->sendToLoaded(&packet, &actorList);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -17,7 +17,7 @@ namespace mwmp
|
|||
{
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||
{
|
||||
serverCell->removeActors(&actorList);
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
|||
// Send only to players who have the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||
{
|
||||
serverCell->readActorList(packetID, &actorList);
|
||||
serverCell->sendToLoaded(&packet, &actorList);
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
|||
// Send only to players who have the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||
serverCell->sendToLoaded(&packet, &actorList);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
|||
// Send only to players who have the cell loaded
|
||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||
|
||||
if (serverCell != nullptr)
|
||||
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||
{
|
||||
serverCell->readActorList(packetID, &actorList);
|
||||
serverCell->sendToLoaded(&packet, &actorList);
|
||||
|
|
Loading…
Reference in a new issue