mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-19 23:53:52 +00:00
[Client] Turn CellController's cellsActive into a map instead of a deque
This commit is contained in:
parent
d829d219c3
commit
e89265e469
3 changed files with 33 additions and 37 deletions
|
@ -78,11 +78,14 @@ void Cell::initializeLocalActors()
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptr(&*listIter, 0);
|
MWWorld::Ptr ptr(&*listIter, 0);
|
||||||
|
|
||||||
std::string mapIndex = generateMapIndex(ptr);
|
LocalActor *actor = new LocalActor();
|
||||||
localActors[mapIndex] = new LocalActor();
|
actor->cell = esmCell;
|
||||||
localActors[mapIndex]->cell = esmCell;
|
|
||||||
ptr.getBase()->isLocalActor = true;
|
ptr.getBase()->isLocalActor = true;
|
||||||
localActors[mapIndex]->setPtr(ptr);
|
actor->setPtr(ptr);
|
||||||
|
|
||||||
|
std::string mapIndex = generateMapIndex(ptr);
|
||||||
|
localActors[mapIndex] = actor;
|
||||||
|
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Initialized LocalActor %s", mapIndex.c_str());
|
LOG_APPEND(Log::LOG_INFO, "- Initialized LocalActor %s", mapIndex.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -112,13 +115,14 @@ void Cell::readCellFrame(mwmp::WorldEvent& worldEvent)
|
||||||
{
|
{
|
||||||
MWWorld::Ptr ptrFound = store->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
|
MWWorld::Ptr ptrFound = store->searchExact(worldObject.refId, worldObject.refNumIndex, worldObject.mpNum);
|
||||||
|
|
||||||
if (ptrFound)
|
if (!ptrFound) return;
|
||||||
{
|
|
||||||
dedicatedActors[mapIndex] = new DedicatedActor();
|
DedicatedActor *actor = new DedicatedActor();
|
||||||
dedicatedActors[mapIndex]->cell = worldEvent.cell;
|
actor->cell = worldEvent.cell;
|
||||||
dedicatedActors[mapIndex]->setPtr(ptrFound);
|
actor->setPtr(ptrFound);
|
||||||
LOG_APPEND(Log::LOG_INFO, "- Initialized DedicatedActor %s", mapIndex.c_str());
|
dedicatedActors[mapIndex] = actor;
|
||||||
}
|
|
||||||
|
LOG_APPEND(Log::LOG_INFO, "- Initialized DedicatedActor %s", mapIndex.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
// If this now exists, set its details
|
// If this now exists, set its details
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "LocalPlayer.hpp"
|
#include "LocalPlayer.hpp"
|
||||||
using namespace mwmp;
|
using namespace mwmp;
|
||||||
|
|
||||||
std::deque<mwmp::Cell *> CellController::cellsActive;
|
std::map<std::string, mwmp::Cell *> CellController::cellsActive;
|
||||||
|
|
||||||
mwmp::CellController::CellController()
|
mwmp::CellController::CellController()
|
||||||
{
|
{
|
||||||
|
@ -24,14 +24,14 @@ mwmp::CellController::~CellController()
|
||||||
|
|
||||||
void CellController::updateLocal()
|
void CellController::updateLocal()
|
||||||
{
|
{
|
||||||
for (std::deque<mwmp::Cell *>::iterator it = cellsActive.begin(); it != cellsActive.end();)
|
for (std::map<std::string, mwmp::Cell *>::iterator it = cellsActive.begin(); it != cellsActive.end();)
|
||||||
{
|
{
|
||||||
mwmp::Cell *mpCell = *it;
|
mwmp::Cell *mpCell = it->second;
|
||||||
|
|
||||||
if (!MWBase::Environment::get().getWorld()->isCellActive(mpCell->getCellStore()))
|
if (!MWBase::Environment::get().getWorld()->isCellActive(mpCell->getCellStore()))
|
||||||
{
|
{
|
||||||
mpCell->uninitializeLocalActors();
|
mpCell->uninitializeLocalActors();
|
||||||
it = cellsActive.erase(it);
|
cellsActive.erase(it++);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -49,42 +49,34 @@ void CellController::initializeCellLocal(const ESM::Cell& cell)
|
||||||
if (!cellStore) return;
|
if (!cellStore) return;
|
||||||
|
|
||||||
mwmp::Cell *mpCell = new mwmp::Cell(cellStore);
|
mwmp::Cell *mpCell = new mwmp::Cell(cellStore);
|
||||||
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Initialized mwmp::Cell %s", mpCell->getDescription().c_str());
|
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Initialized mwmp::Cell %s", mpCell->getDescription().c_str());
|
||||||
|
|
||||||
mpCell->initializeLocalActors();
|
mpCell->initializeLocalActors();
|
||||||
cellsActive.push_back(mpCell);
|
|
||||||
|
std::string mapIndex = mpCell->getDescription();
|
||||||
|
cellsActive[mapIndex] = mpCell;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CellController::readCellFrame(mwmp::WorldEvent& worldEvent)
|
void CellController::readCellFrame(mwmp::WorldEvent& worldEvent)
|
||||||
{
|
{
|
||||||
bool cellExisted = false;
|
std::string mapIndex = worldEvent.cell.getDescription();
|
||||||
|
|
||||||
// Check if this cell already exists
|
// If this key doesn't exist, create it
|
||||||
for (std::deque<mwmp::Cell *>::iterator it = cellsActive.begin(); it != cellsActive.end(); ++it)
|
if (cellsActive.count(mapIndex) == 0)
|
||||||
{
|
|
||||||
mwmp::Cell *mpCell = *it;
|
|
||||||
|
|
||||||
if (worldEvent.cell.getDescription() == mpCell->getDescription())
|
|
||||||
{
|
|
||||||
mpCell->readCellFrame(worldEvent);
|
|
||||||
cellExisted = true;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!cellExisted)
|
|
||||||
{
|
{
|
||||||
MWWorld::CellStore *cellStore = getCell(worldEvent.cell);
|
MWWorld::CellStore *cellStore = getCell(worldEvent.cell);
|
||||||
|
|
||||||
if (!cellStore) return;
|
if (!cellStore) return;
|
||||||
|
|
||||||
mwmp::Cell *mpCell = new mwmp::Cell(cellStore);
|
mwmp::Cell *mpCell = new mwmp::Cell(cellStore);
|
||||||
|
cellsActive[mapIndex] = mpCell;
|
||||||
|
}
|
||||||
|
|
||||||
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Initialized mwmp::Cell %s", mpCell->getDescription().c_str());
|
// If this now exists, send it the data
|
||||||
|
if (cellsActive.count(mapIndex) > 0)
|
||||||
cellsActive.push_back(mpCell);
|
{
|
||||||
mpCell->readCellFrame(worldEvent);
|
cellsActive[mapIndex]->readCellFrame(worldEvent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ namespace mwmp
|
||||||
void closeContainer(const MWWorld::Ptr& container);
|
void closeContainer(const MWWorld::Ptr& container);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::deque<mwmp::Cell *> cellsActive;
|
static std::map<std::string, mwmp::Cell *> cellsActive;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue