Added a new setting to DebugMode to send debug output to both the screen and the debug log (from Crafty)

Simplified the code for ObjCanSeeObj_ShootThru_Fix a bit (from Mr.Stalin)
Changed sfall to not to create sfallfs.sav when UseFileSystemOverride is disabled.
This commit is contained in:
NovaRain
2018-10-27 09:46:35 +08:00
parent b5306406b3
commit 9f689863d7
8 changed files with 43 additions and 22 deletions
+2 -2
View File
@@ -649,8 +649,8 @@ CreditsAtBottom=0
Enable=0
;Fallout 2 Debug Patch
;Set to 1 to enable debugging output to screen or 2 to create a debug.log file
;While you don't need to create an environment variable, you do still need to set the appropriate lines in fallout2.cfg
;Set to 1 to send debug output to the screen, 2 to a debug.log file, or 3 to both the screen and a debug.log file
;While you don't need to create an environment variable, you do still need to set the appropriate lines in fallout2.cfg:
;-------
;[debug]
;mode=environment
+1
View File
@@ -310,6 +310,7 @@ const DWORD db_get_file_list_ = 0x4C6628;
const DWORD db_read_to_buf_ = 0x4C5DD4;
const DWORD dbase_close_ = 0x4E5270;
const DWORD dbase_open_ = 0x4E4F58;
const DWORD debug_log_ = 0x4C7028;
const DWORD debug_printf_ = 0x4C6F48;
const DWORD debug_register_env_ = 0x4C6D90;
const DWORD determine_to_hit_func_ = 0x4243A8;
+2
View File
@@ -88,6 +88,7 @@
#define _glblmode 0x5709D0
#define _gmouse_current_cursor 0x518C0C
#define _gmovie_played_list 0x596C78
#define _GNW_win_init_flag 0x51E3E0
#define _GreenColor 0x6A3CB0
#define _gsound_initialized 0x518E30
#define _hit_location_penalty 0x510954
@@ -506,6 +507,7 @@ extern const DWORD db_get_file_list_;
extern const DWORD db_read_to_buf_;
extern const DWORD dbase_close_;
extern const DWORD dbase_open_;
extern const DWORD debug_log_;
extern const DWORD debug_printf_;
extern const DWORD debug_register_env_;
extern const DWORD determine_to_hit_func_;
+2 -5
View File
@@ -36,7 +36,7 @@ std::vector<fsFile> files;
static DWORD loadedtiles = 0;
static DWORD retval;
static bool UsingFileSystem = false;
bool UsingFileSystem = false;
struct openFile {
DWORD pos;
@@ -446,12 +446,9 @@ void FileSystemReset() {
for (DWORD i = files.size() - 1; i >= loadedtiles; i--) files.erase(files.begin() + i);
}
}
void FileSystemSave(HANDLE h) {
DWORD count = 0, unused;
if (!UsingFileSystem) {
WriteFile(h, &count, 4, &unused, 0);
return;
}
for (DWORD i = 0; i < files.size(); i++) {
if (files[i].data) count++;
}
+3 -1
View File
@@ -18,6 +18,8 @@
#pragma once
extern bool UsingFileSystem;
void FileSystemInit();
void FileSystemReset();
void FileSystemSave(HANDLE h);
@@ -35,7 +37,7 @@ void _stdcall FSwrite_bstring(DWORD id, const char* data);
int _stdcall FSread_byte(DWORD id);
int _stdcall FSread_short(DWORD id);
int _stdcall FSread_int(DWORD id);
void _stdcall FSdelete(DWORD id);
void _stdcall FSdelete(DWORD id);
DWORD _stdcall FSsize(DWORD id);
DWORD _stdcall FSpos(DWORD id);
void _stdcall FSseek(DWORD id, DWORD pos);
+3 -1
View File
@@ -110,12 +110,14 @@ static void _stdcall SaveGame2() {
DisplayConsoleMessage(SaveSfallDataFailMsg);
PlaySfx("IISXXXX1");
}
if (!UsingFileSystem) return;
GetSavePath(buf, "fs");
h = CreateFileA(buf, GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, 0);
if (h != INVALID_HANDLE_VALUE) {
FileSystemSave(h);
}
CloseHandle(h);
}
}
static char SaveFailMsg[128];
+2
View File
@@ -1722,11 +1722,13 @@ void LoadGlobalScripts() {
isGlobalScriptLoading = 0;
}
}
__asm {
xor edx, edx
lea eax, filenames
call db_free_file_list_
}
dlogr("Finished loading global scripts.", DL_SCRIPT|DL_INIT);
}
+28 -13
View File
@@ -658,18 +658,14 @@ fail:
}
}
static void __declspec(naked) op_obj_can_see_obj_hook() { // (EAX *objStruct, EDX hexNum1, EBX hexNum2, ECX ?, stack1 **ret_objStruct, stack2 flags)
static void __declspec(naked) op_obj_can_see_obj_hook() {
__asm {
push esi;
push edi;
push obj_shoot_blocking_at_; // arg3 check hex objects func pointer
mov esi, 0x20; // arg2 flags, 0x20 = check shootthru
push esi;
mov edi, dword ptr ss:[esp + 0x14]; // arg1 **ret_objStruct
push edi;
call make_straight_path_func_; // (EAX *objStruct, EDX hexNum1, EBX hexNum2, ECX ?, stack1 **ret_objStruct, stack2 flags, stack3 *check_hex_objs_func)
pop edi;
pop esi;
push obj_shoot_blocking_at_; // check hex objects func pointer
push 0x20; // flags, 0x20 = check shootthru
mov ecx, dword ptr [esp + 0x0C]; // buf **ret_objStruct
push ecx;
xor ecx, ecx;
call make_straight_path_func_; // (EAX *objStruct, EDX hexNum1, EBX hexNum2, ECX 0, stack1 **ret_objStruct, stack2 flags, stack3 *check_hex_objs_func)
retn 8;
}
}
@@ -766,6 +762,16 @@ static void __declspec(naked) wmInterfaceInit_text_font_hook() {
}
}
static void __declspec(naked) win_debug_hook() {
__asm {
call debug_log_;
xor eax, eax;
cmp ds:[_GNW_win_init_flag], eax;
push 0x4DC320;
retn;
}
}
static void DllMain2() {
//SafeWrite8(0x4B15E8, 0xc3);
//SafeWrite8(0x4B30C4, 0xc3); //this is the one I need to override for bigger tiles
@@ -1102,8 +1108,17 @@ static void DllMain2() {
SafeWrite32(0x444A6E, 0x90909090);
}
SafeWrite8(0x4C6D9B, 0xB8); // mov eax, GNW/LOG
if (tmp == 2) SafeWrite32(0x4C6D9C, (DWORD)debugLog);
else SafeWrite32(0x4C6D9C, (DWORD)debugGnw);
if (tmp & 2) {
SafeWrite32(0x4C6D9C, (DWORD)debugLog);
if (tmp & 1) {
SafeWrite16(0x4C6E75, 0x66EB); // jmps 0x4C6EDD
SafeWrite8(0x4C6EF2, 0xEB);
SafeWrite8(0x4C7034, 0x0);
MakeJump(0x4DC319, win_debug_hook);
}
} else {
SafeWrite32(0x4C6D9C, (DWORD)debugGnw);
}
dlogr(" Done", DL_INIT);
}
}