prepared code to support more tape actions than players
[rocksndiamonds.git] / src / game.c
index fd1bdc53d936c6a821c8639b66a331d09ccd6750..e43739030777399cda01f06e2f86ef62833cd187 100644 (file)
@@ -3279,6 +3279,23 @@ static void InitGameEngine(void)
   // Supaplex levels with time limit currently unsupported -- should be added
   if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
     level.time = 0;
+
+  // ----------initialize flag for handling mouse events ---------------------
+
+  // set flag to default value: do not handle mouse events
+  game.use_mouse_events = FALSE;
+
+  // now check for custom elements which have mouse click events defined
+  for (i = 0; i < NUM_CUSTOM_ELEMENTS; i++)
+  {
+    int element = EL_CUSTOM_START + i;
+
+    if (HAS_CHANGE_EVENT(element, CE_CLICKED_BY_MOUSE) ||
+       HAS_CHANGE_EVENT(element, CE_PRESSED_BY_MOUSE) ||
+       HAS_CHANGE_EVENT(element, CE_MOUSE_CLICKED_ON_X) ||
+       HAS_CHANGE_EVENT(element, CE_MOUSE_PRESSED_ON_X))
+      game.use_mouse_events = TRUE;
+  }
 }
 
 static int get_num_special_action(int element, int action_first,
@@ -9880,11 +9897,14 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page)
     // ---------- player actions  ---------------------------------------------
 
     case CA_MOVE_PLAYER:
+    case CA_MOVE_PLAYER_NEW:
     {
       // automatically move to the next field in specified direction
       for (i = 0; i < MAX_PLAYERS; i++)
        if (trigger_player_bits & (1 << i))
-         stored_player[i].programmed_action = action_arg_direction;
+         if (action_type == CA_MOVE_PLAYER ||
+             stored_player[i].MovPos == 0)
+           stored_player[i].programmed_action = action_arg_direction;
 
       break;
     }
@@ -11354,7 +11374,7 @@ static void GameActionsExt(void)
   unsigned int game_frame_delay_value;
   byte *recorded_player_action;
   byte summarized_player_action = 0;
-  byte tape_action[MAX_PLAYERS];
+  byte tape_action[MAX_TAPE_ACTIONS] = { 0 };
   int i;
 
   // detect endless loops, caused by custom element programming