From e268f6ef72bca3f090ad46451fbe66ee5b31c066 Mon Sep 17 00:00:00 2001 From: Patrik Gornicz Date: Mon, 22 Sep 2008 21:28:06 -0400 Subject: [PATCH] fixed string problems --- src/config/keys.h | 19 +------------------ src/config/reader.cpp | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/config/keys.h b/src/config/keys.h index 49fe66f..31dfcdd 100644 --- a/src/config/keys.h +++ b/src/config/keys.h @@ -26,23 +26,6 @@ #include "../debug.h" -class comparestrings -{ - public: - bool operator() - ( - const std::string& a, - const std::string& b - ) - { - cout << a << endl; - cout << b << endl; - cout << endl; - - return a.compare(b) < 0; - } -}; - /// ***** Header Methods ***** namespace key { @@ -51,7 +34,7 @@ namespace key extern SDLKey follow; extern SDLKey well; - typedef std::map inputMap; + typedef std::map inputMap; extern inputMap sdlMap; diff --git a/src/config/reader.cpp b/src/config/reader.cpp index c42e50d..4e27d93 100644 --- a/src/config/reader.cpp +++ b/src/config/reader.cpp @@ -27,7 +27,7 @@ using std::ifstream; using std::string; -typedef std::map kMap; +typedef std::map kMap; kMap keyMap; /// ***** Private Method Headers ***** @@ -201,17 +201,26 @@ bool extractLine(const string& str, string* name, string* value) void createKeyMap() { + char buf[2] = {0,0}; + // add all the letters for (int i = 'A'; i <= 'Z'; i++) // uppercase - keyMap["" + (char)i] = (SDLKey)i; + { + buf[0] = (char)i; + keyMap[buf] = (SDLKey)i; + } for (int i = 'a'; i <= 'z'; i++) // lowercase - keyMap["" + (char)i] = (SDLKey)i; + { + buf[0] = (char)i; + keyMap[buf] = (SDLKey)i; + } // add all the numbers for (int i = '0'; i <= '9'; i++) - keyMap["" + (char)i] = (SDLKey)i; - - keyMap["k"] = (SDLKey)'k'; + { + buf[0] = (char)i; + keyMap[buf] = (SDLKey)i; + } /* // add the function keys @@ -287,7 +296,4 @@ void createKeyMap() keyMap["Down"] = SDLK_DOWN; keyMap["Left"] = SDLK_LEFT; keyMap["Right"] = SDLK_RIGHT; - - cout << "done" << endl; - cout << keyMap["k"] << endl; } -- 2.10.2