mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Code correction/edits to the previous commit
Added a debug message for the open file limit being exceeded.
This commit is contained in:
@@ -235,11 +235,8 @@ fo::QueueAddictData* __fastcall CheckAddictByPid(fo::GameObject* critter, long p
|
||||
}
|
||||
|
||||
fo::QueueAddictData* queue = (fo::QueueAddictData*)fo::func::queue_find_first(critter, fo::QueueType::addict_event);
|
||||
if (!queue) return queue; // null
|
||||
|
||||
while (queue->drugPid != pid) {
|
||||
while (queue && queue->drugPid != pid) {
|
||||
queue = (fo::QueueAddictData*)fo::func::queue_find_next(critter, fo::QueueType::addict_event);
|
||||
if (!queue) break;
|
||||
}
|
||||
return queue; // return null or pointer to queue_addict
|
||||
}
|
||||
|
||||
@@ -88,8 +88,8 @@
|
||||
#define FO_VAR_doing_refresh_all 0x6ADF38
|
||||
#define FO_VAR_dropped_explosive 0x5190E0
|
||||
#define FO_VAR_drugInfoList 0x5191CC
|
||||
#define FO_VAR_editor_message_file 0x56FCA8
|
||||
#define FO_VAR_edit_win 0x57060C
|
||||
#define FO_VAR_editor_message_file 0x56FCA8
|
||||
#define FO_VAR_Educated 0x57082C
|
||||
#define FO_VAR_elevation 0x631D2C
|
||||
#define FO_VAR_EncounterMapID 0x672E4C
|
||||
@@ -100,6 +100,7 @@
|
||||
#define FO_VAR_endWindowRect 0x518FA0
|
||||
#define FO_VAR_Experience_pc 0x6681B4
|
||||
#define FO_VAR_fade_steps 0x6642D0
|
||||
#define FO_VAR_fadeEventHandle 0x51D480
|
||||
#define FO_VAR_fallout_config 0x50281C
|
||||
#define FO_VAR_fallout_game_time 0x51C720
|
||||
#define FO_VAR_fidgetFID 0x5186F4
|
||||
|
||||
@@ -62,6 +62,7 @@ VAR_(elevation, DWORD)
|
||||
VAR_(endgame_subtitle_done, DWORD)
|
||||
VAR_(endWindowRect, fo::BoundRect)
|
||||
VAR_(Experience_pc, DWORD)
|
||||
VAR_(fadeEventHandle, DWORD)
|
||||
VAR_(fallout_game_time, DWORD)
|
||||
VAR_(fidgetFID, DWORD)
|
||||
VAR_(flptr, DWORD)
|
||||
|
||||
@@ -1726,7 +1726,7 @@ static void __declspec(naked) obj_examine_func_hack_ammo1() {
|
||||
push eax;
|
||||
call AppendText;
|
||||
mov currDescLen, 0;
|
||||
lea eax, [messageBuffer];
|
||||
lea eax, messageBuffer;
|
||||
jmp fo::funcoffs::gdialogDisplayMsg_;
|
||||
skip:
|
||||
jmp dword ptr [esp + 0x1AC - 0x14 + 4];
|
||||
@@ -1745,7 +1745,7 @@ static void __declspec(naked) obj_examine_func_hack_weapon() {
|
||||
sub eax, 2;
|
||||
mov byte ptr messageBuffer[eax], 0; // cutoff last character
|
||||
mov currDescLen, 0;
|
||||
lea eax, [messageBuffer];
|
||||
lea eax, messageBuffer;
|
||||
skip:
|
||||
jmp ObjExamineFuncWeapon_Ret;
|
||||
}
|
||||
|
||||
@@ -704,6 +704,57 @@ bool FileSystem::IsEmpty() {
|
||||
return (int)(files.size() - loadedFiles) <= 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static const DWORD __set_errno_ = 0x4E11F5;
|
||||
|
||||
static void __stdcall OpenFail() {
|
||||
MessageBoxA(0, "Failed to open file.\nToo many open files.", 0, MB_TASKMODAL | MB_ICONERROR);
|
||||
}
|
||||
|
||||
static void __declspec(naked) sopen_hook() {
|
||||
__asm {
|
||||
call __set_errno_;
|
||||
jmp OpenFail;
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef NDEBUG
|
||||
long openfiles = 0; // current number of open files
|
||||
|
||||
void __stdcall OpenLog(const char* file, long id) {
|
||||
openfiles++;
|
||||
dlog_f(">> Open %s(%d) [%d]\n", 0, file, id, openfiles);
|
||||
}
|
||||
|
||||
void __stdcall CloseLog(long id) {
|
||||
dlog_f("<< Close id:%d [%d]\n", 0, id, openfiles);
|
||||
openfiles--;
|
||||
}
|
||||
|
||||
static void __declspec(naked) OpenFileLog() {
|
||||
__asm {
|
||||
pushadc;
|
||||
push eax;
|
||||
push ebp;
|
||||
call OpenLog;
|
||||
popadc;
|
||||
call dword ptr ds:[0x51E758]; // __InitAccessH
|
||||
retn;
|
||||
}
|
||||
}
|
||||
|
||||
static void __declspec(naked) CloseFileLog() {
|
||||
__asm {
|
||||
pushadc;
|
||||
push eax;
|
||||
call CloseLog;
|
||||
popadc;
|
||||
retn;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void FileSystem::init() {
|
||||
if (IniReader::GetConfigInt("Misc", "UseFileSystemOverride", 0)) {
|
||||
FileSystemOverride();
|
||||
@@ -717,6 +768,13 @@ void FileSystem::init() {
|
||||
// xfopen_ - remove sprintf_ function calls that do nothing (probably just checking the filename for the '%' formatting char?)
|
||||
BlockCall(0x4DEF12);
|
||||
BlockCall(0x4DEF84);
|
||||
|
||||
// Debug message "Failed to open file"
|
||||
HookCall(0x4EE0EC, sopen_hook);
|
||||
|
||||
// DEV Testing: Check open/close file descriptors
|
||||
//MakeCall(0x4EE216, OpenFileLog, 1);
|
||||
//MakeCall(0x4EB814, CloseFileLog, 1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -351,7 +351,7 @@ static void __stdcall game_init_hook() {
|
||||
static void __stdcall GameInitialized(int initResult) {
|
||||
#ifdef NDEBUG
|
||||
if (!initResult) {
|
||||
MessageBoxA(0, "Game initialization failed!", "Error", MB_TASKMODAL | MB_ICONERROR);
|
||||
MessageBoxA(0, "Game initialization failed!", 0, MB_TASKMODAL | MB_ICONERROR);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -117,13 +117,11 @@ static bool PatchesCompare(const char* p1, const char* p2) {
|
||||
size_t len1 = std::strlen(p1);
|
||||
size_t len2 = std::strlen(p2);
|
||||
|
||||
if (len1 == 0 || len2 == 0) return false;
|
||||
|
||||
// R-Trim
|
||||
while (p1[len1 - 1] == '\\') len1--;
|
||||
while (p2[len2 - 1] == '\\') len2--;
|
||||
while (len1 > 0 && p1[len1 - 1] == '\\') len1--;
|
||||
while (len2 > 0 && p2[len2 - 1] == '\\') len2--;
|
||||
|
||||
if (len1 != len2) return false;
|
||||
if (len1 != len2 || len1 == 0 || len2 == 0) return false;
|
||||
|
||||
size_t n = 0;
|
||||
while (true) {
|
||||
@@ -134,10 +132,8 @@ static bool PatchesCompare(const char* p1, const char* p2) {
|
||||
if (c1 >= 'A' && c1 <= 'Z') c1 |= 32;
|
||||
if (c2 >= 'A' && c2 <= 'Z') c2 |= 32;
|
||||
|
||||
if (c1 != c2) return false;
|
||||
if (c1 != c2 || ++n > len1 || n > len2) return false;
|
||||
|
||||
n++;
|
||||
if (n > len1 || n > len2) return false;
|
||||
if (n == len1 && n == len2) break; // paths are matched
|
||||
}
|
||||
return true;
|
||||
|
||||
@@ -269,7 +269,7 @@ static void __declspec(naked) PrintPages() {
|
||||
push eax;
|
||||
|
||||
push format;
|
||||
lea eax, [bufPage];
|
||||
lea eax, bufPage;
|
||||
push eax; // text buf
|
||||
call fo::funcoffs::sprintf_;
|
||||
add esp, 0x18;
|
||||
@@ -278,7 +278,7 @@ static void __declspec(naked) PrintPages() {
|
||||
mov dword ptr ds:[FO_VAR_cursor_line], ebx;
|
||||
mov bl, byte ptr ds:[FO_VAR_GreenColor];
|
||||
mov edx, 0x21;
|
||||
lea eax, [bufPage];
|
||||
lea eax, bufPage;
|
||||
jmp fo::funcoffs::pip_print_;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1003,7 +1003,7 @@ stop:
|
||||
static bool fadeProcess = false;
|
||||
|
||||
static void __stdcall sf_doTimerEvent(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2) {
|
||||
if (!fadeProcess && dwUser) {
|
||||
if (!fadeProcess && fo::var::fadeEventHandle != -1 && dwUser) {
|
||||
fadeProcess = true;
|
||||
__asm call dwUser; // fadeSounds_
|
||||
fadeProcess = false;
|
||||
@@ -1012,7 +1012,6 @@ static void __stdcall sf_doTimerEvent(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser
|
||||
|
||||
static void __declspec(naked) internalSoundFade_hack_timer() {
|
||||
__asm {
|
||||
//mov dword ptr [esp + 8], TIME_PERIODIC | TIME_KILL_SYNCHRONOUS;
|
||||
lea eax, sf_doTimerEvent;
|
||||
xchg [esp], eax;
|
||||
jmp eax;
|
||||
|
||||
Reference in New Issue
Block a user