forked from github/server
Cache Optimizations:
- do prepare_reports simultaneously - make battle-sides more cache-local - avoid dereferencing bfaction for the faction - avoid dereferencing side for the index
This commit is contained in:
parent
ba9e081fdf
commit
81de21fcb8
28 changed files with 313 additions and 261 deletions
|
@ -1730,8 +1730,8 @@ list_address(FILE * F, const faction * uf, const faction_list * seenfactions)
|
|||
char label = '-';
|
||||
|
||||
sprintf(buf, "%s: %s; %s", factionname(f), f->email, f->banner);
|
||||
if (ALLIED(uf, f)) label = '+';
|
||||
else if (alliedfaction(NULL, uf, f, HELP_ALL)) label = '*';
|
||||
if (ALLIED(uf, f)) label = '*';
|
||||
else if (alliedfaction(NULL, uf, f, HELP_ALL)) label = '+';
|
||||
rparagraph(F, buf, 4, 0, label);
|
||||
#ifdef SHORTPWDS
|
||||
if (f->shortpwds) {
|
||||
|
|
|
@ -165,7 +165,7 @@ sidename(side * s)
|
|||
"%s", factionname(s->stealthfaction));
|
||||
} else {
|
||||
snprintf(sidename_buf, SIDENAMEBUFLEN,
|
||||
"%s", factionname(s->bf->faction));
|
||||
"%s", factionname(s->faction));
|
||||
}
|
||||
return sidename_buf;
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ sideabkz(side *s, boolean truename)
|
|||
if (s->stealthfaction && truename == false) {
|
||||
abkz(s->stealthfaction->name, sideabkz_buf, sizeof(sideabkz_buf), 3);
|
||||
} else {
|
||||
abkz(s->bf->faction->name, sideabkz_buf, sizeof(sideabkz_buf), 3);
|
||||
abkz(s->faction->name, sideabkz_buf, sizeof(sideabkz_buf), 3);
|
||||
}
|
||||
return sideabkz_buf;
|
||||
}
|
||||
|
@ -246,8 +246,11 @@ fbattlerecord(battle * b, faction * f, const char *s)
|
|||
msg_release(m);
|
||||
}
|
||||
|
||||
/* being an enemy or a friend is (and must always be!) symmetrical */
|
||||
#define enemy_i(as, di) (as->relations[di]&E_ENEMY)
|
||||
#define friendly_i(as, di) (as->relations[di]&E_FRIEND)
|
||||
#define enemy(as, ds) (as->relations[ds->index]&E_ENEMY)
|
||||
#define friendly(as, ds) (as->bf->faction==ds->bf->faction || (as->relations[ds->index]&E_FRIEND))
|
||||
#define friendly(as, ds) (as->relations[ds->index]&E_FRIEND)
|
||||
|
||||
static boolean
|
||||
set_enemy(side * as, side * ds, boolean attacking)
|
||||
|
@ -284,11 +287,11 @@ set_friendly(side * as, side * ds)
|
|||
static int
|
||||
allysfm(const side * s, const faction * f, int mode)
|
||||
{
|
||||
if (s->bf->faction==f) return mode;
|
||||
if (s->faction==f) return mode;
|
||||
if (s->group) {
|
||||
return alliedgroup(s->battle->plane, s->bf->faction, f, s->group->allies, mode);
|
||||
return alliedgroup(s->battle->plane, s->faction, f, s->group->allies, mode);
|
||||
}
|
||||
return alliedfaction(s->battle->plane, s->bf->faction, f, mode);
|
||||
return alliedfaction(s->battle->plane, s->faction, f, mode);
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -311,17 +314,18 @@ select_corpse(battle * b, fighter * af)
|
|||
*
|
||||
* Untote werden nicht ausgewählt (casualties, not dead) */
|
||||
{
|
||||
int di, maxcasualties = 0;
|
||||
int si, di, maxcasualties = 0;
|
||||
fighter *df;
|
||||
side *s;
|
||||
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
if (af==NULL || (!enemy(af->side, s) && allysf(af->side, s->bf->faction))) {
|
||||
for (si=0;si!=b->nsides;++si) {
|
||||
side * s = b->sides+si;
|
||||
if (af==NULL || (!enemy_i(af->side, si) && allysf(af->side, s->faction))) {
|
||||
maxcasualties += s->casualties;
|
||||
}
|
||||
}
|
||||
di = rng_int() % maxcasualties;
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
for (df=s->fighters;df;df=df->next) {
|
||||
/* Geflohene haben auch 0 hp, dürfen hier aber nicht ausgewählt
|
||||
* werden! */
|
||||
|
@ -343,8 +347,8 @@ select_corpse(battle * b, fighter * af)
|
|||
boolean
|
||||
helping(const side * as, const side * ds)
|
||||
{
|
||||
if (as->bf->faction==ds->bf->faction) return true;
|
||||
return (boolean)(!enemy(as, ds) && allysf(as, ds->bf->faction));
|
||||
if (as->faction==ds->faction) return true;
|
||||
return (boolean)(!enemy(as, ds) && allysf(as, ds->faction));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -397,12 +401,12 @@ get_row(const side * s, int row, const side * vs)
|
|||
int retreat = 0;
|
||||
int size[NUMROWS];
|
||||
int front = 0;
|
||||
battle * b = s->battle;
|
||||
|
||||
memset(counted, 0, sizeof(counted));
|
||||
memset(size, 0, sizeof(size));
|
||||
for (line=FIRST_ROW;line!=NUMROWS;++line) {
|
||||
int si;
|
||||
side *sa;
|
||||
int si, sa_i;
|
||||
/* how many enemies are there in the first row? */
|
||||
for (si=0;s->enemies[si];++si) {
|
||||
side *se = s->enemies[si];
|
||||
|
@ -411,16 +415,17 @@ get_row(const side * s, int row, const side * vs)
|
|||
/* - s->nonblockers[line] (nicht, weil angreifer) */
|
||||
}
|
||||
}
|
||||
for (sa = s->battle->sides; sa; sa=sa->next) {
|
||||
for (sa_i=0; sa_i!=b->nsides; ++sa_i) {
|
||||
side * sa = b->sides+sa_i;
|
||||
/* count people that like me, but don't like my enemy */
|
||||
if (friendly(sa, s) && enemy(sa, vs)) {
|
||||
if (!counted[sa->index]) {
|
||||
if (friendly_i(s, sa_i) && enemy_i(vs, sa_i)) {
|
||||
if (!counted[sa_i]) {
|
||||
int i;
|
||||
|
||||
for (i=0;i!=NUMROWS;++i) {
|
||||
size[i] += sa->size[i] - sa->nonblockers[i];
|
||||
}
|
||||
counted[sa->index] = true;
|
||||
counted[sa_i] = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -744,7 +749,7 @@ meffect_protection(battle * b, meffect * s, side * ds)
|
|||
if (!s->magician->alive) return false;
|
||||
if (s->duration <= 0) return false;
|
||||
if (enemy(s->magician->side, ds)) return false;
|
||||
if (allysf(s->magician->side, ds->bf->faction)) return true;
|
||||
if (allysf(s->magician->side, ds->faction)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -1203,7 +1208,7 @@ count_allies(const side * as, int minrow, int maxrow, int select)
|
|||
side *s;
|
||||
int count = 0;
|
||||
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
if (!helping(as, s)) continue;
|
||||
count += count_side(s, NULL, minrow, maxrow, select);
|
||||
if (count>0 && (select&SELECT_FIND)) break;
|
||||
|
@ -1217,7 +1222,7 @@ count_enemies_i(battle * b, const fighter * af, int minrow, int maxrow, int sele
|
|||
side *es, *as = af->side;
|
||||
int i = 0;
|
||||
|
||||
for (es = b->sides; es; es = es->next) {
|
||||
for (es=b->sides;es!=b->sides+b->nsides;++es) {
|
||||
if (as==NULL || enemy(es, as)) {
|
||||
int offset = 0;
|
||||
if (select&SELECT_DISTANCE) {
|
||||
|
@ -1394,13 +1399,13 @@ fighters(battle *b, const side * vs, int minrow, int maxrow, int mask)
|
|||
assert(vs!=NULL);
|
||||
cv_init(fightervp);
|
||||
|
||||
for (s = b->sides; s; s = s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter *fig;
|
||||
|
||||
if (mask==FS_ENEMY) {
|
||||
if (!enemy(s, vs)) continue;
|
||||
} else if (mask==FS_HELP) {
|
||||
if (enemy(s, vs) || !allysf(s, vs->bf->faction)) {
|
||||
if (enemy(s, vs) || !allysf(s, vs->faction)) {
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
|
@ -1436,7 +1441,7 @@ do_combatmagic(battle *b, combatmagic_t was)
|
|||
|
||||
memset(spellranks, 0, sizeof(spellranks));
|
||||
|
||||
for (s = b->sides; s; s = s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter * fig;
|
||||
for (fig = s->fighters; fig; fig = fig->next) {
|
||||
unit * mage = fig->unit;
|
||||
|
@ -1828,7 +1833,7 @@ damage_building(battle *b, building *bldg, int damage_abs)
|
|||
|
||||
bldg->sizeleft = bldg->size;
|
||||
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter * fig;
|
||||
for (fig=s->fighters;fig;fig=fig->next) {
|
||||
if (fig->building == bldg) {
|
||||
|
@ -1857,7 +1862,7 @@ static void
|
|||
make_heroes(battle * b)
|
||||
{
|
||||
side * s;
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter * fig;
|
||||
for (fig=s->fighters;fig;fig=fig->next) {
|
||||
unit * u = fig->unit;
|
||||
|
@ -2124,20 +2129,18 @@ fleechance(unit * u)
|
|||
return c;
|
||||
}
|
||||
|
||||
static int nextside = 0;
|
||||
|
||||
/** add a new army to the conflict
|
||||
* beware: armies need to be added _at the beginning_ of the list because
|
||||
* otherwise join_allies() will get into trouble */
|
||||
static side *
|
||||
make_side(battle * b, const faction * f, const group * g, unsigned int flags, const faction *stealthfaction)
|
||||
{
|
||||
side *s1 = calloc(sizeof(struct side), 1);
|
||||
side *s1 = b->sides+b->nsides;
|
||||
bfaction * bf;
|
||||
|
||||
#ifdef SIMPLE_COMBAT
|
||||
if (!fval(b->region->terrain, LAND_REGION)) {
|
||||
/* in ozeanregionen ist jeder kampf kurz */
|
||||
/* every fight in an ocean is short */
|
||||
flags |= SIDE_HASGUARDS;
|
||||
} else {
|
||||
unit * u;
|
||||
|
@ -2156,17 +2159,15 @@ make_side(battle * b, const faction * f, const group * g, unsigned int flags, co
|
|||
s1->group = g;
|
||||
s1->flags = flags;
|
||||
s1->stealthfaction = stealthfaction;
|
||||
s1->next = b->sides;
|
||||
b->sides = s1;
|
||||
for (bf = b->factions;bf;bf=bf->next) {
|
||||
faction * f2 = bf->faction;
|
||||
|
||||
if (f2 == f) {
|
||||
s1->bf = bf;
|
||||
s1->index = nextside++;
|
||||
s1->faction = f2;
|
||||
s1->index = b->nsides++;
|
||||
s1->nextF = bf->sides;
|
||||
bf->sides = s1;
|
||||
++b->nsides;
|
||||
assert(b->nsides<=MAXSIDES);
|
||||
break;
|
||||
}
|
||||
|
@ -2243,7 +2244,7 @@ merge_fleeloot(fighter* fig, unit* u)
|
|||
static boolean
|
||||
seematrix(const faction * f, const side * s)
|
||||
{
|
||||
if (f==s->bf->faction) return true;
|
||||
if (f==s->faction) return true;
|
||||
if (s->flags & SIDE_STEALTH) return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -2285,7 +2286,7 @@ aftermath(battle * b)
|
|||
int *trollsave = calloc(2 * cv_size(&b->factions), sizeof(int));
|
||||
#endif
|
||||
|
||||
for (s=b->sides; s; s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter * df;
|
||||
for (df = s->fighters; df; df=df->next) {
|
||||
unit *du = df->unit;
|
||||
|
@ -2349,7 +2350,7 @@ aftermath(battle * b)
|
|||
/* POSTCOMBAT */
|
||||
do_combatmagic(b, DO_POSTCOMBATSPELL);
|
||||
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
int snumber = 0;
|
||||
fighter *df;
|
||||
boolean relevant = false; /* Kampf relevant für diese Partei? */
|
||||
|
@ -2507,7 +2508,7 @@ aftermath(battle * b)
|
|||
|
||||
battle_effects(b, dead_players);
|
||||
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
message * seen = msg_message("battle::army_report",
|
||||
"index abbrev dead fled survived",
|
||||
army_index(s), sideabkz(s, false), s->dead, s->flee, s->alive);
|
||||
|
@ -2530,7 +2531,7 @@ aftermath(battle * b)
|
|||
* schonmal Schaden genommen hat. (moved und drifted
|
||||
* sollten in flags überführt werden */
|
||||
|
||||
for (s=b->sides; s; s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter *df;
|
||||
|
||||
for (df=s->fighters; df; df=df->next) {
|
||||
|
@ -2664,7 +2665,7 @@ print_header(battle * b)
|
|||
size_t size = sizeof(zText) - 1;
|
||||
int bytes;
|
||||
|
||||
for (s=b->sides; s; s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter *df;
|
||||
for (df=s->fighters;df;df=df->next) {
|
||||
if (is_attacker(df)) {
|
||||
|
@ -2710,7 +2711,7 @@ print_stats(battle * b)
|
|||
side *s2;
|
||||
side *s;
|
||||
int i = 0;
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
bfaction *bf;
|
||||
|
||||
++i;
|
||||
|
@ -2737,7 +2738,7 @@ print_stats(battle * b)
|
|||
komma = 0;
|
||||
header = LOC(f->locale, "battle_opponents");
|
||||
|
||||
for (s2=b->sides;s2;s2=s2->next) {
|
||||
for (s2=b->sides;s2!=b->sides+b->nsides;++s2) {
|
||||
if (enemy(s2, s)) {
|
||||
const char * abbrev = seematrix(f, s2)?sideabkz(s2, false):"-?-";
|
||||
rsize = slprintf(bufp, size, "%s %s %d(%s)",
|
||||
|
@ -2754,7 +2755,7 @@ print_stats(battle * b)
|
|||
komma = 0;
|
||||
header = LOC(f->locale, "battle_helpers");
|
||||
|
||||
for (s2=b->sides;s2;s2=s2->next) {
|
||||
for (s2=b->sides;s2!=b->sides+b->nsides;++s2) {
|
||||
if (friendly(s2, s)) {
|
||||
const char * abbrev = seematrix(f, s2)?sideabkz(s2, false):"-?-";
|
||||
rsize = slprintf(bufp, size, "%s %s %d(%s)",
|
||||
|
@ -2771,7 +2772,7 @@ print_stats(battle * b)
|
|||
komma = 0;
|
||||
header = LOC(f->locale, "battle_attack");
|
||||
|
||||
for (s2=b->sides;s2;s2=s2->next) {
|
||||
for (s2=b->sides;s2!=b->sides+b->nsides;++s2) {
|
||||
if (s->relations[s2->index] & E_ATTACKING) {
|
||||
const char * abbrev = seematrix(f, s2)?sideabkz(s2, false):"-?-";
|
||||
rsize = slprintf(bufp, size, "%s %s %d(%s)", komma++ ? "," : (const char*)header, loc_army,
|
||||
|
@ -2784,12 +2785,12 @@ print_stats(battle * b)
|
|||
if (komma) fbattlerecord(b, f, buf);
|
||||
}
|
||||
|
||||
if (bdebug && s->bf->faction) {
|
||||
if (s->bf->faction->alliance) {
|
||||
fprintf(bdebug, "##### %s (%s/%d)\n", s->bf->faction->name, itoa36(s->bf->faction->no),
|
||||
s->bf->faction->alliance?s->bf->faction->alliance->id:0);
|
||||
if (bdebug && s->faction) {
|
||||
if (s->faction->alliance) {
|
||||
fprintf(bdebug, "##### %s (%s/%d)\n", s->faction->name, itoa36(s->faction->no),
|
||||
s->faction->alliance?s->faction->alliance->id:0);
|
||||
} else {
|
||||
fprintf(bdebug, "##### %s (%s)\n", s->bf->faction->name, itoa36(s->bf->faction->no));
|
||||
fprintf(bdebug, "##### %s (%s)\n", s->faction->name, itoa36(s->faction->no));
|
||||
}
|
||||
}
|
||||
print_fighters(b, s);
|
||||
|
@ -2801,14 +2802,14 @@ print_stats(battle * b)
|
|||
|
||||
b->max_tactics = 0;
|
||||
|
||||
for (s = b->sides; s; s = s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
if (cv_size(&s->leader.fighters)) {
|
||||
b->max_tactics = max(b->max_tactics, s->leader.value);
|
||||
}
|
||||
}
|
||||
|
||||
if (b->max_tactics > 0) {
|
||||
for (s = b->sides; s; s = s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
if (s->leader.value == b->max_tactics) {
|
||||
fighter *tf;
|
||||
cv_foreach(tf, s->leader.fighters) {
|
||||
|
@ -2873,8 +2874,8 @@ make_fighter(battle * b, unit * u, side * s1, boolean attack)
|
|||
return NULL;
|
||||
|
||||
if (s1==NULL) {
|
||||
for (s2 = b->sides; s2; s2 = s2->next) {
|
||||
if (s2->bf->faction == u->faction && s2->group==g) {
|
||||
for (s2=b->sides;s2!=b->sides+b->nsides;++s2) {
|
||||
if (s2->faction == u->faction && s2->group==g) {
|
||||
#ifdef SIMPLE_COMBAT
|
||||
int s1flags = flags|SIDE_HASGUARDS;
|
||||
int s2flags = s2->flags|SIDE_HASGUARDS;
|
||||
|
@ -3150,7 +3151,7 @@ join_battle(battle * b, unit * u, boolean attack, fighter ** cp)
|
|||
}
|
||||
}
|
||||
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter *fig;
|
||||
for (fig=s->fighters;fig;fig=fig->next) {
|
||||
if (fig->unit == u) {
|
||||
|
@ -3213,7 +3214,6 @@ make_battle(region * r)
|
|||
}
|
||||
obs_count++;
|
||||
}
|
||||
nextside = 0;
|
||||
|
||||
b->region = r;
|
||||
b->plane = getplane(r);
|
||||
|
@ -3269,7 +3269,7 @@ free_fighter(fighter * fig)
|
|||
static void
|
||||
free_battle(battle * b)
|
||||
{
|
||||
side *snext;
|
||||
side *s;
|
||||
meffect *meffect;
|
||||
int max_fac_no = 0;
|
||||
|
||||
|
@ -3285,9 +3285,7 @@ free_battle(battle * b)
|
|||
free(bf);
|
||||
}
|
||||
|
||||
snext = b->sides;
|
||||
while (snext) {
|
||||
side *s = snext;
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter *fnext = s->fighters;
|
||||
while (fnext) {
|
||||
fighter *fig = fnext;
|
||||
|
@ -3295,9 +3293,7 @@ free_battle(battle * b)
|
|||
free_fighter(fig);
|
||||
free(fig);
|
||||
}
|
||||
snext = s->next;
|
||||
free_side(s);
|
||||
free(s);
|
||||
}
|
||||
cv_kill(&b->leaders);
|
||||
cv_foreach(meffect, b->meffects) {
|
||||
|
@ -3333,8 +3329,8 @@ battle_report(battle * b)
|
|||
boolean komma;
|
||||
bfaction *bf;
|
||||
|
||||
for (s=b->sides; s; s=s->next) {
|
||||
for(s2=b->sides; s2; s2=s2->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
for (s2=b->sides;s2!=b->sides+b->nsides;++s2) {
|
||||
if (s->alive-s->removed > 0 && s2->alive-s2->removed > 0 && enemy(s, s2)) {
|
||||
cont = true;
|
||||
break;
|
||||
|
@ -3362,7 +3358,7 @@ battle_report(battle * b)
|
|||
msg_release(m);
|
||||
|
||||
komma = false;
|
||||
for (s=b->sides; s; s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
if (s->alive) {
|
||||
int r, k = 0, * alive = get_alive(s);
|
||||
int l = FIGHT_ROW;
|
||||
|
@ -3415,9 +3411,9 @@ join_allies(battle * b)
|
|||
{
|
||||
region *r = b->region;
|
||||
unit *u;
|
||||
side *s, *sbegin = b->sides;
|
||||
/* make_side might be adding a new faciton, but it adds them to the beginning
|
||||
* of the list, so we're safe in our iteration here if we remember b->sides
|
||||
side *s, *s_end = b->sides+b->nsides;
|
||||
/* make_side might be adding a new faction, but it adds them to the end
|
||||
* of the list, so we're safe in our iteration here if we remember the end
|
||||
* up front. */
|
||||
for (u=r->units;u;u=u->next) {
|
||||
/* Was ist mit Schiffen? */
|
||||
|
@ -3425,15 +3421,15 @@ join_allies(battle * b)
|
|||
faction * f = u->faction;
|
||||
fighter * c = NULL;
|
||||
|
||||
for (s = sbegin; s; s=s->next) {
|
||||
for (s=b->sides;s!=s_end;++s) {
|
||||
side * se;
|
||||
/* Wenn alle attackierten noch FFL_NOAID haben, dann kämpfe nicht mit. */
|
||||
if (fval(s->bf->faction, FFL_NOAID)) continue;
|
||||
if (s->bf->faction!=f) {
|
||||
if (fval(s->faction, FFL_NOAID)) continue;
|
||||
if (s->faction!=f) {
|
||||
/* Wenn wir attackiert haben, kommt niemand mehr hinzu: */
|
||||
if (s->bf->attacker) continue;
|
||||
/* alliiert müssen wir schon sein, sonst ist's eh egal : */
|
||||
if (!alliedunit(u, s->bf->faction, HELP_FIGHT)) continue;
|
||||
if (!alliedunit(u, s->faction, HELP_FIGHT)) continue;
|
||||
/* wenn die partei verborgen ist, oder gar eine andere
|
||||
* vorgespiegelt wird, und er sich uns gegenüber nicht zu
|
||||
* erkennen gibt, helfen wir ihm nicht */
|
||||
|
@ -3446,14 +3442,14 @@ join_allies(battle * b)
|
|||
/* einen alliierten angreifen dürfen sie nicht, es sei denn, der
|
||||
* ist mit einem alliierten verfeindet, der nicht attackiert
|
||||
* hat: */
|
||||
for (se = sbegin; se; se = se->next) {
|
||||
if (u->faction==se->bf->faction) continue;
|
||||
if (alliedunit(u, se->bf->faction, HELP_FIGHT) && !se->bf->attacker) {
|
||||
for (se=b->sides;se!=s_end;++se) {
|
||||
if (u->faction==se->faction) continue;
|
||||
if (alliedunit(u, se->faction, HELP_FIGHT) && !se->bf->attacker) {
|
||||
continue;
|
||||
}
|
||||
if (enemy(s, se)) break;
|
||||
}
|
||||
if (se==NULL) continue;
|
||||
if (se==s_end) continue;
|
||||
/* Wenn die Einheit belagert ist, muß auch einer der Alliierten belagert sein: */
|
||||
if (besieged(u)) {
|
||||
fighter *ally;
|
||||
|
@ -3469,17 +3465,17 @@ join_allies(battle * b)
|
|||
if (join_battle(b, u, false, &c)) {
|
||||
if (battledebug) {
|
||||
fprintf(bdebug, "%s joins to help %s against %s.\n",
|
||||
unitname(u), factionname(s->bf->faction),
|
||||
factionname(se->bf->faction));
|
||||
unitname(u), factionname(s->faction),
|
||||
factionname(se->faction));
|
||||
}
|
||||
} else if (c==NULL) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
/* Die Feinde meiner Freunde sind meine Feinde: */
|
||||
for (se = sbegin; se; se=se->next) {
|
||||
if (se->bf->faction!=u->faction && enemy(s, se)) {
|
||||
/* the enemy of my friend is my enemy: */
|
||||
for (se=b->sides;se!=s_end;++se) {
|
||||
if (se->faction!=u->faction && enemy(s, se)) {
|
||||
if (set_enemy(se, c->side, false) && battledebug) {
|
||||
fprintf(bdebug, "%u/%s hates %u/%s because they are enemies with %u/%s.\n",
|
||||
c->side->index, sidename(c->side),
|
||||
|
@ -3492,10 +3488,10 @@ join_allies(battle * b)
|
|||
}
|
||||
}
|
||||
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
int si;
|
||||
side * sa;
|
||||
faction * f = s->bf->faction;
|
||||
faction * f = s->faction;
|
||||
|
||||
/* Den Feinden meiner Feinde gebe ich Deckung (gegen gemeinsame Feinde): */
|
||||
for (si=0; s->enemies[si]; ++si) {
|
||||
|
@ -3509,11 +3505,11 @@ join_allies(battle * b)
|
|||
}
|
||||
}
|
||||
|
||||
for (sa=s->next;sa;sa=sa->next) {
|
||||
for (sa=s+1;sa!=b->sides+b->nsides;sa=++sa) {
|
||||
if (enemy(s, sa)) continue;
|
||||
if (friendly(s, sa)) continue;
|
||||
if (!alliedgroup(r->planep, f, sa->bf->faction, f->allies, HELP_FIGHT)) continue;
|
||||
if (!alliedgroup(r->planep, sa->bf->faction, f, sa->bf->faction->allies, HELP_FIGHT)) continue;
|
||||
if (!alliedgroup(r->planep, f, sa->faction, f->allies, HELP_FIGHT)) continue;
|
||||
if (!alliedgroup(r->planep, sa->faction, f, sa->faction->allies, HELP_FIGHT)) continue;
|
||||
|
||||
set_friendly(s, sa);
|
||||
}
|
||||
|
@ -3775,7 +3771,7 @@ battle_stats(FILE * F, battle * b)
|
|||
} stat_info;
|
||||
side * s;
|
||||
|
||||
for (s = b->sides; s; s = s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter * df;
|
||||
stat_info * stats = NULL, * stat;
|
||||
|
||||
|
@ -3814,7 +3810,7 @@ battle_stats(FILE * F, battle * b)
|
|||
}
|
||||
}
|
||||
|
||||
fprintf(F, "##STATS## Heer %u - %s:\n", army_index(s), factionname(s->bf->faction));
|
||||
fprintf(F, "##STATS## Heer %u - %s:\n", army_index(s), factionname(s->faction));
|
||||
for (stat=stats;stat!=NULL;stat=stat->next) {
|
||||
fprintf(F, "%s %u : %u\n", stat->wtype?stat->wtype->itype->rtype->_name[0]:"none", stat->level, stat->number);
|
||||
}
|
||||
|
@ -3831,7 +3827,7 @@ battle_attacks(battle * b)
|
|||
{
|
||||
side * s;
|
||||
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter *fig;
|
||||
for (fig=s->fighters;fig;fig=fig->next) {
|
||||
|
||||
|
@ -3842,7 +3838,7 @@ battle_attacks(battle * b)
|
|||
if (b->turn == 0) {
|
||||
side *stac;
|
||||
|
||||
for (stac=b->sides; stac; stac=stac->next) {
|
||||
for (stac=b->sides;stac!=b->sides+b->nsides;++stac) {
|
||||
if (b->max_tactics > 0 && stac->leader.value == b->max_tactics && helping(stac, fig->side)) {
|
||||
break;
|
||||
}
|
||||
|
@ -3863,7 +3859,7 @@ static void
|
|||
battle_update(battle * b)
|
||||
{
|
||||
side * s;
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter *fig;
|
||||
for (fig=s->fighters;fig;fig=fig->next) {
|
||||
fig->fighting = fig->alive - fig->removed;
|
||||
|
@ -3884,7 +3880,7 @@ battle_flee(battle * b)
|
|||
|
||||
for (attempt=1;attempt<=flee_ops;++attempt) {
|
||||
side * s;
|
||||
for (s=b->sides;s;s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
fighter *fig;
|
||||
for (fig=s->fighters;fig;fig=fig->next) {
|
||||
unit *u = fig->unit;
|
||||
|
|
|
@ -52,6 +52,40 @@ extern "C" {
|
|||
boolean attacker;
|
||||
} bfaction;
|
||||
|
||||
typedef struct tactics {
|
||||
cvector fighters;
|
||||
int value;
|
||||
} tactics;
|
||||
|
||||
#define SIDE_STEALTH 1<<0
|
||||
#ifdef SIMPLE_COMBAT
|
||||
#define SIDE_HASGUARDS 1<<1
|
||||
#endif
|
||||
typedef struct side {
|
||||
struct side * nextF; /* next army of same faction */
|
||||
struct battle * battle;
|
||||
struct bfaction * bf; /* battle info that goes with the faction */
|
||||
struct faction * faction; /* cache optimization for bf->faction */
|
||||
const struct group * group;
|
||||
struct tactics leader; /* this army's best tactician */
|
||||
# define E_ENEMY 1
|
||||
# define E_FRIEND 2
|
||||
# define E_ATTACKING 4
|
||||
unsigned char relations[MAXSIDES];
|
||||
struct side * enemies[MAXSIDES];
|
||||
struct fighter * fighters;
|
||||
int index; /* Eintrag der Fraktion in b->matrix/b->enemies */
|
||||
int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */
|
||||
int nonblockers[NUMROWS]; /* Anzahl nichtblockierender Kämpfer, z.B. Schattenritter. */
|
||||
int alive; /* Die Partei hat den Kampf verlassen */
|
||||
int removed; /* stoned */
|
||||
int flee;
|
||||
int dead;
|
||||
int casualties; /* those dead that were real people, not undead! */
|
||||
int healed;
|
||||
unsigned int flags;
|
||||
const struct faction *stealthfaction;
|
||||
} side;
|
||||
|
||||
typedef struct battle {
|
||||
cvector leaders;
|
||||
|
@ -60,7 +94,7 @@ extern "C" {
|
|||
bfaction * factions;
|
||||
int nfactions;
|
||||
int nfighters;
|
||||
struct side * sides;
|
||||
side sides[MAXSIDES];
|
||||
int nsides;
|
||||
cvector meffects;
|
||||
int max_tactics;
|
||||
|
@ -94,41 +128,6 @@ extern "C" {
|
|||
#endif
|
||||
} battle;
|
||||
|
||||
typedef struct tactics {
|
||||
cvector fighters;
|
||||
int value;
|
||||
} tactics;
|
||||
|
||||
#define SIDE_STEALTH 1<<0
|
||||
#ifdef SIMPLE_COMBAT
|
||||
#define SIDE_HASGUARDS 1<<1
|
||||
#endif
|
||||
typedef struct side {
|
||||
struct side * next; /* nächstes Heer in der Schlacht */
|
||||
struct side * nextF; /* nächstes Heer der gleichen Partei */
|
||||
struct battle * battle;
|
||||
struct bfaction * bf; /* Die Partei, die hier kämpft */
|
||||
const struct group * group;
|
||||
struct tactics leader; /* der beste Taktiker des Heeres */
|
||||
# define E_ENEMY 1
|
||||
# define E_FRIEND 2
|
||||
# define E_ATTACKING 4
|
||||
unsigned char relations[MAXSIDES];
|
||||
struct side * enemies[MAXSIDES];
|
||||
struct fighter * fighters;
|
||||
int index; /* Eintrag der Fraktion in b->matrix/b->enemies */
|
||||
int size[NUMROWS]; /* Anzahl Personen in Reihe X. 0 = Summe */
|
||||
int nonblockers[NUMROWS]; /* Anzahl nichtblockierender Kämpfer, z.B. Schattenritter. */
|
||||
int alive; /* Die Partei hat den Kampf verlassen */
|
||||
int removed; /* stoned */
|
||||
int flee;
|
||||
int dead;
|
||||
int casualties; /* those dead that were real people, not undead! */
|
||||
int healed;
|
||||
unsigned int flags;
|
||||
const struct faction *stealthfaction;
|
||||
} side;
|
||||
|
||||
typedef struct weapon {
|
||||
int count, used;
|
||||
const struct weapon_type * type;
|
||||
|
|
|
@ -438,6 +438,13 @@ building *
|
|||
new_building(const struct building_type * btype, region * r, const struct locale * lang)
|
||||
{
|
||||
building *b = (building *) calloc(1, sizeof(building));
|
||||
static boolean init_lighthouse = false;
|
||||
static const struct building_type * bt_lighthouse = 0;
|
||||
|
||||
if (!init_lighthouse) {
|
||||
bt_lighthouse = bt_find("lighthouse");
|
||||
init_lighthouse = true;
|
||||
}
|
||||
|
||||
b->no = newcontainerid();
|
||||
bhash(b);
|
||||
|
@ -446,6 +453,9 @@ new_building(const struct building_type * btype, region * r, const struct locale
|
|||
b->region = r;
|
||||
addlist(&r->buildings, b);
|
||||
|
||||
if (b->type==bt_lighthouse) {
|
||||
r->flags |= RF_LIGHTHOUSE;
|
||||
}
|
||||
{
|
||||
const char * bname;
|
||||
if (b->type->name==NULL) {
|
||||
|
|
|
@ -1198,6 +1198,10 @@ update_lighthouse(building * lh)
|
|||
short d = (short)log10(lh->size) + 1;
|
||||
short x;
|
||||
|
||||
if (lh->size>0) {
|
||||
r->flags |= RF_LIGHTHOUSE;
|
||||
}
|
||||
|
||||
for (x=-d;x<=d;++x) {
|
||||
short y;
|
||||
for (y=-d;y<=d;++y) {
|
||||
|
@ -1219,7 +1223,6 @@ update_lighthouse(building * lh)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1887,27 +1890,6 @@ firstregion (faction * f)
|
|||
#endif
|
||||
}
|
||||
|
||||
void
|
||||
update_intervals(void)
|
||||
{
|
||||
#ifdef SMART_INTERVALS
|
||||
region *r;
|
||||
for (r = regions; r; r = r->next) {
|
||||
plane * p = rplane(r);
|
||||
|
||||
if (p!=NULL) {
|
||||
struct watcher * w = p->watchers;
|
||||
while (w) {
|
||||
if (w->faction!=NULL) {
|
||||
update_interval(w->faction, r);
|
||||
}
|
||||
w = w->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void ** blk_list[1024];
|
||||
int list_index;
|
||||
int blk_index;
|
||||
|
|
|
@ -274,7 +274,6 @@ int weight(const struct unit * u);
|
|||
void changeblockchaos(void);
|
||||
|
||||
/* intervall, in dem die regionen der partei zu finden sind */
|
||||
extern void update_intervals(void);
|
||||
extern struct region *firstregion(struct faction * f);
|
||||
extern struct region *lastregion(struct faction * f);
|
||||
|
||||
|
|
|
@ -19,7 +19,8 @@ extern "C" {
|
|||
struct player;
|
||||
struct alliance;
|
||||
struct item;
|
||||
|
||||
struct seen_region;
|
||||
|
||||
/* SMART_INTERVALS: define to speed up finding the interval of regions that a
|
||||
faction is in. defining this speeds up the turn by 30-40% */
|
||||
#define SMART_INTERVALS
|
||||
|
@ -53,63 +54,64 @@ typedef struct shortpwd {
|
|||
#define FFL_SAVEMASK (FFL_NEWID|FFL_GM|FFL_NOTIMEOUT|FFL_DBENTRY|FFL_NOTIMEOUT)
|
||||
|
||||
typedef struct faction {
|
||||
struct faction *next;
|
||||
struct faction *nexthash;
|
||||
struct faction *next;
|
||||
struct faction *nexthash;
|
||||
|
||||
struct player *owner;
|
||||
struct player *owner;
|
||||
#ifdef SMART_INTERVALS
|
||||
struct region *first;
|
||||
struct region *last;
|
||||
struct region *first;
|
||||
struct region *last;
|
||||
#endif
|
||||
int no;
|
||||
int subscription;
|
||||
unsigned int flags;
|
||||
char *name;
|
||||
char *banner;
|
||||
char *email;
|
||||
char *passw;
|
||||
char *override;
|
||||
int no;
|
||||
int subscription;
|
||||
unsigned int flags;
|
||||
char *name;
|
||||
char *banner;
|
||||
char *email;
|
||||
char *passw;
|
||||
char *override;
|
||||
#ifdef SHORTPWDS
|
||||
struct shortpwd * shortpwds;
|
||||
#endif
|
||||
const struct locale * locale;
|
||||
int lastorders; /* enno: short? */
|
||||
int age; /* enno: short? */
|
||||
struct ursprung *ursprung;
|
||||
const struct race * race;
|
||||
magic_t magiegebiet;
|
||||
int newbies;
|
||||
int num_people; /* Anzahl Personen ohne Monster */
|
||||
const struct locale * locale;
|
||||
int lastorders; /* enno: short? */
|
||||
int age; /* enno: short? */
|
||||
struct ursprung *ursprung;
|
||||
const struct race * race;
|
||||
magic_t magiegebiet;
|
||||
int newbies;
|
||||
int num_people; /* Anzahl Personen ohne Monster */
|
||||
int num_total; /* Anzahl Personen mit Monstern */
|
||||
int options;
|
||||
int no_units;
|
||||
struct ally *allies;
|
||||
struct group *groups;
|
||||
boolean alive; /* enno: sollte ein flag werden */
|
||||
int nregions;
|
||||
int money;
|
||||
int options;
|
||||
int no_units;
|
||||
struct ally *allies;
|
||||
struct group *groups;
|
||||
boolean alive; /* enno: sollte ein flag werden */
|
||||
int nregions;
|
||||
int money;
|
||||
#ifdef SCORE_MODULE
|
||||
int score;
|
||||
#endif
|
||||
#ifdef KARMA_MODULE
|
||||
int karma;
|
||||
#endif
|
||||
struct alliance * alliance;
|
||||
struct alliance * alliance;
|
||||
#ifdef VICTORY_DELAY
|
||||
unsigned char victory_delay;
|
||||
unsigned char victory_delay;
|
||||
#endif
|
||||
struct unit * units;
|
||||
struct attrib *attribs;
|
||||
struct message_list * msgs;
|
||||
struct unit * units;
|
||||
struct attrib *attribs;
|
||||
struct message_list * msgs;
|
||||
#ifdef ENEMIES
|
||||
struct faction_list * enemies;
|
||||
#endif
|
||||
struct bmsg {
|
||||
struct bmsg * next;
|
||||
struct region * r;
|
||||
struct message_list * msgs;
|
||||
} * battles;
|
||||
struct bmsg {
|
||||
struct bmsg * next;
|
||||
struct region * r;
|
||||
struct message_list * msgs;
|
||||
} * battles;
|
||||
struct item * items; /* items this faction can claim */
|
||||
struct seen_region ** seen;
|
||||
} faction;
|
||||
|
||||
typedef struct faction_list {
|
||||
|
|
|
@ -45,6 +45,7 @@ extern "C" {
|
|||
/* debug flags */
|
||||
#define RF_COMBATDEBUG (1<<14)
|
||||
#define RF_MAPPER_HIGHLIGHT (1<<14) /* only used by mapper, not stored */
|
||||
#define RF_LIGHTHOUSE (1<<15) /* this region may contain a lighthouse */
|
||||
|
||||
#define RF_SELECT (1<<17)
|
||||
#define RF_MARK (1<<18)
|
||||
|
|
|
@ -806,11 +806,11 @@ get_addresses(report_context * ctx)
|
|||
}
|
||||
}
|
||||
}
|
||||
} if (sr->mode==see_travel) {
|
||||
} else if (sr->mode==see_travel) {
|
||||
unit * u = r->units;
|
||||
while (u) {
|
||||
faction * sf = visible_faction(ctx->f, u);
|
||||
assert(u->faction!=ctx->f);
|
||||
assert(u->faction!=ctx->f); /* if this is see_travel only, then I shouldn't be here. */
|
||||
if (lastf!=sf) {
|
||||
attrib * a = a_find(r->attribs, &at_travelunit);
|
||||
while (a && a->type==&at_travelunit) {
|
||||
|
@ -1103,97 +1103,107 @@ view_regatta(struct seen_region ** seen, region * r, faction * f)
|
|||
recurse_regatta(seen, r, r, f, skill/2);
|
||||
}
|
||||
|
||||
static struct seen_region **
|
||||
prepare_report(faction * f)
|
||||
static void
|
||||
prepare_reports(void)
|
||||
{
|
||||
region * r;
|
||||
region * end = lastregion(f);
|
||||
struct seen_region ** seen = seen_init();
|
||||
|
||||
faction * f;
|
||||
static const struct building_type * bt_lighthouse = NULL;
|
||||
if (bt_lighthouse==NULL) bt_lighthouse = bt_find("lighthouse");
|
||||
|
||||
for (r = firstregion(f); r != end; r = r->next) {
|
||||
for (f = factions; f ; f = f->next) {
|
||||
if (f->seen) seen_done(f->seen);
|
||||
f->seen = seen_init();
|
||||
}
|
||||
|
||||
for (r = regions; r ; r = r->next) {
|
||||
attrib *ru;
|
||||
unit * u;
|
||||
plane * p = r->planep;
|
||||
unsigned char mode = see_none;
|
||||
boolean dis = false;
|
||||
int light = 0;
|
||||
|
||||
if (p) {
|
||||
watcher * w = p->watchers;
|
||||
while (w) {
|
||||
if (f==w->faction) {
|
||||
mode = w->mode;
|
||||
break;
|
||||
}
|
||||
w = w->next;
|
||||
for (;w;w=w->next) {
|
||||
add_seen(w->faction->seen, r, w->mode, false);
|
||||
#ifdef SMART_INTERVALS
|
||||
update_interval(w->faction, r);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
for (u = r->units; u; u = u->next) {
|
||||
if (u->faction == f) {
|
||||
if (u->building && u->building->type==bt_lighthouse) {
|
||||
int r = lighthouse_range(u->building, f);
|
||||
if (r>light) light = r;
|
||||
}
|
||||
if (u->race != new_race[RC_SPELL] || u->number == RS_FARVISION) {
|
||||
mode = see_unit;
|
||||
if (fval(u, UFL_DISBELIEVES)) {
|
||||
dis = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (u->building && u->building->type==bt_lighthouse) {
|
||||
/* we are in a lighthouse. add the regions we can see from here! */
|
||||
int range = lighthouse_range(u->building, u->faction);
|
||||
region_list * rlist = get_regions_distance(r, range);
|
||||
region_list * rp = rlist;
|
||||
|
||||
if (light) {
|
||||
/* we are in a lighthouse. add the others! */
|
||||
region_list * rlist = get_regions_distance(r, light);
|
||||
region_list * rp = rlist;
|
||||
while (rp) {
|
||||
region * rl = rp->data;
|
||||
if (fval(rl->terrain, SEA_REGION)) {
|
||||
direction_t d;
|
||||
add_seen(seen, rl, see_lighthouse, false);
|
||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||
region * rn = rconnect(rl, d);
|
||||
if (rn!=NULL) {
|
||||
add_seen(seen, rn, see_neighbour, false);
|
||||
while (rp) {
|
||||
region * rl = rp->data;
|
||||
if (fval(rl->terrain, SEA_REGION)) {
|
||||
direction_t d;
|
||||
add_seen(u->faction->seen, rl, see_lighthouse, false);
|
||||
for (d=0;d!=MAXDIRECTIONS;++d) {
|
||||
region * rn = rconnect(rl, d);
|
||||
if (rn!=NULL) {
|
||||
add_seen(u->faction->seen, rn, see_neighbour, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
rp = rp->next;
|
||||
}
|
||||
free_regionlist(rlist);
|
||||
}
|
||||
|
||||
if (u->race != new_race[RC_SPELL] || u->number == RS_FARVISION) {
|
||||
if (fval(u, UFL_DISBELIEVES)) {
|
||||
add_seen(u->faction->seen, r, see_unit, true);
|
||||
} else {
|
||||
add_seen(u->faction->seen, r, see_unit, false);
|
||||
}
|
||||
rp = rp->next;
|
||||
}
|
||||
free_regionlist(rlist);
|
||||
}
|
||||
|
||||
if (mode<see_travel && fval(r, RF_TRAVELUNIT)) {
|
||||
if (fval(r, RF_TRAVELUNIT)) {
|
||||
for (ru = a_find(r->attribs, &at_travelunit); ru && ru->type==&at_travelunit; ru = ru->next) {
|
||||
unit * u = (unit*)ru->data.v;
|
||||
if (u->faction == f) {
|
||||
mode = see_travel;
|
||||
break;
|
||||
|
||||
/* make sure the faction has not been removed this turn: */
|
||||
if (u->faction) {
|
||||
add_seen(u->faction->seen, r, see_travel, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mode == see_none)
|
||||
continue;
|
||||
static seen_region **
|
||||
prepare_report(faction * f)
|
||||
{
|
||||
struct seen_region * sr;
|
||||
region * r = firstregion(f);
|
||||
region * last = lastregion(f);
|
||||
|
||||
add_seen(seen, r, mode, dis);
|
||||
/* nicht, wenn Verwirrung herrscht: */
|
||||
if (!is_cursed(r->attribs, C_REGCONF, 0)) {
|
||||
void (*view)(struct seen_region **, region * r, faction * f) = view_default;
|
||||
if (p && fval(p, PFL_SEESPECIAL)) {
|
||||
attrib * a = a_find(p->attribs, &at_viewrange);
|
||||
if (a) view = (void (*)(struct seen_region **, region * r, faction * f))a->data.f;
|
||||
for (sr=NULL; sr==NULL && r!=last; r=r->next) {
|
||||
sr = find_seen(f->seen, r);
|
||||
}
|
||||
|
||||
for (;sr!=NULL;sr=sr->next) {
|
||||
if (sr->mode>see_neighbour) {
|
||||
region * r = sr->r;
|
||||
plane * p = r->planep;
|
||||
/* if no confusion in the region, add neighbors: */
|
||||
if (!is_cursed(r->attribs, C_REGCONF, 0)) {
|
||||
void (*view)(struct seen_region **, region *, faction *) = view_default;
|
||||
if (p && fval(p, PFL_SEESPECIAL)) {
|
||||
attrib * a = a_find(p->attribs, &at_viewrange);
|
||||
if (a) view = (void (*)(struct seen_region **, region *, faction *))a->data.f;
|
||||
}
|
||||
view(f->seen, r, f);
|
||||
}
|
||||
view(seen, r, f);
|
||||
}
|
||||
}
|
||||
return seen;
|
||||
return f->seen;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -1319,8 +1329,7 @@ write_script(FILE * F, const faction * f)
|
|||
int
|
||||
init_reports(void)
|
||||
{
|
||||
update_intervals();
|
||||
|
||||
prepare_reports();
|
||||
#ifdef HAVE_STAT
|
||||
{
|
||||
stat_type st;
|
||||
|
|
|
@ -1532,6 +1532,7 @@ readgame(const char * filename, int backup)
|
|||
char path[MAX_PATH];
|
||||
char token[32];
|
||||
int encoding = enc_gamedata;
|
||||
const struct building_type * bt_lighthouse = bt_find("lighthouse");
|
||||
|
||||
sprintf(path, "%s/%s", datapath(), filename);
|
||||
log_printf("- reading game data from %s\n", filename);
|
||||
|
@ -1713,6 +1714,9 @@ readgame(const char * filename, int backup)
|
|||
b->type = bt_find(token);
|
||||
b->region = r;
|
||||
a_read(F, &b->attribs);
|
||||
if (b->type==bt_lighthouse) {
|
||||
r->flags |= RF_LIGHTHOUSE;
|
||||
}
|
||||
}
|
||||
/* Schiffe */
|
||||
|
||||
|
@ -1783,8 +1787,10 @@ readgame(const char * filename, int backup)
|
|||
resolve();
|
||||
|
||||
for (r=regions;r;r=r->next) {
|
||||
building * b;
|
||||
for (b=r->buildings;b;b=b->next) update_lighthouse(b);
|
||||
if (r->flags & RF_LIGHTHOUSE) {
|
||||
building * b;
|
||||
for (b=r->buildings;b;b=b->next) update_lighthouse(b);
|
||||
}
|
||||
}
|
||||
if (quiet < 2) printf(" - Regionen initialisieren & verbinden...\n");
|
||||
for (f = factions; f; f = f->next) {
|
||||
|
|
|
@ -398,7 +398,7 @@ select_ally(fighter * af, int minrow, int maxrow)
|
|||
}
|
||||
allies = rng_int() % allies;
|
||||
|
||||
for (ds=b->sides; ds; ds=ds->next) {
|
||||
for (ds=b->sides;ds!=b->sides+b->nsides;++ds) {
|
||||
if (helping(as, ds)) {
|
||||
fighter * df;
|
||||
for (df=ds->fighters; df; df=df->next) {
|
||||
|
@ -1377,7 +1377,7 @@ count_healable(battle *b, fighter *df)
|
|||
side *s;
|
||||
int healable = 0;
|
||||
|
||||
for (s=b->sides; s; s=s->next) {
|
||||
for (s=b->sides;s!=b->sides+b->nsides;++s) {
|
||||
if (helping(df->side, s)) {
|
||||
healable += s->casualties;
|
||||
}
|
||||
|
|
|
@ -18,8 +18,11 @@
|
|||
/* lua includes */
|
||||
#include "lua/bindings.h"
|
||||
#include <boost/version.hpp>
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
static const struct {
|
||||
const char * name;
|
||||
|
|
|
@ -9,10 +9,12 @@
|
|||
#include <kernel/alliance.h>
|
||||
|
||||
// lua includes
|
||||
#include <lua.hpp>
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#include <luabind/object.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
using namespace luabind;
|
||||
|
||||
|
|
|
@ -10,12 +10,15 @@
|
|||
#include <unit.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#if LUABIND_BETA >= 7
|
||||
# include <luabind/operator.hpp>
|
||||
#endif
|
||||
#pragma warning (pop)
|
||||
|
||||
// util includes
|
||||
#include <util/attrib.h>
|
||||
|
|
|
@ -22,9 +22,12 @@
|
|||
#include <kernel/unit.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
// util includes
|
||||
#include <util/attrib.h>
|
||||
|
|
|
@ -10,8 +10,11 @@
|
|||
#include <util/event.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
using namespace luabind;
|
||||
|
||||
|
|
|
@ -21,6 +21,8 @@
|
|||
#include <attributes/variable.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
|
@ -29,6 +31,7 @@
|
|||
#if LUABIND_BETA >= 7
|
||||
# include <luabind/operator.hpp>
|
||||
#endif
|
||||
#pragma warning (pop)
|
||||
|
||||
#include <ostream>
|
||||
#include <cstring>
|
||||
|
|
|
@ -34,9 +34,12 @@
|
|||
#include <kernel/unit.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
// util includes
|
||||
#include <util/lists.h>
|
||||
|
|
|
@ -9,9 +9,12 @@
|
|||
#include <kernel/region.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
using namespace luabind;
|
||||
|
||||
|
|
|
@ -14,9 +14,12 @@
|
|||
#include <util/log.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
using namespace luabind;
|
||||
|
||||
|
|
|
@ -10,9 +10,12 @@
|
|||
#include <util/attrib.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/object.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
#include <string>
|
||||
|
||||
|
|
|
@ -2,8 +2,10 @@
|
|||
#define LUA_OBJECTS_H
|
||||
|
||||
#include <attributes/object.h>
|
||||
#include <lua.hpp>
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <luabind/object.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
struct lua_State;
|
||||
|
||||
|
|
|
@ -19,12 +19,15 @@
|
|||
#include <attributes/key.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#if LUABIND_BETA >= 7
|
||||
# include <luabind/operator.hpp>
|
||||
#endif
|
||||
#pragma warning (pop)
|
||||
|
||||
#include <ostream>
|
||||
using namespace luabind;
|
||||
|
|
|
@ -31,8 +31,11 @@
|
|||
#include <util/functions.h>
|
||||
#include <util/log.h>
|
||||
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/object.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
#include <region.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#if LUABIND_BETA >= 7
|
||||
# include <luabind/operator.hpp>
|
||||
#endif
|
||||
#pragma warning (pop)
|
||||
|
||||
#include <util/base36.h>
|
||||
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
#include <kernel/magic.h>
|
||||
|
||||
// lua includes
|
||||
#include <lua.hpp>
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <luabind/luabind.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
using namespace luabind;
|
||||
|
||||
|
|
|
@ -32,12 +32,15 @@
|
|||
#include <util/log.h>
|
||||
|
||||
// lua includes
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#include <luabind/iterator_policy.hpp>
|
||||
#if LUABIND_BETA>=7
|
||||
# include <luabind/operator.hpp>
|
||||
#endif
|
||||
#pragma warning (pop)
|
||||
|
||||
#include <ostream>
|
||||
#include <string>
|
||||
|
|
|
@ -105,8 +105,11 @@
|
|||
#include "lua/bindings.h"
|
||||
#include "lua/script.h"
|
||||
#include <boost/version.hpp>
|
||||
#pragma warning (push)
|
||||
#pragma warning (disable: 4127)
|
||||
#include <lua.hpp>
|
||||
#include <luabind/luabind.hpp>
|
||||
#pragma warning (pop)
|
||||
|
||||
#include <libxml/encoding.h>
|
||||
|
||||
|
|
Loading…
Reference in a new issue