forked from github/server
eressea-pbem.de no longer exists
improve default_order generation, save memory.
This commit is contained in:
parent
7b6a719a62
commit
9065334677
|
@ -137,7 +137,6 @@ static void game_init(void)
|
|||
register_cr();
|
||||
register_xr();
|
||||
|
||||
debug_language("locales.log");
|
||||
register_names();
|
||||
register_resources();
|
||||
register_buildings();
|
||||
|
|
|
@ -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(i<MAXLOCALES);
|
||||
result = defaults[i];
|
||||
if (!result) {
|
||||
const char * str = locale_string(lang, "defaultorder");
|
||||
if (str) {
|
||||
result = defaults[i] = parse_order(str, lang);
|
||||
}
|
||||
}
|
||||
return result ? copy_order(result) : 0;
|
||||
}
|
||||
|
||||
int entertainmoney(const region * r)
|
||||
|
@ -3284,10 +3296,17 @@ int markets_module(void)
|
|||
*/
|
||||
void free_gamedata(void)
|
||||
{
|
||||
int i;
|
||||
free_units();
|
||||
free_regions();
|
||||
free_borders();
|
||||
|
||||
for (i=0;i!=MAXLOCALES;++i) {
|
||||
if (defaults[i]) {
|
||||
free_order(defaults[i]);
|
||||
defaults[i] = 0;
|
||||
}
|
||||
}
|
||||
while (alliances) {
|
||||
alliance *al = alliances;
|
||||
alliances = al->next;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| | Enno Rehling <enno@eressea.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2001 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
|
|
Loading…
Reference in New Issue