Skip to content

Commit 0742b43

Browse files
committed
Fixed tile_is_visible function not checking tile visibilty correctly
(ref. fallout2-ce/fallout2-ce#741)
1 parent dcf0062 commit 0742b43

1 file changed

Lines changed: 42 additions & 4 deletions

File tree

‎sfall/Modules/BugFixes.cpp‎

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3839,10 +3839,10 @@ static __declspec(naked) void game_reset_hook() {
38393839
static __declspec(naked) void sfxl_init_mem_free_hook() {
38403840
__asm {
38413841
call fo::funcoffs::mem_free_;
3842-
xor ecx, ecx;
3843-
mov ds:[FO_VAR_sfxl_effect_path], ecx;
3844-
mov ds:[FO_VAR_sfxl_effect_path_len], ecx;
3845-
mov ds:[FO_VAR_sfxl_files_total], ecx;
3842+
xor eax, eax;
3843+
mov ds:[FO_VAR_sfxl_effect_path], eax;
3844+
mov ds:[FO_VAR_sfxl_effect_path_len], eax;
3845+
mov ds:[FO_VAR_sfxl_files_total], eax;
38463846
retn;
38473847
}
38483848
}
@@ -3860,6 +3860,40 @@ static __declspec(naked) void map_load_file_hook_get_cursor() {
38603860
}
38613861
}
38623862

3863+
static __declspec(naked) void scripts_tile_is_visible_hack() {
3864+
static RECT tileRect;
3865+
__asm {
3866+
lea ebx, [tileRect + 4]; // y
3867+
lea edx, [tileRect]; // x
3868+
call fo::funcoffs::tile_coord_; // eax - tile
3869+
cmp eax, -1;
3870+
je invalid;
3871+
mov eax, [tileRect];
3872+
add eax, 31;
3873+
mov [tileRect + 8], eax; // offx
3874+
mov eax, [tileRect + 4];
3875+
add eax, 15
3876+
mov [tileRect + 12], eax; // offy
3877+
lea ebx, tileRect; // outRect
3878+
mov edx, FO_VAR_scr_size; // inRect
3879+
lea eax, tileRect; // srcRect
3880+
call fo::funcoffs::rect_inside_bound_;
3881+
neg eax;
3882+
sbb eax, eax;
3883+
inc eax;
3884+
pop edx;
3885+
pop ecx;
3886+
pop ebx;
3887+
retn;
3888+
invalid:
3889+
xor eax, eax;
3890+
pop edx;
3891+
pop ecx;
3892+
pop ebx;
3893+
retn;
3894+
}
3895+
}
3896+
38633897
void BugFixes::init() {
38643898
#ifndef NDEBUG
38653899
LoadGameHook::OnBeforeGameClose() += PrintAddrList;
@@ -4800,6 +4834,10 @@ void BugFixes::init() {
48004834

48014835
// Fix for the cursor getting stuck in view scrolling mode upon entering an encounter
48024836
HookCall(0x482BB4, map_load_file_hook_get_cursor);
4837+
4838+
// Fix for tile_is_visible function not checking tile visibilty correctly
4839+
// The original code forms a broad cross-shaped region spanning the whole map width
4840+
MakeJump(0x45404F, scripts_tile_is_visible_hack, 1);
48034841
}
48044842

48054843
}

0 commit comments

Comments
 (0)