Skip to content

Commit 0b37f56

Browse files
committed
Migrate cvars sv_fullmsg, sv_fps
1 parent 11f4c61 commit 0b37f56

File tree

4 files changed

+14
-31
lines changed

4 files changed

+14
-31
lines changed

src/engine/server/server.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ extern serverStatic_t svs; // persistent server info across maps
290290
extern server_t sv; // cleared each map
291291
extern GameVM gvm; // game virtual machine
292292

293-
extern cvar_t *sv_fps;
293+
extern Cvar::Range<Cvar::Cvar<int>> sv_fps;
294294
extern Cvar::Cvar<int> sv_timeout;
295295
extern Cvar::Cvar<int> sv_zombietime;
296296
extern Cvar::Cvar<std::string> sv_privatePassword;
@@ -314,7 +314,7 @@ extern Cvar::Cvar<bool> sv_lanForceRate;
314314
extern Cvar::Cvar<int> sv_dl_maxRate;
315315

316316
//fretn
317-
extern cvar_t *sv_fullmsg;
317+
extern Cvar::Cvar<std::string> sv_fullmsg;
318318

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

src/engine/server/sv_client.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void SV_DirectConnect( const netadr_t& from, const Cmd::Args& args )
175175
}
176176
else
177177
{
178-
Net::OutOfBandPrint( netsrc_t::NS_SERVER, from, "print\n%s", sv_fullmsg->string );
178+
Net::OutOfBandPrint( netsrc_t::NS_SERVER, from, "print\n%s", sv_fullmsg.Get() );
179179
Log::Debug( "Rejected a connection." );
180180
return;
181181
}
@@ -1055,9 +1055,9 @@ void SV_UserinfoChanged( client_t *cl )
10551055
{
10561056
i = 1;
10571057
}
1058-
else if ( i > sv_fps->integer )
1058+
else if ( i > sv_fps.Get() )
10591059
{
1060-
i = sv_fps->integer;
1060+
i = sv_fps.Get();
10611061
}
10621062

10631063
cl->snapshotMsec = 1000 / i;

src/engine/server/sv_init.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -614,14 +614,9 @@ void SV_Init()
614614
sv_serverid = Cvar_Get( "sv_serverid", "0", CVAR_SYSTEMINFO | CVAR_ROM );
615615

616616
// server vars
617-
sv_fps = Cvar_Get( "sv_fps", "40", CVAR_TEMP );
618617

619618
sv_killserver = Cvar_Get( "sv_killserver", "0", 0 );
620619

621-
// fretn - note: redirecting of clients to other servers relies on this,
622-
// ET://someserver.com
623-
sv_fullmsg = Cvar_Get( "sv_fullmsg", "Server is full.", 0 );
624-
625620
svs.serverLoad = -1;
626621
}
627622

src/engine/server/sv_main.cpp

Lines changed: 9 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ GameVM gvm; // game virtual machine
5656
// timescale 5, the number of gamelogic frames per wall second will be 200.
5757
// For the dedicated server this also controls the engine frame rate. The engine framerate
5858
// is based on real time, disregarding timescale.
59-
cvar_t *sv_fps;
59+
Cvar::Range<Cvar::Cvar<int>> sv_fps("sv_fps", "sgame and dedicated server frame rate", Cvar::NONE, 40, 1, 1000);
6060

6161
Cvar::Cvar<int> sv_timeout("sv_timeout", "seconds without connectivity after which to drop a client", Cvar::NONE, 240);
6262
Cvar::Cvar<int> sv_zombietime("sv_zombietime", "seconds without messages after which to recycle client slot", Cvar::NONE, 2);
@@ -81,7 +81,7 @@ Cvar::Cvar<bool> sv_lanForceRate("sv_lanForceRate", "make LAN clients use max ne
8181
Cvar::Cvar<int> sv_dl_maxRate("sv_dl_maxRate", "max bytes/sec for UDP pak download", Cvar::NONE, 42000);
8282

8383
// fretn
84-
cvar_t *sv_fullmsg;
84+
Cvar::Cvar<std::string> sv_fullmsg("sv_fullmsg", "message for clients attempting to join full server", Cvar::NONE, "Server is full.");
8585

8686
Cvar::Range<Cvar::Cvar<int>> sv_networkScope(
8787
"sv_networkScope",
@@ -1285,23 +1285,16 @@ Return time in milliseconds until processing of the next server frame.
12851285
*/
12861286
int SV_FrameMsec()
12871287
{
1288-
if( sv_fps )
1289-
{
1290-
const int frameMsec = static_cast<int>(1000.0f / sv_fps->value);
1291-
int scaledResidual = static_cast<int>( sv.timeResidual / com_timescale->value );
1288+
const int frameMsec = 1000 / sv_fps.Get();
1289+
int scaledResidual = static_cast<int>( sv.timeResidual / com_timescale->value );
12921290

1293-
if ( frameMsec < scaledResidual )
1294-
{
1295-
return 0;
1296-
}
1297-
else
1298-
{
1299-
return frameMsec - scaledResidual;
1300-
}
1291+
if ( frameMsec < scaledResidual )
1292+
{
1293+
return 0;
13011294
}
13021295
else
13031296
{
1304-
return 1;
1297+
return frameMsec - scaledResidual;
13051298
}
13061299
}
13071300

@@ -1340,12 +1333,7 @@ void SV_Frame( int msec )
13401333
frameStartTime = Sys::Milliseconds();
13411334

13421335
// if it isn't time for the next frame, do nothing
1343-
if ( sv_fps->integer < 1 )
1344-
{
1345-
Cvar_Set( "sv_fps", "10" );
1346-
}
1347-
1348-
frameMsec = 1000 / sv_fps->integer;
1336+
frameMsec = 1000 / sv_fps.Get();
13491337

13501338
sv.timeResidual += msec;
13511339

0 commit comments

Comments
 (0)