mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-09 21:44:54 +00:00
Replace VisitorCellIdIsESM3Ext with RefId::getIf function
This commit is contained in:
parent
4fd8ed8f13
commit
20129568e6
@ -224,36 +224,14 @@ MWWorld::CellStore* MWWorld::WorldModel::getInterior(std::string_view name)
|
|||||||
return result->second;
|
return result->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct VisitorCellIdIsESM3Ext
|
|
||||||
{
|
|
||||||
bool operator()(const ESM::ESM3ExteriorCellRefId& id)
|
|
||||||
{
|
|
||||||
coordOut = { id.getX(), id.getY() };
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
bool operator()(const T&)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::pair<int32_t, int32_t> coordOut = {};
|
|
||||||
};
|
|
||||||
|
|
||||||
MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::RefId& id)
|
MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::RefId& id)
|
||||||
{
|
{
|
||||||
auto result = mCells.find(id);
|
auto result = mCells.find(id);
|
||||||
if (result != mCells.end())
|
if (result != mCells.end())
|
||||||
return &result->second;
|
return &result->second;
|
||||||
|
|
||||||
VisitorCellIdIsESM3Ext isESM3ExteriorVisitor;
|
if (const auto* exteriorId = id.getIf<ESM::ESM3ExteriorCellRefId>())
|
||||||
|
return getExterior(exteriorId->getX(), exteriorId->getY());
|
||||||
if (visit(isESM3ExteriorVisitor, id)) // That is an exterior cell Id
|
|
||||||
{
|
|
||||||
|
|
||||||
return getExterior(isESM3ExteriorVisitor.coordOut.first, isESM3ExteriorVisitor.coordOut.second);
|
|
||||||
}
|
|
||||||
|
|
||||||
const ESM4::Cell* cell4 = mStore.get<ESM4::Cell>().search(id);
|
const ESM4::Cell* cell4 = mStore.get<ESM4::Cell>().search(id);
|
||||||
CellStore* newCellStore = nullptr;
|
CellStore* newCellStore = nullptr;
|
||||||
|
@ -136,6 +136,12 @@ namespace ESM
|
|||||||
// Serialize into stable text format.
|
// Serialize into stable text format.
|
||||||
std::string serializeText() const;
|
std::string serializeText() const;
|
||||||
|
|
||||||
|
template <class T>
|
||||||
|
const T* getIf() const
|
||||||
|
{
|
||||||
|
return std::get_if<T>(&mValue);
|
||||||
|
}
|
||||||
|
|
||||||
friend constexpr bool operator==(const RefId& l, const RefId& r) { return l.mValue == r.mValue; }
|
friend constexpr bool operator==(const RefId& l, const RefId& r) { return l.mValue == r.mValue; }
|
||||||
|
|
||||||
bool operator==(std::string_view rhs) const;
|
bool operator==(std::string_view rhs) const;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user