[Client] When getting an actor, make sure their cell is initialized

0.6.2
David Cernat 7 years ago
parent 4caf7ca30a
commit 4a9a628a0f

@ -191,15 +191,16 @@ bool CellController::isLocalActor(MWWorld::Ptr ptr)
if (ptr.mRef == nullptr) if (ptr.mRef == nullptr)
return false; return false;
std::string mapIndex = generateMapIndex(ptr); std::string actorIndex = generateMapIndex(ptr);
return (localActorsToCells.count(mapIndex) > 0); return (localActorsToCells.count(actorIndex) > 0 && isInitializedCell(localActorsToCells.at(actorIndex)));
} }
bool CellController::isLocalActor(int refNumIndex, int mpNum) bool CellController::isLocalActor(int refNumIndex, int mpNum)
{ {
std::string mapIndex = generateMapIndex(refNumIndex, mpNum); std::string actorIndex = generateMapIndex(refNumIndex, mpNum);
return (localActorsToCells.count(mapIndex) > 0);
return (localActorsToCells.count(actorIndex) > 0 && isInitializedCell(localActorsToCells.at(actorIndex)));
} }
LocalActor *CellController::getLocalActor(MWWorld::Ptr ptr) LocalActor *CellController::getLocalActor(MWWorld::Ptr ptr)
@ -228,20 +229,21 @@ void CellController::removeDedicatedActorRecord(std::string actorIndex)
dedicatedActorsToCells.erase(actorIndex); dedicatedActorsToCells.erase(actorIndex);
} }
bool CellController::isDedicatedActor(int refNumIndex, int mpNum)
{
std::string mapIndex = generateMapIndex(refNumIndex, mpNum);
return (dedicatedActorsToCells.count(mapIndex) > 0);
}
bool CellController::isDedicatedActor(MWWorld::Ptr ptr) bool CellController::isDedicatedActor(MWWorld::Ptr ptr)
{ {
if (ptr.mRef == nullptr) if (ptr.mRef == nullptr)
return false; return false;
std::string mapIndex = generateMapIndex(ptr); std::string actorIndex = generateMapIndex(ptr);
return (dedicatedActorsToCells.count(mapIndex) > 0); return (dedicatedActorsToCells.count(actorIndex) > 0 && isInitializedCell(dedicatedActorsToCells.at(actorIndex)));
}
bool CellController::isDedicatedActor(int refNumIndex, int mpNum)
{
std::string actorIndex = generateMapIndex(refNumIndex, mpNum);
return (dedicatedActorsToCells.count(actorIndex) > 0 && isInitializedCell(dedicatedActorsToCells.at(actorIndex)));
} }
DedicatedActor *CellController::getDedicatedActor(MWWorld::Ptr ptr) DedicatedActor *CellController::getDedicatedActor(MWWorld::Ptr ptr)
@ -285,9 +287,14 @@ bool CellController::hasLocalAuthority(const ESM::Cell& cell)
return false; return false;
} }
bool CellController::isInitializedCell(const std::string& cellDescription)
{
return (cellsInitialized.count(cellDescription) > 0);
}
bool CellController::isInitializedCell(const ESM::Cell& cell) bool CellController::isInitializedCell(const ESM::Cell& cell)
{ {
return (cellsInitialized.count(cell.getDescription()) > 0); return isInitializedCell(cell.getDescription());
} }
bool CellController::isActiveWorldCell(const ESM::Cell& cell) bool CellController::isActiveWorldCell(const ESM::Cell& cell)

@ -51,6 +51,7 @@ namespace mwmp
std::string generateMapIndex(mwmp::BaseActor baseActor); std::string generateMapIndex(mwmp::BaseActor baseActor);
bool hasLocalAuthority(const ESM::Cell& cell); bool hasLocalAuthority(const ESM::Cell& cell);
bool isInitializedCell(const std::string& cellDescription);
bool isInitializedCell(const ESM::Cell& cell); bool isInitializedCell(const ESM::Cell& cell);
bool isActiveWorldCell(const ESM::Cell& cell); bool isActiveWorldCell(const ESM::Cell& cell);
virtual Cell *getCell(const ESM::Cell& cell); virtual Cell *getCell(const ESM::Cell& cell);

Loading…
Cancel
Save