Skip to content

Commit

Permalink
Add mv_clFlags cvar to userinfo to let servers know which new feature…
Browse files Browse the repository at this point in the history
…s a client supports.
  • Loading branch information
Daggolin committed Sep 16, 2023
1 parent 4312e6f commit 626d5c3
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/client/cl_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2778,6 +2778,50 @@ void CL_SetForcePowers_f( void ) {
#define G2_VERT_SPACE_CLIENT_SIZE 256
#endif


/*
=================
MV_UpdateClFlags
Called by CL_Init. Updates the mv_clFlags accoding to the current settings
At the time of initial implementation there is only two clFlags, one which is always active and one which could be determined at compile time, so the function is not required, yet.
However in future versions users might be able to disable some of the features, so the clFlags need to be adjusted in such cases
=================
*/
void MV_UpdateClFlags( void )
{
// mv_clFlags - Used to inform the server about available jk2mv clientside features
static cvar_t *mv_clFlags;
char *value;
int intValue = 0;

// Check for the features and determine the flags
if ( MV_APILEVEL >= 4 ) intValue |= MV_CLFLAG_SUBMODEL_BYPASS;
intValue |= MV_CLFLAG_ADVANCED_REMAPS;

// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
// !!! Forks of JK2MV should NOT modify the mv_clFlags !!!
// !!! Removal, replacement or adding of new flags might lead to incompatibilities !!!
// !!! Forks should define their own userinfo cvar instead of modifying this !!!
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

// If the current clFlags match the intValue we can return
if ( mv_clFlags && mv_clFlags->integer == intValue ) return;

// We need a string when registering/setting the cvar
value = va( "%i", intValue );

if ( !mv_clFlags )
{ // Register the cvar as rom, internal and userinfo for the server to see, but without users manually changing it
mv_clFlags = Cvar_Get( "mv_clFlags", value, CVAR_ROM|CVAR_INTERNAL|CVAR_USERINFO );
}
else
{ // Update the cvar
Cvar_Set( "mv_clFlags", value );
}
}

/*
====================
CL_Init
Expand Down Expand Up @@ -2907,6 +2951,9 @@ void CL_Init( void ) {
cl_downloadTime = Cvar_Get("cl_downloadTime", "", CVAR_INTERNAL);
cl_downloadProtocol = Cvar_Get("cl_downloadProtocol", "", CVAR_INTERNAL);

// Update cl flags userinfo
MV_UpdateClFlags();

//
// register our commands
//
Expand Down
4 changes: 4 additions & 0 deletions src/game/bg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@

#define MAX_CLIENT_SCORE_SEND 20

// mv_clflags - set by the client engine in the mv_clFlags userinfo cvar to inform the server about additional features
#define MV_CLFLAG_SUBMODEL_BYPASS (1) // Indicates the client engine supports bypassing the MAX_SUBMODEL limit if the cgame module and the server support it, too.
#define MV_CLFLAG_ADVANCED_REMAPS (1 << 1) // Indicates the client engine supports the new advanced shader remaps.

//
// config strings are a general means of communicating variable length strings
// from the server to all connected clients.
Expand Down

0 comments on commit 626d5c3

Please sign in to comment.