#include "cells.hpp" MWWorld::Cells::Cells (const ESMS::ESMStore& store, ESM::ESMReader& reader) : mStore (store), mReader (reader) {} MWWorld::Ptr::CellStore *MWWorld::Cells::getExterior (int x, int y) { std::map, Ptr::CellStore>::iterator result = mExteriors.find (std::make_pair (x, y)); if (result==mExteriors.end()) { const ESM::Cell *cell = mStore.cells.findExt (x, y); result = mExteriors.insert (std::make_pair ( std::make_pair (x, y), Ptr::CellStore (cell))).first; result->second.load (mStore, mReader); } return &result->second; } MWWorld::Ptr::CellStore *MWWorld::Cells::getInterior (const std::string& name) { std::map::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; result->second.load (mStore, mReader); } return &result->second; } MWWorld::Ptr MWWorld::Cells::getPtr (const std::string& name, Ptr::CellStore& cell) { cell.load (mStore, mReader); if (ESMS::LiveCellRef *ref = cell.activators.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.potions.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.appas.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.armors.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.books.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.clothes.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.containers.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.creatures.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.doors.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.ingreds.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.creatureLists.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.itemLists.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.lights.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.lockpicks.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.miscItems.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.npcs.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.probes.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.repairs.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.statics.find (name)) return Ptr (ref, &cell); if (ESMS::LiveCellRef *ref = cell.weapons.find (name)) return Ptr (ref, &cell); return Ptr(); }