MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) { std::map<std::pair<int, int>, Ptr::CellStore>::iterator result = mExteriors.find (std::make_pair (x, y)); if (result==mExteriors.end()) { const ESM::Cell *cell = mStore.cells.searchExt (x, y); if (!cell) { // Cell isn't predefined. Make one on the fly. ESM::Cell record; record.data.flags = 0; record.data.gridX = x; record.data.gridY = y; record.water = 0; record.mapColor = 0; cell = mWorld.createRecord (record); } result = mExteriors.insert (std::make_pair ( std::make_pair (x, y), Ptr::CellStore (cell))).first; } if (result->second.mState!=Ptr::CellStore::State_Loaded) { result->second.load (mStore, mReader); fillContainers (result->second); } return &result->second; }
MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name) { std::map<std::string, Ptr::CellStore>::iterator result = mInteriors.find (name); if (result==mInteriors.end()) { const ESM::Cell *cell = mStore.cells.findInt (name); result = mInteriors.insert (std::make_pair (name, Ptr::CellStore (cell))).first; } if (result->second.mState!=Ptr::CellStore::State_Loaded) { result->second.load (mStore, mReader); fillContainers (result->second); } return &result->second; }
MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) { std::map<std::pair<int, int>, Ptr::CellStore>::iterator result = mExteriors.find (std::make_pair (x, y)); if (result==mExteriors.end()) { const ESM::Cell *cell = mStore.get<ESM::Cell>().search(x, y); if (!cell) { // Cell isn't predefined. Make one on the fly. ESM::Cell record; record.mData.mFlags = 0; record.mData.mX = x; record.mData.mY = y; record.mWater = 0; record.mMapColor = 0; cell = MWBase::Environment::get().getWorld()->createRecord (record); } result = mExteriors.insert (std::make_pair ( std::make_pair (x, y), CellStore (cell))).first; } if (result->second.mState!=Ptr::CellStore::State_Loaded) { // Multiple plugin support for landscape data is much easier than for references. The last plugin wins. result->second.load (mStore, mReader); fillContainers (result->second); } return &result->second; }
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& cell) { if (cell.mState==Ptr::CellStore::State_Unloaded) cell.preload (mStore, mReader); if (cell.mState==Ptr::CellStore::State_Preloaded) { std::string lowerCase = Misc::StringUtils::lowerCase(name); if (std::binary_search (cell.mIds.begin(), cell.mIds.end(), lowerCase)) { cell.load (mStore, mReader); fillContainers (cell); } else return Ptr(); } MWWorld::Ptr ptr; if (MWWorld::LiveCellRef<ESM::Activator> *ref = cell.mActivators.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Potion> *ref = cell.mPotions.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = cell.mAppas.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Armor> *ref = cell.mArmors.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Book> *ref = cell.mBooks.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Clothing> *ref = cell.mClothes.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Container> *ref = cell.mContainers.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Creature> *ref = cell.mCreatures.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Door> *ref = cell.mDoors.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Ingredient> *ref = cell.mIngreds.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = cell.mCreatureLists.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::ItemLevList> *ref = cell.mItemLists.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Light> *ref = cell.mLights.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Lockpick> *ref = cell.mLockpicks.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = cell.mMiscItems.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::NPC> *ref = cell.mNpcs.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Probe> *ref = cell.mProbes.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Repair> *ref = cell.mRepairs.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Static> *ref = cell.mStatics.find (name)) ptr = Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Weapon> *ref = cell.mWeapons.find (name)) ptr = Ptr (ref, &cell); if (!ptr.isEmpty() && ptr.getRefData().getCount() > 0) { return ptr; } return Ptr(); }
MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& cell) { if (cell.mState==Ptr::CellStore::State_Unloaded) cell.preload (mStore, mReader); if (cell.mState==Ptr::CellStore::State_Preloaded) { std::string lowerCase; std::transform (name.begin(), name.end(), std::back_inserter (lowerCase), (int(*)(int)) std::tolower); if (std::binary_search (cell.mIds.begin(), cell.mIds.end(), lowerCase)) { cell.load (mStore, mReader); fillContainers (cell); } else return Ptr(); } if (MWWorld::LiveCellRef<ESM::Activator> *ref = cell.activators.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Potion> *ref = cell.potions.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Apparatus> *ref = cell.appas.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Armor> *ref = cell.armors.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Book> *ref = cell.books.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Clothing> *ref = cell.clothes.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Container> *ref = cell.containers.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Creature> *ref = cell.creatures.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Door> *ref = cell.doors.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Ingredient> *ref = cell.ingreds.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::CreatureLevList> *ref = cell.creatureLists.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::ItemLevList> *ref = cell.itemLists.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Light> *ref = cell.lights.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Tool> *ref = cell.lockpicks.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Miscellaneous> *ref = cell.miscItems.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::NPC> *ref = cell.npcs.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Probe> *ref = cell.probes.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Repair> *ref = cell.repairs.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Static> *ref = cell.statics.find (name)) return Ptr (ref, &cell); if (MWWorld::LiveCellRef<ESM::Weapon> *ref = cell.weapons.find (name)) return Ptr (ref, &cell); return Ptr(); }