From a392e5620a6d5700ec8cd73613c6baf7bf9bd73a Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 20 Feb 2022 08:39:02 +0800 Subject: [PATCH] Added support for LocalMapXLimit/LocalMapYLimit options to sfall HRP --- artifacts/ddraw.ini | 2 +- sfall/HRP/Init.cpp | 9 ++++----- sfall/Modules/Worldmap.cpp | 17 +++++++++++------ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 7e16365f..e6ec802c 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -332,7 +332,7 @@ Movie17=credits.mve ;To change the limit of the distance away from the player to which you're allowed to scroll the local maps, uncomment the next two lines ;Defaults are 480 in the x direction and 400 in the y direction. -;Not compatible with the hi-res patch! +;Does not work with the hi-res patch by Mash! ;LocalMapXLimit=480 ;LocalMapYLimit=400 diff --git a/sfall/HRP/Init.cpp b/sfall/HRP/Init.cpp index 788ec7b5..3e1a1dc7 100644 --- a/sfall/HRP/Init.cpp +++ b/sfall/HRP/Init.cpp @@ -11,7 +11,6 @@ #include "..\main.h" #include "..\FalloutEngine\Fallout2.h" #include "..\Translate.h" -#include "..\Utils.h" #include "..\WinProc.h" #include "..\Modules\Graphics.h" #include "..\Modules\LoadOrder.h" @@ -258,10 +257,10 @@ void Setting::init(const char* exeFileName, std::string &cmdline) { SlidesScreen::END_SLIDE_SIZE = sf::IniReader::GetInt("STATIC_SCREENS", "END_SLIDE_SIZE", 1, f2ResIni); MoviesScreen::MOVIE_SIZE = sf::IniReader::GetInt("MOVIES", "MOVIE_SIZE", 1, f2ResIni); - std::string x = sf::trim(sf::IniReader::GetString("MAPS", "SCROLL_DIST_X", "480", 16, f2ResIni)); - std::string y = sf::trim(sf::IniReader::GetString("MAPS", "SCROLL_DIST_Y", "400", 16, f2ResIni)); - ViewMap::SCROLL_DIST_X = (!x.compare(0, 9, "HALF_SCRN")) ? (SCR_WIDTH / 2) + 32 : std::atol(x.c_str()); - ViewMap::SCROLL_DIST_Y = (!y.compare(0, 9, "HALF_SCRN")) ? (SCR_HEIGHT / 2) + 24 : std::atol(y.c_str()); + long x = sf::IniReader::GetInt("MAPS", "SCROLL_DIST_X", 0, f2ResIni); + long y = sf::IniReader::GetInt("MAPS", "SCROLL_DIST_Y", 0, f2ResIni); + ViewMap::SCROLL_DIST_X = (x <= 0) ? (SCR_WIDTH / 2) + 32 : x; + ViewMap::SCROLL_DIST_Y = (y <= 0) ? (SCR_HEIGHT / 2) + 24 : y; ViewMap::IGNORE_PLAYER_SCROLL_LIMITS = (sf::IniReader::GetInt("MAPS", "IGNORE_PLAYER_SCROLL_LIMITS", 0, f2ResIni) != 0); ViewMap::IGNORE_MAP_EDGES = (sf::IniReader::GetInt("MAPS", "IGNORE_MAP_EDGES", 0, f2ResIni) != 0); diff --git a/sfall/Modules/Worldmap.cpp b/sfall/Modules/Worldmap.cpp index 283a1c00..35eba9b4 100644 --- a/sfall/Modules/Worldmap.cpp +++ b/sfall/Modules/Worldmap.cpp @@ -26,6 +26,8 @@ #include "ScriptExtender.h" #include "SpeedPatch.h" +#include "..\HRP\viewmap\ViewMap.h" + #include "Worldmap.h" namespace sfall @@ -369,24 +371,27 @@ static void RestRestore() { SafeWrite16(0x499E93, 0x0574); } -static void WorldLimitsPatches() { - DWORD data = IniReader::GetConfigInt("Misc", "LocalMapXLimit", 0); - if (data) { +static void MapLimitsPatches() { + // This has priority over the SCROLL_DIST_X/Y options in f2_res.ini + long data = IniReader::GetConfigInt("Misc", "LocalMapXLimit", 0); + if (data > 0) { dlog("Applying local map x limit patch.", DL_INIT); SafeWrite32(0x4B13B9, data); + HRP::ViewMap::SCROLL_DIST_X = data; dlogr(" Done", DL_INIT); } data = IniReader::GetConfigInt("Misc", "LocalMapYLimit", 0); - if (data) { + if (data > 0) { dlog("Applying local map y limit patch.", DL_INIT); SafeWrite32(0x4B13C7, data); + HRP::ViewMap::SCROLL_DIST_Y = data; dlogr(" Done", DL_INIT); } //if (IniReader::GetConfigInt("Misc", "CitiesLimitFix", 0)) { dlog("Applying cities limit patch.", DL_INIT); if (*((BYTE*)0x4BF3BB) != CodeType::JumpShort) { - SafeWrite8(0x4BF3BB, CodeType::JumpShort); + SafeWrite8(0x4BF3BB, CodeType::JumpShort); // wmAreaInit_ } dlogr(" Done", DL_INIT); //} @@ -697,7 +702,7 @@ void Worldmap::init() { PathfinderFixInit(); StartingStatePatches(); TimeLimitPatch(); - WorldLimitsPatches(); + MapLimitsPatches(); WorldmapFpsPatch(); PipBoyAutomapsPatch();