[wesnoth-commits] [wesnoth/wesnoth] 77da93: Fix a rare crash in attack prediction
Jyrki Vesterinen
noreply at github.com
Sat May 11 20:26:43 UTC 2019
Branch: refs/heads/master
Home: https://github.com/wesnoth/wesnoth
Commit: 77da93cbf2a5686f4107b732780069de6506c2e7
https://github.com/wesnoth/wesnoth/commit/77da93cbf2a5686f4107b732780069de6506c2e7
Author: Jyrki Vesterinen <sandgtx at gmail.com>
Date: 2019-05-11 (Sat, 11 May 2019)
Changed paths:
M src/attack_prediction.cpp
Log Message:
-----------
Fix a rare crash in attack prediction
The crash occurred if
* the AI simulated three fights for a unit in a row
* the unit was initially slowed
* the unit had a chance of killing the attacking unit in the first
fight, removing the slow status
* the second fight was NOT simulated with Monte Carlo mode...
* ...and the third fight was.
It was my mistake from commit d83e0176. I hadn't understood the meaning
of those two function parameters correctly. They don't need to be set to
true if the target unit is already slowed... and, in fact, they must not
be set to true if the attacking unit doesn't slow.
What happened here is that the combat matrix thought that the attacker's
attack slowed the defending unit, placing the result of some of
attacker's hits in the wrong plane. Meanwhile the calculation about the
probability that the defending unit is slowed produced the correct
result. In the next battle, when Monte Carlo mode scaled the "not
slowed" HP distribution with the probability of not being slowed, it
detected the severe discrepancy (in the example case, probabilities only
added up to 12,5 % instead of 100 %) and crashed the game.
This commit fixes the issue by passing correct parameter values.
Fixes #4068.
More information about the Commits
mailing list