mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-06-23 09:41:35 +00:00
[Client] Ignore cell changes that move actors to where they already are
This commit is contained in:
parent
4a9a628a0f
commit
09548d05f7
1 changed files with 20 additions and 6 deletions
|
@ -64,14 +64,16 @@ void Cell::updateLocal(bool forceUpdate)
|
||||||
// If the cell this actor has moved to is under our authority, move them to it
|
// If the cell this actor has moved to is under our authority, move them to it
|
||||||
if (cellController->hasLocalAuthority(actor->cell))
|
if (cellController->hasLocalAuthority(actor->cell))
|
||||||
{
|
{
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Moving LocalActor %s to our authority in %s", mapIndex.c_str(), actor->cell.getDescription().c_str());
|
LOG_APPEND(Log::LOG_INFO, "- Moving LocalActor %s to our authority in %s",
|
||||||
|
mapIndex.c_str(), actor->cell.getDescription().c_str());
|
||||||
Cell *newCell = cellController->getCell(actor->cell);
|
Cell *newCell = cellController->getCell(actor->cell);
|
||||||
newCell->localActors[mapIndex] = actor;
|
newCell->localActors[mapIndex] = actor;
|
||||||
cellController->setLocalActorRecord(mapIndex, newCell->getDescription());
|
cellController->setLocalActorRecord(mapIndex, newCell->getDescription());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Deleting LocalActor %s which is no longer under our authority", mapIndex.c_str(), getDescription().c_str());
|
LOG_APPEND(Log::LOG_INFO, "- Deleting LocalActor %s which is no longer under our authority",
|
||||||
|
mapIndex.c_str(), getDescription().c_str());
|
||||||
cellController->removeLocalActorRecord(mapIndex);
|
cellController->removeLocalActorRecord(mapIndex);
|
||||||
delete actor;
|
delete actor;
|
||||||
}
|
}
|
||||||
|
@ -281,6 +283,14 @@ void Cell::readCellChange(ActorList& actorList)
|
||||||
{
|
{
|
||||||
std::string mapIndex = Main::get().getCellController()->generateMapIndex(baseActor);
|
std::string mapIndex = Main::get().getCellController()->generateMapIndex(baseActor);
|
||||||
|
|
||||||
|
// Is a packet mistakenly moving the actor to the cell it's already in? If so, ignore it
|
||||||
|
if (Misc::StringUtils::ciEqual(getDescription(), baseActor.cell.getDescription()))
|
||||||
|
{
|
||||||
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Server says DedicatedActor %s moved to %s, but it was already there",
|
||||||
|
mapIndex.c_str(), getDescription().c_str());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (dedicatedActors.count(mapIndex) > 0)
|
if (dedicatedActors.count(mapIndex) > 0)
|
||||||
{
|
{
|
||||||
DedicatedActor *dedicatedActor = dedicatedActors[mapIndex];
|
DedicatedActor *dedicatedActor = dedicatedActors[mapIndex];
|
||||||
|
@ -288,7 +298,8 @@ void Cell::readCellChange(ActorList& actorList)
|
||||||
dedicatedActor->position = baseActor.position;
|
dedicatedActor->position = baseActor.position;
|
||||||
dedicatedActor->direction = baseActor.direction;
|
dedicatedActor->direction = baseActor.direction;
|
||||||
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Server says DedicatedActor %s moved to %s", mapIndex.c_str(), dedicatedActor->cell.getDescription().c_str());
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Server says DedicatedActor %s moved to %s",
|
||||||
|
mapIndex.c_str(), dedicatedActor->cell.getDescription().c_str());
|
||||||
|
|
||||||
MWWorld::CellStore *newStore = cellController->getCellStore(dedicatedActor->cell);
|
MWWorld::CellStore *newStore = cellController->getCellStore(dedicatedActor->cell);
|
||||||
dedicatedActor->setCell(newStore);
|
dedicatedActor->setCell(newStore);
|
||||||
|
@ -296,7 +307,8 @@ void Cell::readCellChange(ActorList& actorList)
|
||||||
// If the cell this actor has moved to is active and not under our authority, move them to it
|
// If the cell this actor has moved to is active and not under our authority, move them to it
|
||||||
if (cellController->isActiveWorldCell(dedicatedActor->cell) && !cellController->hasLocalAuthority(dedicatedActor->cell))
|
if (cellController->isActiveWorldCell(dedicatedActor->cell) && !cellController->hasLocalAuthority(dedicatedActor->cell))
|
||||||
{
|
{
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Moving DedicatedActor %s to our active cell %s", mapIndex.c_str(), dedicatedActor->cell.getDescription().c_str());
|
LOG_APPEND(Log::LOG_INFO, "- Moving DedicatedActor %s to our active cell %s",
|
||||||
|
mapIndex.c_str(), dedicatedActor->cell.getDescription().c_str());
|
||||||
cellController->initializeCell(dedicatedActor->cell);
|
cellController->initializeCell(dedicatedActor->cell);
|
||||||
Cell *newCell = cellController->getCell(dedicatedActor->cell);
|
Cell *newCell = cellController->getCell(dedicatedActor->cell);
|
||||||
newCell->dedicatedActors[mapIndex] = dedicatedActor;
|
newCell->dedicatedActors[mapIndex] = dedicatedActor;
|
||||||
|
@ -306,7 +318,8 @@ void Cell::readCellChange(ActorList& actorList)
|
||||||
{
|
{
|
||||||
if (cellController->hasLocalAuthority(dedicatedActor->cell))
|
if (cellController->hasLocalAuthority(dedicatedActor->cell))
|
||||||
{
|
{
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Creating new LocalActor based on %s in %s", mapIndex.c_str(), dedicatedActor->cell.getDescription().c_str());
|
LOG_APPEND(Log::LOG_INFO, "- Creating new LocalActor based on %s in %s",
|
||||||
|
mapIndex.c_str(), dedicatedActor->cell.getDescription().c_str());
|
||||||
Cell *newCell = cellController->getCell(dedicatedActor->cell);
|
Cell *newCell = cellController->getCell(dedicatedActor->cell);
|
||||||
LocalActor *localActor = new LocalActor();
|
LocalActor *localActor = new LocalActor();
|
||||||
localActor->cell = dedicatedActor->cell;
|
localActor->cell = dedicatedActor->cell;
|
||||||
|
@ -322,7 +335,8 @@ void Cell::readCellChange(ActorList& actorList)
|
||||||
cellController->setLocalActorRecord(mapIndex, newCell->getDescription());
|
cellController->setLocalActorRecord(mapIndex, newCell->getDescription());
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Deleting DedicatedActor %s which is no longer needed", mapIndex.c_str(), getDescription().c_str());
|
LOG_APPEND(Log::LOG_INFO, "- Deleting DedicatedActor %s which is no longer needed",
|
||||||
|
mapIndex.c_str(), getDescription().c_str());
|
||||||
cellController->removeDedicatedActorRecord(mapIndex);
|
cellController->removeDedicatedActorRecord(mapIndex);
|
||||||
delete dedicatedActor;
|
delete dedicatedActor;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue