From: Patrik Gornicz Date: Tue, 23 Sep 2008 01:28:06 +0000 (-0400) Subject: fixed string problems X-Git-Tag: v0.07~17 X-Git-Url: http://gitweb.pgornicz.com/gitweb.cgi?p=physics.git;a=commitdiff_plain;h=e268f6ef72bca3f090ad46451fbe66ee5b31c066 fixed string problems --- 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; }