Added new modes for get_game_mode to match Crafty's (backported from 4.0 development branch, commit c32dc7664e)

This commit is contained in:
NovaRain
2017-06-22 09:41:05 +08:00
parent 874b047ce1
commit a93ad5a9ba
5 changed files with 96 additions and 49 deletions
+4
View File
@@ -14,6 +14,10 @@
#define INVENTORY (0x1000)
#define AUTOMAP (0x2000)
#define SKILLDEX (0x4000)
#define INTFACEUSE (0x8000)
#define INTFACELOOT (0x10000)
#define BARTER (0x20000)
#define HEROWIN (0x40000)
//Valid arguments to register_hook
#define HOOK_TOHIT (0)
+3
View File
@@ -245,6 +245,7 @@ const DWORD art_ptr_lock_data_ = 0x419188;
const DWORD art_ptr_unlock_ = 0x419260;
const DWORD automap_ = 0x41B8BC;
const DWORD barter_compute_value_ = 0x474B2C;
const DWORD barter_inventory_ = 0x4757F0;
const DWORD buf_to_buf_ = 0x4D36D4;
const DWORD check_death_ = 0x410814;
const DWORD Check4Keys_ = 0x43F73C;
@@ -422,6 +423,7 @@ const DWORD loadColorTable_ = 0x4C78E4;
const DWORD LoadGame_ = 0x47C640;
const DWORD loadProgram_ = 0x4A3B74;
const DWORD LoadSlot_ = 0x47DC68;
const DWORD loot_container_ = 0x473904;
const DWORD main_game_loop_ = 0x480E48;
const DWORD main_menu_hide_ = 0x481A00;
const DWORD main_menu_loop_ = 0x481AEC;
@@ -577,6 +579,7 @@ const DWORD trait_get_ = 0x4B3B54;
const DWORD trait_init_ = 0x4B39F0;
const DWORD trait_level_ = 0x4B3BC8;
const DWORD trait_set_ = 0x4B3B48;
const DWORD use_inventory_on_ = 0x4717E4;
const DWORD _word_wrap_ = 0x4BC6F0;
const DWORD win_add_ = 0x4D6238;
const DWORD win_delete_ = 0x4D6468;
+3
View File
@@ -419,6 +419,7 @@ extern const DWORD art_ptr_lock_data_;
extern const DWORD art_ptr_unlock_;
extern const DWORD automap_;
extern const DWORD barter_compute_value_;
extern const DWORD barter_inventory_;
extern const DWORD buf_to_buf_;
extern const DWORD check_death_;
extern const DWORD Check4Keys_;
@@ -595,6 +596,7 @@ extern const DWORD loadColorTable_;
extern const DWORD LoadGame_;
extern const DWORD loadProgram_; // loads script from scripts/ folder by file name and returns pointer to it: char* <eax> - file name (w/o extension)
extern const DWORD LoadSlot_;
extern const DWORD loot_container_;
extern const DWORD main_game_loop_;
extern const DWORD main_menu_hide_;
extern const DWORD main_menu_loop_;
@@ -753,6 +755,7 @@ extern const DWORD trait_get_;
extern const DWORD trait_init_;
extern const DWORD trait_level_;
extern const DWORD trait_set_;
extern const DWORD use_inventory_on_;
extern const DWORD _word_wrap_;
extern const DWORD win_add_;
extern const DWORD win_delete_;
+51 -18
View File
@@ -157,7 +157,7 @@ static void __declspec(naked) SaveGame() {
or InLoop, SAVEGAME;
call SaveGame_;
and InLoop, (-1^SAVEGAME);
and InLoop, (-1 ^ SAVEGAME);
cmp eax, 1;
jne end;
call SaveGame2;
@@ -219,7 +219,7 @@ static void __declspec(naked) LoadGame() {
push edx;
or InLoop, LOADGAME;
call LoadGame_;
and InLoop, (-1^LOADGAME);
and InLoop, (-1 ^ LOADGAME);
pop edx;
pop ecx;
pop ebx;
@@ -295,7 +295,7 @@ static void __declspec(naked) WorldMapHook() {
or InLoop, WORLDMAP;
xor eax, eax;
call wmWorldMapFunc_;
and InLoop, (-1^WORLDMAP);
and InLoop, (-1 ^ WORLDMAP);
retn;
}
}
@@ -304,7 +304,7 @@ static void __declspec(naked) WorldMapHook2() {
__asm {
or InLoop, WORLDMAP;
call wmWorldMapFunc_;
and InLoop, (-1^WORLDMAP);
and InLoop, (-1 ^ WORLDMAP);
retn;
}
}
@@ -319,7 +319,7 @@ static void __declspec(naked) CombatHook() {
pushad;
call AICombatEnd;
popad
and InLoop, (-1^COMBAT);
and InLoop, (-1 ^ COMBAT);
retn;
}
}
@@ -328,7 +328,7 @@ static void __declspec(naked) PlayerCombatHook() {
__asm {
or InLoop, PCOMBAT;
call combat_input_;
and InLoop, (-1^PCOMBAT);
and InLoop, (-1 ^ PCOMBAT);
retn;
}
}
@@ -337,7 +337,7 @@ static void __declspec(naked) EscMenuHook() {
__asm {
or InLoop, ESCMENU;
call do_optionsFunc_;
and InLoop, (-1^ESCMENU);
and InLoop, (-1 ^ ESCMENU);
retn;
}
}
@@ -347,7 +347,7 @@ static void __declspec(naked) EscMenuHook2() {
__asm {
or InLoop, ESCMENU;
call do_options_;
and InLoop, (-1^ESCMENU);
and InLoop, (-1 ^ ESCMENU);
retn;
}
}
@@ -356,7 +356,7 @@ static void __declspec(naked) OptionsMenuHook() {
__asm {
or InLoop, OPTIONS;
call do_prefscreen_;
and InLoop, (-1^OPTIONS);
and InLoop, (-1 ^ OPTIONS);
retn;
}
}
@@ -365,7 +365,7 @@ static void __declspec(naked) HelpMenuHook() {
__asm {
or InLoop, HELP;
call game_help_;
and InLoop, (-1^HELP);
and InLoop, (-1 ^ HELP);
retn;
}
}
@@ -386,7 +386,7 @@ success:
call PerksAcceptCharScreen;
end:
popad;
and InLoop, (-1^CHARSCREEN);
and InLoop, (-1 ^ CHARSCREEN);
retn;
}
}
@@ -395,7 +395,7 @@ static void __declspec(naked) DialogHook() {
__asm {
or InLoop, DIALOG;
call gdProcess_;
and InLoop, (-1^DIALOG);
and InLoop, (-1 ^ DIALOG);
retn;
}
}
@@ -404,7 +404,7 @@ static void __declspec(naked) PipboyHook() {
__asm {
or InLoop, PIPBOY;
call pipboy_;
and InLoop, (-1^PIPBOY);
and InLoop, (-1 ^ PIPBOY);
retn;
}
}
@@ -413,25 +413,53 @@ static void __declspec(naked) SkilldexHook() {
__asm {
or InLoop, SKILLDEX;
call skilldex_select_;
and InLoop, (-1^SKILLDEX);
and InLoop, (-1 ^ SKILLDEX);
retn;
}
}
static void __declspec(naked) InventoryHook() {
static void __declspec(naked) HandleInventoryHook() {
__asm {
or InLoop, INVENTORY;
call handle_inventory_;
and InLoop, (-1^INVENTORY);
and InLoop, (-1 ^ INVENTORY);
retn;
}
}
static void __declspec(naked) UseInventoryOnHook() {
__asm {
or InLoop, INTFACEUSE;
call use_inventory_on_;
and InLoop, (-1 ^ INTFACEUSE);
retn;
}
}
static void __declspec(naked) LootContainerHook() {
__asm {
or InLoop, INTFACELOOT;
call loot_container_;
and InLoop, (-1 ^ INTFACELOOT);
retn;
}
}
static void __declspec(naked) BarterInventoryHook() {
__asm {
or InLoop, BARTER;
push [ESP + 4];
call barter_inventory_;
and InLoop, (-1 ^ BARTER);
retn 4;
}
}
static void __declspec(naked) AutomapHook() {
__asm {
or InLoop, AUTOMAP;
call automap_;
and InLoop, (-1^AUTOMAP);
and InLoop, (-1 ^ AUTOMAP);
retn;
}
}
@@ -497,7 +525,12 @@ void LoadGameHookInit() {
HookCall(0x443605, PipboyHook);
HookCall(0x4434AC, SkilldexHook);
HookCall(0x44C7BD, SkilldexHook);
HookCall(0x443357, InventoryHook);
HookCall(0x443357, HandleInventoryHook);
HookCall(0x44C6FB, UseInventoryOnHook);
HookCall(0x4746EC, LootContainerHook);
HookCall(0x4A4369, LootContainerHook);
HookCall(0x4A4565, LootContainerHook);
HookCall(0x4466C7, BarterInventoryHook);
HookCall(0x44396D, AutomapHook);
HookCall(0x479519, AutomapHook);
}
+19 -15
View File
@@ -24,21 +24,25 @@ bool IsMapLoaded();
DWORD InWorldMap();
DWORD InCombat();
#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 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 HEROWIN (1<<18) // 0x40000
#define RESERVED (1<<31)
DWORD GetCurrentLoops();