if (game_status == GAME_MODE_MAIN &&
(key == setup.shortcut.toggle_pause || key == KSYM_space))
{
- StartGameActions(options.network, setup.autorecord, level.random_seed);
+ StartGameActions(network.enabled, setup.autorecord, level.random_seed);
return;
}
}
#if defined(NETWORK_AVALIABLE)
- if (options.network)
+ if (network.enabled)
HandleNetworking();
#endif
if (game.use_block_last_field_bug)
player->block_delay_adjustment = (player->block_last_field ? -1 : 1);
- if (!options.network || player->connected_network)
+ if (!network.enabled || player->connected_network)
{
player->active = TRUE;
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++)
{
local_player = &stored_player[i];
}
- if (!options.network)
+ 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 (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) */
}
#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 */
}
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)
// 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;
CloseDoor(DOOR_CLOSE_1);
#if defined(NETWORK_AVALIABLE)
- if (options.network)
+ if (network.enabled)
SendToServer_StopPlaying(NETWORK_STOP_BY_PLAYER);
else
#endif
if (Request(message, REQ_ASK | REQ_STAY_CLOSED))
{
- StartGameActions(options.network, setup.autorecord, level.random_seed);
+ StartGameActions(network.enabled, setup.autorecord, level.random_seed);
}
else
{
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)
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
InitGlobalAnimations();
}
-void InitNetworkServer()
+void InitNetworkSettings()
{
- if (setup.network_mode)
- options.network = TRUE;
+ InitNetworkInfo(options.network || setup.network_mode,
+ FALSE,
+ options.serveronly,
+ options.server_host,
+ options.server_port);
+}
- if (!options.network)
+void InitNetworkServer()
+{
+ if (!network.enabled)
return;
#if defined(NETWORK_AVALIABLE)
- if (!ConnectToServer(options.server_host, options.server_port))
+ if (!ConnectToServer(network.server_host, network.server_port))
Error(ERR_EXIT, "cannot connect to network game server");
SendToServer_PlayerName(setup.player_name);
if (options.execute_command)
Execute_Command(options.execute_command);
- if (options.serveronly)
+ InitNetworkSettings();
+
+ if (network.serveronly)
{
#if defined(PLATFORM_UNIX)
- NetworkServer(options.server_port, options.serveronly);
+ NetworkServer(network.server_port, TRUE);
#else
Error(ERR_WARN, "networking only supported in Unix version");
#endif
/* ========================================================================= */
struct ProgramInfo program;
+struct NetworkInfo network;
struct OptionInfo options;
struct VideoSystemInfo video;
struct AudioSystemInfo audio;
program.headless = FALSE;
}
+void InitNetworkInfo(boolean enabled, boolean connected, boolean serveronly,
+ char *server_host, int server_port)
+{
+ network.enabled = enabled;
+ network.connected = connected;
+ network.serveronly = serveronly;
+
+ network.server_host = server_host;
+ network.server_port = server_port;
+}
+
void InitScoresInfo()
{
char *global_scores_dir = getPath2(getCommonDataDir(), SCORES_DIRECTORY);
boolean headless;
};
+struct NetworkInfo
+{
+ boolean enabled;
+ boolean connected;
+ boolean serveronly;
+
+ char *server_host;
+ int server_port;
+
+};
+
struct OptionInfo
{
char *server_host;
/* ========================================================================= */
extern struct ProgramInfo program;
+extern struct NetworkInfo network;
extern struct OptionInfo options;
extern struct VideoSystemInfo video;
extern struct AudioSystemInfo audio;
void InitProgramInfo(char *, char *, char *, char *, char *, char *, char *,
char *, int);
+void InitNetworkInfo(boolean, boolean, boolean, char *, int);
void InitScoresInfo();
void SetWindowTitle();
static void SendBufferToServer(int size)
{
- if (!options.network)
+ if (!network.enabled)
return;
realbuffer[0] = realbuffer[1] = realbuffer[2] = 0;
static void InitializeMainControls()
{
- boolean local_team_mode = (!options.network && setup.team_mode);
+ boolean local_team_mode = (!network.enabled && setup.team_mode);
int i;
/* set main control text values to dynamically determined values */
}
else if (pos == MAIN_CONTROL_GAME)
{
- StartGameActions(options.network, setup.autorecord, level.random_seed);
+ StartGameActions(network.enabled, setup.autorecord, level.random_seed);
}
else if (pos == MAIN_CONTROL_SETUP)
{
if (si->value == &setup.network_mode &&
setup.network_mode &&
- !options.network)
+ !network.enabled)
Request("Please restart game to enable network games!", REQ_CONFIRM);
}
static void TapeStartGameRecording()
{
- StartGameActions(options.network, TRUE, level.random_seed);
+ StartGameActions(network.enabled, TRUE, level.random_seed);
}
static void TapeAppendRecording()
static void TapeSingleStep()
{
- if (options.network)
+ if (network.enabled)
return;
if (!tape.pausing)
#if defined(NETWORK_AVALIABLE)
/* pause network game while waiting for request to answer */
- if (options.network &&
+ if (network.enabled &&
game_status == GAME_MODE_PLAYING &&
req_state & REQUEST_WAIT_FOR_INPUT)
SendToServer_PausePlaying();
#if defined(NETWORK_AVALIABLE)
/* continue network game after request */
- if (options.network &&
+ if (network.enabled &&
game_status == GAME_MODE_PLAYING &&
req_state & REQUEST_WAIT_FOR_INPUT)
SendToServer_ContinuePlaying();
#if defined(NETWORK_AVALIABLE)
/* pause network game while waiting for request to answer */
- if (options.network &&
+ if (network.enabled &&
game_status == GAME_MODE_PLAYING &&
req_state & REQUEST_WAIT_FOR_INPUT)
SendToServer_PausePlaying();
#if defined(NETWORK_AVALIABLE)
/* continue network game after request */
- if (options.network &&
+ if (network.enabled &&
game_status == GAME_MODE_PLAYING &&
req_state & REQUEST_WAIT_FOR_INPUT)
SendToServer_ContinuePlaying();