mirror of
https://github.com/OpenMW/openmw.git
synced 2025-06-20 21:41:35 +00:00
Get Rid of ESM::CellId almost everywhere
it was a competing concept from using RefIds for cell. There is almost no point to it now, except to load older data.
This commit is contained in:
parent
fb6701ac1a
commit
c2182c2fcc
18 changed files with 82 additions and 93 deletions
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <components/esm3/loadcell.hpp>
|
||||||
#include <components/misc/constants.hpp>
|
#include <components/misc/constants.hpp>
|
||||||
#include <components/misc/strings/lower.hpp>
|
#include <components/misc/strings/lower.hpp>
|
||||||
|
|
||||||
|
@ -60,20 +61,19 @@ namespace ESSImport
|
||||||
|
|
||||||
const PCDT::PNAM::MarkLocation& mark = pcdt.mPNAM.mMarkLocation;
|
const PCDT::PNAM::MarkLocation& mark = pcdt.mPNAM.mMarkLocation;
|
||||||
|
|
||||||
ESM::CellId cell;
|
ESM::RefId cell;
|
||||||
cell.mPaged = true;
|
|
||||||
|
|
||||||
cell.mIndex.mX = mark.mCellX;
|
|
||||||
cell.mIndex.mY = mark.mCellY;
|
|
||||||
|
|
||||||
// TODO: Figure out a better way to detect interiors. (0, 0) is a valid exterior cell.
|
// TODO: Figure out a better way to detect interiors. (0, 0) is a valid exterior cell.
|
||||||
if (mark.mCellX == 0 && mark.mCellY == 0)
|
if (mark.mCellX == 0 && mark.mCellY == 0)
|
||||||
{
|
{
|
||||||
cell.mWorldspace = pcdt.mMNAM;
|
cell = ESM::RefId::stringRefId(pcdt.mMNAM);
|
||||||
cell.mPaged = false;
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cell = ESM::Cell::generateIdForExteriorCell(mark.mCellX, mark.mCellY);
|
||||||
}
|
}
|
||||||
|
|
||||||
out.mMarkedCell = cell.getCellRefId();
|
out.mMarkedCell = cell;
|
||||||
out.mMarkedPosition.pos[0] = mark.mX;
|
out.mMarkedPosition.pos[0] = mark.mX;
|
||||||
out.mMarkedPosition.pos[1] = mark.mY;
|
out.mMarkedPosition.pos[1] = mark.mY;
|
||||||
out.mMarkedPosition.pos[2] = mark.mZ;
|
out.mMarkedPosition.pos[2] = mark.mZ;
|
||||||
|
|
|
@ -419,8 +419,13 @@ namespace ESSImport
|
||||||
= static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[1] / Constants::CellSizeInUnits));
|
= static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[1] / Constants::CellSizeInUnits));
|
||||||
cellId.mIndex.mX = cellX;
|
cellId.mIndex.mX = cellX;
|
||||||
cellId.mIndex.mY = cellY;
|
cellId.mIndex.mY = cellY;
|
||||||
|
|
||||||
|
context.mPlayer.mCellId = ESM::Cell::generateIdForExteriorCell(cellX, cellY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
context.mPlayer.mCellId = ESM::RefId::stringRefId(cellId.mWorldspace);
|
||||||
}
|
}
|
||||||
context.mPlayer.mCellId = cellId.getCellRefId();
|
|
||||||
context.mPlayer.save(writer);
|
context.mPlayer.save(writer);
|
||||||
writer.endRecord(ESM::REC_PLAY);
|
writer.endRecord(ESM::REC_PLAY);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include <components/esm3/controlsstate.hpp>
|
#include <components/esm3/controlsstate.hpp>
|
||||||
#include <components/esm3/dialoguestate.hpp>
|
#include <components/esm3/dialoguestate.hpp>
|
||||||
#include <components/esm3/globalmap.hpp>
|
#include <components/esm3/globalmap.hpp>
|
||||||
|
#include <components/esm3/loadcell.hpp>
|
||||||
#include <components/esm3/loadcrea.hpp>
|
#include <components/esm3/loadcrea.hpp>
|
||||||
#include <components/esm3/loadnpc.hpp>
|
#include <components/esm3/loadnpc.hpp>
|
||||||
#include <components/esm3/player.hpp>
|
#include <components/esm3/player.hpp>
|
||||||
|
@ -59,10 +60,7 @@ namespace ESSImport
|
||||||
, mHour(0.f)
|
, mHour(0.f)
|
||||||
, mNextActorId(0)
|
, mNextActorId(0)
|
||||||
{
|
{
|
||||||
ESM::CellId playerCellId;
|
mPlayer.mCellId = ESM::Cell::generateIdForExteriorCell(0, 0);
|
||||||
playerCellId.mPaged = true;
|
|
||||||
playerCellId.mIndex.mX = playerCellId.mIndex.mY = 0;
|
|
||||||
mPlayer.mCellId = playerCellId.getCellRefId();
|
|
||||||
mPlayer.mLastKnownExteriorPosition[0] = mPlayer.mLastKnownExteriorPosition[1]
|
mPlayer.mLastKnownExteriorPosition[0] = mPlayer.mLastKnownExteriorPosition[1]
|
||||||
= mPlayer.mLastKnownExteriorPosition[2] = 0.0f;
|
= mPlayer.mLastKnownExteriorPosition[2] = 0.0f;
|
||||||
mPlayer.mHasMark = 0;
|
mPlayer.mHasMark = 0;
|
||||||
|
|
|
@ -264,7 +264,7 @@ namespace NavMeshTool
|
||||||
const osg::Vec2i cellPosition(cell.mData.mX, cell.mData.mY);
|
const osg::Vec2i cellPosition(cell.mData.mX, cell.mData.mY);
|
||||||
const std::size_t cellObjectsBegin = data.mObjects.size();
|
const std::size_t cellObjectsBegin = data.mObjects.size();
|
||||||
const auto cellNameLowerCase
|
const auto cellNameLowerCase
|
||||||
= Misc::StringUtils::lowerCase(cell.isExterior() ? ESM::CellId::sDefaultWorldspace : cell.mName);
|
= Misc::StringUtils::lowerCase(cell.isExterior() ? ESM::Cell::sDefaultWorldspace : cell.mName);
|
||||||
WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& {
|
WorldspaceNavMeshInput& navMeshInput = [&]() -> WorldspaceNavMeshInput& {
|
||||||
auto it = navMeshInputs.find(cellNameLowerCase);
|
auto it = navMeshInputs.find(cellNameLowerCase);
|
||||||
if (it == navMeshInputs.end())
|
if (it == navMeshInputs.end())
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <apps/opencs/model/world/record.hpp>
|
#include <apps/opencs/model/world/record.hpp>
|
||||||
#include <apps/opencs/model/world/universalid.hpp>
|
#include <apps/opencs/model/world/universalid.hpp>
|
||||||
|
|
||||||
#include <components/esm3/cellid.hpp>
|
#include <components/esm3/loadcell.hpp>
|
||||||
#include <components/misc/strings/lower.hpp>
|
#include <components/misc/strings/lower.hpp>
|
||||||
|
|
||||||
#include "collectionbase.hpp"
|
#include "collectionbase.hpp"
|
||||||
|
@ -337,7 +337,7 @@ std::pair<CSMWorld::UniversalId, std::string> CSMWorld::IdTable::view(int row) c
|
||||||
return std::make_pair(UniversalId::Type_None, "");
|
return std::make_pair(UniversalId::Type_None, "");
|
||||||
|
|
||||||
if (id[0] == '#')
|
if (id[0] == '#')
|
||||||
id = ESM::CellId::sDefaultWorldspace;
|
id = ESM::Cell::sDefaultWorldspace;
|
||||||
|
|
||||||
return std::make_pair(UniversalId(UniversalId::Type_Scene, id), hint);
|
return std::make_pair(UniversalId(UniversalId::Type_Scene, id), hint);
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,7 +307,7 @@ void CSVWorld::RegionMap::view()
|
||||||
}
|
}
|
||||||
|
|
||||||
emit editRequest(
|
emit editRequest(
|
||||||
CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Scene, ESM::CellId::sDefaultWorldspace), hint.str());
|
CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Scene, ESM::Cell::sDefaultWorldspace), hint.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSVWorld::RegionMap::viewInTable()
|
void CSVWorld::RegionMap::viewInTable()
|
||||||
|
|
|
@ -49,7 +49,7 @@ CSVWorld::SceneSubView::SceneSubView(const CSMWorld::UniversalId& id, CSMDoc::Do
|
||||||
CSVRender::WorldspaceWidget* worldspaceWidget = nullptr;
|
CSVRender::WorldspaceWidget* worldspaceWidget = nullptr;
|
||||||
widgetType whatWidget;
|
widgetType whatWidget;
|
||||||
|
|
||||||
if (Misc::StringUtils::ciEqual(id.getId(), ESM::CellId::sDefaultWorldspace))
|
if (Misc::StringUtils::ciEqual(id.getId(), ESM::Cell::sDefaultWorldspace))
|
||||||
{
|
{
|
||||||
whatWidget = widget_Paged;
|
whatWidget = widget_Paged;
|
||||||
|
|
||||||
|
@ -170,7 +170,7 @@ void CSVWorld::SceneSubView::cellSelectionChanged(const CSMWorld::UniversalId& i
|
||||||
|
|
||||||
void CSVWorld::SceneSubView::cellSelectionChanged(const CSMWorld::CellSelection& selection)
|
void CSVWorld::SceneSubView::cellSelectionChanged(const CSMWorld::CellSelection& selection)
|
||||||
{
|
{
|
||||||
setUniversalId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Scene, ESM::CellId::sDefaultWorldspace));
|
setUniversalId(CSMWorld::UniversalId(CSMWorld::UniversalId::Type_Scene, ESM::Cell::sDefaultWorldspace));
|
||||||
int size = selection.getSize();
|
int size = selection.getSize();
|
||||||
|
|
||||||
std::ostringstream stream;
|
std::ostringstream stream;
|
||||||
|
|
|
@ -351,12 +351,17 @@ namespace MWGui
|
||||||
{
|
{
|
||||||
for (int dY = -mCellDistance; dY <= mCellDistance; ++dY)
|
for (int dY = -mCellDistance; dY <= mCellDistance; ++dY)
|
||||||
{
|
{
|
||||||
ESM::CellId cellId;
|
ESM::RefId cellRefId;
|
||||||
cellId.mPaged = !mInterior;
|
|
||||||
cellId.mWorldspace = (mInterior ? mPrefix : ESM::CellId::sDefaultWorldspace);
|
if (mInterior)
|
||||||
cellId.mIndex.mX = mCurX + dX;
|
{
|
||||||
cellId.mIndex.mY = mCurY + dY;
|
cellRefId = ESM::RefId::stringRefId(mPrefix);
|
||||||
ESM::RefId cellRefId = cellId.getCellRefId();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cellRefId = ESM::Cell::generateIdForExteriorCell(mCurX + dX, mCurY + dY);
|
||||||
|
}
|
||||||
|
|
||||||
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(cellRefId);
|
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(cellRefId);
|
||||||
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second;
|
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second;
|
||||||
++it)
|
++it)
|
||||||
|
@ -885,18 +890,17 @@ namespace MWGui
|
||||||
|
|
||||||
mEditingMarker.mWorldX = worldPos.x();
|
mEditingMarker.mWorldX = worldPos.x();
|
||||||
mEditingMarker.mWorldY = worldPos.y();
|
mEditingMarker.mWorldY = worldPos.y();
|
||||||
ESM::CellId clickedId;
|
ESM::RefId clickedId;
|
||||||
|
|
||||||
clickedId.mPaged = !mInterior;
|
|
||||||
if (mInterior)
|
if (mInterior)
|
||||||
clickedId.mWorldspace = LocalMapBase::mPrefix;
|
{
|
||||||
|
clickedId = ESM::RefId::stringRefId(LocalMapBase::mPrefix);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
clickedId.mWorldspace = ESM::CellId::sDefaultWorldspace;
|
clickedId = ESM::Cell::generateIdForExteriorCell(x, y);
|
||||||
clickedId.mIndex.mX = x;
|
|
||||||
clickedId.mIndex.mY = y;
|
|
||||||
}
|
}
|
||||||
mEditingMarker.mCell = clickedId.getCellRefId();
|
mEditingMarker.mCell = clickedId;
|
||||||
|
|
||||||
mEditNoteDialog.setVisible(true);
|
mEditNoteDialog.setVisible(true);
|
||||||
mEditNoteDialog.showDeleteButton(false);
|
mEditNoteDialog.showDeleteButton(false);
|
||||||
|
@ -1122,12 +1126,7 @@ namespace MWGui
|
||||||
|
|
||||||
void MapWindow::setGlobalMapMarkerTooltip(MyGUI::Widget* markerWidget, int x, int y)
|
void MapWindow::setGlobalMapMarkerTooltip(MyGUI::Widget* markerWidget, int x, int y)
|
||||||
{
|
{
|
||||||
ESM::CellId cellId;
|
ESM::RefId cellRefId = ESM::Cell::generateIdForExteriorCell(x, y);
|
||||||
cellId.mIndex.mX = x;
|
|
||||||
cellId.mIndex.mY = y;
|
|
||||||
cellId.mWorldspace = ESM::CellId::sDefaultWorldspace;
|
|
||||||
cellId.mPaged = true;
|
|
||||||
ESM::RefId cellRefId = cellId.getCellRefId();
|
|
||||||
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(cellRefId);
|
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(cellRefId);
|
||||||
std::vector<std::string> destNotes;
|
std::vector<std::string> destNotes;
|
||||||
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second; ++it)
|
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second; ++it)
|
||||||
|
|
|
@ -195,15 +195,19 @@ namespace MWGui
|
||||||
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
|
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->fadeScreenOut(1);
|
MWBase::Environment::get().getWindowManager()->fadeScreenOut(1);
|
||||||
ESM::CellId cellId;
|
ESM::RefId cellId;
|
||||||
osg::Vec2i posCell = MWWorld::positionToCellIndex(pos.pos[0], pos.pos[1]);
|
osg::Vec2i posCell = MWWorld::positionToCellIndex(pos.pos[0], pos.pos[1]);
|
||||||
cellId.mPaged = !interior;
|
if (interior)
|
||||||
cellId.mWorldspace = Misc::StringUtils::lowerCase(cellname);
|
{
|
||||||
cellId.mIndex.mX = posCell.x();
|
cellId = ESM::RefId::stringRefId(cellname);
|
||||||
cellId.mIndex.mY = posCell.y();
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cellId = ESM::Cell::generateIdForExteriorCell(posCell.x(), posCell.y());
|
||||||
|
}
|
||||||
|
|
||||||
// Teleports any followers, too.
|
// Teleports any followers, too.
|
||||||
MWWorld::ActionTeleport action(cellId.getCellRefId(), pos, true);
|
MWWorld::ActionTeleport action(cellId, pos, true);
|
||||||
action.execute(player);
|
action.execute(player);
|
||||||
|
|
||||||
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0);
|
MWBase::Environment::get().getWindowManager()->fadeScreenOut(0);
|
||||||
|
|
|
@ -40,7 +40,7 @@ namespace MWWorld
|
||||||
, mNameID(cell.mName)
|
, mNameID(cell.mName)
|
||||||
, mRegion(cell.mRegion)
|
, mRegion(cell.mRegion)
|
||||||
, mId(cell.mId)
|
, mId(cell.mId)
|
||||||
, mParent(ESM::RefId::stringRefId(ESM::CellId::sDefaultWorldspace))
|
, mParent(ESM::RefId::stringRefId(ESM::Cell::sDefaultWorldspace))
|
||||||
, mMood{
|
, mMood{
|
||||||
.mAmbiantColor = cell.mAmbi.mAmbient,
|
.mAmbiantColor = cell.mAmbi.mAmbient,
|
||||||
.mDirectionalColor = cell.mAmbi.mSunlight,
|
.mDirectionalColor = cell.mAmbi.mSunlight,
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
|
||||||
#include <components/debug/debuglog.hpp>
|
#include <components/debug/debuglog.hpp>
|
||||||
#include <components/esm3/cellid.hpp>
|
#include <components/esm3/loadcell.hpp>
|
||||||
#include <components/esm3/objectstate.hpp>
|
#include <components/esm3/objectstate.hpp>
|
||||||
|
|
||||||
#include <apps/openmw/mwworld/cellutils.hpp>
|
#include <apps/openmw/mwworld/cellutils.hpp>
|
||||||
|
@ -90,11 +90,7 @@ namespace MWWorld
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const osg::Vec2i index = positionToCellIndex(ref.mDoorDest.pos[0], ref.mDoorDest.pos[1]);
|
const osg::Vec2i index = positionToCellIndex(ref.mDoorDest.pos[0], ref.mDoorDest.pos[1]);
|
||||||
ESM::CellId cellId;
|
return ESM::Cell::generateIdForExteriorCell(index.x(), index.y());
|
||||||
cellId.mPaged = true;
|
|
||||||
cellId.mIndex.mX = index.x();
|
|
||||||
cellId.mIndex.mY = index.y();
|
|
||||||
return cellId.getCellRefId();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -380,10 +380,8 @@ namespace MWWorld
|
||||||
pos.rot[2] = 0;
|
pos.rot[2] = 0;
|
||||||
|
|
||||||
osg::Vec2i exteriorCellPos = positionToCellIndex(pos.pos[0], pos.pos[1]);
|
osg::Vec2i exteriorCellPos = positionToCellIndex(pos.pos[0], pos.pos[1]);
|
||||||
ESM::CellId cellId;
|
ESM::RefId cellId = ESM::Cell::generateIdForExteriorCell(exteriorCellPos.x(), exteriorCellPos.y());
|
||||||
cellId.mPaged = true;
|
mWorldScene->changeToExteriorCell(cellId, pos, true);
|
||||||
cellId.mIndex = { exteriorCellPos.x(), exteriorCellPos.y() };
|
|
||||||
mWorldScene->changeToExteriorCell(cellId.getCellRefId(), pos, true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -979,7 +977,7 @@ namespace MWWorld
|
||||||
mPhysics->clearQueuedMovement();
|
mPhysics->clearQueuedMovement();
|
||||||
mDiscardMovements = true;
|
mDiscardMovements = true;
|
||||||
|
|
||||||
if (changeEvent && mCurrentWorldSpace != ESM::CellId::sDefaultWorldspace)
|
if (changeEvent && mCurrentWorldSpace != ESM::Cell::sDefaultWorldspace)
|
||||||
{
|
{
|
||||||
// changed worldspace
|
// changed worldspace
|
||||||
mProjectileManager->clear();
|
mProjectileManager->clear();
|
||||||
|
@ -987,10 +985,8 @@ namespace MWWorld
|
||||||
}
|
}
|
||||||
removeContainerScripts(getPlayerPtr());
|
removeContainerScripts(getPlayerPtr());
|
||||||
osg::Vec2i exteriorCellPos = positionToCellIndex(position.pos[0], position.pos[1]);
|
osg::Vec2i exteriorCellPos = positionToCellIndex(position.pos[0], position.pos[1]);
|
||||||
ESM::CellId cellId;
|
ESM::RefId cellId = ESM::Cell::generateIdForExteriorCell(exteriorCellPos.x(), exteriorCellPos.y());
|
||||||
cellId.mPaged = true;
|
mWorldScene->changeToExteriorCell(cellId, position, adjustPlayerPos, changeEvent);
|
||||||
cellId.mIndex = { exteriorCellPos.x(), exteriorCellPos.y() };
|
|
||||||
mWorldScene->changeToExteriorCell(cellId.getCellRefId(), position, adjustPlayerPos, changeEvent);
|
|
||||||
addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell());
|
addContainerScripts(getPlayerPtr(), getPlayerPtr().getCell());
|
||||||
mRendering->getCamera()->instantTransition();
|
mRendering->getCamera()->instantTransition();
|
||||||
}
|
}
|
||||||
|
|
|
@ -448,10 +448,7 @@ namespace
|
||||||
refId = RecordType::indexToRefId(index);
|
refId = RecordType::indexToRefId(index);
|
||||||
else if constexpr (std::is_same_v<RecordType, ESM::Cell>)
|
else if constexpr (std::is_same_v<RecordType, ESM::Cell>)
|
||||||
{
|
{
|
||||||
ESM::CellId cellId;
|
refId = ESM::Cell::generateIdForExteriorCell(0, 0);
|
||||||
cellId.mPaged = true;
|
|
||||||
cellId.mIndex = { 0, 0 };
|
|
||||||
refId = cellId.getCellRefId();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
refId = ESM::StringRefId(stringId);
|
refId = ESM::StringRefId(stringId);
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
|
|
||||||
const std::string CellId::sDefaultWorldspace = "sys::default";
|
|
||||||
|
|
||||||
void CellId::load(ESMReader& esm)
|
void CellId::load(ESMReader& esm)
|
||||||
{
|
{
|
||||||
mWorldspace = esm.getHNString("SPAC");
|
mWorldspace = esm.getHNString("SPAC");
|
||||||
|
@ -34,18 +32,6 @@ namespace ESM
|
||||||
esm.writeHNT("CIDX", mIndex, 8);
|
esm.writeHNT("CIDX", mIndex, 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
ESM::RefId CellId::getCellRefId() const
|
|
||||||
{
|
|
||||||
if (mPaged)
|
|
||||||
{
|
|
||||||
return ESM::RefId::stringRefId("#" + std::to_string(mIndex.mX) + "," + std::to_string(mIndex.mY));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return ESM::RefId::stringRefId(mWorldspace);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CellId CellId::extractFromRefId(const ESM::RefId& id)
|
CellId CellId::extractFromRefId(const ESM::RefId& id)
|
||||||
{
|
{
|
||||||
// This is bad and that code should not be merged.
|
// This is bad and that code should not be merged.
|
||||||
|
|
|
@ -21,11 +21,8 @@ namespace ESM
|
||||||
CellIndex mIndex;
|
CellIndex mIndex;
|
||||||
bool mPaged;
|
bool mPaged;
|
||||||
|
|
||||||
static const std::string sDefaultWorldspace;
|
|
||||||
|
|
||||||
void load(ESMReader& esm);
|
void load(ESMReader& esm);
|
||||||
void save(ESMWriter& esm) const;
|
void save(ESMWriter& esm) const;
|
||||||
ESM::RefId getCellRefId() const;
|
|
||||||
|
|
||||||
// TODO tetramir: this probably shouldn't exist, needs it because some CellIds are saved on disk
|
// TODO tetramir: this probably shouldn't exist, needs it because some CellIds are saved on disk
|
||||||
static CellId extractFromRefId(const ESM::RefId& id);
|
static CellId extractFromRefId(const ESM::RefId& id);
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include "savedgame.hpp"
|
#include "savedgame.hpp"
|
||||||
|
|
||||||
#include <components/esm3/cellid.hpp>
|
#include <components/esm3/cellid.hpp>
|
||||||
|
#include <components/esm3/loadcell.hpp>
|
||||||
#include <components/files/conversion.hpp>
|
#include <components/files/conversion.hpp>
|
||||||
#include <components/files/openfile.hpp>
|
#include <components/files/openfile.hpp>
|
||||||
#include <components/misc/strings/algorithm.hpp>
|
#include <components/misc/strings/algorithm.hpp>
|
||||||
|
@ -93,7 +94,14 @@ namespace ESM
|
||||||
{
|
{
|
||||||
ESM::CellId cellId;
|
ESM::CellId cellId;
|
||||||
cellId.load(*this);
|
cellId.load(*this);
|
||||||
return cellId.getCellRefId();
|
if (cellId.mPaged)
|
||||||
|
{
|
||||||
|
return ESM::Cell::generateIdForExteriorCell(cellId.mIndex.mX, cellId.mIndex.mY);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return ESM::RefId::stringRefId(cellId.mWorldspace);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return getHNRefId("NAME");
|
return getHNRefId("NAME");
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,8 @@ namespace ESM
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
|
const std::string Cell::sDefaultWorldspace = "sys::default";
|
||||||
|
|
||||||
// Some overloaded compare operators.
|
// Some overloaded compare operators.
|
||||||
bool operator==(const MovedCellRef& ref, const RefNum& refNum)
|
bool operator==(const MovedCellRef& ref, const RefNum& refNum)
|
||||||
{
|
{
|
||||||
|
@ -59,26 +61,23 @@ namespace ESM
|
||||||
|
|
||||||
const ESM::RefId& Cell::updateId()
|
const ESM::RefId& Cell::updateId()
|
||||||
{
|
{
|
||||||
CellId cellid;
|
|
||||||
|
|
||||||
cellid.mPaged = !(mData.mFlags & Interior);
|
if (mData.mFlags & Interior)
|
||||||
|
|
||||||
if (cellid.mPaged)
|
|
||||||
{
|
{
|
||||||
cellid.mWorldspace = CellId::sDefaultWorldspace;
|
mId = ESM::RefId::stringRefId(mName);
|
||||||
cellid.mIndex.mX = mData.mX;
|
|
||||||
cellid.mIndex.mY = mData.mY;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cellid.mWorldspace = Misc::StringUtils::lowerCase(mName);
|
mId = generateIdForExteriorCell(getGridX(), getGridY());
|
||||||
cellid.mIndex.mX = 0;
|
|
||||||
cellid.mIndex.mY = 0;
|
|
||||||
}
|
}
|
||||||
mId = cellid.getCellRefId();
|
|
||||||
return mId;
|
return mId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ESM::RefId Cell::generateIdForExteriorCell(int x, int y)
|
||||||
|
{
|
||||||
|
return ESM::RefId::stringRefId("#" + std::to_string(x) + "," + std::to_string(y));
|
||||||
|
}
|
||||||
|
|
||||||
void Cell::loadNameAndData(ESMReader& esm, bool& isDeleted)
|
void Cell::loadNameAndData(ESMReader& esm, bool& isDeleted)
|
||||||
{
|
{
|
||||||
isDeleted = false;
|
isDeleted = false;
|
||||||
|
|
|
@ -67,6 +67,8 @@ namespace ESM
|
||||||
*/
|
*/
|
||||||
struct Cell
|
struct Cell
|
||||||
{
|
{
|
||||||
|
static const std::string sDefaultWorldspace;
|
||||||
|
|
||||||
constexpr static RecNameInts sRecordId = REC_CELL;
|
constexpr static RecNameInts sRecordId = REC_CELL;
|
||||||
|
|
||||||
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
||||||
|
@ -191,6 +193,8 @@ namespace ESM
|
||||||
///< Set record to default state (does not touch the ID/index).
|
///< Set record to default state (does not touch the ID/index).
|
||||||
|
|
||||||
const ESM::RefId& updateId();
|
const ESM::RefId& updateId();
|
||||||
|
|
||||||
|
static ESM::RefId generateIdForExteriorCell(int x, int y);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue