diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 86d6cee5f..bb5cd29d5 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -225,7 +225,7 @@ rpsnr(FILE * F, const char * s, int offset) if (*(x - 1) && indent && *x == ' ') indent += 2; if (!indent) indent = offset; x = s; - memset(inset, 32, indent * sizeof(char)); + memset(inset, ' ', indent * sizeof(char)); inset[indent] = 0; while (s <= x+len) { size_t line = min(len-(s-x), REPORTWIDTH - indent*ui); @@ -349,27 +349,39 @@ centre(FILE * F, const char *s, boolean breaking) static void rparagraph(FILE *F, const char *s, int indent, char mark) { - static char mbuf[BUFSIZE+1]; - /* static size_t bsize = 0; */ - size_t size; - char inset[REPORTWIDTH]; + static const char * spaces = " "; + size_t length = REPORTWIDTH - indent; + const char * end = s; - if (indent) { - memset(inset, ' ', indent); - inset[indent]=0; - if (mark) - inset[indent - 2] = mark; - } else { - assert(mark == 0); - inset[0] = 0; - } - inset[indent]=0; - size = strlen(s)+indent+1; - if (size==1) return; - strcpy(mbuf, inset); - strncpy(mbuf+indent, s, BUFSIZE-indent); - *(mbuf+size-1)=0; - rps(F, mbuf); + while (*s) { + const char * last_space = s; + + if (mark && indent>=2) { + fwrite(spaces, sizeof(char), indent-2, F); + fputc(mark, F); + fputc(' ', F); + mark = 0; + } else { + fwrite(spaces, sizeof(char), indent, F); + } + while (*end && end!=s+length) { + if (*end==' ') { + last_space = end; + } + ++end; + } + if (last_space==s) { + /* there was no space in this line. clip it */ + last_space = end; + } + fwrite(s, sizeof(char), last_space-s, F); + s = last_space; + while (*s==' ') { + ++s; + } + if (s>end) end = s; + fputc('\n', F); + } } static void @@ -1700,9 +1712,12 @@ guards(FILE * F, const region * r, const faction * see) static void rpline(FILE * F) { - rpc(F, ' ', 1); - rpc(F, '-', REPORTWIDTH); - rnl(F); + static char line[REPORTWIDTH+1]; + if (line[0]!='-') { + memset(line, '-', sizeof(line)); + line[REPORTWIDTH] = '\n'; + } + fwrite(line, sizeof(char), sizeof(line), F); } static void diff --git a/src/common/kernel/building.c b/src/common/kernel/building.c index 90c3c2457..97c16a31d 100644 --- a/src/common/kernel/building.c +++ b/src/common/kernel/building.c @@ -27,11 +27,12 @@ #include "save.h" /* util includes */ -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* libc includes */ #include diff --git a/src/common/kernel/eressea.h b/src/common/kernel/eressea.h index d0007ff8d..f584df5dd 100644 --- a/src/common/kernel/eressea.h +++ b/src/common/kernel/eressea.h @@ -98,7 +98,6 @@ struct building_type; #include #include #include -#include #include #include #include @@ -1067,12 +1066,6 @@ extern void guard(struct unit * u, unsigned int mask); * 'mask' kann einzelne flags zusätzlich und-maskieren. */ -typedef struct local_names { - struct local_names * next; - const struct locale * lang; - struct tnode names; -} local_names; - extern boolean hunger(int number, struct unit * u); extern int lifestyle(const struct unit*); extern int besieged(const struct unit * u); diff --git a/src/common/kernel/item.c b/src/common/kernel/item.c index eaaf91ce2..0ea229698 100644 --- a/src/common/kernel/item.c +++ b/src/common/kernel/item.c @@ -39,6 +39,7 @@ #include #include #include +#include /* libc includes */ #include diff --git a/src/common/kernel/ship.c b/src/common/kernel/ship.c index 4ce512542..7432c6cb2 100644 --- a/src/common/kernel/ship.c +++ b/src/common/kernel/ship.c @@ -24,10 +24,11 @@ #include "skill.h" /* util includes */ -#include -#include -#include -#include +#include +#include +#include +#include +#include /* libc includes */ #include diff --git a/src/common/kernel/spell.c b/src/common/kernel/spell.c index 44fd7c528..c7361569d 100644 --- a/src/common/kernel/spell.c +++ b/src/common/kernel/spell.c @@ -35,6 +35,7 @@ /* util includes */ #include #include +#include /* Bitte die Sprüche nach Gebieten und Stufe ordnen, denn in derselben * Reihenfolge wie in Spelldaten tauchen sie auch im Report auf diff --git a/src/common/util/umlaut.h b/src/common/util/umlaut.h index 35fc121e9..09d4e8c04 100644 --- a/src/common/util/umlaut.h +++ b/src/common/util/umlaut.h @@ -35,6 +35,12 @@ typedef struct tnode { int findtoken(const struct tnode * tk, const char * str, variant* result); void addtoken(struct tnode * root, const char* str, variant id); +typedef struct local_names { + struct local_names * next; + const struct locale * lang; + struct tnode names; +} local_names; + #ifdef __cplusplus } #endif