From 9065334677f61cf4f05378d0e124f761ef818958 Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Wed, 16 May 2012 13:07:28 -0700 Subject: [PATCH] eressea-pbem.de no longer exists improve default_order generation, save memory. --- src/eressea.c | 1 - src/kernel/config.c | 21 ++++++++++++++++++++- src/settings.h | 2 +- src/util/language.c | 27 +++++---------------------- src/util/language.h | 5 +++-- src/util/language_struct.h | 3 +-- tools/atoi36.c | 2 +- tools/namegen.c | 2 +- 8 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/eressea.c b/src/eressea.c index e637d2292..f3620b2a5 100644 --- a/src/eressea.c +++ b/src/eressea.c @@ -137,7 +137,6 @@ static void game_init(void) register_cr(); register_xr(); - debug_language("locales.log"); register_names(); register_resources(); register_buildings(); diff --git a/src/kernel/config.c b/src/kernel/config.c index 1e90fc778..d2b5d4541 100644 --- a/src/kernel/config.c +++ b/src/kernel/config.c @@ -3238,9 +3238,21 @@ void kernel_init(void) } } +static order * defaults[MAXLOCALES]; + order *default_order(const struct locale *lang) { - return parse_order(locale_string(lang, "defaultorder"), lang); + int i = locale_index(lang); + order *result = 0; + assert(inext; diff --git a/src/settings.h b/src/settings.h index 3333ec8de..fd0607625 100644 --- a/src/settings.h +++ b/src/settings.h @@ -1,6 +1,6 @@ /* vi: set ts=2: +-------------------+ Christian Schlittchen - | | Enno Rehling + | | Enno Rehling | Eressea PBEM host | Katja Zedel | (c) 1998 - 2003 | Henning Peters | | Ingo Wilken diff --git a/src/util/language.c b/src/util/language.c index d38c0ba0b..0616bdba8 100644 --- a/src/util/language.c +++ b/src/util/language.c @@ -34,10 +34,10 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. locale *default_locale; locale *locales; -unsigned int locale_hashkey(const locale * lang) +unsigned int locale_index(const locale * lang) { assert(lang); - return lang->hashkey; + return lang->index; } locale *find_locale(const char *name) @@ -49,7 +49,7 @@ locale *find_locale(const char *name) return l; } -static int nextlocaleindex = 0; +static unsigned int nextlocaleindex = 0; locale *make_locale(const char *name) { @@ -95,14 +95,6 @@ void make_locales(const char *str) } } -static FILE *s_debug = NULL; -static char *s_logfile = NULL; - -void debug_language(const char *log) -{ - s_logfile = strdup(log); -} - const char *locale_getstring(const locale * lang, const char *key) { unsigned int hkey = hashstring(key); @@ -156,21 +148,12 @@ const char *locale_string(const locale * lang, const char *key) find = find->nexthash; } if (!find) { - const char *s = key; log_warning(("missing translation for \"%s\" in locale %s\n", key, lang->name)); if (lang != default_locale) { - s = locale_string(default_locale, key); + return locale_string(default_locale, key); } - if (s_logfile) { - s_debug = s_debug ? s_debug : fopen(s_logfile, "w"); - if (s_debug) { - fprintf(s_debug, "%s;%s;%s\n", key, lang->name, s); - fflush(s_debug); - locale_setstring((struct locale *)lang, key, s); - } - } - return s; + return 0; } return find->str; } diff --git a/src/util/language.h b/src/util/language.h index 3953a5712..e851865a0 100644 --- a/src/util/language.h +++ b/src/util/language.h @@ -22,6 +22,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. extern "C" { #endif +#define MAXLOCALES 3 + struct locale; /** managing multiple locales: **/ @@ -34,13 +36,12 @@ extern "C" { extern const char *locale_getstring(const struct locale *lang, const char *key); extern const char *locale_string(const struct locale *lang, const char *key); /* does fallback */ - extern unsigned int locale_hashkey(const struct locale *lang); + extern unsigned int locale_index(const struct locale *lang); extern const char *locale_name(const struct locale *lang); extern const char *mkname(const char *namespc, const char *key); extern char *mkname_buf(const char *namespc, const char *key, char *buffer); - extern void debug_language(const char *log); extern void make_locales(const char *str); #define LOC(lang, s) (lang?locale_string(lang, s):s) diff --git a/src/util/language_struct.h b/src/util/language_struct.h index 3b1d0e9bc..616998213 100644 --- a/src/util/language_struct.h +++ b/src/util/language_struct.h @@ -5,7 +5,6 @@ * feel that you need to include it, it's a sure sign that you're trying to * do something BAD. */ -#define MAXLOCALES 3 #define SMAXHASH 2048 typedef struct locale_str { unsigned int hashkey; @@ -15,7 +14,7 @@ typedef struct locale_str { } locale_str; typedef struct locale { - int index; + unsigned int index; struct locale *next; unsigned int hashkey; const char *name; diff --git a/tools/atoi36.c b/tools/atoi36.c index 678fa248d..b93fab3a4 100644 --- a/tools/atoi36.c +++ b/tools/atoi36.c @@ -1,6 +1,6 @@ /* vi: set ts=2: +-------------------+ Christian Schlittchen - | | Enno Rehling + | | Enno Rehling | Eressea PBEM host | Katja Zedel | (c) 1998 - 2001 | Henning Peters | | Ingo Wilken diff --git a/tools/namegen.c b/tools/namegen.c index 175e1cbe0..924524179 100644 --- a/tools/namegen.c +++ b/tools/namegen.c @@ -1,6 +1,6 @@ /* vi: set ts=2: +-------------------+ Christian Schlittchen - | | Enno Rehling + | | Enno Rehling | Eressea PBEM host | Katja Zedel | (c) 1998 - 2001 | Henning Peters | | Ingo Wilken