From: Holger Schemel Date: Wed, 14 Nov 2018 19:59:13 +0000 (+0100) Subject: moved (and renamed) global variables to game structure (ExitX/ExitY) X-Git-Tag: 4.1.2.0~104 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=54cd73c4e6a8fc9521f0adda5501cd09eb294b4c;p=rocksndiamonds.git moved (and renamed) global variables to game structure (ExitX/ExitY) --- diff --git a/src/game.c b/src/game.c index c8c5de48..c1846d6a 100644 --- a/src/game.c +++ b/src/game.c @@ -3544,7 +3544,6 @@ void InitGame(void) SendToServer_MovePlayer(MV_NONE); ZX = ZY = -1; - ExitX = ExitY = -1; FrameCounter = 0; TimeFrames = 0; @@ -3558,6 +3557,9 @@ void InitGame(void) ScrollStepSize = 0; // will be correctly initialized by ScrollScreen() + game.exit_x = -1; + game.exit_y = -1; + game.all_players_gone = FALSE; game.LevelSolved = FALSE; @@ -4570,30 +4572,35 @@ void GameWon(void) if (level.game_engine_type == GAME_ENGINE_TYPE_RND) { - if (ExitX >= 0 && ExitY >= 0) // local player has left the level + // check if last player has left the level + if (game.exit_x >= 0 && + game.exit_y >= 0) { + int x = game.exit_x; + int y = game.exit_y; + int element = Feld[x][y]; + // close exit door after last player if ((game.all_players_gone && - (Feld[ExitX][ExitY] == EL_EXIT_OPEN || - Feld[ExitX][ExitY] == EL_SP_EXIT_OPEN || - Feld[ExitX][ExitY] == EL_STEEL_EXIT_OPEN)) || - Feld[ExitX][ExitY] == EL_EM_EXIT_OPEN || - Feld[ExitX][ExitY] == EL_EM_STEEL_EXIT_OPEN) + (element == EL_EXIT_OPEN || + element == EL_SP_EXIT_OPEN || + element == EL_STEEL_EXIT_OPEN)) || + element == EL_EM_EXIT_OPEN || + element == EL_EM_STEEL_EXIT_OPEN) { - int element = Feld[ExitX][ExitY]; - Feld[ExitX][ExitY] = + Feld[x][y] = (element == EL_EXIT_OPEN ? EL_EXIT_CLOSING : element == EL_EM_EXIT_OPEN ? EL_EM_EXIT_CLOSING : element == EL_SP_EXIT_OPEN ? EL_SP_EXIT_CLOSING: element == EL_STEEL_EXIT_OPEN ? EL_STEEL_EXIT_CLOSING: EL_EM_STEEL_EXIT_CLOSING); - PlayLevelSoundElementAction(ExitX, ExitY, element, ACTION_CLOSING); + PlayLevelSoundElementAction(x, y, element, ACTION_CLOSING); } // player disappears - DrawLevelField(ExitX, ExitY); + DrawLevelField(x, y); } for (i = 0; i < MAX_PLAYERS; i++) @@ -6815,8 +6822,8 @@ static void TurnRoundExt(int x, int y) if (game.all_players_gone) { - attr_x = ExitX; - attr_y = ExitY; + attr_x = game.exit_x; + attr_y = game.exit_y; } else { @@ -7184,8 +7191,8 @@ static void TurnRoundExt(int x, int y) if (game.all_players_gone) { - attr_x = ExitX; - attr_y = ExitY; + attr_x = game.exit_x; + attr_y = game.exit_y; } else { @@ -13441,8 +13448,8 @@ void RemovePlayer(struct PlayerInfo *player) game.GameOver = TRUE; } - ExitX = ZX = jx; - ExitY = ZY = jy; + game.exit_x = ZX = jx; + game.exit_y = ZY = jy; } void ExitPlayer(struct PlayerInfo *player) @@ -15236,8 +15243,6 @@ static ListNode *SaveEngineSnapshotBuffers(void) SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(ZX)); SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(ZY)); - SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(ExitX)); - SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(ExitY)); SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(FrameCounter)); SaveSnapshotBuffer(&buffers, ARGS_ADDRESS_AND_SIZEOF(TimeFrames)); diff --git a/src/game.h b/src/game.h index aed0ce04..bba270cd 100644 --- a/src/game.h +++ b/src/game.h @@ -204,6 +204,8 @@ struct GameInfo int players_still_needed; int friends_still_needed; + int exit_x, exit_y; + boolean all_players_gone; // values for the new EMC elements diff --git a/src/game_mm/mm_main.h b/src/game_mm/mm_main.h index d8c8c42d..94825661 100644 --- a/src/game_mm/mm_main.h +++ b/src/game_mm/mm_main.h @@ -234,7 +234,7 @@ extern int FfwdFrameDelay; extern int BX1, BY1, BX2, BY2; extern int SBX_Left, SBX_Right; extern int SBY_Upper, SBY_Lower; -extern int ZX, ZY, ExitX, ExitY; +extern int ZX, ZY; extern int TimeFrames, TimePlayed, TimeLeft; extern boolean SiebAktiv; extern int SiebCount; diff --git a/src/main.c b/src/main.c index 1d3a8059..1805b6e0 100644 --- a/src/main.c +++ b/src/main.c @@ -127,7 +127,6 @@ int BX2, BY2; int SBX_Left, SBX_Right; int SBY_Upper, SBY_Lower; int ZX, ZY; -int ExitX, ExitY; int TimeFrames, TimePlayed, TimeLeft, TapeTime; diff --git a/src/main.h b/src/main.h index f4a738bc..45d46969 100644 --- a/src/main.h +++ b/src/main.h @@ -3629,7 +3629,6 @@ extern int BX2, BY2; extern int SBX_Left, SBX_Right; extern int SBY_Upper, SBY_Lower; extern int ZX, ZY; -extern int ExitX, ExitY; extern int TimeFrames, TimePlayed, TimeLeft, TapeTime;