diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index a75cc21dc..3c5770042 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: battle.c,v 1.11 2001/02/11 08:55:30 enno Exp $ + * $Id: battle.c,v 1.12 2001/02/14 01:38:50 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) @@ -295,15 +295,30 @@ fbattlerecord(faction * f, region * r, const char *s) boolean enemy(const side * as, const side * ds) { +#ifdef FASTENEMY + switch(as->enemy[ds->index]) { + case E_ENEMY: + case E_ENEMY|E_ATTACKING: + return true; + default: + return false; + } +#else const struct enemy * e = as->enemies[ds->index % 16]; while (e && e->side!=ds) e=e->nexthash; if (e) return true; return false; +#endif } static void set_enemy(side * as, side * ds, boolean attacking) { +#ifdef FASTENEMY + ds->enemy[as->index] |= E_ENEMY; + as->enemy[ds->index] |= E_ENEMY; + if (attacking) as->enemy[ds->index] |= E_ATTACKING; +#else struct enemy * e = as->enemies[ds->index % 16]; while (e && e->side!=ds) e=e->nexthash; if (e==NULL) { @@ -319,6 +334,7 @@ set_enemy(side * as, side * ds, boolean attacking) ds->enemies[as->index % 16] = e; } else e->attacking |= attacking; +#endif } extern int alliance(const ally * sf, const faction * f, int mode); @@ -2522,7 +2538,9 @@ print_stats(battle * b) for (bf=b->factions;bf;bf=bf->next) { faction * f = bf->faction; +#ifndef FASTENEMY struct enemy * e; +#endif fbattlerecord(f, b->region, " "); sprintf(buf, "Heer %d: %s", side->index, seematrix(f, side) @@ -2546,6 +2564,20 @@ print_stats(battle * b) fbattlerecord(f, b->region, buf); strcpy(buf, "Attacke gegen:"); komma = false; +#ifdef FASTENEMY + for_each(s2, b->sides) { + if (side->enemy[s2->index] & E_ATTACKING) { + if (seematrix(f, s2) == true) { + sprintf(buf, "%s%s Heer %d(%s)", buf, komma++ ? "," : "", + s2->index, abkz(s2->bf->faction->name, 3)); + } else { + sprintf(buf, "%s%s Heer %d(Unb)", buf, komma++ ? "," : "", + s2->index); + } + } + } + next(s2); +#else for (i=0;i!=16;i++) for (e=side->enemies[i]; e; e=e->nexthash) if (e->attacking) { struct side * s2 = e->side; @@ -2557,6 +2589,7 @@ print_stats(battle * b) s2->index); } } +#endif fbattlerecord(f, b->region, buf); } buf[77] = (char)0; @@ -2964,12 +2997,14 @@ make_battle(region * r) static void free_side(side * si) { +#ifndef FASTENEMY int i; for (i=0;i!=16;++i) while (si->enemies[i]) { struct enemy * e = si->enemies[i]->nexthash; free(si->enemies[i]); si->enemies[i] = e; } +#endif cv_kill(&si->fighters); } diff --git a/src/common/kernel/battle.h b/src/common/kernel/battle.h index bc8d8beb5..cea2436f5 100644 --- a/src/common/kernel/battle.h +++ b/src/common/kernel/battle.h @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: battle.h,v 1.2 2001/01/26 16:19:39 enno Exp $ + * $Id: battle.h,v 1.3 2001/02/14 01:38:50 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) @@ -65,14 +65,19 @@ typedef struct side { struct battle * battle; struct faction *faction; /* Die Partei, die hier kämpft */ struct bfaction * bf; /* Die Partei, die hier kämpft */ -#ifdef GROUPS const struct group * group; -#endif +#define FASTENEMY +#ifdef FASTENEMY +# define E_ENEMY 1 +# define E_ATTACKING 2 + int enemy[128]; +#else struct enemy { struct enemy * nexthash; boolean attacking; struct side * side; } * enemies[16]; +#endif cvector fighters; /* vector der Einheiten dieser Fraktion */ int index; /* Eintrag der Fraktion in b->matrix/b->enemies */ int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */ diff --git a/src/common/kernel/message.c b/src/common/kernel/message.c index c3fbb4dea..e15bec16c 100644 --- a/src/common/kernel/message.c +++ b/src/common/kernel/message.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: message.c,v 1.6 2001/02/11 20:54:01 enno Exp $ + * $Id: message.c,v 1.7 2001/02/14 01:38:50 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) @@ -195,6 +195,30 @@ mistake(const unit * u, const char *command, const char *comment, int mtype) static messagetype * messagetypes; +extern unsigned int new_hashstring(const char* s); + +int +old_hashstring(const char* s) +{ + int key = 0; + int i = strlen(s); + while (i) { + --i; + key = ((key >> 31) & 1) ^ (key << 1) ^ s[i]; + } + return key & 0x7fff; +} + + +void +debug_messagetypes(FILE * out) +{ + messagetype * mt; + for (mt=messagetypes;mt;mt=mt->next) { + fprintf(out, "%ut%u\n", old_hashstring(mt->name), mt->hashkey); + } +} + messagetype * new_messagetype(const char * name, int level, const char * section) { diff --git a/src/common/util/goodies.c b/src/common/util/goodies.c index ac95d0e85..7b393b495 100644 --- a/src/common/util/goodies.c +++ b/src/common/util/goodies.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: goodies.c,v 1.6 2001/02/11 20:54:01 enno Exp $ + * $Id: goodies.c,v 1.7 2001/02/14 01:38:50 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) @@ -66,7 +66,7 @@ hashstring(const char* s) while (i>0) { key = (s[--i] + key*37); } - return key; + return key % 0x7FFFFFFF; } char * diff --git a/src/eressea-6.opt b/src/eressea-6.opt index 5d1ac37d3..87d1647fe 100644 Binary files a/src/eressea-6.opt and b/src/eressea-6.opt differ diff --git a/src/eressea/main.c b/src/eressea/main.c index 0357c692d..c4598d811 100644 --- a/src/eressea/main.c +++ b/src/eressea/main.c @@ -1,6 +1,6 @@ /* vi: set ts=2: * - * $Id: main.c,v 1.15 2001/02/12 22:39:57 enno Exp $ + * $Id: main.c,v 1.16 2001/02/14 01:38:51 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) @@ -119,6 +119,7 @@ print_potions(FILE * F) static char * orders = NULL; static int nowrite = 0; +extern void debug_messagetypes(FILE * out); static void game_init(void) @@ -137,7 +138,15 @@ game_init(void) init_museum(); init_arena(); init_xmas2000(); +#ifdef REMOVE_THIS render_init(); + { + FILE * F = fopen("messagetypes.txt", "w"); + debug_messagetypes(F); + fclose(F); + abort(); + } +#endif /* print_potions(stdout); exit(0); */ }