pingus-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pingus-CVS] CVS: Games/Pingus/src game_session.cxx,1.30,1.31 system.cx


From: grumbel
Subject: [Pingus-CVS] CVS: Games/Pingus/src game_session.cxx,1.30,1.31 system.cxx,1.7,1.8 system.hxx,1.6,1.7
Date: 4 Mar 2003 17:02:53 -0000

Update of /usr/local/cvsroot/Games/Pingus/src
In directory dark:/tmp/cvs-serv4773

Modified Files:
        game_session.cxx system.cxx system.hxx 
Log Message:
some cleanup and translator fix


Index: game_session.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/game_session.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- game_session.cxx    3 Mar 2003 20:32:18 -0000       1.30
+++ game_session.cxx    4 Mar 2003 17:02:51 -0000       1.31
@@ -101,20 +101,22 @@
 
   left_over_time = 0;
 
-  int i;
-  for (i = 0; 
-       ((i * update_time < time_passed)
-        || i < min_frame_skip)
-         && !(i > max_frame_skip);
-       ++i)
-    {
-      // This updates the world and all objects
-      server->update ();
-      ++number_of_updates;
-    }
-
-  // Time that got not used for updates
-  left_over_time = time_passed - (i * update_time);
+  {
+    int i;
+    for (i = 0; 
+         ((i * update_time < time_passed)
+          || i < min_frame_skip)
+           && !(i > max_frame_skip);
+         ++i)
+      {
+        // This updates the world and all objects
+        server->update ();
+        ++number_of_updates;
+      }
+      
+    // Time that got not used for updates
+    left_over_time = time_passed - (i * update_time);
+  }
 
   if (!max_cpu_usage && left_over_time < 0)
     {

Index: system.cxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/system.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- system.cxx  18 Feb 2003 18:41:59 -0000      1.7
+++ system.cxx  4 Mar 2003 17:02:51 -0000       1.8
@@ -357,13 +357,9 @@
     return lang.substr (0, 2);
 }
 
-const std::string&
+std::string
 System::translate(const std::map<std::string, std::string>& strs)
 {
-  // FIXME: Hack...
-  static std::string nothing1 = "<translator bug1>";
-  static std::string nothing2 = "<translator bug2>";
-
   if (pingus_debug_flags & PINGUS_DEBUG_TRANSLATOR)
     {
       std::cout << ",-- [ Translator: lang=" << System::get_language () 
@@ -378,22 +374,36 @@
 
   std::map<std::string, std::string>::const_iterator p = 
strs.find(System::get_language());
 
-  if (p != strs.end ())
-    {
-      const std::string& str = p->second;
-  
-      if (str.empty())
+  if (p == strs.end ())
+    { // No native-language text found, fallback to default
+      return translate_default(strs);
+    }
+  else
+    { // Native language was empty, try default fallback
+      if (p->second.empty())
        {
-         std::map<std::string, std::string>::const_iterator p2 = 
strs.find(default_language);
-         if (p2 != strs.end ())
-           return p2->second;
-         else
-           return nothing2;
+          return translate_default(strs);
        }
       else
-       return str;
+        {
+          return p->second;
+        }
+    }
+}
+
+std::string
+System::translate_default(const std::map<std::string, std::string>& strs)
+{
+  std::map<std::string, std::string>::const_iterator default_text = 
strs.find(default_language);
+
+  if (default_text == strs.end())
+    { // no 'en' default text given probally a bug in the level data
+      return "<Translation Bug: no 'en' text given>";
+    }
+  else
+    {
+      return default_text->second;
     }
-  return nothing1;
 }
 
 /** Read file and create a checksum and return it */

Index: system.hxx
===================================================================
RCS file: /usr/local/cvsroot/Games/Pingus/src/system.hxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- system.hxx  27 Sep 2002 11:26:44 -0000      1.6
+++ system.hxx  4 Mar 2003 17:02:51 -0000       1.7
@@ -121,7 +121,10 @@
 
   /** Choose the correct translation out of the map, if there is none
       present, fall back to the default language */
-  static const std::string& translate(const std::map<std::string, 
std::string>& strs);
+  static std::string translate(const std::map<std::string, std::string>& strs);
+
+  /** Translate to 'en' */
+  static std::string translate_default(const std::map<std::string, 
std::string>& strs);
 
   /** Read a file and generate a checksum and return it. The checksum
    generation is very primitiv and should probably be replaced by CRC





reply via email to

[Prev in Thread] Current Thread [Next in Thread]