mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-01 01:15:33 +00:00
Nothing can be loaded yet. Just foundations.
This commit is contained in:
parent
0f9bb71534
commit
cddf6f29d6
5 changed files with 66 additions and 1 deletions
|
@ -51,10 +51,17 @@ namespace ESM
|
|||
struct BodyPart;
|
||||
}
|
||||
|
||||
namespace ESM4
|
||||
{
|
||||
class Reader;
|
||||
struct Cell;
|
||||
}
|
||||
|
||||
namespace MWWorld
|
||||
{
|
||||
class ESMStore;
|
||||
struct CellStoreImp;
|
||||
typedef std::variant<const ESM4::Cell*, const ESM::Cell*> CellVariant;
|
||||
|
||||
using CellStoreTuple = std::tuple<CellRefList<ESM::Activator>, CellRefList<ESM::Potion>,
|
||||
CellRefList<ESM::Apparatus>, CellRefList<ESM::Armor>, CellRefList<ESM::Book>, CellRefList<ESM::Clothing>,
|
||||
|
@ -86,6 +93,7 @@ namespace MWWorld
|
|||
std::unique_ptr<ESM::FogState> mFogState;
|
||||
|
||||
const ESM::Cell* mCell;
|
||||
CellVariant mCellVariant;
|
||||
State mState;
|
||||
bool mHasState;
|
||||
std::vector<ESM::RefId> mIds;
|
||||
|
|
|
@ -1183,6 +1183,31 @@ namespace MWWorld
|
|||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
// ESM4 Cell
|
||||
//=========================================================================
|
||||
|
||||
const ESM4::Cell* Store<ESM4::Cell>::searchCellName(std::string_view cellName) const
|
||||
{
|
||||
const auto foundCell = mCellNameIndex.find(cellName);
|
||||
if (foundCell == mCellNameIndex.end())
|
||||
return nullptr;
|
||||
return foundCell->second;
|
||||
}
|
||||
|
||||
ESM4::Cell* Store<ESM4::Cell>::insert(const ESM4::Cell& item, bool overrideOnly)
|
||||
{
|
||||
auto cellPtr = TypedDynamicStore<ESM4::Cell>::insert(item, overrideOnly);
|
||||
mCellNameIndex[cellPtr->mEditorId] = cellPtr;
|
||||
return cellPtr;
|
||||
}
|
||||
|
||||
ESM4::Cell* Store<ESM4::Cell>::insertStatic(const ESM4::Cell& item)
|
||||
{
|
||||
auto cellPtr = TypedDynamicStore<ESM4::Cell>::insertStatic(item);
|
||||
mCellNameIndex[cellPtr->mEditorId] = cellPtr;
|
||||
return cellPtr;
|
||||
}
|
||||
}
|
||||
|
||||
template class MWWorld::TypedDynamicStore<ESM::Activator>;
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include <components/esm3/loadgmst.hpp>
|
||||
#include <components/esm3/loadland.hpp>
|
||||
#include <components/esm3/loadpgrd.hpp>
|
||||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
|
||||
|
@ -268,6 +269,19 @@ namespace MWWorld
|
|||
const ESM::GameSetting* find(const std::string_view id) const;
|
||||
const ESM::GameSetting* search(const std::string_view id) const;
|
||||
};
|
||||
|
||||
template <>
|
||||
class Store<ESM4::Cell> : public TypedDynamicStore<ESM4::Cell>
|
||||
{
|
||||
std::unordered_map<std::string, ESM4::Cell*, Misc::StringUtils::CiHash, Misc::StringUtils::CiEqual>
|
||||
mCellNameIndex;
|
||||
|
||||
public:
|
||||
const ESM4::Cell* searchCellName(std::string_view) const;
|
||||
ESM4::Cell* insert(const ESM4::Cell& item, bool overrideOnly = false);
|
||||
ESM4::Cell* insertStatic(const ESM4::Cell& item);
|
||||
};
|
||||
|
||||
template <>
|
||||
class Store<ESM::Land> : public DynamicStore
|
||||
{
|
||||
|
|
|
@ -253,6 +253,17 @@ const ESM::Cell* MWWorld::WorldModel::getESMCellByName(std::string_view name)
|
|||
return cell;
|
||||
}
|
||||
|
||||
MWWorld::CellVariant MWWorld::WorldModel::getCellByName(std::string_view name)
|
||||
{
|
||||
const ESM::Cell* cellEsm3 = getESMCellByName(name);
|
||||
return cellEsm3;
|
||||
if (!cellEsm3)
|
||||
{
|
||||
const ESM4::Cell* cellESM4 = mStore.get<ESM4::Cell>().searchCellName(name);
|
||||
return cellESM4;
|
||||
}
|
||||
}
|
||||
|
||||
MWWorld::CellStore* MWWorld::WorldModel::getCell(std::string_view name)
|
||||
{
|
||||
const ESM::Cell* cell = getESMCellByName(name);
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <map>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <variant>
|
||||
|
||||
#include <components/misc/algorithm.hpp>
|
||||
|
||||
|
@ -21,6 +22,11 @@ namespace ESM
|
|||
struct RefNum;
|
||||
}
|
||||
|
||||
namespace ESM4
|
||||
{
|
||||
struct Cell;
|
||||
}
|
||||
|
||||
namespace Loading
|
||||
{
|
||||
class Listener;
|
||||
|
@ -45,8 +51,9 @@ namespace MWWorld
|
|||
WorldModel& operator=(const WorldModel&);
|
||||
|
||||
const ESM::Cell* getESMCellByName(std::string_view name);
|
||||
CellStore* getCellStore(const ESM::Cell* cell);
|
||||
CellVariant getCellByName(std::string_view name);
|
||||
|
||||
CellStore* getCellStore(const ESM::Cell* cell);
|
||||
Ptr getPtrAndCache(const ESM::RefId& name, CellStore& cellStore);
|
||||
|
||||
Ptr getPtr(CellStore& cellStore, const ESM::RefId& id, const ESM::RefNum& refNum);
|
||||
|
|
Loading…
Reference in a new issue