minor change to handle explosion sound for EM engine
[rocksndiamonds.git] / src / game_em / logic.c
index b76bac67400b54ac4b54a4cdb7914c7086d5727f..fc6cbb30ce8af579d45984f7058994eb6d1c739c 100644 (file)
@@ -113,31 +113,31 @@ static void Lboom_generic(int x, int y, int element, int element_middle)
   boom[x+1][y+1] = element;
 }
 
-static void Lboom_bug(int x, int y, int by_element)
+static void Lboom_bug(int x, int y)
 {
-  next[x][y] = Znormal;
+  next[x][y] = Zbug;
 
   Lboom_generic(x, y, Xemerald, Xdiamond);
 
 #if PLAY_ELEMENT_SOUND
-  play_element_sound(x, y, SOUND_boom, by_element);
+  play_element_sound(x, y, SOUND_boom, Xbug_1_n);
 #endif
 }
 
-static void Lboom_tank(int x, int y, int by_element)
+static void Lboom_tank(int x, int y)
 {
-  next[x][y] = Znormal;
+  next[x][y] = Ztank;
 
   Lboom_generic(x, y, Xblank, Xblank);
 
 #if PLAY_ELEMENT_SOUND
-  play_element_sound(x, y, SOUND_boom, by_element);
+  play_element_sound(x, y, SOUND_boom, Xtank_1_n);
 #endif
 }
 
-static void Lboom_eater(int x, int y, int by_element)
+static void Lboom_eater(int x, int y)
 {
-  next[x][y] = Znormal;
+  next[x][y] = Zeater;
 
   boom[x-1][y-1] = lev.eater_array[lev.eater_pos][0];
   boom[x][y-1]   = lev.eater_array[lev.eater_pos][1];
@@ -152,7 +152,7 @@ static void Lboom_eater(int x, int y, int by_element)
   lev.eater_pos = (lev.eater_pos + 1) & 7;
 
 #if PLAY_ELEMENT_SOUND
-  play_element_sound(x, y, SOUND_boom, by_element);
+  play_element_sound(x, y, SOUND_boom, Xeater_n);
 #endif
 }
 
@@ -303,7 +303,7 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x][y-1] = Xboom_bomb;
+      cave[x][y-1] = Xboom_tank;
       break;
   }
 
@@ -328,7 +328,7 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x+1][y] = Xboom_bomb;
+      cave[x+1][y] = Xboom_tank;
       break;
   }
 
@@ -353,7 +353,7 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x][y+1] = Xboom_bomb;
+      cave[x][y+1] = Xboom_tank;
       break;
   }
 
@@ -378,7 +378,7 @@ static void kill_player(struct PLAYER *ply)
     case Xtank_2_e:
     case Xtank_2_s:
     case Xtank_2_w:
-      cave[x-1][y] = Xboom_bomb;
+      cave[x-1][y] = Xboom_tank;
       break;
   }
 
@@ -1313,7 +1313,8 @@ static void check_player(struct PLAYER *ply)
       ply->dynamite_cnt = 0;
     }
 
-    RandomEM += 7;     /* be a bit more random if the player doesn't move */
+    /* be a bit more random if the player doesn't move */
+    game_em.random += 7;
 
     return;
   }
@@ -2801,7 +2802,7 @@ static void Lbug_1_n(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_1_n);
+    Lboom_bug(x, y);
 
     return;
   }
@@ -2848,7 +2849,7 @@ static void Lbug_2_n(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_2_n);
+    Lboom_bug(x, y);
 
     return;
   }
@@ -2913,7 +2914,7 @@ static void Lbug_1_e(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_1_e);
+    Lboom_bug(x, y);
 
     return;
   }
@@ -2960,7 +2961,7 @@ static void Lbug_2_e(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_2_e);
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3025,7 +3026,7 @@ static void Lbug_1_s(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_1_s);
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3072,7 +3073,7 @@ static void Lbug_2_s(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_2_s);
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3137,7 +3138,7 @@ static void Lbug_1_w(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_1_w);
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3184,7 +3185,7 @@ static void Lbug_2_w(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_bug(x, y, Xbug_2_w);
+    Lboom_bug(x, y);
 
     return;
   }
@@ -3249,7 +3250,7 @@ static void Ltank_1_n(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_1_n);
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3296,7 +3297,7 @@ static void Ltank_2_n(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_2_n);
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3361,7 +3362,7 @@ static void Ltank_1_e(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_1_e);
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3408,7 +3409,7 @@ static void Ltank_2_e(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_2_e);
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3473,7 +3474,7 @@ static void Ltank_1_s(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_1_s);
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3520,7 +3521,7 @@ static void Ltank_2_s(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_2_s);
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3585,7 +3586,7 @@ static void Ltank_1_w(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_1_w);
+    Lboom_tank(x, y);
 
     return;
   }
@@ -3632,7 +3633,7 @@ static void Ltank_2_w(int x, int y)
       is_amoeba[cave[x][y+1]] ||
       is_amoeba[cave[x-1][y]])
   {
-    Lboom_tank(x, y, Xtank_2_w);
+    Lboom_tank(x, y);
 
     return;
   }
@@ -4393,7 +4394,7 @@ static void Lstone_fall(int x, int y)
     case Xeater_w:
       cave[x][y] = Ystone_sB;
       cave[x][y+1] = Yeater_stone;
-      Lboom_eater(x, y+1, Xstone_fall);
+      Lboom_eater(x, y+1);
       score += lev.eater_score;
       return;
 
@@ -4401,7 +4402,7 @@ static void Lstone_fall(int x, int y)
     case Xalien_pause:
       cave[x][y] = Ystone_sB;
       cave[x][y+1] = Yalien_stone;
-      Lboom_tank(x, y+1, Xstone_fall);
+      Lboom_tank(x, y+1);
       score += lev.alien_score;
       return;
 
@@ -4415,7 +4416,7 @@ static void Lstone_fall(int x, int y)
     case Xbug_2_w:
       cave[x][y] = Ystone_sB;
       cave[x][y+1] = Ybug_stone;
-      Lboom_bug(x, y+1, Xstone_fall);
+      Lboom_bug(x, y+1);
       score += lev.bug_score;
       return;
 
@@ -4429,7 +4430,7 @@ static void Lstone_fall(int x, int y)
     case Xtank_2_w:
       cave[x][y] = Ystone_sB;
       cave[x][y+1] = Ytank_stone;
-      Lboom_tank(x, y+1, Xstone_fall);
+      Lboom_tank(x, y+1);
       score += lev.tank_score;
       return;
 
@@ -4506,7 +4507,7 @@ static void Lstone_fall(int x, int y)
     case Xbomb:
     case Xbomb_pause:
       cave[x][y+1] = Ybomb_blank;
-      Lboom_tank(x, y+1, Xstone_fall);
+      Lboom_tank(x, y+1);
       return;
 
     case Xnut:
@@ -4814,7 +4815,7 @@ static void Lbomb_fall(int x, int y)
 
     default:
       cave[x][y] = Ybomb_blank;
-      Lboom_tank(x, y, Xbomb_fall);
+      Lboom_tank(x, y);
       return;
   }
 }
@@ -5509,7 +5510,7 @@ static void Lspring_fall(int x, int y)
     case Xeater_w:
       cave[x][y] = Yspring_sB;
       cave[x][y+1] = Yeater_spring;
-      Lboom_eater(x, y+1, Xspring_fall);
+      Lboom_eater(x, y+1);
       score += lev.eater_score;
       return;
 
@@ -5517,7 +5518,7 @@ static void Lspring_fall(int x, int y)
     case Xalien_pause:
       cave[x][y] = Yspring_sB;
       cave[x][y+1] = Yalien_spring;
-      Lboom_tank(x, y+1, Xspring_fall);
+      Lboom_tank(x, y+1);
       score += lev.alien_score;
       return;
 
@@ -5531,7 +5532,7 @@ static void Lspring_fall(int x, int y)
     case Xbug_2_w:
       cave[x][y] = Yspring_sB;
       cave[x][y+1] = Ybug_spring;
-      Lboom_bug(x, y+1, Xspring_fall);
+      Lboom_bug(x, y+1);
       score += lev.bug_score;
       return;
 
@@ -5545,14 +5546,14 @@ static void Lspring_fall(int x, int y)
     case Xtank_2_w:
       cave[x][y] = Yspring_sB;
       cave[x][y+1] = Ytank_spring;
-      Lboom_tank(x, y+1, Xspring_fall);
+      Lboom_tank(x, y+1);
       score += lev.tank_score;
       return;
 
     case Xbomb:
     case Xbomb_pause:
       cave[x][y+1] = Ybomb_blank;
-      Lboom_tank(x, y+1, Xspring_fall);
+      Lboom_tank(x, y+1);
       return;
 
     default:
@@ -5571,10 +5572,12 @@ static void Lpush_emerald_e(int x, int y)
   switch (cave[x+1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5609,10 +5612,12 @@ static void Lpush_emerald_w(int x, int y)
   switch (cave[x-1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5647,10 +5652,12 @@ static void Lpush_diamond_e(int x, int y)
   switch (cave[x+1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5685,10 +5692,12 @@ static void Lpush_diamond_w(int x, int y)
   switch (cave[x-1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5723,10 +5732,12 @@ static void Lpush_stone_e(int x, int y)
   switch (cave[x+1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5761,10 +5772,12 @@ static void Lpush_stone_w(int x, int y)
   switch (cave[x-1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5799,10 +5812,12 @@ static void Lpush_bomb_e(int x, int y)
   switch (cave[x+1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5837,10 +5852,12 @@ static void Lpush_bomb_w(int x, int y)
   switch (cave[x-1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5875,10 +5892,12 @@ static void Lpush_nut_e(int x, int y)
   switch (cave[x+1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5913,10 +5932,12 @@ static void Lpush_nut_w(int x, int y)
   switch (cave[x-1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5951,10 +5972,12 @@ static void Lpush_spring_e(int x, int y)
   switch (cave[x+1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -5989,10 +6012,12 @@ static void Lpush_spring_w(int x, int y)
   switch (cave[x-1][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xboom_1:
       return;
@@ -6786,10 +6811,12 @@ static void Lboom_one(int x, int y, boolean by_dynamite)
   switch (cave[x][y])
   {
     case Zborder:
-    case Znormal:
+    case Zbug:
+    case Ztank:
+    case Zeater:
     case Zdynamite:
     case Xboom_bug:
-    case Xboom_bomb:
+    case Xboom_tank:
     case Xboom_android:
     case Xacid_1:
     case Xacid_2:
@@ -6855,7 +6882,7 @@ static void Lboom_one(int x, int y, boolean by_dynamite)
     case Xbomb:
     case Xbomb_pause:
     case Xbomb_fall:
-      cave[x][y] = Xboom_bomb;
+      cave[x][y] = Xboom_tank;
       return;
 
     default:
@@ -6882,7 +6909,15 @@ static void Lexplode(int x, int y)
 {
   switch (cave[x][y])
   {
-    case Znormal:
+    case Zbug:
+      Lboom_nine(x, y, FALSE);
+      break;
+
+    case Ztank:
+      Lboom_nine(x, y, FALSE);
+      break;
+
+    case Zeater:
       Lboom_nine(x, y, FALSE);
       break;
 
@@ -7076,8 +7111,8 @@ static void handle_tile(int x, int y)
 
     case Xpause:               Lpause(x, y);                   break;
 
-    case Xboom_bug:            Lboom_bug(x, y, Xboom_bug);     break;
-    case Xboom_bomb:           Lboom_tank(x, y, Xboom_bomb);   break;
+    case Xboom_bug:            Lboom_bug(x, y);                break;
+    case Xboom_tank:           Lboom_tank(x, y);               break;
     case Xboom_android:                Lboom_android(x, y);            break;
     case Xboom_1:              Lboom_1(x, y);                  break;
     case Xboom_2:              Lboom_2(x, y);                  break;
@@ -7123,7 +7158,8 @@ void logic_players(void)
     ply[i].anim = PLY_still;
   }
 
-  start_check_nr = (RandomEM & 128 ? 0 : 1) * 2 + (RandomEM & 256 ? 0 : 1);
+  start_check_nr = ((game_em.random & 128 ? 0 : 1) * 2 +
+                   (game_em.random & 256 ? 0 : 1));
 
   for (i = 0; i < MAX_PLAYERS; i++)
   {
@@ -7160,7 +7196,7 @@ void logic_objects(void)
   next = lev.next;
   boom = lev.boom;
 
-  seed = RandomEM;
+  seed = game_em.random;
   score = 0;
 
   for (y = lev.top; y < lev.bottom; y++)
@@ -7172,7 +7208,7 @@ void logic_objects(void)
   else
     game_em.game_over = TRUE;
 
-  RandomEM = seed;
+  game_em.random = seed;
 
   /* triple buffering */
   void *temp = lev.cave;
@@ -7220,7 +7256,7 @@ void logic_globals(void)
 
   /* grow amoeba */
 
-  random = RandomEM;
+  random = game_em.random;
 
   for (count = lev.amoeba_time; count--;)
   {
@@ -7234,7 +7270,7 @@ void logic_globals(void)
     random = random * 129 + 1;
   }
 
-  RandomEM = random;
+  game_em.random = random;
 
   /* handle explosions */