forked from teamnwah/openmw-tes3coop
always use the cell ID instead of the exterior coordinate fields from the original cell struct
This commit is contained in:
parent
decd4270d9
commit
19b31c4146
3 changed files with 21 additions and 8 deletions
|
@ -9,6 +9,9 @@
|
||||||
namespace CSMWorld
|
namespace CSMWorld
|
||||||
{
|
{
|
||||||
/// \brief Wrapper for Cell record
|
/// \brief Wrapper for Cell record
|
||||||
|
///
|
||||||
|
/// \attention The mData.mX and mData.mY fields of the ESM::Cell struct are not used.
|
||||||
|
/// Exterior cell coordinates are encoded in the cell ID.
|
||||||
struct Cell : public ESM::Cell
|
struct Cell : public ESM::Cell
|
||||||
{
|
{
|
||||||
std::string mId;
|
std::string mId;
|
||||||
|
|
|
@ -38,6 +38,18 @@ QModelIndex CSMWorld::RegionMap::getIndex (const CellCoordinates& index) const
|
||||||
index.getX()-mMin.getX());
|
index.getX()-mMin.getX());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CSMWorld::CellCoordinates CSMWorld::RegionMap::getIndex (const Cell& cell) const
|
||||||
|
{
|
||||||
|
std::istringstream stream (cell.mId);
|
||||||
|
|
||||||
|
char ignore;
|
||||||
|
int x = 0;
|
||||||
|
int y = 0;
|
||||||
|
stream >> ignore >> x >> y;
|
||||||
|
|
||||||
|
return CellCoordinates (x, y);
|
||||||
|
}
|
||||||
|
|
||||||
void CSMWorld::RegionMap::buildRegions()
|
void CSMWorld::RegionMap::buildRegions()
|
||||||
{
|
{
|
||||||
const IdCollection<ESM::Region>& regions = mData.getRegions();
|
const IdCollection<ESM::Region>& regions = mData.getRegions();
|
||||||
|
@ -70,7 +82,7 @@ void CSMWorld::RegionMap::buildMap()
|
||||||
{
|
{
|
||||||
CellDescription description (cell);
|
CellDescription description (cell);
|
||||||
|
|
||||||
CellCoordinates index (cell2.mData.mX, cell2.mData.mY);
|
CellCoordinates index = getIndex (cell2);
|
||||||
|
|
||||||
mMap.insert (std::make_pair (index, description));
|
mMap.insert (std::make_pair (index, description));
|
||||||
}
|
}
|
||||||
|
@ -114,7 +126,7 @@ void CSMWorld::RegionMap::addCells (int start, int end)
|
||||||
|
|
||||||
if (cell2.isExterior())
|
if (cell2.isExterior())
|
||||||
{
|
{
|
||||||
CellCoordinates index (cell2.mData.mX, cell2.mData.mY);
|
CellCoordinates index = getIndex (cell2);
|
||||||
|
|
||||||
CellDescription description (cell);
|
CellDescription description (cell);
|
||||||
|
|
||||||
|
@ -236,7 +248,7 @@ std::pair<CSMWorld::CellCoordinates, CSMWorld::CellCoordinates> CSMWorld::Region
|
||||||
|
|
||||||
if (cell2.isExterior())
|
if (cell2.isExterior())
|
||||||
{
|
{
|
||||||
CellCoordinates index (cell2.mData.mX, cell2.mData.mY);
|
CellCoordinates index = getIndex (cell2);
|
||||||
|
|
||||||
if (min==max)
|
if (min==max)
|
||||||
{
|
{
|
||||||
|
@ -476,11 +488,7 @@ void CSMWorld::RegionMap::cellsAboutToBeRemoved (const QModelIndex& parent, int
|
||||||
const Cell& cell2 = cell.get();
|
const Cell& cell2 = cell.get();
|
||||||
|
|
||||||
if (cell2.isExterior())
|
if (cell2.isExterior())
|
||||||
{
|
removeCell (getIndex (cell2));
|
||||||
CellCoordinates index (cell2.mData.mX, cell2.mData.mY);
|
|
||||||
|
|
||||||
removeCell (index);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -54,6 +54,8 @@ namespace CSMWorld
|
||||||
|
|
||||||
QModelIndex getIndex (const CellCoordinates& index) const;
|
QModelIndex getIndex (const CellCoordinates& index) const;
|
||||||
|
|
||||||
|
CellCoordinates getIndex (const Cell& cell) const;
|
||||||
|
|
||||||
void buildRegions();
|
void buildRegions();
|
||||||
|
|
||||||
void buildMap();
|
void buildMap();
|
||||||
|
|
Loading…
Reference in a new issue