forked from github/server
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:
parent
e76ddede60
commit
06cdb2b292
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 ? */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 *
|
||||
|
|
Loading…
Reference in New Issue