Bugfixes:

- resourcetypen haben ein RTF_POOLED flag. Nur wenn es gesetzt ist, kann die resource 
  über den pool benutzt werden. Derzeit für alle item-typen aktiviert, noch was?
- In den rassen-ec_flags gibt es NOGIVE, was vom pool beachtet wird. Die Unterscheidung 
  zu GIVEITEM ist mir, offen gesagt, aber unklar.

Speedups:
- Auswertung in movement schneller, weniger igetkeyword() Aufrufe.
- battle.c schneller
- a_find und a_select, lokale Variablen gestrichen.

Comments:
- Der Server crasht bei mir während Reportgenerierung, wenn er mit Optimierungen 
  kompiliert ist und ich 225 komplett auswerte. Noch keine Ahnung, warum.
This commit is contained in:
Enno Rehling 2001-02-14 07:44:57 +00:00
parent e76ddede60
commit 06cdb2b292
5 changed files with 43 additions and 34 deletions

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -1288,7 +1288,7 @@ init_olditems(void)
for (i=0; i!=MAXITEMS; ++i) { for (i=0; i!=MAXITEMS; ++i) {
int iflags = ITF_NONE; int iflags = ITF_NONE;
int rflags = RTF_ITEM; int rflags = RTF_ITEM|RTF_POOLED;
int m, n; int m, n;
const char * name[2]; const char * name[2];
const char * appearance[2]; const char * appearance[2];
@ -1494,7 +1494,7 @@ init_oldherbs(void)
names[1] = reverse_lookup(NULL, herbdata[1][h]); 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); itype = new_itemtype(rtype, ITF_HERB, 0, 0, 0, NOSKILL);
t = (terrain_t)(h/3+1); t = (terrain_t)(h/3+1);
@ -1894,7 +1894,7 @@ init_oldpotions(void)
names[1] = reverse_lookup(NULL, potionnames[1][p]); 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; if (p==P_FOOL) rtype->flags |= RTF_SNEAK;
oldresourcetype[potion2res(p)] = rtype; oldresourcetype[potion2res(p)] = rtype;
itype = new_itemtype(rtype, ITF_POTION, 0, 0, 0, NOSKILL); itype = new_itemtype(rtype, ITF_POTION, 0, 0, 0, NOSKILL);
@ -1925,7 +1925,7 @@ void
init_resources(void) init_resources(void)
{ {
/* silver was never an item: */ /* 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); i_silver = new_itemtype(r_silver, ITF_NONE, 1/*weight*/, 0, 0, NOSKILL);
r_silver->uchange = res_changeitem; r_silver->uchange = res_changeitem;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.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 #define RTF_LIMITED (1<<2) /* a resource that's freely available, but in
* limited supply */ * limited supply */
#define RTF_DYNAMIC (1<<3) /* dynamic type, must be saved */ #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_ITYPE /* should resource_type use an attribute for items ? */
#undef AT_HTYPE /* should resource_type use an attribute for herbs ? */ #undef AT_HTYPE /* should resource_type use an attribute for herbs ? */

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -1945,7 +1945,6 @@ void
movement(void) movement(void)
{ {
region *r; region *r;
unit *u;
/* Initialize the additional encumbrance by transported units */ /* Initialize the additional encumbrance by transported units */
#ifdef NEW_DRIVE #ifdef NEW_DRIVE
@ -1953,7 +1952,7 @@ movement(void)
#endif #endif
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
unit ** up = &r->units;
/* Bewegungen. /* Bewegungen.
* *
* Zuerst müssen sich alle Einheiten ohne u->target bewegen * 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 * neue NEW_FOLLOW-Variante: Verfolger folgen sofort, FL_FOLLOW
* ist bereits gesetzt. * ist bereits gesetzt.
*/ */
for (u = r->units; u;) { while (*up) {
unit *un = u->next; unit *u = *up;
keyword_t kword;
if (!fval(u,FL_FOLLOWING) if (fval(u, FL_FOLLOWING)) {
&& (igetkeyword(u->thisorder) == K_ROUTE || /* skip all followers */
igetkeyword(u->thisorder) == K_MOVE)) 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)) { if (attacked(u)) {
cmistake(u, findorder(u, u->thisorder), 52, MSG_MOVE); cmistake(u, findorder(u, u->thisorder), 52, MSG_MOVE);
set_string(&u->thisorder, ""); set_string(&u->thisorder, "");
u = un; up = &u->next;
} else if (race[u->race].flags & RCF_CANNOTMOVE) { } else if (race[u->race].flags & RCF_CANNOTMOVE) {
cmistake(u, findorder(u, u->thisorder), 55, MSG_MOVE); cmistake(u, findorder(u, u->thisorder), 55, MSG_MOVE);
set_string(&u->thisorder, ""); set_string(&u->thisorder, "");
u = un; up = &u->next;
} else { } else {
move(r, u, true); move(r, u, true);
set_string(&u->thisorder, ""); set_string(&u->thisorder, "");
/* Nach einer Bewegung muß die Schleife von vorn durchlaufen if (u==*up) up = &u->next;
* werden, sonst bringen Schiffe die Schleife durcheinander,
* weil u->next sich evt. mitbewegt hat. */
u = r->units;
} }
} else { break;
u = un; default:
up = &u->next;
} }
} }
} }
@ -1996,6 +2002,7 @@ movement(void)
* bewegen sich. */ * bewegen sich. */
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
unit * u;
for (u = r->units; u;) { for (u = r->units; u;) {
unit *u2 = u->next; unit *u2 = u->next;
strlist *o; strlist *o;
@ -2033,6 +2040,7 @@ movement(void)
/* Reguläre Verfolger starten */ /* Reguläre Verfolger starten */
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
unit * u;
for (u = r->units; u;) { for (u = r->units; u;) {
unit * u2 = u->next; unit * u2 = u->next;
if (utarget(u) if (utarget(u)
@ -2056,6 +2064,7 @@ movement(void)
/* Piraten und Cleanup */ /* Piraten und Cleanup */
for (r = regions; r; r = r->next) { for (r = regions; r; r = r->next) {
unit * u;
for(u = r->units; u;) { for(u = r->units; u;) {
unit *un = u->next; unit *un = u->next;
if(igetkeyword(u->thisorder) == K_PIRACY) piracy(u); if(igetkeyword(u->thisorder) == K_PIRACY) piracy(u);

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.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; if (mode & GET_RESERVE) use = have-slack;
else if (mode & GET_SLACK) use = 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) { for (v = r->units; v; v = v->next) if (u!=v) {
int mask; int mask;
@ -225,7 +225,7 @@ new_use_pooled(unit * u, const resource_type * rtype, int mode, int count)
use -= n; 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) { for (v = r->units; v; v = v->next) if (u!=v) {
int mask; int mask;
if (urace(v)->ec_flags & NOGIVE) continue; if (urace(v)->ec_flags & NOGIVE) continue;

View File

@ -1,6 +1,6 @@
/* vi: set ts=2: /* 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 * Eressea PB(E)M host Copyright (C) 1998-2000
* Christian Schlittchen (corwin@amber.kn-bremen.de) * Christian Schlittchen (corwin@amber.kn-bremen.de)
* Katja Zedel (katze@felidae.kn-bremen.de) * Katja Zedel (katze@felidae.kn-bremen.de)
@ -77,16 +77,15 @@ at_find(unsigned int hk)
attrib * attrib *
a_select(attrib * a, void * data, boolean(*compare)(const attrib *, void *)) a_select(attrib * a, void * data, boolean(*compare)(const attrib *, void *))
{ {
attrib * find = a; while (a && !compare(a, data)) a = a->next;
while (find && !compare(find, data)) find = find->next; return a;
return find;
} }
attrib * attrib *
a_find(attrib * a, const attrib_type * at) { a_find(attrib * a, const attrib_type * at)
attrib * find = a; {
while (find && find->type!=at) find = find->next; while (a && a->type!=at) a = a->next;
return find; return a;
} }
attrib * attrib *