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:07:26 +08:00
parent b32c358a77
commit a89e672355
5 changed files with 17 additions and 8 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
;sfall configuration settings
;v4.4.2.1
;v4.4.3
[Main]
;Set to 1 to enable the built-in High Resolution Patch mode that is similar to the hi-res patch by Mash
+9
View File
@@ -21,6 +21,7 @@
#include "..\main.h"
#include "..\FalloutEngine\Fallout2.h"
#include "..\Utils.h"
#include "LoadGameHook.h"
#include "Message.h"
@@ -63,6 +64,7 @@ const char* Message::GameLanguage() {
ExtraGameMessageListsMap Message::gExtraGameMsgLists;
static std::vector<std::string> msgFileList;
static std::unordered_map<std::string, long> addedExtraMsgFiles;
static long msgNumCounter = 0x3000;
@@ -193,6 +195,11 @@ long Message::AddExtraMsgFile(const char* msgName, long msgNumber) {
std::string path("game\\");
path += msgName;
ToLowerCase(path);
const auto &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
@@ -204,6 +211,7 @@ long Message::AddExtraMsgFile(const char* msgName, long msgNumber) {
}
if (msgNumber == 0) msgNumber = msgNumCounter++;
Message::gExtraGameMsgLists.emplace(msgNumber, list);
addedExtraMsgFiles.emplace(path, msgNumber);
return msgNumber;
}
@@ -216,6 +224,7 @@ static void ClearScriptAddedExtraGameMsg() { // C++11
++it;
}
}
addedExtraMsgFiles.clear();
msgNumCounter = 0x3000;
heroIsFemale = -1;
}
+1 -1
View File
@@ -40,7 +40,7 @@ void ObjectName::SetName(long sid, const char* name) {
const char* __stdcall ObjectName::GetName(fo::GameObject* object) {
if (!overrideScrName.empty()) {
auto& name = overrideScrName.find(object->scriptId);
const auto &name = overrideScrName.find(object->scriptId);
if (name != overrideScrName.cend()) {
return (name->second.length() > 0)
? name->second.c_str()
+3 -3
View File
@@ -46,10 +46,10 @@ struct levelRest {
};
#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
std::unordered_map<long, std::string> wmAreaHotSpotTitle;
static std::vector<std::pair<long, std::string>> wmTerrainTypeNames; // pair first: x + y * number of horizontal sub-tiles
static std::unordered_map<long, std::string> wmAreaHotSpotTitle;
static bool restMap;
static bool restMode;
+3 -3
View File
@@ -24,7 +24,7 @@
#define VERSION_MAJOR 4
#define VERSION_MINOR 4
#define VERSION_BUILD 2
#define VERSION_REV 1
#define VERSION_BUILD 3
#define VERSION_REV 0
#define VERSION_STRING "4.4.2.1"
#define VERSION_STRING "4.4.3"