Skip to content

Commit

Permalink
engine: client: make a common function for sending out userinfo changes
Browse files Browse the repository at this point in the history
  • Loading branch information
a1batross committed Jul 6, 2024
1 parent 457422c commit b4376a6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion engine/client/cl_game.c
Original file line number Diff line number Diff line change
Expand Up @@ -2791,7 +2791,7 @@ static void GAME_EXPORT PlayerInfo_SetValueForKey( const char *key, const char *
else if( Info_SetValueForStarKey( cls.userinfo, key, value, MAX_INFO_STRING ))
{
// time to update server copy of userinfo
CL_ServerCommand( true, "setinfo \"%s\" \"%s\"\n", key, value );
CL_UpdateInfo( key, value );
}
}

Expand Down
23 changes: 23 additions & 0 deletions engine/client/cl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2722,6 +2722,29 @@ void CL_ServerCommand( qboolean reliable, const char *fmt, ... )
}
}

/*
===============
CL_UpdateInfo
tell server about changed userinfo
===============
*/
void CL_UpdateInfo( const char *key, const char *value )
{
if( !cls.legacymode )
{
CL_ServerCommand( true, "setinfo \"%s\" \"%s\"\n", key, value );
}
else
{
if( cls.state != ca_active )
return;

MSG_BeginClientCmd( &cls.netchan.message, clc_legacy_userinfo );
MSG_WriteString( &cls.netchan.message, cls.userinfo );
}
}

//=============================================================================
/*
==============
Expand Down
12 changes: 0 additions & 12 deletions engine/client/cl_parse_48.c
Original file line number Diff line number Diff line change
Expand Up @@ -657,18 +657,6 @@ void CL_LegacyPrecache_f( void )
cls.signon = SIGNONS;
}

void CL_LegacyUpdateInfo( void )
{
if( !cls.legacymode )
return;

if( cls.state != ca_active )
return;

MSG_BeginClientCmd( &cls.netchan.message, clc_legacy_userinfo );
MSG_WriteString( &cls.netchan.message, cls.userinfo );
}

qboolean CL_LegacyMode( void )
{
return cls.legacymode == PROTO_LEGACY;
Expand Down
1 change: 1 addition & 0 deletions engine/common/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ void SV_BroadcastPrintf( struct sv_client_s *ignore, const char *fmt, ... ) _for
void CL_ClearStaticEntities( void );
qboolean S_StreamGetCurrentState( char *currentTrack, size_t currentTrackSize, char *loopTrack, size_t loopTrackSize, int *position );
void CL_ServerCommand( qboolean reliable, const char *fmt, ... ) _format( 2 );
void CL_UpdateInfo( const char *key, const char *value );
void CL_HudMessage( const char *pMessage );
const char *CL_MsgInfo( int cmd );
void SV_DrawDebugTriangles( void );
Expand Down
3 changes: 1 addition & 2 deletions engine/common/cvar.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ static qboolean Cvar_UpdateInfo( convar_t *var, const char *value, qboolean noti
return false; // failed to change value

// time to update server copy of userinfo
CL_ServerCommand( true, "setinfo \"%s\" \"%s\"\n", var->name, value );
CL_LegacyUpdateInfo();
CL_UpdateInfo( var->name, value );
}
#endif
}
Expand Down

0 comments on commit b4376a6

Please sign in to comment.