Fixed crash in an encounter between two groups

* when they are set to fight each other but one group fails to spawn.
(ref. BGforgeNet/Fallout2_Restoration_Project#350)

Updated version number.
This commit is contained in:
NovaRain
2025-08-17 15:10:17 +08:00
parent 1fb58e3aa4
commit 9996b60aae
2 changed files with 20 additions and 2 deletions
+18
View File
@@ -3604,6 +3604,21 @@ skip:
} }
} }
static __declspec(naked) void wmSetupRandomEncounter_hack() {
static const DWORD wmSetupRandomEncounter_Ret = 0x4C11DB;
__asm {
test edx, edx; // critter
jz skip;
// overwritten engine code
mov [esi + whoHitMe], edx;
mov [edx + whoHitMe], esi;
retn;
skip:
add esp, 4;
jmp wmSetupRandomEncounter_Ret;
}
}
void BugFixes::init() { void BugFixes::init() {
#ifndef NDEBUG #ifndef NDEBUG
LoadGameHook::OnBeforeGameClose() += PrintAddrList; LoadGameHook::OnBeforeGameClose() += PrintAddrList;
@@ -4470,6 +4485,9 @@ void BugFixes::init() {
// Fix crash when a critter with a powered melee/unarmed weapon runs out of ammo and there is ammo nearby // Fix crash when a critter with a powered melee/unarmed weapon runs out of ammo and there is ammo nearby
MakeCall(0x47887B, item_w_can_reload_hack); MakeCall(0x47887B, item_w_can_reload_hack);
// Fix crash when an encounter between two groups fighting each other fails to spawn one group
MakeCall(0x4C119A, wmSetupRandomEncounter_hack, 1);
} }
} }
+2 -2
View File
@@ -25,6 +25,6 @@
#define VERSION_MAJOR 4 #define VERSION_MAJOR 4
#define VERSION_MINOR 4 #define VERSION_MINOR 4
#define VERSION_BUILD 7 #define VERSION_BUILD 7
#define VERSION_REV 0 #define VERSION_REV 1
#define VERSION_STRING "4.4.7" #define VERSION_STRING "4.4.7.1"