diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 9adc43d315..3714ecef64 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -275,7 +275,7 @@ namespace MWGui if (!mInterior) { - ESM::ExteriorCellLocation cellPos = ESM::positionToCellIndex(worldX, worldY); + ESM::ExteriorCellLocation cellPos = ESM::positionToExteriorCellLocation(worldX, worldY); cellIndex.x() = cellPos.mX; cellIndex.y() = cellPos.mY; diff --git a/apps/openmw/mwgui/travelwindow.cpp b/apps/openmw/mwgui/travelwindow.cpp index c83caa0dc5..2c3310b891 100644 --- a/apps/openmw/mwgui/travelwindow.cpp +++ b/apps/openmw/mwgui/travelwindow.cpp @@ -126,7 +126,7 @@ namespace MWGui std::string_view cellname = transport[i].mCellName; bool interior = true; const ESM::ExteriorCellLocation cellIndex - = ESM::positionToCellIndex(transport[i].mPos.pos[0], transport[i].mPos.pos[1]); + = ESM::positionToExteriorCellLocation(transport[i].mPos.pos[0], transport[i].mPos.pos[1]); if (cellname.empty()) { MWWorld::CellStore& cell = MWBase::Environment::get().getWorldModel()->getExterior(cellIndex); @@ -192,7 +192,7 @@ namespace MWGui MWBase::Environment::get().getWindowManager()->exitCurrentGuiMode(); MWBase::Environment::get().getWindowManager()->fadeScreenOut(1); - const ESM::ExteriorCellLocation posCell = ESM::positionToCellIndex(pos.pos[0], pos.pos[1]); + const ESM::ExteriorCellLocation posCell = ESM::positionToExteriorCellLocation(pos.pos[0], pos.pos[1]); ESM::RefId cellId = ESM::Cell::generateIdForCell(!interior, cellname, posCell.mX, posCell.mY); // Teleports any followers, too. diff --git a/apps/openmw/mwscript/transformationextensions.cpp b/apps/openmw/mwscript/transformationextensions.cpp index bf9fe14298..879cf85144 100644 --- a/apps/openmw/mwscript/transformationextensions.cpp +++ b/apps/openmw/mwscript/transformationextensions.cpp @@ -402,7 +402,7 @@ namespace MWScript if (store->isExterior()) { const ESM::ExteriorCellLocation cellIndex - = ESM::positionToCellIndex(x, y, store->getCell()->getWorldSpace()); + = ESM::positionToExteriorCellLocation(x, y, store->getCell()->getWorldSpace()); store = &worldModel->getExterior(cellIndex); } } @@ -418,7 +418,7 @@ namespace MWScript if (!isPlayer) return; const ESM::ExteriorCellLocation cellIndex - = ESM::positionToCellIndex(x, y, store->getCell()->getWorldSpace()); + = ESM::positionToExteriorCellLocation(x, y, store->getCell()->getWorldSpace()); store = &worldModel->getExterior(cellIndex); } if (store) @@ -469,7 +469,7 @@ namespace MWScript if (isPlayer) world->getPlayer().setTeleported(true); const ESM::ExteriorCellLocation cellIndex - = ESM::positionToCellIndex(x, y, ESM::Cell::sDefaultWorldspaceId); + = ESM::positionToExteriorCellLocation(x, y, ESM::Cell::sDefaultWorldspaceId); // another morrowind oddity: player will be moved to the exterior cell at this location, // non-player actors will move within the cell they are in. @@ -570,7 +570,7 @@ namespace MWScript if (player.getCell()->isExterior()) { const ESM::ExteriorCellLocation cellIndex - = ESM::positionToCellIndex(x, y, player.getCell()->getCell()->getWorldSpace()); + = ESM::positionToExteriorCellLocation(x, y, player.getCell()->getCell()->getWorldSpace()); store = &MWBase::Environment::get().getWorldModel()->getExterior(cellIndex); } else diff --git a/apps/openmw/mwworld/cellref.cpp b/apps/openmw/mwworld/cellref.cpp index 3e81ba1c37..6b9494b24f 100644 --- a/apps/openmw/mwworld/cellref.cpp +++ b/apps/openmw/mwworld/cellref.cpp @@ -88,7 +88,7 @@ namespace MWWorld } else { - const auto cellPos = ESM::positionToCellIndex(ref.mDoorDest.pos[0], ref.mDoorDest.pos[1]); + const auto cellPos = ESM::positionToExteriorCellLocation(ref.mDoorDest.pos[0], ref.mDoorDest.pos[1]); return ESM::RefId::esm3ExteriorCell(cellPos.mX, cellPos.mY); } }; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index b116fbe633..5112fad252 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -521,7 +521,7 @@ namespace MWWorld if (distance <= maxDistance) return *currentGridCenter; } - ESM::ExteriorCellLocation cellPos = ESM::positionToCellIndex(pos.x(), pos.y(), worldspace); + ESM::ExteriorCellLocation cellPos = ESM::positionToExteriorCellLocation(pos.x(), pos.y(), worldspace); return { cellPos.mX, cellPos.mY }; } @@ -1283,7 +1283,8 @@ namespace MWWorld else { osg::Vec3f pos = dest.mPos.asVec3(); - const ESM::ExteriorCellLocation cellIndex = ESM::positionToCellIndex(pos.x(), pos.y(), extWorldspace); + const ESM::ExteriorCellLocation cellIndex + = ESM::positionToExteriorCellLocation(pos.x(), pos.y(), extWorldspace); preloadCell(mWorld.getWorldModel().getExterior(cellIndex), true); exteriorPositions.emplace_back(pos, gridCenterToBounds(getNewGridCenter(pos))); } diff --git a/apps/openmw/mwworld/store.cpp b/apps/openmw/mwworld/store.cpp index ec984e030d..e2bd7cafb2 100644 --- a/apps/openmw/mwworld/store.cpp +++ b/apps/openmw/mwworld/store.cpp @@ -1166,8 +1166,8 @@ namespace MWWorld const ESM4::Cell* cell = cells.find(ref.mParent); if (cell->isExterior() && (cell->mFlags & ESM4::Rec_Persistent)) { - const ESM4::Cell* actualCell - = cells.searchExterior(positionToCellIndex(ref.mPos.pos[0], ref.mPos.pos[1], cell->mParent)); + const ESM4::Cell* actualCell = cells.searchExterior( + positionToExteriorCellLocation(ref.mPos.pos[0], ref.mPos.pos[1], cell->mParent)); if (actualCell) ref.mParent = actualCell->mId; } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 0db747898f..349215460c 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -380,7 +380,7 @@ namespace MWWorld pos.rot[1] = 0; pos.rot[2] = 0; - ESM::ExteriorCellLocation exteriorCellPos = ESM::positionToCellIndex(pos.pos[0], pos.pos[1]); + ESM::ExteriorCellLocation exteriorCellPos = ESM::positionToExteriorCellLocation(pos.pos[0], pos.pos[1]); ESM::RefId cellId = ESM::RefId::esm3ExteriorCell(exteriorCellPos.mX, exteriorCellPos.mY); mWorldScene->changeToExteriorCell(cellId, pos, true); } @@ -1248,7 +1248,8 @@ namespace MWWorld CellStore* cell = ptr.getCell(); ESM::RefId worldspaceId = cell->isExterior() ? cell->getCell()->getWorldSpace() : ESM::Cell::sDefaultWorldspaceId; - const ESM::ExteriorCellLocation index = ESM::positionToCellIndex(position.x(), position.y(), worldspaceId); + const ESM::ExteriorCellLocation index + = ESM::positionToExteriorCellLocation(position.x(), position.y(), worldspaceId); CellStore* newCell = cell->isExterior() ? &mWorldModel.getExterior(index) : nullptr; bool isCellActive = getPlayerPtr().isInCell() && getPlayerPtr().getCell()->isExterior() @@ -2047,7 +2048,7 @@ namespace MWWorld if (cell->isExterior()) { const ESM::ExteriorCellLocation index - = ESM::positionToCellIndex(pos.pos[0], pos.pos[1], cell->getCell()->getWorldSpace()); + = ESM::positionToExteriorCellLocation(pos.pos[0], pos.pos[1], cell->getCell()->getWorldSpace()); cell = &mWorldModel.getExterior(index); } diff --git a/apps/openmw/mwworld/worldmodel.cpp b/apps/openmw/mwworld/worldmodel.cpp index 19110fb31a..3423cf06d1 100644 --- a/apps/openmw/mwworld/worldmodel.cpp +++ b/apps/openmw/mwworld/worldmodel.cpp @@ -326,7 +326,8 @@ MWWorld::CellStore& MWWorld::WorldModel::getCellByPosition( return *cellInSameWorldSpace; ESM::RefId exteriorWorldspace = cellInSameWorldSpace ? cellInSameWorldSpace->getCell()->getWorldSpace() : ESM::Cell::sDefaultWorldspaceId; - const ESM::ExteriorCellLocation cellIndex = ESM::positionToCellIndex(pos.x(), pos.y(), exteriorWorldspace); + const ESM::ExteriorCellLocation cellIndex + = ESM::positionToExteriorCellLocation(pos.x(), pos.y(), exteriorWorldspace); return getExterior(cellIndex); } diff --git a/components/esm/util.hpp b/components/esm/util.hpp index 6edf087854..ac687fea4b 100644 --- a/components/esm/util.hpp +++ b/components/esm/util.hpp @@ -83,7 +83,7 @@ namespace ESM return isEsm4Ext(worldspaceId) ? Constants::ESM4CellSizeInUnits : Constants::CellSizeInUnits; } - inline ESM::ExteriorCellLocation positionToCellIndex( + inline ESM::ExteriorCellLocation positionToExteriorCellLocation( float x, float y, ESM::RefId worldspaceId = ESM::Cell::sDefaultWorldspaceId) { const float cellSize = getCellSize(worldspaceId);