projects
/
rocksndiamonds.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
added using counter of players that still have to enter an exit
[rocksndiamonds.git]
/
src
/
game.c
diff --git
a/src/game.c
b/src/game.c
index 2cf0e9aa46a468e4eacf98bf528d34964359d322..e1522b58bb844136786b4113ee247df34506cfdb 100644
(file)
--- a/
src/game.c
+++ b/
src/game.c
@@
-1112,6
+1112,7
@@
void TestIfGoodThingGetsHitByBadThing(int, int, int);
void KillPlayer(struct PlayerInfo *);
void BuryPlayer(struct PlayerInfo *);
void RemovePlayer(struct PlayerInfo *);
void KillPlayer(struct PlayerInfo *);
void BuryPlayer(struct PlayerInfo *);
void RemovePlayer(struct PlayerInfo *);
+void ExitPlayer(struct PlayerInfo *);
static int getInvisibleActiveFromInvisibleElement(int);
static int getInvisibleFromInvisibleActiveElement(int);
static int getInvisibleActiveFromInvisibleElement(int);
static int getInvisibleFromInvisibleActiveElement(int);
@@
-3391,6
+3392,7
@@
void InitGame()
player->gems_still_needed = level.gems_needed;
player->sokobanfields_still_needed = 0;
player->lights_still_needed = 0;
player->gems_still_needed = level.gems_needed;
player->sokobanfields_still_needed = 0;
player->lights_still_needed = 0;
+ player->players_still_needed = 0;
player->friends_still_needed = 0;
for (j = 0; j < MAX_NUM_KEYS; j++)
player->friends_still_needed = 0;
for (j = 0; j < MAX_NUM_KEYS; j++)
@@
-3948,6
+3950,10
@@
void InitGame()
}
}
}
}
+ for (i = 0; i < MAX_PLAYERS; i++)
+ if (stored_player[i].active)
+ local_player->players_still_needed++;
+
/* when recording the game, store which players take part in the game */
if (tape.recording)
{
/* when recording the game, store which players take part in the game */
if (tape.recording)
{
@@
-4416,6
+4422,10
@@
void InitAmoebaNr(int x, int y)
static void PlayerWins(struct PlayerInfo *player)
{
static void PlayerWins(struct PlayerInfo *player)
{
+ if (level.game_engine_type == GAME_ENGINE_TYPE_RND &&
+ local_player->players_still_needed > 0)
+ return;
+
player->LevelSolved = TRUE;
player->GameOver = TRUE;
player->LevelSolved = TRUE;
player->GameOver = TRUE;
@@
-9775,7
+9785,10
@@
static void ExecuteCustomElementAction(int x, int y, int element, int page)
{
for (i = 0; i < MAX_PLAYERS; i++)
if (action_arg_player_bits & (1 << i))
{
for (i = 0; i < MAX_PLAYERS; i++)
if (action_arg_player_bits & (1 << i))
- PlayerWins(&stored_player[i]);
+ ExitPlayer(&stored_player[i]);
+
+ if (AllPlayersGone)
+ PlayerWins(local_player);
break;
}
break;
}
@@
-12641,12
+12654,12
@@
void ScrollPlayer(struct PlayerInfo *player, int mode)
Feld[jx][jy] == EL_SP_EXIT_OPEN ||
Feld[jx][jy] == EL_SP_EXIT_OPENING) /* <-- special case */
{
Feld[jx][jy] == EL_SP_EXIT_OPEN ||
Feld[jx][jy] == EL_SP_EXIT_OPENING) /* <-- special case */
{
- DrawPlayer(player); /* needed here only to cleanup last field */
- RemovePlayer(player);
+ ExitPlayer(player);
- if (local_player->friends_still_needed == 0 ||
- IS_SP_ELEMENT(Feld[jx][jy]))
- PlayerWins(player);
+ if ((local_player->friends_still_needed == 0 ||
+ IS_SP_ELEMENT(Feld[jx][jy])) &&
+ AllPlayersGone)
+ PlayerWins(local_player);
}
/* this breaks one level: "machine", level 000 */
}
/* this breaks one level: "machine", level 000 */
@@
-13402,6
+13415,14
@@
void RemovePlayer(struct PlayerInfo *player)
ExitY = ZY = jy;
}
ExitY = ZY = jy;
}
+void ExitPlayer(struct PlayerInfo *player)
+{
+ DrawPlayer(player); /* needed here only to cleanup last field */
+ RemovePlayer(player);
+
+ local_player->players_still_needed--;
+}
+
static void setFieldForSnapping(int x, int y, int element, int direction)
{
struct ElementInfo *ei = &element_info[element];
static void setFieldForSnapping(int x, int y, int element, int direction)
{
struct ElementInfo *ei = &element_info[element];
@@
-13947,6
+13968,8
@@
static int DigField(struct PlayerInfo *player,
if (local_player->sokobanfields_still_needed == 0 &&
(game.emulation == EMU_SOKOBAN || level.auto_exit_sokoban))
{
if (local_player->sokobanfields_still_needed == 0 &&
(game.emulation == EMU_SOKOBAN || level.auto_exit_sokoban))
{
+ local_player->players_still_needed = 0;
+
PlayerWins(player);
PlayLevelSound(x, y, SND_GAME_SOKOBAN_SOLVING);
PlayerWins(player);
PlayLevelSound(x, y, SND_GAME_SOKOBAN_SOLVING);