ref: f1bde3d5212cab46aa9f40bec29e8a72013f8a41
parent: d3cd96a9dc73d4b261757a34bf1e3c59b48ddf19
author: Simon Howard <[email protected]>
date: Fri Apr 5 17:01:45 EDT 2013
Use two-stage startup for Hexen, and add netgame startup callback for the spinal loading screen. Subversion-branch: /branches/v2-branch Subversion-revision: 2585
--- a/src/d_loop.c
+++ b/src/d_loop.c
@@ -313,7 +313,8 @@
// Block until the game start message is received from the server.
//
-void D_BlockUntilStart(net_gamesettings_t *settings)
+static void BlockUntilStart(net_gamesettings_t *settings,
+ netgame_startup_callback_t callback)
{
while (!NET_CL_GetSettings(settings))
{
@@ -324,10 +325,17 @@
{
I_Error("Lost connection to server");
}
+
+ if (callback != NULL && !callback(net_client_wait_data.ready_players,
+ net_client_wait_data.num_players))
+ {
+ I_Error("Netgame startup aborted.");
+ }
}
}
-void D_StartNetGame(net_gamesettings_t *settings)
+void D_StartNetGame(net_gamesettings_t *settings,
+ netgame_startup_callback_t callback)
{
int i;
@@ -384,7 +392,7 @@
// from the server.
NET_CL_StartGame(settings);
- D_BlockUntilStart(settings);
+ BlockUntilStart(settings, callback);
// Read the game settings that were received.
--- a/src/d_loop.h
+++ b/src/d_loop.h
@@ -29,6 +29,13 @@
#include "net_defs.h"
+// Callback function invoked while waiting for the netgame to start.
+// The callback is invoked when new players are ready. The callback
+// should return true, or return false to abort startup.
+
+typedef boolean (*netgame_startup_callback_t)(int ready_players,
+ int num_players);
+
typedef struct
{
// Read events from the event queue, and process them.
@@ -72,7 +79,8 @@
// Start game with specified settings. The structure will be updated
// with the actual settings for the game.
-void D_StartNetGame(net_gamesettings_t *settings);
+void D_StartNetGame(net_gamesettings_t *settings,
+ netgame_startup_callback_t callback);
extern boolean singletics;
extern int gametic, ticdup;
--- a/src/doom/d_net.c
+++ b/src/doom/d_net.c
@@ -253,7 +253,7 @@
D_RegisterLoopCallbacks(&doom_loop_interface);
SaveGameSettings(&settings);
- D_StartNetGame(&settings);
+ D_StartNetGame(&settings, NULL);
LoadGameSettings(&settings);
DEH_printf("startskill %i deathmatch: %i startmap: %i startepisode: %i\n",
--- a/src/heretic/d_net.c
+++ b/src/heretic/d_net.c
@@ -214,7 +214,7 @@
}
SaveGameSettings(&settings);
- D_StartNetGame(&settings);
+ D_StartNetGame(&settings, NULL);
LoadGameSettings(&settings);
}
--- a/src/hexen/d_net.c
+++ b/src/hexen/d_net.c
@@ -206,18 +206,10 @@
connect_data->is_freedoom = 0;
}
-//
-// D_CheckNetGame
-// Works out player numbers among the net participants
-//
-
-void D_CheckNetGame (void)
+void D_ConnectNetGame(void)
{
net_connect_data_t connect_data;
- net_gamesettings_t settings;
- D_RegisterLoopCallbacks(&hexen_loop_interface);
-
InitConnectData(&connect_data);
netgame = D_InitNetGame(&connect_data);
@@ -233,7 +225,34 @@
{
netgame = true;
}
+}
+static boolean StartupProgress(int now_ready, int total)
+{
+ static int ready = 0;
+
+ while (ready < now_ready)
+ {
+ ST_NetProgress();
+ ++ready;
+ }
+
+ ready = now_ready;
+
+ return true;
+}
+
+//
+// D_CheckNetGame
+// Works out player numbers among the net participants
+//
+
+void D_CheckNetGame(void)
+{
+ net_gamesettings_t settings;
+
+ D_RegisterLoopCallbacks(&hexen_loop_interface);
+
if (netgame)
{
autostart = true;
@@ -240,8 +259,16 @@
}
SaveGameSettings(&settings);
- D_StartNetGame(&settings);
+ D_StartNetGame(&settings, StartupProgress);
LoadGameSettings(&settings);
+
+ // Finish netgame progress on startup screen.
+
+ if (netgame)
+ {
+ StartupProgress(settings.num_players, settings.num_players);
+ ST_NetDone();
+ }
}
//==========================================================================
--- a/src/hexen/h2_main.c
+++ b/src/hexen/h2_main.c
@@ -76,6 +76,7 @@
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void R_ExecuteSetViewSize(void);
+void D_ConnectNetGame(void);
void D_CheckNetGame(void);
boolean F_Responder(event_t * ev);
void I_StartupKeyboard(void);
@@ -331,11 +332,6 @@
ST_Message("MN_Init: Init menu system.\n");
MN_Init();
-#ifdef FEATURE_MULTIPLAYER
- ST_Message("NET_Init: Init networking subsystem.\n");
- NET_Init();
-#endif
-
ST_Message("CT_Init: Init chat mode data.\n");
CT_Init();
@@ -351,6 +347,12 @@
I_InitTimer();
I_InitJoystick();
+#ifdef FEATURE_MULTIPLAYER
+ ST_Message("NET_Init: Init networking subsystem.\n");
+ NET_Init();
+#endif
+ D_ConnectNetGame();
+
S_Init();
S_Start();
@@ -372,16 +374,13 @@
// MAPINFO.TXT script must be already processed.
WarpCheck();
- ST_Done();
-
- // Netgame start must be here, after the splash screen has finished.
ST_Message("D_CheckNetGame: Checking network game status.\n");
D_CheckNetGame();
- // SB_Init has been moved here; the status bar must be initialized
- // *after* the netgame has started.
ST_Message("SB_Init: Loading patches.\n");
SB_Init();
+
+ ST_Done();
if (autostart)
{
--- a/src/strife/d_net.c
+++ b/src/strife/d_net.c
@@ -253,7 +253,7 @@
}
SaveGameSettings(&settings);
- D_StartNetGame(&settings);
+ D_StartNetGame(&settings, NULL);
LoadGameSettings(&settings);
// Strife games are always deathmatch, though -altdeath is