forked from github/server
use enums, fix typecasts
This commit is contained in:
parent
496aa22e65
commit
04b3d7ff45
|
@ -1438,7 +1438,7 @@ report_computer(const char *filename, report_context * ctx, const char *charset)
|
||||||
perror(filename);
|
perror(filename);
|
||||||
return -1;
|
return -1;
|
||||||
} else if (enc == XML_CHAR_ENCODING_UTF8) {
|
} 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);
|
fwrite(utf8_bom, 1, 3, F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1495,7 +1495,7 @@ report_template(const char *filename, report_context * ctx, const char *charset)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enc == XML_CHAR_ENCODING_UTF8) {
|
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);
|
fwrite(utf8_bom, 1, 3, F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2141,7 +2141,7 @@ report_plaintext(const char *filename, report_context * ctx,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if (enc == XML_CHAR_ENCODING_UTF8) {
|
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);
|
fwrite(utf8_bom, 1, 3, F);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,7 +149,7 @@ void report_summary(summary * s, summary * o, boolean full)
|
||||||
return;
|
return;
|
||||||
#ifdef SUMMARY_BOM
|
#ifdef SUMMARY_BOM
|
||||||
else {
|
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);
|
fwrite(utf8_bom, 1, 3, F);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -3673,7 +3673,7 @@ static battle *make_battle(region * r)
|
||||||
if (!bdebug)
|
if (!bdebug)
|
||||||
log_error(("battles cannot be debugged\n"));
|
log_error(("battles cannot be debugged\n"));
|
||||||
else {
|
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);
|
fwrite(utf8_bom, 1, 3, bdebug);
|
||||||
fprintf(bdebug, "In %s findet ein Kampf stattactics:\n", rname(r,
|
fprintf(bdebug, "In %s findet ein Kampf stattactics:\n", rname(r,
|
||||||
default_locale));
|
default_locale));
|
||||||
|
|
|
@ -22,7 +22,7 @@ extern "C" {
|
||||||
#define SMF_RIDING (1<<2) /* Bonus für berittene - an der rasse */
|
#define SMF_RIDING (1<<2) /* Bonus für berittene - an der rasse */
|
||||||
|
|
||||||
typedef struct skill {
|
typedef struct skill {
|
||||||
unsigned int id:8;
|
int id:8;
|
||||||
unsigned int level:8;
|
unsigned int level:8;
|
||||||
unsigned int weeks:8;
|
unsigned int weeks:8;
|
||||||
unsigned int old:8;
|
unsigned int old:8;
|
||||||
|
|
|
@ -60,7 +60,7 @@ static int txt_w_flt(struct storage *store, float arg)
|
||||||
static float txt_r_flt(struct storage *store)
|
static float txt_r_flt(struct storage *store)
|
||||||
{
|
{
|
||||||
double result;
|
double result;
|
||||||
fscanf((FILE *) store->userdata, "%lf", &result);
|
fscanf((FILE *) store->userdata, "%f", &result);
|
||||||
return (float)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]);
|
FILE *F = fopen(filename, modes[mode]);
|
||||||
store->userdata = F;
|
store->userdata = F;
|
||||||
if (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) {
|
if (mode == IO_READ) {
|
||||||
char token[8];
|
char token[8];
|
||||||
/* recognize UTF8 BOM */
|
/* recognize UTF8 BOM */
|
||||||
|
@ -154,7 +154,7 @@ static int txt_open(struct storage *store, const char *filename, int mode)
|
||||||
store->version = atoi(token);
|
store->version = atoi(token);
|
||||||
}
|
}
|
||||||
} else if (store->encoding == XML_CHAR_ENCODING_UTF8) {
|
} else if (store->encoding == XML_CHAR_ENCODING_UTF8) {
|
||||||
fputs(utf8_bom, F);
|
fputs((const char*)utf8_bom, F);
|
||||||
fprintf(F, "%d\n", RELEASE_VERSION);
|
fprintf(F, "%d\n", RELEASE_VERSION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,10 +31,7 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
#include <util/variant.h>
|
#include <util/variant.h>
|
||||||
|
|
||||||
typedef short terrain_t;
|
typedef short terrain_t;
|
||||||
typedef short direction_t;
|
|
||||||
typedef short race_t;
|
|
||||||
typedef short magic_t;
|
typedef short magic_t;
|
||||||
typedef short skill_t;
|
|
||||||
typedef short typ_t;
|
typedef short typ_t;
|
||||||
typedef short item_t;
|
typedef short item_t;
|
||||||
typedef unsigned int spellid_t;
|
typedef unsigned int spellid_t;
|
||||||
|
@ -76,8 +73,7 @@ typedef struct ursprung {
|
||||||
|
|
||||||
/* ----------------- Befehle ----------------------------------- */
|
/* ----------------- Befehle ----------------------------------- */
|
||||||
|
|
||||||
typedef unsigned char keyword_t;
|
typedef enum {
|
||||||
enum {
|
|
||||||
K_KOMMENTAR,
|
K_KOMMENTAR,
|
||||||
K_BANNER,
|
K_BANNER,
|
||||||
K_WORK,
|
K_WORK,
|
||||||
|
@ -148,8 +144,8 @@ enum {
|
||||||
K_PROMOTION,
|
K_PROMOTION,
|
||||||
K_PAY,
|
K_PAY,
|
||||||
MAXKEYWORDS,
|
MAXKEYWORDS,
|
||||||
NOKEYWORD = (keyword_t) - 1
|
NOKEYWORD = -1
|
||||||
};
|
} keyword_t;
|
||||||
|
|
||||||
/* ------------------ Status von Einheiten --------------------- */
|
/* ------------------ Status von Einheiten --------------------- */
|
||||||
|
|
||||||
|
@ -165,8 +161,7 @@ enum {
|
||||||
|
|
||||||
/* ----------------- Parameter --------------------------------- */
|
/* ----------------- Parameter --------------------------------- */
|
||||||
|
|
||||||
typedef unsigned char param_t;
|
typedef enum {
|
||||||
enum {
|
|
||||||
P_LOCALE,
|
P_LOCALE,
|
||||||
P_ANY,
|
P_ANY,
|
||||||
P_EACH,
|
P_EACH,
|
||||||
|
@ -218,8 +213,8 @@ enum {
|
||||||
P_XELAEN,
|
P_XELAEN,
|
||||||
P_ALLIANCE,
|
P_ALLIANCE,
|
||||||
MAXPARAMS,
|
MAXPARAMS,
|
||||||
NOPARAM = (param_t) - 1
|
NOPARAM = -1
|
||||||
};
|
} param_t;
|
||||||
|
|
||||||
typedef enum { /* Fehler und Meldungen im Report */
|
typedef enum { /* Fehler und Meldungen im Report */
|
||||||
MSG_BATTLE,
|
MSG_BATTLE,
|
||||||
|
@ -268,7 +263,7 @@ enum {
|
||||||
|
|
||||||
/* ------------------ Talente ---------------------------------- */
|
/* ------------------ Talente ---------------------------------- */
|
||||||
|
|
||||||
enum {
|
typedef enum {
|
||||||
SK_ALCHEMY,
|
SK_ALCHEMY,
|
||||||
SK_CROSSBOW,
|
SK_CROSSBOW,
|
||||||
SK_MINING,
|
SK_MINING,
|
||||||
|
@ -299,12 +294,12 @@ enum {
|
||||||
SK_STAMINA,
|
SK_STAMINA,
|
||||||
SK_WEAPONLESS,
|
SK_WEAPONLESS,
|
||||||
MAXSKILLS,
|
MAXSKILLS,
|
||||||
NOSKILL = (skill_t) - 1
|
NOSKILL = -1
|
||||||
};
|
} skill_t;
|
||||||
|
|
||||||
/* ------------- Typ von Einheiten ----------------------------- */
|
/* ------------- Typ von Einheiten ----------------------------- */
|
||||||
|
|
||||||
enum {
|
typedef enum {
|
||||||
RC_DWARF, /* 0 - Zwerg */
|
RC_DWARF, /* 0 - Zwerg */
|
||||||
RC_ELF,
|
RC_ELF,
|
||||||
RC_GOBLIN = 3,
|
RC_GOBLIN = 3,
|
||||||
|
@ -363,11 +358,11 @@ enum {
|
||||||
RC_CLONE,
|
RC_CLONE,
|
||||||
|
|
||||||
MAXRACES,
|
MAXRACES,
|
||||||
NORACE = (race_t) - 1
|
NORACE = -1
|
||||||
};
|
} race_t;
|
||||||
|
|
||||||
/* Richtungen */
|
/* Richtungen */
|
||||||
enum {
|
typedef enum {
|
||||||
D_NORTHWEST,
|
D_NORTHWEST,
|
||||||
D_NORTHEAST,
|
D_NORTHEAST,
|
||||||
D_EAST,
|
D_EAST,
|
||||||
|
@ -377,8 +372,8 @@ enum {
|
||||||
MAXDIRECTIONS,
|
MAXDIRECTIONS,
|
||||||
D_PAUSE,
|
D_PAUSE,
|
||||||
D_SPECIAL,
|
D_SPECIAL,
|
||||||
NODIRECTION = (direction_t) - 1
|
NODIRECTION = -1
|
||||||
};
|
} direction_t;
|
||||||
|
|
||||||
#define DONT_HELP 0
|
#define DONT_HELP 0
|
||||||
#define HELP_MONEY 1 /* Mitversorgen von Einheiten */
|
#define HELP_MONEY 1 /* Mitversorgen von Einheiten */
|
||||||
|
|
|
@ -115,9 +115,6 @@
|
||||||
<ClInclude Include="bindings\bindings.h" />
|
<ClInclude Include="bindings\bindings.h" />
|
||||||
<ClInclude Include="bindings\helpers.h" />
|
<ClInclude Include="bindings\helpers.h" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Jamfile" />
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
<ImportGroup Label="ExtensionTargets">
|
<ImportGroup Label="ExtensionTargets">
|
||||||
</ImportGroup>
|
</ImportGroup>
|
||||||
|
|
|
@ -89,7 +89,4 @@
|
||||||
<Filter>Header Files</Filter>
|
<Filter>Header Files</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="Jamfile" />
|
|
||||||
</ItemGroup>
|
|
||||||
</Project>
|
</Project>
|
|
@ -155,7 +155,7 @@ void score(void)
|
||||||
sprintf(path, "%s/score", basepath());
|
sprintf(path, "%s/score", basepath());
|
||||||
scoreFP = fopen(path, "w");
|
scoreFP = fopen(path, "w");
|
||||||
if (scoreFP) {
|
if (scoreFP) {
|
||||||
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf };
|
const unsigned char utf8_bom[4] = { 0xef, 0xbb, 0xbf, 0 };
|
||||||
faction *f;
|
faction *f;
|
||||||
fwrite(utf8_bom, 1, 3, scoreFP);
|
fwrite(utf8_bom, 1, 3, scoreFP);
|
||||||
for (f = factions; f; f = f->next)
|
for (f = factions; f; f = f->next)
|
||||||
|
@ -176,7 +176,7 @@ void score(void)
|
||||||
sprintf(path, "%s/score.alliances", basepath());
|
sprintf(path, "%s/score.alliances", basepath());
|
||||||
scoreFP = fopen(path, "w");
|
scoreFP = fopen(path, "w");
|
||||||
if (scoreFP) {
|
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);
|
fwrite(utf8_bom, 1, 3, scoreFP);
|
||||||
|
|
||||||
fprintf(scoreFP, "# alliance:factions:persons:score\n");
|
fprintf(scoreFP, "# alliance:factions:persons:score\n");
|
||||||
|
|
|
@ -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.
|
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||||
**/
|
**/
|
||||||
|
|
||||||
#define _GNU_SOURCE
|
|
||||||
|
|
||||||
#ifndef CONFIG_H
|
#ifndef CONFIG_H
|
||||||
#define CONFIG_H
|
#define CONFIG_H
|
||||||
|
|
||||||
|
|
|
@ -30,45 +30,6 @@ INLINE_FUNCTION unsigned int hashstring(const char *s)
|
||||||
return key & 0x7FFFFFFF;
|
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 && i<MAXQUOTES) {
|
|
||||||
char * next = strchr(o, '"');
|
|
||||||
d[i++] = o;
|
|
||||||
o = next?next:(o+strlen(o));
|
|
||||||
}
|
|
||||||
d[i] = o;
|
|
||||||
if (i<MAXQUOTES) {
|
|
||||||
// more than 32 hits! must go recursive
|
|
||||||
char * start = d[i];
|
|
||||||
unsigned int nlen = len - (start-buffer) - MAXQUOTES;
|
|
||||||
escape_string_inplace(start, nlen, MAXQUOTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
o[i] = '\0';
|
|
||||||
while (--i>0) {
|
|
||||||
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,
|
INLINE_FUNCTION const char *escape_string(const char *str, char *buffer,
|
||||||
unsigned int len)
|
unsigned int len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -68,25 +68,25 @@ int unicode_utf8_tolower(utf8_t * op, size_t outlen, const utf8_t * ip)
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
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)
|
size_t * inlen)
|
||||||
{
|
{
|
||||||
int is = (int)*inlen;
|
int is = (int)*inlen;
|
||||||
int os = (int)*outlen;
|
int os = (int)*outlen;
|
||||||
const char *ip = in;
|
const char *ip = in;
|
||||||
utf8_t *op = out;
|
unsigned char *out = (unsigned char *)dst, *op = out;
|
||||||
|
|
||||||
while (ip - in < is) {
|
while (ip - in < is) {
|
||||||
unsigned char c = *ip;
|
unsigned char c = *ip;
|
||||||
if (c > 0xBF) {
|
if (c > 0xBF) {
|
||||||
if (op - out >= os - 1)
|
if (op - out >= os - 1)
|
||||||
break;
|
break;
|
||||||
*op++ = (char) 0xC3;
|
*op++ = 0xC3;
|
||||||
*op++ = c - 64;
|
*op++ = c - 64;
|
||||||
} else if (c > 0x7F) {
|
} else if (c > 0x7F) {
|
||||||
if (op - out >= os - 1)
|
if (op - out >= os - 1)
|
||||||
break;
|
break;
|
||||||
*op++ = (char) 0xC2;
|
*op++ = 0xC2;
|
||||||
*op++ = c;
|
*op++ = c;
|
||||||
} else {
|
} else {
|
||||||
if (op - out >= os)
|
if (op - out >= os)
|
||||||
|
|
Loading…
Reference in New Issue