- versorgung durch vertraute gefixt
- is_monstrous entfernt, und sinnvoll ersetzt.
This commit is contained in:
Enno Rehling 2004-03-09 21:14:27 +00:00
parent f413603e0f
commit 4ad249acc6
5 changed files with 43 additions and 49 deletions

View File

@ -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;
}
}

View File

@ -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;

View File

@ -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;

View File

@ -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)
{

View File

@ -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