本文整理汇总了C++中Q_vsnprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_vsnprintf函数的具体用法?C++ Q_vsnprintf怎么用?C++ Q_vsnprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了Q_vsnprintf函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SV_SendServerCommand
/**
* @brief Sends a reliable command string to be interpreted by the client game
* module: "cp", "print", "chat", etc
*
* A NULL client will broadcast to all clients
*/
void QDECL SV_SendServerCommand(client_t *cl, const char *fmt, ...)
{
va_list argptr;
byte message[MAX_MSGLEN];
client_t *client;
int j;
va_start(argptr, fmt);
Q_vsnprintf((char *)message, sizeof(message), fmt, argptr);
va_end(argptr);
// do not forward server command messages that would be too big to clients
// ( q3infoboom / q3msgboom stuff )
// see http://aluigi.altervista.org/adv/q3msgboom-adv.txt
if (strlen((char *)message) > 1022)
{
SV_WriteAttackLog("Warning: q3infoboom/q3msgboom exploit attack.\n"); // FIXME: add client slot
return;
}
if (cl != NULL)
{
SV_AddServerCommand(cl, (char *)message);
return;
}
// hack to echo broadcast prints to console
if (com_dedicated->integer && !strncmp((char *)message, "print", 5))
{
Com_Printf("broadcast: %s\n", SV_ExpandNewlines((char *)message));
}
// send the data to all relevent clients
for (j = 0, client = svs.clients; j < sv_maxclients->integer ; j++, client++)
{
if (client->state < CS_PRIMED)
{
continue;
}
// don't need to send messages to AI
if (client->gentity && (client->gentity->r.svFlags & SVF_BOT))
{
continue;
}
SV_AddServerCommand(client, (char *)message);
}
}
示例2: dMessage
void dMessage (int num, const char *msg, ...)
{
va_list ap;
char buf[2048];
va_start (ap, msg);
Q_vsnprintf(buf, sizeof(buf), msg, ap);
va_end(ap);
if(num)
{
Com_PrintError("\nODE Message %d: %s\n", num, buf);
}else{
Com_PrintError("\nODE Message: %s\n", buf);
}
}
示例3: safe_centerprintf
///////////////////////////////////////////////////////////////////////
// botsafe centerprintf
///////////////////////////////////////////////////////////////////////
void safe_centerprintf (edict_t *ent, char *fmt, ...)
{
char bigbuffer[0x10000];
va_list argptr;
int len;
if (!ent->inuse || ent->is_bot)
return;
va_start (argptr, fmt);
len = Q_vsnprintf (bigbuffer, sizeof(bigbuffer), fmt, argptr);
va_end (argptr);
gi.centerprintf(ent, "%s", bigbuffer);
//gi.centerprintf(ent, bigbuffer);
}
示例4: SV_RefPrintf
void QDECL SV_RefPrintf( int print_level, const char *fmt, ...) {
va_list argptr;
char msg[MAXPRINTMSG];
va_start (argptr,fmt);
Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
va_end (argptr);
if ( print_level == PRINT_ALL ) {
Com_Printf ("%s", msg);
} else if ( print_level == PRINT_WARNING ) {
Com_Printf (S_COLOR_YELLOW "%s", msg); // yellow
} else if ( print_level == PRINT_DEVELOPER ) {
Com_DPrintf (S_COLOR_RED "%s", msg); // red
}
}
示例5: Com_Printf
void QDECL Com_Printf(const char *msg, ...) {
va_list argptr;
char text[1024];
va_start(argptr, msg);
Q_vsnprintf(text, sizeof (text), msg, argptr);
va_end(argptr);
#ifdef CGAMEDLL
CG_Printf("%s", text);
#elif defined GAMEDLL
G_Printf("%s", text);
#else
trap_Print(va("%s", text));
#endif
}
示例6: SetValue
void SetValue( const char *pValue, ... )
{
char valueString[4096];
va_list marker;
va_start( marker, pValue );
Q_vsnprintf( valueString, sizeof( valueString ), pValue, marker );
va_end( marker );
#ifdef WIN32
char str[4096];
Q_snprintf( str, sizeof( str ), "%s=%s", m_pVarName, valueString );
_putenv( str );
#else
setenv( m_pVarName, valueString, 1 );
#endif
}
示例7: va_start
void udtContext::LogError(UDT_PRINTF_FORMAT_ARG const char* format, ...) const
{
if(!_messageCallback)
{
return;
}
char msg[MAXPRINTMSG];
va_list argptr;
va_start(argptr, format);
Q_vsnprintf(msg, sizeof(msg) - 1, format, argptr);
va_end(argptr);
(*_messageCallback)(2, msg);
}
示例8: Host_ClientCommands
/* <35f03> ../engine/host.c:646 */
void Host_ClientCommands(const char *fmt, ...)
{
va_list argptr;
char string[1024];
va_start(argptr, fmt);
if (!host_client->fakeclient)
{
Q_vsnprintf(string, sizeof(string), fmt, argptr);
string[sizeof(string) - 1] = 0;
MSG_WriteByte(&host_client->netchan.message, svc_stufftext);
MSG_WriteString(&host_client->netchan.message, string);
}
va_end(argptr);
}
示例9: VID_Printf
void VID_Printf (int print_level, char *fmt, ...)
{
va_list argptr;
char msg[MAXPRINTMSG];
// static qboolean inupdate;
va_start (argptr, fmt);
// vsprintf (msg, fmt, argptr);
Q_vsnprintf (msg, sizeof(msg), fmt, argptr);
va_end (argptr);
if (print_level == PRINT_ALL)
Com_Printf ("%s", msg);
else
Com_DPrintf ("%s", msg);
}
示例10: dError
void dError (int num, const char *msg, ...)
{
va_list ap;
char buf[2048];
va_start (ap, msg);
Q_vsnprintf(buf, sizeof(buf), msg, ap);
va_end(ap);
if(num)
{
Com_Error(ERR_FATAL, "\nODE Error %d: %s\n", num, buf);
}else{
Com_Error(ERR_FATAL, "\nODE Error: %s\n", buf);
}
}
示例11: Com_vPrintf
/**
* @note Both client and server can use this, and it will output
* to the appropriate place.
*/
void Com_vPrintf (const char* fmt, va_list ap)
{
char msg[MAXPRINTMSG];
Q_vsnprintf(msg, sizeof(msg), fmt, ap);
/* redirect the output? */
if (rd_buffer) {
if ((strlen(msg) + strlen(rd_buffer)) > (rd_buffersize - 1)) {
NET_OOB_Printf(rd_stream, SV_CMD_PRINT "\n%s", rd_buffer);
rd_buffer[0] = '\0';
}
Q_strcat(rd_buffer, sizeof(char) * rd_buffersize, "%s", msg);
return;
}
Con_Print(msg);
/* also echo to debugging console */
Sys_ConsoleOutput(msg);
/* logfile */
if (logfile_active && logfile_active->integer) {
if (!logfile.f) {
if (logfile_active->integer > 2)
FS_OpenFile(consoleLogName, &logfile, FILE_APPEND);
else
FS_OpenFile(consoleLogName, &logfile, FILE_WRITE);
}
if (logfile.f) {
/* strip color codes */
const char* output = msg;
if (output[strlen(output) - 1] == '\n') {
char timestamp[40];
Com_MakeTimestamp(timestamp, sizeof(timestamp));
FS_Write(timestamp, strlen(timestamp), &logfile);
FS_Write(" ", 1, &logfile);
}
FS_Write(output, strlen(output), &logfile);
if (logfile_active->integer > 1)
fflush(logfile.f); /* force it to save every time */
}
}
}
示例12: Com_Error
/**
* @note Both client and server can use this, and it will
* do the appropriate things.
*/
void Com_Error (int code, const char* fmt, ...)
{
va_list argptr;
static char msg[MAXPRINTMSG];
static bool recursive = false;
if (recursive)
Sys_Error("recursive error after: %s", msg);
recursive = true;
va_start(argptr, fmt);
Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
va_end(argptr);
switch (code) {
case ERR_DISCONNECT:
Com_Printf("%s\n", msg);
CL_Drop();
recursive = false;
Com_Drop();
case ERR_DROP:
Com_Printf("********************\n");
Com_Printf("ERROR: %s\n", msg);
Com_Printf("********************\n");
Sys_Backtrace();
SV_Shutdown("Server crashed.", false);
CL_Drop();
recursive = false;
Com_Drop();
default:
Com_Printf("%s\n", msg);
SV_Shutdown("Server fatal crashed", false);
/* send an receive net messages a last time */
NET_Wait(0);
FS_CloseFile(&logfile);
if (pipefile.f != nullptr) {
FS_CloseFile(&pipefile);
FS_RemoveFile(va("%s/%s", FS_Gamedir(), pipefile.name));
}
CL_Shutdown();
Qcommon_Shutdown();
Sys_Error("Shutdown");
}
}
示例13: va_start
void CBaseGameStats::StatsLog( char const *fmt, ... )
{
if ( !m_bLogging && !m_bLoggingToFile )
return;
char buf[ 2048 ];
va_list argptr;
va_start( argptr, fmt );
Q_vsnprintf( buf, sizeof( buf ), fmt, argptr );
va_end( argptr );
// Prepend timestamp and spew it
// Prepend the time.
time_t aclock;
time( &aclock );
struct tm *newtime = localtime( &aclock );
char timeString[ 128 ];
Q_strncpy( timeString, asctime( newtime ), sizeof( timeString ) );
// Get rid of the \n.
char *pEnd = strstr( timeString, "\n" );
if ( pEnd )
{
*pEnd = 0;
}
if ( m_bLogging )
{
DevMsg( "[GS %s - %7.2f] %s", timeString, gpGlobals->realtime, buf );
}
if ( m_bLoggingToFile )
{
if ( FILESYSTEM_INVALID_HANDLE == g_LogFileHandle )
{
g_LogFileHandle = filesystem->Open( GAMESTATS_LOG_FILE, "a", GAMESTATS_PATHID );
}
if ( FILESYSTEM_INVALID_HANDLE != g_LogFileHandle )
{
filesystem->FPrintf( g_LogFileHandle, "[GS %s - %7.2f] %s", timeString, gpGlobals->realtime, buf );
filesystem->Flush( g_LogFileHandle );
}
}
}
示例14: va_start
/* <2d4b0a> ../game_shared/shared_util.cpp:68 */
char *SharedVarArgs(char *format, ...)
{
va_list argptr;
const int BufLen = 1024;
const int NumBuffers = 4;
static char string[ NumBuffers ][ BufLen ];
static int curstring = 0;
curstring = (curstring + 1) % NumBuffers;
va_start(argptr, format);
Q_vsnprintf(string[ curstring ], BufLen, format, argptr);
va_end(argptr);
return string[ curstring ];
}
示例15: SV_ClientPrintf
/* <35e4e> ../engine/host.c:594 */
void SV_ClientPrintf(const char *fmt, ...)
{
va_list va;
char string[1024];
if (!host_client->fakeclient)
{
va_start(va, fmt);
Q_vsnprintf(string, ARRAYSIZE(string) - 1, fmt, va);
va_end(va);
string[ARRAYSIZE(string) - 1] = 0;
MSG_WriteByte(&host_client->netchan.message, svc_print);
MSG_WriteString(&host_client->netchan.message, string);
}
}