diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/doom/d_net.c | 18 | ||||
-rw-r--r-- | src/doom/g_game.c | 15 | ||||
-rw-r--r-- | src/i_system.c | 6 | ||||
-rw-r--r-- | src/net_gui.c | 2 | ||||
-rw-r--r-- | src/net_query.c | 2 | ||||
-rw-r--r-- | src/net_server.c | 24 | ||||
-rw-r--r-- | src/setup/mainmenu.c | 5 | ||||
-rw-r--r-- | src/setup/multiplayer.c | 120 | ||||
-rw-r--r-- | src/setup/multiplayer.h | 1 | ||||
-rw-r--r-- | src/setup/txt_joybinput.c | 1 | ||||
-rw-r--r-- | src/setup/txt_keyinput.c | 1 | ||||
-rw-r--r-- | src/setup/txt_mouseinput.c | 1 |
12 files changed, 142 insertions, 54 deletions
diff --git a/src/doom/d_net.c b/src/doom/d_net.c index b307d97f..70359ebd 100644 --- a/src/doom/d_net.c +++ b/src/doom/d_net.c @@ -204,8 +204,8 @@ void NetUpdate (void) G_BuildTiccmd(&cmd); #ifdef FEATURE_MULTIPLAYER - - if (netgame && !demoplayback) + + if (net_client_connected) { NET_CL_SendTiccmd(&cmd, maketic); } @@ -460,6 +460,19 @@ void D_InitSinglePlayerGame(void) recvtic = 0; playeringame[0] = true; + + //! + // @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; + } } boolean D_InitNetGame(net_connect_data_t *connect_data, @@ -468,6 +481,7 @@ boolean D_InitNetGame(net_connect_data_t *connect_data, net_addr_t *addr = NULL; int i; + #ifdef FEATURE_MULTIPLAYER //! diff --git a/src/doom/g_game.c b/src/doom/g_game.c index 0aaf8ee7..5d30899d 100644 --- a/src/doom/g_game.c +++ b/src/doom/g_game.c @@ -2145,16 +2145,11 @@ void G_DoPlayDemo (void) for (i=0 ; i<MAXPLAYERS ; i++) playeringame[i] = *demo_p++; - //! - // @category demo - // - // Play back a demo recorded in a netgame with a single player. - // - - if (playeringame[1] || M_CheckParm("-netdemo") > 0) - { - netgame = true; - netdemo = true; + if (playeringame[1] || M_CheckParm("-solo-net") > 0 + || M_CheckParm("-netdemo") > 0) + { + netgame = true; + netdemo = true; } // don't spend a lot of time in loadlevel diff --git a/src/i_system.c b/src/i_system.c index cd8ddcee..18dfb415 100644 --- a/src/i_system.c +++ b/src/i_system.c @@ -327,9 +327,9 @@ void I_Error (char *error, ...) // Message first. va_start(argptr, error); - fprintf(stderr, "\nError: "); + //fprintf(stderr, "\nError: "); vfprintf(stderr, error, argptr); - fprintf(stderr, "\n"); + fprintf(stderr, "\n\n"); va_end(argptr); fflush(stderr); @@ -362,7 +362,7 @@ void I_Error (char *error, ...) msgbuf, strlen(msgbuf) + 1, wmsgbuf, sizeof(wmsgbuf)); - MessageBoxW(NULL, wmsgbuf, L"Error", MB_OK); + MessageBoxW(NULL, wmsgbuf, L"", MB_OK); } #endif diff --git a/src/net_gui.c b/src/net_gui.c index 7473c948..f2c4f1e5 100644 --- a/src/net_gui.c +++ b/src/net_gui.c @@ -287,7 +287,7 @@ void NET_WaitForStart(net_gamesettings_t *settings) if (!net_client_connected) { - I_Error("Disconnected from server"); + I_Error("Lost connection to server"); } TXT_Sleep(100); diff --git a/src/net_query.c b/src/net_query.c index 0c69c231..ae56dea6 100644 --- a/src/net_query.c +++ b/src/net_query.c @@ -39,7 +39,7 @@ // DNS address of the Internet master server. -#define MASTER_SERVER_ADDRESS "master.chocolate-doom.org" +#define MASTER_SERVER_ADDRESS "master.chocolate-doom.org:2342" // Time to wait for a response before declaring a timeout. diff --git a/src/net_server.c b/src/net_server.c index 3d5df135..f3c16c1b 100644 --- a/src/net_server.c +++ b/src/net_server.c @@ -70,6 +70,11 @@ typedef struct int last_send_time; char *name; + // Time that this client connected to the server. + // This is used to determine the controller (oldest client). + + unsigned int connect_time; + // Last time new gamedata was received from this client int last_gamedata_time; @@ -382,19 +387,29 @@ static void NET_SV_AdvanceWindow(void) static net_client_t *NET_SV_Controller(void) { + net_client_t *best; int i; - // first client in the list is the controller + // Find the oldest client (first to connect). + + best = NULL; for (i=0; i<MAXNETNODES; ++i) { - if (ClientConnected(&clients[i]) && !clients[i].drone) + // Can't be controller? + + if (!ClientConnected(&clients[i]) || clients[i].drone) { - return &clients[i]; + continue; + } + + if (best == NULL || clients[i].connect_time < best->connect_time) + { + best = &clients[i]; } } - return NULL; + return best; } // Given an address, find the corresponding client @@ -434,6 +449,7 @@ static void NET_SV_InitNewClient(net_client_t *client, char *player_name) { client->active = true; + client->connect_time = I_GetTimeMS(); NET_Conn_InitServer(&client->connection, addr); client->addr = addr; client->last_send_time = -1; diff --git a/src/setup/mainmenu.c b/src/setup/mainmenu.c index c3cb7db5..ffa174de 100644 --- a/src/setup/mainmenu.c +++ b/src/setup/mainmenu.c @@ -189,6 +189,7 @@ void MainMenu(void) { txt_window_t *window; txt_window_action_t *quit_action; + txt_window_action_t *warp_action; window = TXT_NewWindow("Main Menu"); @@ -230,8 +231,12 @@ void MainMenu(void) NULL); quit_action = TXT_NewWindowAction(KEY_ESCAPE, "Quit"); + warp_action = TXT_NewWindowAction(KEY_F1, "Warp"); TXT_SignalConnect(quit_action, "pressed", QuitConfirm, NULL); + TXT_SignalConnect(warp_action, "pressed", + (TxtWidgetSignalFunc) WarpMenu, NULL); TXT_SetWindowAction(window, TXT_HORIZ_LEFT, quit_action); + TXT_SetWindowAction(window, TXT_HORIZ_CENTER, warp_action); TXT_SetKeyListener(window, MainMenuKeyPress, NULL); } diff --git a/src/setup/multiplayer.c b/src/setup/multiplayer.c index 24cd0670..0d88221f 100644 --- a/src/setup/multiplayer.c +++ b/src/setup/multiplayer.c @@ -209,7 +209,11 @@ static void AddIWADParameter(execute_context_t *exec) } } -static void StartGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(user_data)) +// Callback function invoked to launch the game. +// This is used when starting a server and also when starting a +// single player game via the "warp" menu. + +static void StartGame(int multiplayer) { execute_context_t *exec; @@ -221,7 +225,6 @@ static void StartGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(user_data)) AddExtraParameters(exec); AddIWADParameter(exec); - AddCmdLineParameter(exec, "-server"); AddCmdLineParameter(exec, "-skill %i", skill + 1); if (gamemission == hexen) @@ -244,20 +247,6 @@ static void StartGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(user_data)) AddCmdLineParameter(exec, "-respawn"); } - if (deathmatch == 1) - { - AddCmdLineParameter(exec, "-deathmatch"); - } - else if (deathmatch == 2) - { - AddCmdLineParameter(exec, "-altdeath"); - } - - if (timer > 0) - { - AddCmdLineParameter(exec, "-timer %i", timer); - } - if (warptype == WARP_ExMy) { // TODO: select IWAD based on warp type @@ -268,7 +257,27 @@ static void StartGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(user_data)) AddCmdLineParameter(exec, "-warp %i", warpmap); } - AddCmdLineParameter(exec, "-port %i", udpport); + // Multiplayer-specific options: + + if (multiplayer) + { + AddCmdLineParameter(exec, "-server"); + AddCmdLineParameter(exec, "-port %i", udpport); + + if (deathmatch == 1) + { + AddCmdLineParameter(exec, "-deathmatch"); + } + else if (deathmatch == 2) + { + AddCmdLineParameter(exec, "-altdeath"); + } + + if (timer > 0) + { + AddCmdLineParameter(exec, "-timer %i", timer); + } + } AddWADs(exec); @@ -282,6 +291,16 @@ static void StartGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(user_data)) exit(0); } +static void StartServerGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) +{ + StartGame(1); +} + +static void StartSinglePlayerGame(TXT_UNCAST_ARG(widget), TXT_UNCAST_ARG(unused)) +{ + StartGame(0); +} + static void UpdateWarpButton(void) { char buf[10]; @@ -544,12 +563,27 @@ static txt_widget_t *IWADSelector(void) return result; } -static txt_window_action_t *StartGameAction(void) +// Create the window action button to start the game. This invokes +// a different callback depending on whether to start a multiplayer +// or single player game. + +static txt_window_action_t *StartGameAction(int multiplayer) { txt_window_action_t *action; + TxtWidgetSignalFunc callback; action = TXT_NewWindowAction(KEY_F10, "Start"); - TXT_SignalConnect(action, "pressed", StartGame, NULL); + + if (multiplayer) + { + callback = StartServerGame; + } + else + { + callback = StartSinglePlayerGame; + } + + TXT_SignalConnect(action, "pressed", callback, NULL); return action; } @@ -591,7 +625,11 @@ static txt_window_action_t *WadWindowAction(void) return action; } -void StartMultiGame(void) +// "Start game" menu. This is used for the start server window +// and the single player warp menu. The parameters specify +// the window title and whether to display multiplayer options. + +static void StartGameMenu(char *window_title, int multiplayer) { txt_window_t *window; txt_table_t *gameopt_table; @@ -599,7 +637,7 @@ void StartMultiGame(void) txt_widget_t *iwad_selector; int num_mult_types = 2; - window = TXT_NewWindow("Start multiplayer game"); + window = TXT_NewWindow(window_title); TXT_AddWidgets(window, gameopt_table = TXT_NewTable(2), @@ -614,7 +652,7 @@ void StartMultiGame(void) NULL); TXT_SetWindowAction(window, TXT_HORIZ_CENTER, WadWindowAction()); - TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, StartGameAction()); + TXT_SetWindowAction(window, TXT_HORIZ_RIGHT, StartGameAction(multiplayer)); TXT_SetColumnWidths(gameopt_table, 12, 12); @@ -632,14 +670,8 @@ void StartMultiGame(void) iwad_selector = IWADSelector(), TXT_NewLabel("Skill"), skillbutton = TXT_NewDropdownList(&skill, doom_skills, 5), - TXT_NewLabel("Game type"), - TXT_NewDropdownList(&deathmatch, gamemodes, num_mult_types), TXT_NewLabel("Level warp"), warpbutton = TXT_NewButton2("????", LevelSelectDialog, NULL), - TXT_NewLabel("Time limit"), - TXT_NewHorizBox(TXT_NewIntInputBox(&timer, 2), - TXT_NewLabel("minutes"), - NULL), NULL); if (gamemission == hexen) @@ -651,19 +683,41 @@ void StartMultiGame(void) NULL); } + if (multiplayer) + { + TXT_AddWidgets(gameopt_table, + TXT_NewLabel("Game type"), + TXT_NewDropdownList(&deathmatch, gamemodes, num_mult_types), + TXT_NewLabel("Time limit"), + TXT_NewHorizBox(TXT_NewIntInputBox(&timer, 2), + TXT_NewLabel("minutes"), + NULL), + NULL); + + TXT_AddWidgets(advanced_table, + TXT_NewLabel("UDP port"), + TXT_NewIntInputBox(&udpport, 5), + NULL); + } + TXT_SetColumnWidths(advanced_table, 12, 12); TXT_SignalConnect(iwad_selector, "changed", UpdateWarpType, NULL); - TXT_AddWidgets(advanced_table, - TXT_NewLabel("UDP port"), - TXT_NewIntInputBox(&udpport, 5), - NULL); - UpdateWarpType(NULL, NULL); UpdateWarpButton(); } +void StartMultiGame(void) +{ + StartGameMenu("Start multiplayer game", 1); +} + +void WarpMenu(void) +{ + StartGameMenu("Level Warp", 0); +} + static void DoJoinGame(void *unused1, void *unused2) { execute_context_t *exec; diff --git a/src/setup/multiplayer.h b/src/setup/multiplayer.h index 7490bc3c..afc8a2a8 100644 --- a/src/setup/multiplayer.h +++ b/src/setup/multiplayer.h @@ -23,6 +23,7 @@ #define SETUP_MULTIPLAYER_H void StartMultiGame(void); +void WarpMenu(void); void JoinMultiGame(void); void MultiplayerConfig(void); diff --git a/src/setup/txt_joybinput.c b/src/setup/txt_joybinput.c index 1e132962..cde3d2c2 100644 --- a/src/setup/txt_joybinput.c +++ b/src/setup/txt_joybinput.c @@ -206,6 +206,7 @@ static void TXT_JoystickInputMousePress(TXT_UNCAST_ARG(widget), int x, int y, in txt_widget_class_t txt_joystick_input_class = { + TXT_AlwaysSelectable, TXT_JoystickInputSizeCalc, TXT_JoystickInputDrawer, TXT_JoystickInputKeyPress, diff --git a/src/setup/txt_keyinput.c b/src/setup/txt_keyinput.c index 483c325f..08eb9d8c 100644 --- a/src/setup/txt_keyinput.c +++ b/src/setup/txt_keyinput.c @@ -171,6 +171,7 @@ static void TXT_KeyInputMousePress(TXT_UNCAST_ARG(widget), int x, int y, int b) txt_widget_class_t txt_key_input_class = { + TXT_AlwaysSelectable, TXT_KeyInputSizeCalc, TXT_KeyInputDrawer, TXT_KeyInputKeyPress, diff --git a/src/setup/txt_mouseinput.c b/src/setup/txt_mouseinput.c index 8b87e651..4f454c8c 100644 --- a/src/setup/txt_mouseinput.c +++ b/src/setup/txt_mouseinput.c @@ -164,6 +164,7 @@ static void TXT_MouseInputMousePress(TXT_UNCAST_ARG(widget), int x, int y, int b txt_widget_class_t txt_mouse_input_class = { + TXT_AlwaysSelectable, TXT_MouseInputSizeCalc, TXT_MouseInputDrawer, TXT_MouseInputKeyPress, |