mirror of
https://github.com/YGGverse/xash3d-fwgs.git
synced 2025-01-29 08:14:15 +00:00
engine: common: replace some obvious va uses by temp buffer and Q_snprintf or equivalent code
This commit is contained in:
parent
9690fe9334
commit
116a605248
@ -1041,10 +1041,14 @@ compare first argument with string
|
|||||||
*/
|
*/
|
||||||
static qboolean Cmd_CheckName( const char *name )
|
static qboolean Cmd_CheckName( const char *name )
|
||||||
{
|
{
|
||||||
if( !Q_stricmp( Cmd_Argv( 0 ), name ))
|
char *p = Cmd_Argv( 0 );
|
||||||
|
|
||||||
|
if( !Q_stricmp( p, name ))
|
||||||
return true;
|
return true;
|
||||||
if( !Q_stricmp( Cmd_Argv( 0 ), va( "\\%s", name )))
|
|
||||||
|
if( p[0] == '\\' && !Q_stricmp( &p[1], name ))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1080,7 +1080,7 @@ void Cvar_Toggle_f( void )
|
|||||||
|
|
||||||
v = !Cvar_VariableInteger( Cmd_Argv( 1 ));
|
v = !Cvar_VariableInteger( Cmd_Argv( 1 ));
|
||||||
|
|
||||||
Cvar_Set( Cmd_Argv( 1 ), va( "%i", v ));
|
Cvar_Set( Cmd_Argv( 1 ), v ? "1" : "0" );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1162,7 +1162,6 @@ void Cvar_List_f( void )
|
|||||||
{
|
{
|
||||||
convar_t *var;
|
convar_t *var;
|
||||||
const char *match = NULL;
|
const char *match = NULL;
|
||||||
char *value;
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
size_t matchlen = 0;
|
size_t matchlen = 0;
|
||||||
|
|
||||||
@ -1174,6 +1173,8 @@ void Cvar_List_f( void )
|
|||||||
|
|
||||||
for( var = cvar_vars; var; var = var->next )
|
for( var = cvar_vars; var; var = var->next )
|
||||||
{
|
{
|
||||||
|
char value[MAX_VA_STRING];
|
||||||
|
|
||||||
if( var->name[0] == '@' )
|
if( var->name[0] == '@' )
|
||||||
continue; // never shows system cvars
|
continue; // never shows system cvars
|
||||||
|
|
||||||
@ -1181,8 +1182,8 @@ void Cvar_List_f( void )
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if( Q_colorstr( var->string ))
|
if( Q_colorstr( var->string ))
|
||||||
value = va( "\"%s\"", var->string );
|
Q_snprintf( value, sizeof( value ), "\"%s\"", var->string );
|
||||||
else value = va( "\"^2%s^7\"", var->string );
|
else Q_snprintf( value, sizeof( value ), "\"^2%s^7\"", var->string );
|
||||||
|
|
||||||
if( FBitSet( var->flags, FCVAR_EXTENDED|FCVAR_ALLOCATED ))
|
if( FBitSet( var->flags, FCVAR_EXTENDED|FCVAR_ALLOCATED ))
|
||||||
Con_Printf( " %-*s %s ^3%s^7\n", 32, var->name, value, var->desc );
|
Con_Printf( " %-*s %s ^3%s^7\n", 32, var->name, value, var->desc );
|
||||||
|
@ -346,10 +346,10 @@ void Host_ChangeGame_f( void )
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
const char *arg1 = va( "%s", Cmd_Argv( 1 ));
|
char finalmsg[MAX_VA_STRING];
|
||||||
const char *arg2 = va( "change game to '%s'", FI->games[i]->title );
|
|
||||||
|
|
||||||
Host_NewInstance( arg1, arg2 );
|
Q_snprintf( finalmsg, sizeof( finalmsg ), "change game to '%s'", FI->games[i]->title );
|
||||||
|
Host_NewInstance( Cmd_Argv( 1 ), finalmsg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -384,9 +384,11 @@ void Host_Exec_f( void )
|
|||||||
"pyro.cfg", "spy.cfg", "engineer.cfg", "civilian.cfg"
|
"pyro.cfg", "spy.cfg", "engineer.cfg", "civilian.cfg"
|
||||||
};
|
};
|
||||||
int i;
|
int i;
|
||||||
|
char temp[MAX_VA_STRING];
|
||||||
qboolean allow = false;
|
qboolean allow = false;
|
||||||
|
|
||||||
unprivilegedWhitelist[0] = va( "%s.cfg", clgame.mapname );
|
Q_snprintf( temp, sizeof( temp ), "%s.cfg", clgame.mapname );
|
||||||
|
unprivilegedWhitelist[0] = temp;
|
||||||
|
|
||||||
for( i = 0; i < ARRAYSIZE( unprivilegedWhitelist ); i++ )
|
for( i = 0; i < ARRAYSIZE( unprivilegedWhitelist ); i++ )
|
||||||
{
|
{
|
||||||
|
@ -3019,9 +3019,13 @@ Mod_LoadBrushModel
|
|||||||
*/
|
*/
|
||||||
void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded )
|
void Mod_LoadBrushModel( model_t *mod, const void *buffer, qboolean *loaded )
|
||||||
{
|
{
|
||||||
|
char poolname[MAX_VA_STRING];
|
||||||
|
|
||||||
|
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", loadmodel->name );
|
||||||
|
|
||||||
if( loaded ) *loaded = false;
|
if( loaded ) *loaded = false;
|
||||||
|
|
||||||
loadmodel->mempool = Mem_AllocPool( va( "^2%s^7", loadmodel->name ));
|
loadmodel->mempool = Mem_AllocPool( poolname );
|
||||||
loadmodel->type = mod_brush;
|
loadmodel->type = mod_brush;
|
||||||
|
|
||||||
// loading all the lumps into heap
|
// loading all the lumps into heap
|
||||||
|
@ -35,6 +35,7 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
|
|||||||
dsprite_hl_t *pinhl;
|
dsprite_hl_t *pinhl;
|
||||||
dsprite_t *pin;
|
dsprite_t *pin;
|
||||||
msprite_t *psprite;
|
msprite_t *psprite;
|
||||||
|
char poolname[MAX_VA_STRING];
|
||||||
int i, size;
|
int i, size;
|
||||||
|
|
||||||
if( loaded ) *loaded = false;
|
if( loaded ) *loaded = false;
|
||||||
@ -54,7 +55,8 @@ void Mod_LoadSpriteModel( model_t *mod, const void *buffer, qboolean *loaded, ui
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mod->mempool = Mem_AllocPool( va( "^2%s^7", mod->name ));
|
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", mod->name );
|
||||||
|
mod->mempool = Mem_AllocPool( poolname );
|
||||||
|
|
||||||
if( i == SPRITE_VERSION_Q1 || i == SPRITE_VERSION_32 )
|
if( i == SPRITE_VERSION_Q1 || i == SPRITE_VERSION_32 )
|
||||||
{
|
{
|
||||||
|
@ -848,10 +848,13 @@ Mod_LoadStudioModel
|
|||||||
*/
|
*/
|
||||||
void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
|
void Mod_LoadStudioModel( model_t *mod, const void *buffer, qboolean *loaded )
|
||||||
{
|
{
|
||||||
|
char poolname[MAX_VA_STRING];
|
||||||
studiohdr_t *phdr;
|
studiohdr_t *phdr;
|
||||||
|
|
||||||
|
Q_snprintf( poolname, sizeof( poolname ), "^2%s^7", loadmodel->name );
|
||||||
|
|
||||||
if( loaded ) *loaded = false;
|
if( loaded ) *loaded = false;
|
||||||
loadmodel->mempool = Mem_AllocPool( va( "^2%s^7", loadmodel->name ));
|
loadmodel->mempool = Mem_AllocPool( poolname );
|
||||||
loadmodel->type = mod_studio;
|
loadmodel->type = mod_studio;
|
||||||
|
|
||||||
phdr = R_StudioLoadHeader( mod, buffer );
|
phdr = R_StudioLoadHeader( mod, buffer );
|
||||||
|
@ -2639,10 +2639,14 @@ void HTTP_Run( void )
|
|||||||
|
|
||||||
if( curfile->state < HTTP_NS_RESOLVED )
|
if( curfile->state < HTTP_NS_RESOLVED )
|
||||||
{
|
{
|
||||||
|
char hostport[MAX_VA_STRING];
|
||||||
|
|
||||||
if( fResolving )
|
if( fResolving )
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
res = NET_StringToSockaddr( va( "%s:%d", curfile->server->host, curfile->server->port ), &addr, true, AF_INET );
|
Q_snprintf( hostport, sizeof( hostport ), "%s:%d", curfile->server->host, curfile->server->port );
|
||||||
|
|
||||||
|
res = NET_StringToSockaddr( hostport, &addr, true, AF_INET );
|
||||||
|
|
||||||
if( res == 2 )
|
if( res == 2 )
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user