From 39c84c84da6f8d0343f3f3c2ab200b04435f2fc6 Mon Sep 17 00:00:00 2001 From: Alexei Dobrohotov Date: Thu, 13 Jul 2023 14:06:49 +0300 Subject: [PATCH] Cap global map cell size (bug #6222) --- CHANGELOG.md | 1 + apps/openmw/mwgui/mapwindow.cpp | 4 ++-- apps/openmw/mwrender/globalmap.cpp | 7 +++---- components/settings/categories/map.hpp | 2 +- docs/source/reference/modding/settings/map.rst | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a0dac4c34..1dfa0d9d3e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ Bug #5883: Immobile creatures don't cause water ripples Bug #5977: Fatigueless NPCs' corpse underwater changes animation on game load Bug #6027: Collisionshape becomes spiderweb-like when the mesh is too complex + Bug #6222: global map cell size can crash openmw if set to too high a value Bug #6313: Followers with high Fight can turn hostile Bug #6427: Enemy health bar disappears before damaging effect ends Bug #6550: Cloned body parts don't inherit texture effects diff --git a/apps/openmw/mwgui/mapwindow.cpp b/apps/openmw/mwgui/mapwindow.cpp index 3714ecef64..47478d1efc 100644 --- a/apps/openmw/mwgui/mapwindow.cpp +++ b/apps/openmw/mwgui/mapwindow.cpp @@ -896,14 +896,14 @@ namespace MWGui void MapWindow::onMapZoomed(MyGUI::Widget* sender, int rel) { const static int localWidgetSize = Settings::Manager::getInt("local map widget size", "Map"); - const static int globalCellSize = Settings::Manager::getInt("global map cell size", "Map"); const bool zoomOut = rel < 0; const bool zoomIn = !zoomOut; const double speedDiff = zoomOut ? 1.0 / speed : speed; const float localMapSizeInUnits = localWidgetSize * mNumCells; - const float currentMinLocalMapZoom = std::max({ (float(globalCellSize) * 4.f) / float(localWidgetSize), + const float currentMinLocalMapZoom = std::max({ (float(Settings::map().mGlobalMapCellSize) * 4.f) + / float(localWidgetSize), float(mLocalMap->getWidth()) / localMapSizeInUnits, float(mLocalMap->getHeight()) / localMapSizeInUnits }); if (mGlobal) diff --git a/apps/openmw/mwrender/globalmap.cpp b/apps/openmw/mwrender/globalmap.cpp index d2137a0e15..8e61c0c4e1 100644 --- a/apps/openmw/mwrender/globalmap.cpp +++ b/apps/openmw/mwrender/globalmap.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include @@ -263,7 +263,8 @@ namespace MWRender }; GlobalMap::GlobalMap(osg::Group* root, SceneUtil::WorkQueue* workQueue) - : mRoot(root) + : mCellSize(Settings::map().mGlobalMapCellSize) + , mRoot(root) , mWorkQueue(workQueue) , mWidth(0) , mHeight(0) @@ -271,9 +272,7 @@ namespace MWRender , mMaxX(0) , mMinY(0) , mMaxY(0) - { - mCellSize = Settings::Manager::getInt("global map cell size", "Map"); } GlobalMap::~GlobalMap() diff --git a/components/settings/categories/map.hpp b/components/settings/categories/map.hpp index d7120eb4b6..bd5bd33d53 100644 --- a/components/settings/categories/map.hpp +++ b/components/settings/categories/map.hpp @@ -18,7 +18,7 @@ namespace Settings { using WithIndex::WithIndex; - SettingValue mGlobalMapCellSize{ mIndex, "Map", "global map cell size", makeMaxSanitizerInt(1) }; + SettingValue mGlobalMapCellSize{ mIndex, "Map", "global map cell size", makeClampSanitizerInt(1, 50) }; SettingValue mLocalMapHudWidgetSize{ mIndex, "Map", "local map hud widget size", makeMaxSanitizerInt(1) }; SettingValue mLocalMapHudFogOfWar{ mIndex, "Map", "local map hud fog of war" }; SettingValue mLocalMapResolution{ mIndex, "Map", "local map resolution", makeMaxSanitizerInt(1) }; diff --git a/docs/source/reference/modding/settings/map.rst b/docs/source/reference/modding/settings/map.rst index 9950fa9792..e20a993a29 100644 --- a/docs/source/reference/modding/settings/map.rst +++ b/docs/source/reference/modding/settings/map.rst @@ -15,7 +15,7 @@ global map cell size -------------------- :Type: integer -:Range: >= 1 +:Range: 1 to 50 :Default: 18 This setting adjusts the scale of the world map in the GUI mode map window.