Index: trunk/src/lib/event/key_mapper.cc
===================================================================
--- trunk/src/lib/event/key_mapper.cc	(revision 9869)
+++ trunk/src/lib/event/key_mapper.cc	(revision 9880)
@@ -74,38 +74,38 @@
  */
 KeyMapper::KeyMapping KeyMapper::map[] = {
-  {&KeyMapper::PEV_FORWARD,              CONFIG_NAME_PLAYER_FORWARD,         SDLK_w},
-  {&KeyMapper::PEV_BACKWARD,             CONFIG_NAME_PLAYER_BACKWARD,        SDLK_s},
-  {&KeyMapper::PEV_UP,                   CONFIG_NAME_PLAYER_UP,              SDLK_r},
-  {&KeyMapper::PEV_DOWN,                 CONFIG_NAME_PLAYER_DOWN,            SDLK_f},
-  {&KeyMapper::PEV_LEFT,                 CONFIG_NAME_PLAYER_LEFT,            SDLK_a},
-  {&KeyMapper::PEV_RIGHT,                CONFIG_NAME_PLAYER_RIGHT,           SDLK_d},
-  {&KeyMapper::PEV_ROLL_RIGHT,           CONFIG_NAME_PLAYER_ROLL_LEFT,       SDLK_z},
-  {&KeyMapper::PEV_ROLL_LEFT,            CONFIG_NAME_PLAYER_ROLL_RIGHT,      SDLK_c},
-  {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft",                       SDLK_q},
-  {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight",                      SDLK_e},
-  {&KeyMapper::PEV_JUMP,                 "Jump",                             SDLK_SPACE},
-
-  {&KeyMapper::PEV_FIRE1,                CONFIG_NAME_PLAYER_FIRE,            EV_MOUSE_BUTTON_LEFT},
-  {&KeyMapper::PEV_FIRE2,                "Fire2",                            EV_MOUSE_BUTTON_RIGHT},
-  {&KeyMapper::PEV_NEXT_WEAPON,          CONFIG_NAME_PLAYER_NEXT_WEAPON,     EV_MOUSE_BUTTON_WHEELUP},
-  {&KeyMapper::PEV_PREVIOUS_WEAPON,      CONFIG_NAME_PLAYER_PREV_WEAPON,     EV_MOUSE_BUTTON_WHEELDOWN},
-
-  {&KeyMapper::PEV_CHANGE_SHIP,          CONFIG_NAME_PLAYER_CHANGE_SHIP,     SDLK_g},
-
-
-  {&KeyMapper::PEV_VIEW0,                CONFIG_NAME_VIEW0,                  SDLK_1},
-  {&KeyMapper::PEV_VIEW1,                CONFIG_NAME_VIEW1,                  SDLK_2},
-  {&KeyMapper::PEV_VIEW2,                CONFIG_NAME_VIEW2,                  SDLK_3},
-  {&KeyMapper::PEV_VIEW3,                CONFIG_NAME_VIEW3,                  SDLK_4},
-  {&KeyMapper::PEV_VIEW4,                CONFIG_NAME_VIEW4,                  SDLK_5},
-  {&KeyMapper::PEV_VIEW5,                CONFIG_NAME_VIEW5,                  SDLK_6},
-
-  {&KeyMapper::PEV_NEXT_WORLD,           CONFIG_NAME_NEXT_WORLD,             SDLK_x},
-  {&KeyMapper::PEV_PREVIOUS_WORLD,       CONFIG_NAME_PREV_WORLD,             SDLK_z},
-
-  {&KeyMapper::PEV_PAUSE,                CONFIG_NAME_PAUSE,                  SDLK_p},
-  {&KeyMapper::PEV_QUIT,                 CONFIG_NAME_QUIT,                   SDLK_ESCAPE},
-  {NULL, "", 0}
-};
+      {&KeyMapper::PEV_FORWARD,              CONFIG_NAME_PLAYER_FORWARD,         SDLK_w},
+      {&KeyMapper::PEV_BACKWARD,             CONFIG_NAME_PLAYER_BACKWARD,        SDLK_s},
+      {&KeyMapper::PEV_UP,                   CONFIG_NAME_PLAYER_UP,              SDLK_r},
+      {&KeyMapper::PEV_DOWN,                 CONFIG_NAME_PLAYER_DOWN,            SDLK_f},
+      {&KeyMapper::PEV_LEFT,                 CONFIG_NAME_PLAYER_LEFT,            SDLK_a},
+      {&KeyMapper::PEV_RIGHT,                CONFIG_NAME_PLAYER_RIGHT,           SDLK_d},
+      {&KeyMapper::PEV_ROLL_RIGHT,           CONFIG_NAME_PLAYER_ROLL_LEFT,       SDLK_z},
+      {&KeyMapper::PEV_ROLL_LEFT,            CONFIG_NAME_PLAYER_ROLL_RIGHT,      SDLK_c},
+      {&KeyMapper::PEV_STRAFE_LEFT,          "StrafeLeft",                       SDLK_q},
+      {&KeyMapper::PEV_STRAFE_RIGHT,         "StrafeRight",                      SDLK_e},
+      {&KeyMapper::PEV_JUMP,                 "Jump",                             SDLK_SPACE},
+
+      {&KeyMapper::PEV_FIRE1,                CONFIG_NAME_PLAYER_FIRE,            EV_MOUSE_BUTTON_LEFT},
+      {&KeyMapper::PEV_FIRE2,                "Fire2",                            EV_MOUSE_BUTTON_RIGHT},
+      {&KeyMapper::PEV_NEXT_WEAPON,          CONFIG_NAME_PLAYER_NEXT_WEAPON,     EV_MOUSE_BUTTON_WHEELUP},
+      {&KeyMapper::PEV_PREVIOUS_WEAPON,      CONFIG_NAME_PLAYER_PREV_WEAPON,     EV_MOUSE_BUTTON_WHEELDOWN},
+
+      {&KeyMapper::PEV_CHANGE_SHIP,          CONFIG_NAME_PLAYER_CHANGE_SHIP,     SDLK_g},
+
+
+      {&KeyMapper::PEV_VIEW0,                CONFIG_NAME_VIEW0,                  SDLK_1},
+      {&KeyMapper::PEV_VIEW1,                CONFIG_NAME_VIEW1,                  SDLK_2},
+      {&KeyMapper::PEV_VIEW2,                CONFIG_NAME_VIEW2,                  SDLK_3},
+      {&KeyMapper::PEV_VIEW3,                CONFIG_NAME_VIEW3,                  SDLK_4},
+      {&KeyMapper::PEV_VIEW4,                CONFIG_NAME_VIEW4,                  SDLK_5},
+      {&KeyMapper::PEV_VIEW5,                CONFIG_NAME_VIEW5,                  SDLK_6},
+
+      {&KeyMapper::PEV_NEXT_WORLD,           CONFIG_NAME_NEXT_WORLD,             SDLK_x},
+      {&KeyMapper::PEV_PREVIOUS_WORLD,       CONFIG_NAME_PREV_WORLD,             SDLK_z},
+
+      {&KeyMapper::PEV_PAUSE,                CONFIG_NAME_PAUSE,                  SDLK_p},
+      {&KeyMapper::PEV_QUIT,                 CONFIG_NAME_QUIT,                   SDLK_ESCAPE},
+      {NULL, "", 0}
+    };
 
 
@@ -124,6 +124,5 @@
 */
 KeyMapper::~KeyMapper ()
-{
-}
+{}
 
 
@@ -140,5 +139,6 @@
 void KeyMapper::loadKeyBindings(IniParser* iniParser)
 {
-  if( !iniParser->getSection (CONFIG_SECTION_CONTROL))
+  IniParser::Section* section = iniParser->getSection (CONFIG_SECTION_CONTROL);
+  if( section == NULL)
   {
     PRINTF(1)("Could not find key bindings " CONFIG_SECTION_CONTROL "\n");
@@ -147,31 +147,32 @@
   int* index;
 
-  iniParser->firstVar();
-  while( iniParser->getCurrentName() != "" )
-  {
-    PRINTF(3)("Keys: Parsing %s, %s now.\n", iniParser->getCurrentName().c_str(), iniParser->getCurrentValue().c_str());
+
+  for(IniParser::Entry::iterator entry = section->begin();
+      entry != section->end();
+      ++entry)
+  {
+    PRINTF(3)("Keys: Parsing %s, %s now.\n", (*entry).name().c_str(), (*entry).value().c_str());
     // map the name to an sdl index
-    index = nameToIndex (iniParser->getCurrentValue());
+    index = nameToIndex ((*entry).value());
     // map the index to a internal name
-    this->mapKeys(iniParser->getCurrentName(), index);
-    iniParser->nextVar();
+    this->mapKeys((*entry).name(), index);
   }
 
 
   // PARSE MISC SECTION
-//   if( !iniParser->getSection (CONFIG_SECTION_MISC_KEYS))
-//   {
-//     PRINTF(1)("Could not find key bindings" CONFIG_SECTION_MISC_KEYS "\n");
-//     return;
-//   }
-//
-//   iniParser->firstVar();
-//   while( iniParser->getCurrentName() != "" )
-//   {
-//     PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
-//     index = nameToIndex (iniParser->getCurrentValue());
-//     this->mapKeys(iniParser->getCurrentName(), index);
-//     iniParser->nextVar();
-//   }
+  //   if( !iniParser->getSection (CONFIG_SECTION_MISC_KEYS))
+  //   {
+  //     PRINTF(1)("Could not find key bindings" CONFIG_SECTION_MISC_KEYS "\n");
+  //     return;
+  //   }
+  //
+  //   iniParser->firstVar();
+  //   while( iniParser->getCurrentName() != "" )
+  //   {
+  //     PRINTF(3)("MISC: Parsing %s, %s now.\n", iniParser->getCurrentName(), iniParser->getCurrentValue());
+  //     index = nameToIndex (iniParser->getCurrentValue());
+  //     this->mapKeys(iniParser->getCurrentName(), index);
+  //     iniParser->nextVar();
+  //   }
 }
 
@@ -205,12 +206,14 @@
   coord[1] = -1;
   int c;
-  if( (c = keynameToSDLK (name)) != -1) {
-      coord[1] = c;
-      coord[0] = 0;
-    }
-  if( (c = buttonnameToSDLB (name)) != -1) {
-      coord[1] = c;
-      coord[0] = 1;
-    }
+  if( (c = keynameToSDLK (name)) != -1)
+  {
+    coord[1] = c;
+    coord[0] = 0;
+  }
+  if( (c = buttonnameToSDLB (name)) != -1)
+  {
+    coord[1] = c;
+    coord[0] = 1;
+  }
   return coord;
 }
@@ -225,20 +228,21 @@
 {
   for( int i = 0; map[i].pValue != NULL; ++i )
+  {
+    if( name == map[i].pName)
     {
-      if( name == map[i].pName)
+      if( index[0] == 0)
       {
-        if( index[0] == 0)
-        {
-          *map[i].pValue = index[1];
-          PRINTF(4)("Mapping %s to '%s' (id %i)\n", name.c_str(), SDLKToKeyname(index[1]).c_str(), index[1]);
-          break;
-        }
-        else {
-          *map[i].pValue = index[1];
-          PRINTF(4)("Mapping %s to '%s' (id %i)\n", name.c_str(), SDLBToButtonname(index[1]).c_str(), index[1]);
-          break;
-        }
+        *map[i].pValue = index[1];
+        PRINTF(4)("Mapping %s to '%s' (id %i)\n", name.c_str(), SDLKToKeyname(index[1]).c_str(), index[1]);
+        break;
+      }
+      else
+      {
+        *map[i].pValue = index[1];
+        PRINTF(4)("Mapping %s to '%s' (id %i)\n", name.c_str(), SDLBToButtonname(index[1]).c_str(), index[1]);
+        break;
       }
     }
+  }
 }
 
@@ -251,7 +255,7 @@
   PRINT(0)("\n==========================| KeyMapper::debug() |===\n");
   for(int i = 0; map[i].pValue != NULL; ++i)
-    {
-      PRINT(0)("%s = %i\n",map[i].pName.c_str(), *map[i].pValue);
-    }
+  {
+    PRINT(0)("%s = %i\n",map[i].pName.c_str(), *map[i].pValue);
+  }
   PRINT(0)("=======================================================\n");
 }
