mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
Fixed file seeking in uncompressed .dat files
(ref. fallout2-ce/fallout2-ce#244)
This commit is contained in:
@@ -706,6 +706,20 @@ bool FileSystem::IsEmpty() {
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
static __declspec(naked) void dfile_fseek_hook() {
|
||||
static const DWORD dfile_fseek_Ret = 0x4E5BCD;
|
||||
__asm {
|
||||
mov ecx, [esi + 4]; // stream->entry
|
||||
test byte ptr [ecx + 4], 1; // stream->entry->compressed
|
||||
jz skip;
|
||||
jmp fo::funcoffs::inflateEnd_;
|
||||
skip:
|
||||
xor eax, eax;
|
||||
add esp, 4;
|
||||
jmp dfile_fseek_Ret;
|
||||
}
|
||||
}
|
||||
|
||||
static void __stdcall OpenWarning() {
|
||||
MessageBoxA(0, "The open file limit is about to be reached.\n"
|
||||
"It is recommended to restart the game to avoid critical errors.", "Warning", MB_TASKMODAL | MB_ICONWARNING);
|
||||
@@ -783,6 +797,9 @@ void FileSystem::init() {
|
||||
BlockCall(0x4DEF12);
|
||||
BlockCall(0x4DEF84);
|
||||
|
||||
// Fix file seeking in uncompressed database files
|
||||
HookCall(0x4E5B52, dfile_fseek_hook);
|
||||
|
||||
// Warning message when there are more than 16 open files (max 20)
|
||||
HookCall(0x4EE0DE, sopen_hook_warning);
|
||||
// Error message "Failed to open file"
|
||||
|
||||
Reference in New Issue
Block a user