X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fgame.c;h=5391ce9197c8728f4f831641fb88e930f44e12ba;hb=dc10681f0cac355f8b3a7197e058d9e50471181b;hp=b8d863fe232597b2b32f3c43132b2d10c6255980;hpb=e6b3efaee4f084e66f2fa709402f25fc67536952;p=rocksndiamonds.git diff --git a/src/game.c b/src/game.c index b8d863fe..5391ce91 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); @@ -4599,6 +4623,10 @@ void InitPlayerGfxAnimation(struct PlayerInfo *player, int action, int dir) static void ResetGfxFrame(int x, int y) { + // profiling showed that "autotest" spends 10~20% of its time in this function + if (DrawingDeactivatedField()) + return; + int element = Feld[x][y]; int graphic = el_act_dir2img(element, GfxAction[x][y], GfxDir[x][y]); @@ -10825,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.level_solved && + !game_mm.game_over) /* game won */ + { + PlayerWins(local_player); + + game_mm.game_over = TRUE; + + AllPlayersGone = TRUE; + } + + if (game_mm.game_over) /* game lost */ + AllPlayersGone = TRUE; + } if (TimeFrames >= FRAMES_PER_SECOND) { @@ -11023,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.level_solved && + !game_mm.game_over) /* game won */ + { + PlayerWins(local_player); + + game_mm.game_over = TRUE; + + AllPlayersGone = TRUE; + } + + if (game_mm.game_over) /* game lost */ + AllPlayersGone = TRUE; + } if (local_player->LevelSolved && !local_player->LevelSolved_GameEnd) GameWon(); @@ -11205,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(); @@ -11291,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(); @@ -14734,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 */ @@ -14743,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 */ @@ -14884,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()