Added dedicated server option to start server menu.

Added switching between dedicated and normal mode in Qcommon_Frame() if the cvar dedicated is modified.
This commit is contained in:
Knightmare66 2021-02-21 22:05:20 -05:00
parent bcf678286b
commit 8d0e9fe406
6 changed files with 67 additions and 15 deletions

View file

@ -44,9 +44,11 @@ Changes as of v0.20 update 8:
- Now compresses .sav and .sv2 savegame files into .savz files. It will still read savegames from earlier
KMQ2 versions (with the same game DLL). This should improve load and save times in multi-level units.
- Renamed cvars hud_scale, hud_alpha, and hud_squeezedigits to scr_hudsize, scr_hudalpha, and scr_hudsqueezedigits.
- Added dedicated server option to start server menu.
- Added descriptions for most cvars.
- Added dumpcvars command to output a list of cvars with their descriptions to cvarlist.txt. Takes an optional wildcard. Usage:

View file

@ -1716,6 +1716,8 @@ void Qcommon_Init (int argc, char **argv)
if (dedicated->value)
Cmd_AddCommand ("quit", Com_Quit);
dedicated->modified = false; // make sure this starts false
Sys_Init ();
NET_Init ();
@ -1811,8 +1813,10 @@ void Qcommon_Frame (int msec)
}
}
if (fixedtime->value)
msec = fixedtime->value;
// if (fixedtime->value)
// msec = fixedtime->value;
if (fixedtime->integer)
msec = abs(fixedtime->integer);
else if (timescale->value)
{
msec *= timescale->value;
@ -1820,7 +1824,8 @@ void Qcommon_Frame (int msec)
msec = 1;
}
if (showtrace->value)
// if (showtrace->value)
if (showtrace->integer)
{
extern int c_traces, c_brush_traces;
extern int c_pointcontents;
@ -1840,21 +1845,49 @@ void Qcommon_Frame (int msec)
Cbuf_Execute ();
if (host_speeds->value)
// if (host_speeds->value)
if (host_speeds->integer)
time_before = Sys_Milliseconds ();
SV_Frame (msec);
if (host_speeds->value)
// switch to/from dedicated here
if (dedicated->modified)
{
// Com_Printf ("dedicated is %f\n", dedicated->value);
dedicated->modified = false;
if (!dedicated->integer)
{
// remove server quit command, to be replaced with client quit command
Cmd_RemoveCommand ("quit");
CL_Init ();
Sys_ShowConsole (false);
}
else
{
CL_Shutdown ();
// the above function call removes client quit command, replace it with server quit command
Cmd_AddCommand ("quit", Com_Quit);
Sys_ShowConsole (true);
}
}
// if (host_speeds->value)
if (host_speeds->integer)
time_between = Sys_Milliseconds ();
CL_Frame (msec);
if (host_speeds->value)
// if (host_speeds->value)
if (host_speeds->integer)
time_after = Sys_Milliseconds ();
if (host_speeds->value)
// if (host_speeds->value)
if (host_speeds->integer)
{
int all, sv, gm, cl, rf;

View file

@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// ui_download.c -- the autodownload options menu
// ui_mp_download.c -- the autodownload options menu
#include <ctype.h>
#ifdef _WIN32

View file

@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// ui_joinserver.c -- the join server menu
// ui_mp_joinserver.c -- the join server menu
#include <ctype.h>
#ifdef _WIN32

View file

@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// ui_playersetup.c -- the player setup menu
// ui_mp_playersetup.c -- the player setup menu
#include <ctype.h>
#ifdef _WIN32

View file

@ -20,7 +20,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
===========================================================================
*/
// ui_startserver.c -- the start server menu
// ui_mp_startserver.c -- the start server menu
#include <ctype.h>
#ifdef _WIN32
@ -47,6 +47,8 @@ static menufield_s s_maxclients_field;
static menufield_s s_hostname_field;
static menulist_s s_startmap_list;
menulist_s s_rules_box;
static menulist_s s_dedicated_box;
static menuaction_s s_startserver_back_action;
#if 0
@ -237,7 +239,7 @@ void M_StartServerActionFunc (void *self)
Cvar_SetValue ("gamerules", FS_RoguePath() ? ((s_rules_box.curvalue == 4) ? 2 : 0) : 0);
#if 1
UI_StartServer (startmap, false);
UI_StartServer (startmap, (s_dedicated_box.curvalue != 0));
#else
spot = NULL;
if (s_rules_box.curvalue == 1) // PGM
@ -277,6 +279,12 @@ void M_StartServerActionFunc (void *self)
void StartServer_MenuInit (void)
{
static const char *yesno_names[] =
{
"no",
"yes",
0
};
static const char *dm_coop_names[] =
{
"deathmatch",
@ -285,7 +293,6 @@ void StartServer_MenuInit (void)
"3Team CTF",
0
};
static const char *dm_coop_names_rogue[] =
{
"deathmatch",
@ -413,12 +420,21 @@ void StartServer_MenuInit (void)
Q_strncpyz (s_hostname_field.buffer, sizeof(s_hostname_field.buffer), Cvar_VariableString("hostname"));
s_hostname_field.cursor = (int)strlen( s_hostname_field.buffer );
s_dedicated_box.generic.type = MTYPE_SPINCONTROL;
s_dedicated_box.generic.textSize = MENU_FONT_SIZE;
s_dedicated_box.generic.name = "dedicated server";;
s_dedicated_box.generic.x = 0;
s_dedicated_box.generic.y = y += 2*MENU_FONT_SIZE;
s_dedicated_box.curvalue = 0; // always start off
s_dedicated_box.generic.statusbar = "makes the server faster, but you can't play on this computer";
s_dedicated_box.itemnames = yesno_names;
s_startserver_dmoptions_action.generic.type = MTYPE_ACTION;
s_startserver_dmoptions_action.generic.textSize = MENU_FONT_SIZE;
s_startserver_dmoptions_action.generic.name = " deathmatch flags";
s_startserver_dmoptions_action.generic.flags = QMF_LEFT_JUSTIFY;
s_startserver_dmoptions_action.generic.x = 24;
s_startserver_dmoptions_action.generic.y = y += 2.25*MENU_FONT_SIZE;
s_startserver_dmoptions_action.generic.y = y += 2*MENU_FONT_SIZE;
s_startserver_dmoptions_action.generic.statusbar = NULL;
s_startserver_dmoptions_action.generic.callback = DMOptionsFunc;
@ -444,6 +460,7 @@ void StartServer_MenuInit (void)
Menu_AddItem( &s_startserver_menu, &s_fraglimit_field );
Menu_AddItem( &s_startserver_menu, &s_maxclients_field );
Menu_AddItem( &s_startserver_menu, &s_hostname_field );
Menu_AddItem( &s_startserver_menu, &s_dedicated_box );
Menu_AddItem( &s_startserver_menu, &s_startserver_dmoptions_action );
Menu_AddItem( &s_startserver_menu, &s_startserver_start_action );
Menu_AddItem( &s_startserver_menu, &s_startserver_back_action );