From 5ef97ae99eb5255fbc706be87ede91f2f1bf1238 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 13 Mar 2023 05:37:45 +0300 Subject: [PATCH] engine: convert Info_SetValueForKey with va to Info_SetValueForKeyf --- engine/client/cl_main.c | 6 +++--- engine/server/sv_client.c | 12 ++++++------ engine/server/sv_game.c | 2 +- engine/server/sv_main.c | 10 +++++----- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/engine/client/cl_main.c b/engine/client/cl_main.c index 07c0de43..959bdb31 100644 --- a/engine/client/cl_main.c +++ b/engine/client/cl_main.c @@ -1029,9 +1029,9 @@ void CL_SendConnectPacket( void ) Cvar_SetCheatState(); Cvar_FullSet( "sv_cheats", "0", FCVAR_READ_ONLY | FCVAR_SERVER ); - Info_SetValueForKey( protinfo, "d", va( "%d", input_devices ), sizeof( protinfo ) ); + Info_SetValueForKeyf( protinfo, "d", sizeof( protinfo ), "%d", input_devices ); Info_SetValueForKey( protinfo, "v", XASH_VERSION, sizeof( protinfo ) ); - Info_SetValueForKey( protinfo, "b", va( "%d", Q_buildnum() ), sizeof( protinfo ) ); + Info_SetValueForKeyf( protinfo, "b", sizeof( protinfo ), "%d", Q_buildnum( )); Info_SetValueForKey( protinfo, "o", Q_buildos(), sizeof( protinfo ) ); Info_SetValueForKey( protinfo, "a", Q_buildarch(), sizeof( protinfo ) ); } @@ -1065,7 +1065,7 @@ void CL_SendConnectPacket( void ) Info_SetValueForKey( protinfo, "uuid", key, sizeof( protinfo )); Info_SetValueForKey( protinfo, "qport", qport, sizeof( protinfo )); - Info_SetValueForKey( protinfo, "ext", va("%d", extensions), sizeof( protinfo )); + Info_SetValueForKeyf( protinfo, "ext", sizeof( protinfo ), "%d", extensions); Netchan_OutOfBandPrint( NS_CLIENT, adr, "connect %i %i \"%s\" \"%s\"\n", PROTOCOL_VERSION, cls.challenge, protinfo, cls.userinfo ); Con_Printf( "Trying to connect by modern protocol\n" ); diff --git a/engine/server/sv_client.c b/engine/server/sv_client.c index 8d1cfcf3..e4c1e8e5 100644 --- a/engine/server/sv_client.c +++ b/engine/server/sv_client.c @@ -432,7 +432,7 @@ void SV_ConnectClient( netadr_t from ) // build protinfo answer protinfo[0] = '\0'; - Info_SetValueForKey( protinfo, "ext", va( "%d", newcl->extensions ), sizeof( protinfo ) ); + Info_SetValueForKeyf( protinfo, "ext", sizeof( protinfo ), "%d", newcl->extensions ); // send the connect packet to the client Netchan_OutOfBandPrint( NS_SERVER, from, "client_connect %s", protinfo ); @@ -875,13 +875,13 @@ void SV_Info( netadr_t from, int protocolVersion ) SV_GetPlayerCount( &count, &bots ); // a1ba: send protocol version to distinguish old engine and new - Info_SetValueForKey( s, "p", va( "%i", PROTOCOL_VERSION ), sizeof( s )); + Info_SetValueForKeyf( s, "p", sizeof( s ), "%i", PROTOCOL_VERSION ); Info_SetValueForKey( s, "map", sv.name, sizeof( s )); Info_SetValueForKey( s, "dm", svgame.globals->deathmatch ? "1" : "0", sizeof( s )); Info_SetValueForKey( s, "team", svgame.globals->teamplay ? "1" : "0", sizeof( s )); Info_SetValueForKey( s, "coop", svgame.globals->coop ? "1" : "0", sizeof( s )); - Info_SetValueForKey( s, "numcl", va( "%i", count ), sizeof( s )); - Info_SetValueForKey( s, "maxcl", va( "%i", svs.maxclients ), sizeof( s )); + Info_SetValueForKeyf( s, "numcl", sizeof( s ), "%i", count ); + Info_SetValueForKeyf( s, "maxcl", sizeof( s ), "%i", svs.maxclients ); Info_SetValueForKey( s, "gamedir", GI->gamefolder, sizeof( s )); Info_SetValueForKey( s, "password", have_password ? "1" : "0", sizeof( s )); @@ -980,8 +980,8 @@ void SV_BuildNetAnswer( netadr_t from ) string[0] = '\0'; Info_SetValueForKey( string, "hostname", hostname.string, MAX_INFO_STRING ); Info_SetValueForKey( string, "gamedir", GI->gamefolder, MAX_INFO_STRING ); - Info_SetValueForKey( string, "current", va( "%i", count ), MAX_INFO_STRING ); - Info_SetValueForKey( string, "max", va( "%i", svs.maxclients ), MAX_INFO_STRING ); + Info_SetValueForKeyf( string, "current", MAX_INFO_STRING, "%i", count ); + Info_SetValueForKeyf( string, "max", MAX_INFO_STRING, "%i", svs.maxclients ); Info_SetValueForKey( string, "map", sv.name, MAX_INFO_STRING ); // send serverinfo diff --git a/engine/server/sv_game.c b/engine/server/sv_game.c index 9661a3d6..ea9edadc 100644 --- a/engine/server/sv_game.c +++ b/engine/server/sv_game.c @@ -3765,7 +3765,7 @@ void GAME_EXPORT pfnSetClientMaxspeed( const edict_t *pEdict, float fNewMaxspeed return; fNewMaxspeed = bound( -svgame.movevars.maxspeed, fNewMaxspeed, svgame.movevars.maxspeed ); - Info_SetValueForKey( cl->physinfo, "maxspd", va( "%.f", fNewMaxspeed ), MAX_INFO_STRING ); + Info_SetValueForKeyf( cl->physinfo, "maxspd", MAX_INFO_STRING, "%.f", fNewMaxspeed ); cl->edict->v.maxspeed = fNewMaxspeed; } diff --git a/engine/server/sv_main.c b/engine/server/sv_main.c index b57a8993..53246008 100644 --- a/engine/server/sv_main.c +++ b/engine/server/sv_main.c @@ -781,11 +781,11 @@ void SV_AddToMaster( netadr_t from, sizebuf_t *msg ) } SV_GetPlayerCount( &clients, &bots ); - Info_SetValueForKey( s, "protocol", va( "%d", PROTOCOL_VERSION ), len ); // protocol version - Info_SetValueForKey( s, "challenge", va( "%u", challenge ), len ); // challenge number - Info_SetValueForKey( s, "players", va( "%d", clients ), len ); // current player number, without bots - Info_SetValueForKey( s, "max", va( "%d", svs.maxclients ), len ); // max_players - Info_SetValueForKey( s, "bots", va( "%d", bots ), len ); // bot count + Info_SetValueForKeyf( s, "protocol", len, "%d", PROTOCOL_VERSION ); // protocol version + Info_SetValueForKeyf( s, "challenge", len, "%u", challenge ); // challenge number + Info_SetValueForKeyf( s, "players", len, "%d", clients ); // current player number, without bots + Info_SetValueForKeyf( s, "max", len, "%d", svs.maxclients ); // max_players + Info_SetValueForKeyf( s, "bots", len, "%d", bots ); // bot count Info_SetValueForKey( s, "gamedir", GI->gamefolder, len ); // gamedir Info_SetValueForKey( s, "map", sv.name, len ); // current map Info_SetValueForKey( s, "type", (Host_IsDedicated()) ? "d" : "l", len ); // dedicated or local