added using single button for snap and drop when using native EM engine
authorHolger Schemel <info@artsoft.org>
Fri, 8 Sep 2017 14:00:53 +0000 (16:00 +0200)
committerHolger Schemel <info@artsoft.org>
Fri, 8 Sep 2017 14:00:53 +0000 (16:00 +0200)
src/events.c
src/game.c
src/game_em/convert.c
src/game_em/export.h
src/game_em/input.c

index 8ddf4e9b87e6704dac106abc5f7004dccb75022d..6f6d41faa580f6ddf393613752fcb6434c91e725 100644 (file)
@@ -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);
index 89e0c110a1e0255bbd22f5d55040666ff66ea1ff..e87dcd04aef71ce57f0e6af83b8b5b8dcbfd7cd9 100644 (file)
@@ -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 */
index d240739efaac68ba01fe913b6c2e2c085e2852fd..32c4b600b4b4e30a45a951de37edb5d23d135175 100644 (file)
@@ -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++)
index 0968f1d64b12491809da4b153c0309f22d79519c..065d6214bb46e099e8a586b8ae5336b56159c32e 100644 (file)
@@ -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];
index b2c79ac7f79e475cb4f34214bd0e897f4d6a0c62..b8e2e663b1f5f96df79356adc6dea8b8220ba33e 100644 (file)
@@ -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;