Added AutoSearchSFX option for automatic search of SFX files

Excluded ANIM_walk from the debug log about missing critter art files.
This commit is contained in:
NovaRain
2021-08-08 22:40:49 +08:00
parent a26b7931a6
commit a34aa64ced
3 changed files with 36 additions and 3 deletions
+6 -1
View File
@@ -1,5 +1,5 @@
;sfall configuration settings ;sfall configuration settings
;v4.3 ;v4.3.1
[Main] [Main]
;Change to 1 if you want to use command line args to tell sfall to use another ini file. ;Change to 1 if you want to use command line args to tell sfall to use another ini file.
@@ -143,6 +143,11 @@ AllowDShowSound=0
;Set to 2 to overwrite all occurrences of the music path ;Set to 2 to overwrite all occurrences of the music path
OverrideMusicDir=1 OverrideMusicDir=1
;Set to 1 to automatically search for new SFX sound files at game startup
;Note: With this option enabled, you will no longer need to use the utility regsnd.exe to register new SFX sounds
;This will also increase the loading time of the game
AutoSearchSFX=1
;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
[Input] [Input]
;Set to 1 to enable the mouse scroll wheel to scroll through the inventory, barter, and loot screens ;Set to 1 to enable the mouse scroll wheel to scroll through the inventory, barter, and loot screens
+19 -2
View File
@@ -313,9 +313,9 @@ hide:
} }
static void __declspec(naked) art_data_size_hook() { static void __declspec(naked) art_data_size_hook() {
static const char* artDbgMsg = "\nERROR: File not found: %s\n"; static const char* artDbgMsg = "\nERROR: Art file not found: %s\n";
__asm { __asm {
test edi, edi; test edi, edi; // 1 - isExistsArt
jz artNotExist; jz artNotExist;
retn; retn;
artNotExist: artNotExist:
@@ -339,6 +339,18 @@ display:
} }
} }
static void __declspec(naked) art_data_size_hook_check() {
using namespace fo;
__asm {
xor esi, esi;
mov eax, ebx; // ebx - FID
shr eax, 16; // al - animation code (ID2)
cmp al, ANIM_walk;
cmove ecx, esi;
retn;
}
}
static void __declspec(naked) proto_load_pid_hack() { static void __declspec(naked) proto_load_pid_hack() {
static const char* proDbgMsg = "\nERROR: Reading prototype file: %s\n"; static const char* proDbgMsg = "\nERROR: Reading prototype file: %s\n";
__asm { __asm {
@@ -437,11 +449,16 @@ static void DebugModePatch() {
} else { } else {
SafeWrite32(0x4C6D9C, (DWORD)debugGnw); SafeWrite32(0x4C6D9C, (DWORD)debugGnw);
} }
if (IniReader::GetIntDefaultConfig("Debugging", "HideObjIsNullMsg", 0)) { if (IniReader::GetIntDefaultConfig("Debugging", "HideObjIsNullMsg", 0)) {
MakeJump(0x453FD2, dbg_error_hack); MakeJump(0x453FD2, dbg_error_hack);
} }
// prints a debug message about a missing critter art file to both debug.log and the message window in sfall debugging mode // prints a debug message about a missing critter art file to both debug.log and the message window in sfall debugging mode
HookCall(0x419B65, art_data_size_hook); HookCall(0x419B65, art_data_size_hook);
// checks the animation code, if ANIM_walk then skip printing the debug message
HookCall(0x419AA0, art_data_size_hook_check);
SafeWrite8(0x419B61, CodeType::JumpNZ); // jz > jnz
// Fix to prevent crashes when there is a '%' character in the printed message // Fix to prevent crashes when there is a '%' character in the printed message
if (dbgMode > 1) { if (dbgMode > 1) {
+11
View File
@@ -938,6 +938,13 @@ skip:
} }
} }
static void __declspec(naked) sfxl_init_hook() {
__asm {
xor eax, eax;
retn;
}
}
constexpr int SampleRate = 44100; // 44.1kHz constexpr int SampleRate = 44100; // 44.1kHz
void Sound::init() { void Sound::init() {
@@ -1013,6 +1020,10 @@ void Sound::init() {
// Support for ACM audio file playback and volume control for the soundplay script function // Support for ACM audio file playback and volume control for the soundplay script function
HookCall(0x4661B3, soundStartInterpret_hook); HookCall(0x4661B3, soundStartInterpret_hook);
if (IniReader::GetConfigInt("Sound", "AutoSearchSFX", 1)) {
HookCalls(sfxl_init_hook, {0x4A9999, 0x4A9B34});
}
} }
void Sound::exit() { void Sound::exit() {