From 6617f41db080196a0e0844c2fcf6e4f982e161b3 Mon Sep 17 00:00:00 2001 From: Simon Howard Date: Fri, 5 Apr 2013 19:42:26 +0000 Subject: Split D_InitNetGame() into two separate functions for startup. Subversion-branch: /branches/v2-branch Subversion-revision: 2582 --- src/heretic/d_net.c | 67 +++++++++++++++++++---------------------------------- 1 file changed, 24 insertions(+), 43 deletions(-) (limited to 'src/heretic') diff --git a/src/heretic/d_net.c b/src/heretic/d_net.c index 73a09ec6..3950b129 100644 --- a/src/heretic/d_net.c +++ b/src/heretic/d_net.c @@ -112,8 +112,7 @@ static loop_interface_t doom_loop_interface = { // Load game settings from the specified structure and // set global variables. -static void LoadGameSettings(net_gamesettings_t *settings, - net_connect_data_t *connect_data) +static void LoadGameSettings(net_gamesettings_t *settings) { unsigned int i; @@ -125,17 +124,9 @@ static void LoadGameSettings(net_gamesettings_t *settings, // TODO startloadgame = settings->loadgame; nomonsters = settings->nomonsters; respawnparm = settings->respawn_monsters; + consoleplayer = settings->consoleplayer; - if (!connect_data->drone) - { - consoleplayer = settings->consoleplayer; - } - else - { - consoleplayer = 0; - } - - for (i=0; inum_players; } @@ -144,8 +135,7 @@ static void LoadGameSettings(net_gamesettings_t *settings, // Save the game settings from global variables to the specified // game settings structure. -static void SaveGameSettings(net_gamesettings_t *settings, - net_connect_data_t *connect_data) +static void SaveGameSettings(net_gamesettings_t *settings) { // Fill in game settings structure with appropriate parameters // for the new game @@ -160,7 +150,10 @@ static void SaveGameSettings(net_gamesettings_t *settings, settings->respawn_monsters = respawnparm; settings->timelimit = 0; settings->lowres_turn = false; +} +static void InitConnectData(net_connect_data_t *connect_data) +{ connect_data->drone = false; connect_data->max_players = MAXPLAYERS; @@ -183,29 +176,6 @@ static void SaveGameSettings(net_gamesettings_t *settings, connect_data->is_freedoom = 0; } -void D_InitSinglePlayerGame(net_gamesettings_t *settings) -{ - // default values for single player - - settings->consoleplayer = 0; - settings->num_players = 1; - - netgame = false; - - //! - // @category net - // - // Start the game playing as though in a netgame with a single - // player. This can also be used to play back single player netgame - // demos. - // - - if (M_CheckParm("-solo-net") > 0) - { - netgame = true; - } -} - // // D_CheckNetGame // Works out player numbers among the net participants @@ -222,17 +192,28 @@ void D_CheckNetGame (void) I_AtExit(D_QuitNetGame, true); - SaveGameSettings(&settings, &connect_data); + InitConnectData(&connect_data); + netgame = D_InitNetGame(&connect_data); + + //! + // @category net + // + // Start the game playing as though in a netgame with a single + // player. This can also be used to play back single player netgame + // demos. + // - if (D_InitNetGame(&connect_data, &settings)) + if (M_CheckParm("-solo-net") > 0) { netgame = true; - autostart = true; } - else + + if (netgame) { - D_InitSinglePlayerGame(&settings); + autostart = true; } - LoadGameSettings(&settings, &connect_data); + SaveGameSettings(&settings); + D_StartNetGame(&settings); + LoadGameSettings(&settings); } -- cgit v1.2.3