From: Holger Schemel Date: Fri, 8 Sep 2017 14:00:53 +0000 (+0200) Subject: added using single button for snap and drop when using native EM engine X-Git-Tag: 4.0.1.0~14 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=4e4b7a3f5581e495af3d0bcf0ca8bb5424306a52;p=rocksndiamonds.git added using single button for snap and drop when using native EM engine --- diff --git a/src/events.c b/src/events.c index 8ddf4e9b..6f6d41fa 100644 --- a/src/events.c +++ b/src/events.c @@ -1560,6 +1560,9 @@ void HandleKey(Key key, int key_status) static boolean element_dropped[MAX_PLAYERS] = { FALSE,FALSE,FALSE,FALSE }; int pnr; + /* initialize unifying snap and drop buttons (EM engine) */ + game_em.use_single_button = game_em.use_single_button_initial; + for (pnr = 0; pnr < MAX_PLAYERS; pnr++) { byte key_action = 0; @@ -1606,6 +1609,9 @@ void HandleKey(Key key, int key_status) if (tape.single_step && tape.recording && tape.pausing) { + /* do not unify snap and drop buttons in single-step mode (EM engine) */ + game_em.use_single_button = FALSE; + if (key_status == KEY_PRESSED && key_action & KEY_MOTION) { TapeTogglePause(TAPE_TOGGLE_AUTOMATIC); diff --git a/src/game.c b/src/game.c index 89e0c110..e87dcd04 100644 --- a/src/game.c +++ b/src/game.c @@ -2698,6 +2698,9 @@ static void InitGameEngine() game.use_block_last_field_bug = (game.engine_version < VERSION_IDENT(3,1,1,0)); + game_em.use_single_button = game_em.use_single_button_initial = + (game.engine_version > VERSION_IDENT(4,0,0,2)); + /* ---------------------------------------------------------------------- */ /* set maximal allowed number of custom element changes per game frame */ diff --git a/src/game_em/convert.c b/src/game_em/convert.c index d240739e..32c4b600 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -1109,6 +1109,9 @@ void prepare_em_level(void) game_em.any_player_moving = FALSE; game_em.any_player_snapping = FALSE; + + game_em.use_single_button = game_em.use_single_button_initial = TRUE; + game_em.last_moving_player = 0; /* default: first player */ for (i = 0; i < MAX_PLAYERS; i++) diff --git a/src/game_em/export.h b/src/game_em/export.h index 0968f1d6..065d6214 100644 --- a/src/game_em/export.h +++ b/src/game_em/export.h @@ -666,6 +666,10 @@ struct GameInfo_EM { boolean any_player_moving; boolean any_player_snapping; + + boolean use_single_button_initial; + boolean use_single_button; + int last_moving_player; int last_player_direction[MAX_PLAYERS]; }; @@ -678,6 +682,9 @@ struct LevelInfo_EM struct LEVEL *lev; struct PLAYER *ply[MAX_PLAYERS]; + + /* used for runtime values */ + struct GameInfo_EM *game_em; }; struct GraphicInfo_EM @@ -721,6 +728,7 @@ struct EngineSnapshotInfo_EM /* ------------------------------------------------------------------------- */ extern struct GlobalInfo_EM global_em_info; +extern struct GameInfo_EM game_em; extern struct LevelInfo_EM native_em_level; extern struct GraphicInfo_EM graphic_info_em_object[TILE_MAX][8]; extern struct GraphicInfo_EM graphic_info_em_player[MAX_PLAYERS][SPR_MAX][8]; diff --git a/src/game_em/input.c b/src/game_em/input.c index b2c79ac7..b8e2e663 100644 --- a/src/game_em/input.c +++ b/src/game_em/input.c @@ -119,6 +119,9 @@ void readjoy(byte action, struct PLAYER *ply) int north = 0, east = 0, south = 0, west = 0; int snap = 0, drop = 0; + if (game_em.use_single_button && action & (JOY_BUTTON_1 | JOY_BUTTON_2)) + action |= JOY_BUTTON_1 | JOY_BUTTON_2; + if (action & JOY_LEFT) west = 1;