diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index 720d690b7..7b7acc3cd 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: item.c,v 1.10 2001/02/13 02:58:51 enno Exp $ + * $Id: item.c,v 1.11 2001/02/14 07:44:57 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -1288,7 +1288,7 @@ init_olditems(void) for (i=0; i!=MAXITEMS; ++i) { int iflags = ITF_NONE; - int rflags = RTF_ITEM; + int rflags = RTF_ITEM|RTF_POOLED; int m, n; const char * name[2]; const char * appearance[2]; @@ -1494,7 +1494,7 @@ init_oldherbs(void) names[1] = reverse_lookup(NULL, herbdata[1][h]); } - rtype = new_resourcetype(names, appearance, RTF_ITEM); + rtype = new_resourcetype(names, appearance, RTF_ITEM|RTF_POOLED); itype = new_itemtype(rtype, ITF_HERB, 0, 0, 0, NOSKILL); t = (terrain_t)(h/3+1); @@ -1894,7 +1894,7 @@ init_oldpotions(void) names[1] = reverse_lookup(NULL, potionnames[1][p]); } - rtype = new_resourcetype(names, appearance, RTF_ITEM); + rtype = new_resourcetype(names, appearance, RTF_ITEM|RTF_POOLED); if (p==P_FOOL) rtype->flags |= RTF_SNEAK; oldresourcetype[potion2res(p)] = rtype; itype = new_itemtype(rtype, ITF_POTION, 0, 0, 0, NOSKILL); @@ -1925,7 +1925,7 @@ void init_resources(void) { /* silver was never an item: */ - r_silver = new_resourcetype(&names[0], NULL, RTF_ITEM); + r_silver = new_resourcetype(&names[0], NULL, RTF_ITEM|RTF_POOLED); i_silver = new_itemtype(r_silver, ITF_NONE, 1/*weight*/, 0, 0, NOSKILL); r_silver->uchange = res_changeitem; diff --git a/src/common/kernel/item.h b/src/common/kernel/item.h index aa63ec357..3cfe25405 100644 --- a/src/common/kernel/item.h +++ b/src/common/kernel/item.h @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: item.h,v 1.4 2001/02/13 02:58:51 enno Exp $ + * $Id: item.h,v 1.5 2001/02/14 07:44:57 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -36,6 +36,7 @@ typedef struct item { #define RTF_LIMITED (1<<2) /* a resource that's freely available, but in * limited supply */ #define RTF_DYNAMIC (1<<3) /* dynamic type, must be saved */ +#define RTF_POOLED (1<<4) /* resource is available in pool */ #undef AT_ITYPE /* should resource_type use an attribute for items ? */ #undef AT_HTYPE /* should resource_type use an attribute for herbs ? */ diff --git a/src/common/kernel/movement.c b/src/common/kernel/movement.c index 0a1041691..0dda8f7fb 100644 --- a/src/common/kernel/movement.c +++ b/src/common/kernel/movement.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: movement.c,v 1.8 2001/02/09 13:53:51 corwin Exp $ + * $Id: movement.c,v 1.9 2001/02/14 07:44:57 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -1945,7 +1945,6 @@ void movement(void) { region *r; - unit *u; /* Initialize the additional encumbrance by transported units */ #ifdef NEW_DRIVE @@ -1953,7 +1952,7 @@ movement(void) #endif for (r = regions; r; r = r->next) { - + unit ** up = &r->units; /* Bewegungen. * * Zuerst müssen sich alle Einheiten ohne u->target bewegen @@ -1963,31 +1962,38 @@ movement(void) * neue NEW_FOLLOW-Variante: Verfolger folgen sofort, FL_FOLLOW * ist bereits gesetzt. */ - for (u = r->units; u;) { - unit *un = u->next; + while (*up) { + unit *u = *up; + keyword_t kword; - if (!fval(u,FL_FOLLOWING) - && (igetkeyword(u->thisorder) == K_ROUTE || - igetkeyword(u->thisorder) == K_MOVE)) - { + if (fval(u, FL_FOLLOWING)) { + /* skip all followers */ + do { + u = u->next; + } while (u && fval(u, FL_FOLLOWING)); + up = &u; + if (u==NULL) break; + } + kword = igetkeyword(u->thisorder); + switch (kword) { + case K_ROUTE: + case K_MOVE: if (attacked(u)) { cmistake(u, findorder(u, u->thisorder), 52, MSG_MOVE); set_string(&u->thisorder, ""); - u = un; + up = &u->next; } else if (race[u->race].flags & RCF_CANNOTMOVE) { cmistake(u, findorder(u, u->thisorder), 55, MSG_MOVE); set_string(&u->thisorder, ""); - u = un; + up = &u->next; } else { move(r, u, true); set_string(&u->thisorder, ""); - /* Nach einer Bewegung muß die Schleife von vorn durchlaufen - * werden, sonst bringen Schiffe die Schleife durcheinander, - * weil u->next sich evt. mitbewegt hat. */ - u = r->units; + if (u==*up) up = &u->next; } - } else { - u = un; + break; + default: + up = &u->next; } } } @@ -1996,6 +2002,7 @@ movement(void) * bewegen sich. */ for (r = regions; r; r = r->next) { + unit * u; for (u = r->units; u;) { unit *u2 = u->next; strlist *o; @@ -2033,6 +2040,7 @@ movement(void) /* Reguläre Verfolger starten */ for (r = regions; r; r = r->next) { + unit * u; for (u = r->units; u;) { unit * u2 = u->next; if (utarget(u) @@ -2056,6 +2064,7 @@ movement(void) /* Piraten und Cleanup */ for (r = regions; r; r = r->next) { + unit * u; for(u = r->units; u;) { unit *un = u->next; if(igetkeyword(u->thisorder) == K_PIRACY) piracy(u); diff --git a/src/common/kernel/pool.c b/src/common/kernel/pool.c index 178fda8f9..c94ddb514 100644 --- a/src/common/kernel/pool.c +++ b/src/common/kernel/pool.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: pool.c,v 1.4 2001/02/13 00:41:15 enno Exp $ + * $Id: pool.c,v 1.5 2001/02/14 07:44:57 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -174,7 +174,7 @@ new_get_pooled(const unit * u, const resource_type * rtype, int mode) if (mode & GET_RESERVE) use = have-slack; else if (mode & GET_SLACK) use = slack; } - if (mode & ~(GET_SLACK|GET_RESERVE)) { + if (rtype->flags & RTF_POOLED && mode & ~(GET_SLACK|GET_RESERVE)) { for (v = r->units; v; v = v->next) if (u!=v) { int mask; @@ -225,7 +225,7 @@ new_use_pooled(unit * u, const resource_type * rtype, int mode, int count) use -= n; } - if (mode & ~(GET_SLACK|GET_RESERVE)) { + if (rtype->flags & RTF_POOLED && mode & ~(GET_SLACK|GET_RESERVE)) { for (v = r->units; v; v = v->next) if (u!=v) { int mask; if (urace(v)->ec_flags & NOGIVE) continue; diff --git a/src/common/util/attrib.c b/src/common/util/attrib.c index c2ead0e6e..2b003e4d6 100644 --- a/src/common/util/attrib.c +++ b/src/common/util/attrib.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: attrib.c,v 1.3 2001/01/27 18:15:32 enno Exp $ + * $Id: attrib.c,v 1.4 2001/02/14 07:44:57 enno Exp $ * Eressea PB(E)M host Copyright (C) 1998-2000 * Christian Schlittchen (corwin@amber.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de) @@ -77,16 +77,15 @@ at_find(unsigned int hk) attrib * a_select(attrib * a, void * data, boolean(*compare)(const attrib *, void *)) { - attrib * find = a; - while (find && !compare(find, data)) find = find->next; - return find; + while (a && !compare(a, data)) a = a->next; + return a; } attrib * -a_find(attrib * a, const attrib_type * at) { - attrib * find = a; - while (find && find->type!=at) find = find->next; - return find; +a_find(attrib * a, const attrib_type * at) +{ + while (a && a->type!=at) a = a->next; + return a; } attrib *