• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ Q_vsnprintf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中Q_vsnprintf函数的典型用法代码示例。如果您正苦于以下问题:C++ Q_vsnprintf函数的具体用法?C++ Q_vsnprintf怎么用?C++ Q_vsnprintf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了Q_vsnprintf函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
	}
}
开发者ID:sxweet,项目名称:etlegacy,代码行数:54,代码来源:sv_main.c


示例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);
  }
}
开发者ID:Call-of-Duty-Scripts,项目名称:CoD4x1.8_Server_Pub,代码行数:16,代码来源:misc.c


示例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);
}
开发者ID:n1ckn4m3,项目名称:kmquake2megacoop,代码行数:19,代码来源:acebot_cmds.c


示例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
	}
}
开发者ID:eezstreet,项目名称:JediKnightGalaxies,代码行数:16,代码来源:sv_init.cpp


示例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
}
开发者ID:boutetnico,项目名称:ETrun,代码行数:16,代码来源:q_shared.c


示例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
	}
开发者ID:AeroHand,项目名称:dota2-lua-engine,代码行数:16,代码来源:filesystem_init.cpp


示例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);
}
开发者ID:Danmer,项目名称:uberdemotools,代码行数:16,代码来源:context.cpp


示例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);
}
开发者ID:mefisto2009,项目名称:rehlds,代码行数:17,代码来源:host.cpp


示例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);
}
开发者ID:ptitSeb,项目名称:gravitybone-pandora,代码行数:16,代码来源:vid_so.c


示例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);
  }
}
开发者ID:Call-of-Duty-Scripts,项目名称:CoD4x1.8_Server_Pub,代码行数:16,代码来源:misc.c


示例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 */
		}
	}
}
开发者ID:ArkyRomania,项目名称:ufoai,代码行数:51,代码来源:common.cpp


示例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");
	}
}
开发者ID:ArkyRomania,项目名称:ufoai,代码行数:51,代码来源:common.cpp


示例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 );
		}
	}
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:47,代码来源:GameStats.cpp


示例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 ];
}
开发者ID:FWGS,项目名称:regamelite,代码行数:18,代码来源:shared_util.cpp


示例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);
	}
}
开发者ID:mefisto2009,项目名称:rehlds,代码行数:18,代码来源:host.cpp


示例16: Com_DPrintf

void QDECL Com_DPrintf(const char *fmt, ...) {
	va_list argptr;
	char msg[MAXPRINTMSG];
	int developer;

	developer = trap_Cvar_VariableValue("developer");

	if (!developer) {
		return;
	}

	va_start(argptr, fmt);
	Q_vsnprintf(msg, sizeof(msg), fmt, argptr);
	va_end(argptr);

	Com_Printf("%s", msg);
}
开发者ID:ioid3-games,项目名称:ioid3-rtcw,代码行数:17,代码来源:ui_atoms.c


示例17: va

/**
 * @brief does a varargs printf into a temp buffer, so I don't need to have
 * varargs versions of all text functions.
 */
const char* va (const char* format, ...)
{
	va_list argptr;
	/* in case va is called by nested functions */
	static char string[16][VA_BUFSIZE];
	static unsigned int index = 0;
	char* buf;

	buf = string[index & 0x0F];
	index++;

	va_start(argptr, format);
	Q_vsnprintf(buf, VA_BUFSIZE, format, argptr);
	va_end(argptr);

	return buf;
}
开发者ID:Isaacssv552,项目名称:ufoai,代码行数:21,代码来源:shared.cpp


示例18: DrawStringForTime

	int DrawStringForTime( float flTime, vgui::HFont hCustomFont, int x, int y, int r, int g, int b, int a, const char *fmt, int messageID, ... )
	{
		va_list argptr;
		char data[ MAX_MESSAGECHARSPANEL_LEN ];
		int len;

		va_start(argptr, messageID);
		len = Q_vsnprintf(data, sizeof( data ), fmt, argptr);
		va_end(argptr);

		data[ MAX_MESSAGECHARSPANEL_LEN - 1 ] = 0;

		if ( !messageCharsPanel )
			return x;

		return messageCharsPanel->AddText( flTime, hCustomFont, x, y, r, g, b, a, data, messageID );
	}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:17,代码来源:vgui_messagechars.cpp


示例19: PRINTF_LIKE

/*
=================
PC_SourceError
=================
*/
void PRINTF_LIKE(2) PC_SourceError( int handle, const char *format, ... )
{
	int         line;
	char        filename[ 128 ];
	va_list     argptr;
	static char string[ 4096 ];

	va_start( argptr, format );
	Q_vsnprintf( string, sizeof( string ), format, argptr );
	va_end( argptr );

	filename[ 0 ] = '\0';
	line = 0;
	trap_Parse_SourceFileAndLine( handle, filename, &line );

	Com_Printf( S_ERROR "%s, line %d: %s\n", filename, line, string );
}
开发者ID:BlueMustache,项目名称:Unvanquished,代码行数:22,代码来源:cg_parseutils.cpp


示例20: NET_OutOfBandPrint

__cdecl void QDECL NET_OutOfBandPrint( netsrc_t sock, netadr_t *adr, const char *format, ... ) {
	va_list		argptr;
	char		string[MAX_MSGLEN];

	// set the header
	string[0] = -1;
	string[1] = -1;
	string[2] = -1;
	string[3] = -1;

	va_start( argptr, format );
	Q_vsnprintf( string+4, sizeof(string)-4, format, argptr );
	va_end( argptr );

	// send the datagram
	NET_SendPacket( sock, strlen( string ), string, adr );
}
开发者ID:BraXi,项目名称:CoD4X18-Server,代码行数:17,代码来源:netchan.c



注:本文中的Q_vsnprintf函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ Q_vsnprintfz函数代码示例发布时间:2022-05-30
下一篇:
C++ Q_strrchr函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap