From 46349c5d693137c44cb1fbf718f63678383fd27f Mon Sep 17 00:00:00 2001 From: NovaRain Date: Fri, 22 Mar 2024 12:09:14 +0800 Subject: [PATCH] Fixed add_extra_msg_file loading the same msg file more than once (#467) Minor code edits. Updated version number. --- artifacts/ddraw.ini | 2 +- sfall/Modules/Message.cpp | 9 +++++++++ sfall/Modules/SubModules/ObjectName.cpp | 2 +- sfall/Modules/Worldmap.cpp | 6 +++--- sfall/version.h | 6 +++--- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index ec61d5cd..e6a270f7 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -1,5 +1,5 @@ ;sfall configuration settings -;v3.8.42.1 +;v3.8.43 [Main] ;Set to 1 if you want to use command line arguments to tell sfall to use another ini file diff --git a/sfall/Modules/Message.cpp b/sfall/Modules/Message.cpp index 1c5fc086..30eb6b4f 100644 --- a/sfall/Modules/Message.cpp +++ b/sfall/Modules/Message.cpp @@ -20,6 +20,7 @@ #include "..\main.h" #include "..\FalloutEngine\Fallout2.h" +#include "..\Utils.h" #include "LoadGameHook.h" #include "Message.h" @@ -62,6 +63,7 @@ const char* Message::GameLanguage() { ExtraGameMessageListsMap Message::gExtraGameMsgLists; static std::vector msgFileList; +static std::unordered_map addedExtraMsgFiles; static long msgNumCounter = 0x3000; @@ -192,6 +194,11 @@ long Message::AddExtraMsgFile(const char* msgName, long msgNumber) { std::string path("game\\"); path += msgName; + ToLowerCase(path); + + const std::unordered_map::iterator &msgIt = addedExtraMsgFiles.find(path.c_str()); + if (msgIt != addedExtraMsgFiles.cend()) return msgIt->second; // file has already been added by func + fo::MessageList* list = new fo::MessageList(); if (!fo::func::message_load(list, path.c_str())) { // change current language folder @@ -203,6 +210,7 @@ long Message::AddExtraMsgFile(const char* msgName, long msgNumber) { } if (msgNumber == 0) msgNumber = msgNumCounter++; Message::gExtraGameMsgLists.insert(std::make_pair(msgNumber, list)); + addedExtraMsgFiles.insert(std::make_pair(path, msgNumber)); return msgNumber; } @@ -216,6 +224,7 @@ void ClearScriptAddedExtraGameMsg() { ++it; } } + addedExtraMsgFiles.clear(); msgNumCounter = 0x3000; heroIsFemale = -1; } diff --git a/sfall/Modules/SubModules/ObjectName.cpp b/sfall/Modules/SubModules/ObjectName.cpp index 8da66672..e009a275 100644 --- a/sfall/Modules/SubModules/ObjectName.cpp +++ b/sfall/Modules/SubModules/ObjectName.cpp @@ -38,7 +38,7 @@ void ObjectName::SetName(long sid, const char* name) { const char* __stdcall ObjectName::GetName(fo::GameObject* object) { if (!overrideScrName.empty()) { - std::unordered_map::iterator &name = overrideScrName.find(object->scriptId); + const std::unordered_map::iterator &name = overrideScrName.find(object->scriptId); if (name != overrideScrName.cend()) { return (name->second.length() > 0) ? name->second.c_str() diff --git a/sfall/Modules/Worldmap.cpp b/sfall/Modules/Worldmap.cpp index 3ee6f208..3824a329 100644 --- a/sfall/Modules/Worldmap.cpp +++ b/sfall/Modules/Worldmap.cpp @@ -42,10 +42,10 @@ struct levelRest { }; #pragma pack(pop) -std::unordered_map mapRestInfo; +static std::unordered_map mapRestInfo; -std::vector> wmTerrainTypeNames; // pair first: x + y * number of horizontal sub-tiles -std::unordered_map wmAreaHotSpotTitle; +static std::vector> wmTerrainTypeNames; // pair first: x + y * number of horizontal sub-tiles +static std::unordered_map wmAreaHotSpotTitle; static bool restMap; static bool restMode; diff --git a/sfall/version.h b/sfall/version.h index 51326a77..b39f3b55 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -24,7 +24,7 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 -#define VERSION_BUILD 42 -#define VERSION_REV 1 +#define VERSION_BUILD 43 +#define VERSION_REV 0 -#define VERSION_STRING "3.8.42.1" +#define VERSION_STRING "3.8.43"