rnd-20080206-1-src
authorHolger Schemel <info@artsoft.org>
Wed, 6 Feb 2008 01:05:02 +0000 (02:05 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:56:56 +0000 (10:56 +0200)
src/conftime.h
src/editor.c
src/game.c
src/game.h
src/main.h

index ad266fc2f60de967605c4bbee32da7b1403b8dbc..1570096735b165e1ebc4c3a3167651057d4fe0ea 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2008-02-05 01:45"
+#define COMPILE_DATE_STRING "2008-02-06 02:04"
index c3583d4b61f7be115a5733d068301d8ceab4e70d..daf6ec331636cde9f0b767a0d0eabde280f041a3 100644 (file)
@@ -1714,7 +1714,7 @@ static struct ValueTextInfo options_action_type[] =
   { CA_HEADLINE_CE_ACTIONS,    "[CE]"                          },
   { CA_SET_CE_VALUE,           "set CE value"                  },
   { CA_SET_CE_SCORE,           "set CE score"                  },
-  { CA_SET_CE_ARTWORK,         "set artwork"                   },
+  { CA_SET_CE_ARTWORK,         "set CE artwork"                },
   { CA_UNDEFINED,              " "                             },
   { CA_HEADLINE_ENGINE_ACTIONS,        "[engine]"                      },
   { CA_SET_ENGINE_SCAN_MODE,   "set scan mode"                 },
@@ -1973,14 +1973,17 @@ static struct ValueTextInfo options_action_arg_scan_mode[] =
 static struct ValueTextInfo options_action_arg_inventory[] =
 {
   { CA_ARG_INVENTORY_HEADLINE, "[add]"                         },
-  { CA_ARG_ELEMENT_TARGET,     "target"                        },
-  { CA_ARG_ELEMENT_TRIGGER,    "trigger"                       },
-  { CA_ARG_ELEMENT_ACTION,     "action ->"                     },
+  { CA_ARG_ELEMENT_TARGET,     "+ target"                      },
+  { CA_ARG_ELEMENT_TRIGGER,    "+ trigger"                     },
+  { CA_ARG_ELEMENT_ACTION,     "+ action"                      },
   { CA_ARG_UNDEFINED,          " "                             },
   { CA_ARG_INVENTORY_RM_HEADLINE,"[remove]"                    },
-  { CA_ARG_INVENTORY_RM_FIRST, "first"                         },
-  { CA_ARG_INVENTORY_RM_LAST,  "last"                          },
-  { CA_ARG_INVENTORY_RM_ALL,   "all"                           },
+  { CA_ARG_INVENTORY_RM_TARGET,        "- target"                      },
+  { CA_ARG_INVENTORY_RM_TRIGGER,"- trigger"                    },
+  { CA_ARG_INVENTORY_RM_ACTION,        "- action"                      },
+  { CA_ARG_INVENTORY_RM_FIRST, "- first"                       },
+  { CA_ARG_INVENTORY_RM_LAST,  "- last"                        },
+  { CA_ARG_INVENTORY_RM_ALL,   "- all"                         },
   { CA_ARG_UNDEFINED,          " "                             },
   { CA_ARG_INVENTORY_RESET,    "reset"                         },
 
index 4bd9bdc1614747b5e00bfad4a193e007c0358935..057c8dd257c598303e17516e1c2ac29097d291c8 100644 (file)
@@ -1791,8 +1791,8 @@ static void InitPlayerField(int x, int y, int element, boolean init_game)
     int player_nr = GET_PLAYER_NR(element);
     struct PlayerInfo *player = &stored_player[player_nr];
 
-    if (player->active)
-      player->killed = FALSE;  /* if player was just killed, reanimate him */
+    if (player->active && player->killed)
+      player->reanimated = TRUE; /* if player was just killed, reanimate him */
   }
 #endif
 }
@@ -3451,8 +3451,8 @@ static void InitGameEngine()
     for (j = 0; j < ei->num_change_pages; j++)
     {
       ei->change_page[j].actual_trigger_element = EL_EMPTY;
-      ei->change_page[j].actual_trigger_player = EL_PLAYER_1;
-      ei->change_page[j].actual_trigger_player_bits = CH_PLAYER_1;
+      ei->change_page[j].actual_trigger_player = EL_EMPTY;
+      ei->change_page[j].actual_trigger_player_bits = CH_PLAYER_NONE;
       ei->change_page[j].actual_trigger_side = CH_SIDE_NONE;
       ei->change_page[j].actual_trigger_ce_value = 0;
       ei->change_page[j].actual_trigger_ce_score = 0;
@@ -3707,6 +3707,7 @@ void InitGame()
     player->present = FALSE;
     player->active = FALSE;
     player->killed = FALSE;
+    player->reanimated = FALSE;
 
     player->action = 0;
     player->effective_action = 0;
@@ -10259,7 +10260,9 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page)
                            action_arg_number_min, action_arg_number_max);
 
 #if 1
-  int trigger_player_bits = change->actual_trigger_player_bits;
+  int trigger_player_bits =
+    (change->actual_trigger_player_bits != CH_PLAYER_NONE ?
+     change->actual_trigger_player_bits : change->trigger_player);
 #else
   int trigger_player_bits =
     (change->actual_trigger_player >= EL_PLAYER_1 &&
@@ -10428,6 +10431,10 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page)
 
     case CA_SET_PLAYER_SPEED:
     {
+#if 0
+      printf("::: trigger_player_bits == %d\n", trigger_player_bits);
+#endif
+
       for (i = 0; i < MAX_PLAYERS; i++)
       {
        if (trigger_player_bits & (1 << i))
@@ -10545,6 +10552,104 @@ static void ExecuteCustomElementAction(int x, int y, int element, int page)
       break;
     }
 
+    case CA_SET_PLAYER_INVENTORY:
+    {
+      for (i = 0; i < MAX_PLAYERS; i++)
+      {
+       struct PlayerInfo *player = &stored_player[i];
+       int j, k;
+
+       if (trigger_player_bits & (1 << i))
+       {
+         int inventory_element = action_arg_element;
+
+         if (action_arg == CA_ARG_ELEMENT_TARGET ||
+             action_arg == CA_ARG_ELEMENT_TRIGGER ||
+             action_arg == CA_ARG_ELEMENT_ACTION)
+         {
+           int element = inventory_element;
+           int collect_count = element_info[element].collect_count_initial;
+
+           if (!IS_CUSTOM_ELEMENT(element))
+             collect_count = 1;
+
+           if (collect_count == 0)
+             player->inventory_infinite_element = element;
+           else
+             for (k = 0; k < collect_count; k++)
+               if (player->inventory_size < MAX_INVENTORY_SIZE)
+                 player->inventory_element[player->inventory_size++] =
+                   element;
+         }
+         else if (action_arg == CA_ARG_INVENTORY_RM_TARGET ||
+                  action_arg == CA_ARG_INVENTORY_RM_TRIGGER ||
+                  action_arg == CA_ARG_INVENTORY_RM_ACTION)
+         {
+           if (player->inventory_infinite_element != EL_UNDEFINED &&
+               IS_EQUAL_OR_IN_GROUP(player->inventory_infinite_element,
+                                    action_arg_element_raw))
+             player->inventory_infinite_element = EL_UNDEFINED;
+
+           for (k = 0, j = 0; j < player->inventory_size; j++)
+           {
+             if (!IS_EQUAL_OR_IN_GROUP(player->inventory_element[j],
+                                       action_arg_element_raw))
+               player->inventory_element[k++] = player->inventory_element[j];
+           }
+
+           player->inventory_size = k;
+         }
+         else if (action_arg == CA_ARG_INVENTORY_RM_FIRST)
+         {
+           if (player->inventory_size > 0)
+           {
+             for (j = 0; j < player->inventory_size - 1; j++)
+               player->inventory_element[j] = player->inventory_element[j + 1];
+
+             player->inventory_size--;
+           }
+         }
+         else if (action_arg == CA_ARG_INVENTORY_RM_LAST)
+         {
+           if (player->inventory_size > 0)
+             player->inventory_size--;
+         }
+         else if (action_arg == CA_ARG_INVENTORY_RM_ALL)
+         {
+           player->inventory_infinite_element = EL_UNDEFINED;
+           player->inventory_size = 0;
+         }
+         else if (action_arg == CA_ARG_ELEMENT_RESET)
+         {
+           player->inventory_infinite_element = EL_UNDEFINED;
+           player->inventory_size = 0;
+
+           if (level.use_initial_inventory[i])
+           {
+             for (j = 0; j < level.initial_inventory_size[i]; j++)
+             {
+               int element = level.initial_inventory_content[i][j];
+               int collect_count = element_info[element].collect_count_initial;
+
+               if (!IS_CUSTOM_ELEMENT(element))
+                 collect_count = 1;
+
+               if (collect_count == 0)
+                 player->inventory_infinite_element = element;
+               else
+                 for (k = 0; k < collect_count; k++)
+                   if (player->inventory_size < MAX_INVENTORY_SIZE)
+                     player->inventory_element[player->inventory_size++] =
+                       element;
+             }
+           }
+         }
+       }
+      }
+
+      break;
+    }
+
     /* ---------- CE actions  ---------------------------------------------- */
 
     case CA_SET_CE_VALUE:
@@ -10804,8 +10909,8 @@ static boolean ChangeElement(int x, int y, int element, int page)
   {
     /* reset actual trigger element, trigger player and action element */
     change->actual_trigger_element = EL_EMPTY;
-    change->actual_trigger_player = EL_PLAYER_1;
-    change->actual_trigger_player_bits = CH_PLAYER_1;
+    change->actual_trigger_player = EL_EMPTY;
+    change->actual_trigger_player_bits = CH_PLAYER_NONE;
     change->actual_trigger_side = CH_SIDE_NONE;
     change->actual_trigger_ce_value = 0;
     change->actual_trigger_ce_score = 0;
@@ -11323,6 +11428,10 @@ static boolean CheckElementChangeExt(int x, int y,
 
   RECURSION_LOOP_DETECTION_START(trigger_element, FALSE);
 
+#if 0
+  printf("::: X: trigger_player_bits == %d\n", trigger_player);
+#endif
+
   for (p = 0; p < element_info[element].num_change_pages; p++)
   {
     struct ElementChangeInfo *change = &element_info[element].change_page[p];
@@ -14239,6 +14348,11 @@ void KillPlayer(struct PlayerInfo *player)
   if (!player->active)
     return;
 
+#if 0
+  printf("::: 0: killed == %d, active == %d, reanimated == %d\n",
+        player->killed, player->active, player->reanimated);
+#endif
+
   /* the following code was introduced to prevent an infinite loop when calling
      -> Bang()
      -> CheckTriggeredElementChangeExt()
@@ -14263,11 +14377,28 @@ void KillPlayer(struct PlayerInfo *player)
   player->shield_normal_time_left = 0;
   player->shield_deadly_time_left = 0;
 
+#if 0
+  printf("::: 1: killed == %d, active == %d, reanimated == %d\n",
+        player->killed, player->active, player->reanimated);
+#endif
+
   Bang(jx, jy);
 
+#if 0
+  printf("::: 2: killed == %d, active == %d, reanimated == %d\n",
+        player->killed, player->active, player->reanimated);
+#endif
+
 #if USE_PLAYER_REANIMATION
+#if 1
+  if (player->reanimated)      /* killed player may have been reanimated */
+    player->killed = player->reanimated = FALSE;
+  else
+    BuryPlayer(player);
+#else
   if (player->killed)          /* player may have been reanimated */
     BuryPlayer(player);
+#endif
 #else
   BuryPlayer(player);
 #endif
index e75d50fcb539ce76a70d83e94e723aafa5384eb6..52202d061e74c7f94b56ec8ba2a389bb1c160088 100644 (file)
@@ -183,6 +183,7 @@ struct PlayerInfo
   boolean connected;           /* player connected (locally or via network) */
   boolean active;              /* player present and connected */
   boolean killed;              /* player maybe present/active, but killed */
+  boolean reanimated;          /* player maybe killed, but reanimated */
 
   int index_nr;                        /* player number (0 to 3) */
   int index_bit;               /* player number bit (1 << 0 to 1 << 3) */
index a20cb5ff496470201abefcad7e3c8e523d06f23c..2b3e42639250f573a3b8764e6c5c3637d5967987 100644 (file)
 #define CA_ARG_SCAN_MODE_HEADLINE      (CA_ARG_SCAN_MODE + 999)
 #define CA_ARG_INVENTORY               18000
 #define CA_ARG_INVENTORY_RESET         (CA_ARG_INVENTORY + 0)
-#define CA_ARG_INVENTORY_RM_FIRST      (CA_ARG_INVENTORY + 1)
-#define CA_ARG_INVENTORY_RM_LAST       (CA_ARG_INVENTORY + 2)
-#define CA_ARG_INVENTORY_RM_ALL                (CA_ARG_INVENTORY + 3)
+#define CA_ARG_INVENTORY_RM_TARGET     (CA_ARG_INVENTORY + 1)
+#define CA_ARG_INVENTORY_RM_TRIGGER    (CA_ARG_INVENTORY + 2)
+#define CA_ARG_INVENTORY_RM_ACTION     (CA_ARG_INVENTORY + 3)
+#define CA_ARG_INVENTORY_RM_FIRST      (CA_ARG_INVENTORY + 4)
+#define CA_ARG_INVENTORY_RM_LAST       (CA_ARG_INVENTORY + 5)
+#define CA_ARG_INVENTORY_RM_ALL                (CA_ARG_INVENTORY + 6)
 #define CA_ARG_INVENTORY_HEADLINE      (CA_ARG_INVENTORY + 998)
 #define CA_ARG_INVENTORY_RM_HEADLINE   (CA_ARG_INVENTORY + 999)
 #define CA_ARG_UNDEFINED               65535