diff --git a/apps/esmtool/record.cpp b/apps/esmtool/record.cpp index 73c75d6d87..9cc8fb1ea4 100644 --- a/apps/esmtool/record.cpp +++ b/apps/esmtool/record.cpp @@ -1342,7 +1342,7 @@ namespace EsmTool template <> std::string Record::getId() const { - return mData.mName.getRefIdString(); + return mData.mName; } template <> diff --git a/apps/essimporter/converter.cpp b/apps/essimporter/converter.cpp index 5b118edeab..0da74d3251 100644 --- a/apps/essimporter/converter.cpp +++ b/apps/essimporter/converter.cpp @@ -202,7 +202,7 @@ namespace ESSImport } // note if the player is in a nameless exterior cell, we will assign the cellId later based on player position - if (cell.mName == ESM::RefId::stringRefId(mContext->mPlayerCellName)) + if (Misc::StringUtils::ciEqual(cell.mName, mContext->mPlayerCellName)) { mContext->mPlayer.mCellId = cell.getCellId(); } diff --git a/apps/essimporter/converter.hpp b/apps/essimporter/converter.hpp index f9f9c19ce6..c8b4b7d779 100644 --- a/apps/essimporter/converter.hpp +++ b/apps/essimporter/converter.hpp @@ -351,7 +351,7 @@ namespace ESSImport std::vector mFogOfWar; }; - std::map mIntCells; + std::map mIntCells; std::map, Cell> mExtCells; std::vector mMarkers; diff --git a/apps/essimporter/convertplayer.cpp b/apps/essimporter/convertplayer.cpp index b7da036e01..5bb9897487 100644 --- a/apps/essimporter/convertplayer.cpp +++ b/apps/essimporter/convertplayer.cpp @@ -70,7 +70,7 @@ namespace ESSImport // TODO: Figure out a better way to detect interiors. (0, 0) is a valid exterior cell. if (mark.mCellX == 0 && mark.mCellY == 0) { - cell.mWorldspace = ESM::RefId::stringRefId(pcdt.mMNAM); + cell.mWorldspace = pcdt.mMNAM; cell.mPaged = false; } diff --git a/apps/launcher/utils/cellnameloader.cpp b/apps/launcher/utils/cellnameloader.cpp index 1c0521bdc8..57c009046d 100644 --- a/apps/launcher/utils/cellnameloader.cpp +++ b/apps/launcher/utils/cellnameloader.cpp @@ -49,5 +49,5 @@ QString CellNameLoader::getCellName(ESM::ESMReader& esmReader) bool isDeleted = false; cell.loadNameAndData(esmReader, isDeleted); - return QString::fromStdString(cell.mName.getRefIdString()); + return QString::fromStdString(cell.mName); } diff --git a/apps/navmeshtool/worldspacedata.cpp b/apps/navmeshtool/worldspacedata.cpp index 6f27bef93d..768fed6d61 100644 --- a/apps/navmeshtool/worldspacedata.cpp +++ b/apps/navmeshtool/worldspacedata.cpp @@ -265,14 +265,16 @@ namespace NavMeshTool const osg::Vec2i cellPosition(cell.mData.mX, cell.mData.mY); const std::size_t cellObjectsBegin = data.mObjects.size(); WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& { - auto it = navMeshInputs.find(cell.mCellId.mWorldspace); + auto it = navMeshInputs.find(ESM::RefId::stringRefId(cell.mCellId.mWorldspace)); if (it == navMeshInputs.end()) { it = navMeshInputs - .emplace(cell.mCellId.mWorldspace, - std::make_unique(cell.mCellId.mWorldspace, settings.mRecast)) + .emplace(ESM::RefId::stringRefId(cell.mCellId.mWorldspace), + std::make_unique( + ESM::RefId::stringRefId(cell.mCellId.mWorldspace), settings.mRecast)) .first; - it->second->mTileCachedRecastMeshManager.setWorldspace(cell.mCellId.mWorldspace, nullptr); + it->second->mTileCachedRecastMeshManager.setWorldspace( + ESM::RefId::stringRefId(cell.mCellId.mWorldspace), nullptr); } return *it->second; }(); diff --git a/apps/opencs/model/tools/referencecheck.cpp b/apps/opencs/model/tools/referencecheck.cpp index 562dbc9ba7..cf6d0b3a4d 100644 --- a/apps/opencs/model/tools/referencecheck.cpp +++ b/apps/opencs/model/tools/referencecheck.cpp @@ -88,8 +88,8 @@ void CSMTools::ReferenceCheckStage::perform(int stage, CSMDoc::Messages& message } if (!cellRef.mDestCell.empty() && mCells.searchId(cellRef.mDestCell) == -1) - messages.add(id, "Destination cell '" + cellRef.mDestCell.getRefIdString() + "' does not exist", "", - CSMDoc::Message::Severity_Error); + messages.add( + id, "Destination cell '" + cellRef.mDestCell + "' does not exist", "", CSMDoc::Message::Severity_Error); if (cellRef.mScale < 0) messages.add(id, "Negative scale", "", CSMDoc::Message::Severity_Error); diff --git a/apps/opencs/model/tools/topicinfocheck.cpp b/apps/opencs/model/tools/topicinfocheck.cpp index 7524f79017..39d1262f26 100644 --- a/apps/opencs/model/tools/topicinfocheck.cpp +++ b/apps/opencs/model/tools/topicinfocheck.cpp @@ -75,7 +75,7 @@ int CSMTools::TopicInfoCheckStage::setup() if (regionRecord.isDeleted()) continue; - mCellNames.insert(ESM::RefId::stringRefId(regionRecord.get().mName)); + mCellNames.insert(regionRecord.get().mName); } // Default cell name int index = mGameSettings.searchId("sDefaultCellname"); @@ -85,7 +85,7 @@ int CSMTools::TopicInfoCheckStage::setup() if (!gmstRecord.isDeleted() && gmstRecord.get().mValue.getType() == ESM::VT_String) { - mCellNames.insert(ESM::RefId::stringRefId(gmstRecord.get().mValue.getString())); + mCellNames.insert(gmstRecord.get().mValue.getString()); } } @@ -130,7 +130,7 @@ void CSMTools::TopicInfoCheckStage::perform(int stage, CSMDoc::Messages& message if (!topicInfo.mCell.empty()) { - verifyCell(topicInfo.mCell, id, messages); + verifyCell(topicInfo.mCell.getRefIdString(), id, messages); } if (!topicInfo.mFaction.empty() && !topicInfo.mFactionLess) @@ -211,11 +211,11 @@ bool CSMTools::TopicInfoCheckStage::verifyActor( } bool CSMTools::TopicInfoCheckStage::verifyCell( - const ESM::RefId& cell, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages) + const std::string& cell, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages) { if (mCellNames.find(cell) == mCellNames.end()) { - messages.add(id, "Cell '" + cell.getRefIdString() + "' does not exist", "", CSMDoc::Message::Severity_Error); + messages.add(id, "Cell '" + cell + "' does not exist", "", CSMDoc::Message::Severity_Error); return false; } @@ -406,7 +406,7 @@ bool CSMTools::TopicInfoCheckStage::verifySelectStruct( return false; } else if (infoCondition.getFunctionName() == CSMWorld::ConstInfoSelectWrapper::Function_NotCell - && !verifyCell(ESM::RefId::stringRefId(infoCondition.getVariableName()), id, messages)) + && !verifyCell(infoCondition.getVariableName(), id, messages)) { return false; } diff --git a/apps/opencs/model/tools/topicinfocheck.hpp b/apps/opencs/model/tools/topicinfocheck.hpp index 8fbf84a59e..1bb2fc61dc 100644 --- a/apps/opencs/model/tools/topicinfocheck.hpp +++ b/apps/opencs/model/tools/topicinfocheck.hpp @@ -7,6 +7,7 @@ #include #include +#include #include "../world/idcollection.hpp" @@ -72,13 +73,13 @@ namespace CSMTools const CSMWorld::RefIdData& mReferencables; const CSMWorld::Resources& mSoundFiles; - std::set mCellNames; + std::set mCellNames; bool mIgnoreBaseRecords; // These return false when not successful and write an error bool verifyActor(const ESM::RefId& name, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages); - bool verifyCell(const ESM::RefId& name, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages); + bool verifyCell(const std::string& cell, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages); bool verifyFactionRank( const ESM::RefId& name, int rank, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages); bool verifyItem(const ESM::RefId& name, const CSMWorld::UniversalId& id, CSMDoc::Messages& messages); diff --git a/apps/opencs/model/world/cell.cpp b/apps/opencs/model/world/cell.cpp index 80995776da..f4b0084ef4 100644 --- a/apps/opencs/model/world/cell.cpp +++ b/apps/opencs/model/world/cell.cpp @@ -6,7 +6,7 @@ void CSMWorld::Cell::load(ESM::ESMReader& esm, bool& isDeleted) { ESM::Cell::load(esm, isDeleted, false); - mId = mName; + mId = ESM::RefId::stringRefId(mName); if (isExterior()) { std::ostringstream stream; diff --git a/apps/opencs/model/world/columnimp.hpp b/apps/opencs/model/world/columnimp.hpp index f85715a098..baaf249231 100644 --- a/apps/opencs/model/world/columnimp.hpp +++ b/apps/opencs/model/world/columnimp.hpp @@ -344,14 +344,14 @@ namespace CSMWorld QVariant get(const Record& record) const override { - return QString::fromUtf8(record.get().mName.getRefIdString().c_str()); + return QString::fromUtf8(record.get().mName.c_str()); } void set(Record& record, const QVariant& data) override { CSMWorld::Cell record2 = record.get(); - record2.mName = ESM::RefId::stringRefId(data.toString().toUtf8().constData()); + record2.mName = data.toString().toUtf8().constData(); record.setModified(record2); } @@ -1147,14 +1147,14 @@ namespace CSMWorld QVariant get(const Record& record) const override { - return QString::fromUtf8(record.get().mDestCell.getRefIdString().c_str()); + return QString::fromUtf8(record.get().mDestCell.c_str()); } void set(Record& record, const QVariant& data) override { ESXRecordT record2 = record.get(); - record2.mDestCell = ESM::RefId::stringRefId(data.toString().toUtf8().constData()); + record2.mDestCell = data.toString().toUtf8().constData(); record.setModified(record2); } diff --git a/apps/opencs/model/world/idtable.cpp b/apps/opencs/model/world/idtable.cpp index d3be51d552..c0da8e7fac 100644 --- a/apps/opencs/model/world/idtable.cpp +++ b/apps/opencs/model/world/idtable.cpp @@ -333,7 +333,7 @@ std::pair CSMWorld::IdTable::view(int row) c return std::make_pair(UniversalId::Type_None, ""); if (id[0] == '#') - id = ESM::CellId::sDefaultWorldspace.getRefIdString(); + id = ESM::CellId::sDefaultWorldspace; return std::make_pair(UniversalId(UniversalId::Type_Scene, id), hint); } diff --git a/apps/opencs/model/world/refidadapterimp.hpp b/apps/opencs/model/world/refidadapterimp.hpp index 8854dfbf05..014952f7f6 100644 --- a/apps/opencs/model/world/refidadapterimp.hpp +++ b/apps/opencs/model/world/refidadapterimp.hpp @@ -1468,7 +1468,7 @@ namespace CSMWorld ESM::Transport::Dest newRow; newRow.mPos = newPos; - newRow.mCellName = ESM::RefId::sEmpty; + newRow.mCellName.clear(); if (position >= (int)list.size()) list.push_back(newRow); @@ -1533,7 +1533,7 @@ namespace CSMWorld switch (subColIndex) { case 0: - return QString::fromUtf8(content.mCellName.getRefIdString().c_str()); + return QString::fromUtf8(content.mCellName.c_str()); case 1: return content.mPos.pos[0]; case 2: @@ -1565,7 +1565,7 @@ namespace CSMWorld switch (subColIndex) { case 0: - list.at(subRowIndex).mCellName = ESM::RefId::stringRefId(value.toString().toUtf8().constData()); + list.at(subRowIndex).mCellName = value.toString().toUtf8().constData(); break; case 1: list.at(subRowIndex).mPos.pos[0] = value.toFloat(); diff --git a/apps/opencs/model/world/regionmap.hpp b/apps/opencs/model/world/regionmap.hpp index 32c205281c..3f62c7b61d 100644 --- a/apps/opencs/model/world/regionmap.hpp +++ b/apps/opencs/model/world/regionmap.hpp @@ -42,7 +42,7 @@ namespace CSMWorld { bool mDeleted; ESM::RefId mRegion; - ESM::RefId mName; + std::string mName; CellDescription(); diff --git a/apps/opencs/view/world/scenesubview.cpp b/apps/opencs/view/world/scenesubview.cpp index a35c9caf84..ed2820c542 100644 --- a/apps/opencs/view/world/scenesubview.cpp +++ b/apps/opencs/view/world/scenesubview.cpp @@ -49,7 +49,7 @@ CSVWorld::SceneSubView::SceneSubView(const CSMWorld::UniversalId& id, CSMDoc::Do CSVRender::WorldspaceWidget* worldspaceWidget = nullptr; widgetType whatWidget; - if (ESM::RefId::stringRefId(id.getId()) == ESM::CellId::sDefaultWorldspace) + if (Misc::StringUtils::ciEqual(id.getId(), ESM::CellId::sDefaultWorldspace)) { whatWidget = widget_Paged; diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 545137f6ec..f160e7025f 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -444,7 +444,7 @@ void OMW::Engine::setResourceDir(const std::filesystem::path& parResDir) // Set start cell name void OMW::Engine::setCell(const std::string& cellName) { - mCellName = ESM::RefId::stringRefId(cellName); + mCellName = cellName; } void OMW::Engine::addContentFile(const std::string& file) diff --git a/apps/openmw/engine.hpp b/apps/openmw/engine.hpp index fe2aff174d..cf7169bf6d 100644 --- a/apps/openmw/engine.hpp +++ b/apps/openmw/engine.hpp @@ -152,7 +152,7 @@ namespace OMW osg::ref_ptr mScreenCaptureOperation; osg::ref_ptr mSelectDepthFormatOperation; osg::ref_ptr mSelectColorFormatOperation; - ESM::RefId mCellName; + std::string mCellName; std::vector mContentFiles; std::vector mGroundcoverFiles; diff --git a/apps/openmw/mwbase/world.hpp b/apps/openmw/mwbase/world.hpp index 46642a8d95..dc25b4f652 100644 --- a/apps/openmw/mwbase/world.hpp +++ b/apps/openmw/mwbase/world.hpp @@ -245,7 +245,7 @@ namespace MWBase virtual void setSimulationTimeScale(float scale) = 0; virtual void changeToInteriorCell( - const ESM::RefId& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent = true) + std::string_view cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent = true) = 0; ///< Move to interior cell. ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes @@ -513,11 +513,11 @@ namespace MWBase /// Find default position inside exterior cell specified by name /// \return false if exterior with given name not exists, true otherwise - virtual bool findExteriorPosition(const ESM::RefId& name, ESM::Position& pos) = 0; + virtual bool findExteriorPosition(std::string_view name, ESM::Position& pos) = 0; /// Find default position inside interior cell specified by name /// \return false if interior with given name not exists, true otherwise - virtual bool findInteriorPosition(const ESM::RefId& name, ESM::Position& pos) = 0; + virtual bool findInteriorPosition(std::string_view name, ESM::Position& pos) = 0; /// Enables or disables use of teleport spell effects (recall, intervention, etc). virtual void enableTeleporting(bool enable) = 0; diff --git a/apps/openmw/mwclass/door.cpp b/apps/openmw/mwclass/door.cpp index cf2f19d681..075b2cffa8 100644 --- a/apps/openmw/mwclass/door.cpp +++ b/apps/openmw/mwclass/door.cpp @@ -299,7 +299,7 @@ namespace MWClass std::string Door::getDestination(const MWWorld::LiveCellRef& door) { - std::string_view dest = door.mRef.getDestCell().getRefIdString(); + std::string_view dest = door.mRef.getDestCell(); if (dest.empty()) { // door leads to exterior, use cell name (if any), otherwise translated region name diff --git a/apps/openmw/mwgui/console.cpp b/apps/openmw/mwgui/console.cpp index 7bb0065ffa..ded51f139e 100644 --- a/apps/openmw/mwgui/console.cpp +++ b/apps/openmw/mwgui/console.cpp @@ -122,7 +122,7 @@ namespace MWGui it != store.get().extEnd(); ++it) { if (!it->mName.empty()) - mNames.push_back(it->mName.getRefIdString()); + mNames.push_back(it->mName); } // sort diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index df30363bbb..c79059d022 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -353,7 +353,7 @@ namespace MWGui { ESM::CellId cellId; cellId.mPaged = !mInterior; - cellId.mWorldspace = (mInterior ? ESM::RefId::stringRefId(mPrefix) : ESM::CellId::sDefaultWorldspace); + cellId.mWorldspace = (mInterior ? mPrefix : ESM::CellId::sDefaultWorldspace); cellId.mIndex.mX = mCurX + dX; cellId.mIndex.mY = mCurY + dY; @@ -637,7 +637,7 @@ namespace MWGui for (MyGUI::Widget* widget : mExteriorDoorMarkerWidgets) widget->setVisible(false); - MWWorld::CellStore* cell = worldModel->getInterior(ESM::RefId::stringRefId(mPrefix)); + MWWorld::CellStore* cell = worldModel->getInterior(mPrefix); world->getDoorMarkers(cell, doors); } else @@ -705,7 +705,7 @@ namespace MWGui ESM::Position markedPosition; MWBase::Environment::get().getWorld()->getPlayer().getMarkedPosition(markedCell, markedPosition); if (markedCell && markedCell->isExterior() == !mInterior - && (!mInterior || Misc::StringUtils::ciEqual(markedCell->getCell()->mName.getRefIdString(), mPrefix))) + && (!mInterior || Misc::StringUtils::ciEqual(markedCell->getCell()->mName, mPrefix))) { MarkerUserData markerPos(mLocalMapRender); MyGUI::ImageBox* markerWidget = mLocalMap->createWidget("ImageBox", @@ -888,7 +888,7 @@ namespace MWGui mEditingMarker.mCell.mPaged = !mInterior; if (mInterior) - mEditingMarker.mCell.mWorldspace = ESM::RefId::stringRefId(LocalMapBase::mPrefix); + mEditingMarker.mCell.mWorldspace = LocalMapBase::mPrefix; else { mEditingMarker.mCell.mWorldspace = ESM::CellId::sDefaultWorldspace; @@ -1333,7 +1333,7 @@ namespace MWGui const ESM::Cell* cell = MWBase::Environment::get().getWorld()->getStore().get().search( cellId.first, cellId.second); if (cell && !cell->mName.empty()) - addVisitedLocation(cell->mName.getRefIdString(), cellId.first, cellId.second); + addVisitedLocation(cell->mName, cellId.first, cellId.second); } } } diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index 3cfe3210ef..1c3af5d8cf 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -123,7 +123,7 @@ namespace MWGui for (unsigned int i = 0; i < transport.size(); i++) { - std::string_view cellname = transport[i].mCellName.getRefIdString(); + std::string_view cellname = transport[i].mCellName; bool interior = true; const osg::Vec2i cellIndex = MWWorld::positionToCellIndex(transport[i].mPos.pos[0], transport[i].mPos.pos[1]); @@ -174,7 +174,7 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->fadeScreenOut(1); ESM::Position pos = *_sender->getUserData(); - const ESM::RefId& cellname = ESM::RefId::stringRefId(_sender->getUserString("Destination")); + const std::string& cellname = _sender->getUserString("Destination"); bool interior = _sender->getUserString("interior") == "y"; if (mPtr.getCell()->isExterior()) { @@ -198,7 +198,7 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->fadeScreenOut(1); // Teleports any followers, too. - MWWorld::ActionTeleport action(interior ? cellname : ESM::RefId::sEmpty, pos, true); + MWWorld::ActionTeleport action(interior ? cellname : "", pos, true); action.execute(player); MWBase::Environment::get().getWindowManager()->fadeScreenOut(0); diff --git a/apps/openmw/mwgui/windowmanagerimp.cpp b/apps/openmw/mwgui/windowmanagerimp.cpp index e717fa1b3e..6b4e7a58c3 100644 --- a/apps/openmw/mwgui/windowmanagerimp.cpp +++ b/apps/openmw/mwgui/windowmanagerimp.cpp @@ -966,8 +966,8 @@ namespace MWGui } else { - mMap->setCellPrefix(cell->getCell()->mName.getRefIdString()); - mHud->setCellPrefix(cell->getCell()->mName.getRefIdString()); + mMap->setCellPrefix(cell->getCell()->mName); + mHud->setCellPrefix(cell->getCell()->mName); osg::Vec3f worldPos; if (!MWBase::Environment::get().getWorld()->findInteriorPositionInWorldSpace(cell, worldPos)) diff --git a/apps/openmw/mwlua/cellbindings.cpp b/apps/openmw/mwlua/cellbindings.cpp index dff4af1afd..bb98a45b46 100644 --- a/apps/openmw/mwlua/cellbindings.cpp +++ b/apps/openmw/mwlua/cellbindings.cpp @@ -38,8 +38,7 @@ namespace MWLua return res.str(); }; - cellT["name"] - = sol::readonly_property([](const CellT& c) { return c.mStore->getCell()->mName.getRefIdString(); }); + cellT["name"] = sol::readonly_property([](const CellT& c) { return c.mStore->getCell()->mName; }); cellT["region"] = sol::readonly_property([](const CellT& c) { return c.mStore->getCell()->mRegion.getRefIdString(); }); cellT["gridX"] = sol::readonly_property([](const CellT& c) { return c.mStore->getCell()->getGridX(); }); diff --git a/apps/openmw/mwlua/luabindings.cpp b/apps/openmw/mwlua/luabindings.cpp index bf4cec09b0..9d59fe9705 100644 --- a/apps/openmw/mwlua/luabindings.cpp +++ b/apps/openmw/mwlua/luabindings.cpp @@ -78,9 +78,8 @@ namespace MWLua sol::table api(context.mLua->sol(), sol::create); WorldView* worldView = context.mWorldView; addTimeBindings(api, context, true); - api["getCellByName"] = [](std::string_view name) { - return GCell{ MWBase::Environment::get().getWorldModel()->getCell(ESM::RefId::stringRefId(name)) }; - }; + api["getCellByName"] + = [](std::string_view name) { return GCell{ MWBase::Environment::get().getWorldModel()->getCell(name) }; }; api["getExteriorCell"] = [](int x, int y) { return GCell{ MWBase::Environment::get().getWorldModel()->getExterior(x, y) }; }; api["activeActors"] = GObjectList{ worldView->getActorsInScene() }; diff --git a/apps/openmw/mwlua/objectbindings.cpp b/apps/openmw/mwlua/objectbindings.cpp index 977aa9569c..8be7c6ff3f 100644 --- a/apps/openmw/mwlua/objectbindings.cpp +++ b/apps/openmw/mwlua/objectbindings.cpp @@ -51,11 +51,11 @@ namespace MWLua class TeleportAction final : public LuaManager::Action { public: - TeleportAction(LuaUtil::LuaState* state, ObjectId object, ESM::RefId cell, const osg::Vec3f& pos, + TeleportAction(LuaUtil::LuaState* state, ObjectId object, std::string_view cell, const osg::Vec3f& pos, const osg::Vec3f& rot) : Action(state) , mObject(object) - , mCell(std::move(cell)) + , mCell(std::string(cell)) , mPos(pos) , mRot(rot) { @@ -94,7 +94,7 @@ namespace MWLua private: ObjectId mObject; - ESM::RefId mCell; + std::string mCell; osg::Vec3f mPos; osg::Vec3f mRot; }; @@ -247,8 +247,7 @@ namespace MWLua const sol::optional& optRot) { MWWorld::Ptr ptr = object.ptr(); osg::Vec3f rot = optRot ? *optRot : ptr.getRefData().getPosition().asRotationVec3(); - auto action = std::make_unique( - context.mLua, object.id(), ESM::RefId::stringRefId(cell), pos, rot); + auto action = std::make_unique(context.mLua, object.id(), cell, pos, rot); if (ptr == MWBase::Environment::get().getWorld()->getPlayerPtr()) context.mLuaManager->addTeleportPlayerAction(std::move(action)); else diff --git a/apps/openmw/mwmechanics/aiescort.cpp b/apps/openmw/mwmechanics/aiescort.cpp index 5338c55cee..7bf593b6da 100644 --- a/apps/openmw/mwmechanics/aiescort.cpp +++ b/apps/openmw/mwmechanics/aiescort.cpp @@ -34,7 +34,7 @@ namespace MWMechanics } AiEscort::AiEscort( - const ESM::RefId& actorId, const ESM::RefId& cellId, int duration, float x, float y, float z, bool repeat) + const ESM::RefId& actorId, std::string_view cellId, int duration, float x, float y, float z, bool repeat) : TypedAiPackage(repeat) , mCellId(cellId) , mX(x) diff --git a/apps/openmw/mwmechanics/aiescort.hpp b/apps/openmw/mwmechanics/aiescort.hpp index ee5cfddbde..e22752446d 100644 --- a/apps/openmw/mwmechanics/aiescort.hpp +++ b/apps/openmw/mwmechanics/aiescort.hpp @@ -28,7 +28,7 @@ namespace MWMechanics /** The Actor will escort the specified actor to the cell position x, y, z until they reach their position, or they run out of time \implement AiEscortCell **/ AiEscort( - const ESM::RefId& actorId, const ESM::RefId& cellId, int duration, float x, float y, float z, bool repeat); + const ESM::RefId& actorId, std::string_view cellId, int duration, float x, float y, float z, bool repeat); AiEscort(const ESM::AiSequence::AiEscort* escort); @@ -52,7 +52,7 @@ namespace MWMechanics osg::Vec3f getDestination() const override { return osg::Vec3f(mX, mY, mZ); } private: - const ESM::RefId mCellId; + const std::string mCellId; const float mX; const float mY; const float mZ; diff --git a/apps/openmw/mwmechanics/aifollow.cpp b/apps/openmw/mwmechanics/aifollow.cpp index 99e72e78d2..091b5ef0c6 100644 --- a/apps/openmw/mwmechanics/aifollow.cpp +++ b/apps/openmw/mwmechanics/aifollow.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "../mwbase/environment.hpp" #include "../mwbase/mechanicsmanager.hpp" @@ -35,7 +36,7 @@ namespace MWMechanics , mX(x) , mY(y) , mZ(z) - , mCellId(ESM::RefId::sEmpty) + , mCellId("") , mActive(false) , mFollowIndex(mFollowIndexCounter++) { @@ -43,7 +44,7 @@ namespace MWMechanics } AiFollow::AiFollow( - const ESM::RefId& actorId, const ESM::RefId& cellId, float duration, float x, float y, float z, bool repeat) + const ESM::RefId& actorId, std::string_view cellId, float duration, float x, float y, float z, bool repeat) : TypedAiPackage(repeat) , mAlwaysFollow(false) , mDuration(duration) @@ -66,7 +67,7 @@ namespace MWMechanics , mX(0) , mY(0) , mZ(0) - , mCellId(ESM::RefId::sEmpty) + , mCellId("") , mActive(false) , mFollowIndex(mFollowIndexCounter++) { @@ -169,13 +170,13 @@ namespace MWMechanics { if (actor.getCell()->isExterior()) // Outside? { - if (mCellId == ESM::RefId::sEmpty) // No cell to travel to + if (mCellId == "") // No cell to travel to { mRemainingDuration = mDuration; return true; } } - else if (mCellId == actor.getCell()->getCell()->mName) // Cell to travel to + else if (Misc::StringUtils::ciEqual(mCellId, actor.getCell()->getCell()->mName)) // Cell to travel to { mRemainingDuration = mDuration; return true; diff --git a/apps/openmw/mwmechanics/aifollow.hpp b/apps/openmw/mwmechanics/aifollow.hpp index 50143338f6..21b98c4a8c 100644 --- a/apps/openmw/mwmechanics/aifollow.hpp +++ b/apps/openmw/mwmechanics/aifollow.hpp @@ -44,8 +44,8 @@ namespace MWMechanics /// Follow Actor for duration or until you arrive at a world position AiFollow(const ESM::RefId& actorId, float duration, float x, float y, float z, bool repeat); /// Follow Actor for duration or until you arrive at a position in a cell - AiFollow(const ESM::RefId& actorId, const ESM::RefId& cellId, float duration, float x, float y, float z, - bool repeat); + AiFollow( + const ESM::RefId& actorId, std::string_view cellId, float duration, float x, float y, float z, bool repeat); /// Follow Actor indefinitively AiFollow(const MWWorld::Ptr& actor, bool commanded = false); @@ -94,7 +94,7 @@ namespace MWMechanics const float mX; const float mY; const float mZ; - const ESM::RefId mCellId; + const std::string mCellId; bool mActive; // have we spotted the target? const int mFollowIndex; diff --git a/apps/openmw/mwmechanics/spelleffects.cpp b/apps/openmw/mwmechanics/spelleffects.cpp index 1fed81d91f..317bfc2be9 100644 --- a/apps/openmw/mwmechanics/spelleffects.cpp +++ b/apps/openmw/mwmechanics/spelleffects.cpp @@ -487,7 +487,7 @@ namespace MWMechanics world->getPlayer().getMarkedPosition(markedCell, markedPosition); if (markedCell) { - ESM::RefId dest; + std::string_view dest; if (!markedCell->isExterior()) dest = markedCell->getCell()->mName; MWWorld::ActionTeleport action(dest, markedPosition, false); diff --git a/apps/openmw/mwscript/aiextensions.cpp b/apps/openmw/mwscript/aiextensions.cpp index 722bc45e5b..421ce5866f 100644 --- a/apps/openmw/mwscript/aiextensions.cpp +++ b/apps/openmw/mwscript/aiextensions.cpp @@ -141,7 +141,7 @@ namespace MWScript ESM::RefId actorID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); runtime.pop(); - ESM::RefId cellID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); + std::string_view cellID = runtime.getStringLiteral(runtime[0].mInteger); runtime.pop(); Interpreter::Type_Float duration = runtime[0].mFloat; @@ -371,7 +371,7 @@ namespace MWScript ESM::RefId actorID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); runtime.pop(); - ESM::RefId cellID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); + std::string_view cellID = runtime.getStringLiteral(runtime[0].mInteger); runtime.pop(); Interpreter::Type_Float duration = runtime[0].mFloat; diff --git a/apps/openmw/mwscript/cellextensions.cpp b/apps/openmw/mwscript/cellextensions.cpp index 21437f0da1..b5a540fd81 100644 --- a/apps/openmw/mwscript/cellextensions.cpp +++ b/apps/openmw/mwscript/cellextensions.cpp @@ -86,7 +86,7 @@ namespace MWScript public: void execute(Interpreter::Runtime& runtime) override { - const ESM::RefId cell = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); + std::string_view cell = runtime.getStringLiteral(runtime[0].mInteger); runtime.pop(); ESM::Position pos; diff --git a/apps/openmw/mwscript/guiextensions.cpp b/apps/openmw/mwscript/guiextensions.cpp index 4266399bd9..8f09500bde 100644 --- a/apps/openmw/mwscript/guiextensions.cpp +++ b/apps/openmw/mwscript/guiextensions.cpp @@ -126,7 +126,7 @@ namespace MWScript for (auto it = cells.extBegin(); it != cells.extEnd(); ++it) { - const auto& cellName = it->mName.getRefIdString(); + const auto& cellName = it->mName; if (Misc::StringUtils::ciStartsWith(cellName, cell)) winMgr->addVisitedLocation(cellName, it->getGridX(), it->getGridY()); } @@ -143,7 +143,7 @@ namespace MWScript for (auto it = cells.extBegin(); it != cells.extEnd(); ++it) { - const std::string& name = it->mName.getRefIdString(); + const std::string& name = it->mName; if (!name.empty()) MWBase::Environment::get().getWindowManager()->addVisitedLocation( name, it->getGridX(), it->getGridY()); diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index f5ba056338..83a3c0ef0c 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -382,7 +382,7 @@ namespace MWScript runtime.pop(); Interpreter::Type_Float zRot = runtime[0].mFloat; runtime.pop(); - const ESM::RefId cellID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); + std::string_view cellID = runtime.getStringLiteral(runtime[0].mInteger); runtime.pop(); if (ptr.getContainerStore()) @@ -405,8 +405,7 @@ namespace MWScript { // cell not found, move to exterior instead if moving the player (vanilla PositionCell // compatibility) - std::string error - = "Warning: PositionCell: unknown interior cell (" + cellID.getRefIdString() + ")"; + std::string error = "Warning: PositionCell: unknown interior cell (" + std::string(cellID) + ")"; if (isPlayer) error += ", moving to exterior instead"; runtime.getContext().report(error); @@ -500,7 +499,7 @@ namespace MWScript { const ESM::RefId itemID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); runtime.pop(); - auto cellID = ESM::RefId::stringRefId(runtime.getStringLiteral(runtime[0].mInteger)); + std::string_view cellName = runtime.getStringLiteral(runtime[0].mInteger); runtime.pop(); Interpreter::Type_Float x = runtime[0].mFloat; @@ -515,12 +514,12 @@ namespace MWScript MWWorld::CellStore* store = nullptr; try { - store = MWBase::Environment::get().getWorldModel()->getCell(cellID); + store = MWBase::Environment::get().getWorldModel()->getCell(cellName); } catch (std::exception&) { - runtime.getContext().report("unknown cell (" + cellID.getRefIdString() + ")"); - Log(Debug::Error) << "Error: unknown cell (" << cellID << ")"; + runtime.getContext().report("unknown cell (" + std::string(cellName) + ")"); + Log(Debug::Error) << "Error: unknown cell (" << cellName << ")"; } if (store) { diff --git a/apps/openmw/mwworld/actionteleport.cpp b/apps/openmw/mwworld/actionteleport.cpp index 29e2687aa4..195eaff43d 100644 --- a/apps/openmw/mwworld/actionteleport.cpp +++ b/apps/openmw/mwworld/actionteleport.cpp @@ -17,7 +17,7 @@ namespace MWWorld { - ActionTeleport::ActionTeleport(const ESM::RefId& cellName, const ESM::Position& position, bool teleportFollowers) + ActionTeleport::ActionTeleport(std::string_view cellName, const ESM::Position& position, bool teleportFollowers) : Action(true) , mCellName(cellName) , mPosition(position) diff --git a/apps/openmw/mwworld/actionteleport.hpp b/apps/openmw/mwworld/actionteleport.hpp index ba15e77725..cbdd59cc87 100644 --- a/apps/openmw/mwworld/actionteleport.hpp +++ b/apps/openmw/mwworld/actionteleport.hpp @@ -13,7 +13,7 @@ namespace MWWorld { class ActionTeleport : public Action { - ESM::RefId mCellName; + std::string mCellName; ESM::Position mPosition; bool mTeleportFollowers; @@ -26,7 +26,7 @@ namespace MWWorld public: /// If cellName is empty, an exterior cell is assumed. /// @param teleportFollowers Whether to teleport any following actors of the target actor as well. - ActionTeleport(const ESM::RefId& cellName, const ESM::Position& position, bool teleportFollowers); + ActionTeleport(std::string_view cellName, const ESM::Position& position, bool teleportFollowers); /// @param includeHostiles If true, include hostile followers (which won't actually be teleported) in the /// output, diff --git a/apps/openmw/mwworld/cellref.hpp b/apps/openmw/mwworld/cellref.hpp index 13db1daa66..e0b589c408 100644 --- a/apps/openmw/mwworld/cellref.hpp +++ b/apps/openmw/mwworld/cellref.hpp @@ -47,7 +47,7 @@ namespace MWWorld const ESM::Position& getDoorDest() const { return mCellRef.mDoorDest; } // Destination cell for doors (optional) - const ESM::RefId& getDestCell() const { return mCellRef.mDestCell; } + const std::string& getDestCell() const { return mCellRef.mDestCell; } // Scale applied to mesh float getScale() const { return mCellRef.mScale; } diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 38ec5112a2..5b008f10bf 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -541,7 +541,8 @@ namespace MWWorld } mNavigator.setWorldspace( - mWorld.getWorldModel().getExterior(playerCellX, playerCellY)->getCell()->mCellId.mWorldspace, + ESM::RefId::stringRefId( + mWorld.getWorldModel().getExterior(playerCellX, playerCellY)->getCell()->mCellId.mWorldspace), navigatorUpdateGuard.get()); mNavigator.updateBounds(pos, navigatorUpdateGuard.get()); @@ -663,7 +664,8 @@ namespace MWWorld "Testing exterior cells (" + std::to_string(i) + "/" + std::to_string(cells.getExtSize()) + ")..."); CellStore* cell = mWorld.getWorldModel().getExterior(it->mData.mX, it->mData.mY); - mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get()); + mNavigator.setWorldspace( + ESM::RefId::stringRefId(cell->getCell()->mCellId.mWorldspace), navigatorUpdateGuard.get()); const osg::Vec3f position = osg::Vec3f(it->mData.mX + 0.5f, it->mData.mY + 0.5f, 0) * Constants::CellSizeInUnits; mNavigator.updateBounds(position, navigatorUpdateGuard.get()); @@ -720,7 +722,8 @@ namespace MWWorld "Testing interior cells (" + std::to_string(i) + "/" + std::to_string(cells.getIntSize()) + ")..."); CellStore* cell = mWorld.getWorldModel().getInterior(it->mName); - mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get()); + mNavigator.setWorldspace( + ESM::RefId::stringRefId(cell->getCell()->mCellId.mWorldspace), navigatorUpdateGuard.get()); ESM::Position position; mWorld.findInteriorPosition(it->mName, position); mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get()); @@ -839,7 +842,7 @@ namespace MWWorld } void Scene::changeToInteriorCell( - const ESM::RefId& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent) + std::string_view cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent) { CellStore* cell = mWorld.getWorldModel().getInterior(cellName); bool useFading = (mCurrentCell != nullptr); @@ -876,7 +879,8 @@ namespace MWWorld loadingListener->setProgressRange(cell->count()); - mNavigator.setWorldspace(cell->getCell()->mCellId.mWorldspace, navigatorUpdateGuard.get()); + mNavigator.setWorldspace( + ESM::RefId::stringRefId(cell->getCell()->mCellId.mWorldspace), navigatorUpdateGuard.get()); mNavigator.updateBounds(position.asVec3(), navigatorUpdateGuard.get()); // Load cell. diff --git a/apps/openmw/mwworld/scene.hpp b/apps/openmw/mwworld/scene.hpp index 6e6607840a..d43842fbba 100644 --- a/apps/openmw/mwworld/scene.hpp +++ b/apps/openmw/mwworld/scene.hpp @@ -163,7 +163,7 @@ namespace MWWorld void resetCellLoaded() { mCellLoaded = false; } void changeToInteriorCell( - const ESM::RefId& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent = true); + std::string_view cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent = true); ///< Move to interior cell. /// @param changeEvent Set cellChanged flag? diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index bf8d656ecd..5a1e508cb1 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -513,15 +513,16 @@ namespace MWWorld esm.restoreContext(ctx); } - const ESM::Cell* Store::search(const ESM::RefId& id) const + const ESM::Cell* Store::search(std::string_view name) const { - DynamicInt::const_iterator it = mInt.find(id); + const std::string nameString = std::string(name); + DynamicInt::const_iterator it = mInt.find(nameString); if (it != mInt.end()) { return &(it->second); } - DynamicInt::const_iterator dit = mDynamicInt.find(id); + DynamicInt::const_iterator dit = mDynamicInt.find(nameString); if (dit != mDynamicInt.end()) { return &dit->second; @@ -574,12 +575,12 @@ namespace MWWorld return &mExt.insert(std::make_pair(key, newCell)).first->second; } - const ESM::Cell* Store::find(const ESM::RefId& id) const + const ESM::Cell* Store::find(std::string_view id) const { const ESM::Cell* ptr = search(id); if (ptr == nullptr) { - const std::string msg = "Cell '" + id.getRefIdString() + "' not found"; + const std::string msg = "Cell '" + std::string(id) + "' not found"; throw std::runtime_error(msg); } return ptr; @@ -709,7 +710,7 @@ namespace MWWorld } } - return RecordId(cell.mName, isDeleted); + return RecordId(ESM::RefId::stringRefId(cell.mName), isDeleted); } Store::iterator Store::intBegin() const { @@ -727,12 +728,12 @@ namespace MWWorld { return iterator(mSharedExt.end()); } - const ESM::Cell* Store::searchExtByName(const ESM::RefId& id) const + const ESM::Cell* Store::searchExtByName(std::string_view name) const { const ESM::Cell* cell = nullptr; for (const ESM::Cell* sharedCell : mSharedExt) { - if (sharedCell->mName == id) + if (sharedCell->mName == name) { if (cell == nullptr || (sharedCell->mData.mX > cell->mData.mX) || (sharedCell->mData.mX == cell->mData.mX && sharedCell->mData.mY > cell->mData.mY)) @@ -777,7 +778,7 @@ namespace MWWorld for (const ESM::Cell* sharedCell : mSharedInt) { - list.push_back(sharedCell->mName); + list.push_back(ESM::RefId::stringRefId(sharedCell->mName)); } } ESM::Cell* Store::insert(const ESM::Cell& cell) @@ -812,9 +813,10 @@ namespace MWWorld } return erase(cell.mName); } - bool Store::erase(const ESM::RefId& id) + bool Store::erase(std::string_view name) { - DynamicInt::iterator it = mDynamicInt.find(id); + const std::string nameString = std::string(name); + auto it = mDynamicInt.find(nameString); if (it == mDynamicInt.end()) { @@ -875,7 +877,8 @@ namespace MWWorld // also an exterior cell with the coordinates of (0,0), so that doesn't help. Check whether mCell is an interior // cell. This isn't perfect, will break if a Region with the same name as an interior cell is created. A proper // fix should be made for future versions of the file format. - bool interior = pathgrid.mData.mX == 0 && pathgrid.mData.mY == 0 && mCells->search(pathgrid.mCell) != nullptr; + bool interior = pathgrid.mData.mX == 0 && pathgrid.mData.mY == 0 + && mCells->search(pathgrid.mCell.getRefIdString()) != nullptr; // deal with mods that have empty pathgrid records (Issue #6209) // we assume that these records are empty on purpose (i.e. to remove old pathgrid on an updated cell) @@ -928,7 +931,7 @@ namespace MWWorld } const ESM::Pathgrid* Store::search(const ESM::RefId& name) const { - Interior::const_iterator it = mInt.find(name); + Interior::const_iterator it = mInt.find(ESM::RefId(name)); if (it != mInt.end()) return &(it->second); return nullptr; @@ -958,14 +961,14 @@ namespace MWWorld if (!(cell.mData.mFlags & ESM::Cell::Interior)) return search(cell.mData.mX, cell.mData.mY); else - return search(cell.mName); + return search(ESM::RefId::stringRefId(cell.mName)); } const ESM::Pathgrid* Store::find(const ESM::Cell& cell) const { if (!(cell.mData.mFlags & ESM::Cell::Interior)) return find(cell.mData.mX, cell.mData.mY); else - return find(cell.mName); + return find(ESM::RefId::stringRefId(cell.mName)); } // Skill diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index 6acfb6d41e..5da7722aab 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -332,7 +332,8 @@ namespace MWWorld } }; - typedef std::unordered_map DynamicInt; + typedef std::unordered_map DynamicInt; + typedef std::map, ESM::Cell, DynamicExtCmp> DynamicExt; DynamicInt mInt; @@ -350,12 +351,12 @@ namespace MWWorld public: typedef SharedIterator iterator; - const ESM::Cell* search(const ESM::RefId& id) const; + const ESM::Cell* search(std::string_view id) const; const ESM::Cell* search(int x, int y) const; const ESM::Cell* searchStatic(int x, int y) const; const ESM::Cell* searchOrCreate(int x, int y); - const ESM::Cell* find(const ESM::RefId& id) const; + const ESM::Cell* find(std::string_view id) const; const ESM::Cell* find(int x, int y) const; void clearDynamic() override; @@ -369,7 +370,7 @@ namespace MWWorld iterator extEnd() const; // Return the northernmost cell in the easternmost column. - const ESM::Cell* searchExtByName(const ESM::RefId& id) const; + const ESM::Cell* searchExtByName(std::string_view id) const; // Return the northernmost cell in the easternmost column. const ESM::Cell* searchExtByRegion(const ESM::RefId& id) const; @@ -383,7 +384,7 @@ namespace MWWorld ESM::Cell* insert(const ESM::Cell& cell); bool erase(const ESM::Cell& cell); - bool erase(const ESM::RefId& id); + bool erase(std::string_view id); bool erase(int x, int y); }; diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index d5c785035a..8e7d1405ac 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -156,7 +156,7 @@ namespace MWWorld World::World(osgViewer::Viewer* viewer, osg::ref_ptr rootNode, Resource::ResourceSystem* resourceSystem, SceneUtil::WorkQueue* workQueue, SceneUtil::UnrefQueue& unrefQueue, const Files::Collections& fileCollections, const std::vector& contentFiles, const std::vector& groundcoverFiles, - ToUTF8::Utf8Encoder* encoder, int activationDistanceOverride, const ESM::RefId& startCell, + ToUTF8::Utf8Encoder* encoder, int activationDistanceOverride, const std::string& startCell, const std::string& startupScript, const std::filesystem::path& resourcePath, const std::filesystem::path& userDataPath) : mResourceSystem(resourceSystem) @@ -640,7 +640,7 @@ namespace MWWorld if (cell) { if (!cell->isExterior() || !cell->mName.empty()) - return cell->mName.getRefIdString(); + return cell->mName; if (const ESM::Region* region = mStore.get().search(cell->mRegion)) return region->mName; @@ -928,7 +928,7 @@ namespace MWWorld } void World::changeToInteriorCell( - const ESM::RefId& cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent) + const std::string_view cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent) { mPhysics->clearQueuedMovement(); mDiscardMovements = true; @@ -1399,10 +1399,10 @@ namespace MWWorld esmPos.pos[0] = traced.x(); esmPos.pos[1] = traced.y(); esmPos.pos[2] = traced.z(); - const ESM::RefId* cell = &ESM::RefId::sEmpty; + std::string_view cell = ""; if (!actor.getCell()->isExterior()) - cell = &actor.getCell()->getCell()->mName; - MWWorld::ActionTeleport(*cell, esmPos, false).execute(actor); + cell = actor.getCell()->getCell()->mName; + MWWorld::ActionTeleport(cell, esmPos, false).execute(actor); } } @@ -2747,7 +2747,7 @@ namespace MWWorld physicActor->enableCollisionBody(enable); } - bool World::findInteriorPosition(const ESM::RefId& name, ESM::Position& pos) + bool World::findInteriorPosition(std::string_view name, ESM::Position& pos) { pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; pos.pos[0] = pos.pos[1] = pos.pos[2] = 0; @@ -2819,10 +2819,9 @@ namespace MWWorld return false; } - bool World::findExteriorPosition(const ESM::RefId& nameId, ESM::Position& pos) + bool World::findExteriorPosition(std::string_view nameId, ESM::Position& pos) { pos.rot[0] = pos.rot[1] = pos.rot[2] = 0; - const std::string& name = nameId.getRefIdString(); const ESM::Cell* ext = nullptr; try @@ -2836,12 +2835,13 @@ namespace MWWorld } if (!ext) { - size_t comma = name.find(','); + size_t comma = nameId.find(','); if (comma != std::string::npos) { int x, y; - std::from_chars_result xResult = std::from_chars(name.data(), name.data() + comma, x); - std::from_chars_result yResult = std::from_chars(name.data() + comma + 1, name.data() + name.size(), y); + std::from_chars_result xResult = std::from_chars(nameId.data(), nameId.data() + comma, x); + std::from_chars_result yResult + = std::from_chars(nameId.data() + comma + 1, nameId.data() + nameId.size(), y); if (xResult.ec == std::errc::result_out_of_range || yResult.ec == std::errc::result_out_of_range) throw std::runtime_error("Cell coordinates out of range."); else if (xResult.ec == std::errc{} && yResult.ec == std::errc{}) @@ -3253,9 +3253,9 @@ namespace MWWorld // Search for a 'nearest' exterior, counting each cell between the starting // cell and the exterior as a distance of 1. Will fail for isolated interiors. - std::set checkedCells; - std::set currentCells; - std::set nextCells; + std::set checkedCells; + std::set currentCells; + std::set nextCells; nextCells.insert(cell->getCell()->mName); while (!nextCells.empty()) @@ -3282,7 +3282,7 @@ namespace MWWorld } else { - const ESM::RefId& dest = ref.mRef.getDestCell(); + const std::string_view dest = ref.mRef.getDestCell(); if (!checkedCells.count(dest) && !currentCells.count(dest)) nextCells.insert(dest); } @@ -3306,9 +3306,9 @@ namespace MWWorld // Search for a 'nearest' marker, counting each cell between the starting // cell and the exterior as a distance of 1. If an exterior is found, jump // to the nearest exterior marker, without further interior searching. - std::set checkedCells; - std::set currentCells; - std::set nextCells; + std::set checkedCells; + std::set currentCells; + std::set nextCells; MWWorld::ConstPtr closestMarker; nextCells.insert(ptr.getCell()->getCell()->mName); @@ -3404,11 +3404,11 @@ namespace MWWorld return; } - const ESM::RefId* cellName = &ESM::RefId::sEmpty; + std::string_view cellName = ""; if (!closestMarker.mCell->isExterior()) - cellName = &closestMarker.mCell->getCell()->mName; + cellName = closestMarker.mCell->getCell()->mName; - MWWorld::ActionTeleport action(*cellName, closestMarker.getRefData().getPosition(), false); + MWWorld::ActionTeleport action(cellName, closestMarker.getRefData().getPosition(), false); action.execute(ptr); } @@ -3610,7 +3610,7 @@ namespace MWWorld Log(Debug::Warning) << "Failed to confiscate items: no closest prison marker found."; return; } - const ESM::RefId& prisonName = prisonMarker.getCellRef().getDestCell(); + std::string_view prisonName = prisonMarker.getCellRef().getDestCell(); if (prisonName.empty()) { Log(Debug::Warning) << "Failed to confiscate items: prison marker not linked to prison interior"; diff --git a/apps/openmw/mwworld/worldimp.hpp b/apps/openmw/mwworld/worldimp.hpp index 1aaefe20c7..df2ee69fbf 100644 --- a/apps/openmw/mwworld/worldimp.hpp +++ b/apps/openmw/mwworld/worldimp.hpp @@ -94,7 +94,7 @@ namespace MWWorld WorldModel mWorldModel; std::vector mESMVersions; // the versions of esm files - ESM::RefId mCurrentWorldSpace; + std::string mCurrentWorldSpace; std::unique_ptr mPlayer; std::unique_ptr mPhysics; @@ -118,7 +118,7 @@ namespace MWWorld int mActivationDistanceOverride; - ESM::RefId mStartCell; + std::string mStartCell; float mSwimHeightScale; @@ -200,7 +200,7 @@ namespace MWWorld SceneUtil::WorkQueue* workQueue, SceneUtil::UnrefQueue& unrefQueue, const Files::Collections& fileCollections, const std::vector& contentFiles, const std::vector& groundcoverFiles, ToUTF8::Utf8Encoder* encoder, - int activationDistanceOverride, const ESM::RefId& startCell, const std::string& startupScript, + int activationDistanceOverride, const std::string& startCell, const std::string& startupScript, const std::filesystem::path& resourcePath, const std::filesystem::path& userDataPath); virtual ~World(); @@ -341,7 +341,7 @@ namespace MWWorld void setSimulationTimeScale(float scale) override; - void changeToInteriorCell(const ESM::RefId& cellName, const ESM::Position& position, bool adjustPlayerPos, + void changeToInteriorCell(const std::string_view cellName, const ESM::Position& position, bool adjustPlayerPos, bool changeEvent = true) override; ///< Move to interior cell. ///< @param changeEvent If false, do not trigger cell change flag or detect worldspace changes @@ -603,11 +603,11 @@ namespace MWWorld /// Find center of exterior cell above land surface /// \return false if exterior with given name not exists, true otherwise - bool findExteriorPosition(const ESM::RefId& name, ESM::Position& pos) override; + bool findExteriorPosition(std::string_view nameId, ESM::Position& pos) override; /// Find position in interior cell near door entrance /// \return false if interior with given name not exists, true otherwise - bool findInteriorPosition(const ESM::RefId& name, ESM::Position& pos) override; + bool findInteriorPosition(std::string_view name, ESM::Position& pos) override; /// Enables or disables use of teleport spell effects (recall, intervention, etc). void enableTeleporting(bool enable) override; diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index 3f93931ce7..39fc960ce8 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -19,8 +19,8 @@ namespace { - template - bool forEachInStore(const ESM::RefId& id, Visitor&& visitor, std::map& cellStore) + template + bool forEachInStore(const ESM::RefId& id, Visitor&& visitor, std::map& cellStore) { for (auto& cell : cellStore) { @@ -64,7 +64,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getCellStore(const ESM::Cell* cell) { if (cell->mData.mFlags & ESM::Cell::Interior) { - auto result = mInteriors.find(cell->mName); + auto result = mInteriors.find(std::string(cell->mName)); if (result == mInteriors.end()) result = mInteriors.emplace(cell->mName, CellStore(cell, mStore, mReaders)).first; @@ -196,9 +196,9 @@ MWWorld::CellStore* MWWorld::WorldModel::getExterior(int x, int y) return &result->second; } -MWWorld::CellStore* MWWorld::WorldModel::getInterior(const ESM::RefId& name) +MWWorld::CellStore* MWWorld::WorldModel::getInterior(std::string_view name) { - auto result = mInteriors.find(name); + auto result = mInteriors.find(std::string(name)); if (result == mInteriors.end()) { @@ -223,7 +223,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::CellId& id) return getInterior(id.mWorldspace); } -const ESM::Cell* MWWorld::WorldModel::getESMCellByName(const ESM::RefId& name) +const ESM::Cell* MWWorld::WorldModel::getESMCellByName(std::string_view name) { const ESM::Cell* cell = mStore.get().search(name); // first try interiors if (!cell) // try named exteriors @@ -231,17 +231,17 @@ const ESM::Cell* MWWorld::WorldModel::getESMCellByName(const ESM::RefId& name) if (!cell) { // treat "Wilderness" like an empty string - static const ESM::RefId defaultName - = ESM::RefId::stringRefId(mStore.get().find("sDefaultCellname")->mValue.getString()); + static const std::string& defaultName + = mStore.get().find("sDefaultCellname")->mValue.getString(); if (name == defaultName) - cell = mStore.get().searchExtByName(ESM::RefId::sEmpty); + cell = mStore.get().searchExtByName(""); } if (!cell) { // now check for regions for (const ESM::Region& region : mStore.get()) { - if (name == ESM::RefId::stringRefId(region.mName)) + if (name == region.mName) { cell = mStore.get().searchExtByRegion(region.mId); break; @@ -249,11 +249,11 @@ const ESM::Cell* MWWorld::WorldModel::getESMCellByName(const ESM::RefId& name) } } if (!cell) - throw std::runtime_error(std::string("Can't find cell with name ") + name.getRefIdString()); + throw std::runtime_error(std::string("Can't find cell with name ") + std::string(name)); return cell; } -MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::RefId& name) +MWWorld::CellStore* MWWorld::WorldModel::getCell(std::string_view name) { const ESM::Cell* cell = getESMCellByName(name); if (cell->isExterior()) @@ -263,7 +263,7 @@ MWWorld::CellStore* MWWorld::WorldModel::getCell(const ESM::RefId& name) } MWWorld::CellStore* MWWorld::WorldModel::getCellByPosition( - const osg::Vec3f& pos, const ESM::RefId& cellNameInSameWorldSpace) + const osg::Vec3f& pos, std::string_view cellNameInSameWorldSpace) { if (cellNameInSameWorldSpace.empty() || getESMCellByName(cellNameInSameWorldSpace)->isExterior()) { diff --git a/apps/openmw/mwworld/worldmodel.hpp b/apps/openmw/mwworld/worldmodel.hpp index 204302667a..6536c063fe 100644 --- a/apps/openmw/mwworld/worldmodel.hpp +++ b/apps/openmw/mwworld/worldmodel.hpp @@ -6,6 +6,8 @@ #include #include +#include + #include "cellstore.hpp" #include "ptr.hpp" @@ -34,7 +36,7 @@ namespace MWWorld typedef std::vector> IdCache; const MWWorld::ESMStore& mStore; ESM::ReadersCache& mReaders; - mutable std::map mInteriors; + mutable std::map mInteriors; mutable std::map, CellStore> mExteriors; IdCache mIdCache; std::size_t mIdCacheIndex; @@ -42,7 +44,7 @@ namespace MWWorld WorldModel(const WorldModel&); WorldModel& operator=(const WorldModel&); - const ESM::Cell* getESMCellByName(const ESM::RefId& name); + const ESM::Cell* getESMCellByName(std::string_view name); CellStore* getCellStore(const ESM::Cell* cell); Ptr getPtrAndCache(const ESM::RefId& name, CellStore& cellStore); @@ -61,14 +63,14 @@ namespace MWWorld explicit WorldModel(const MWWorld::ESMStore& store, ESM::ReadersCache& reader); CellStore* getExterior(int x, int y); - CellStore* getInterior(const ESM::RefId& name); - CellStore* getCell(const ESM::RefId& name); // interior or named exterior - CellStore* getCell(const ESM::CellId& id); + CellStore* getInterior(std::string_view name); + CellStore* getCell(std::string_view name); // interior or named exterior + CellStore* getCell(const ESM::CellId& Id); // If cellNameInSameWorldSpace is an interior - returns this interior. // Otherwise returns exterior cell for given position in the same world space. // At the moment multiple world spaces are not supported, so all exteriors are in one world space. - CellStore* getCellByPosition(const osg::Vec3f& pos, const ESM::RefId& cellNameInSameWorldSpace); + CellStore* getCellByPosition(const osg::Vec3f& pos, std::string_view cellNameInSameWorldSpace); void registerPtr(const MWWorld::Ptr& ptr); void deregisterPtr(const MWWorld::Ptr& ptr); diff --git a/components/esm3/aisequence.cpp b/components/esm3/aisequence.cpp index 69b639f0e8..377006e12b 100644 --- a/components/esm3/aisequence.cpp +++ b/components/esm3/aisequence.cpp @@ -54,7 +54,7 @@ namespace ESM mTargetActorId = -1; esm.getHNOT(mTargetActorId, "TAID"); esm.getHNT(mRemainingDuration, "DURA"); - mCellId = ESM::RefId::stringRefId(esm.getHNOString("CELL")); + mCellId = esm.getHNOString("CELL"); mRepeat = false; esm.getHNOT(mRepeat, "REPT"); if (esm.getFormat() < 18) @@ -74,7 +74,7 @@ namespace ESM esm.writeHNT("TAID", mTargetActorId); esm.writeHNT("DURA", mRemainingDuration); if (!mCellId.empty()) - esm.writeHNString("CELL", mCellId.getRefIdString()); + esm.writeHNString("CELL", mCellId); if (mRepeat) esm.writeHNT("REPT", mRepeat); } @@ -86,7 +86,7 @@ namespace ESM mTargetActorId = -1; esm.getHNOT(mTargetActorId, "TAID"); esm.getHNT(mRemainingDuration, "DURA"); - mCellId = ESM::RefId::stringRefId(esm.getHNOString("CELL")); + mCellId = esm.getHNOString("CELL"); esm.getHNT(mAlwaysFollow, "ALWY"); mCommanded = false; esm.getHNOT(mCommanded, "CMND"); @@ -111,7 +111,7 @@ namespace ESM esm.writeHNT("TAID", mTargetActorId); esm.writeHNT("DURA", mRemainingDuration); if (!mCellId.empty()) - esm.writeHNString("CELL", mCellId.getRefIdString()); + esm.writeHNString("CELL", mCellId); esm.writeHNT("ALWY", mAlwaysFollow); esm.writeHNT("CMND", mCommanded); if (mActive) diff --git a/components/esm3/aisequence.hpp b/components/esm3/aisequence.hpp index 24ee63e18c..10e1b316eb 100644 --- a/components/esm3/aisequence.hpp +++ b/components/esm3/aisequence.hpp @@ -92,7 +92,7 @@ namespace ESM int mTargetActorId; ESM::RefId mTargetId; - ESM::RefId mCellId; + std::string mCellId; float mRemainingDuration; bool mRepeat; @@ -106,7 +106,7 @@ namespace ESM int mTargetActorId; ESM::RefId mTargetId; - ESM::RefId mCellId; + std::string mCellId; float mRemainingDuration; bool mAlwaysFollow; diff --git a/components/esm3/cellid.cpp b/components/esm3/cellid.cpp index 64ca4c03ba..a63a1bfad6 100644 --- a/components/esm3/cellid.cpp +++ b/components/esm3/cellid.cpp @@ -6,11 +6,11 @@ namespace ESM { - const ESM::RefId CellId::sDefaultWorldspace = ESM::RefId::stringRefId("sys::default"); + const std::string CellId::sDefaultWorldspace = "sys::default"; void CellId::load(ESMReader& esm) { - mWorldspace = ESM::RefId::stringRefId(esm.getHNString("SPAC")); + mWorldspace = esm.getHNString("SPAC"); if (esm.isNextSub("CIDX")) { @@ -23,7 +23,7 @@ namespace ESM void CellId::save(ESMWriter& esm) const { - esm.writeHNString("SPAC", mWorldspace.getRefIdString()); + esm.writeHNString("SPAC", mWorldspace); if (mPaged) esm.writeHNT("CIDX", mIndex, 8); diff --git a/components/esm3/cellid.hpp b/components/esm3/cellid.hpp index 40acb63a2b..33db9e7432 100644 --- a/components/esm3/cellid.hpp +++ b/components/esm3/cellid.hpp @@ -17,11 +17,11 @@ namespace ESM int mY; }; - ESM::RefId mWorldspace; + std::string mWorldspace; CellIndex mIndex; bool mPaged; - static const ESM::RefId sDefaultWorldspace; + static const std::string sDefaultWorldspace; void load(ESMReader& esm); void save(ESMWriter& esm) const; diff --git a/components/esm3/cellref.cpp b/components/esm3/cellref.cpp index b83adedda3..733274619e 100644 --- a/components/esm3/cellref.cpp +++ b/components/esm3/cellref.cpp @@ -109,7 +109,7 @@ namespace ESM cellRef.mTeleport = true; break; case fourCC("DNAM"): - getRefIdOrSkip(cellRef.mDestCell); + getHStringOrSkip(cellRef.mDestCell); break; case fourCC("FLTV"): getHTOrSkip(cellRef.mLockLevel); @@ -235,7 +235,7 @@ namespace ESM if (!inInventory && mTeleport) { esm.writeHNT("DODT", mDoorDest); - esm.writeHNOCString("DNAM", mDestCell.getRefIdString()); + esm.writeHNOCString("DNAM", mDestCell); } if (!inInventory && mLockLevel != 0) @@ -270,7 +270,7 @@ namespace ESM mChargeIntRemainder = 0.0f; mEnchantmentCharge = -1; mGoldValue = 1; - mDestCell = ESM::RefId::sEmpty; + mDestCell.clear(); mLockLevel = 0; mKey = ESM::RefId::sEmpty; mTrap = ESM::RefId::sEmpty; diff --git a/components/esm3/cellref.hpp b/components/esm3/cellref.hpp index b514748a41..7912c11b69 100644 --- a/components/esm3/cellref.hpp +++ b/components/esm3/cellref.hpp @@ -89,7 +89,7 @@ namespace ESM Position mDoorDest; // Destination cell for doors (optional) - ESM::RefId mDestCell; + std::string mDestCell; // Lock level for doors and containers int mLockLevel; diff --git a/components/esm3/loadcell.cpp b/components/esm3/loadcell.cpp index 7c1e500ea3..f69fd88c44 100644 --- a/components/esm3/loadcell.cpp +++ b/components/esm3/loadcell.cpp @@ -71,7 +71,7 @@ namespace ESM switch (esm.retSubName().toInt()) { case SREC_NAME: - mName = esm.getRefId(); + mName = esm.getHString(); break; case fourCC("DATA"): esm.getHTSized<12>(mData); @@ -101,7 +101,7 @@ namespace ESM } else { - mCellId.mWorldspace = mName; + mCellId.mWorldspace = Misc::StringUtils::lowerCase(mName); mCellId.mIndex.mX = 0; mCellId.mIndex.mY = 0; } @@ -173,7 +173,7 @@ namespace ESM void Cell::save(ESMWriter& esm, bool isDeleted) const { - esm.writeHNCString("NAME", mName.getRefIdString()); + esm.writeHNCString("NAME", mName); esm.writeHNT("DATA", mData, 12); if (isDeleted) @@ -225,7 +225,7 @@ namespace ESM std::string Cell::getDescription() const { - const auto& nameString = mName.getRefIdString(); + const auto& nameString = mName; if (mData.mFlags & Interior) return nameString; @@ -315,7 +315,7 @@ namespace ESM void Cell::blank() { - mName = ESM::RefId::sEmpty; + mName = ""; mRegion = ESM::RefId::sEmpty; mWater = 0; mWaterInt = false; diff --git a/components/esm3/loadcell.hpp b/components/esm3/loadcell.hpp index dd7fedf661..3cf1834dfa 100644 --- a/components/esm3/loadcell.hpp +++ b/components/esm3/loadcell.hpp @@ -101,7 +101,7 @@ namespace ESM }; Cell() - : mName(ESM::RefId::sEmpty) + : mName("") , mRegion(ESM::RefId()) , mHasAmbi(true) , mWater(0) @@ -113,7 +113,7 @@ namespace ESM // Interior cells are indexed by this (it's the 'id'), for exterior // cells it is optional. - ESM::RefId mName; + std::string mName; // Optional region name for exterior and quasi-exterior cells. RefId mRegion; diff --git a/components/esm3/transport.cpp b/components/esm3/transport.cpp index 850edb1170..aacbbe5a52 100644 --- a/components/esm3/transport.cpp +++ b/components/esm3/transport.cpp @@ -18,7 +18,7 @@ namespace ESM } else if (esm.retSubName().toInt() == fourCC("DNAM")) { - const ESM::RefId name = esm.getRefId(); + std::string name = esm.getHString(); if (mList.empty()) Log(Debug::Warning) << "Encountered DNAM record without DODT record, skipped."; else @@ -32,7 +32,7 @@ namespace ESM for (DestIter it = mList.begin(); it != mList.end(); ++it) { esm.writeHNT("DODT", it->mPos, sizeof(it->mPos)); - esm.writeHNOCString("DNAM", it->mCellName.getRefIdString()); + esm.writeHNOCString("DNAM", it->mCellName); } } diff --git a/components/esm3/transport.hpp b/components/esm3/transport.hpp index 2e70a98e11..2d4f3002b3 100644 --- a/components/esm3/transport.hpp +++ b/components/esm3/transport.hpp @@ -20,7 +20,7 @@ namespace ESM struct Dest { Position mPos; - ESM::RefId mCellName; + std::string mCellName; }; std::vector mList; diff --git a/components/esmloader/load.cpp b/components/esmloader/load.cpp index 6783ec416b..46fe3717a4 100644 --- a/components/esmloader/load.cpp +++ b/components/esmloader/load.cpp @@ -59,7 +59,7 @@ namespace EsmLoader struct CellRecords { Records mValues; - std::map mByName; + std::map mByName; std::map, std::size_t> mByPosition; };