aboutsummaryrefslogtreecommitdiff
path: root/Source/GameLoop.cpp
diff options
context:
space:
mode:
authorrelnev <relnev@5198baeb-e213-0410-be47-fc2ff85ca46f>2003-01-20 20:36:30 +0000
committerrelnev <relnev@5198baeb-e213-0410-be47-fc2ff85ca46f>2003-01-20 20:36:30 +0000
commit837ada7e2ca481b0cd854c5b97cd9015c0b567e9 (patch)
tree0aec59b84a7c1152bad7a12fd01d27e81ae2df28 /Source/GameLoop.cpp
parent09eed08a0a20cf0c5a2a657ab95dd2217eda8ea9 (diff)
downloadblackshades-837ada7e2ca481b0cd854c5b97cd9015c0b567e9.tar.gz
properly fixed uninitialized key handling
git-svn-id: svn://svn.icculus.org/blackshades/trunk@95 5198baeb-e213-0410-be47-fc2ff85ca46f
Diffstat (limited to 'Source/GameLoop.cpp')
-rw-r--r--Source/GameLoop.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/Source/GameLoop.cpp b/Source/GameLoop.cpp
index 35bc4fe..7b520bb 100644
--- a/Source/GameLoop.cpp
+++ b/Source/GameLoop.cpp
@@ -26,8 +26,6 @@ void Game::HandleKeyDown( char theChar )
{
- ALint tempInt;
-
XYZ facing;
@@ -214,6 +212,12 @@ static unsigned char ourkeys[16];
static void init_sdlkeymap()
{
+ int i;
+
+ for (i = 0; i < SDLK_LAST; i++) {
+ sdlkeymap[i] = -1;
+ }
+
sdlkeymap[SDLK_1] = MAC_1_KEY;
sdlkeymap[SDLK_2] = MAC_2_KEY;
sdlkeymap[SDLK_3] = MAC_3_KEY;
@@ -320,10 +324,11 @@ static void DoSDLKey(Game *g, SDL_Event *event)
}
mackey = sdlkeymap[event->key.keysym.sym];
- index = mackey / 8;
- mask = 1 << (mackey % 8);
- if (mackey) {
+ if (mackey != -1) {
+ index = mackey / 8;
+ mask = 1 << (mackey % 8);
+
if (press) {
ourkeys[index] |= mask;
} else {