Burn damage calculation not fixed? #2045
Comments
anonymous uploaded file |
Daltx commented Added a savegame. (forgot to to change my name) |
cybersphinx uploaded file |
cybersphinx commented That patch makes the code a. work and b. readable. The "if (damageToDo > 20)" block after that still looks strange, not sure if that works right, but at least we don't get "(uint)(- a bit) / 1000" damage anymore. |
Zarel commented Why'd you take out the cast to |
Zarel uploaded file |
Zarel commented This patch is cybersphinx's patch, plus a bit of cleanup, plus adding the cast to signed back, plus duplicating the code to the other place where burn damage is calculated. It is now ready for commit. The |
Zarel commented (No, I will not be committing this fix personally; someone else should commit it, since I am on commit-sabbatical.) |
cybersphinx commented Replying to Warzone2100/old-trac-import#2045 (comment:3):
Because casts are ugly, and it didn't seem to be needed. Is there a reason for burnDamage to be over ~2.000.000.000, which should be interpreted as negative in this case? Maybe there is a reason for it to be negative (do some units heal themselves when they burn?), but then the variable itself should be signed, and not casted. Replying to Warzone2100/old-trac-import#2045 (comment:4):
Minus the testing it seems, since it doesn't compile.
...
But where is the 20 damage done? It looks like it reduces damageToDo by its %20, and then does damageToDo damage. But maybe I just don't understand it, I haven't looked that much at it. |
Zarel uploaded file |
Zarel commented Replying to Warzone2100/old-trac-import#2045 (comment:6):
You don't use signed integers to prevent overflow, you use them to prevent underflow. It's unlikely that burnDamage would be over 2 billion. It's certainly possible that burnDamage could go negative. The fact that Pumpkin casted to signed suggests that there may have been at least one such underflow bug, and even if it were fixed, a future commit could reintroduce such a problem. Remove it if you want.
Gah, uploaded the wrong patch.
Reducing damageToDo by its So (for some theoretical extremely high damage burn) damageToDo will look something like:
|
cybersphinx commented Replying to Warzone2100/old-trac-import#2045 (comment:7):
I don't see how, it's either set to zero or increased by damageToDo when that is positive. |
the_cybersphinx changed status from |
the_cybersphinx changed resolution from `` to |
the_cybersphinx commented (In [11393]) Really fix burn damage calculations. Closes #2045. |
keyword_Burn_damage
resolution_fixed
type_bug
| by fjodorvanveen@...The very same problem as last time. I was using cheats in an 8 player map, I played against 7 hard enemies all in team G. Screenshot seems irrelevant, just like last time. The enemies incendiary mortar kills all units in one shot, as well as it's fire.
Issue migrated from trac:2045 at 2022-04-15 22:11:16 -0700
The text was updated successfully, but these errors were encountered: