diff --git a/sfall/FalloutEngine.cpp b/sfall/FalloutEngine.cpp index 6ac6f7c6..ae9cca4b 100644 --- a/sfall/FalloutEngine.cpp +++ b/sfall/FalloutEngine.cpp @@ -128,7 +128,7 @@ PathNode** ptr_master_db_handle = reinterpret_cast(_master_db_ DWORD* ptr_master_volume = reinterpret_cast(_master_volume); DWORD* ptr_max = reinterpret_cast(_max); long* ptr_maxScriptNum = reinterpret_cast(_maxScriptNum); -DWORD* ptr_Meet_Frank_Horrigan = reinterpret_cast(_Meet_Frank_Horrigan); +bool* ptr_Meet_Frank_Horrigan = reinterpret_cast(_Meet_Frank_Horrigan); const char** ptr_movie_list = reinterpret_cast(_movie_list); // array of 17 char* DWORD* ptr_mouse_hotx = reinterpret_cast(_mouse_hotx); DWORD* ptr_mouse_hoty = reinterpret_cast(_mouse_hoty); diff --git a/sfall/FalloutEngine.h b/sfall/FalloutEngine.h index 852fee97..ea33da64 100644 --- a/sfall/FalloutEngine.h +++ b/sfall/FalloutEngine.h @@ -410,7 +410,7 @@ extern PathNode** ptr_master_db_handle; extern DWORD* ptr_master_volume; extern DWORD* ptr_max; extern long* ptr_maxScriptNum; -extern DWORD* ptr_Meet_Frank_Horrigan; +extern bool* ptr_Meet_Frank_Horrigan; extern const char** ptr_movie_list; // array of 17 char* extern DWORD* ptr_mouse_hotx; extern DWORD* ptr_mouse_hoty; diff --git a/sfall/LoadGameHook.cpp b/sfall/LoadGameHook.cpp index 6cc781de..abdb3b57 100644 --- a/sfall/LoadGameHook.cpp +++ b/sfall/LoadGameHook.cpp @@ -236,6 +236,7 @@ errorLoad: static void __stdcall LoadGame_After() { CritLoad(); + *ptr_Meet_Frank_Horrigan = disableHorrigan; LoadGlobalScripts(); gameLoaded = true; } @@ -317,6 +318,7 @@ static void NewGame2() { CritLoad(); SetNewCharAppearanceGlobals(); LoadHeroAppearance(); + *ptr_Meet_Frank_Horrigan = disableHorrigan; LoadGlobalScripts(); dlogr("New Game started.", DL_MAIN); @@ -328,8 +330,6 @@ static void __declspec(naked) NewGame() { __asm { pushad; call NewGame2; - mov al, disableHorrigan; - mov byte ptr ds:[_Meet_Frank_Horrigan], al; popad; jmp main_game_loop_; } @@ -628,13 +628,12 @@ void LoadGameHookInit() { pipBoyAvailableAtGameStart = true; break; case 2: - SafeWrite8(0x497011, 0xEB); // skip the vault suit movie check + SafeWrite8(0x497011, CODETYPE_JumpShort); // skip the vault suit movie check break; } if (GetConfigInt("Misc", "DisableHorrigan", 0)) { disableHorrigan = true; - SafeWrite8(0x4C06D8, 0xEB); // skip the Horrigan encounter check } // 4.x backport diff --git a/sfall/Movies.cpp b/sfall/Movies.cpp index 85880086..e5b3c807 100644 --- a/sfall/Movies.cpp +++ b/sfall/Movies.cpp @@ -472,20 +472,22 @@ void MoviesInit() { if (*((DWORD*)0x00518DA0) != 0x00503300) { dlog("Error: The value at address 0x001073A0 is not equal to 0x00503300.", DL_INIT); } + + char optName[8] = "Movie"; for (int i = 0; i < MaxMovies; i++) { - MoviePtrs[i] = (DWORD)&MoviePaths[65 * i]; - MoviePaths[i * 65 + 64] = 0; - char ininame[8]; - strcpy_s(ininame, "Movie"); - _itoa_s(i + 1, &ininame[5], 3, 10); + int index = 65 * i; + MoviePtrs[i] = (DWORD)&MoviePaths[index]; + MoviePaths[index + 64] = '\0'; + + _itoa_s(i + 1, &optName[5], 3, 10); if (i < 17) { - GetConfigString("Misc", ininame, ptr_movie_list[i], &MoviePaths[i * 65], 65); + GetConfigString("Misc", optName, ptr_movie_list[i], &MoviePaths[index], 65); } else { - GetConfigString("Misc", ininame, "", &MoviePaths[i * 65], 65); + GetConfigString("Misc", optName, "", &MoviePaths[index], 65); } } dlog(".", DL_INIT); - const DWORD movieListAddr[] = {0x44E6AE, 0x44E721, 0x44E75E, 0x44E78A}; + const DWORD movieListAddr[] = {0x44E6AE, 0x44E721, 0x44E75E, 0x44E78A}; // gmovie_play_ SafeWriteBatch((DWORD)MoviePtrs, movieListAddr); dlog(".", DL_INIT); diff --git a/sfall/SafeWrite.cpp b/sfall/SafeWrite.cpp index 68a5b766..a6a4e384 100644 --- a/sfall/SafeWrite.cpp +++ b/sfall/SafeWrite.cpp @@ -1,10 +1,4 @@ -#include "main.h" - -enum CodeType : BYTE { - CODE_Call = 0xE8, - CODE_Jump = 0xE9, - CODE_Nop = 0x90 -}; +#include "SafeWrite.h" static void __stdcall SafeWriteFunc(BYTE code, DWORD addr, void* func) { DWORD oldProtect, data = (DWORD)func - (addr + 5); @@ -26,7 +20,7 @@ static __declspec(noinline) void __stdcall SafeWriteFunc(BYTE code, DWORD addr, *((DWORD*)(addr + 1)) = data; for (unsigned int i = 0; i < len; i++) { - *((BYTE*)(addrMem + i)) = CODE_Nop; + *((BYTE*)(addrMem + i)) = CODETYPE_Nop; } VirtualProtect((void *)addr, protectLen, oldProtect, &oldProtect); } @@ -77,19 +71,19 @@ void HookCall(DWORD addr, void* func) { } void MakeCall(DWORD addr, void* func) { - SafeWriteFunc(CODE_Call, addr, func); + SafeWriteFunc(CODETYPE_Call, addr, func); } void MakeCall(DWORD addr, void* func, int len) { - SafeWriteFunc(CODE_Call, addr, func, len); + SafeWriteFunc(CODETYPE_Call, addr, func, len); } void MakeJump(DWORD addr, void* func) { - SafeWriteFunc(CODE_Jump, addr, func); + SafeWriteFunc(CODETYPE_Jump, addr, func); } void MakeJump(DWORD addr, void* func, int len) { - SafeWriteFunc(CODE_Jump, addr, func, len); + SafeWriteFunc(CODETYPE_Jump, addr, func, len); } void SafeMemSet(DWORD addr, BYTE val, int len) { diff --git a/sfall/SafeWrite.h b/sfall/SafeWrite.h index 8f8ebbd6..8fdfbe24 100644 --- a/sfall/SafeWrite.h +++ b/sfall/SafeWrite.h @@ -1,5 +1,14 @@ #pragma once +enum CodeType : BYTE { + CODETYPE_Call = 0xE8, + CODETYPE_Jump = 0xE9, + CODETYPE_Nop = 0x90, + CODETYPE_JumpShort = 0xEB, // 0xEB [jmp short ...] + CODETYPE_JumpNZ = 0x75, // 0x75 [jnz short ...] + CODETYPE_JumpZ = 0x74, // 0x74 [jz short ...] +}; + template void __stdcall SafeWrite(DWORD addr, T data) { DWORD oldProtect;