bugfix make_side

This commit is contained in:
Enno Rehling 2007-01-31 15:28:51 +00:00
parent b116026d1d
commit 622d0d496e
2 changed files with 15 additions and 6 deletions

View File

@ -290,14 +290,15 @@ static void
set_enemy(side * as, side * ds, boolean attacking) set_enemy(side * as, side * ds, boolean attacking)
{ {
int i; int i;
for (i=0;i!=128;++i) { for (i=0;i!=MAXSIDES;++i) {
if (ds->enemies[i]==NULL) ds->enemies[i]=as; if (ds->enemies[i]==NULL) ds->enemies[i]=as;
if (ds->enemies[i]==as) break; if (ds->enemies[i]==as) break;
} }
for (i=0;i!=128;++i) { for (i=0;i!=MAXSIDES;++i) {
if (as->enemies[i]==NULL) as->enemies[i]=ds; if (as->enemies[i]==NULL) as->enemies[i]=ds;
if (as->enemies[i]==ds) break; if (as->enemies[i]==ds) break;
} }
assert(i!=MAXSIDES);
ds->relations[as->index] |= E_ENEMY; ds->relations[as->index] |= E_ENEMY;
as->relations[ds->index] |= E_ENEMY; as->relations[ds->index] |= E_ENEMY;
if (attacking) as->relations[ds->index] |= E_ATTACKING; if (attacking) as->relations[ds->index] |= E_ATTACKING;
@ -2236,6 +2237,7 @@ make_side(battle * b, const faction * f, const group * g, unsigned int flags, co
s1->nextF = bf->sides; s1->nextF = bf->sides;
bf->sides = s1; bf->sides = s1;
++b->nsides; ++b->nsides;
assert(b->nsides<=MAXSIDES);
break; break;
} }
} }
@ -2901,7 +2903,14 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
if (s1==NULL) { if (s1==NULL) {
for (s2 = b->sides; s2; s2 = s2->next) { for (s2 = b->sides; s2; s2 = s2->next) {
if (s2->bf->faction == u->faction && s2->group==g) { if (s2->bf->faction == u->faction && s2->group==g) {
if (s2->flags==flags && s2->stealthfaction==stealthfaction) { #ifdef SIMPLE_COMBAT
int s1flags = flags|SIDE_HASGUARDS;
int s2flags = s2->flags|SIDE_HASGUARDS;
#else
int s1flags = flags;
int s2flags = s2->flags;
#endif
if (s1flags==s2flags && s2->stealthfaction==stealthfaction) {
s1 = s2; s1 = s2;
break; break;
} }

View File

@ -36,7 +36,7 @@ extern "C" {
#define FLEE_ROW 4 #define FLEE_ROW 4
#define LAST_ROW (NUMROWS-1) #define LAST_ROW (NUMROWS-1)
#define FIRST_ROW FIGHT_ROW #define FIRST_ROW FIGHT_ROW
#define MAXSIDES 256 /* if there are ever more than this, we're fucked. */ #define MAXSIDES 128 /* if there are ever more than this, we're fucked. */
struct message; struct message;
@ -91,8 +91,8 @@ extern "C" {
# define E_ENEMY 1 # define E_ENEMY 1
# define E_FRIEND 2 # define E_FRIEND 2
# define E_ATTACKING 4 # define E_ATTACKING 4
unsigned char relations[128]; unsigned char relations[MAXSIDES];
struct side * enemies[128]; struct side * enemies[MAXSIDES];
struct fighter * fighters; struct fighter * fighters;
int index; /* Eintrag der Fraktion in b->matrix/b->enemies */ int index; /* Eintrag der Fraktion in b->matrix/b->enemies */
int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */ int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */