CID 26254: Incorrect expression (DIVIDE_BY_ZERO)

magic should never be zero, but coverity doesn't know that.
This commit is contained in:
Enno Rehling 2015-10-29 16:46:43 +01:00
parent 7a01b58e8d
commit 6113bc2144
1 changed files with 6 additions and 5 deletions

View File

@ -1281,19 +1281,20 @@ bool fumble(region * r, unit * u, const spell * sp, int cast_grade)
* 20% Warscheinlichkeit nicht * 20% Warscheinlichkeit nicht
* */ * */
int rnd = 0; int fumble_chance, rnd = 0;
double x = (double)cast_grade / (double)effskill(u, SK_MAGIC, r); int effsk = effskill(u, SK_MAGIC, r);
int fumble_chance = (int)(((double)x * 40.0) - 20.0);
struct building *b = inside_building(u); struct building *b = inside_building(u);
const struct building_type *btype = b ? b->type : NULL; const struct building_type *btype = b ? b->type : NULL;
int fumble_enabled = get_param_int(global.parameters, "magic.fumble.enable", 1); int fumble_enabled = get_param_int(global.parameters, "magic.fumble.enable", 1);
sc_mage * mage; sc_mage * mage;
if (!fumble_enabled) { if (effsk<=0 || !fumble_enabled) {
return false; return false;
} }
if (btype) fumble_chance = (int)((cast_grade * 40.0 / (double)effsk) - 20.0);
if (btype) {
fumble_chance -= btype->fumblebonus; fumble_chance -= btype->fumblebonus;
}
/* CHAOSPATZERCHANCE 10 : +10% Chance zu Patzern */ /* CHAOSPATZERCHANCE 10 : +10% Chance zu Patzern */
mage = get_mage(u); mage = get_mage(u);