Skip to content

Commit 816e6a6

Browse files
committed
Migrate cvar sv_running
We need to be careful with this one: I changed the type to bool, but the string representation must still be "0"/"1" for gamelogic compat.
1 parent 0b611af commit 816e6a6

File tree

10 files changed

+22
-23
lines changed

10 files changed

+22
-23
lines changed

src/engine/client/cl_cgame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ void CL_AdjustTimeDelta()
694694
// if the current time is WAY off, just correct to the current value
695695

696696
/*
697-
if(com_sv_running->integer)
697+
if(com_sv_running.Get())
698698
{
699699
resetTime = 100;
700700
}

src/engine/client/cl_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,7 +689,7 @@ void CL_ShutdownAll()
689689
// Gordon: stop recording on map change etc, demos aren't valid over map changes anyway
690690
CL_StopRecord();
691691

692-
if ( !com_sv_running->integer )
692+
if ( !com_sv_running.Get() )
693693
{
694694
void SV_ShutdownGameProgs();
695695
SV_ShutdownGameProgs();
@@ -1014,7 +1014,7 @@ void CL_Connect_f()
10141014
// clear any previous "server full" type messages
10151015
clc.serverMessage[ 0 ] = 0;
10161016

1017-
if ( com_sv_running->integer && !strcmp( server, "loopback" ) )
1017+
if ( com_sv_running.Get() && !strcmp( server, "loopback" ) )
10181018
{
10191019
// if running a local server, kill it
10201020
SV_Shutdown( "Server quit" );

src/engine/client/cl_parse.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ void CL_SystemInfoChanged()
352352
cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) );
353353

354354
// load paks sent by the server, but not if we are running a local server
355-
if (!com_sv_running->integer) {
355+
if (!com_sv_running.Get()) {
356356
FS::PakPath::ClearPaks();
357357
if (!FS_LoadServerPaks(Info_ValueForKey(systemInfo, "sv_paks"), clc.demoplaying)) {
358358
if (!cl_allowDownload->integer) {

src/engine/client/cl_scrn.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ void SCR_DrawScreenField()
255255

256256
// also draw the connection information, so it doesn't
257257
// flash away too briefly on local or LAN games
258-
//if (!com_sv_running->value || Cvar_VariableIntegerValue("sv_cheats")) // Ridah, don't draw useless text if not in dev mode
258+
//if (!com_sv_running.Get() || Cvar_VariableIntegerValue("sv_cheats")) // Ridah, don't draw useless text if not in dev mode
259259
break;
260260

261261
case connstate_t::CA_ACTIVE:

src/engine/qcommon/common.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ Cvar::Cvar<bool> cvar_demo_timedemo(
6161
Cvar::CHEAT | Cvar::TEMPORARY,
6262
false
6363
);
64-
cvar_t *com_sv_running;
64+
Cvar::Cvar<bool> com_sv_running("sv_running", "do we have a server running?", Cvar::ROM, false);
6565
cvar_t *com_cl_running;
6666
cvar_t *com_version;
6767

@@ -183,7 +183,7 @@ bool Com_IsDedicatedServer()
183183

184184
bool Com_ServerRunning()
185185
{
186-
return com_sv_running->integer;
186+
return com_sv_running.Get();
187187
}
188188

189189
/*
@@ -384,7 +384,7 @@ static void HandlePacketEvent(const Sys::PacketEvent& event)
384384
buf.cursize = event.data.size();
385385
memcpy( buf.data, event.data.data(), buf.cursize );
386386

387-
if ( com_sv_running->integer )
387+
if ( com_sv_running.Get() )
388388
{
389389
Com_RunAndTimeServerPacket( &event.adr, &buf );
390390
}
@@ -432,7 +432,7 @@ void Com_EventLoop()
432432
while ( NET_GetLoopPacket( netsrc_t::NS_SERVER, &evFrom, &buf ) )
433433
{
434434
// if the server just shut down, flush the events
435-
if ( com_sv_running->integer )
435+
if ( com_sv_running.Get() )
436436
{
437437
Com_RunAndTimeServerPacket( &evFrom, &buf );
438438
}
@@ -560,7 +560,6 @@ void Com_Init()
560560
com_dropsim = Cvar_Get( "com_dropsim", "0", CVAR_CHEAT );
561561
com_speeds = Cvar_Get( "com_speeds", "0", 0 );
562562

563-
com_sv_running = Cvar_Get( "sv_running", "0", CVAR_ROM );
564563
com_cl_running = Cvar_Get( "cl_running", "0", CVAR_ROM );
565564

566565
com_unfocused = Cvar_Get( "com_unfocused", "0", CVAR_ROM );

src/engine/qcommon/net_ip.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,6 @@ void NET_Restart_f()
18821882
#ifdef BUILD_SERVER
18831883
NET_EnableNetworking( true );
18841884
#else
1885-
NET_EnableNetworking( !!com_sv_running->integer );
1885+
NET_EnableNetworking( com_sv_running.Get() );
18861886
#endif
18871887
}

src/engine/qcommon/qcommon.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ bool Com_ServerRunning();
530530

531531
extern cvar_t *com_speeds;
532532
extern cvar_t *com_timescale;
533-
extern cvar_t *com_sv_running;
533+
extern Cvar::Cvar<bool> com_sv_running;
534534
extern cvar_t *com_cl_running;
535535
extern cvar_t *com_version;
536536

src/engine/server/sv_ccmds.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ static void SV_MapRestart_f()
153153
}
154154

155155
// make sure server is running
156-
if ( !com_sv_running->integer )
156+
if ( !com_sv_running.Get() )
157157
{
158158
Log::Notice( "Server is not running." );
159159
return;
@@ -245,7 +245,7 @@ class StatusCmd: public Cmd::StaticCmd
245245
void Run(const Cmd::Args&) const override
246246
{
247247
// make sure server is running
248-
if ( !com_sv_running->integer )
248+
if ( !com_sv_running.Get() )
249249
{
250250
Log::Notice( "Server is not running." );
251251
return;
@@ -352,7 +352,7 @@ Examine the serverinfo string
352352
static void SV_Serverinfo_f()
353353
{
354354
// make sure server is running
355-
if ( !com_sv_running->integer )
355+
if ( !com_sv_running.Get() )
356356
{
357357
Log::Notice( "Server is not running." );
358358
return;
@@ -372,7 +372,7 @@ Examine the systeminfo string
372372
static void SV_Systeminfo_f()
373373
{
374374
// make sure server is running
375-
if ( !com_sv_running->integer )
375+
if ( !com_sv_running.Get() )
376376
{
377377
Log::Notice( "Server is not running." );
378378
return;
@@ -413,7 +413,7 @@ SV_AddOperatorCommands
413413
*/
414414
void SV_AddOperatorCommands()
415415
{
416-
if ( com_sv_running->integer )
416+
if ( com_sv_running.Get() )
417417
{
418418
// These commands should only be available while the server is running.
419419
Cmd_AddCommand( "fieldinfo", SV_FieldInfo_f );

src/engine/server/sv_init.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ void SV_Startup()
320320

321321
svs.initialized = true;
322322

323-
Cvar_Set( "sv_running", "1" );
323+
Cvar::SetValueForce( "sv_running", "1" );
324324
#ifndef BUILD_SERVER
325325
// For clients, reconfigure to open server ports.
326326
NET_EnableNetworking( true );
@@ -665,7 +665,7 @@ void SV_FinalCommand( char *cmd, bool disconnect )
665665
// Used instead of SV_Shutdown when Daemon is exiting
666666
void SV_QuickShutdown( const char *finalmsg )
667667
{
668-
if ( !com_sv_running || !com_sv_running->integer )
668+
if ( !com_sv_running.Get() )
669669
{
670670
return;
671671
}
@@ -690,7 +690,7 @@ Called to shut down the sgame VM, or to clean up after the VM shut down on its o
690690
*/
691691
void SV_Shutdown( const char *finalmsg )
692692
{
693-
if ( !com_sv_running || !com_sv_running->integer )
693+
if ( !com_sv_running.Get() )
694694
{
695695
return;
696696
}
@@ -725,7 +725,7 @@ void SV_Shutdown( const char *finalmsg )
725725
svs.serverLoad = -1;
726726
ChallengeManager::Clear();
727727

728-
Cvar_Set( "sv_running", "0" );
728+
Cvar::SetValueForce( "sv_running", "0" );
729729
#ifndef BUILD_SERVER
730730
// For clients, reconfigure to close server ports.
731731
NET_EnableNetworking( false );

src/engine/server/sv_main.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,7 @@ if a user is interested in a server to do a full status
513513
*/
514514
static void SVC_Info( const netadr_t& from, const Cmd::Args& args )
515515
{
516-
if ( SV_Private(ServerPrivate::NoStatus) || !com_sv_running || !com_sv_running->integer )
516+
if ( SV_Private(ServerPrivate::NoStatus) || !com_sv_running.Get() )
517517
{
518518
return;
519519
}
@@ -1325,7 +1325,7 @@ void SV_Frame( int msec )
13251325
return;
13261326
}
13271327

1328-
if ( !com_sv_running->integer )
1328+
if ( !com_sv_running.Get() )
13291329
{
13301330
return;
13311331
}

0 commit comments

Comments
 (0)