Skip to content

Cvar migration: server #1626

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/engine/client/cl_cgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ void CL_AdjustTimeDelta()
// if the current time is WAY off, just correct to the current value

/*
if(com_sv_running->integer)
if(com_sv_running.Get())
{
resetTime = 100;
}
Expand Down
6 changes: 3 additions & 3 deletions src/engine/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ void CL_ShutdownAll()
// Gordon: stop recording on map change etc, demos aren't valid over map changes anyway
CL_StopRecord();

if ( !com_sv_running->integer )
if ( !com_sv_running.Get() )
{
void SV_ShutdownGameProgs();
SV_ShutdownGameProgs();
Expand Down Expand Up @@ -1014,7 +1014,7 @@ void CL_Connect_f()
// clear any previous "server full" type messages
clc.serverMessage[ 0 ] = 0;

if ( com_sv_running->integer && !strcmp( server, "loopback" ) )
if ( com_sv_running.Get() && !strcmp( server, "loopback" ) )
{
// if running a local server, kill it
SV_Shutdown( "Server quit" );
Expand Down Expand Up @@ -2376,7 +2376,7 @@ void CL_Init()
cl_altTab = Cvar_Get( "cl_altTab", "1", 0 );

// userinfo
cl_rate = Cvar_Get( "rate", "25000", CVAR_USERINFO | CVAR_ARCHIVE );
cl_rate = Cvar_Get( "rate", XSTRING(NETWORK_DEFAULT_RATE), CVAR_USERINFO | CVAR_ARCHIVE);

#if defined(USE_MUMBLE)
cl_useMumble = Cvar_Get( "cl_useMumble", "0", CVAR_LATCH );
Expand Down
2 changes: 1 addition & 1 deletion src/engine/client/cl_parse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void CL_SystemInfoChanged()
cl.serverId = atoi( Info_ValueForKey( systemInfo, "sv_serverid" ) );

// load paks sent by the server, but not if we are running a local server
if (!com_sv_running->integer) {
if (!com_sv_running.Get()) {
FS::PakPath::ClearPaks();
if (!FS_LoadServerPaks(Info_ValueForKey(systemInfo, "sv_paks"), clc.demoplaying)) {
if (!cl_allowDownload->integer) {
Expand Down
2 changes: 1 addition & 1 deletion src/engine/client/cl_scrn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ void SCR_DrawScreenField()

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

case connstate_t::CA_ACTIVE:
Expand Down
9 changes: 4 additions & 5 deletions src/engine/qcommon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ Cvar::Cvar<bool> cvar_demo_timedemo(
Cvar::CHEAT | Cvar::TEMPORARY,
false
);
cvar_t *com_sv_running;
Cvar::Cvar<bool> com_sv_running("sv_running", "do we have a server running?", Cvar::ROM, false);
cvar_t *com_cl_running;
cvar_t *com_version;

Expand Down Expand Up @@ -183,7 +183,7 @@ bool Com_IsDedicatedServer()

bool Com_ServerRunning()
{
return com_sv_running->integer;
return com_sv_running.Get();
}

/*
Expand Down Expand Up @@ -384,7 +384,7 @@ static void HandlePacketEvent(const Sys::PacketEvent& event)
buf.cursize = event.data.size();
memcpy( buf.data, event.data.data(), buf.cursize );

if ( com_sv_running->integer )
if ( com_sv_running.Get() )
{
Com_RunAndTimeServerPacket( &event.adr, &buf );
}
Expand Down Expand Up @@ -432,7 +432,7 @@ void Com_EventLoop()
while ( NET_GetLoopPacket( netsrc_t::NS_SERVER, &evFrom, &buf ) )
{
// if the server just shut down, flush the events
if ( com_sv_running->integer )
if ( com_sv_running.Get() )
{
Com_RunAndTimeServerPacket( &evFrom, &buf );
}
Expand Down Expand Up @@ -560,7 +560,6 @@ void Com_Init()
com_dropsim = Cvar_Get( "com_dropsim", "0", CVAR_CHEAT );
com_speeds = Cvar_Get( "com_speeds", "0", 0 );

com_sv_running = Cvar_Get( "sv_running", "0", CVAR_ROM );
com_cl_running = Cvar_Get( "cl_running", "0", CVAR_ROM );

com_unfocused = Cvar_Get( "com_unfocused", "0", CVAR_ROM );
Expand Down
2 changes: 1 addition & 1 deletion src/engine/qcommon/net_ip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1882,6 +1882,6 @@ void NET_Restart_f()
#ifdef BUILD_SERVER
NET_EnableNetworking( true );
#else
NET_EnableNetworking( !!com_sv_running->integer );
NET_EnableNetworking( com_sv_running.Get() );
#endif
}
2 changes: 1 addition & 1 deletion src/engine/qcommon/qcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ bool Com_ServerRunning();

extern cvar_t *com_speeds;
extern cvar_t *com_timescale;
extern cvar_t *com_sv_running;
extern Cvar::Cvar<bool> com_sv_running;
extern cvar_t *com_cl_running;
extern cvar_t *com_version;

Expand Down
6 changes: 6 additions & 0 deletions src/engine/qcommon/sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ Maryland 20850 USA.

#include "engine/qcommon/net_types.h"

// server->client bandwidth limits in bytes/sec
#define NETWORK_MIN_RATE 1000
#define NETWORK_DEFAULT_RATE 25000
#define NETWORK_MAX_RATE 90000
#define NETWORK_LAN_RATE 99999

void Sys_SendPacket(int length, const void *data, const netadr_t& to);
bool Sys_GetPacket(netadr_t *net_from, msg_t *net_message);

Expand Down
36 changes: 16 additions & 20 deletions src/engine/server/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ struct client_t
// note: this is one-shot, multiple downloads would cause a www download to be attempted again

int deltaMessage; // frame last client usercmd message
int nextReliableTime; // svs.time when another reliable command will be allowed
int lastPacketTime; // svs.time when packet was last received
int lastConnectTime; // svs.time when connection started
int nextSnapshotTime; // send another snapshot when svs.time >= nextSnapshotTime
Expand Down Expand Up @@ -291,34 +290,31 @@ extern serverStatic_t svs; // persistent server info across maps
extern server_t sv; // cleared each map
extern GameVM gvm; // game virtual machine

extern cvar_t *sv_fps;
extern cvar_t *sv_timeout;
extern cvar_t *sv_zombietime;
extern cvar_t *sv_privatePassword;
extern cvar_t *sv_allowDownload;
extern Cvar::Range<Cvar::Cvar<int>> sv_fps;
extern Cvar::Cvar<int> sv_timeout;
extern Cvar::Cvar<int> sv_zombietime;
extern Cvar::Cvar<std::string> sv_privatePassword;
extern Cvar::Cvar<bool> sv_allowDownload;
extern Cvar::Range<Cvar::Cvar<int>> sv_maxClients;

extern Cvar::Range<Cvar::Cvar<int>> sv_privateClients;
extern cvar_t *sv_hostname;
extern cvar_t *sv_statsURL;
extern cvar_t *sv_reconnectlimit;
extern cvar_t *sv_padPackets;
extern Cvar::Cvar<std::string> sv_hostname;
extern Cvar::Cvar<std::string> sv_statsURL;
extern Cvar::Cvar<int> sv_reconnectlimit;
extern Cvar::Cvar<int> sv_padPackets;
extern cvar_t *sv_killserver;
extern cvar_t *sv_mapname;
extern Cvar::Cvar<std::string> sv_mapname;
extern cvar_t *sv_mapChecksum;
extern cvar_t *sv_serverid;
extern cvar_t *sv_maxRate;
extern Cvar::Cvar<int> sv_serverid;
extern Cvar::Cvar<int> sv_maxRate;

extern cvar_t *sv_floodProtect;
extern cvar_t *sv_lanForceRate;

extern cvar_t *sv_showAverageBPS; // NERVE - SMF - net debugging
extern Cvar::Cvar<bool> sv_lanForceRate;

// TTimo - autodl
extern cvar_t *sv_dl_maxRate;
extern Cvar::Cvar<int> sv_dl_maxRate;

//fretn
extern cvar_t *sv_fullmsg;
extern Cvar::Cvar<std::string> sv_fullmsg;

extern Cvar::Range<Cvar::Cvar<int>> sv_networkScope;

Expand Down Expand Up @@ -372,7 +368,7 @@ void SV_ClientEnterWorld( client_t *client, usercmd_t *cmd );
void SV_FreeClient( client_t *client );
void SV_DropClient( client_t *drop, const char *reason );

void SV_ExecuteClientCommand( client_t *cl, const char *s, bool clientOK, bool premaprestart );
void SV_ExecuteClientCommand( client_t *cl, const char *s, bool premaprestart );
void SV_ClientThink( client_t *cl, usercmd_t *cmd );

void SV_WriteDownloadToClient( client_t *cl, msg_t *msg );
Expand Down
3 changes: 2 additions & 1 deletion src/engine/server/sv_bot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ Maryland 20850 USA.
// sv_bot.c

#include "server.h"
#include "qcommon/sys.h"

/*
==================
Expand All @@ -60,7 +61,7 @@ int SV_BotAllocateClient()
cl->state = clientState_t::CS_ACTIVE;
cl->lastPacketTime = svs.time;
cl->netchan.remoteAddress.type = netadrtype_t::NA_BOT;
cl->rate = 16384;
cl->rate = NETWORK_DEFAULT_RATE;

return i;
}
Expand Down
16 changes: 8 additions & 8 deletions src/engine/server/sv_ccmds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ static void SV_MapRestart_f()
}

// make sure server is running
if ( !com_sv_running->integer )
if ( !com_sv_running.Get() )
{
Log::Notice( "Server is not running." );
return;
Expand All @@ -166,7 +166,7 @@ static void SV_MapRestart_f()
// generate a new serverid
// TTimo - don't update restartedserverId there, otherwise we won't deal correctly with multiple map_restart
sv.serverId = com_frameTime;
Cvar_Set( "sv_serverid", va( "%i", sv.serverId ) );
Cvar::SetValueForce( "sv_serverid", va( "%i", sv.serverId ) );

// reset all the VM data in place without changing memory allocation
// note that we do NOT set sv.state = SS_LOADING, so configstrings that
Expand Down Expand Up @@ -245,7 +245,7 @@ class StatusCmd: public Cmd::StaticCmd
void Run(const Cmd::Args&) const override
{
// make sure server is running
if ( !com_sv_running->integer )
if ( !com_sv_running.Get() )
{
Log::Notice( "Server is not running." );
return;
Expand Down Expand Up @@ -286,12 +286,12 @@ class StatusCmd: public Cmd::StaticCmd
"players: %d / %d\n"
"num score connection address port name\n"
"--- ----- ---------- ---------------------- ------ ----",
sv_hostname->string,
sv_hostname.Get(),
Q3_VERSION " on " Q3_ENGINE,
PROTOCOL_VERSION,
cpu,
time_string,
sv_mapname->string,
sv_mapname.Get(),
players,
sv_maxClients.Get()
);
Expand Down Expand Up @@ -352,7 +352,7 @@ Examine the serverinfo string
static void SV_Serverinfo_f()
{
// make sure server is running
if ( !com_sv_running->integer )
if ( !com_sv_running.Get() )
{
Log::Notice( "Server is not running." );
return;
Expand All @@ -372,7 +372,7 @@ Examine the systeminfo string
static void SV_Systeminfo_f()
{
// make sure server is running
if ( !com_sv_running->integer )
if ( !com_sv_running.Get() )
{
Log::Notice( "Server is not running." );
return;
Expand Down Expand Up @@ -413,7 +413,7 @@ SV_AddOperatorCommands
*/
void SV_AddOperatorCommands()
{
if ( com_sv_running->integer )
if ( com_sv_running.Get() )
{
// These commands should only be available while the server is running.
Cmd_AddCommand( "fieldinfo", SV_FieldInfo_f );
Expand Down
Loading