X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame_em%2Flogic.c;h=8b759630e93bc8524f02d7c7663af538b7134030;hb=3fd63fd1559c678f0b63ba48d0de211aab1cf591;hp=7840734eaa75235a2d3a6b977be4b3f39c0ddf1e;hpb=63539da7f2d5e1ca071f0e4a9d897df0595d6ae5;p=rocksndiamonds.git diff --git a/src/game_em/logic.c b/src/game_em/logic.c index 7840734e..8b759630 100644 --- a/src/game_em/logic.c +++ b/src/game_em/logic.c @@ -12,6 +12,8 @@ #define ACID_ROLL /* rolling objects go into acid rather than remove it */ #define ACID_PLAYER /* player gets killed by acid, but without explosion */ +#define RANDOM_BUG /* handle problem with old tapes using 64-bit random */ + #define RANDOM(x) ((seed = seed << 31 | seed >> 1) % x) static short **cave, **next, **boom; @@ -165,7 +167,7 @@ static void Lboom_eater(int x, int y) 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) % 8; + lev.eater_pos = (lev.eater_pos + 1) % lev.num_eater_arrays; #if PLAY_ELEMENT_SOUND play_element_sound(x, y, SOUND_boom, Xeater_n); @@ -5744,6 +5746,8 @@ static void Lpush_emerald_e(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x+2][y-1] == Xblank) cave[x+2][y-1] = Xsplash_e; if (cave[x][y-1] == Xblank) @@ -5790,6 +5794,8 @@ static void Lpush_emerald_w(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x][y-1] == Xblank) cave[x][y-1] = Xsplash_e; if (cave[x-2][y-1] == Xblank) @@ -5836,6 +5842,8 @@ static void Lpush_diamond_e(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x+2][y-1] == Xblank) cave[x+2][y-1] = Xsplash_e; if (cave[x][y-1] == Xblank) @@ -5882,6 +5890,8 @@ static void Lpush_diamond_w(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x][y-1] == Xblank) cave[x][y-1] = Xsplash_e; if (cave[x-2][y-1] == Xblank) @@ -5928,6 +5938,8 @@ static void Lpush_stone_e(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x+2][y-1] == Xblank) cave[x+2][y-1] = Xsplash_e; if (cave[x][y-1] == Xblank) @@ -5974,6 +5986,8 @@ static void Lpush_stone_w(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x][y-1] == Xblank) cave[x][y-1] = Xsplash_e; if (cave[x-2][y-1] == Xblank) @@ -6020,6 +6034,8 @@ static void Lpush_bomb_e(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x+2][y-1] == Xblank) cave[x+2][y-1] = Xsplash_e; if (cave[x][y-1] == Xblank) @@ -6066,6 +6082,8 @@ static void Lpush_bomb_w(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x][y-1] == Xblank) cave[x][y-1] = Xsplash_e; if (cave[x-2][y-1] == Xblank) @@ -6112,6 +6130,8 @@ static void Lpush_nut_e(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x+2][y-1] == Xblank) cave[x+2][y-1] = Xsplash_e; if (cave[x][y-1] == Xblank) @@ -6158,6 +6178,8 @@ static void Lpush_nut_w(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x][y-1] == Xblank) cave[x][y-1] = Xsplash_e; if (cave[x-2][y-1] == Xblank) @@ -6204,6 +6226,8 @@ static void Lpush_spring_e(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x+2][y-1] == Xblank) cave[x+2][y-1] = Xsplash_e; if (cave[x][y-1] == Xblank) @@ -6250,6 +6274,8 @@ static void Lpush_spring_w(int x, int y) case Xacid_6: case Xacid_7: case Xacid_8: + if (game_em.use_old_push_into_acid) + break; if (cave[x][y-1] == Xblank) cave[x][y-1] = Xsplash_e; if (cave[x-2][y-1] == Xblank) @@ -7355,27 +7381,28 @@ static void handle_tile(int x, int y) } } -static void logic_players(void) +boolean logic_check_wrap(void) { - int start_check_nr; int i; - cave = lev.cave; - next = lev.next; - boom = lev.boom; - - game_em.any_player_moving = FALSE; - game_em.any_player_snapping = FALSE; - - /* must test for death and actually kill separately */ for (i = 0; i < MAX_PLAYERS; i++) { - boolean ply_kill = player_killed(&ply[i]); + if (!ply[i].alive) + continue; - if (ply[i].alive && ply_kill) - kill_player(&ply[i]); + /* check for wrap-around movement */ + if (ply[i].x < lev.left || + ply[i].x > lev.right - 1) + return TRUE; } + return FALSE; +} + +void logic_move(void) +{ + int i; + for (i = 0; i < MAX_PLAYERS; i++) { if (!ply[i].alive) @@ -7387,6 +7414,9 @@ static void logic_players(void) { ply[i].x = (ply[i].x < lev.left ? lev.right - 1 : lev.left); + if (!lev.infinite_true) + ply[i].y += (ply[i].x == lev.left ? 1 : -1); + game.centered_player_nr_next = i; game.set_centered_player = TRUE; game.set_centered_player_wrap = TRUE; @@ -7396,6 +7426,30 @@ static void logic_players(void) ply[i].prev_y = ply[i].y; ply[i].anim = PLY_still; } +} + +static void logic_players(void) +{ + int start_check_nr; + int i; + + cave = lev.cave; + next = lev.next; + boom = lev.boom; + + game_em.any_player_moving = FALSE; + game_em.any_player_snapping = FALSE; + + /* must test for death and actually kill separately */ + for (i = 0; i < MAX_PLAYERS; i++) + { + boolean ply_kill = player_killed(&ply[i]); + + if (ply[i].alive && ply_kill) + kill_player(&ply[i]); + } + + logic_move(); start_check_nr = ((game_em.random & 128 ? 0 : 1) * 2 + (game_em.random & 256 ? 0 : 1)); @@ -7461,7 +7515,11 @@ static void logic_globals(void) int x; int y; int count; - unsigned int random; +#ifdef RANDOM_BUG + uint64_t random; +#else + uint32_t random; +#endif cave = lev.cave; next = lev.next; @@ -7507,6 +7565,11 @@ static void logic_globals(void) Lamoeba(x, y); random = random * 129 + 1; + +#ifdef RANDOM_BUG + if (!game_em.use_random_bug) + random = (uint32_t)random; +#endif } game_em.random = random;