mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fix and refactor loading of ExtraGameMsgFileList
This commit is contained in:
@@ -77,7 +77,7 @@ void CRC(const char* filepath) {
|
||||
DWORD size = GetFileSize(h, 0), crc;
|
||||
bool sizeMatch = (size == ExpectedSize);
|
||||
|
||||
if (isDebug && !sizeMatch && GetPrivateProfileIntA("Debugging", "SkipSizeCheck", 0, ".\\ddraw.ini")) {
|
||||
if (isDebug && !sizeMatch && GetPrivateProfileIntA("Debugging", "SkipSizeCheck", 0, ddrawIni)) {
|
||||
sizeMatch = true;
|
||||
}
|
||||
|
||||
@@ -91,7 +91,7 @@ void CRC(const char* filepath) {
|
||||
|
||||
bool matchedCRC = false;
|
||||
|
||||
if (isDebug && GetPrivateProfileStringA("Debugging", "ExtraCRC", "", buf, 512, ".\\ddraw.ini") > 0) {
|
||||
if (isDebug && GetPrivateProfileStringA("Debugging", "ExtraCRC", "", buf, 512, ddrawIni) > 0) {
|
||||
char *TestCRC;
|
||||
TestCRC = strtok(buf, ",");
|
||||
while (TestCRC) {
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
|
||||
#include "LoadGameHook.h"
|
||||
|
||||
Delegate<> LoadGameHook::onGameInit;
|
||||
Delegate<> LoadGameHook::onGameReset;
|
||||
Delegate<> LoadGameHook::onBeforeGameStart;
|
||||
Delegate<> LoadGameHook::onAfterGameStarted;
|
||||
@@ -43,6 +44,7 @@ static DWORD saveInCombatFix;
|
||||
static bool disableHorrigan = false;
|
||||
static bool pipBoyAvailableAtGameStart = false;
|
||||
static bool mapLoaded = false;
|
||||
static bool gameLoaded = false;
|
||||
|
||||
bool IsMapLoaded() {
|
||||
return mapLoaded;
|
||||
@@ -235,6 +237,11 @@ static void __declspec(naked) main_load_new_hook() {
|
||||
|
||||
static void __stdcall MainMenuLoop() {
|
||||
mapLoaded = false;
|
||||
if (!gameLoaded) {
|
||||
gameLoaded = true;
|
||||
// called only once
|
||||
LoadGameHook::onGameInit.invoke();
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) main_menu_loop_hook() {
|
||||
|
||||
@@ -27,6 +27,9 @@ public:
|
||||
const char* name() { return "LoadGameHook"; }
|
||||
void init();
|
||||
|
||||
// Invoked when the game has initialized (game_init_ was called).
|
||||
static Delegate<> onGameInit;
|
||||
|
||||
// Invoked when game state is being reset (before loading a save, after quitting, etc.)
|
||||
static Delegate<> onGameReset;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "..\main.h"
|
||||
#include "..\FalloutEngine\Fallout2.h"
|
||||
#include "LoadGameHook.h"
|
||||
|
||||
#include "Message.h"
|
||||
|
||||
@@ -61,32 +62,10 @@ char* GetMsg(MessageList *msgList, int msgRef, int msgNum) {
|
||||
}
|
||||
|
||||
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";
|
||||
auto msgFileList = GetConfigList("Misc", "ExtraGameMsgFileList", "", 512);
|
||||
if (msgFileList.size() > 0) {
|
||||
for (auto& msgName : msgFileList) {
|
||||
std::string path = "game\\" + msgName + ".msg";
|
||||
MessageList* list = new MessageList();
|
||||
if (Wrapper::message_load(list, (char*)path.data()) == 1) {
|
||||
gExtraGameMsgLists.insert(std::make_pair(0x2000 + gExtraGameMsgLists.size(), list));
|
||||
@@ -94,8 +73,6 @@ void ReadExtraGameMsgFiles() {
|
||||
delete list;
|
||||
}
|
||||
}
|
||||
|
||||
begin = end + 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,7 +87,7 @@ void ClearReadExtraGameMsgFiles() {
|
||||
}
|
||||
|
||||
void Message::init() {
|
||||
ReadExtraGameMsgFiles();
|
||||
LoadGameHook::onGameInit += ReadExtraGameMsgFiles;
|
||||
}
|
||||
|
||||
void Message::exit() {
|
||||
|
||||
@@ -184,7 +184,7 @@ void __declspec(naked) defaultOpcodeHandler() {
|
||||
|
||||
void InitNewOpcodes() {
|
||||
bool AllowUnsafeScripting = isDebug
|
||||
&& GetPrivateProfileIntA("Debugging", "AllowUnsafeScripting", 0, ".\\ddraw.ini") != 0;
|
||||
&& GetPrivateProfileIntA("Debugging", "AllowUnsafeScripting", 0, ddrawIni) != 0;
|
||||
|
||||
dlogr("Adding additional opcodes", DL_SCRIPT);
|
||||
if (AllowUnsafeScripting) {
|
||||
|
||||
@@ -141,6 +141,7 @@ static void DllMain2() {
|
||||
manager.add<BurstMods>();
|
||||
manager.add<Books>();
|
||||
manager.add<Explosions>();
|
||||
manager.add<Message>();
|
||||
|
||||
manager.add<AI>();
|
||||
manager.add<AmmoMod>();
|
||||
|
||||
Reference in New Issue
Block a user