From 9a331c918cc396eba2f462c32b917c6979d380c9 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 2 Jun 2019 08:52:42 +0800 Subject: [PATCH] Fixed a bug in knockback modifier functions that could crash the game (#237) Updated version number. --- sfall/Knockback.cpp | 10 +++++----- sfall/version.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sfall/Knockback.cpp b/sfall/Knockback.cpp index 85cb2e02..0ce84ccc 100644 --- a/sfall/Knockback.cpp +++ b/sfall/Knockback.cpp @@ -73,8 +73,8 @@ static double ApplyModifiers(std::vector* mods, TGameObj* obj static DWORD __fastcall CalcKnockbackMod(int knockValue, int damage, TGameObj* weapon, TGameObj* attacker, TGameObj* target) { double result = (double)damage / (double)knockValue; - result = ApplyModifiers(&mWeapons, weapon, result); - result = ApplyModifiers(&mAttackers, attacker, result); + if (weapon) result = ApplyModifiers(&mWeapons, weapon, result); + if (attacker) result = ApplyModifiers(&mAttackers, attacker, result); result = ApplyModifiers(&mTargets, target, result); return (DWORD)floor(result); } @@ -97,9 +97,9 @@ static void __declspec(naked) compute_dmg_damage_hack() { __asm { push ecx push esi; // Target - mov eax, -1; - push eax; // Attacker - push eax; // Weapon + xor eax, eax; + push eax; // Attacker (no attacker) + push eax; // Weapon (no weapon) mov edx, ebx; // Damage mov ecx, 10; // Knockback value call CalcKnockbackMod; diff --git a/sfall/version.h b/sfall/version.h index da538898..65eefed5 100644 --- a/sfall/version.h +++ b/sfall/version.h @@ -25,12 +25,12 @@ #define VERSION_MAJOR 3 #define VERSION_MINOR 8 #define VERSION_BUILD 18 -#define VERSION_REV 0 +#define VERSION_REV 1 #ifdef WIN2K -#define VERSION_STRING "3.8.18 win2k" +#define VERSION_STRING "3.8.18.1 win2k" #else -#define VERSION_STRING "3.8.18" +#define VERSION_STRING "3.8.18.1" #endif //#define CHECK_VAL (4)