diff --git a/src/common/gamecode/laws.c b/src/common/gamecode/laws.c index fc59b2a62..fb1b99aa3 100644 --- a/src/common/gamecode/laws.c +++ b/src/common/gamecode/laws.c @@ -153,7 +153,12 @@ checkorders(void) if (f->no!=MONSTER_FACTION && turn - f->lastorders == NMRTimeout() - 1) ADDMSG(&f->msgs, msg_message("turnreminder", "")); } -/* ------------------------------------------------------------- */ +static boolean +help_money(const unit * u) +{ + if (u->race->ec_flags & GIVEITEM) return true; + return false; +} static void get_food(region *r) @@ -176,17 +181,17 @@ get_food(region *r) if (need > 0) { unit *v; - for (v = r->units; need && v; v = v->next) - if (v->faction == u->faction && !is_monstrous(v)) { - int give = get_money(v) - lifestyle(v); - give = max(0, give); - give = min(need, give); - if (give) { - change_money(v, -give); - change_money(u, give); - need -= give; - } - } + for (v = r->units; need && v; v = v->next) { + if (v->faction == u->faction && help_money(v)) { + int give = get_money(v) - lifestyle(v); + give = min(need, give); + if (give>0) { + change_money(v, -give); + change_money(u, give); + need -= give; + } + } + } } } @@ -194,6 +199,7 @@ get_food(region *r) * entsprechend verteilt. */ for (u = r->units; u; u = u->next) { int need = lifestyle(u); + faction * f = u->faction; need -= max(0, get_money(u)); @@ -201,13 +207,11 @@ get_food(region *r) unit *v; for (v = r->units; need && v; v = v->next) { - if (v->faction != u->faction && alliedunit(v, u->faction, HELP_MONEY) - && !is_monstrous(v)) { - int give = lifestyle(v); - give = max(0, get_money(v) - give); + if (v->faction != f && alliedunit(v, f, HELP_MONEY) && help_money(v)) { + int give = get_money(v) - lifestyle(v); give = min(need, give); - if (give) { + if (give>0) { change_money(v, -give); change_money(u, give); need -= give; @@ -288,36 +292,35 @@ get_food(region *r) static void live(region * r) { - unit *u, *un; + unit **up = &r->units; get_food(r); - for (u = r->units; u; u = un) { + while (*up) { + unit * u = *up; /* IUW: age_unit() kann u löschen, u->next ist dann * undefiniert, also müssen wir hier schon das nächste * Element bestimmen */ - un = u->next; - if (!is_monstrous(u)) { - int effect = get_effect(u, oldpotiontype[P_FOOL]); - if (effect > 0) { /* Trank "Dumpfbackenbrot" */ - skill * sv = u->skills, * sb = NULL; - while (sv!=u->skills+u->skill_size) { - if (sb==NULL || skill_compare(sv, sb)>0) { - sb = sv; - } - ++sv; - } /* bestes Talent raussuchen */ - if (sb!=NULL) { - int weeks = min(effect, u->number); - reduce_skill(u, sb, weeks); - ADDMSG(&u->faction->msgs, msg_message("dumbeffect", - "unit weeks skill", u, weeks, (skill_t)sb->id)); - } /* sonst Glück gehabt: wer nix weiß, kann nix vergessen... */ - change_effect(u, oldpotiontype[P_FOOL], -effect); - } + int effect = get_effect(u, oldpotiontype[P_FOOL]); + if (effect > 0) { /* Trank "Dumpfbackenbrot" */ + skill * sv = u->skills, * sb = NULL; + while (sv!=u->skills+u->skill_size) { + if (sb==NULL || skill_compare(sv, sb)>0) { + sb = sv; + } + ++sv; + } /* bestes Talent raussuchen */ + if (sb!=NULL) { + int weeks = min(effect, u->number); + reduce_skill(u, sb, weeks); + ADDMSG(&u->faction->msgs, msg_message("dumbeffect", + "unit weeks skill", u, weeks, (skill_t)sb->id)); + } /* sonst Glück gehabt: wer nix weiß, kann nix vergessen... */ + change_effect(u, oldpotiontype[P_FOOL], -effect); } - age_unit(r, u); + age_unit(r, u); + if (*up==u) up=&u->next; } } diff --git a/src/common/kernel/eressea.c b/src/common/kernel/eressea.c index 1947f5f3e..134d28038 100644 --- a/src/common/kernel/eressea.c +++ b/src/common/kernel/eressea.c @@ -2590,7 +2590,7 @@ lifestyle(const unit * u) static plane * astralspace = NULL; int need; - if(is_monstrous(u)) return 0; + if (u->faction->no == MONSTER_FACTION) return 0; need = u->number * u->race->maintenance; diff --git a/src/common/kernel/group.c b/src/common/kernel/group.c index d2a21421c..e690af7af 100644 --- a/src/common/kernel/group.c +++ b/src/common/kernel/group.c @@ -42,7 +42,6 @@ new_group(faction * f, const char * name, int gid) group ** gp = &f->groups; int index = gid % GMAXHASH; group * g = calloc(sizeof(group), 1); - attrib *a; while (*gp) gp = &(*gp)->next; *gp = g; diff --git a/src/common/kernel/unit.c b/src/common/kernel/unit.c index bd49f8b5e..0ee9a43b6 100644 --- a/src/common/kernel/unit.c +++ b/src/common/kernel/unit.c @@ -1085,12 +1085,6 @@ invisible(const unit *u) #endif } -boolean -is_monstrous(const unit * u) -{ - return (boolean) (u->faction->no == MONSTER_FACTION || !playerrace(u->race)); -} - void unitlist_clear(struct unit_list **ul) { diff --git a/src/common/kernel/unit.h b/src/common/kernel/unit.h index 7914a112e..871467c4a 100644 --- a/src/common/kernel/unit.h +++ b/src/common/kernel/unit.h @@ -192,8 +192,6 @@ extern boolean learn_skill(struct unit * u, skill_t sk, double chance); extern int invisible(const unit *u); -extern boolean is_monstrous(const unit * u); - #ifdef __cplusplus } #endif