1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-25 15:35:23 +00:00
OpenMW/game/esm_reclists.hpp

110 lines
2.2 KiB
C++
Raw Normal View History

2010-05-17 20:59:15 +02:00
#ifndef _GAME_ESM_RECLISTS_H
#define _GAME_ESM_RECLISTS_H
#include "esm/records.hpp"
#include <map>
#include <string>
namespace ESMS
{
using namespace ESM;
struct RecList
{
virtual void load(ESMReader &esm) = 0;
virtual int getSize() = 0;
};
typedef std::map<int,RecList*> RecListList;
template <typename X>
struct RecListT : RecList
{
typedef std::map<std::string,X> 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 <typename X>
struct RecIDListT : RecList
{
typedef std::map<std::string,X> 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.
2010-05-17 20:59:15 +02:00
int count;
CellList() : count(0) {}
int getSize() { return count; }
// List of interior cells. Indexed by cell name.
std::map<std::string,Cell> intCells;
// List of exterior cells. Indexed as extCells[gridX][gridY].
std::map<int, std::map<int, Cell> > extCells;
2010-05-17 20:59:15 +02:00
void load(ESMReader &esm)
{
using namespace std;
2010-05-17 20:59:15 +02:00
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;
}
}
2010-05-17 20:59:15 +02:00
};
/* We need special lists for:
Magic effects
Skills
Dialog / Info combo
Scripts
Land
Path grids
Land textures
*/
}
#endif