fix crash when rules do not define a unicorn item

This commit is contained in:
Enno Rehling 2015-11-03 17:33:44 +01:00
parent 15ff621cbb
commit cc89e9c9da
1 changed files with 5 additions and 4 deletions

View File

@ -1116,7 +1116,6 @@ double magic_resistance(unit * target)
{ {
attrib *a; attrib *a;
curse *c; curse *c;
int n;
const curse_type * ct_goodresist = 0, *ct_badresist = 0; const curse_type * ct_goodresist = 0, *ct_badresist = 0;
const resource_type *rtype; const resource_type *rtype;
double probability = u_race(target)->magres; double probability = u_race(target)->magres;
@ -1133,9 +1132,11 @@ double magic_resistance(unit * target)
/* Unicorn +10 */ /* Unicorn +10 */
rtype = get_resourcetype(R_UNICORN); rtype = get_resourcetype(R_UNICORN);
n = i_get(target->items, rtype->itype); if (rtype) {
if (n) { int n = i_get(target->items, rtype->itype);
probability += n * 0.1 / target->number; if (n) {
probability += n * 0.1 / target->number;
}
} }
/* Auswirkungen von Zaubern auf der Region */ /* Auswirkungen von Zaubern auf der Region */