Kampf crasht mit Datenfile 420

Da waren 50 Armeen in einer Region, das hat einen string-buffer auf dem stack von battle_report gekillt.
This commit is contained in:
Enno Rehling 2005-06-15 20:51:25 +00:00
parent b16bbb9146
commit a6ffd0f35b
1 changed files with 31 additions and 28 deletions

View File

@ -51,17 +51,17 @@
#include <items/demonseye.h> #include <items/demonseye.h>
/* util includes */ /* util includes */
#include <base36.h> #include <util/base36.h>
#include <cvector.h> #include <util/bsdstring.h>
#include <rand.h> #include <util/cvector.h>
#include <log.h> #include <util/rand.h>
#include <util/log.h>
/* libc includes */ /* libc includes */
#include <assert.h> #include <assert.h>
#include <ctype.h> #include <ctype.h>
#include <limits.h> #include <limits.h>
#include <math.h> #include <math.h>
#include <message.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sys/stat.h> #include <sys/stat.h>
@ -3284,7 +3284,7 @@ battle_report(battle * b)
side *s, *s2; side *s, *s2;
boolean cont = false; boolean cont = false;
boolean komma; boolean komma;
char buf2[1024]; char * bufp = buf;
bfaction *bf; bfaction *bf;
buf[0] = 0; buf[0] = 0;
@ -3301,46 +3301,49 @@ battle_report(battle * b)
} cv_next(s); } cv_next(s);
printf(" %d", b->turn); printf(" %d", b->turn);
fflush(stdout); fflush(stdout);
for (bf=b->factions;bf;bf=bf->next) { for (bf=b->factions;bf;bf=bf->next) {
faction * fac = bf->faction; faction * fac = bf->faction;
message * m; message * m;
fbattlerecord(b, fac, " ");
if (cont) m = msg_message("battle::lineup", "turn", b->turn); fbattlerecord(b, fac, " ");
else m = msg_message("battle::after", "");
message_faction(b, fac, m);
msg_release(m);
buf2[0] = 0; if (cont) m = msg_message("battle::lineup", "turn", b->turn);
komma = false; else m = msg_message("battle::after", "");
cv_foreach(s, b->sides) { message_faction(b, fac, m);
if (s->alive) { msg_release(m);
komma = false;
cv_foreach(s, b->sides) {
if (s->alive) {
int r, k = 0, * alive = get_alive(b, s, fac, seematrix(fac, s)); int r, k = 0, * alive = get_alive(b, s, fac, seematrix(fac, s));
int l = FIGHT_ROW; int l = FIGHT_ROW;
const char * abbrev = seematrix(fac, s)?sideabkz(s, false):"-?-"; const char * abbrev = seematrix(fac, s)?sideabkz(s, false):"-?-";
const char * loc_army = LOC(fac->locale, "battle_army"); const char * loc_army = LOC(fac->locale, "battle_army");
sprintf(buf, "%s%s %2d(%s): ", (komma==true?", ":""), char buffer[32];
loc_army, s->index, abbrev);
if (komma) bufp += strlcpy(bufp, ", ", sizeof(buf) - (bufp - buf));
snprintf(buffer, sizeof(buffer), "%s %2d(%s): ",
loc_army, s->index, abbrev);
buffer[sizeof(buffer)-1] = 0;
bufp += strlcpy(bufp, buffer, sizeof(buf) - (bufp - buf));
for (r=FIGHT_ROW;r!=NUMROWS;++r) { for (r=FIGHT_ROW;r!=NUMROWS;++r) {
if (alive[r]) { if (alive[r]) {
if (l!=FIGHT_ROW) scat("+"); if (l!=FIGHT_ROW) scat("+");
while(k--) scat("0+"); while(k--) scat("0+");
icat(alive[r]); icat(alive[r]);
k = 0; k = 0;
l=r+1; l = r+1;
} else ++k; } else ++k;
} }
strcat(buf2, buf); komma = true;
if (komma == false) {
komma = true;
}
} }
} cv_next(s); } cv_next(s);
fbattlerecord(b, fac, buf2); fbattlerecord(b, fac, buf);
} }
return cont; return cont;
} }