X-Git-Url: https://git.artsoft.org/?p=rocksndiamonds.git;a=blobdiff_plain;f=src%2Fgame.c;h=95d5555ac234d479f76f6e5f74ea0f8ab3fe1dda;hp=e159b96ef2183c7d6c73aed8c0f709872fefe5d6;hb=bedda26c9679746341258d3c69cc36793051d4c2;hpb=727d3b5fc7cac6f59652eaa23f1ed9e991ae50bd diff --git a/src/game.c b/src/game.c index e159b96e..95d5555a 100644 --- a/src/game.c +++ b/src/game.c @@ -2150,6 +2150,8 @@ void UpdateGameControlValues() level.native_em_level->lev->time : level.game_engine_type == GAME_ENGINE_TYPE_SP ? level.native_sp_level->game_sp->time_played : + level.game_engine_type == GAME_ENGINE_TYPE_MM ? + game_mm.energy_left : game.no_time_limit ? TimePlayed : TimeLeft); int score = (local_player->LevelSolved ? local_player->LevelSolved_CountingScore : @@ -2157,16 +2159,23 @@ void UpdateGameControlValues() level.native_em_level->lev->score : level.game_engine_type == GAME_ENGINE_TYPE_SP ? level.native_sp_level->game_sp->score : + level.game_engine_type == GAME_ENGINE_TYPE_MM ? + game_mm.score : local_player->score); int gems = (level.game_engine_type == GAME_ENGINE_TYPE_EM ? level.native_em_level->lev->required : level.game_engine_type == GAME_ENGINE_TYPE_SP ? level.native_sp_level->game_sp->infotrons_still_needed : + level.game_engine_type == GAME_ENGINE_TYPE_MM ? + game_mm.kettles_still_needed : local_player->gems_still_needed); int exit_closed = (level.game_engine_type == GAME_ENGINE_TYPE_EM ? level.native_em_level->lev->required > 0 : level.game_engine_type == GAME_ENGINE_TYPE_SP ? level.native_sp_level->game_sp->infotrons_still_needed > 0 : + level.game_engine_type == GAME_ENGINE_TYPE_MM ? + game_mm.kettles_still_needed > 0 || + game_mm.lights_still_needed > 0 : local_player->gems_still_needed > 0 || local_player->sokobanfields_still_needed > 0 || local_player->lights_still_needed > 0); @@ -3060,6 +3069,11 @@ static void InitGameEngine() strEqual(setup.engine_snapshot_mode, STR_SNAPSHOT_MODE_EVERY_COLLECT) ? SNAPSHOT_MODE_EVERY_COLLECT : SNAPSHOT_MODE_OFF); game.snapshot.save_snapshot = FALSE; + + /* ---------- initialize level time for Supaplex engine ------------------- */ + /* Supaplex levels with time limit currently unsupported -- should be added */ + if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + level.time = 0; } int get_num_special_action(int element, int action_first, int action_last) @@ -3930,6 +3944,10 @@ void InitGame() { InitGameEngine_SP(); } + else if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + { + InitGameEngine_MM(); + } else { DrawLevel(REDRAW_FIELD); @@ -3948,6 +3966,9 @@ void InitGame() FadeIn(fade_mask); + if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + InitGameEngine_MM_AfterFadingIn(); + #if 1 // full screen redraw is required at this point in the following cases: // - special editor door undrawn when game was started from level editor @@ -4263,7 +4284,10 @@ static void PlayerWins(struct PlayerInfo *player) player->GameOver = TRUE; player->score_final = (level.game_engine_type == GAME_ENGINE_TYPE_EM ? - level.native_em_level->lev->score : player->score); + level.native_em_level->lev->score : + level.game_engine_type == GAME_ENGINE_TYPE_MM ? + game_mm.score : + player->score); player->LevelSolved_CountingTime = (game.no_time_limit ? TimePlayed : TimeLeft); @@ -10829,6 +10853,21 @@ static void CheckLevelTime() if (game_sp.GameOver) /* game lost */ AllPlayersGone = TRUE; } + else if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + { + if (game_mm.LevelSolved && + !game_mm.GameOver) /* game won */ + { + PlayerWins(local_player); + + game_mm.GameOver = TRUE; + + AllPlayersGone = TRUE; + } + + if (game_mm.GameOver) /* game lost */ + AllPlayersGone = TRUE; + } if (TimeFrames >= FRAMES_PER_SECOND) { @@ -11027,6 +11066,21 @@ void GameActionsExt() if (game_sp.GameOver) /* game lost */ AllPlayersGone = TRUE; } + else if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + { + if (game_mm.LevelSolved && + !game_mm.GameOver) /* game won */ + { + PlayerWins(local_player); + + game_mm.GameOver = TRUE; + + AllPlayersGone = TRUE; + } + + if (game_mm.GameOver) /* game lost */ + AllPlayersGone = TRUE; + } if (local_player->LevelSolved && !local_player->LevelSolved_GameEnd) GameWon(); @@ -11209,6 +11263,10 @@ void GameActionsExt() { GameActions_SP_Main(); } + else if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + { + GameActions_MM_Main(); + } else { GameActions_RND_Main(); @@ -11295,6 +11353,18 @@ void GameActions_SP_Main() } } +void GameActions_MM_Main() +{ + byte effective_action[MAX_PLAYERS]; + boolean warp_mode = (tape.playing && tape.warp_forward && !tape.pausing); + int i; + + for (i = 0; i < MAX_PLAYERS; i++) + effective_action[i] = stored_player[i].effective_action; + + GameActions_MM(effective_action, warp_mode); +} + void GameActions_RND_Main() { GameActions_RND(); @@ -14738,6 +14808,8 @@ ListNode *SaveEngineSnapshotBuffers() SaveEngineSnapshotValues_EM(); if (level.game_engine_type == GAME_ENGINE_TYPE_SP) SaveEngineSnapshotValues_SP(&buffers); + if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + SaveEngineSnapshotValues_MM(&buffers); /* save values stored in special snapshot structure */ @@ -14747,6 +14819,8 @@ ListNode *SaveEngineSnapshotBuffers() SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_em)); if (level.game_engine_type == GAME_ENGINE_TYPE_SP) SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_sp)); + if (level.game_engine_type == GAME_ENGINE_TYPE_MM) + SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(engine_snapshot_mm)); /* save further RND engine values */ @@ -14888,6 +14962,8 @@ void LoadEngineSnapshotValues() LoadEngineSnapshotValues_EM(); if (level.game_engine_type == GAME_ENGINE_TYPE_SP) LoadEngineSnapshotValues_SP(); + if (level.game_engine_type == GAME_ENGINE_TYPE_SP) + LoadEngineSnapshotValues_MM(); } void LoadEngineSnapshotSingle()