-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No math overflow checking in battle #1026
Comments
Comment author: @bob-the-hamster see also related bug bz#16 (#1029) for situations when adding to 32767 results in a |
Comment author: @bob-the-hamster Created attachment 25 Cleaning out my ancient e-mail, I found this: On Tue, Aug 26, 2003 at 02:59:02PM +0000, Sean Sheeley wrote:
This may not be the only math overflow. I believe there to be multiple
|
Comment author: @arperry http://www.cp-games.org/images/dderror.png In Darkmoor Dungeon, there is an enemy who counters attacks by raising his Defense and Magic Defense can't be set past 999 in the editor, so it is odd that |
Comment author: @pkmnfrk (I had forgotten about this bug.) Right, the defense would get so large that it eventually goes negative, screwing |
Comment author: @arperry No, I believe the overflow error occurs when the defense exceeds 32,767 and not |
Comment author: @pkmnfrk Either way, I added a few things to curb this bug. A) I cap damage at 32767 (mainly for 32-Bit OHR, which uses a larger unsigned A.5) There's also a new 9999 Damage Cap bitset, although James wants to make it B) I changed percentage based attacks to use the standard inflicting routines, I've tested it (albeit with my own test case), and it seems to work fine. |
Comment author: @bob-the-hamster Did you test with Sean Sheeley's attached testcase also? |
Comment author: @pkmnfrk No, but I'll do so now. |
Comment author: @pkmnfrk Oh bother. That should not be happening ("Duh!"). I checked with 32-bit game, and the damage being dealt is +326760. *sigh* Well, I did fix half of it, the part plaguing Darkmoor. |
Comment author: @bob-the-hamster I think the case where this bug is still occuring is when various multipliers For example, suppose your hero has strength of 1000, and does an attack on an The attack has Extra Damage=500, making his damage 5000 The attack's elements are Fire, Water, Earth, Wind, and Pizza, and the target is So now the damage is way over the limit. The same can happen with enemy-type So I think we need a safemultiply() function similar to the safesubtract() There might be some other cases too, like suppose an attack does exactly 32767 |
Comment author: @pkmnfrk Funny that you mention it, because I just added a safemultiply :) I made the second parameter a double, since more often than not, we're I got it to stop crashing, but it's A) still healing, and B) it gives a segment |
Comment author: @pkmnfrk I've kinda run into a bit of a problem. I changed the percentage-based-attack atk(11) is 1000: h = safesubtract(, safesubtract(, -(safemultiply(atk(11), As you can see, this is a result of truncating it every time... What if we just use Longs instead, and round at the end? |
Comment author: @pkmnfrk Now, had I actually looked that the attack settings in this case, I would have Anyway, I converted the battle routine to use a long, right up until it actually Only problem is that I'm still getting that seg... eh? It stopped happening when |
[bz#13]
There is currenty (almost) no math overflow checking in battle, so certain
situations, such as extremely high damage can result in a crash.
I need test cases with attacks that do so much damage they cause errors. 32767
is the maximum damage, but I am not sure in what situations exceeding that will
cause a crash.
From: @bob-the-hamster
Reported version: 20040628 Ozarks
The text was updated successfully, but these errors were encountered: