void Bang(int, int);
void InitMovDir(int, int);
void InitAmoebaNr(int, int);
-int NewHiScore(void);
+int NewHiScore(int);
void TestIfGoodThingHitsBadThing(int, int, int);
void TestIfBadThingHitsGoodThing(int, int, int);
if (game.use_block_last_field_bug)
player->block_delay_adjustment = (player->block_last_field ? -1 : 1);
- if (!options.network || player->connected)
+ if (!network.enabled || player->connected_network)
{
player->active = TRUE;
game_panel_controls[GAME_PANEL_TIME_MM].value = (time / 60) % 60;
game_panel_controls[GAME_PANEL_TIME_SS].value = time % 60;
- if (game.no_time_limit)
+ if (level.time == 0)
game_panel_controls[GAME_PANEL_TIME_ANIM].value = 100;
else
game_panel_controls[GAME_PANEL_TIME_ANIM].value = time * 100 / level.time;
=============================================================================
*/
+#if DEBUG_INIT_PLAYER
+static void DebugPrintPlayerStatus(char *message)
+{
+ int i;
+
+ if (!options.debug)
+ return;
+
+ printf("%s:\n", message);
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ {
+ struct PlayerInfo *player = &stored_player[i];
+
+ printf("- player %d: present == %d, connected == %d [%d/%d], active == %d",
+ i + 1,
+ player->present,
+ player->connected,
+ player->connected_locally,
+ player->connected_network,
+ player->active);
+
+ if (local_player == player)
+ printf(" (local player)");
+
+ printf("\n");
+ }
+}
+#endif
+
void InitGame()
{
int full_lev_fieldx = lev_fieldx + (BorderElement != EL_EMPTY ? 2 : 0);
else
FadeSetEnterScreen();
- if (CheckIfGlobalBorderHasChanged())
+ if (CheckIfGlobalBorderOrPlayfieldViewportHasChanged())
fade_mask = REDRAW_ALL;
FadeLevelSoundsAndMusic();
ExpireSoundLoops(TRUE);
- FadeOut(fade_mask);
+ if (!level_editor_test_game)
+ FadeOut(fade_mask);
/* needed if different viewport properties defined for playing */
ChangeViewportPropertiesIfNeeded();
ClearField();
- OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
-
DrawCompleteVideoDisplay();
+ OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+
InitGameEngine();
InitGameControlValues();
/* don't play tapes over network */
- network_playing = (options.network && !tape.playing);
+ network_playing = (network.enabled && !tape.playing);
for (i = 0; i < MAX_PLAYERS; i++)
{
player->mouse_action.lx = 0;
player->mouse_action.ly = 0;
player->mouse_action.button = 0;
+ player->mouse_action.button_hint = 0;
player->effective_mouse_action.lx = 0;
player->effective_mouse_action.ly = 0;
player->effective_mouse_action.button = 0;
+ player->effective_mouse_action.button_hint = 0;
player->score = 0;
player->score_final = 0;
network_player_action_received = FALSE;
-#if defined(NETWORK_AVALIABLE)
/* initial null action */
if (network_playing)
SendToServer_MovePlayer(MV_NONE);
-#endif
ZX = ZY = -1;
ExitX = ExitY = -1;
game.envelope_active = FALSE;
- /* set focus to local player for network games, else to all players */
- game.centered_player_nr = (network_playing ? local_player->index_nr : -1);
- game.centered_player_nr_next = game.centered_player_nr;
- game.set_centered_player = FALSE;
-
- if (network_playing && tape.recording)
- {
- /* store client dependent player focus when recording network games */
- tape.centered_player_nr_next = game.centered_player_nr_next;
- tape.set_centered_player = TRUE;
- }
-
for (i = 0; i < NUM_BELTS; i++)
{
game.belt_dir[i] = MV_NONE;
AmoebaCnt[i] = AmoebaCnt2[i] = 0;
#if DEBUG_INIT_PLAYER
- if (options.debug)
- {
- printf("Player status at level initialization:\n");
- }
+ DebugPrintPlayerStatus("Player status at level initialization");
#endif
SCAN_PLAYFIELD(x, y)
game.belt_dir_nr[i] = 3; /* not moving, next moving left */
#if USE_NEW_PLAYER_ASSIGNMENTS
- /* !!! SAME AS init.c:InitPlayerInfo() -- FIX THIS !!! */
- /* choose default local player */
- local_player = &stored_player[0];
-
for (i = 0; i < MAX_PLAYERS; i++)
+ {
stored_player[i].connected = FALSE;
- local_player->connected = TRUE;
- /* !!! SAME AS init.c:InitPlayerInfo() -- FIX THIS !!! */
+ /* in network game mode, the local player might not be the first player */
+ if (stored_player[i].connected_locally)
+ local_player = &stored_player[i];
+ }
+
+ if (!network.enabled)
+ local_player->connected = TRUE;
if (tape.playing)
{
for (i = 0; i < MAX_PLAYERS; i++)
stored_player[i].connected = tape.player_participates[i];
}
- else if (game.team_mode && !options.network)
+ else if (network.enabled)
+ {
+ /* add team mode players connected over the network (needed for correct
+ assignment of player figures from level to locally playing players) */
+
+ for (i = 0; i < MAX_PLAYERS; i++)
+ if (stored_player[i].connected_network)
+ stored_player[i].connected = TRUE;
+ }
+ else if (game.team_mode)
{
/* try to guess locally connected team mode players (needed for correct
assignment of player figures from level to locally playing players) */
}
#if DEBUG_INIT_PLAYER
- if (options.debug)
- {
- printf("Player status after level initialization:\n");
-
- for (i = 0; i < MAX_PLAYERS; i++)
- {
- struct PlayerInfo *player = &stored_player[i];
-
- printf("- player %d: present == %d, connected == %d, active == %d",
- i + 1,
- player->present,
- player->connected,
- player->active);
-
- if (local_player == player)
- printf(" (local player)");
-
- printf("\n");
- }
- }
+ DebugPrintPlayerStatus("Player status after level initialization");
#endif
#if DEBUG_INIT_PLAYER
}
#if DEBUG_INIT_PLAYER
- if (options.debug)
- {
- printf("Player status after player assignment (first stage):\n");
-
- for (i = 0; i < MAX_PLAYERS; i++)
- {
- struct PlayerInfo *player = &stored_player[i];
-
- printf("- player %d: present == %d, connected == %d, active == %d",
- i + 1,
- player->present,
- player->connected,
- player->active);
-
- if (local_player == player)
- printf(" (local player)");
-
- printf("\n");
- }
- }
+ DebugPrintPlayerStatus("Player status after player assignment (first stage)");
#endif
#else
printf("::: local_player->present == %d\n", local_player->present);
#endif
+ /* set focus to local player for network games, else to all players */
+ game.centered_player_nr = (network_playing ? local_player->index_nr : -1);
+ game.centered_player_nr_next = game.centered_player_nr;
+ game.set_centered_player = FALSE;
+
+ if (network_playing && tape.recording)
+ {
+ /* store client dependent player focus when recording network games */
+ tape.centered_player_nr_next = game.centered_player_nr_next;
+ tape.set_centered_player = TRUE;
+ }
+
if (tape.playing)
{
/* when playing a tape, eliminate all players who do not participate */
}
#endif
}
- else if (!options.network && !game.team_mode) /* && !tape.playing */
+ else if (!network.enabled && !game.team_mode) /* && !tape.playing */
{
- /* when in single player mode, eliminate all but the first active player */
+ /* when in single player mode, eliminate all but the local player */
for (i = 0; i < MAX_PLAYERS; i++)
{
- if (stored_player[i].active)
+ struct PlayerInfo *player = &stored_player[i];
+
+ if (player->active && player != local_player)
{
- for (j = i + 1; j < MAX_PLAYERS; j++)
- {
- if (stored_player[j].active)
- {
- struct PlayerInfo *player = &stored_player[j];
- int jx = player->jx, jy = player->jy;
+ int jx = player->jx, jy = player->jy;
- player->active = FALSE;
- player->present = FALSE;
+ player->active = FALSE;
+ player->present = FALSE;
- StorePlayer[jx][jy] = 0;
- Feld[jx][jy] = EL_EMPTY;
- }
- }
+ StorePlayer[jx][jy] = 0;
+ Feld[jx][jy] = EL_EMPTY;
}
}
}
}
#if DEBUG_INIT_PLAYER
- if (options.debug)
- {
- printf("Player status after player assignment (final stage):\n");
-
- for (i = 0; i < MAX_PLAYERS; i++)
- {
- struct PlayerInfo *player = &stored_player[i];
-
- printf("- player %d: present == %d, connected == %d, active == %d",
- i + 1,
- player->present,
- player->connected,
- player->active);
-
- if (local_player == player)
- printf(" (local player)");
-
- printf("\n");
- }
- }
+ DebugPrintPlayerStatus("Player status after player assignment (final stage)");
#endif
if (BorderElement == EL_EMPTY)
OpenDoor(DOOR_OPEN_ALL);
- PlaySound(SND_GAME_STARTING);
-
- if (setup.sound_music)
- PlayLevelMusic();
-
KeyboardAutoRepeatOffUnlessAutoplay();
#if DEBUG_INIT_PLAYER
- if (options.debug)
- {
- printf("Player status (final):\n");
-
- for (i = 0; i < MAX_PLAYERS; i++)
- {
- struct PlayerInfo *player = &stored_player[i];
-
- printf("- player %d: present == %d, connected == %d, active == %d",
- i + 1,
- player->present,
- player->connected,
- player->active);
-
- if (local_player == player)
- printf(" (local player)");
-
- printf("\n");
- }
- }
+ DebugPrintPlayerStatus("Player status (final)");
#endif
}
}
game.restart_level = FALSE;
+ game.restart_game_message = NULL;
if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
InitGameActions_MM();
SaveEngineSnapshotToListInitial();
+
+ if (!game.restart_level)
+ {
+ PlaySound(SND_GAME_STARTING);
+
+ if (setup.sound_music)
+ PlayLevelMusic();
+ }
}
void UpdateEngineValues(int actual_scroll_x, int actual_scroll_y,
local_player->LevelSolved_GameEnd = TRUE;
- if (!global.use_envelope_request)
- CloseDoor(DOOR_CLOSE_1);
-
if (local_player->LevelSolved_SaveTape)
{
- SaveTapeChecked(tape.level_nr); /* ask to save tape */
+ /* make sure that request dialog to save tape does not open door again */
+ if (!global.use_envelope_request)
+ CloseDoor(DOOR_CLOSE_1);
+
+ SaveTapeChecked_LevelSolved(tape.level_nr); /* ask to save tape */
}
+ /* if no tape is to be saved, close both doors simultaneously */
CloseDoor(DOOR_CLOSE_ALL);
if (level_editor_test_game)
level_nr < leveldir_current->last_level)
raise_level = TRUE; /* advance to next level */
- if ((hi_pos = NewHiScore()) >= 0)
+ if ((hi_pos = NewHiScore(level_nr)) >= 0)
{
SetGameStatus(GAME_MODE_SCORES);
- DrawHallOfFame(hi_pos);
+ DrawHallOfFame(level_nr, hi_pos);
if (raise_level)
{
}
}
-int NewHiScore()
+int NewHiScore(int level_nr)
{
int k, l;
int position = -1;
if (record_tape)
TapeStartRecording(new_random_seed);
-#if defined(NETWORK_AVALIABLE)
if (init_network_game)
{
SendToServer_StartPlaying();
return;
}
-#endif
InitGame();
}
}
if (game.restart_level)
- StartGameActions(options.network, setup.autorecord, level.random_seed);
+ StartGameActions(network.enabled, setup.autorecord, level.random_seed);
/* !!! SAME CODE AS IN "CheckLevelTime()" -- FIX THIS !!! */
if (level.game_engine_type == GAME_ENGINE_TYPE_EM)
{
/* try to get network player actions in time */
-#if defined(NETWORK_AVALIABLE)
/* last chance to get network player actions without main loop delay */
HandleNetworking();
-#endif
/* game was quit by network peer */
if (game_status != GAME_MODE_PLAYING)
stored_player[i].effective_action = stored_player[i].action;
}
-#if defined(NETWORK_AVALIABLE)
if (network_playing)
SendToServer_MovePlayer(summarized_player_action);
-#endif
// summarize all actions at local players mapped input device position
// (this allows using different input devices in single player mode)
- if (!options.network && !game.team_mode)
+ if (!network.enabled && !game.team_mode)
stored_player[map_player_action[local_player->index_nr]].effective_action =
summarized_player_action;
}
}
- if (!options.network && game.centered_player_nr == -1 &&
+ if (!network.enabled && game.centered_player_nr == -1 &&
!AllPlayersInSight(player, new_jx, new_jy))
return MP_NO_ACTION;
if (scroll_x != old_scroll_x || scroll_y != old_scroll_y)
{
- if (!options.network && game.centered_player_nr == -1 &&
+ if (!network.enabled && game.centered_player_nr == -1 &&
!AllPlayersInVisibleScreen())
{
scroll_x = old_scroll_x;
if (!skip_request)
CloseDoor(DOOR_CLOSE_1);
-#if defined(NETWORK_AVALIABLE)
- if (options.network)
+ if (network.enabled)
SendToServer_StopPlaying(NETWORK_STOP_BY_PLAYER);
else
-#endif
{
if (quick_quit)
FadeSkipNextFadeIn();
"Do you really want to quit the game?");
}
+void RequestRestartGame(char *message)
+{
+ game.restart_game_message = NULL;
+
+ if (Request(message, REQ_ASK | REQ_STAY_CLOSED))
+ {
+ StartGameActions(network.enabled, setup.autorecord, level.random_seed);
+ }
+ else
+ {
+ SetGameStatus(GAME_MODE_MAIN);
+
+ DrawMainMenu();
+ }
+}
+
/* ------------------------------------------------------------------------- */
/* random generator functions */
LoadEngineSnapshotValues_EM();
if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
LoadEngineSnapshotValues_SP();
- if (level.game_engine_type == GAME_ENGINE_TYPE_SP)
+ if (level.game_engine_type == GAME_ENGINE_TYPE_MM)
LoadEngineSnapshotValues_MM();
}
for (i = 0; i < NUM_GAME_BUTTONS; i++)
{
- struct GraphicInfo *gfx = &graphic_info[gamebutton_info[i].graphic];
+ int graphic = gamebutton_info[i].graphic;
+ struct GraphicInfo *gfx = &graphic_info[graphic];
struct XY *pos = gamebutton_info[i].pos;
struct GadgetInfo *gi;
int button_type;
}
gi = CreateGadget(GDI_CUSTOM_ID, id,
+ GDI_IMAGE_ID, graphic,
GDI_INFO_TEXT, gamebutton_info[i].infotext,
GDI_X, base_x + GDI_ACTIVE_POS(pos->x),
GDI_Y, base_y + GDI_ACTIVE_POS(pos->y),
case GAME_CTRL_ID_PAUSE:
case GAME_CTRL_ID_PAUSE2:
case GAME_CTRL_ID_PANEL_PAUSE:
- if (options.network && game_status == GAME_MODE_PLAYING)
+ if (network.enabled && game_status == GAME_MODE_PLAYING)
{
-#if defined(NETWORK_AVALIABLE)
if (tape.pausing)
SendToServer_ContinuePlaying();
else
SendToServer_PausePlaying();
-#endif
}
else
TapeTogglePause(TAPE_TOGGLE_MANUAL);
case GAME_CTRL_ID_PANEL_PLAY:
if (game_status == GAME_MODE_MAIN)
{
- StartGameActions(options.network, setup.autorecord, level.random_seed);
+ StartGameActions(network.enabled, setup.autorecord, level.random_seed);
}
else if (tape.pausing)
{
-#if defined(NETWORK_AVALIABLE)
- if (options.network)
+ if (network.enabled)
SendToServer_ContinuePlaying();
else
-#endif
TapeTogglePause(TAPE_TOGGLE_MANUAL | TAPE_TOGGLE_PLAY_PAUSE);
}
break;