1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-30 03:32:36 +00:00

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

95 lines
2.7 KiB
C++
Raw Normal View History

#ifndef GAME_MWWORLD_CELLS_H
#define GAME_MWWORLD_CELLS_H
#include <list>
#include <map>
#include <string>
#include "ptr.hpp"
namespace ESM
{
class ESMReader;
class ESMWriter;
class ReadersCache;
struct CellId;
2014-02-23 20:11:05 +01:00
struct Cell;
struct RefNum;
}
namespace Loading
{
class Listener;
}
2012-10-01 19:17:04 +04:00
namespace MWWorld
{
class ESMStore;
/// \brief Cell container
class Cells
{
typedef std::vector<std::pair<std::string, CellStore*>> IdCache;
2012-10-01 19:17:04 +04:00
const MWWorld::ESMStore& mStore;
ESM::ReadersCache& mReaders;
mutable std::map<std::string, CellStore> mInteriors;
mutable std::map<std::pair<int, int>, CellStore> mExteriors;
IdCache mIdCache;
std::size_t mIdCacheIndex;
Cells(const Cells&);
Cells& operator=(const Cells&);
2022-08-27 13:07:59 +02:00
CellStore* getCellStore(const ESM::Cell* cell);
Ptr getPtrAndCache(std::string_view name, CellStore& cellStore);
Ptr getPtr(CellStore& cellStore, const std::string& id, const ESM::RefNum& refNum);
void writeCell(ESM::ESMWriter& writer, CellStore& cell) const;
2022-09-22 21:26:05 +03:00
public:
2013-05-15 17:54:18 +02:00
void clear();
explicit Cells(const MWWorld::ESMStore& store, ESM::ReadersCache& reader);
CellStore* getExterior(int x, int y);
CellStore* getInterior(std::string_view name);
CellStore* getCell(const ESM::CellId& id);
2022-08-27 13:07:59 +02:00
Ptr getPtr(std::string_view name, CellStore& cellStore, bool searchInContainers = false);
///< \param searchInContainers Only affect loaded cells.
/// @note name must be lower case
/// @note name must be lower case
Ptr getPtr(const std::string& name);
Ptr getPtr(const std::string& id, const ESM::RefNum& refNum);
void rest(double hours);
void recharge(float duration);
/// 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
2022-08-27 13:07:59 +02:00
void getExteriorPtrs(std::string_view name, std::vector<MWWorld::Ptr>& out);
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);
std::vector<MWWorld::Ptr> getAll(const std::string& id);
int countSavedGameRecords() const;
void write(ESM::ESMWriter& writer, Loading::Listener& progress) const;
2015-01-22 19:04:59 +01:00
bool readRecord(ESM::ESMReader& reader, uint32_t type, const std::map<int, int>& contentFileMap);
};
}
#endif