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