From 653ddd3f2520cefa189901f195aca181bd9a0a53 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 2 Mar 2015 20:16:11 +0100 Subject: [PATCH 1/7] Warning fix --- apps/openmw/mwgui/inventorywindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/openmw/mwgui/inventorywindow.cpp b/apps/openmw/mwgui/inventorywindow.cpp index e8e88ef65..b0adddffa 100644 --- a/apps/openmw/mwgui/inventorywindow.cpp +++ b/apps/openmw/mwgui/inventorywindow.cpp @@ -653,7 +653,7 @@ namespace MWGui if (selected != -1) lastId = model.getItem(selected).mBase.getCellRef().getRefId(); ItemModel::ModelIndex cycled = selected; - for (int i=0; i Date: Mon, 2 Mar 2015 21:12:21 +0100 Subject: [PATCH 2/7] Remove "loading cell" message This spams the log too much, in particular when loading a savegame. --- apps/openmw/mwworld/cellstore.cpp | 2 -- apps/openmw/mwworld/scene.cpp | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwworld/cellstore.cpp b/apps/openmw/mwworld/cellstore.cpp index 545bbd4b3..7da7c187d 100644 --- a/apps/openmw/mwworld/cellstore.cpp +++ b/apps/openmw/mwworld/cellstore.cpp @@ -407,8 +407,6 @@ namespace MWWorld if (mState==State_Preloaded) mIds.clear(); - std::cout << "loading cell " << mCell->getDescription() << std::endl; - loadRefs (store, esm); mState = State_Loaded; diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 08767df80..96e5ef224 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -219,6 +219,8 @@ namespace MWWorld if(result.second) { + std::cout << "loading cell " << cell->getCell()->getDescription() << std::endl; + float verts = ESM::Land::LAND_SIZE; float worldsize = ESM::Land::REAL_SIZE; From 8eb1f4e70e5e7a431c807d2412ca32bfafa20cb8 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 2 Mar 2015 22:13:50 +0100 Subject: [PATCH 3/7] Remove more log spam --- apps/openmw/mwworld/scene.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/openmw/mwworld/scene.cpp b/apps/openmw/mwworld/scene.cpp index 96e5ef224..8d689240b 100644 --- a/apps/openmw/mwworld/scene.cpp +++ b/apps/openmw/mwworld/scene.cpp @@ -492,8 +492,6 @@ namespace MWWorld loadingListener->setProgressRange(refsToLoad); // Load cell. - std::cout << "cellName: " << cell->getCell()->mName << std::endl; - loadCell (cell, loadingListener); changePlayerCell(cell, position, true); From f6509fe53eeffd1fc3834616b68989b09300087c Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 2 Mar 2015 22:23:00 +0100 Subject: [PATCH 4/7] Another crash fix for land record without data --- apps/opencs/view/render/cell.cpp | 2 +- components/esmterrain/storage.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/opencs/view/render/cell.cpp b/apps/opencs/view/render/cell.cpp index a0d0f6e71..ae2fad95a 100644 --- a/apps/opencs/view/render/cell.cpp +++ b/apps/opencs/view/render/cell.cpp @@ -78,7 +78,7 @@ CSVRender::Cell::Cell (CSMWorld::Data& data, Ogre::SceneManager *sceneManager, if (landIndex != -1) { const ESM::Land* esmLand = land.getRecord(mId).get().mLand.get(); - if(esmLand) + if(esmLand && esmLand->mDataTypes&ESM::Land::DATA_VHGT) { mTerrain.reset(new Terrain::TerrainGrid(sceneManager, new TerrainStorage(mData), Element_Terrain, true, Terrain::Align_XY)); diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index d4a0a0df2..e925a1e17 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -383,7 +383,7 @@ namespace ESMTerrain int cellY = std::floor(worldPos.y / 8192.f); ESM::Land* land = getLand(cellX, cellY); - if (!land) + if (!land || !(land->mDataTypes&ESM::Land::DATA_VHGT)) return -2048; // Mostly lifted from Ogre::Terrain::getHeightAtTerrainPosition From 17e3069896f9d5453281650b4f6bb6ed81c7fc9d Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 2 Mar 2015 22:33:37 +0100 Subject: [PATCH 5/7] Minor efficiency fix --- components/esmterrain/storage.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/esmterrain/storage.cpp b/components/esmterrain/storage.cpp index e925a1e17..9c7beebce 100644 --- a/components/esmterrain/storage.cpp +++ b/components/esmterrain/storage.cpp @@ -465,8 +465,9 @@ namespace ESMTerrain Terrain::LayerInfo Storage::getLayerInfo(const std::string& texture) { // Already have this cached? - if (mLayerInfoMap.find(texture) != mLayerInfoMap.end()) - return mLayerInfoMap[texture]; + std::map::iterator found = mLayerInfoMap.find(texture); + if (found != mLayerInfoMap.end()) + return found->second; Terrain::LayerInfo info; info.mParallax = false; From 666248618eb2e4ca2003f51a5dbc1891baa98998 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 2 Mar 2015 23:20:59 +0100 Subject: [PATCH 6/7] Fix reference cell movement leaving behind deleted Ptrs for script access --- apps/openmw/mwworld/worldimp.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index 8a2b67bfc..3ef4f8e81 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -1206,6 +1206,10 @@ namespace MWWorld } } ptr.getRefData().setCount(0); + // Deleted references can still be accessed by scripts, + // so we need this extra step to remove access to the old reference completely. + // This will no longer be necessary once we have a proper cell movement tracker. + ptr.getCellRef().unsetRefNum(); } } if (haveToMove && ptr.getRefData().getBaseNode()) From f09cbfb1678f7df933d858889dfa0da0b884afc1 Mon Sep 17 00:00:00 2001 From: scrawl Date: Mon, 2 Mar 2015 23:29:33 +0100 Subject: [PATCH 7/7] Add a comment --- apps/openmw/mwworld/store.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/openmw/mwworld/store.hpp b/apps/openmw/mwworld/store.hpp index a155a3760..50dd37ac0 100644 --- a/apps/openmw/mwworld/store.hpp +++ b/apps/openmw/mwworld/store.hpp @@ -555,6 +555,9 @@ namespace MWWorld if (left.first == right.first) return left.second > right.second; + // Exterior cells are listed in descending, row-major order, + // this is a workaround for an ambiguous chargen_plank reference in the vanilla game. + // there is one at -22,16 and one at -2,-9, the latter should be used. return left.first > right.first; } };