From: Holger Schemel Date: Thu, 24 Jan 2019 18:26:01 +0000 (+0100) Subject: fixed bug with player moving when releasing one of several pressed snap keys X-Git-Tag: 4.1.2.0~43 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=931d95b5a399bbed7280bd39be8373adad147dc2;p=rocksndiamonds.git fixed bug with player moving when releasing one of several pressed snap keys When using TAS snap keys, pressing more than one snap key at the same time and then releasing one of them caused the player to move. --- diff --git a/src/events.c b/src/events.c index bc6e2eb0..0d1f6baf 100644 --- a/src/events.c +++ b/src/events.c @@ -2015,6 +2015,7 @@ void HandleKey(Key key, int key_status) for (pnr = 0; pnr < MAX_PLAYERS; pnr++) { byte key_action = 0; + byte key_snap_action = 0; if (setup.input[pnr].use_joystick) continue; @@ -2030,15 +2031,33 @@ void HandleKey(Key key, int key_status) { ssi = setup.shortcut; + // also remember normal snap key when handling snap+direction keys + key_snap_action |= key_action & JOY_BUTTON_SNAP; + for (i = 0; i < NUM_DIRECTIONS; i++) + { if (key == *key_info[i].key_snap) - key_action |= key_info[i].action | JOY_BUTTON_SNAP; + { + key_action |= key_info[i].action | JOY_BUTTON_SNAP; + key_snap_action |= key_info[i].action; + } + } } if (key_status == KEY_PRESSED) - stored_player[pnr].action |= key_action; + { + stored_player[pnr].action |= key_action; + stored_player[pnr].snap_action |= key_snap_action; + } else - stored_player[pnr].action &= ~key_action; + { + stored_player[pnr].action &= ~key_action; + stored_player[pnr].snap_action &= ~key_snap_action; + } + + // restore snap action if one of several pressed snap keys was released + if (stored_player[pnr].snap_action) + stored_player[pnr].action |= JOY_BUTTON_SNAP; if (tape.single_step && tape.recording && tape.pausing && !tape.use_mouse) { diff --git a/src/game.c b/src/game.c index 20157c6d..30ebdd17 100644 --- a/src/game.c +++ b/src/game.c @@ -3402,6 +3402,7 @@ void InitGame(void) player->action = 0; player->effective_action = 0; player->programmed_action = 0; + player->snap_action = 0; player->mouse_action.lx = 0; player->mouse_action.ly = 0; diff --git a/src/game.h b/src/game.h index 00131fb9..0319a8df 100644 --- a/src/game.h +++ b/src/game.h @@ -281,6 +281,7 @@ struct PlayerInfo devices when in single player mode */ byte programmed_action; /* action forced by game itself (like moving through doors); overrides other actions */ + byte snap_action; // action from TAS snap keys struct MouseActionInfo mouse_action; // (used by MM engine only) struct MouseActionInfo effective_mouse_action; // (used by MM engine only)