#ifndef _GAME_CELL_STORE_H #define _GAME_CELL_STORE_H /* Cell storage. Used to load, look up and store all references in a single cell. Depends on esm/loadcell.hpp (loading from ESM) and esm_store.hpp (looking up references.) Neither of these modules depend on us. */ #include "store.hpp" #include "components/esm/records.hpp" #include "components/esm/loadcell.hpp" #include #include namespace ESMS { using namespace ESM; /// A reference to one object (of any type) in a cell. template struct LiveCellRef { // The object that this instance is based on. const X* base; /* Information about this instance, such as 3D location and rotation and individual type-dependent data. */ CellRef ref; /* Pointer to any user-defined or engine-specific object. Eg. a Sound object for sound sources. */ void *custom; }; /// A list of cell references template struct CellRefList { typedef LiveCellRef LiveRef; typedef std::list List; List list; // Search for the given reference in the given reclist from // ESMStore. Insert the reference into the list if a match is // found. If not, throw an exception. template void find(CellRef &ref, const Y& recList) { const X* obj = recList.find(ref.refID); if(obj == NULL) throw str_exception("Error resolving cell reference " + ref.refID); LiveRef lr; lr.ref = ref; lr.base = obj; lr.custom = NULL; list.push_back(lr); } }; /// A storage struct for one single cell reference. class CellStore { public: CellStore() : cell (0) {} const ESM::Cell *cell; // Lists for each individual object type CellRefList activators; CellRefList potions; CellRefList appas; CellRefList armors; CellRefList books; CellRefList clothes; CellRefList containers; CellRefList creatures; CellRefList doors; CellRefList ingreds; CellRefList creatureLists; CellRefList itemLists; CellRefList lights; CellRefList lockpicks; CellRefList miscItems; CellRefList npcs; CellRefList probes; CellRefList repairs; CellRefList statics; CellRefList weapons; /** Look up and load an interior cell from the given ESM data storage. */ void loadInt(const std::string &name, const ESMStore &data, ESMReader &esm); /** Ditto for exterior cell. */ void loadExt(int X, int Y, const ESMStore &data, ESMReader &esm); private: void loadRefs(const ESMStore &data, ESMReader &esm); }; } #endif