From 56a716622ad446a46ed02a5afd3c221ced797da2 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Mon, 7 Jan 2008 19:26:36 +0000 Subject: [PATCH] http://eressea.upb.de/mantis/view.php?id=1339 "In der Taktikerrunde greifen alle an" - fixed finding allies Also: - fixed an error reading the order file in text mode. --- src/common/kernel/battle.c | 27 ++++++++++++++++----------- src/common/kernel/save.c | 7 +------ src/common/util/filereader.c | 4 +++- 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/common/kernel/battle.c b/src/common/kernel/battle.c index 06bedc668..357e396d3 100644 --- a/src/common/kernel/battle.c +++ b/src/common/kernel/battle.c @@ -3829,22 +3829,27 @@ battle_attacks(battle * b) for (s=b->sides;s!=b->sides+b->nsides;++s) { fighter *fig; + + /* Taktikrunde: */ + if (b->turn == 0) { + side *stac; + + for (stac=b->sides;stac!=b->sides+b->nsides;++stac) { + if (b->max_tactics > 0 && stac->leader.value == b->max_tactics && helping(stac, s)) { + break; + } + } + if (stac==b->sides+b->nsides) { + /* could not find a side that is helping us and won the tactics round */ + continue; + } + } + for (fig=s->fighters;fig;fig=fig->next) { /* ist in dieser Einheit noch jemand handlungsfähig? */ if (fig->fighting <= 0) continue; - /* Taktikrunde: */ - if (b->turn == 0) { - side *stac; - - 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; - } - } - if (stac==NULL) continue; - } /* Handle the unit's attack on someone */ do_attack(fig); } diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index be95df4cc..41d03703e 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -435,11 +435,6 @@ unitorders(FILE * F, int enc, struct faction * f) if (u && u->faction == f) { order ** ordp; - if (quiet==0) { - printf(",_%4s_", itoa36(u->no)); - fflush(stdout); - } - if (!fval(u, UFL_ORDERS)) { /* alle wiederholbaren, langen befehle werden gesichert: */ fset(u, UFL_ORDERS); @@ -555,7 +550,7 @@ readorders(const char *filename) int nfactions=0; struct faction *f = NULL; - if (filename) F = cfopen(filename, "rt"); + if (filename) F = cfopen(filename, "rb"); if (F==NULL) return 0; puts(" - lese Befehlsdatei...\n"); diff --git a/src/common/util/filereader.c b/src/common/util/filereader.c index a6b087db3..dbfb73e77 100644 --- a/src/common/util/filereader.c +++ b/src/common/util/filereader.c @@ -181,7 +181,9 @@ getbuf_utf8(FILE * F) do { const char * bp = fgets(lbuf, MAXLINE, F); size_t white; - if (bp==NULL) return NULL; + if (bp==NULL) { + return NULL; + } eatwhite(bp, &white); /* decoding errors will get caught later on, don't have to check */ bp += white;