#ifndef _GAME_ESM_RECLISTS_H #define _GAME_ESM_RECLISTS_H #include "esm/records.hpp" #include #include namespace ESMS { using namespace ESM; struct RecList { virtual void load(ESMReader &esm) = 0; virtual int getSize() = 0; }; typedef std::map RecListList; template struct RecListT : RecList { typedef std::map MapType; MapType list; void load(ESMReader &esm) { std::string id = esm.getHNString("NAME"); X &ref = list[id]; ref.load(esm); } int getSize() { return list.size(); } }; // The only difference to the above is a slight change to the load() // function. We might merge these together later, and store the id // in all the structs. template struct RecIDListT : RecList { typedef std::map MapType; MapType list; void load(ESMReader &esm) { std::string id = esm.getHNString("NAME"); X &ref = list[id]; ref.id = id; ref.load(esm); } int getSize() { return list.size(); } }; // Cells aren't simply indexed by name. Exterior cells are treated // separately. struct CellList : RecList { // Total cell count. Used for statistics. int count; CellList() : count(0) {} int getSize() { return count; } // List of interior cells. Indexed by cell name. std::map intCells; // List of exterior cells. Indexed as extCells[gridX][gridY]. std::map > extCells; void load(ESMReader &esm) { using namespace std; count++; // The cell itself takes care of all the hairy details Cell cell; cell.load(esm); if(cell.data.flags & Cell::Interior) { // Store interior cell by name intCells[cell.name] = cell; } else { // Store exterior cells by grid position extCells[cell.data.gridX][cell.data.gridY] = cell; } } }; /* We need special lists for: Magic effects Skills Dialog / Info combo Scripts Land Path grids Land textures */ } #endif