diff --git a/sfall/HeroAppearance.cpp b/sfall/HeroAppearance.cpp
index facfb137..0f761bec 100644
--- a/sfall/HeroAppearance.cpp
+++ b/sfall/HeroAppearance.cpp
@@ -24,6 +24,7 @@
#include "HeroAppearance.h"
#include "Message.h"
#include "ScriptExtender.h"
+#include "Message.h"
bool AppModEnabled=false; //check if Appearance mod enabled for script fuctions
diff --git a/sfall/LoadGameHook.cpp b/sfall/LoadGameHook.cpp
index d0b079a5..a20e1858 100644
--- a/sfall/LoadGameHook.cpp
+++ b/sfall/LoadGameHook.cpp
@@ -39,6 +39,7 @@
#include "sound.h"
#include "SuperSave.h"
#include "version.h"
+#include "Message.h"
#define MAX_GLOBAL_SIZE (MaxGlobalVars*12 + 4)
@@ -276,6 +277,7 @@ end:
retn;
}
}
+
static void NewGame2() {
ResetState(0);
@@ -311,11 +313,17 @@ static void __declspec(naked) NewGame() {
}
}
+static void ReadExtraGameMsgFilesIfNeeded() {
+ if (gExtraGameMsgLists.empty())
+ ReadExtraGameMsgFiles();
+}
+
static void __declspec(naked) MainMenu() {
__asm {
pushad;
push 0;
call ResetState;
+ call ReadExtraGameMsgFilesIfNeeded;
call LoadHeroAppearance;
popad;
call main_menu_loop_;
diff --git a/sfall/Message.cpp b/sfall/Message.cpp
index 4ebb13e4..5942747d 100644
--- a/sfall/Message.cpp
+++ b/sfall/Message.cpp
@@ -1,6 +1,10 @@
/*
* sfall
+<<<<<<< HEAD
* Copyright (C) 2008-2016 The sfall team
+=======
+ * Copyright (C) 2009, 2010 Mash (Matt Wells, mashw at bigpond dot net dot au)
+>>>>>>> c3e489424351eadbc1d5f36772da89b586872eb9
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -16,10 +20,18 @@
* along with this program. If not, see .
*/
+<<<<<<< HEAD
#include "main.h"
#include "FalloutEngine.h"
#include "Message.h"
+=======
+#include
+#include "Message.h"
+#include "FalloutEngine.h"
+
+std::tr1::unordered_map gExtraGameMsgLists;
+>>>>>>> c3e489424351eadbc1d5f36772da89b586872eb9
int LoadMsgList(MSGList *MsgList, char *MsgFilePath) {
int retVal;
@@ -42,6 +54,7 @@ int DestroyMsgList(MSGList *MsgList) {
return retVal;
}
+<<<<<<< HEAD
/*
bool GetMsg(MSGList *MsgList, MSGNode *MsgNode, DWORD msgRef) {
bool retVal=FALSE;
@@ -59,6 +72,23 @@ EndFunc:
return retVal;
}
*/
+=======
+//bool GetMsg(MSGList *MsgList, MSGNode *MsgNode, DWORD msgRef) {
+// bool retVal=FALSE;
+// MsgNode->ref=msgRef;
+//
+// __asm {
+// mov edx, MsgNode
+// mov eax, MsgList
+// call message_search_
+// cmp eax, 1
+// jne EndFunc
+// mov retVal, 1
+// EndFunc:
+// }
+// return retVal;
+//}
+>>>>>>> c3e489424351eadbc1d5f36772da89b586872eb9
MSGNode *GetMsgNode(MSGList *MsgList, DWORD msgRef) {
@@ -95,3 +125,54 @@ char* GetMsg(MSGList *MsgList, DWORD msgRef, int msgNum) {
}
return NULL;
}
+<<<<<<< HEAD
+=======
+
+void ReadExtraGameMsgFiles() {
+ int read;
+ std::string names;
+
+ names.resize(256);
+
+ while ((read = GetPrivateProfileStringA("Misc", "ExtraGameMsgFileList", "",
+ (LPSTR)names.data(), names.size(), ".\\ddraw.ini")) == names.size() - 1)
+ names.resize(names.size() + 256);
+
+ if (names.empty())
+ return;
+
+ names.resize(names.find_first_of('\0'));
+ names.append(",");
+
+ int begin = 0;
+ int end;
+ int length;
+
+ while ((end = names.find_first_of(',', begin)) != std::string::npos) {
+ length = end - begin;
+
+ if (length > 0) {
+ std::string path = "game\\" + names.substr(begin, length) + ".msg";
+ MSGList* list = new MSGList;
+
+ if (LoadMsgList(list, (char*)path.data()) == 1)
+ gExtraGameMsgLists.insert(std::make_pair(0x2000 + gExtraGameMsgLists.size(), list));
+ else
+ delete list;
+ }
+
+ begin = end + 1;
+ }
+}
+
+void ClearReadExtraGameMsgFiles() {
+ std::tr1::unordered_map::iterator it;
+
+ for (it = gExtraGameMsgLists.begin(); it != gExtraGameMsgLists.end(); ++it) {
+ DestroyMsgList(it->second);
+ delete it->second;
+ }
+
+ gExtraGameMsgLists.clear();
+}
+>>>>>>> c3e489424351eadbc1d5f36772da89b586872eb9
diff --git a/sfall/Message.h b/sfall/Message.h
index f525ce03..1c36b4ca 100644
--- a/sfall/Message.h
+++ b/sfall/Message.h
@@ -1,4 +1,5 @@
/*
+<<<<<<< HEAD
* sfall
* Copyright (C) 2008-2016 The sfall team
*
@@ -18,6 +19,30 @@
#pragma once
+=======
+* sfall
+* Copyright (C) 2008, 2009 The sfall team
+*
+* This program is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* This program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with this program. If not, see .
+*/
+
+#pragma once
+
+#include
+#include "main.h"
+
+>>>>>>> c3e489424351eadbc1d5f36772da89b586872eb9
//for holding a message
typedef struct MSGNode {
DWORD ref;
@@ -44,8 +69,18 @@ typedef struct MSGList {
}
} MSGList;
+<<<<<<< HEAD
+=======
+extern std::tr1::unordered_map gExtraGameMsgLists;
+
+>>>>>>> c3e489424351eadbc1d5f36772da89b586872eb9
int LoadMsgList(MSGList *MsgList, char *MsgFilePath);
int DestroyMsgList(MSGList *MsgList);
//bool GetMsg(MSGList *MsgList, MSGNode *MsgNode, DWORD msgRef);
MSGNode *GetMsgNode(MSGList *MsgList, DWORD msgRef);
char* GetMsg(MSGList *MsgList, DWORD msgRef, int msgNum);
+<<<<<<< HEAD
+=======
+void ReadExtraGameMsgFiles();
+void ClearReadExtraGameMsgFiles();
+>>>>>>> c3e489424351eadbc1d5f36772da89b586872eb9
diff --git a/sfall/ScriptOps/ScriptUtils.hpp b/sfall/ScriptOps/ScriptUtils.hpp
index 2d626c36..023a4b45 100644
--- a/sfall/ScriptOps/ScriptUtils.hpp
+++ b/sfall/ScriptOps/ScriptUtils.hpp
@@ -26,6 +26,7 @@
#include "ScriptArrays.hpp"
#include "FileSystem.h"
#include "Arrays.h"
+#include "Message.h"
static void __declspec(naked) funcSqrt() {
__asm {
@@ -861,22 +862,28 @@ static const DWORD* proto_msg_files = (DWORD*)0x006647AC;
static void _stdcall op_message_str_game2() {
DWORD fileId = opArgs[0];
+ const char* msg = 0;
+
if (IsOpArgInt(0) && IsOpArgInt(1)) {
int msgId = GetOpArgInt(1);
- const char* msg;
if (fileId < 20) { // main msg files
msg = GetMessageStr(game_msg_files[fileId], msgId);
}
else if (fileId >= 0x1000 && fileId <= 0x1005) { // proto msg files
msg = GetMessageStr((DWORD)&proto_msg_files[2*(fileId - 0x1000)], msgId);
}
- if (msg != 0)
- SetOpReturn(msg);
- else
- SetOpReturn(0, DATATYPE_INT);
- } else {
- SetOpReturn(0, DATATYPE_INT);
+ else if (fileId >= 0x2000) { // Extra game message files.
+ std::tr1::unordered_map::iterator it = gExtraGameMsgLists.find(fileId);
+
+ if (it != gExtraGameMsgLists.end())
+ msg = GetMsg(it->second, msgId, 2);
+ }
}
+
+ if (msg == 0)
+ msg = "Error";
+
+ SetOpReturn(msg);
}
static void __declspec(naked) op_message_str_game() {
diff --git a/sfall/main.cpp b/sfall/main.cpp
index 042895d6..392464d7 100644
--- a/sfall/main.cpp
+++ b/sfall/main.cpp
@@ -60,6 +60,7 @@
#include "Tiles.h"
#include "timer.h"
#include "version.h"
+#include "Message.h"
bool IsDebug = false;
@@ -1550,6 +1551,7 @@ static void DllMain2() {
}
static void _stdcall OnExit() {
+ ClearReadExtraGameMsgFiles();
ConsoleExit();
AnimationsAtOnceExit();
HeroAppearanceModExit();