mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-27 03:35:27 +00:00
Removes most cellId.hpp include, simplifies id generation for cells.
This commit is contained in:
parent
c2182c2fcc
commit
f99e65843a
@ -61,17 +61,9 @@ namespace ESSImport
|
||||
|
||||
const PCDT::PNAM::MarkLocation& mark = pcdt.mPNAM.mMarkLocation;
|
||||
|
||||
ESM::RefId cell;
|
||||
|
||||
// TODO: Figure out a better way to detect interiors. (0, 0) is a valid exterior cell.
|
||||
if (mark.mCellX == 0 && mark.mCellY == 0)
|
||||
{
|
||||
cell = ESM::RefId::stringRefId(pcdt.mMNAM);
|
||||
}
|
||||
else
|
||||
{
|
||||
cell = ESM::Cell::generateIdForExteriorCell(mark.mCellX, mark.mCellY);
|
||||
}
|
||||
bool interior = mark.mCellX == 0 && mark.mCellY == 0;
|
||||
ESM::RefId cell = ESM::Cell::generateIdForCell(!interior, pcdt.mMNAM, mark.mCellX, mark.mCellY);
|
||||
|
||||
out.mMarkedCell = cell;
|
||||
out.mMarkedPosition.pos[0] = mark.mX;
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include <components/esm3/player.hpp>
|
||||
#include <components/esm3/savedgame.hpp>
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/esm3/loadalch.hpp>
|
||||
#include <components/esm3/loadarmo.hpp>
|
||||
#include <components/esm3/loadclot.hpp>
|
||||
@ -410,22 +411,10 @@ namespace ESSImport
|
||||
|
||||
writer.startRecord(ESM::REC_PLAY);
|
||||
ESM::CellId cellId = ESM::CellId::extractFromRefId(context.mPlayer.mCellId);
|
||||
if (cellId.mPaged)
|
||||
{
|
||||
// exterior cell -> determine cell coordinates based on position
|
||||
int cellX
|
||||
= static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[0] / Constants::CellSizeInUnits));
|
||||
int cellY
|
||||
= static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[1] / Constants::CellSizeInUnits));
|
||||
cellId.mIndex.mX = cellX;
|
||||
cellId.mIndex.mY = cellY;
|
||||
int cellX = static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[0] / Constants::CellSizeInUnits));
|
||||
int cellY = static_cast<int>(std::floor(context.mPlayer.mObject.mPosition.pos[1] / Constants::CellSizeInUnits));
|
||||
|
||||
context.mPlayer.mCellId = ESM::Cell::generateIdForExteriorCell(cellX, cellY);
|
||||
}
|
||||
else
|
||||
{
|
||||
context.mPlayer.mCellId = ESM::RefId::stringRefId(cellId.mWorldspace);
|
||||
}
|
||||
context.mPlayer.mCellId = ESM::Cell::generateIdForCell(cellId.mPaged, cellId.mWorldspace, cellX, cellY);
|
||||
context.mPlayer.save(writer);
|
||||
writer.endRecord(ESM::REC_PLAY);
|
||||
|
||||
|
@ -16,8 +16,6 @@
|
||||
|
||||
#include <apps/opencs/view/world/dragrecordtable.hpp>
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
#include "../../model/world/columns.hpp"
|
||||
|
@ -14,8 +14,6 @@
|
||||
#include <apps/opencs/view/doc/subview.hpp>
|
||||
#include <apps/opencs/view/render/worldspacewidget.hpp>
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
|
||||
#include "../../model/doc/document.hpp"
|
||||
|
||||
#include "../../model/world/cellselection.hpp"
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/misc/rng.hpp>
|
||||
|
||||
#include <osg/Timer>
|
||||
|
@ -351,16 +351,7 @@ namespace MWGui
|
||||
{
|
||||
for (int dY = -mCellDistance; dY <= mCellDistance; ++dY)
|
||||
{
|
||||
ESM::RefId cellRefId;
|
||||
|
||||
if (mInterior)
|
||||
{
|
||||
cellRefId = ESM::RefId::stringRefId(mPrefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
cellRefId = ESM::Cell::generateIdForExteriorCell(mCurX + dX, mCurY + dY);
|
||||
}
|
||||
ESM::RefId cellRefId = ESM::Cell::generateIdForCell(!mInterior, mPrefix, mCurX + dX, mCurY + dY);
|
||||
|
||||
CustomMarkerCollection::RangeType markers = mCustomMarkers.getMarkers(cellRefId);
|
||||
for (CustomMarkerCollection::ContainerType::const_iterator it = markers.first; it != markers.second;
|
||||
@ -890,16 +881,8 @@ namespace MWGui
|
||||
|
||||
mEditingMarker.mWorldX = worldPos.x();
|
||||
mEditingMarker.mWorldY = worldPos.y();
|
||||
ESM::RefId clickedId;
|
||||
ESM::RefId clickedId = ESM::Cell::generateIdForCell(!mInterior, LocalMapBase::mPrefix, x, y);
|
||||
|
||||
if (mInterior)
|
||||
{
|
||||
clickedId = ESM::RefId::stringRefId(LocalMapBase::mPrefix);
|
||||
}
|
||||
else
|
||||
{
|
||||
clickedId = ESM::Cell::generateIdForExteriorCell(x, y);
|
||||
}
|
||||
mEditingMarker.mCell = clickedId;
|
||||
|
||||
mEditNoteDialog.setVisible(true);
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
#include "windowpinnablebase.hpp"
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
|
||||
#include <components/esm3/custommarkerstate.hpp>
|
||||
#include <components/misc/constants.hpp>
|
||||
|
||||
|
@ -195,16 +195,8 @@ namespace MWGui
|
||||
MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode();
|
||||
|
||||
MWBase::Environment::get().getWindowManager()->fadeScreenOut(1);
|
||||
ESM::RefId cellId;
|
||||
osg::Vec2i posCell = MWWorld::positionToCellIndex(pos.pos[0], pos.pos[1]);
|
||||
if (interior)
|
||||
{
|
||||
cellId = ESM::RefId::stringRefId(cellname);
|
||||
}
|
||||
else
|
||||
{
|
||||
cellId = ESM::Cell::generateIdForExteriorCell(posCell.x(), posCell.y());
|
||||
}
|
||||
ESM::RefId cellId = ESM::Cell::generateIdForCell(!interior, cellname, posCell.x(), posCell.y());
|
||||
|
||||
// Teleports any followers, too.
|
||||
MWWorld::ActionTeleport action(cellId, pos, true);
|
||||
|
@ -4,7 +4,6 @@
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/esm3/esmwriter.hpp>
|
||||
#include <components/esm3/loadcell.hpp>
|
||||
|
@ -1,6 +1,5 @@
|
||||
#include "cell.hpp"
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/esm3/loadcell.hpp>
|
||||
#include <components/esm4/loadcell.hpp>
|
||||
#include <components/misc/algorithm.hpp>
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
||||
#include <components/esm/format.hpp>
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/esm3/cellref.hpp>
|
||||
#include <components/esm3/cellstate.hpp>
|
||||
#include <components/esm3/containerstate.hpp>
|
||||
|
@ -392,12 +392,8 @@ namespace MWWorld
|
||||
mLastKnownExteriorPosition.y() = player.mLastKnownExteriorPosition[1];
|
||||
mLastKnownExteriorPosition.z() = player.mLastKnownExteriorPosition[2];
|
||||
|
||||
bool exterior = ESM::CellId::extractFromRefId(player.mMarkedCell).mPaged;
|
||||
if (player.mHasMark && !exterior)
|
||||
if (player.mHasMark)
|
||||
{
|
||||
// interior cell -> need to check if it exists (exterior cell will be
|
||||
// generated on the fly)
|
||||
|
||||
if (!world.getStore().get<ESM::Cell>().search(player.mMarkedCell))
|
||||
player.mHasMark = false; // drop mark silently
|
||||
}
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/esm3/cellref.hpp>
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
#include <components/esm3/esmwriter.hpp>
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/esm3/cellref.hpp>
|
||||
#include <components/esm3/cellstate.hpp>
|
||||
#include <components/esm3/esmreader.hpp>
|
||||
|
@ -1,9 +1,8 @@
|
||||
#ifndef OPENMW_ESM_CELLSTATE_H
|
||||
#define OPENMW_ESM_CELLSTATE_H
|
||||
|
||||
#include "cellid.hpp"
|
||||
|
||||
#include "components/esm/defs.hpp"
|
||||
#include "components/esm/refid.hpp"
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
|
@ -1,10 +1,12 @@
|
||||
#ifndef OPENMW_ESM_CUSTOMMARKERSTATE_H
|
||||
#define OPENMW_ESM_CUSTOMMARKERSTATE_H
|
||||
|
||||
#include "cellid.hpp"
|
||||
#include <components/esm/refid.hpp>
|
||||
|
||||
namespace ESM
|
||||
{
|
||||
class ESMReader;
|
||||
class ESMWriter;
|
||||
|
||||
// format 0, saved games only
|
||||
struct CustomMarker
|
||||
|
@ -4,7 +4,6 @@
|
||||
#include <fstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/misc/notnullptr.hpp>
|
||||
#include <components/to_utf8/to_utf8.hpp>
|
||||
|
@ -7,7 +7,6 @@
|
||||
#include <components/debug/debuglog.hpp>
|
||||
#include <components/misc/strings/algorithm.hpp>
|
||||
|
||||
#include "cellid.hpp"
|
||||
#include "esmreader.hpp"
|
||||
#include "esmwriter.hpp"
|
||||
|
||||
@ -61,15 +60,7 @@ namespace ESM
|
||||
|
||||
const ESM::RefId& Cell::updateId()
|
||||
{
|
||||
|
||||
if (mData.mFlags & Interior)
|
||||
{
|
||||
mId = ESM::RefId::stringRefId(mName);
|
||||
}
|
||||
else
|
||||
{
|
||||
mId = generateIdForExteriorCell(getGridX(), getGridY());
|
||||
}
|
||||
mId = generateIdForCell(isExterior(), mName, getGridX(), getGridY());
|
||||
return mId;
|
||||
}
|
||||
|
||||
@ -78,6 +69,18 @@ namespace ESM
|
||||
return ESM::RefId::stringRefId("#" + std::to_string(x) + "," + std::to_string(y));
|
||||
}
|
||||
|
||||
ESM::RefId Cell::generateIdForCell(bool exterior, std::string_view cellName, int x, int y)
|
||||
{
|
||||
if (!exterior)
|
||||
{
|
||||
return ESM::RefId::stringRefId(cellName);
|
||||
}
|
||||
else
|
||||
{
|
||||
return generateIdForExteriorCell(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void Cell::loadNameAndData(ESMReader& esm, bool& isDeleted)
|
||||
{
|
||||
isDeleted = false;
|
||||
|
@ -5,7 +5,6 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "cellid.hpp"
|
||||
#include "cellref.hpp"
|
||||
#include "components/esm/defs.hpp"
|
||||
#include "components/esm/esmcommon.hpp"
|
||||
@ -195,6 +194,7 @@ namespace ESM
|
||||
const ESM::RefId& updateId();
|
||||
|
||||
static ESM::RefId generateIdForExteriorCell(int x, int y);
|
||||
static ESM::RefId generateIdForCell(bool exterior, std::string_view cellName, int x, int y);
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
@ -3,7 +3,6 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "cellid.hpp"
|
||||
#include "components/esm/defs.hpp"
|
||||
#include "npcstate.hpp"
|
||||
|
||||
|
@ -36,7 +36,6 @@
|
||||
|
||||
#include <components/esm/defs.hpp>
|
||||
#include <components/esm/refid.hpp>
|
||||
#include <components/esm3/cellid.hpp>
|
||||
#include <components/esm4/reader.hpp>
|
||||
|
||||
namespace ESM4
|
||||
|
Loading…
x
Reference in New Issue
Block a user