forked from teamnwah/openmw-tes3coop
[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();
|
cellActorList.count = cellActorList.baseActors.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RakNet::RakNetGUID *Cell::getAuthority()
|
||||||
|
{
|
||||||
|
return &authorityGuid;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cell::setAuthority(const RakNet::RakNetGUID& guid)
|
||||||
|
{
|
||||||
|
authorityGuid = guid;
|
||||||
|
}
|
||||||
|
|
||||||
mwmp::BaseActorList *Cell::getActorList()
|
mwmp::BaseActorList *Cell::getActorList()
|
||||||
{
|
{
|
||||||
return &cellActorList;
|
return &cellActorList;
|
||||||
|
|
|
@ -34,6 +34,9 @@ public:
|
||||||
bool containsActor(int refNumIndex, int mpNum);
|
bool containsActor(int refNumIndex, int mpNum);
|
||||||
mwmp::BaseActor *getActor(int refNumIndex, int mpNum);
|
mwmp::BaseActor *getActor(int refNumIndex, int mpNum);
|
||||||
void removeActors(const mwmp::BaseActorList *newActorList);
|
void removeActors(const mwmp::BaseActorList *newActorList);
|
||||||
|
|
||||||
|
RakNet::RakNetGUID *getAuthority();
|
||||||
|
void setAuthority(const RakNet::RakNetGUID& guid);
|
||||||
mwmp::BaseActorList *getActorList();
|
mwmp::BaseActorList *getActorList();
|
||||||
|
|
||||||
TPlayers getPlayers() const;
|
TPlayers getPlayers() const;
|
||||||
|
@ -47,6 +50,7 @@ private:
|
||||||
TPlayers players;
|
TPlayers players;
|
||||||
ESM::Cell cell;
|
ESM::Cell cell;
|
||||||
|
|
||||||
|
RakNet::RakNetGUID authorityGuid;
|
||||||
mwmp::BaseActorList cellActorList;
|
mwmp::BaseActorList cellActorList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -232,15 +232,19 @@ void ActorFunctions::SendActorList() noexcept
|
||||||
|
|
||||||
void ActorFunctions::SendActorAuthority() noexcept
|
void ActorFunctions::SendActorAuthority() noexcept
|
||||||
{
|
{
|
||||||
|
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);
|
mwmp::ActorPacket *authorityPacket = mwmp::Networking::get().getActorPacketController()->GetPacket(ID_ACTOR_AUTHORITY);
|
||||||
authorityPacket->setActorList(&writeActorList);
|
authorityPacket->setActorList(&writeActorList);
|
||||||
authorityPacket->Send(writeActorList.guid);
|
authorityPacket->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
|
||||||
Cell *serverCell = CellController::get()->getCell(&writeActorList.cell);
|
|
||||||
|
|
||||||
if (serverCell != nullptr)
|
|
||||||
serverCell->sendToLoaded(authorityPacket, &writeActorList);
|
serverCell->sendToLoaded(authorityPacket, &writeActorList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActorFunctions::SendActorPosition() noexcept
|
void ActorFunctions::SendActorPosition() noexcept
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
||||||
// Send only to players who have the cell loaded
|
// Send only to players who have the cell loaded
|
||||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||||
|
|
||||||
if (serverCell != nullptr)
|
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||||
serverCell->sendToLoaded(&packet, &actorList);
|
serverCell->sendToLoaded(&packet, &actorList);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
||||||
// Send only to players who have the cell loaded
|
// Send only to players who have the cell loaded
|
||||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||||
|
|
||||||
if (serverCell != nullptr)
|
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||||
serverCell->sendToLoaded(&packet, &actorList);
|
serverCell->sendToLoaded(&packet, &actorList);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
||||||
// Send only to players who have the cell loaded
|
// Send only to players who have the cell loaded
|
||||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||||
|
|
||||||
if (serverCell != nullptr)
|
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||||
serverCell->sendToLoaded(&packet, &actorList);
|
serverCell->sendToLoaded(&packet, &actorList);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -17,7 +17,7 @@ namespace mwmp
|
||||||
{
|
{
|
||||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||||
|
|
||||||
if (serverCell != nullptr)
|
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||||
{
|
{
|
||||||
serverCell->removeActors(&actorList);
|
serverCell->removeActors(&actorList);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
||||||
// Send only to players who have the cell loaded
|
// Send only to players who have the cell loaded
|
||||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||||
|
|
||||||
if (serverCell != nullptr)
|
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||||
{
|
{
|
||||||
serverCell->readActorList(packetID, &actorList);
|
serverCell->readActorList(packetID, &actorList);
|
||||||
serverCell->sendToLoaded(&packet, &actorList);
|
serverCell->sendToLoaded(&packet, &actorList);
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
||||||
// Send only to players who have the cell loaded
|
// Send only to players who have the cell loaded
|
||||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||||
|
|
||||||
if (serverCell != nullptr)
|
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||||
serverCell->sendToLoaded(&packet, &actorList);
|
serverCell->sendToLoaded(&packet, &actorList);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -18,7 +18,7 @@ namespace mwmp
|
||||||
// Send only to players who have the cell loaded
|
// Send only to players who have the cell loaded
|
||||||
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
Cell *serverCell = CellController::get()->getCell(&actorList.cell);
|
||||||
|
|
||||||
if (serverCell != nullptr)
|
if (serverCell != nullptr && *serverCell->getAuthority() == actorList.guid)
|
||||||
{
|
{
|
||||||
serverCell->readActorList(packetID, &actorList);
|
serverCell->readActorList(packetID, &actorList);
|
||||||
serverCell->sendToLoaded(&packet, &actorList);
|
serverCell->sendToLoaded(&packet, &actorList);
|
||||||
|
|
Loading…
Reference in a new issue