Integrated Crafty's updated fix to prevent the game with old (pre-3.0) versions of f2_res from crashing/hanging while trying to use drag&drop to reload weapons in the inventory list.

Added a few new engine-related defines and constants.
This commit is contained in:
NovaRain
2016-03-21 11:58:56 +08:00
parent dfe4b6b2e0
commit 720f937b4f
3 changed files with 38 additions and 28 deletions
+32 -28
View File
@@ -432,37 +432,43 @@ static void __declspec(naked) inven_pickup_hack() {
} }
} }
static DWORD inven_pickup_loop=-1;
static void __declspec(naked) inven_pickup_hack2() { static void __declspec(naked) inven_pickup_hack2() {
__asm { __asm {
cmp inven_pickup_loop, -1
jne inLoop
test eax, eax test eax, eax
jnz startLoop jz end
mov eax, 0x47125C mov eax, ds:[_i_wid]
jmp eax call GNW_find_
startLoop: mov ecx, [eax+0x8+0x4] // ecx = _i_wid.rect.y
mov eax, [eax+0x8+0x0] // eax = _i_wid.rect.x
add eax, 44 // x_start
mov ebx, 64
add ebx, eax // x_end
xor edx, edx xor edx, edx
mov inven_pickup_loop, edx next:
nextLoop: push eax
mov ebx, 188 // x_end push edx
add edx, 35 // y_start push ecx
push ebx
imul edx, edx, 48
add edx, 35
add edx, ecx // y_start
mov ecx, edx mov ecx, edx
add ecx, 48 // y_end add ecx, 48 // y_end
mov eax, 0x471140 // x_start address call mouse_click_in_
jmp eax pop ebx
inLoop: pop ecx
pop edx
test eax, eax test eax, eax
mov eax, inven_pickup_loop pop eax
jnz foundRect jnz found
inc eax inc edx
mov inven_pickup_loop, eax cmp edx, 6
imul edx, eax, 48 jb next
jmp nextLoop end:
foundRect: mov eax, 0x47125C
mov inven_pickup_loop, -1 jmp eax
mov edx, [esp+0x40] // inventory_offset found:
add edx, eax add edx, [esp+0x40] // inventory_offset
mov eax, ds:[_pud] mov eax, ds:[_pud]
push eax push eax
mov eax, [eax] // itemsCount mov eax, [eax] // itemsCount
@@ -470,7 +476,7 @@ foundRect:
jz skip jz skip
dec eax dec eax
cmp edx, eax cmp edx, eax
jle inRange jbe inRange
skip: skip:
pop eax pop eax
mov ebx, 0x4711DF mov ebx, 0x4711DF
@@ -806,9 +812,7 @@ void BugsInit()
MakeCall(0x470EC2, &inven_pickup_hack, true); MakeCall(0x470EC2, &inven_pickup_hack, true);
// Fix for error in player's inventory, related to IFACE_BAR_MODE=1 in f2_res.ini, and // Fix for error in player's inventory, related to IFACE_BAR_MODE=1 in f2_res.ini, and
// also for reverse order error // also for reverse order error
if (*((DWORD*)0x471140) == 0x00007CB8) { // check for old (pre-3.0) versions of f2_res MakeCall(0x47114A, &inven_pickup_hack2, true);
MakeCall(0x47114A, &inven_pickup_hack2, true);
}
// Fix for using only one box of ammo when a weapon is above the ammo in the inventory list // Fix for using only one box of ammo when a weapon is above the ammo in the inventory list
HookCall(0x476598, &drop_ammo_into_weapon_hook); HookCall(0x476598, &drop_ammo_into_weapon_hook);
dlogr(" Done", DL_INIT); dlogr(" Done", DL_INIT);
+3
View File
@@ -245,8 +245,10 @@ const DWORD message_init_ = 0x48494C;
const DWORD message_load_ = 0x484AA4; const DWORD message_load_ = 0x484AA4;
const DWORD message_make_path_ = 0x484CB8; const DWORD message_make_path_ = 0x484CB8;
const DWORD message_search_ = 0x484C30; const DWORD message_search_ = 0x484C30;
const DWORD mouse_click_in_ = 0x4CA934;
const DWORD mouse_get_position_ = 0x4CA9DC; const DWORD mouse_get_position_ = 0x4CA9DC;
const DWORD mouse_hide_ = 0x4CA534; const DWORD mouse_hide_ = 0x4CA534;
const DWORD mouse_in_ = 0x4CA8C8;
const DWORD mouse_show_ = 0x4CA34C; const DWORD mouse_show_ = 0x4CA34C;
const DWORD move_inventory_ = 0x474708; const DWORD move_inventory_ = 0x474708;
const DWORD NixHotLines_ = 0x4999C0; const DWORD NixHotLines_ = 0x4999C0;
@@ -271,6 +273,7 @@ const DWORD obj_scroll_blocking_at_ = 0x48BB44;
const DWORD obj_set_light_ = 0x48AC90; // <eax>(int aObj<eax>, signed int aDist<edx>, int a3<ecx>, int aIntensity<ebx>) const DWORD obj_set_light_ = 0x48AC90; // <eax>(int aObj<eax>, signed int aDist<edx>, int a3<ecx>, int aIntensity<ebx>)
const DWORD obj_shoot_blocking_at_ = 0x48B930; // (EAX *obj, EDX hexNum, EBX level) const DWORD obj_shoot_blocking_at_ = 0x48B930; // (EAX *obj, EDX hexNum, EBX level)
const DWORD obj_sight_blocking_at_ = 0x48BB88; const DWORD obj_sight_blocking_at_ = 0x48BB88;
const DWORD obj_top_environment_ = 0x48B304;
const DWORD obj_use_book_ = 0x49B9F0; const DWORD obj_use_book_ = 0x49B9F0;
const DWORD obj_use_power_on_car_ = 0x49BDE8; const DWORD obj_use_power_on_car_ = 0x49BDE8;
const DWORD OptionWindow_ = 0x437C08; const DWORD OptionWindow_ = 0x437C08;
+3
View File
@@ -393,8 +393,10 @@ extern const DWORD message_init_;
extern const DWORD message_load_; extern const DWORD message_load_;
extern const DWORD message_make_path_; extern const DWORD message_make_path_;
extern const DWORD message_search_; extern const DWORD message_search_;
extern const DWORD mouse_click_in_;
extern const DWORD mouse_get_position_; extern const DWORD mouse_get_position_;
extern const DWORD mouse_hide_; extern const DWORD mouse_hide_;
extern const DWORD mouse_in_;
extern const DWORD mouse_show_; extern const DWORD mouse_show_;
extern const DWORD move_inventory_; extern const DWORD move_inventory_;
extern const DWORD NixHotLines_; extern const DWORD NixHotLines_;
@@ -419,6 +421,7 @@ extern const DWORD obj_scroll_blocking_at_;
extern const DWORD obj_set_light_; // <eax>(int aObj<eax>, signed int aDist<edx>, int a3<ecx>, int aIntensity<ebx>) extern const DWORD obj_set_light_; // <eax>(int aObj<eax>, signed int aDist<edx>, int a3<ecx>, int aIntensity<ebx>)
extern const DWORD obj_shoot_blocking_at_; extern const DWORD obj_shoot_blocking_at_;
extern const DWORD obj_sight_blocking_at_; extern const DWORD obj_sight_blocking_at_;
extern const DWORD obj_top_environment_;
extern const DWORD obj_use_book_; extern const DWORD obj_use_book_;
extern const DWORD obj_use_power_on_car_; extern const DWORD obj_use_power_on_car_;
extern const DWORD OptionWindow_; extern const DWORD OptionWindow_;