1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-21 13:20:54 +00:00

Exterior cell naming corrections

Use the ID for anonymous regions
Try to use the name of the worldspace for ESM4
This commit is contained in:
Alexei Kotov 2024-03-23 09:15:12 +03:00
parent 82bc6674dc
commit 24913687cd
3 changed files with 22 additions and 20 deletions

View File

@ -183,8 +183,6 @@ namespace MWBase
/// generate a name.
virtual std::string_view getCellName(const MWWorld::Cell& cell) const = 0;
virtual std::string_view getCellName(const ESM::Cell* cell) const = 0;
virtual void removeRefScript(const MWWorld::CellRef* ref) = 0;
//< Remove the script attached to ref from mLocalScripts

View File

@ -27,6 +27,7 @@
#include <components/esm4/loadcell.hpp>
#include <components/esm4/loaddoor.hpp>
#include <components/esm4/loadstat.hpp>
#include <components/esm4/loadwrld.hpp>
#include <components/misc/constants.hpp>
#include <components/misc/convert.hpp>
@ -662,25 +663,29 @@ namespace MWWorld
if (!cell.isExterior() || !cell.getDisplayName().empty())
return cell.getDisplayName();
return ESM::visit(ESM::VisitOverload{
[&](const ESM::Cell& cellIn) -> std::string_view { return getCellName(&cellIn); },
[&](const ESM4::Cell& cellIn) -> std::string_view {
return mStore.get<ESM::GameSetting>().find("sDefaultCellname")->mValue.getString();
},
},
cell);
}
std::string_view World::getCellName(const ESM::Cell* cell) const
{
if (cell)
if (!cell.getRegion().empty())
{
if (!cell->isExterior() || !cell->mName.empty())
return cell->mName;
if (const ESM::Region* region = mStore.get<ESM::Region>().search(cell->mRegion))
return region->mName;
std::string_view regionName
= ESM::visit(ESM::VisitOverload{
[&](const ESM::Cell& cellIn) -> std::string_view {
if (const ESM::Region* region = mStore.get<ESM::Region>().search(cell.getRegion()))
return !region->mName.empty() ? region->mName : region->mId.getRefIdString();
return {};
},
[&](const ESM4::Cell& cellIn) -> std::string_view { return {}; },
},
cell);
if (!regionName.empty())
return regionName;
}
if (!cell.getWorldSpace().empty() && ESM::isEsm4Ext(cell.getWorldSpace()))
{
if (const ESM4::World* worldspace = mStore.get<ESM4::World>().search(cell.getWorldSpace()))
if (!worldspace->mFullName.empty())
return worldspace->mFullName;
}
return mStore.get<ESM::GameSetting>().find("sDefaultCellname")->mValue.getString();
}

View File

@ -273,7 +273,6 @@ namespace MWWorld
/// \note If cell==0, the cell the player is currently in will be used instead to
/// generate a name.
std::string_view getCellName(const MWWorld::Cell& cell) const override;
std::string_view getCellName(const ESM::Cell* cell) const override;
void removeRefScript(const MWWorld::CellRef* ref) override;
//< Remove the script attached to ref from mLocalScripts