[Client] Add CellController methods to fetch Actors without needing Ptrs

0.6.1
David Cernat 8 years ago
parent 0ef9e014eb
commit 61cedfa192

@ -166,11 +166,20 @@ void CellController::removeLocalActorRecord(std::string actorIndex)
bool CellController::isLocalActor(MWWorld::Ptr ptr)
{
if (ptr.mRef == NULL)
return false;
std::string mapIndex = generateMapIndex(ptr);
return (localActorsToCells.count(mapIndex) > 0);
}
bool CellController::isLocalActor(std::string refId, int refNumIndex, int mpNum)
{
std::string mapIndex = generateMapIndex(refId, refNumIndex, mpNum);
return (localActorsToCells.count(mapIndex) > 0);
}
LocalActor *CellController::getLocalActor(MWWorld::Ptr ptr)
{
std::string actorIndex = generateMapIndex(ptr);
@ -179,6 +188,14 @@ LocalActor *CellController::getLocalActor(MWWorld::Ptr ptr)
return cellsActive.at(cellIndex)->getLocalActor(actorIndex);
}
LocalActor *CellController::getLocalActor(std::string refId, int refNumIndex, int mpNum)
{
std::string actorIndex = generateMapIndex(refId, refNumIndex, mpNum);
std::string cellIndex = localActorsToCells.at(actorIndex);
return cellsActive.at(cellIndex)->getLocalActor(actorIndex);
}
void CellController::setDedicatedActorRecord(std::string actorIndex, std::string cellIndex)
{
dedicatedActorsToCells[actorIndex] = cellIndex;
@ -189,8 +206,17 @@ void CellController::removeDedicatedActorRecord(std::string actorIndex)
dedicatedActorsToCells.erase(actorIndex);
}
bool CellController::isDedicatedActor(std::string refId, int refNumIndex, int mpNum)
{
std::string mapIndex = generateMapIndex(refId, refNumIndex, mpNum);
return (dedicatedActorsToCells.count(mapIndex) > 0);
}
bool CellController::isDedicatedActor(MWWorld::Ptr ptr)
{
if (ptr.mRef == NULL)
return false;
std::string mapIndex = generateMapIndex(ptr);
return (dedicatedActorsToCells.count(mapIndex) > 0);
@ -204,22 +230,32 @@ DedicatedActor *CellController::getDedicatedActor(MWWorld::Ptr ptr)
return cellsActive.at(cellIndex)->getDedicatedActor(actorIndex);
}
std::string CellController::generateMapIndex(MWWorld::Ptr ptr)
DedicatedActor *CellController::getDedicatedActor(std::string refId, int refNumIndex, int mpNum)
{
std::string actorIndex = generateMapIndex(refId, refNumIndex, mpNum);
std::string cellIndex = dedicatedActorsToCells.at(actorIndex);
return cellsActive.at(cellIndex)->getDedicatedActor(actorIndex);
}
std::string CellController::generateMapIndex(std::string refId, int refNumIndex, int mpNum)
{
std::string mapIndex = "";
mapIndex += ptr.getCellRef().getRefId();
mapIndex += "-" + Utils::toString(ptr.getCellRef().getRefNum().mIndex);
mapIndex += "-" + Utils::toString(ptr.getCellRef().getMpNum());
mapIndex += refId;
mapIndex += "-" + Utils::toString(refNumIndex);
mapIndex += "-" + Utils::toString(mpNum);
return mapIndex;
}
std::string CellController::generateMapIndex(MWWorld::Ptr ptr)
{
return generateMapIndex(ptr.getCellRef().getRefId(),
ptr.getCellRef().getRefNum().mIndex, ptr.getCellRef().getMpNum());
}
std::string CellController::generateMapIndex(BaseActor baseActor)
{
std::string mapIndex = "";
mapIndex += baseActor.refId;
mapIndex += "-" + Utils::toString(baseActor.refNumIndex);
mapIndex += "-" + Utils::toString(baseActor.mpNum);
return mapIndex;
return generateMapIndex(baseActor.refId, baseActor.refNumIndex, baseActor.mpNum);
}
bool CellController::isActiveCell(const ESM::Cell& cell)

@ -30,14 +30,21 @@ namespace mwmp
void setLocalActorRecord(std::string actorIndex, std::string cellIndex);
void removeLocalActorRecord(std::string actorIndex);
bool isLocalActor(MWWorld::Ptr ptr);
bool isLocalActor(std::string refId, int refNumIndex, int mpNum);
virtual LocalActor *getLocalActor(MWWorld::Ptr ptr);
virtual LocalActor *getLocalActor(std::string refId, int refNumIndex, int mpNum);
void setDedicatedActorRecord(std::string actorIndex, std::string cellIndex);
void removeDedicatedActorRecord(std::string actorIndex);
bool isDedicatedActor(MWWorld::Ptr ptr);
bool isDedicatedActor(std::string refId, int refNumIndex, int mpNum);
virtual DedicatedActor *getDedicatedActor(MWWorld::Ptr ptr);
virtual DedicatedActor *getDedicatedActor(std::string refId, int refNumIndex, int mpNum);
std::string generateMapIndex(std::string refId, int refNumindex, int mpNum);
std::string generateMapIndex(MWWorld::Ptr ptr);
std::string generateMapIndex(mwmp::BaseActor baseActor);

Loading…
Cancel
Save