- resizing buffer in battle.

- not writing past-the-end in orders.
- fix for show_allies.
This commit is contained in:
Enno Rehling 2007-09-02 07:57:31 +00:00
parent a1865ee2fa
commit d434b73617
3 changed files with 13 additions and 9 deletions

View file

@ -1413,7 +1413,7 @@ report_template(const char * filename, report_context * ctx, const char * charse
}
static void
show_allies(FILE * F, const faction * f, const ally * allies, char * buf, size_t size)
show_allies(const faction * f, const ally * allies, char * buf, size_t size)
{
int allierte = 0;
int i=0, h, hh = 0;
@ -1491,8 +1491,6 @@ show_allies(FILE * F, const faction * f, const ally * allies, char * buf, size_t
bytes = (int)strlcpy(bufp, ".", size);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
*bufp = 0;
rparagraph(F, buf, 0, 0, 0);
rnl(F);
}
static void
@ -1510,7 +1508,9 @@ allies(FILE * F, const faction * f)
bytes = (int)strlcpy(buf, "Wir helfen den Parteien ", size);
}
size -= bytes;
show_allies(F, f, f->allies, buf + bytes, size);
show_allies(f, f->allies, buf + bytes, size);
rparagraph(F, buf, 0, 0, 0);
rnl(F);
}
while (g) {
@ -1523,7 +1523,9 @@ allies(FILE * F, const faction * f)
bytes = snprintf(buf, size, "%s hilft den Parteien ", g->name);
}
size -= bytes;
show_allies(F, f, g->allies, buf + bytes, size);
show_allies(f, g->allies, buf + bytes, size);
rparagraph(F, buf, 0, 0, 0);
rnl(F);
}
g = g->next;
}

View file

@ -2629,7 +2629,7 @@ static void
print_header(battle * b)
{
bfaction * bf;
char zText[1024];
char zText[32*MAXSIDES];
for (bf=b->factions;bf;bf=bf->next) {
message * m;
@ -2645,8 +2645,10 @@ print_header(battle * b)
fighter *df;
for (df=s->fighters;df;df=df->next) {
if (is_attacker(df)) {
if (first) bytes = (int)strlcpy(bufp, ", ", size);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
if (first) {
bytes = (int)strlcpy(bufp, ", ", size);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
}
if (lastf) {
bytes = (int)strlcpy(bufp, (const char *)lastf, size);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();

View file

@ -115,7 +115,7 @@ get_command(const order * ord, char * sbuffer, size_t size)
bytes = (int)strlcpy(bufp, (const char *)text, size);
if (wrptr(&bufp, &size, bytes)!=0) WARN_STATIC_BUFFER();
}
*bufp = 0;
if (size>0) *bufp = 0;
return sbuffer;
}