X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_em%2Flogic.c;h=7840734eaa75235a2d3a6b977be4b3f39c0ddf1e;hb=63539da7f2d5e1ca071f0e4a9d897df0595d6ae5;hp=ffb4d8765a381c691296566aea3396d70d83e5b9;hpb=9e54f3f605e0999f4f2d866107449c247493e957;p=rocksndiamonds.git diff --git a/src/game_em/logic.c b/src/game_em/logic.c index ffb4d876..7840734e 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -10,17 +10,15 @@ #define SPRING_ROLL /* spring rolling off round things continues to roll */ #define ACID_ROLL /* rolling objects go into acid rather than remove it */ +#define ACID_PLAYER /* player gets killed by acid, but without explosion */ -#define USE_CHANGED_ACID_STUFF - -#define RANDOM_RAW (seed = seed << 31 | seed >> 1) -#define RANDOM(x) (RANDOM_RAW & (x - 1)) +#define RANDOM(x) ((seed = seed << 31 | seed >> 1) % x) static short **cave, **next, **boom; static unsigned int seed; static int score; -static const byte is_blank[TILE_MAX] = +static const byte is_blank[GAME_TILE_MAX] = { [Xblank] = 1, [Xsplash_e] = 1, @@ -35,7 +33,7 @@ static const byte is_blank[TILE_MAX] = [Xfake_acid_8] = 1 }; -static const byte is_blank_or_acid[TILE_MAX] = +static const byte is_blank_or_acid[GAME_TILE_MAX] = { [Xblank] = 1, [Xsplash_e] = 1, @@ -58,7 +56,7 @@ static const byte is_blank_or_acid[TILE_MAX] = [Xacid_8] = 1 }; -static const byte is_fake_acid[TILE_MAX] = +static const byte is_fake_acid[GAME_TILE_MAX] = { [Xfake_acid_1] = 1, [Xfake_acid_2] = 1, @@ -70,7 +68,7 @@ static const byte is_fake_acid[TILE_MAX] = [Xfake_acid_8] = 1 }; -static const byte is_amoeba[TILE_MAX] = +static const byte is_amoeba[GAME_TILE_MAX] = { [Xfake_amoeba] = 1, [Yfake_amoeba] = 1, @@ -84,7 +82,22 @@ static const byte is_amoeba[TILE_MAX] = [Xamoeba_8] = 1 }; -static const byte is_android_walkable[TILE_MAX] = +static byte is_android_blank[GAME_TILE_MAX] = +{ + [Xblank] = 1, + [Xsplash_e] = 1, + [Xsplash_w] = 1, + [Xfake_acid_1] = 1, + [Xfake_acid_2] = 1, + [Xfake_acid_3] = 1, + [Xfake_acid_4] = 1, + [Xfake_acid_5] = 1, + [Xfake_acid_6] = 1, + [Xfake_acid_7] = 1, + [Xfake_acid_8] = 1 +}; + +static const byte is_android_walkable[GAME_TILE_MAX] = { [Xblank] = 1, [Xsplash_e] = 1, @@ -113,31 +126,34 @@ 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] = Zbug; + if (game_em.use_old_explosions) + 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] = Ztank; + if (game_em.use_old_explosions) + 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] = Zeater; + if (game_em.use_old_explosions) + 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]; @@ -149,13 +165,95 @@ static void Lboom_eater(int x, int y, int by_element) boom[x][y+1] = lev.eater_array[lev.eater_pos][7]; boom[x+1][y+1] = lev.eater_array[lev.eater_pos][8]; - lev.eater_pos = (lev.eater_pos + 1) & 7; + lev.eater_pos = (lev.eater_pos + 1) % 8; #if PLAY_ELEMENT_SOUND - play_element_sound(x, y, SOUND_boom, by_element); + play_element_sound(x, y, SOUND_boom, Xeater_n); #endif } +static void Lboom_bug_old(int x, int y) +{ + if (!game_em.use_old_explosions) + return; + + Lboom_bug(x, y); +} + +static void Lboom_tank_old(int x, int y) +{ + if (!game_em.use_old_explosions) + return; + + Lboom_tank(x, y); +} + +static void Lboom_eater_old(int x, int y) +{ + if (!game_em.use_old_explosions) + return; + + Lboom_eater(x, y); +} + +static void Lboom_bug_new(int x, int y, boolean chain_explosion) +{ + if (game_em.use_old_explosions) + return; + + if (chain_explosion) + cave[x][y] = Xchain; + + Lboom_bug(x, y); +} + +static void Lboom_tank_new(int x, int y, boolean chain_explosion) +{ + if (game_em.use_old_explosions) + return; + + if (chain_explosion) + cave[x][y] = Xchain; + + Lboom_tank(x, y); +} + +static void Lboom_eater_new(int x, int y, boolean chain_explosion) +{ + if (game_em.use_old_explosions) + return; + + if (chain_explosion) + cave[x][y] = Xchain; + + Lboom_eater(x, y); +} + +static void Lboom_cave_new(int x, int y, int element) +{ + if (game_em.use_old_explosions) + return; + + cave[x][y] = element; +} + +static void Lboom_next_new(int x, int y, int element) +{ + if (game_em.use_old_explosions) + return; + + next[x][y] = element; +} + +static void Lpush_element_old(int x, int y, int element) +{ + if (!game_em.use_old_push_elements) + return; + + cave[x][y] = element; + next[x][y] = element; +} + static boolean player_killed(struct PLAYER *ply) { int x = ply->x; @@ -280,7 +378,7 @@ static void kill_player(struct PLAYER *ply) int x = ply->x; int y = ply->y; - ply->alive = 0; + ply->alive = FALSE; switch (cave[x][y-1]) { @@ -293,6 +391,7 @@ static void kill_player(struct PLAYER *ply) case Xbug_2_s: case Xbug_2_w: cave[x][y-1] = Xboom_bug; + Lboom_bug_new(x, y-1, TRUE); break; case Xtank_1_n: @@ -304,6 +403,7 @@ static void kill_player(struct PLAYER *ply) case Xtank_2_s: case Xtank_2_w: cave[x][y-1] = Xboom_tank; + Lboom_tank_new(x, y-1, TRUE); break; } @@ -318,6 +418,7 @@ static void kill_player(struct PLAYER *ply) case Xbug_2_s: case Xbug_2_w: cave[x+1][y] = Xboom_bug; + Lboom_bug_new(x+1, y, TRUE); break; case Xtank_1_n: @@ -329,6 +430,7 @@ static void kill_player(struct PLAYER *ply) case Xtank_2_s: case Xtank_2_w: cave[x+1][y] = Xboom_tank; + Lboom_tank_new(x+1, y, TRUE); break; } @@ -343,6 +445,7 @@ static void kill_player(struct PLAYER *ply) case Xbug_2_s: case Xbug_2_w: cave[x][y+1] = Xboom_bug; + Lboom_bug_new(x, y+1, TRUE); break; case Xtank_1_n: @@ -354,6 +457,7 @@ static void kill_player(struct PLAYER *ply) case Xtank_2_s: case Xtank_2_w: cave[x][y+1] = Xboom_tank; + Lboom_tank_new(x, y+1, TRUE); break; } @@ -368,6 +472,7 @@ static void kill_player(struct PLAYER *ply) case Xbug_2_s: case Xbug_2_w: cave[x-1][y] = Xboom_bug; + Lboom_bug_new(x-1, y, TRUE); break; case Xtank_1_n: @@ -379,6 +484,7 @@ static void kill_player(struct PLAYER *ply) case Xtank_2_s: case Xtank_2_w: cave[x-1][y] = Xboom_tank; + Lboom_tank_new(x-1, y, TRUE); break; } @@ -399,7 +505,7 @@ static void kill_player(struct PLAYER *ply) switch (cave[x][y]) { -#ifdef USE_CHANGED_ACID_STUFF +#ifdef ACID_PLAYER case Xacid_1: case Xacid_2: case Xacid_3: @@ -433,7 +539,7 @@ static boolean player_digfield(struct PLAYER *ply, int dx, int dy) if (dx && dy && ply->joy_snap) /* more than one direction specified */ return FALSE; - if (ply->joy_snap == 0) /* player wants to move */ + if (!ply->joy_snap) /* player wants to move */ { int element = cave[x][y]; @@ -445,6 +551,8 @@ static boolean player_digfield(struct PLAYER *ply, int dx, int dy) case Xsplash_w: cave[x][y] = Zplayer; next[x][y] = Zplayer; + // FALL THROUGH + case Xfake_acid_1: case Xfake_acid_2: case Xfake_acid_3: @@ -459,7 +567,6 @@ static boolean player_digfield(struct PLAYER *ply, int dx, int dy) ply->y = y; break; -#ifdef USE_CHANGED_ACID_STUFF case Xacid_1: case Xacid_2: case Xacid_3: @@ -468,13 +575,14 @@ static boolean player_digfield(struct PLAYER *ply, int dx, int dy) case Xacid_6: case Xacid_7: case Xacid_8: +#ifdef ACID_PLAYER if (cave[x+1][y-1] == Xblank) cave[x+1][y-1] = Xsplash_e; if (cave[x-1][y-1] == Xblank) cave[x-1][y-1] = Xsplash_w; play_element_sound(x, y, SOUND_acid, Xacid_1); + // FALL THROUGH #endif - case Xboom_android: case Xboom_1: case Xbug_1_n: @@ -493,17 +601,6 @@ static boolean player_digfield(struct PLAYER *ply, int dx, int dy) case Xtank_2_e: case Xtank_2_s: case Xtank_2_w: - -#ifndef USE_CHANGED_ACID_STUFF - case Xacid_1: - case Xacid_2: - case Xacid_3: - case Xacid_4: - case Xacid_5: - case Xacid_6: - case Xacid_7: - case Xacid_8: -#endif ply->anim = PLY_walk_n + anim; ply->x = x; ply->y = y; @@ -1068,7 +1165,7 @@ static boolean player_digfield(struct PLAYER *ply, int dx, int dy) case Xswitch: play_element_sound(x, y, SOUND_press, element); lev.ball_cnt = lev.ball_time; - lev.ball_state = !lev.ball_state; + lev.ball_active = !lev.ball_active; break; case Xplant: @@ -1222,6 +1319,11 @@ static boolean player_digfield(struct PLAYER *ply, int dx, int dy) } } + /* check for wrap-around movement */ + if (ply->x < lev.left || + ply->x > lev.right - 1) + play_element_sound(oldx, oldy, SOUND_door, Xdoor_1); + return result; } @@ -1289,7 +1391,10 @@ static void check_player(struct PLAYER *ply) if (!can_move) { - ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0; + ply->joy_n = FALSE; + ply->joy_e = FALSE; + ply->joy_s = FALSE; + ply->joy_w = FALSE; return; } @@ -1297,7 +1402,7 @@ static void check_player(struct PLAYER *ply) if (dx == 0 && dy == 0) { - ply->joy_stick = 0; + ply->joy_stick = FALSE; if (ply->joy_drop) { @@ -1319,12 +1424,15 @@ static void check_player(struct PLAYER *ply) return; } - ply->joy_stick = 1; - ply->joy_n = ply->joy_e = ply->joy_s = ply->joy_w = 0; + ply->joy_stick = TRUE; + ply->joy_n = FALSE; + ply->joy_e = FALSE; + ply->joy_s = FALSE; + ply->joy_w = FALSE; + ply->dynamite_cnt = 0; /* reset dynamite timer if we move */ - ply->joy_spin = !ply->joy_spin; - if (ply->joy_snap == 0) /* player wants to move */ + if (!ply->joy_snap) /* player wants to move */ { boolean moved = FALSE; @@ -1469,14 +1577,14 @@ static void Landroid(int x, int y) if (lev.android_clone_cnt == 0) { - if (!is_blank[cave[x-1][y-1]] && - !is_blank[cave[x][y-1]] && - !is_blank[cave[x+1][y-1]] && - !is_blank[cave[x-1][y]] && - !is_blank[cave[x+1][y]] && - !is_blank[cave[x-1][y+1]] && - !is_blank[cave[x][y+1]] && - !is_blank[cave[x+1][y+1]]) + if (!is_android_blank[cave[x-1][y-1]] && + !is_android_blank[cave[x][y-1]] && + !is_android_blank[cave[x+1][y-1]] && + !is_android_blank[cave[x-1][y]] && + !is_android_blank[cave[x+1][y]] && + !is_android_blank[cave[x-1][y+1]] && + !is_android_blank[cave[x][y+1]] && + !is_android_blank[cave[x+1][y+1]]) goto android_move; switch (RANDOM(8)) @@ -1580,91 +1688,91 @@ static void Landroid(int x, int y) /* randomly find a direction to move */ case 0: /* S,NE,W,NW,SE,E,SW,N */ - if (is_blank[cave[x][y+1]]) goto android_s; - if (is_blank[cave[x+1][y-1]]) goto android_ne; - if (is_blank[cave[x-1][y]]) goto android_w; - if (is_blank[cave[x-1][y-1]]) goto android_nw; - if (is_blank[cave[x+1][y+1]]) goto android_se; - if (is_blank[cave[x+1][y]]) goto android_e; - if (is_blank[cave[x-1][y+1]]) goto android_sw; - if (is_blank[cave[x][y-1]]) goto android_n; + if (is_android_blank[cave[x][y+1]]) goto android_s; + if (is_android_blank[cave[x+1][y-1]]) goto android_ne; + if (is_android_blank[cave[x-1][y]]) goto android_w; + if (is_android_blank[cave[x-1][y-1]]) goto android_nw; + if (is_android_blank[cave[x+1][y+1]]) goto android_se; + if (is_android_blank[cave[x+1][y]]) goto android_e; + if (is_android_blank[cave[x-1][y+1]]) goto android_sw; + if (is_android_blank[cave[x][y-1]]) goto android_n; goto android_move; case 1: /* NW,SE,N,S,NE,SW,E,W */ - if (is_blank[cave[x-1][y-1]]) goto android_nw; - if (is_blank[cave[x+1][y+1]]) goto android_se; - if (is_blank[cave[x][y-1]]) goto android_n; - if (is_blank[cave[x][y+1]]) goto android_s; - if (is_blank[cave[x+1][y-1]]) goto android_ne; - if (is_blank[cave[x-1][y+1]]) goto android_sw; - if (is_blank[cave[x+1][y]]) goto android_e; - if (is_blank[cave[x-1][y]]) goto android_w; + if (is_android_blank[cave[x-1][y-1]]) goto android_nw; + if (is_android_blank[cave[x+1][y+1]]) goto android_se; + if (is_android_blank[cave[x][y-1]]) goto android_n; + if (is_android_blank[cave[x][y+1]]) goto android_s; + if (is_android_blank[cave[x+1][y-1]]) goto android_ne; + if (is_android_blank[cave[x-1][y+1]]) goto android_sw; + if (is_android_blank[cave[x+1][y]]) goto android_e; + if (is_android_blank[cave[x-1][y]]) goto android_w; goto android_move; case 2: /* SW,E,S,W,N,NW,SE,NE */ - if (is_blank[cave[x-1][y+1]]) goto android_sw; - if (is_blank[cave[x+1][y]]) goto android_e; - if (is_blank[cave[x][y+1]]) goto android_s; - if (is_blank[cave[x-1][y]]) goto android_w; - if (is_blank[cave[x][y-1]]) goto android_n; - if (is_blank[cave[x-1][y-1]]) goto android_nw; - if (is_blank[cave[x+1][y+1]]) goto android_se; - if (is_blank[cave[x+1][y-1]]) goto android_ne; + if (is_android_blank[cave[x-1][y+1]]) goto android_sw; + if (is_android_blank[cave[x+1][y]]) goto android_e; + if (is_android_blank[cave[x][y+1]]) goto android_s; + if (is_android_blank[cave[x-1][y]]) goto android_w; + if (is_android_blank[cave[x][y-1]]) goto android_n; + if (is_android_blank[cave[x-1][y-1]]) goto android_nw; + if (is_android_blank[cave[x+1][y+1]]) goto android_se; + if (is_android_blank[cave[x+1][y-1]]) goto android_ne; goto android_move; case 3: /* N,SE,NE,E,W,S,NW,SW */ - if (is_blank[cave[x][y-1]]) goto android_n; - if (is_blank[cave[x+1][y+1]]) goto android_se; - if (is_blank[cave[x+1][y-1]]) goto android_ne; - if (is_blank[cave[x+1][y]]) goto android_e; - if (is_blank[cave[x-1][y]]) goto android_w; - if (is_blank[cave[x][y+1]]) goto android_s; - if (is_blank[cave[x-1][y-1]]) goto android_nw; - if (is_blank[cave[x-1][y+1]]) goto android_sw; + if (is_android_blank[cave[x][y-1]]) goto android_n; + if (is_android_blank[cave[x+1][y+1]]) goto android_se; + if (is_android_blank[cave[x+1][y-1]]) goto android_ne; + if (is_android_blank[cave[x+1][y]]) goto android_e; + if (is_android_blank[cave[x-1][y]]) goto android_w; + if (is_android_blank[cave[x][y+1]]) goto android_s; + if (is_android_blank[cave[x-1][y-1]]) goto android_nw; + if (is_android_blank[cave[x-1][y+1]]) goto android_sw; goto android_move; case 4: /* SE,NW,E,NE,SW,W,N,S */ - if (is_blank[cave[x+1][y+1]]) goto android_se; - if (is_blank[cave[x-1][y-1]]) goto android_nw; - if (is_blank[cave[x+1][y]]) goto android_e; - if (is_blank[cave[x+1][y-1]]) goto android_ne; - if (is_blank[cave[x-1][y+1]]) goto android_sw; - if (is_blank[cave[x-1][y]]) goto android_w; - if (is_blank[cave[x][y-1]]) goto android_n; - if (is_blank[cave[x][y+1]]) goto android_s; + if (is_android_blank[cave[x+1][y+1]]) goto android_se; + if (is_android_blank[cave[x-1][y-1]]) goto android_nw; + if (is_android_blank[cave[x+1][y]]) goto android_e; + if (is_android_blank[cave[x+1][y-1]]) goto android_ne; + if (is_android_blank[cave[x-1][y+1]]) goto android_sw; + if (is_android_blank[cave[x-1][y]]) goto android_w; + if (is_android_blank[cave[x][y-1]]) goto android_n; + if (is_android_blank[cave[x][y+1]]) goto android_s; goto android_move; case 5: /* NE,W,SE,SW,S,N,E,NW */ - if (is_blank[cave[x+1][y-1]]) goto android_ne; - if (is_blank[cave[x-1][y]]) goto android_w; - if (is_blank[cave[x+1][y+1]]) goto android_se; - if (is_blank[cave[x-1][y+1]]) goto android_sw; - if (is_blank[cave[x][y+1]]) goto android_s; - if (is_blank[cave[x][y-1]]) goto android_n; - if (is_blank[cave[x+1][y]]) goto android_e; - if (is_blank[cave[x-1][y-1]]) goto android_nw; + if (is_android_blank[cave[x+1][y-1]]) goto android_ne; + if (is_android_blank[cave[x-1][y]]) goto android_w; + if (is_android_blank[cave[x+1][y+1]]) goto android_se; + if (is_android_blank[cave[x-1][y+1]]) goto android_sw; + if (is_android_blank[cave[x][y+1]]) goto android_s; + if (is_android_blank[cave[x][y-1]]) goto android_n; + if (is_android_blank[cave[x+1][y]]) goto android_e; + if (is_android_blank[cave[x-1][y-1]]) goto android_nw; goto android_move; case 6: /* E,N,SW,S,NW,NE,SE,W */ - if (is_blank[cave[x+1][y]]) goto android_e; - if (is_blank[cave[x][y-1]]) goto android_n; - if (is_blank[cave[x-1][y+1]]) goto android_sw; - if (is_blank[cave[x][y+1]]) goto android_s; - if (is_blank[cave[x-1][y-1]]) goto android_nw; - if (is_blank[cave[x+1][y-1]]) goto android_ne; - if (is_blank[cave[x+1][y+1]]) goto android_se; - if (is_blank[cave[x-1][y]]) goto android_w; + if (is_android_blank[cave[x+1][y]]) goto android_e; + if (is_android_blank[cave[x][y-1]]) goto android_n; + if (is_android_blank[cave[x-1][y+1]]) goto android_sw; + if (is_android_blank[cave[x][y+1]]) goto android_s; + if (is_android_blank[cave[x-1][y-1]]) goto android_nw; + if (is_android_blank[cave[x+1][y-1]]) goto android_ne; + if (is_android_blank[cave[x+1][y+1]]) goto android_se; + if (is_android_blank[cave[x-1][y]]) goto android_w; goto android_move; case 7: /* W,SW,NW,N,E,SE,NE,S */ - if (is_blank[cave[x-1][y]]) goto android_w; - if (is_blank[cave[x-1][y+1]]) goto android_sw; - if (is_blank[cave[x-1][y-1]]) goto android_nw; - if (is_blank[cave[x][y-1]]) goto android_n; - if (is_blank[cave[x+1][y]]) goto android_e; - if (is_blank[cave[x+1][y+1]]) goto android_se; - if (is_blank[cave[x+1][y-1]]) goto android_ne; - if (is_blank[cave[x][y+1]]) goto android_s; + if (is_android_blank[cave[x-1][y]]) goto android_w; + if (is_android_blank[cave[x-1][y+1]]) goto android_sw; + if (is_android_blank[cave[x-1][y-1]]) goto android_nw; + if (is_android_blank[cave[x][y-1]]) goto android_n; + if (is_android_blank[cave[x+1][y]]) goto android_e; + if (is_android_blank[cave[x+1][y+1]]) goto android_se; + if (is_android_blank[cave[x+1][y-1]]) goto android_ne; + if (is_android_blank[cave[x][y+1]]) goto android_s; goto android_move; } } @@ -2802,7 +2910,8 @@ 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); + next[x][y] = Zboom; + Lboom_bug(x, y); return; } @@ -2849,7 +2958,8 @@ 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); + next[x][y] = Zboom; + Lboom_bug(x, y); return; } @@ -2914,7 +3024,8 @@ 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); + next[x][y] = Zboom; + Lboom_bug(x, y); return; } @@ -2961,7 +3072,8 @@ 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); + next[x][y] = Zboom; + Lboom_bug(x, y); return; } @@ -3026,7 +3138,8 @@ 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); + next[x][y] = Zboom; + Lboom_bug(x, y); return; } @@ -3073,7 +3186,8 @@ 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); + next[x][y] = Zboom; + Lboom_bug(x, y); return; } @@ -3138,7 +3252,8 @@ 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); + next[x][y] = Zboom; + Lboom_bug(x, y); return; } @@ -3185,7 +3300,8 @@ 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); + next[x][y] = Zboom; + Lboom_bug(x, y); return; } @@ -3250,7 +3366,8 @@ 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); + next[x][y] = Zboom; + Lboom_tank(x, y); return; } @@ -3297,7 +3414,8 @@ 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); + next[x][y] = Zboom; + Lboom_tank(x, y); return; } @@ -3362,7 +3480,8 @@ 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); + next[x][y] = Zboom; + Lboom_tank(x, y); return; } @@ -3409,7 +3528,8 @@ 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); + next[x][y] = Zboom; + Lboom_tank(x, y); return; } @@ -3474,7 +3594,8 @@ 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); + next[x][y] = Zboom; + Lboom_tank(x, y); return; } @@ -3521,7 +3642,8 @@ 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); + next[x][y] = Zboom; + Lboom_tank(x, y); return; } @@ -3586,7 +3708,8 @@ 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); + next[x][y] = Zboom; + Lboom_tank(x, y); return; } @@ -3633,7 +3756,8 @@ 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); + next[x][y] = Zboom; + Lboom_tank(x, y); return; } @@ -3878,9 +4002,9 @@ static void Lemerald_fall(int x, int y) return; case Xwonderwall: - if (lev.wonderwall_time) + if (lev.wonderwall_time > 0) { - lev.wonderwall_state = 1; + lev.wonderwall_active = TRUE; cave[x][y] = Yemerald_sB; next[x][y] = Xblank; if (is_blank[cave[x][y+2]]) @@ -4137,9 +4261,9 @@ static void Ldiamond_fall(int x, int y) return; case Xwonderwall: - if (lev.wonderwall_time) + if (lev.wonderwall_time > 0) { - lev.wonderwall_state = 1; + lev.wonderwall_active = TRUE; cave[x][y] = Ydiamond_sB; next[x][y] = Xblank; if (is_blank[cave[x][y+2]]) @@ -4393,16 +4517,20 @@ static void Lstone_fall(int x, int y) case Xeater_s: case Xeater_w: cave[x][y] = Ystone_sB; + Lboom_next_new(x, y, Xblank); cave[x][y+1] = Yeater_stone; - Lboom_eater(x, y+1, Xstone_fall); + next[x][y+1] = Zeater; + Lboom_eater_old(x, y+1); score += lev.eater_score; return; case Xalien: case Xalien_pause: cave[x][y] = Ystone_sB; + Lboom_next_new(x, y, Xblank); cave[x][y+1] = Yalien_stone; - Lboom_tank(x, y+1, Xstone_fall); + next[x][y+1] = Ztank; + Lboom_tank_old(x, y+1); score += lev.alien_score; return; @@ -4415,8 +4543,10 @@ static void Lstone_fall(int x, int y) case Xbug_2_s: case Xbug_2_w: cave[x][y] = Ystone_sB; + Lboom_next_new(x, y, Xblank); cave[x][y+1] = Ybug_stone; - Lboom_bug(x, y+1, Xstone_fall); + next[x][y+1] = Zbug; + Lboom_bug_old(x, y+1); score += lev.bug_score; return; @@ -4429,8 +4559,10 @@ static void Lstone_fall(int x, int y) case Xtank_2_s: case Xtank_2_w: cave[x][y] = Ystone_sB; + Lboom_next_new(x, y, Xblank); cave[x][y+1] = Ytank_stone; - Lboom_tank(x, y+1, Xstone_fall); + next[x][y+1] = Ztank; + Lboom_tank_old(x, y+1); score += lev.tank_score; return; @@ -4506,8 +4638,11 @@ static void Lstone_fall(int x, int y) case Xbomb: case Xbomb_pause: + Lboom_cave_new(x, y, Xstone); + Lboom_next_new(x, y, Xstone); cave[x][y+1] = Ybomb_blank; - Lboom_tank(x, y+1, Xstone_fall); + next[x][y+1] = Ztank; + Lboom_tank_old(x, y+1); return; case Xnut: @@ -4574,9 +4709,9 @@ static void Lstone_fall(int x, int y) return; case Xwonderwall: - if (lev.wonderwall_time) + if (lev.wonderwall_time > 0) { - lev.wonderwall_state = 1; + lev.wonderwall_active = TRUE; cave[x][y] = Ystone_sB; next[x][y] = Xblank; if (is_blank[cave[x][y+2]]) @@ -4815,7 +4950,8 @@ static void Lbomb_fall(int x, int y) default: cave[x][y] = Ybomb_blank; - Lboom_tank(x, y, Xbomb_fall); + next[x][y] = Ztank; + Lboom_tank_old(x, y); return; } } @@ -5509,16 +5645,20 @@ static void Lspring_fall(int x, int y) case Xeater_s: case Xeater_w: cave[x][y] = Yspring_sB; + next[x][y] = Xblank; cave[x][y+1] = Yeater_spring; - Lboom_eater(x, y+1, Xspring_fall); + next[x][y+1] = Zeater; + Lboom_eater_old(x, y+1); score += lev.eater_score; return; case Xalien: case Xalien_pause: cave[x][y] = Yspring_sB; + next[x][y] = Xblank; cave[x][y+1] = Yalien_spring; - Lboom_tank(x, y+1, Xspring_fall); + next[x][y+1] = Ztank; + Lboom_tank_old(x, y+1); score += lev.alien_score; return; @@ -5531,8 +5671,10 @@ static void Lspring_fall(int x, int y) case Xbug_2_s: case Xbug_2_w: cave[x][y] = Yspring_sB; + next[x][y] = Xblank; cave[x][y+1] = Ybug_spring; - Lboom_bug(x, y+1, Xspring_fall); + next[x][y+1] = Zbug; + Lboom_bug_old(x, y+1); score += lev.bug_score; return; @@ -5545,15 +5687,20 @@ static void Lspring_fall(int x, int y) case Xtank_2_s: case Xtank_2_w: cave[x][y] = Yspring_sB; + next[x][y] = Xblank; cave[x][y+1] = Ytank_spring; - Lboom_tank(x, y+1, Xspring_fall); + next[x][y+1] = Ztank; + Lboom_tank_old(x, y+1); score += lev.tank_score; return; case Xbomb: case Xbomb_pause: + cave[x][y] = Xspring; + next[x][y] = Xspring; cave[x][y+1] = Ybomb_blank; - Lboom_tank(x, y+1, Xspring_fall); + next[x][y+1] = Ztank; + Lboom_tank_old(x, y+1); return; default: @@ -5571,15 +5718,21 @@ static void Lpush_emerald_e(int x, int y) switch (cave[x+1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xemerald); return; #ifdef ACID_ROLL @@ -5611,15 +5764,21 @@ static void Lpush_emerald_w(int x, int y) switch (cave[x-1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xemerald); return; #ifdef ACID_ROLL @@ -5651,15 +5810,21 @@ static void Lpush_diamond_e(int x, int y) switch (cave[x+1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xdiamond); return; #ifdef ACID_ROLL @@ -5691,15 +5856,21 @@ static void Lpush_diamond_w(int x, int y) switch (cave[x-1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xdiamond); return; #ifdef ACID_ROLL @@ -5731,15 +5902,21 @@ static void Lpush_stone_e(int x, int y) switch (cave[x+1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xstone); return; #ifdef ACID_ROLL @@ -5771,15 +5948,21 @@ static void Lpush_stone_w(int x, int y) switch (cave[x-1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xstone); return; #ifdef ACID_ROLL @@ -5811,15 +5994,21 @@ static void Lpush_bomb_e(int x, int y) switch (cave[x+1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xbomb); return; #ifdef ACID_ROLL @@ -5851,15 +6040,21 @@ static void Lpush_bomb_w(int x, int y) switch (cave[x-1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xbomb); return; #ifdef ACID_ROLL @@ -5891,15 +6086,21 @@ static void Lpush_nut_e(int x, int y) switch (cave[x+1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xnut); return; #ifdef ACID_ROLL @@ -5931,15 +6132,21 @@ static void Lpush_nut_w(int x, int y) switch (cave[x-1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xnut); return; #ifdef ACID_ROLL @@ -5971,15 +6178,21 @@ static void Lpush_spring_e(int x, int y) switch (cave[x+1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xspring); return; #ifdef ACID_ROLL @@ -6011,15 +6224,21 @@ static void Lpush_spring_w(int x, int y) switch (cave[x-1][y]) { + case Zplayer: + if (!game_em.use_old_push_elements) + break; case Zborder: case Zbug: case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: case Xboom_1: + Lpush_element_old(x, y, Xspring); return; #ifdef ACID_ROLL @@ -6428,7 +6647,7 @@ static void Lball_common(int x, int y) static void Lball_1(int x, int y) { - if (lev.ball_state == 0) + if (!lev.ball_active) return; cave[x][y] = Yball_1; @@ -6441,7 +6660,7 @@ static void Lball_1(int x, int y) static void Lball_2(int x, int y) { - if (lev.ball_state == 0) + if (!lev.ball_active) return; cave[x][y] = Yball_2; @@ -6534,7 +6753,7 @@ static void Ldrip_stretchB(int x, int y) static void Lwonderwall(int x, int y) { - if (lev.wonderwall_time && lev.wonderwall_state) + if (lev.wonderwall_time > 0 && lev.wonderwall_active) { cave[x][y] = Ywonderwall; play_element_sound(x, y, SOUND_wonder, Xwonderwall); @@ -6549,7 +6768,7 @@ static void Lwheel(int x, int y) static void Lswitch(int x, int y) { - if (lev.ball_state) + if (lev.ball_active) cave[x][y] = Yswitch; } @@ -6815,6 +7034,8 @@ static void Lboom_one(int x, int y, boolean by_dynamite) case Ztank: case Zeater: case Zdynamite: + case Zboom: + case Xchain: case Xboom_bug: case Xboom_tank: case Xboom_android: @@ -6877,12 +7098,14 @@ static void Lboom_one(int x, int y, boolean by_dynamite) case Xbug_2_s: case Xbug_2_w: cave[x][y] = Xboom_bug; + Lboom_bug_new(x, y, TRUE); return; case Xbomb: case Xbomb_pause: case Xbomb_fall: cave[x][y] = Xboom_tank; + Lboom_tank_new(x, y, TRUE); return; default: @@ -6910,20 +7133,27 @@ static void Lexplode(int x, int y) switch (cave[x][y]) { case Zbug: + Lboom_bug_new(x, y, FALSE); Lboom_nine(x, y, FALSE); break; case Ztank: + Lboom_tank_new(x, y, FALSE); Lboom_nine(x, y, FALSE); break; case Zeater: + Lboom_eater_new(x, y, FALSE); Lboom_nine(x, y, FALSE); break; case Zdynamite: Lboom_nine(x, y, TRUE); break; + + case Zboom: + Lboom_nine(x, y, FALSE); + break; } } @@ -6952,6 +7182,11 @@ static void Lboom_android(int x, int y) Lboom_1(x, y); } +static void Lchain(int x, int y) +{ + next[x][y] = Zboom; +} + static void handle_tile(int x, int y) { switch (cave[x][y]) @@ -7111,15 +7346,16 @@ 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_tank: Lboom_tank(x, y, Xboom_tank); break; + case Xchain: Lchain(x, y); 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; } } -void logic_players(void) +static void logic_players(void) { int start_check_nr; int i; @@ -7142,6 +7378,9 @@ void logic_players(void) for (i = 0; i < MAX_PLAYERS; i++) { + if (!ply[i].alive) + continue; + /* check for wrap-around movement */ if (ply[i].x < lev.left || ply[i].x > lev.right - 1) @@ -7150,11 +7389,11 @@ void logic_players(void) game.centered_player_nr_next = i; game.set_centered_player = TRUE; - game.set_centered_player_fast = TRUE; + game.set_centered_player_wrap = TRUE; } - ply[i].oldx = ply[i].x; - ply[i].oldy = ply[i].y; + ply[i].prev_x = ply[i].x; + ply[i].prev_y = ply[i].y; ply[i].anim = PLY_still; } @@ -7174,10 +7413,10 @@ void logic_players(void) if (!ply[i].alive) continue; - if (cave[ply[i].oldx][ply[i].oldy] == Zplayer) + if (cave[ply[i].prev_x][ply[i].prev_y] == Zplayer) { - cave[ply[i].oldx][ply[i].oldy] = Xblank; - next[ply[i].oldx][ply[i].oldy] = Xblank; + cave[ply[i].prev_x][ply[i].prev_y] = Xblank; + next[ply[i].prev_x][ply[i].prev_y] = Xblank; } if (cave[ply[i].x][ply[i].y] == Xblank) @@ -7188,7 +7427,7 @@ void logic_players(void) } } -void logic_objects(void) +static void logic_objects(void) { int x, y; @@ -7217,7 +7456,7 @@ void logic_objects(void) lev.draw = temp; } -void logic_globals(void) +static void logic_globals(void) { int x; int y; @@ -7237,7 +7476,7 @@ void logic_globals(void) lev.android_move_cnt = lev.android_move_time; if (lev.android_clone_cnt-- == 0) lev.android_clone_cnt = lev.android_clone_time; - if (lev.ball_state) + if (lev.ball_active) if (lev.ball_cnt-- == 0) lev.ball_cnt = lev.ball_time; if (lev.lenses_cnt) @@ -7248,7 +7487,7 @@ void logic_globals(void) lev.wheel_cnt--; if (lev.wind_cnt) lev.wind_cnt--; - if (lev.wonderwall_time && lev.wonderwall_state) + if (lev.wonderwall_time > 0 && lev.wonderwall_active) lev.wonderwall_time--; if (lev.wheel_cnt) @@ -7284,3 +7523,25 @@ void logic_globals(void) for (x = lev.left; x < lev.right; x++) next[x][y] = cave[x][y]; } + +void logic_init(void) +{ + int splash_is_blank = !game_em.use_old_android; + + is_android_blank[Xsplash_e] = splash_is_blank; + is_android_blank[Xsplash_w] = splash_is_blank; +} + +void logic(void) +{ + if (frame == 0) + { + logic_players(); + logic_objects(); + } + + if (frame == 1) + { + logic_globals(); + } +}