Fixed add_extra_msg_file loading the same msg file more than once (#467)

Minor code edits.
Updated version number.
This commit is contained in:
NovaRain
2024-03-22 12:09:14 +08:00
parent 8a8455efea
commit 46349c5d69
5 changed files with 17 additions and 8 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
;sfall configuration settings ;sfall configuration settings
;v3.8.42.1 ;v3.8.43
[Main] [Main]
;Set to 1 if you want to use command line arguments to tell sfall to use another ini file ;Set to 1 if you want to use command line arguments to tell sfall to use another ini file
+9
View File
@@ -20,6 +20,7 @@
#include "..\main.h" #include "..\main.h"
#include "..\FalloutEngine\Fallout2.h" #include "..\FalloutEngine\Fallout2.h"
#include "..\Utils.h"
#include "LoadGameHook.h" #include "LoadGameHook.h"
#include "Message.h" #include "Message.h"
@@ -62,6 +63,7 @@ const char* Message::GameLanguage() {
ExtraGameMessageListsMap Message::gExtraGameMsgLists; ExtraGameMessageListsMap Message::gExtraGameMsgLists;
static std::vector<std::string> msgFileList; static std::vector<std::string> msgFileList;
static std::unordered_map<std::string, long> addedExtraMsgFiles;
static long msgNumCounter = 0x3000; static long msgNumCounter = 0x3000;
@@ -192,6 +194,11 @@ long Message::AddExtraMsgFile(const char* msgName, long msgNumber) {
std::string path("game\\"); std::string path("game\\");
path += msgName; path += msgName;
ToLowerCase(path);
const std::unordered_map<std::string, long>::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(); fo::MessageList* list = new fo::MessageList();
if (!fo::func::message_load(list, path.c_str())) { if (!fo::func::message_load(list, path.c_str())) {
// change current language folder // change current language folder
@@ -203,6 +210,7 @@ long Message::AddExtraMsgFile(const char* msgName, long msgNumber) {
} }
if (msgNumber == 0) msgNumber = msgNumCounter++; if (msgNumber == 0) msgNumber = msgNumCounter++;
Message::gExtraGameMsgLists.insert(std::make_pair(msgNumber, list)); Message::gExtraGameMsgLists.insert(std::make_pair(msgNumber, list));
addedExtraMsgFiles.insert(std::make_pair(path, msgNumber));
return msgNumber; return msgNumber;
} }
@@ -216,6 +224,7 @@ void ClearScriptAddedExtraGameMsg() {
++it; ++it;
} }
} }
addedExtraMsgFiles.clear();
msgNumCounter = 0x3000; msgNumCounter = 0x3000;
heroIsFemale = -1; heroIsFemale = -1;
} }
+1 -1
View File
@@ -38,7 +38,7 @@ void ObjectName::SetName(long sid, const char* name) {
const char* __stdcall ObjectName::GetName(fo::GameObject* object) { const char* __stdcall ObjectName::GetName(fo::GameObject* object) {
if (!overrideScrName.empty()) { if (!overrideScrName.empty()) {
std::unordered_map<int, std::string>::iterator &name = overrideScrName.find(object->scriptId); const std::unordered_map<int, std::string>::iterator &name = overrideScrName.find(object->scriptId);
if (name != overrideScrName.cend()) { if (name != overrideScrName.cend()) {
return (name->second.length() > 0) return (name->second.length() > 0)
? name->second.c_str() ? name->second.c_str()
+3 -3
View File
@@ -42,10 +42,10 @@ struct levelRest {
}; };
#pragma pack(pop) #pragma pack(pop)
std::unordered_map<int, levelRest> mapRestInfo; static std::unordered_map<int, levelRest> mapRestInfo;
std::vector<std::pair<long, std::string>> wmTerrainTypeNames; // pair first: x + y * number of horizontal sub-tiles static std::vector<std::pair<long, std::string>> wmTerrainTypeNames; // pair first: x + y * number of horizontal sub-tiles
std::unordered_map<long, std::string> wmAreaHotSpotTitle; static std::unordered_map<long, std::string> wmAreaHotSpotTitle;
static bool restMap; static bool restMap;
static bool restMode; static bool restMode;
+3 -3
View File
@@ -24,7 +24,7 @@
#define VERSION_MAJOR 3 #define VERSION_MAJOR 3
#define VERSION_MINOR 8 #define VERSION_MINOR 8
#define VERSION_BUILD 42 #define VERSION_BUILD 43
#define VERSION_REV 1 #define VERSION_REV 0
#define VERSION_STRING "3.8.42.1" #define VERSION_STRING "3.8.43"