mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-02-20 19:39:41 +00:00
[Client] Make it possible to get DedicatedActor from CellController
This commit is contained in:
parent
6557577c03
commit
5b43e62c50
4 changed files with 54 additions and 1 deletions
|
@ -117,6 +117,16 @@ void Cell::uninitializeLocalActors()
|
|||
localActors.clear();
|
||||
}
|
||||
|
||||
void Cell::uninitializeDedicatedActors()
|
||||
{
|
||||
for (std::map<std::string, DedicatedActor *>::iterator it = dedicatedActors.begin(); it != dedicatedActors.end(); ++it)
|
||||
{
|
||||
Main::get().getCellController()->removeDedicatedActorRecord(it->first);
|
||||
}
|
||||
|
||||
dedicatedActors.clear();
|
||||
}
|
||||
|
||||
void Cell::readCellFrame(WorldEvent& worldEvent)
|
||||
{
|
||||
WorldObject worldObject;
|
||||
|
@ -138,6 +148,8 @@ void Cell::readCellFrame(WorldEvent& worldEvent)
|
|||
actor->setPtr(ptrFound);
|
||||
dedicatedActors[mapIndex] = actor;
|
||||
|
||||
Main::get().getCellController()->setDedicatedActorRecord(mapIndex, getDescription());
|
||||
|
||||
LOG_APPEND(Log::LOG_INFO, "- Initialized DedicatedActor %s", mapIndex.c_str());
|
||||
}
|
||||
|
||||
|
@ -158,6 +170,11 @@ LocalActor *Cell::getLocalActor(std::string actorIndex)
|
|||
return localActors.at(actorIndex);
|
||||
}
|
||||
|
||||
DedicatedActor *Cell::getDedicatedActor(std::string actorIndex)
|
||||
{
|
||||
return dedicatedActors.at(actorIndex);
|
||||
}
|
||||
|
||||
MWWorld::CellStore *Cell::getCellStore()
|
||||
{
|
||||
return store;
|
||||
|
|
|
@ -17,11 +17,15 @@ namespace mwmp
|
|||
|
||||
void updateLocal();
|
||||
void updateDedicated(float dt);
|
||||
|
||||
void initializeLocalActors();
|
||||
void uninitializeLocalActors();
|
||||
void uninitializeDedicatedActors();
|
||||
|
||||
void readCellFrame(mwmp::WorldEvent& worldEvent);
|
||||
|
||||
virtual LocalActor *getLocalActor(std::string actorIndex);
|
||||
virtual DedicatedActor *getDedicatedActor(std::string actorIndex);
|
||||
|
||||
MWWorld::CellStore* getCellStore();
|
||||
std::string getDescription();
|
||||
|
|
|
@ -14,6 +14,7 @@ using namespace mwmp;
|
|||
|
||||
std::map<std::string, mwmp::Cell *> CellController::cellsActive;
|
||||
std::map<std::string, std::string> CellController::localActorsToCells;
|
||||
std::map<std::string, std::string> CellController::dedicatedActorsToCells;
|
||||
|
||||
mwmp::CellController::CellController()
|
||||
{
|
||||
|
@ -34,6 +35,7 @@ void CellController::updateLocal()
|
|||
if (!MWBase::Environment::get().getWorld()->isCellActive(mpCell->getCellStore()))
|
||||
{
|
||||
mpCell->uninitializeLocalActors();
|
||||
mpCell->uninitializeDedicatedActors();
|
||||
cellsActive.erase(it++);
|
||||
}
|
||||
else
|
||||
|
@ -116,6 +118,31 @@ LocalActor *CellController::getLocalActor(MWWorld::Ptr ptr)
|
|||
return cellsActive.at(cellIndex)->getLocalActor(actorIndex);
|
||||
}
|
||||
|
||||
void CellController::setDedicatedActorRecord(std::string actorIndex, std::string cellIndex)
|
||||
{
|
||||
dedicatedActorsToCells[actorIndex] = cellIndex;
|
||||
}
|
||||
|
||||
void CellController::removeDedicatedActorRecord(std::string actorIndex)
|
||||
{
|
||||
dedicatedActorsToCells.erase(actorIndex);
|
||||
}
|
||||
|
||||
bool CellController::hasDedicatedActorRecord(MWWorld::Ptr ptr)
|
||||
{
|
||||
std::string mapIndex = generateMapIndex(ptr);
|
||||
|
||||
return (dedicatedActorsToCells.count(mapIndex) > 0);
|
||||
}
|
||||
|
||||
DedicatedActor *CellController::getDedicatedActor(MWWorld::Ptr ptr)
|
||||
{
|
||||
std::string actorIndex = generateMapIndex(ptr);
|
||||
std::string cellIndex = dedicatedActorsToCells.at(actorIndex);
|
||||
|
||||
return cellsActive.at(cellIndex)->getDedicatedActor(actorIndex);
|
||||
}
|
||||
|
||||
std::string CellController::generateMapIndex(MWWorld::Ptr ptr)
|
||||
{
|
||||
std::string mapIndex = "";
|
||||
|
|
|
@ -25,9 +25,13 @@ namespace mwmp
|
|||
void setLocalActorRecord(std::string actorIndex, std::string cellIndex);
|
||||
void removeLocalActorRecord(std::string actorIndex);
|
||||
bool hasLocalActorRecord(MWWorld::Ptr ptr);
|
||||
|
||||
virtual LocalActor *getLocalActor(MWWorld::Ptr ptr);
|
||||
|
||||
void setDedicatedActorRecord(std::string actorIndex, std::string cellIndex);
|
||||
void removeDedicatedActorRecord(std::string actorIndex);
|
||||
bool hasDedicatedActorRecord(MWWorld::Ptr ptr);
|
||||
virtual DedicatedActor *getDedicatedActor(MWWorld::Ptr ptr);
|
||||
|
||||
std::string generateMapIndex(MWWorld::Ptr ptr);
|
||||
std::string generateMapIndex(mwmp::WorldObject object);
|
||||
|
||||
|
@ -40,6 +44,7 @@ namespace mwmp
|
|||
private:
|
||||
static std::map<std::string, mwmp::Cell *> cellsActive;
|
||||
static std::map<std::string, std::string> localActorsToCells;
|
||||
static std::map<std::string, std::string> dedicatedActorsToCells;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue