Corrected code for initializing attached script (create_object_sid, #378)

This commit is contained in:
NovaRain
2021-05-19 10:19:38 +08:00
parent 86e71738b9
commit fdfb4c3a17
4 changed files with 25 additions and 0 deletions
+3
View File
@@ -2980,6 +2980,9 @@ static void __declspec(naked) op_create_object_sid_hack() {
mov eax, esi;
retn;
init:
call IsMapLoading;
test al, al;
jnz end; // yes - initialization will be performed by engine functions
cmp createObjectSidStartFix, 0;
jne runStart;
call InitScript;
+1
View File
@@ -370,6 +370,7 @@ FUNC(map_enable_bk_processes_, 0x4820C0)
FUNC(map_exit_, 0x482084)
FUNC(map_get_short_name_, 0x48261C)
FUNC(map_load_, 0x482A68)
FUNC(map_load_file_, 0x482B74)
FUNC(map_load_idx_, 0x482B34)
FUNC(map_set_elevation_, 0x482158)
FUNC(mem_free_, 0x4C5C24)
+19
View File
@@ -71,9 +71,14 @@ static DWORD saveInCombatFix;
static bool disableHorrigan = false;
static bool pipBoyAvailableAtGameStart = false;
static bool gameLoaded = false;
static bool onLoadingMap = false;
long gameInterfaceWID = -1;
bool IsMapLoading() {
return onLoadingMap;
}
// True if game was started, false when on the main menu
bool IsGameLoaded() {
return gameLoaded;
@@ -451,6 +456,16 @@ static void __declspec(naked) game_close_hook() {
}
}
static void __declspec(naked) map_load_hook() {
__asm {
mov onLoadingMap, 1;
call map_load_file_;
mov onLoadingMap, 0;
retn;
}
}
static void __declspec(naked) WorldMapHook_Start() {
__asm {
call wmInterfaceInit_;
@@ -775,14 +790,17 @@ void LoadGameHook_Init() {
disableHorrigan = true;
}
HookCall(0x482AEC, map_load_hook);
HookCall(0x4809BA, main_init_system_hook);
HookCall(0x4426A6, game_init_hook);
HookCall(0x480AAE, main_load_new_hook);
const DWORD loadGameAddr[] = {0x443AE4, 0x443B89, 0x480B77, 0x48FD35};
HookCalls(LoadGame_hook, loadGameAddr);
SafeWrite32(0x5194C0, (DWORD)&EndLoadHook);
const DWORD saveGameAddr[] = {0x443AAC, 0x443B1C, 0x48FCFF};
HookCalls(SaveGame_hook, saveGameAddr);
const DWORD gameResetAddr[] = {
0x47DD6B, // LoadSlot_ (on load error)
0x47DDF3, // LoadSlot_ (on load error)
@@ -797,6 +815,7 @@ void LoadGameHook_Init() {
};
HookCalls(game_reset_hook, gameResetAddr);
HookCall(0x47F491, game_reset_on_load_hook); // PrepLoad_ (the very first step during save game loading)
const DWORD beforeGameExitAddr[] = {0x480ACE, 0x480BC7}; // gnw_main_
HookCalls(before_game_exit_hook, beforeGameExitAddr);
const DWORD afterGameExitAddr[] = {0x480AEB, 0x480BE4}; // gnw_main_
+2
View File
@@ -22,6 +22,8 @@ extern long gameInterfaceWID;
void LoadGameHook_Init();
bool IsMapLoading();
// True if game was started, false when on the main menu
bool IsGameLoaded();