From: Holger Schemel Date: Tue, 30 Oct 2018 19:55:42 +0000 (+0100) Subject: added flags for "level solved" and "game over" to EM engine X-Git-Tag: 4.1.2.0~115 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=99261bc36a147246e39cdc6d5ce9b098257c4d1b;p=rocksndiamonds.git added flags for "level solved" and "game over" to EM engine --- diff --git a/src/game.c b/src/game.c index a780952b..12397d5c 100644 --- a/src/game.c +++ b/src/game.c @@ -11117,19 +11117,17 @@ static void CheckLevelSolved(void) { if (level.game_engine_type == GAME_ENGINE_TYPE_EM) { - if (level.native_em_level->lev->home == 0) // all players at home + if (game_em.level_solved && + !game_em.game_over) // game won { PlayerWins(local_player); - AllPlayersGone = TRUE; + game_em.game_over = TRUE; - level.native_em_level->lev->home = -1; + AllPlayersGone = TRUE; } - if (level.native_em_level->ply[0]->alive == 0 && - level.native_em_level->ply[1]->alive == 0 && - level.native_em_level->ply[2]->alive == 0 && - level.native_em_level->ply[3]->alive == 0) // all dead + if (game_em.game_over) // game lost AllPlayersGone = TRUE; } else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) @@ -15041,7 +15039,7 @@ boolean checkGameFailed(void) return FALSE; if (level.game_engine_type == GAME_ENGINE_TYPE_EM) - return (level.native_em_level->lev->home > 0); + return (game_em.game_over && !game_em.level_solved); else if (level.game_engine_type == GAME_ENGINE_TYPE_SP) return (game_sp.game_over && !game_sp.level_solved); else if (level.game_engine_type == GAME_ENGINE_TYPE_MM) diff --git a/src/game_em/convert.c b/src/game_em/convert.c index c5f563b2..d61e33ee 100644 --- a/src/game_em/convert.c +++ b/src/game_em/convert.c @@ -1115,6 +1115,9 @@ void prepare_em_level(void) // - game_em.use_single_button (default: TRUE) // - game_em.use_snap_key_bug (default: FALSE) + game_em.level_solved = FALSE; + game_em.game_over = FALSE; + game_em.any_player_moving = FALSE; game_em.any_player_snapping = FALSE; diff --git a/src/game_em/export.h b/src/game_em/export.h index 90957d69..45cbd250 100644 --- a/src/game_em/export.h +++ b/src/game_em/export.h @@ -664,6 +664,9 @@ struct GlobalInfo_EM struct GameInfo_EM { + boolean level_solved; + boolean game_over; + boolean any_player_moving; boolean any_player_snapping; diff --git a/src/game_em/synchro_1.c b/src/game_em/synchro_1.c index cea29bb2..b390ad91 100644 --- a/src/game_em/synchro_1.c +++ b/src/game_em/synchro_1.c @@ -1069,6 +1069,9 @@ static boolean player_digfield(struct PLAYER *ply, int dx, int dy) case Xexit_3: lev.home--; + if (lev.home == 0) + game_em.level_solved = TRUE; + ply->anim = SPR_walk + anim; ply->x = x; ply->y = y; diff --git a/src/game_em/synchro_2.c b/src/game_em/synchro_2.c index 8fc7ada1..70f6797c 100644 --- a/src/game_em/synchro_2.c +++ b/src/game_em/synchro_2.c @@ -4867,6 +4867,8 @@ void synchro_2(void) if (ply[0].alive || ply[1].alive || ply[2].alive || ply[3].alive) lev.score += score; /* only add a score if someone is alive */ + else + game_em.game_over = TRUE; RandomEM = random;