[Client] Ignore cell changes that move actors to where they already are

0.6.2
David Cernat 6 years ago
parent 4a9a628a0f
commit 09548d05f7

@ -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 (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);
newCell->localActors[mapIndex] = actor;
cellController->setLocalActorRecord(mapIndex, newCell->getDescription());
}
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);
delete actor;
}
@ -281,6 +283,14 @@ void Cell::readCellChange(ActorList& actorList)
{
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)
{
DedicatedActor *dedicatedActor = dedicatedActors[mapIndex];
@ -288,7 +298,8 @@ void Cell::readCellChange(ActorList& actorList)
dedicatedActor->position = baseActor.position;
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);
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 (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);
Cell *newCell = cellController->getCell(dedicatedActor->cell);
newCell->dedicatedActors[mapIndex] = dedicatedActor;
@ -306,7 +318,8 @@ void Cell::readCellChange(ActorList& actorList)
{
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);
LocalActor *localActor = new LocalActor();
localActor->cell = dedicatedActor->cell;
@ -322,7 +335,8 @@ void Cell::readCellChange(ActorList& actorList)
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);
delete dedicatedActor;
}

Loading…
Cancel
Save