Fixed division by zero error in obj_examine_func_

(ref. fallout2-ce/fallout2-ce#541)
This commit is contained in:
NovaRain
2026-07-12 21:55:04 +08:00
parent 249adde00f
commit d4f49fd75c
+19
View File
@@ -1873,6 +1873,22 @@ skip:
} }
} }
static __declspec(naked) void obj_examine_func_hack_checkhp() {
static const DWORD ObjExamineFuncCheckHP_Ret = 0x49AF26;
__asm { // eax - maximum hp, ecx - current hp
test eax, eax;
jle dead;
// overwritten engine code
mov edx, eax;
test ecx, ecx;
jle dead;
retn;
dead:
add esp, 4;
jmp ObjExamineFuncCheckHP_Ret;
}
}
static DWORD expSwiftLearner; // experience points for print static DWORD expSwiftLearner; // experience points for print
static __declspec(naked) void statPCAddExperienceCheckPMs_hack() { static __declspec(naked) void statPCAddExperienceCheckPMs_hack() {
@@ -4074,6 +4090,9 @@ void BugFixes::init() {
// Supplementary fix for hacks in Game\GUI\Text.cpp // Supplementary fix for hacks in Game\GUI\Text.cpp
MakeCall(0x49AE33, obj_examine_func_hack_objdesc, 1); MakeCall(0x49AE33, obj_examine_func_hack_objdesc, 1);
// Fix division by zero error in obj_examine_func_ engine function (when a critter's max HP <= 0 for any reason)
MakeCall(0x49AF15, obj_examine_func_hack_checkhp, 1);
// Display experience points with the bonus from Swift Learner perk when gained from non-scripted situations // Display experience points with the bonus from Swift Learner perk when gained from non-scripted situations
//if (IniReader::GetConfigInt("Misc", "DisplaySwiftLearnerExp", 1)) { //if (IniReader::GetConfigInt("Misc", "DisplaySwiftLearnerExp", 1)) {
dlogr("Applying Swift Learner exp display patch.", DL_FIX); dlogr("Applying Swift Learner exp display patch.", DL_FIX);