From 6309d7ad56357e3aecbfeb7096b434a03bdc70a8 Mon Sep 17 00:00:00 2001 From: Magnus Auvinen Date: Mon, 15 Jun 2009 06:45:44 +0000 Subject: continued with localization --- src/game/localization.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'src/game/localization.cpp') diff --git a/src/game/localization.cpp b/src/game/localization.cpp index 58ec539c..110a0f5e 100644 --- a/src/game/localization.cpp +++ b/src/game/localization.cpp @@ -1,5 +1,6 @@ #include "localization.hpp" +#include extern "C" { #include @@ -16,7 +17,6 @@ static unsigned str_hash(const char *str) const char *localize(const char *str) { const char *new_str = localization.find_string(str_hash(str)); - //dbg_msg("", "no localization for '%s'", str); return new_str ? new_str : str; } @@ -86,15 +86,19 @@ bool LOCALIZATIONDATABASE::load(const char *filename) replacement += 3; localization.add_string(line, replacement); } - + current_version++; return true; } const char *LOCALIZATIONDATABASE::find_string(unsigned hash) { - array::range r = ::find(strings.all(), hash); + STRING s; + s.hash = hash; + sorted_array::range r = ::find_binary(strings.all(), s); if(r.empty()) return 0; return r.front().replacement; } + +LOCALIZATIONDATABASE localization; -- cgit 1.4.1