From a6a8e2e42f32debaad3ceb4408ed8fd60327a9d3 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Fri, 13 Sep 2019 08:09:07 +0800 Subject: [PATCH] Backported HEROWIN, DIALOGVIEW, COUNTERWIN game mode flags from 4.x Updated UI hotkeys example mod. --- .../example_mods/UIHotkeys/gl_uihotkeys.int | Bin 552 -> 602 bytes .../example_mods/UIHotkeys/gl_uihotkeys.ssl | 3 +- artifacts/scripting/headers/sfall.h | 3 ++ sfall/FalloutEngine.cpp | 3 ++ sfall/FalloutEngine.h | 3 ++ sfall/HeroAppearance.cpp | 5 ++ sfall/LoadGameHook.cpp | 45 ++++++++++++++++ sfall/LoadGameHook.h | 50 +++++++++++------- 8 files changed, 92 insertions(+), 20 deletions(-) diff --git a/artifacts/example_mods/UIHotkeys/gl_uihotkeys.int b/artifacts/example_mods/UIHotkeys/gl_uihotkeys.int index 4fab3d8a14f14a89cc1551195588d09f7ac5d91a..f00771f4a86447db8fc47ff45cadcd5482e1f19e 100644 GIT binary patch delta 190 zcmZ3%a*JicL0P8;mc}Os7#SEC7#a+rEXD>ykO-60#Cww3G9V@cQ-jd~Mg{=}h6aZQ zeXs~a18;+5gI0rP15X234P)5EABLPx4J;sO#tD;+7!kZvlXDmi6`^uWP9PNwj9?=f j7%Ur%Ax1JuP2R_-kERM@F%ts=SPx5sWrOi#HYOziJ>o3; delta 124 zcmcb`vVvv8L0N$Ymc}Os7#SEC7#a+rEXD>ykO-5&#CwvAI+K+c4LJoGSU^IIX_I4+ vcnc;^L-3dcCSPC_V`BU;`30lCBvb>F07x4HQ-jd~Mg}GZh6abp7EDS2?^GSy diff --git a/artifacts/example_mods/UIHotkeys/gl_uihotkeys.ssl b/artifacts/example_mods/UIHotkeys/gl_uihotkeys.ssl index 0288b17b..60336c17 100644 --- a/artifacts/example_mods/UIHotkeys/gl_uihotkeys.ssl +++ b/artifacts/example_mods/UIHotkeys/gl_uihotkeys.ssl @@ -32,6 +32,7 @@ procedure start begin if (event) then begin mode := get_game_mode; + if (mode bwand COUNTERWIN) then return; // new mode from sfall 4.2/3.8.20 if (keyDX == DIK_I and (mode bwand INVENTORY)) then begin tap_key(DIK_ESCAPE); end else if (keyDX == DIK_S and (mode bwand SKILLDEX)) then begin @@ -43,7 +44,7 @@ procedure start begin tap_key(DIK_CAPITAL); tap_key(DIK_A); tap_key(DIK_CAPITAL); - end else if (mode bwand BARTER) then begin + end else if (mode == (BARTER + DIALOG)) then begin tap_key(DIK_M); end end diff --git a/artifacts/scripting/headers/sfall.h b/artifacts/scripting/headers/sfall.h index 471e9d27..db849818 100644 --- a/artifacts/scripting/headers/sfall.h +++ b/artifacts/scripting/headers/sfall.h @@ -17,6 +17,9 @@ #define INTFACEUSE (0x8000) #define INTFACELOOT (0x10000) #define BARTER (0x20000) +#define HEROWIN (0x40000) +#define DIALOGVIEW (0x80000) +#define COUNTERWIN (0x100000) // counter window for moving multiple items or setting a timer //Valid arguments to register_hook #define HOOK_TOHIT (0) diff --git a/sfall/FalloutEngine.cpp b/sfall/FalloutEngine.cpp index 131ac910..ca68c3af 100644 --- a/sfall/FalloutEngine.cpp +++ b/sfall/FalloutEngine.cpp @@ -367,6 +367,8 @@ const DWORD gdialog_barter_pressed_ = 0x44A52C; const DWORD gdialogActive_ = 0x444D2C; const DWORD gdialogDisplayMsg_ = 0x445448; const DWORD gdProcess_ = 0x4465C0; +const DWORD gdReviewExit_ = 0x445C18; +const DWORD gdReviewInit_ = 0x445938; const DWORD GetSlotList_ = 0x47E5D0; const DWORD get_input_ = 0x4C8B78; const DWORD get_time_ = 0x4C9370; @@ -644,6 +646,7 @@ const DWORD strParseStrFromList_ = 0x4AFE08; const DWORD switch_hand_ = 0x4714E0; const DWORD talk_to_critter_reacts_ = 0x447CA0; const DWORD talk_to_translucent_trans_buf_to_buf_ = 0x44AC68; +const DWORD text_curr_ = 0x4D58D4; const DWORD text_font_ = 0x4D58DC; const DWORD text_object_create_ = 0x4B036C; const DWORD tile_coord_ = 0x4B1674; diff --git a/sfall/FalloutEngine.h b/sfall/FalloutEngine.h index 80f13a54..1c8561fd 100644 --- a/sfall/FalloutEngine.h +++ b/sfall/FalloutEngine.h @@ -591,6 +591,8 @@ extern const DWORD gdialog_barter_pressed_; extern const DWORD gdialogActive_; extern const DWORD gdialogDisplayMsg_; extern const DWORD gdProcess_; +extern const DWORD gdReviewExit_; +extern const DWORD gdReviewInit_; extern const DWORD GetSlotList_; extern const DWORD get_input_; extern const DWORD get_time_; @@ -877,6 +879,7 @@ extern const DWORD strParseStrFromList_; extern const DWORD switch_hand_; extern const DWORD talk_to_critter_reacts_; extern const DWORD talk_to_translucent_trans_buf_to_buf_; +extern const DWORD text_curr_; extern const DWORD text_font_; extern const DWORD text_object_create_; extern const DWORD tile_coord_; // eax - tilenum, edx (int*) - x, ebx (int*) - y diff --git a/sfall/HeroAppearance.cpp b/sfall/HeroAppearance.cpp index 00607ec9..0bef696e 100644 --- a/sfall/HeroAppearance.cpp +++ b/sfall/HeroAppearance.cpp @@ -22,6 +22,7 @@ #include "Define.h" #include "FalloutEngine.h" #include "HeroAppearance.h" +#include "LoadGameHook.h" #include "Message.h" #include "PartyControl.h" #include "ScriptExtender.h" @@ -1403,6 +1404,8 @@ void _stdcall HeroSelectWindow(int raceStyleFlag) { if (!isStyle) styleVal = 0; LoadHeroDat(raceVal, styleVal, true); + SetLoopFlag(HEROWIN); + while (true) { // main loop NewTick = GetTickCount(); // timer for redraw if (OldTick > NewTick) OldTick = NewTick; @@ -1486,6 +1489,8 @@ void _stdcall HeroSelectWindow(int raceStyleFlag) { } } + ClearLoopFlag(HEROWIN); + LoadHeroDat(currentRaceVal, currentStyleVal, true); SetAppearanceGlobals(currentRaceVal, currentStyleVal); diff --git a/sfall/LoadGameHook.cpp b/sfall/LoadGameHook.cpp index 4391c222..6fb63f3a 100644 --- a/sfall/LoadGameHook.cpp +++ b/sfall/LoadGameHook.cpp @@ -74,6 +74,14 @@ DWORD GetLoopFlags() { return InLoop; } +void SetLoopFlag(LoopFlag flag) { + InLoop |= flag; +} + +void ClearLoopFlag(LoopFlag flag) { + InLoop &= ~flag; +} + static void _stdcall ResetState(DWORD onLoad) { if (!onLoad) FileSystemReset(); ClearGlobalScripts(); @@ -522,6 +530,39 @@ static void __declspec(naked) AutomapHook() { } } +static void __declspec(naked) DialogReviewInitHook() { + __asm { + call gdReviewInit_; + test eax, eax; + jnz error; + or InLoop, DIALOGVIEW; + xor eax, eax; +error: + retn; + } +} + +static void __declspec(naked) DialogReviewExitHook() { + __asm { + and InLoop, (-1 ^ DIALOGVIEW); + jmp gdReviewExit_; + } +} + +static void __declspec(naked) setup_move_timer_win_Hook() { + __asm { + or InLoop, COUNTERWIN; + jmp text_curr_; + } +} + +static void __declspec(naked) exit_move_timer_win_Hook() { + __asm { + and InLoop, (-1 ^ COUNTERWIN); + jmp win_delete_; + } +} + void LoadGameHookInit() { SaveInCombatFix = GetPrivateProfileInt("Misc", "SaveInCombatFix", 1, ini); if (SaveInCombatFix > 2) SaveInCombatFix = 0; @@ -596,4 +637,8 @@ void LoadGameHookInit() { HookCall(0x4466C7, BarterInventoryHook); HookCall(0x44396D, AutomapHook); HookCall(0x479519, AutomapHook); + HookCall(0x445CA7, DialogReviewInitHook); + HookCall(0x445D30, DialogReviewExitHook); + HookCall(0x476AC6, setup_move_timer_win_Hook); // before init win + HookCall(0x477067, exit_move_timer_win_Hook); } diff --git a/sfall/LoadGameHook.h b/sfall/LoadGameHook.h index 9fcee217..fda6a240 100644 --- a/sfall/LoadGameHook.h +++ b/sfall/LoadGameHook.h @@ -27,24 +27,36 @@ DWORD InWorldMap(); DWORD InCombat(); DWORD InDialog(); -#define WORLDMAP (1<<0) // 0x1 -#define LOCALMAP (1<<1) // 0x2 No point hooking this: would always be 1 at any point at which scripts are running -#define DIALOG (1<<2) // 0x4 -#define ESCMENU (1<<3) // 0x8 -#define SAVEGAME (1<<4) // 0x10 -#define LOADGAME (1<<5) // 0x20 -#define COMBAT (1<<6) // 0x40 -#define OPTIONS (1<<7) // 0x80 -#define HELP (1<<8) // 0x100 -#define CHARSCREEN (1<<9) // 0x200 -#define PIPBOY (1<<10) // 0x400 -#define PCOMBAT (1<<11) // 0x800 -#define INVENTORY (1<<12) // 0x1000 -#define AUTOMAP (1<<13) // 0x2000 -#define SKILLDEX (1<<14) // 0x4000 -#define INTFACEUSE (1<<15) // 0x8000 -#define INTFACELOOT (1<<16) // 0x10000 -#define BARTER (1<<17) // 0x20000 -#define RESERVED (1<<31) +enum LoopFlag : unsigned long { + WORLDMAP = 1 << 0, // 0x1 + LOCALMAP = 1 << 1, // 0x2 No point hooking this: would always be 1 at any point at which scripts are running + DIALOG = 1 << 2, // 0x4 + ESCMENU = 1 << 3, // 0x8 + SAVEGAME = 1 << 4, // 0x10 + LOADGAME = 1 << 5, // 0x20 + COMBAT = 1 << 6, // 0x40 + OPTIONS = 1 << 7, // 0x80 + HELP = 1 << 8, // 0x100 + CHARSCREEN = 1 << 9, // 0x200 + PIPBOY = 1 << 10, // 0x400 + PCOMBAT = 1 << 11, // 0x800 + INVENTORY = 1 << 12, // 0x1000 + AUTOMAP = 1 << 13, // 0x2000 + SKILLDEX = 1 << 14, // 0x4000 + INTFACEUSE = 1 << 15, // 0x8000 + INTFACELOOT = 1 << 16, // 0x10000 + BARTER = 1 << 17, // 0x20000 + HEROWIN = 1 << 18, // 0x40000 Hero Appearance mod + DIALOGVIEW = 1 << 19, // 0x80000 + COUNTERWIN = 1 << 20, // 0x100000 Counter window for moving multiple items or setting a timer + + // RESERVED = 1 << 31 +}; DWORD GetLoopFlags(); + +// set the given flag +void SetLoopFlag(LoopFlag flag); + +// unset the given flag +void ClearLoopFlag(LoopFlag flag);