From b132ffdd2bea524cac3cb476baab656a420e9ae5 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 19 Aug 2007 20:40:42 +0000 Subject: [PATCH] Unicode WIP: - links on Linux (Jamfile changes) - bugfix latin1/newfactions file --- src/common/gamecode/Jamfile | 3 ++- src/common/gamecode/report.c | 12 ++++++------ src/common/kernel/region.c | 14 +++++++++----- src/common/kernel/region.h | 2 +- src/common/modules/autoseed.c | 14 ++++++++++++++ src/common/races/Jamfile | 1 + src/common/util/Jamfile | 1 + src/eressea/server.cpp | 2 +- src/scripts/eressea.lua | 6 ++---- 9 files changed, 37 insertions(+), 18 deletions(-) diff --git a/src/common/gamecode/Jamfile b/src/common/gamecode/Jamfile index bf6e16ea1..1d693b573 100644 --- a/src/common/gamecode/Jamfile +++ b/src/common/gamecode/Jamfile @@ -18,10 +18,11 @@ SOURCES = luck.c monster.c randenc.c -# report.c + report.c spells.c spy.c study.c + summary.c xmlreport.c ; diff --git a/src/common/gamecode/report.c b/src/common/gamecode/report.c index 5256f51d0..1401d16d3 100644 --- a/src/common/gamecode/report.c +++ b/src/common/gamecode/report.c @@ -908,12 +908,12 @@ describe(FILE * F, const region * r, int partial, faction * f) /* Spezielle Richtungen */ for (a = a_find(r->attribs, &at_direction);a && a->type==&at_direction;a=a->next) { spec_direction * d = (spec_direction *)(a->data.v); - strcpy(bufp++, " "); - bufp += strxcpy(bufp, d->desc); - bufp += strxcpy(bufp, " (\""); - bufp += strxcpy(bufp, d->keyword); - bufp += strxcpy(bufp, "\")"); - strcpy(bufp++, "."); + bufp += strlcpy(bufp, " ", sizeof(buf) - (bufp-buf)); + bufp += strlcpy(bufp, LOC(f->locale, d->desc), sizeof(buf) - (bufp-buf)); + bufp += strlcpy(bufp, " (\"", sizeof(buf) - (bufp-buf)); + bufp += strlcpy(bufp, LOC(f->locale, d->keyword), sizeof(buf) - (bufp-buf)); + bufp += strlcpy(bufp, "\")", sizeof(buf) - (bufp-buf)); + bufp += strlcpy(bufp, ".", sizeof(buf) - (bufp-buf)); dh = 1; } } diff --git a/src/common/kernel/region.c b/src/common/kernel/region.c index 4cd8a273a..cf4ffbf5b 100644 --- a/src/common/kernel/region.c +++ b/src/common/kernel/region.c @@ -248,21 +248,21 @@ register_special_direction(const char * name) static int a_readdirection(attrib *a, FILE *f) { - char lbuf[16]; spec_direction *d = (spec_direction *)(a->data.v); fscanf(f, "%hd %hd %d", &d->x, &d->y, &d->duration); - fscanf(f, "%15s ", lbuf); - d->desc = strdup(lbuf); - fscanf(f, "%15s ", lbuf); if (global.data_versiondesc); cstring_i(lbuf); for (;dl;dl=dl->next) { if (strcmp(lbuf, dl->oldname)==0) { d->keyword=strdup(dl->name); + sprintf(lbuf, "%s_desc", d->keyword); + d->desc=strdup(dl->name); break; } } @@ -272,6 +272,10 @@ a_readdirection(attrib *a, FILE *f) } } else { + char lbuf[16]; + fscanf(f, "%15s ", lbuf); + d->desc = strdup(lbuf); + fscanf(f, "%15s ", lbuf); d->keyword = strdup(lbuf); } d->active = true; diff --git a/src/common/kernel/region.h b/src/common/kernel/region.h index eba1a3ec6..178dd4edb 100644 --- a/src/common/kernel/region.h +++ b/src/common/kernel/region.h @@ -169,7 +169,7 @@ extern struct region * find_special_direction(const struct region *r, const char extern void register_special_direction(const char * name); extern struct spec_direction * special_direction(const region * from, const region * to); extern struct attrib *create_special_direction(struct region *r, struct region *rt, - int duration, const char *desc, + int duration, const char *desc, const char *keyword); int deathcount(const struct region * r); diff --git a/src/common/modules/autoseed.c b/src/common/modules/autoseed.c index 862d18202..0c98630e1 100644 --- a/src/common/modules/autoseed.c +++ b/src/common/modules/autoseed.c @@ -33,6 +33,8 @@ #include #include +#include + /* libc includes */ #include #include @@ -239,6 +241,18 @@ read_newfactions(const char * filename) /* if the script didn't supply the race as a token, then it gives us a * race in the default locale (which means that itis a UTF8 string) */ nf->race = findrace(race, default_locale); + if (nf->race==NULL) { + char buffer[32]; + int outbytes = sizeof(buffer); + int inbytes = strlen(race); + isolat1ToUTF8((unsigned char *)buffer, &outbytes, (const unsigned char *)race, &inbytes); + nf->race = findrace(buffer, default_locale); + if (nf->race==NULL) { + log_error(("new faction has unknown race '%s'.\n", race)); + free(nf); + continue; + } + } } nf->lang = find_locale(lang); nf->bonus = bonus; diff --git a/src/common/races/Jamfile b/src/common/races/Jamfile index d8b50ab54..cff0136e3 100644 --- a/src/common/races/Jamfile +++ b/src/common/races/Jamfile @@ -11,6 +11,7 @@ SubDirHdrs $(XMLHDRS) ; SOURCES = dragons.c illusion.c + races.c zombies.c ; diff --git a/src/common/util/Jamfile b/src/common/util/Jamfile index 16d79e100..edb69e0e8 100644 --- a/src/common/util/Jamfile +++ b/src/common/util/Jamfile @@ -16,6 +16,7 @@ SOURCES = cvector.c dice.c event.c + filereader.c functions.c goodies.c graph.c diff --git a/src/eressea/server.cpp b/src/eressea/server.cpp index 07a3d10f9..8faa3d9aa 100644 --- a/src/eressea/server.cpp +++ b/src/eressea/server.cpp @@ -620,7 +620,7 @@ load_inifile(const char * filename) luafile = iniparser_getstring(d, "eressea:run", luafile); g_reportdir = iniparser_getstring(d, "eressea:report", g_reportdir); - str = iniparser_getstring(d, "common:locales", "de"); + str = iniparser_getstring(d, "common:locales", "de,en"); make_locales(str); } inifile = d; diff --git a/src/scripts/eressea.lua b/src/scripts/eressea.lua index f89cb6a11..83b8c443f 100644 --- a/src/scripts/eressea.lua +++ b/src/scripts/eressea.lua @@ -1,7 +1,5 @@ -- the locales that this gameworld supports. local locales = { "de", "en" } -enc_orders = "ISO-8859-1" -enc_game = "ISO-8859-1" function loadscript(name) local script = scriptpath .. "/" .. name @@ -56,7 +54,7 @@ function process(orders) equipment_setitem("new_faction", "money", "4200"); file = "" .. get_turn() - set_encoding(enc_game) + -- set_encoding(enc_game) if read_game(file)~=0 then print("could not read game") return -1 @@ -67,7 +65,7 @@ function process(orders) loadscript("eressea/multis.lua") -- run the turn: - if read_orders(orders, enc_orders) ~= 0 then + if read_orders(orders) ~= 0 then print("could not read " .. orders) return -1 end