Browse Source

public: move va() function back to engine, it's not recommended to use in shared modules

pull/2/head
Alibek Omarov 2 years ago
parent
commit
fb6e310eab
  1. 24
      engine/common/common.c
  2. 1
      engine/common/common.h
  3. 24
      public/crtlib.c
  4. 1
      public/crtlib.h

24
engine/common/common.c

@ -151,6 +151,30 @@ int GAME_EXPORT COM_RandomLong( int lLow, int lHigh )
return lLow + (n % x); return lLow + (n % x);
} }
/*
============
va
does a varargs printf into a temp buffer,
so I don't need to have varargs versions
of all text functions.
============
*/
char *va( const char *format, ... )
{
va_list argptr;
static char string[16][MAX_VA_STRING], *s;
static int stringindex = 0;
s = string[stringindex];
stringindex = (stringindex + 1) & 15;
va_start( argptr, format );
Q_vsnprintf( s, sizeof( string[0] ), format, argptr );
va_end( argptr );
return s;
}
/* /*
=============================================================================== ===============================================================================

1
engine/common/common.h

@ -844,6 +844,7 @@ void COM_NormalizeAngles( vec3_t angles );
int COM_FileSize( const char *filename ); int COM_FileSize( const char *filename );
void COM_FreeFile( void *buffer ); void COM_FreeFile( void *buffer );
int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare ); int COM_CompareFileTime( const char *filename1, const char *filename2, int *iCompare );
char *va( const char *format, ... ) _format( 1 );
// soundlib shared exports // soundlib shared exports
qboolean S_Init( void ); qboolean S_Init( void );

24
public/crtlib.c

@ -619,30 +619,6 @@ char *Q_pretifymem( float value, int digitsafterdecimal )
return out; return out;
} }
/*
============
va
does a varargs printf into a temp buffer,
so I don't need to have varargs versions
of all text functions.
============
*/
char *va( const char *format, ... )
{
va_list argptr;
static char string[16][MAX_VA_STRING], *s;
static int stringindex = 0;
s = string[stringindex];
stringindex = (stringindex + 1) & 15;
va_start( argptr, format );
Q_vsnprintf( s, sizeof( string[0] ), format, argptr );
va_end( argptr );
return s;
}
/* /*
============ ============
COM_FileBase COM_FileBase

1
public/crtlib.h

@ -90,7 +90,6 @@ int Q_sprintf( char *buffer, const char *format, ... ) _format( 2 );
void COM_StripColors( const char *in, char *out ); void COM_StripColors( const char *in, char *out );
#define Q_memprint( val ) Q_pretifymem( val, 2 ) #define Q_memprint( val ) Q_pretifymem( val, 2 )
char *Q_pretifymem( float value, int digitsafterdecimal ); char *Q_pretifymem( float value, int digitsafterdecimal );
char *va( const char *format, ... ) _format( 1 );
void COM_FileBase( const char *in, char *out ); void COM_FileBase( const char *in, char *out );
const char *COM_FileExtension( const char *in ); const char *COM_FileExtension( const char *in );
void COM_DefaultExtension( char *path, const char *extension ); void COM_DefaultExtension( char *path, const char *extension );

Loading…
Cancel
Save