diff --git a/apps/opencs/model/world/cellcoordinates.cpp b/apps/opencs/model/world/cellcoordinates.cpp index a82d4649a6..bb5c73fc54 100644 --- a/apps/opencs/model/world/cellcoordinates.cpp +++ b/apps/opencs/model/world/cellcoordinates.cpp @@ -6,6 +6,7 @@ #include +#include #include #include @@ -59,6 +60,11 @@ bool CSMWorld::CellCoordinates::isExteriorCell(const std::string& id) return (!id.empty() && id[0] == '#'); } +bool CSMWorld::CellCoordinates::isExteriorCell(const ESM::RefId& id) +{ + return id.startsWith("#"); +} + std::pair CSMWorld::CellCoordinates::fromId(const std::string& id) { // no worldspace for now, needs to be changed for 1.1 diff --git a/apps/opencs/model/world/cellcoordinates.hpp b/apps/opencs/model/world/cellcoordinates.hpp index 0be856e7f0..d6359ffa52 100644 --- a/apps/opencs/model/world/cellcoordinates.hpp +++ b/apps/opencs/model/world/cellcoordinates.hpp @@ -12,6 +12,11 @@ namespace osg class Vec3d; } +namespace ESM +{ + class RefId; +} + namespace CSMWorld { class CellCoordinates @@ -41,6 +46,8 @@ namespace CSMWorld static bool isExteriorCell(const std::string& id); + static bool isExteriorCell(const ESM::RefId& id); + /// \return first: CellCoordinates (or 0, 0 if cell does not have coordinates), /// second: is cell paged? /// diff --git a/apps/opencs/model/world/collection.hpp b/apps/opencs/model/world/collection.hpp index ad8d3690b8..0ec7142d2a 100644 --- a/apps/opencs/model/world/collection.hpp +++ b/apps/opencs/model/world/collection.hpp @@ -91,10 +91,10 @@ namespace CSMWorld /// /// \return Success? - int cloneRecordImp(const std::string& origin, const std::string& dest, UniversalId::Type type); + int cloneRecordImp(const ESM::RefId& origin, const ESM::RefId& dest, UniversalId::Type type); ///< Returns the index of the clone. - int touchRecordImp(const std::string& id); + int touchRecordImp(const ESM::RefId& id); ///< Returns the index of the record on success, -1 on failure. public: @@ -227,29 +227,28 @@ namespace CSMWorld template int Collection::cloneRecordImp( - const std::string& origin, const std::string& destination, UniversalId::Type type) + const ESM::RefId& origin, const ESM::RefId& destination, UniversalId::Type type) { auto copy = std::make_unique>(); - copy->mModified = getRecord(ESM::RefId::stringRefId(origin)).get(); + copy->mModified = getRecord(origin).get(); copy->mState = RecordBase::State_ModifiedOnly; - setRecordId(ESM::RefId::stringRefId(destination), copy->get()); + setRecordId(destination, copy->get()); if (type == UniversalId::Type_Reference) { CSMWorld::CellRef* ptr = (CSMWorld::CellRef*)©->mModified; ptr->mRefNum.mIndex = 0; } - ESM::RefId destinationRefId = ESM::RefId::stringRefId(destination); - int index = getAppendIndex(destinationRefId, type); - insertRecord(std::move(copy), getAppendIndex(destinationRefId, type)); + const int index = getAppendIndex(destination, type); + insertRecord(std::move(copy), getAppendIndex(destination, type)); return index; } template - int Collection::touchRecordImp(const std::string& id) + int Collection::touchRecordImp(const ESM::RefId& id) { - int index = getIndex(ESM::RefId::stringRefId(id)); + const int index = getIndex(id); Record& record = *mRecords.at(index); if (record.isDeleted()) { @@ -269,27 +268,27 @@ namespace CSMWorld void Collection::cloneRecord( const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type) { - cloneRecordImp(origin.getRefIdString(), destination.getRefIdString(), type); + cloneRecordImp(origin, destination, type); } template <> inline void Collection::cloneRecord( const ESM::RefId& origin, const ESM::RefId& destination, const UniversalId::Type type) { - int index = cloneRecordImp(origin.getRefIdString(), destination.getRefIdString(), type); + const int index = cloneRecordImp(origin, destination, type); mRecords.at(index)->get().setPlugin(0); } template bool Collection::touchRecord(const ESM::RefId& id) { - return touchRecordImp(id.getRefIdString()) != -1; + return touchRecordImp(id) != -1; } template <> inline bool Collection::touchRecord(const ESM::RefId& id) { - int index = touchRecordImp(id.getRefIdString()); + const int index = touchRecordImp(id); if (index >= 0) { mRecords.at(index)->get().setPlugin(0); diff --git a/apps/opencs/view/render/object.cpp b/apps/opencs/view/render/object.cpp index 4887d0ef3d..7782ce36c9 100644 --- a/apps/opencs/view/render/object.cpp +++ b/apps/opencs/view/render/object.cpp @@ -737,7 +737,7 @@ void CSVRender::Object::apply(CSMWorld::CommandMacro& commands) // Do cell check first so positions can be compared const CSMWorld::CellRef& ref = collection.getRecord(recordIndex).get(); - if (CSMWorld::CellCoordinates::isExteriorCell(ref.mCell.getRefIdString())) + if (CSMWorld::CellCoordinates::isExteriorCell(ref.mCell)) { // Find cell index at new position std::pair cellIndex