From b8fe8cb4e309d3cf74fbed58a22cc581a00bd090 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Thu, 25 Jan 2024 10:19:23 +0800 Subject: [PATCH] Fixed the modulo operator for negative integers * this changes the behavior of vanilla modulo operator to use signed integer division to match how the fixed division operator works. --- sfall/Modules/BugFixes.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sfall/Modules/BugFixes.cpp b/sfall/Modules/BugFixes.cpp index 8f85088e8..860f72789 100644 --- a/sfall/Modules/BugFixes.cpp +++ b/sfall/Modules/BugFixes.cpp @@ -3305,13 +3305,16 @@ void BugFixes::init() { SafeWriteBatch(0x04DB, { // fild 64bit > fild 32bit 0x46A3A8, 0x46A3F4, // op_mul_ 0x46A4E7, 0x46A566, // op_div_ - 0x46A280, 0x46A2CD, // op_sub_ + 0x46A280, 0x46A2CD // op_sub_ }); - // Fix for vanilla division operator treating negative integers as unsigned + // Fix for vanilla division and modulo operators treating negative integers as unsigned //if (IniReader::GetConfigInt("Misc", "DivisionOperatorFix", 1)) { dlogr("Applying division operator fix.", DL_FIX); - SafeWrite32(0x46A51D, 0xFBF79990); // xor edx, edx; div ebx > cdq; idiv ebx + SafeWriteBatch(0x90FBF799, { // xor edx, edx; div ebx > cdq; idiv ebx + 0x46A51D, // op_div_ + 0x46A669 // op_mod_ + }); //} //if (IniReader::GetConfigInt("Misc", "SpecialUnarmedAttacksFix", 1)) {