Replace more snprintf by UTIL_Format.
This commit is contained in:
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
||||
|
||||
#endif //MEMORY_TEST
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||
|
||||
#endif // #ifndef __AMXXMODULE_H__
|
||||
|
@ -3123,3 +3123,21 @@ unsigned short FixedUnsigned16( float value, float scale )
|
||||
return (unsigned short)output;
|
||||
}
|
||||
#endif // USE_METAMOD
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
size_t len = vsnprintf(buffer, maxlength, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (len >= maxlength)
|
||||
{
|
||||
buffer[maxlength - 1] = '\0';
|
||||
return (maxlength - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
return len;
|
||||
}
|
||||
}
|
||||
|
@ -2495,4 +2495,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
|
||||
|
||||
#endif //MEMORY_TEST
|
||||
|
||||
size_t UTIL_Format(char *buffer, size_t maxlength, const char *fmt, ...);
|
||||
|
||||
#endif // #ifndef __AMXXMODULE_H__
|
||||
|
Reference in New Issue
Block a user