forked from github/server
- versorgung durch vertraute gefixt - is_monstrous entfernt, und sinnvoll ersetzt.
This commit is contained in:
parent
f413603e0f
commit
4ad249acc6
|
@ -153,7 +153,12 @@ checkorders(void)
|
||||||
if (f->no!=MONSTER_FACTION && turn - f->lastorders == NMRTimeout() - 1)
|
if (f->no!=MONSTER_FACTION && turn - f->lastorders == NMRTimeout() - 1)
|
||||||
ADDMSG(&f->msgs, msg_message("turnreminder", ""));
|
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
|
static void
|
||||||
get_food(region *r)
|
get_food(region *r)
|
||||||
|
@ -176,17 +181,17 @@ get_food(region *r)
|
||||||
if (need > 0) {
|
if (need > 0) {
|
||||||
unit *v;
|
unit *v;
|
||||||
|
|
||||||
for (v = r->units; need && v; v = v->next)
|
for (v = r->units; need && v; v = v->next) {
|
||||||
if (v->faction == u->faction && !is_monstrous(v)) {
|
if (v->faction == u->faction && help_money(v)) {
|
||||||
int give = get_money(v) - lifestyle(v);
|
int give = get_money(v) - lifestyle(v);
|
||||||
give = max(0, give);
|
give = min(need, give);
|
||||||
give = min(need, give);
|
if (give>0) {
|
||||||
if (give) {
|
change_money(v, -give);
|
||||||
change_money(v, -give);
|
change_money(u, give);
|
||||||
change_money(u, give);
|
need -= give;
|
||||||
need -= give;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +199,7 @@ get_food(region *r)
|
||||||
* entsprechend verteilt. */
|
* entsprechend verteilt. */
|
||||||
for (u = r->units; u; u = u->next) {
|
for (u = r->units; u; u = u->next) {
|
||||||
int need = lifestyle(u);
|
int need = lifestyle(u);
|
||||||
|
faction * f = u->faction;
|
||||||
|
|
||||||
need -= max(0, get_money(u));
|
need -= max(0, get_money(u));
|
||||||
|
|
||||||
|
@ -201,13 +207,11 @@ get_food(region *r)
|
||||||
unit *v;
|
unit *v;
|
||||||
|
|
||||||
for (v = r->units; need && v; v = v->next) {
|
for (v = r->units; need && v; v = v->next) {
|
||||||
if (v->faction != u->faction && alliedunit(v, u->faction, HELP_MONEY)
|
if (v->faction != f && alliedunit(v, f, HELP_MONEY) && help_money(v)) {
|
||||||
&& !is_monstrous(v)) {
|
int give = get_money(v) - lifestyle(v);
|
||||||
int give = lifestyle(v);
|
|
||||||
give = max(0, get_money(v) - give);
|
|
||||||
give = min(need, give);
|
give = min(need, give);
|
||||||
|
|
||||||
if (give) {
|
if (give>0) {
|
||||||
change_money(v, -give);
|
change_money(v, -give);
|
||||||
change_money(u, give);
|
change_money(u, give);
|
||||||
need -= give;
|
need -= give;
|
||||||
|
@ -288,36 +292,35 @@ get_food(region *r)
|
||||||
static void
|
static void
|
||||||
live(region * r)
|
live(region * r)
|
||||||
{
|
{
|
||||||
unit *u, *un;
|
unit **up = &r->units;
|
||||||
|
|
||||||
get_food(r);
|
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
|
/* IUW: age_unit() kann u löschen, u->next ist dann
|
||||||
* undefiniert, also müssen wir hier schon das nächste
|
* undefiniert, also müssen wir hier schon das nächste
|
||||||
* Element bestimmen */
|
* Element bestimmen */
|
||||||
un = u->next;
|
|
||||||
|
|
||||||
if (!is_monstrous(u)) {
|
int effect = get_effect(u, oldpotiontype[P_FOOL]);
|
||||||
int effect = get_effect(u, oldpotiontype[P_FOOL]);
|
if (effect > 0) { /* Trank "Dumpfbackenbrot" */
|
||||||
if (effect > 0) { /* Trank "Dumpfbackenbrot" */
|
skill * sv = u->skills, * sb = NULL;
|
||||||
skill * sv = u->skills, * sb = NULL;
|
while (sv!=u->skills+u->skill_size) {
|
||||||
while (sv!=u->skills+u->skill_size) {
|
if (sb==NULL || skill_compare(sv, sb)>0) {
|
||||||
if (sb==NULL || skill_compare(sv, sb)>0) {
|
sb = sv;
|
||||||
sb = sv;
|
}
|
||||||
}
|
++sv;
|
||||||
++sv;
|
} /* bestes Talent raussuchen */
|
||||||
} /* bestes Talent raussuchen */
|
if (sb!=NULL) {
|
||||||
if (sb!=NULL) {
|
int weeks = min(effect, u->number);
|
||||||
int weeks = min(effect, u->number);
|
reduce_skill(u, sb, weeks);
|
||||||
reduce_skill(u, sb, weeks);
|
ADDMSG(&u->faction->msgs, msg_message("dumbeffect",
|
||||||
ADDMSG(&u->faction->msgs, msg_message("dumbeffect",
|
"unit weeks skill", u, weeks, (skill_t)sb->id));
|
||||||
"unit weeks skill", u, weeks, (skill_t)sb->id));
|
} /* sonst Glück gehabt: wer nix weiß, kann nix vergessen... */
|
||||||
} /* sonst Glück gehabt: wer nix weiß, kann nix vergessen... */
|
change_effect(u, oldpotiontype[P_FOOL], -effect);
|
||||||
change_effect(u, oldpotiontype[P_FOOL], -effect);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
age_unit(r, u);
|
age_unit(r, u);
|
||||||
|
if (*up==u) up=&u->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2590,7 +2590,7 @@ lifestyle(const unit * u)
|
||||||
static plane * astralspace = NULL;
|
static plane * astralspace = NULL;
|
||||||
int need;
|
int need;
|
||||||
|
|
||||||
if(is_monstrous(u)) return 0;
|
if (u->faction->no == MONSTER_FACTION) return 0;
|
||||||
|
|
||||||
need = u->number * u->race->maintenance;
|
need = u->number * u->race->maintenance;
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,6 @@ new_group(faction * f, const char * name, int gid)
|
||||||
group ** gp = &f->groups;
|
group ** gp = &f->groups;
|
||||||
int index = gid % GMAXHASH;
|
int index = gid % GMAXHASH;
|
||||||
group * g = calloc(sizeof(group), 1);
|
group * g = calloc(sizeof(group), 1);
|
||||||
attrib *a;
|
|
||||||
|
|
||||||
while (*gp) gp = &(*gp)->next;
|
while (*gp) gp = &(*gp)->next;
|
||||||
*gp = g;
|
*gp = g;
|
||||||
|
|
|
@ -1085,12 +1085,6 @@ invisible(const unit *u)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean
|
|
||||||
is_monstrous(const unit * u)
|
|
||||||
{
|
|
||||||
return (boolean) (u->faction->no == MONSTER_FACTION || !playerrace(u->race));
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
unitlist_clear(struct unit_list **ul)
|
unitlist_clear(struct unit_list **ul)
|
||||||
{
|
{
|
||||||
|
|
|
@ -192,8 +192,6 @@ extern boolean learn_skill(struct unit * u, skill_t sk, double chance);
|
||||||
|
|
||||||
extern int invisible(const unit *u);
|
extern int invisible(const unit *u);
|
||||||
|
|
||||||
extern boolean is_monstrous(const unit * u);
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue