#include "../mwworld/worldimp.hpp" #include #include #include #include "Cell.hpp" #include "Main.hpp" #include "LocalPlayer.hpp" using namespace mwmp; mwmp::Cell::Cell(MWWorld::CellStore* cellStore) { store = cellStore; std::map localActors; std::map dedicatedActors; } mwmp::Cell::~Cell() { } void Cell::update() { for (std::map::iterator it = localActors.begin(); it != localActors.end();) { LocalActor *actor = it->second; // TODO:: Make sure this condition actually works if (actor->getPtr().getCell() != nullptr && actor->getPtr().getCell() != store) { LOG_APPEND(Log::LOG_INFO, "- Removing LocalActor %s which is no longer in this cell", it->first.c_str()); localActors.erase(it++); } else { LOG_APPEND(Log::LOG_VERBOSE, "- Updating LocalActor %s", it->first.c_str()); actor->update(); ++it; } } } void Cell::initializeLocalActors() { ESM::Cell esmCell = *store->getCell(); MWWorld::CellRefList *npcList = store->getNpcs(); for (typename MWWorld::CellRefList::List::iterator listIter(npcList->mList.begin()); listIter != npcList->mList.end(); ++listIter) { MWWorld::Ptr ptr(&*listIter, 0); std::string mapIndex = generateMapIndex(ptr); localActors[mapIndex] = new LocalActor(); localActors[mapIndex]->cell = esmCell; ptr.getBase()->isLocalActor = true; localActors[mapIndex]->setPtr(ptr); LOG_APPEND(Log::LOG_INFO, "- Initialized LocalActor %s", mapIndex.c_str()); } } void Cell::uninitializeLocalActors() { for (std::map::iterator it = localActors.begin(); it != localActors.end(); ++it) { LocalActor *actor = it->second; actor->getPtr().getBase()->isLocalActor = false; } localActors.clear(); } std::string Cell::generateMapIndex(MWWorld::Ptr ptr) { std::string mapIndex = ""; mapIndex += ptr.getCellRef().getRefId(); mapIndex += "-" + Utils::toString(ptr.getCellRef().getRefNum().mIndex); mapIndex += "-" + Utils::toString(ptr.getCellRef().getMpNum()); return mapIndex; } MWWorld::CellStore *mwmp::Cell::getCellStore() { return store; } std::string mwmp::Cell::getDescription() { return store->getCell()->getDescription(); }