2011-09-08 11:02:55 +02:00
|
|
|
#ifndef GAME_MWWORLD_CELLS_H
|
|
|
|
#define GAME_MWWORLD_CELLS_H
|
|
|
|
|
|
|
|
#include <map>
|
2012-11-10 21:43:41 +01:00
|
|
|
#include <list>
|
2011-09-08 11:02:55 +02:00
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include "ptr.hpp"
|
|
|
|
|
|
|
|
namespace ESM
|
|
|
|
{
|
|
|
|
class ESMReader;
|
2014-01-23 11:29:40 +01:00
|
|
|
class ESMWriter;
|
|
|
|
struct CellId;
|
2014-02-23 20:11:05 +01:00
|
|
|
struct Cell;
|
2011-09-08 11:02:55 +02:00
|
|
|
}
|
|
|
|
|
2012-10-01 19:17:04 +04:00
|
|
|
namespace MWWorld
|
2011-09-08 11:02:55 +02:00
|
|
|
{
|
|
|
|
class ESMStore;
|
|
|
|
|
|
|
|
/// \brief Cell container
|
|
|
|
class Cells
|
|
|
|
{
|
2012-10-01 19:17:04 +04:00
|
|
|
const MWWorld::ESMStore& mStore;
|
2012-11-10 21:43:41 +01:00
|
|
|
std::vector<ESM::ESMReader>& mReader;
|
2012-07-03 12:30:50 +02:00
|
|
|
std::map<std::string, CellStore> mInteriors;
|
|
|
|
std::map<std::pair<int, int>, CellStore> mExteriors;
|
|
|
|
std::vector<std::pair<std::string, CellStore *> > mIdCache;
|
2012-06-21 11:43:18 +02:00
|
|
|
std::size_t mIdCacheIndex;
|
2011-09-08 11:02:55 +02:00
|
|
|
|
|
|
|
Cells (const Cells&);
|
|
|
|
Cells& operator= (const Cells&);
|
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
CellStore *getCellStore (const ESM::Cell *cell);
|
2011-09-22 12:44:17 +02:00
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
Ptr getPtrAndCache (const std::string& name, CellStore& cellStore);
|
2012-06-21 11:43:18 +02:00
|
|
|
|
2014-01-23 11:29:40 +01:00
|
|
|
void writeCell (ESM::ESMWriter& writer, const CellStore& cell) const;
|
|
|
|
|
|
|
|
bool hasState (const CellStore& cellStore) const;
|
|
|
|
///< Check if cell has state that needs to be included in a saved game file.
|
|
|
|
|
2011-09-08 11:02:55 +02:00
|
|
|
public:
|
|
|
|
|
2013-05-15 17:54:18 +02:00
|
|
|
void clear();
|
|
|
|
|
2012-11-25 14:12:44 +01:00
|
|
|
Cells (const MWWorld::ESMStore& store, std::vector<ESM::ESMReader>& reader);
|
2011-09-08 11:02:55 +02:00
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
CellStore *getExterior (int x, int y);
|
2011-09-08 11:02:55 +02:00
|
|
|
|
2012-07-03 12:30:50 +02:00
|
|
|
CellStore *getInterior (const std::string& name);
|
2011-09-08 11:02:55 +02:00
|
|
|
|
2014-01-23 11:29:40 +01:00
|
|
|
CellStore *getCell (const ESM::CellId& id);
|
|
|
|
|
2013-08-15 14:45:13 +02:00
|
|
|
Ptr getPtr (const std::string& name, CellStore& cellStore, bool searchInContainers = false);
|
|
|
|
///< \param searchInContainers Only affect loaded cells.
|
2014-01-01 02:22:11 +01:00
|
|
|
/// @note name must be lower case
|
2011-09-22 12:44:17 +02:00
|
|
|
|
2014-01-01 02:22:11 +01:00
|
|
|
/// @note name must be lower case
|
2011-09-22 12:44:17 +02:00
|
|
|
Ptr getPtr (const std::string& name);
|
2014-01-01 02:22:11 +01:00
|
|
|
|
|
|
|
/// Get all Ptrs referencing \a name in exterior cells
|
|
|
|
/// @note Due to the current implementation of getPtr this only supports one Ptr per cell.
|
|
|
|
/// @note name must be lower case
|
|
|
|
void getExteriorPtrs (const std::string& name, std::vector<MWWorld::Ptr>& out);
|
2014-01-23 11:29:40 +01:00
|
|
|
|
2014-01-11 03:29:41 +01:00
|
|
|
/// Get all Ptrs referencing \a name in interior cells
|
|
|
|
/// @note Due to the current implementation of getPtr this only supports one Ptr per cell.
|
|
|
|
/// @note name must be lower case
|
|
|
|
void getInteriorPtrs (const std::string& name, std::vector<MWWorld::Ptr>& out);
|
|
|
|
|
2014-01-23 11:29:40 +01:00
|
|
|
int countSavedGameRecords() const;
|
|
|
|
|
|
|
|
void write (ESM::ESMWriter& writer) const;
|
|
|
|
|
2014-01-27 13:27:42 +01:00
|
|
|
bool readRecord (ESM::ESMReader& reader, int32_t type,
|
|
|
|
const std::map<int, int>& contentFileMap);
|
2011-09-08 11:02:55 +02:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|