diff --git a/src/gamecode/creport.c b/src/gamecode/creport.c index b8b2a975f..4a0e767c8 100644 --- a/src/gamecode/creport.c +++ b/src/gamecode/creport.c @@ -1438,7 +1438,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset) perror(filename); return -1; } else if (enc == XML_CHAR_ENCODING_UTF8) { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf }; + const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; fwrite(utf8_bom, 1, 3, F); } diff --git a/src/gamecode/report.c b/src/gamecode/report.c index 5d635992d..9907dc182 100644 --- a/src/gamecode/report.c +++ b/src/gamecode/report.c @@ -1495,7 +1495,7 @@ report_template(const char *filename, report_context * ctx, const char *charset) } if (enc == XML_CHAR_ENCODING_UTF8) { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf }; + const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; fwrite(utf8_bom, 1, 3, F); } @@ -2141,7 +2141,7 @@ report_plaintext(const char *filename, report_context * ctx, return -1; } if (enc == XML_CHAR_ENCODING_UTF8) { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf }; + const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; fwrite(utf8_bom, 1, 3, F); } diff --git a/src/gamecode/summary.c b/src/gamecode/summary.c index a734eeba4..03690dee7 100644 --- a/src/gamecode/summary.c +++ b/src/gamecode/summary.c @@ -149,7 +149,7 @@ void report_summary(summary * s, summary * o, boolean full) return; #ifdef SUMMARY_BOM else { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf }; + const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; fwrite(utf8_bom, 1, 3, F); } #endif diff --git a/src/kernel/battle.c b/src/kernel/battle.c index 4af7ace44..5c1fa233f 100644 --- a/src/kernel/battle.c +++ b/src/kernel/battle.c @@ -3673,7 +3673,7 @@ static battle *make_battle(region * r) if (!bdebug) log_error(("battles cannot be debugged\n")); else { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf }; + const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; fwrite(utf8_bom, 1, 3, bdebug); fprintf(bdebug, "In %s findet ein Kampf stattactics:\n", rname(r, default_locale)); diff --git a/src/kernel/skill.h b/src/kernel/skill.h index 8d91aab37..dde1c0721 100644 --- a/src/kernel/skill.h +++ b/src/kernel/skill.h @@ -22,7 +22,7 @@ extern "C" { #define SMF_RIDING (1<<2) /* Bonus für berittene - an der rasse */ typedef struct skill { - unsigned int id:8; + int id:8; unsigned int level:8; unsigned int weeks:8; unsigned int old:8; diff --git a/src/kernel/textstore.c b/src/kernel/textstore.c index 7c12d89be..9fc80f01e 100644 --- a/src/kernel/textstore.c +++ b/src/kernel/textstore.c @@ -60,7 +60,7 @@ static int txt_w_flt(struct storage *store, float arg) static float txt_r_flt(struct storage *store) { double result; - fscanf((FILE *) store->userdata, "%lf", &result); + fscanf((FILE *) store->userdata, "%f", &result); return (float)result; } @@ -135,7 +135,7 @@ static int txt_open(struct storage *store, const char *filename, int mode) FILE *F = fopen(filename, modes[mode]); store->userdata = F; if (F) { - char utf8_bom[4] = { (char)0xef, (char)0xbb, (char)0xbf }; + const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf }; if (mode == IO_READ) { char token[8]; /* recognize UTF8 BOM */ @@ -154,7 +154,7 @@ static int txt_open(struct storage *store, const char *filename, int mode) store->version = atoi(token); } } else if (store->encoding == XML_CHAR_ENCODING_UTF8) { - fputs(utf8_bom, F); + fputs((const char*)utf8_bom, F); fprintf(F, "%d\n", RELEASE_VERSION); } } diff --git a/src/kernel/types.h b/src/kernel/types.h index 2ec5585f3..866a72cc2 100644 --- a/src/kernel/types.h +++ b/src/kernel/types.h @@ -31,10 +31,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. #include typedef short terrain_t; -typedef short direction_t; -typedef short race_t; typedef short magic_t; -typedef short skill_t; typedef short typ_t; typedef short item_t; typedef unsigned int spellid_t; @@ -76,8 +73,7 @@ typedef struct ursprung { /* ----------------- Befehle ----------------------------------- */ -typedef unsigned char keyword_t; -enum { +typedef enum { K_KOMMENTAR, K_BANNER, K_WORK, @@ -148,8 +144,8 @@ enum { K_PROMOTION, K_PAY, MAXKEYWORDS, - NOKEYWORD = (keyword_t) - 1 -}; + NOKEYWORD = -1 +} keyword_t; /* ------------------ Status von Einheiten --------------------- */ @@ -165,8 +161,7 @@ enum { /* ----------------- Parameter --------------------------------- */ -typedef unsigned char param_t; -enum { +typedef enum { P_LOCALE, P_ANY, P_EACH, @@ -218,8 +213,8 @@ enum { P_XELAEN, P_ALLIANCE, MAXPARAMS, - NOPARAM = (param_t) - 1 -}; + NOPARAM = -1 +} param_t; typedef enum { /* Fehler und Meldungen im Report */ MSG_BATTLE, @@ -268,7 +263,7 @@ enum { /* ------------------ Talente ---------------------------------- */ -enum { +typedef enum { SK_ALCHEMY, SK_CROSSBOW, SK_MINING, @@ -299,12 +294,12 @@ enum { SK_STAMINA, SK_WEAPONLESS, MAXSKILLS, - NOSKILL = (skill_t) - 1 -}; + NOSKILL = -1 +} skill_t; /* ------------- Typ von Einheiten ----------------------------- */ -enum { +typedef enum { RC_DWARF, /* 0 - Zwerg */ RC_ELF, RC_GOBLIN = 3, @@ -363,11 +358,11 @@ enum { RC_CLONE, MAXRACES, - NORACE = (race_t) - 1 -}; + NORACE = -1 +} race_t; /* Richtungen */ -enum { +typedef enum { D_NORTHWEST, D_NORTHEAST, D_EAST, @@ -377,8 +372,8 @@ enum { MAXDIRECTIONS, D_PAUSE, D_SPECIAL, - NODIRECTION = (direction_t) - 1 -}; + NODIRECTION = -1 +} direction_t; #define DONT_HELP 0 #define HELP_MONEY 1 /* Mitversorgen von Einheiten */ diff --git a/src/lua-bindings.vcxproj b/src/lua-bindings.vcxproj index 3929ae569..5714a1cbd 100644 --- a/src/lua-bindings.vcxproj +++ b/src/lua-bindings.vcxproj @@ -115,9 +115,6 @@ - - - diff --git a/src/lua-bindings.vcxproj.filters b/src/lua-bindings.vcxproj.filters index cb23911a8..83b65c358 100644 --- a/src/lua-bindings.vcxproj.filters +++ b/src/lua-bindings.vcxproj.filters @@ -89,7 +89,4 @@ Header Files - - - \ No newline at end of file diff --git a/src/modules/score.c b/src/modules/score.c index 40c4f8e29..c65dac5d9 100644 --- a/src/modules/score.c +++ b/src/modules/score.c @@ -155,7 +155,7 @@ void score(void) sprintf(path, "%s/score", basepath()); scoreFP = fopen(path, "w"); if (scoreFP) { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf }; + const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; faction *f; fwrite(utf8_bom, 1, 3, scoreFP); for (f = factions; f; f = f->next) @@ -176,7 +176,7 @@ void score(void) sprintf(path, "%s/score.alliances", basepath()); scoreFP = fopen(path, "w"); if (scoreFP) { - const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf }; + const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 }; fwrite(utf8_bom, 1, 3, scoreFP); fprintf(scoreFP, "# alliance:factions:persons:score\n"); diff --git a/src/platform.h b/src/platform.h index b6d201040..cdf87ea37 100644 --- a/src/platform.h +++ b/src/platform.h @@ -16,8 +16,6 @@ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. **/ -#define _GNU_SOURCE - #ifndef CONFIG_H #define CONFIG_H diff --git a/src/util/strings.c b/src/util/strings.c index ade70fe35..7efa9c032 100644 --- a/src/util/strings.c +++ b/src/util/strings.c @@ -30,45 +30,6 @@ INLINE_FUNCTION unsigned int hashstring(const char *s) return key & 0x7FFFFFFF; } -/* -static const char * -escape_string_inplace(char * buffer, unsigned int len, unsigned int offset) -{ -#define MAXQUOTES 32 - char * o; - char * d[MAXQUOTES+1]; - int i = 0; - - o = strchr(buffer, '"'); - if (!o) { - return buffer; - } - - while (*o && i0) { - const char * src = d[i]; - char * dst = d[i] + i + offset; - size_t mlen = d[i+1] - d[i]; - memmove(dst--, src, mlen); - *dst = '\\'; - } - return buffer; -} -*/ - INLINE_FUNCTION const char *escape_string(const char *str, char *buffer, unsigned int len) { diff --git a/src/util/unicode.c b/src/util/unicode.c index ca7d0fbad..33db457e7 100644 --- a/src/util/unicode.c +++ b/src/util/unicode.c @@ -68,25 +68,25 @@ int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip) } int -unicode_latin1_to_utf8(utf8_t * out, size_t * outlen, const char *in, +unicode_latin1_to_utf8(utf8_t * dst, size_t * outlen, const char *in, size_t * inlen) { int is = (int)*inlen; int os = (int)*outlen; const char *ip = in; - utf8_t *op = out; + unsigned char *out = (unsigned char *)dst, *op = out; while (ip - in < is) { unsigned char c = *ip; if (c > 0xBF) { if (op - out >= os - 1) break; - *op++ = (char) 0xC3; + *op++ = 0xC3; *op++ = c - 64; } else if (c > 0x7F) { if (op - out >= os - 1) break; - *op++ = (char) 0xC2; + *op++ = 0xC2; *op++ = c; } else { if (op - out >= os)