Skip to content

Engine support for server engine version in client #1539

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

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 3 additions & 1 deletion src/engine/qcommon/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ Cvar::Cvar<bool> cvar_demo_timedemo(
cvar_t *com_sv_running;
cvar_t *com_cl_running;
cvar_t *com_version;
Cvar::Cvar<std::string> com_engineVersion( "com_engineVersion", "Engine version used by the server",
Cvar::ROM | Cvar::SERVERINFO, ENGINE_VERSION );

cvar_t *com_unfocused;
cvar_t *com_minimized;
Expand Down Expand Up @@ -278,7 +280,7 @@ std::unique_ptr<Sys::EventBase> Com_GetEvent()
return std::move(eventQueue[( eventTail - 1 ) & MASK_QUEUED_EVENTS ]);
}

// check for console commands
// check for tty/curses console commands
if ( char* s = CON_Input() )
{
Com_QueueEvent( Util::make_unique<Sys::ConsoleInputEvent>( s ) );
Expand Down
1 change: 1 addition & 0 deletions src/engine/qcommon/qcommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,7 @@ extern cvar_t *com_timescale;
extern cvar_t *com_sv_running;
extern cvar_t *com_cl_running;
extern cvar_t *com_version;
extern Cvar::Cvar<std::string> com_engineVersion;

extern Cvar::Cvar<std::string> com_consoleCommand;

Expand Down
21 changes: 12 additions & 9 deletions src/engine/server/sv_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,11 @@ cvar_t *sv_timeout; // seconds without any message
cvar_t *sv_zombietime; // seconds to sink messages after disconnect
cvar_t *sv_privatePassword; // password for the privateClient slots
cvar_t *sv_allowDownload;
cvar_t *sv_maxclients;
Cvar::Range<Cvar::Cvar<int>> sv_maxClients("sv_maxclients",
"max number of players on the server", Cvar::SERVERINFO, 20, 1, MAX_CLIENTS);

Cvar::Range<Cvar::Cvar<int>> sv_privateClients("sv_privateClients",
"number of password-protected client slots", CVAR_SERVERINFO, 0, 0, MAX_CLIENTS);
"number of password-protected client slots", Cvar::SERVERINFO, 0, 0, MAX_CLIENTS);
cvar_t *sv_hostname;
cvar_t *sv_statsURL;
cvar_t *sv_reconnectlimit; // minimum seconds between connect messages
Expand Down Expand Up @@ -245,7 +246,7 @@ void PRINTF_LIKE(2) SV_SendServerCommand( client_t *cl, const char *fmt, ... )
}

// send the data to all relevent clients
for ( j = 0, client = svs.clients; j < sv_maxclients->integer; j++, client++ )
for ( j = 0, client = svs.clients; j < sv_maxClients.Get(); j++, client++ )
{
if ( client->state < clientState_t::CS_PRIMED )
{
Expand Down Expand Up @@ -490,7 +491,7 @@ static void SVC_Status( const netadr_t& from, const Cmd::Args& args )
}

std::string status;
for ( int i = 0; i < sv_maxclients->integer; i++ )
for ( int i = 0; i < sv_maxClients.Get(); i++ )
{
client_t* cl = &svs.clients[ i ];

Expand Down Expand Up @@ -524,7 +525,7 @@ static void SVC_Info( const netadr_t& from, const Cmd::Args& args )
int publicSlotHumans = 0;
int privateSlotHumans = 0;

for ( int i = 0; i < sv_maxclients->integer; i++ )
for ( int i = 0; i < sv_maxClients.Get(); i++ )
{
if ( svs.clients[ i ].state >= clientState_t::CS_CONNECTED )
{
Expand Down Expand Up @@ -586,11 +587,13 @@ static void SVC_Info( const netadr_t& from, const Cmd::Args& args )
info_map["hostname"] = sv_hostname->string;
info_map["serverload"] = std::to_string( svs.serverLoad );
info_map["mapname"] = sv_mapname->string;
info_map["version"] = com_engineVersion.Get();
info_map["abiVersion"] = IPC::SYSCALL_ABI_VERSION;
info_map["clients"] = std::to_string( publicSlotHumans + privateSlotHumans );
info_map["bots"] = std::to_string( bots );
// Satisfies (number of open public slots) = (displayed max clients) - (number of clients).
info_map["sv_maxclients"] = std::to_string(
std::max( 0, sv_maxclients->integer - sv_privateClients.Get() ) + privateSlotHumans );
std::max( 0, sv_maxClients.Get() - sv_privateClients.Get() ) + privateSlotHumans );

if ( sv_statsURL->string[0] )
{
Expand Down Expand Up @@ -1097,7 +1100,7 @@ void SV_PacketEvent( const netadr_t& from, msg_t *msg )
qport = MSG_ReadShort( msg ) & 0xffff;

// find which client the message is from
for ( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
for ( i = 0, cl = svs.clients; i < sv_maxClients.Get(); i++, cl++ )
{
if ( cl->state == clientState_t::CS_FREE )
{
Expand Down Expand Up @@ -1160,7 +1163,7 @@ void SV_CalcPings()
int total, count;
int delta;

for ( i = 0; i < sv_maxclients->integer; i++ )
for ( i = 0; i < sv_maxClients.Get(); i++ )
{
cl = &svs.clients[ i ];

Expand Down Expand Up @@ -1236,7 +1239,7 @@ void SV_CheckTimeouts()
droppoint = svs.time - 1000 * sv_timeout->integer;
zombiepoint = svs.time - 1000 * sv_zombietime->integer;

for ( i = 0, cl = svs.clients; i < sv_maxclients->integer; i++, cl++ )
for ( i = 0, cl = svs.clients; i < sv_maxClients.Get(); i++, cl++ )
{
// message times may be wrong across a changelevel
if ( cl->lastPacketTime > svs.time )
Expand Down