Merge pull request #72 from badgerman/master

fix two crashes, and undead heroes
This commit is contained in:
Enno Rehling 2014-12-13 20:42:16 +01:00
commit 968304db96
4 changed files with 19 additions and 3 deletions

View File

@ -2719,7 +2719,7 @@ static void aftermath(battle * b)
fset(sh, SF_DAMAGED);
}
if (df->alive == du->number) {
if (df->alive && df->alive == du->number) {
du->hp = sum_hp;
continue; /* nichts passiert */
}

View File

@ -634,7 +634,7 @@ int give_control_cmd(unit * u, order * ord)
getunit(r, u->faction, &u2);
s = getstrtoken();
if (isparam(s, u->faction->locale, P_CONTROL)) {
if (s && isparam(s, u->faction->locale, P_CONTROL)) {
message *msg = 0;
if (!can_give_to(u, u2)) {

View File

@ -459,7 +459,7 @@ damage_unit(unit * u, const char *dam, bool physical, bool magic)
return 0;
}
assert(u->number > u->hp);
assert(u->number <= u->hp);
h = u->hp / u->number;
/* HP verteilen */
for (i = 0; i < u->number; i++)

View File

@ -1737,6 +1737,7 @@ int sp_undeadhero(struct castorder * co)
}
if (j > 0) {
item **ilist;
unit *u =
create_unit(r, mage->faction, 0, get_race(RC_UNDEAD), 0, du->name,
du);
@ -1750,6 +1751,21 @@ int sp_undeadhero(struct castorder * co)
}
setstatus(u, du->status);
setguard(u, GUARD_NONE);
for (ilist = &du->items; *ilist;) {
item *itm = *ilist;
int loot = itm->number * j / du->number;
if (loot != itm->number) {
int split = itm->number * j % du->number;
if (split > 0 && (rng_int() % du->number) < split) {
++loot;
}
}
i_change(&u->items, itm->type, loot);
i_change(ilist, itm->type, -loot);
if (*ilist == itm) {
ilist = &itm->next;
}
}
/* inherit stealth from magician */
if (fval(mage, UFL_ANON_FACTION)) {