Skip to content

Commit

Permalink
Add new flag to mark secondary or long cvars in infostrings,
Browse files Browse the repository at this point in the history
so they can be inserted in a second batch in case of overflow.
  • Loading branch information
karnute committed Apr 9, 2018
1 parent 0bafb8a commit 8452121
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 15 deletions.
2 changes: 1 addition & 1 deletion code/qcommon/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,7 @@ void Com_Init( char *commandLine ) {
#endif

s = va("%s %s %s", Q3_VERSION, PLATFORM_STRING, PRODUCT_DATE );
com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO );
com_version = Cvar_Get ("version", s, CVAR_ROM | CVAR_SERVERINFO | CVAR_INFOSECLONG );
com_gamename = Cvar_Get("com_gamename", GAMENAME_FOR_MASTER, CVAR_SERVERINFO | CVAR_INIT);
com_protocol = Cvar_Get("com_protocol", va("%i", PROTOCOL_VERSION), CVAR_SERVERINFO | CVAR_INIT);
#ifdef LEGACY_PROTOCOL
Expand Down
27 changes: 21 additions & 6 deletions code/qcommon/cvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -886,14 +886,14 @@ void Cvar_Set_f( void ) {
break;
case 'u':
if( !( v->flags & CVAR_USERINFO ) ) {
v->flags |= CVAR_USERINFO;
cvar_modifiedFlags |= CVAR_USERINFO;
v->flags |= CVAR_USERINFO | CVAR_INFOSECLONG;
cvar_modifiedFlags |= CVAR_USERINFO | CVAR_INFOSECLONG;
}
break;
case 's':
if( !( v->flags & CVAR_SERVERINFO ) ) {
v->flags |= CVAR_SERVERINFO;
cvar_modifiedFlags |= CVAR_SERVERINFO;
v->flags |= CVAR_SERVERINFO | CVAR_INFOSECLONG;
cvar_modifiedFlags |= CVAR_SERVERINFO | CVAR_INFOSECLONG;
}
break;
}
Expand Down Expand Up @@ -1249,7 +1249,14 @@ char *Cvar_InfoString(int bit)

for(var = cvar_vars; var; var = var->next)
{
if(var->name && (var->flags & bit))
if(var->name && (var->flags & bit) && !(var->flags & CVAR_INFOSECLONG))
Info_SetValueForKey (info, var->name, var->string);
}

// secondary or potential long cvar in a second batch in case they overflow
for(var = cvar_vars; var; var = var->next)
{
if(var->name && (var->flags & bit) && (var->flags & CVAR_INFOSECLONG))
Info_SetValueForKey (info, var->name, var->string);
}

Expand All @@ -1272,9 +1279,17 @@ char *Cvar_InfoString_Big(int bit)

for (var = cvar_vars; var; var = var->next)
{
if(var->name && (var->flags & bit))
if(var->name && (var->flags & bit) && !(var->flags & CVAR_INFOSECLONG))
Info_SetValueForKey_Big (info, var->name, var->string);
}

// secondary or potential long cvar in a second batch in case they overflow
for (var = cvar_vars; var; var = var->next)
{
if(var->name && (var->flags & bit) && (var->flags & CVAR_INFOSECLONG))
Info_SetValueForKey_Big (info, var->name, var->string);
}

return info;
}

Expand Down
1 change: 1 addition & 0 deletions code/qcommon/q_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -910,6 +910,7 @@ default values.
#define CVAR_SERVER_CREATED 0x0800 // cvar was created by a server the client connected to.
#define CVAR_VM_CREATED 0x1000 // cvar was created exclusively in one of the VMs.
#define CVAR_PROTECTED 0x2000 // prevent modifying this var from VMs or the server
#define CVAR_INFOSECLONG 0X4000 // secondary or potential long cvar in infostrings
// These flags are only returned by the Cvar_Flags() function
#define CVAR_MODIFIED 0x40000000 // Cvar was modified
#define CVAR_NONEXISTENT 0x80000000 // Cvar doesn't exist.
Expand Down
16 changes: 8 additions & 8 deletions code/server/sv_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,10 +872,10 @@ void SV_Init (void)

// serverinfo vars
Cvar_Get ("dmflags", "0", CVAR_SERVERINFO);
Cvar_Get ("fraglimit", "20", CVAR_SERVERINFO);
Cvar_Get ("timelimit", "0", CVAR_SERVERINFO);
Cvar_Get ("fraglimit", "20", CVAR_SERVERINFO | CVAR_INFOSECLONG);
Cvar_Get ("timelimit", "0", CVAR_SERVERINFO | CVAR_INFOSECLONG);
sv_gametype = Cvar_Get ("g_gametype", "0", CVAR_SERVERINFO | CVAR_LATCH );
Cvar_Get ("sv_keywords", "", CVAR_SERVERINFO);
Cvar_Get ("sv_keywords", "", CVAR_SERVERINFO | CVAR_INFOSECLONG);
sv_mapname = Cvar_Get ("mapname", "nomap", CVAR_SERVERINFO | CVAR_ROM);
sv_privateClients = Cvar_Get ("sv_privateClients", "0", CVAR_SERVERINFO);
sv_hostname = Cvar_Get ("sv_hostname", "noname", CVAR_SERVERINFO | CVAR_ARCHIVE );
Expand All @@ -897,10 +897,10 @@ void SV_Init (void)
Cvar_CheckRange(sv_voip, 0, 1, qtrue);
sv_voipProtocol = Cvar_Get("sv_voipProtocol", sv_voip->integer ? "opus" : "", CVAR_SYSTEMINFO | CVAR_ROM );
#endif
Cvar_Get ("sv_paks", "", CVAR_SYSTEMINFO | CVAR_ROM );
Cvar_Get ("sv_pakNames", "", CVAR_SYSTEMINFO | CVAR_ROM );
Cvar_Get ("sv_referencedPaks", "", CVAR_SYSTEMINFO | CVAR_ROM );
Cvar_Get ("sv_referencedPakNames", "", CVAR_SYSTEMINFO | CVAR_ROM );
Cvar_Get ("sv_paks", "", CVAR_SYSTEMINFO | CVAR_ROM | CVAR_INFOSECLONG );
Cvar_Get ("sv_pakNames", "", CVAR_SYSTEMINFO | CVAR_ROM | CVAR_INFOSECLONG );
Cvar_Get ("sv_referencedPaks", "", CVAR_SYSTEMINFO | CVAR_ROM | CVAR_INFOSECLONG );
Cvar_Get ("sv_referencedPakNames", "", CVAR_SYSTEMINFO | CVAR_ROM | CVAR_INFOSECLONG );

// server vars
sv_rconPassword = Cvar_Get ("rconPassword", "", CVAR_TEMP );
Expand All @@ -911,7 +911,7 @@ void SV_Init (void)
Cvar_Get ("nextmap", "", CVAR_TEMP );
Cvar_Get ("sv_cheatMode", "0", CVAR_TEMP );

Cvar_Get ("sv_dlURL", "", CVAR_SERVERINFO | CVAR_ARCHIVE);
Cvar_Get ("sv_dlURL", "", CVAR_SERVERINFO | CVAR_ARCHIVE | CVAR_INFOSECLONG );

sv_master[0] = Cvar_Get("sv_master1", MASTER_SERVER_NAME, 0);
sv_master[1] = Cvar_Get("sv_master2", "master.ioquake3.org", 0);
Expand Down

0 comments on commit 8452121

Please sign in to comment.