当前位置: 首页>>代码示例>>C++>>正文


C++ Q_snprintfz函数代码示例

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


在下文中一共展示了Q_snprintfz函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Q_snprintfz

char *G_Gametype_GENERIC_ScoreboardMessage( void )
{
	char entry[MAX_TOKEN_CHARS];
	size_t len;
	int i;
	edict_t	*e;
	int carrierIcon;

	*scoreboardString = 0;
	len = 0;

	Q_snprintfz( entry, sizeof(entry), "&t %i 0 0 ", TEAM_PLAYERS );
	if( SCOREBOARD_MSG_MAXSIZE - len > strlen( entry ) )
	{
		Q_strncatz( scoreboardString, entry, sizeof( scoreboardString ) );
		len = strlen( scoreboardString );
	}

	// players
	for( i = 0; i < teamlist[TEAM_PLAYERS].numplayers; i++ )
	{
		e = game.edicts + teamlist[TEAM_PLAYERS].playerIndices[i];

		if( e->s.effects & EF_CARRIER )
			carrierIcon = trap_ImageIndex( ( e->s.team == TEAM_BETA ) ? PATH_ALPHAFLAG_ICON : PATH_BETAFLAG_ICON );
		else if( e->s.effects & EF_QUAD )
			carrierIcon = trap_ImageIndex( PATH_QUAD_ICON );
		else if( e->s.effects & EF_SHELL )
			carrierIcon = trap_ImageIndex( PATH_SHELL_ICON );
		else if( e->s.effects & EF_REGEN )
			carrierIcon = trap_ImageIndex( PATH_REGEN_ICON );
		else
			carrierIcon = 0;

		Q_snprintfz( entry, sizeof( entry ), "&p %i %i %i %i %i ",
			PLAYERNUM( e ),
			e->r.client->level.stats.score,
			e->r.client->r.ping > 999 ? 999 : e->r.client->r.ping,
			carrierIcon,
			( level.ready[PLAYERNUM( e )] || GS_MatchState() >= MATCH_STATE_PLAYTIME ) ? trap_ImageIndex( PATH_VSAY_YES_ICON ) : 0
			);

		if( SCOREBOARD_MSG_MAXSIZE - len > strlen( entry ) )
		{
			Q_strncatz( scoreboardString, entry, sizeof( scoreboardString ) );
			len = strlen( scoreboardString );
		}
	}

	return scoreboardString;
}
开发者ID:codetwister,项目名称:qfusion,代码行数:51,代码来源:g_gametypes.cpp

示例2: CG_DemocamInit

/*
* CG_DemocamInit
*/
void CG_DemocamInit( void ) {
	int name_size;
	bool hassoundstream = false;

	democam_editing_mode = false;
	demo_time = 0;
	demo_initial_timestamp = 0;

	if( !cgs.demoPlaying ) {
		return;
	}

	if( !*cgs.demoName ) {
		CG_Error( "CG_DemocamInit: no demo name string\n" );
	}

	// see if there is any script for this demo, and load it
	name_size = sizeof( char ) * ( strlen( cgs.demoName ) + strlen( ".cam" ) + 1 );
	demoscriptname = ( char * )CG_Malloc( name_size );
	Q_snprintfz( demoscriptname, name_size, "%s", cgs.demoName );
	COM_ReplaceExtension( demoscriptname, ".cam", name_size );

	CG_Printf( "cam: %s\n", demoscriptname );

	// add console commands
	trap_Cmd_AddCommand( "demoEditMode", CG_DemoEditMode_Cmd_f );
	trap_Cmd_AddCommand( "demoFreeFly", CG_DemoFreeFly_Cmd_f );
	trap_Cmd_AddCommand( "camswitch", CG_CamSwitch_Cmd_f );

	if( CG_LoadRecamScriptFile( demoscriptname ) ) {
		CG_Printf( "Loaded demo cam script\n" );
	}

	// check for a sound stream file
	cgs.demoAudioStream = ( char * )CG_Malloc( name_size );
	Q_snprintfz( cgs.demoAudioStream, name_size, "%s", cgs.demoName );
	COM_ReplaceExtension( cgs.demoAudioStream, ".wav", name_size );
	if( trap_FS_FOpenFile( cgs.demoAudioStream, NULL, FS_READ ) != -1 ) {
		hassoundstream = true;
	} else {
		COM_ReplaceExtension( cgs.demoAudioStream, ".ogg", name_size );
		if( trap_FS_FOpenFile( cgs.demoAudioStream, NULL, FS_READ ) != -1 ) {
			hassoundstream = true;
		}
	}

	if( !hassoundstream ) {
		CG_Free( cgs.demoAudioStream );
		cgs.demoAudioStream = NULL;
	}
}
开发者ID:Picmip,项目名称:qfusion,代码行数:54,代码来源:cg_democams.cpp

示例3: CL_WriteServerCache

/*
* CL_WriteServerCache
*/
void CL_WriteServerCache( void )
{
	serverlist_t *server;
	int filehandle;
	char str[256];
	netadr_t adr;

	if( FS_FOpenFile( SERVERSFILE, &filehandle, FS_WRITE ) == -1 )
	{
		Com_Printf( "CL_WriteServerList: Couldn't create the cache file\n" );
		return;
	}

	Q_snprintfz( str, sizeof( str ), "// servers cache file generated by %s. Do not modify\n", APPLICATION );
	FS_Print( filehandle, str );

	FS_Print( filehandle, "master\n" );
	server = masterList;
	while( server )
	{
		if( server->lastValidPing + 7 > Com_DaysSince1900() )
		{
			if( NET_StringToAddress( server->address, &adr ) )
			{
				Q_snprintfz( str, sizeof( str ), "%s %i\n", server->address, (int)server->lastValidPing );
				FS_Print( filehandle, str );
			}
		}

		server = server->pnext;
	}

	FS_Print( filehandle, "favorites\n" );
	server = favoritesList;
	while( server )
	{
		if( server->lastValidPing + 7 > Com_DaysSince1900() )
		{
			if( NET_StringToAddress( server->address, &adr ) )
			{
				Q_snprintfz( str, sizeof( str ), "%s %i\n", server->address, (int)server->lastValidPing );
				FS_Print( filehandle, str );
			}
		}

		server = server->pnext;
	}

	FS_FCloseFile( filehandle );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:53,代码来源:cl_serverlist.c

示例4: Com_Error

/*
* Com_LoadScriptLibrary
*/
static void *Com_LoadScriptLibrary( const char *basename, void *parms )
{
	size_t file_size;
	char *file;
	void *( *GetAngelwrapAPI )(void *);
	dllfunc_t funcs[2];

	if( script_library )
		Com_Error( ERR_FATAL, "Com_LoadScriptLibrary without Com_UnloadScriptLibrary" );

	file_size = strlen( LIB_DIRECTORY "/" ) + strlen( basename ) + 1 + strlen( ARCH ) + strlen( LIB_SUFFIX ) + 1;
	file = Mem_TempMalloc( file_size );
	Q_snprintfz( file, file_size, LIB_DIRECTORY "/%s_" ARCH LIB_SUFFIX, basename );

	funcs[0].name = "GetAngelwrapAPI";
	funcs[0].funcPointer = ( void ** )&GetAngelwrapAPI;
	funcs[1].name = NULL;
	script_library = Com_LoadLibrary( file, funcs );

	Mem_TempFree( file );

	if( script_library )
		return GetAngelwrapAPI( parms );
	return NULL;
}
开发者ID:Racenet,项目名称:racesow,代码行数:28,代码来源:ascript.c

示例5: Q_snprintfz

/*
* Sys_Library_GetGameLibPath
*/
const char *Sys_Library_GetGameLibPath( const char *name, int64_t time, int randomizer )
{
	static char tempname[1024 * 10];
	Q_snprintfz( tempname, sizeof( tempname ), "%s/%s/tempmodules_%lld_%d_%d/%s", FS_RuntimeDirectory(), FS_GameDirectory(), 
		time, Sys_GetCurrentProcessId(), randomizer, name );
	return tempname;
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:10,代码来源:sdl_lib.c

示例6: G_PlayerAward

void G_PlayerAward( edict_t *ent, const char *awardMsg )
{
	edict_t *other;
	char cmd[MAX_STRING_CHARS];
	gameaward_t *ga;
	int i, size;
	score_stats_t *stats;

	if( !awardMsg || !awardMsg[0] || !ent->r.client )
		return;

	Q_snprintfz( cmd, sizeof( cmd ), "aw \"%s\"", awardMsg );
	trap_GameCmd( ent, cmd );

	if( dedicated->integer )
		G_Printf( "%s", COM_RemoveColorTokens( va( "%s receives a '%s' award.\n", ent->r.client->netname, awardMsg ) ) );

	ent->r.client->level.stats.awards++;
	teamlist[ent->s.team].stats.awards++;
	G_Gametype_ScoreEvent( ent->r.client, "award", awardMsg );

	stats = &ent->r.client->level.stats;
	if( !stats->awardAllocator )
		stats->awardAllocator = LinearAllocator( sizeof( gameaward_t ), 0, _G_LevelMalloc, _G_LevelFree );

	// ch : this doesnt work for race right?
	if( GS_MatchState() == MATCH_STATE_PLAYTIME || GS_MatchState() == MATCH_STATE_POSTMATCH )
	{
		// ch : we store this locally to send to MM
		// first check if we already have this one on the clients list
		size = LA_Size( stats->awardAllocator );
		ga = NULL;
		for( i = 0; i < size; i++ )
		{
			ga = ( gameaward_t * )LA_Pointer( stats->awardAllocator, i );
			if( !strncmp( ga->name, awardMsg, sizeof(ga->name)-1 ) )
				break;
		}

		if( i >= size )
		{
			ga = ( gameaward_t * )LA_Alloc( stats->awardAllocator );
			memset( ga, 0, sizeof(*ga) );
			ga->name = G_RegisterLevelString( awardMsg );
		}

		if( ga )
			ga->count++;
	}

	// add it to every player who's chasing this player
	for( other = game.edicts + 1; PLAYERNUM( other ) < gs.maxclients; other++ )
	{
		if( !other->r.client || !other->r.inuse || !other->r.client->resp.chase.active )
			continue;

		if( other->r.client->resp.chase.target == ENTNUM( ent ) )
			trap_GameCmd( other, cmd );
	}
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:60,代码来源:g_awards.cpp

示例7: G_ScoreboardMessage_AddChasers

void G_ScoreboardMessage_AddChasers( int entnum, int entnum_self )
{
	char entry[MAX_TOKEN_CHARS];
	int i;
	edict_t *e;
	size_t len;

	len = strlen( scoreboardString );
	if( !len )
		return;

	// add personal spectators
	Q_strncpyz( entry, "&y ", sizeof( entry ) );
	ADD_SCOREBOARD_ENTRY( scoreboardString, len, entry );

	for( i = 0; i < teamlist[TEAM_SPECTATOR].numplayers; i++ )
	{
		e = game.edicts + teamlist[TEAM_SPECTATOR].playerIndices[i];

		if( ENTNUM( e ) == entnum_self )
			continue;

		if( e->r.client->connecting || trap_GetClientState( PLAYERNUM( e ) ) < CS_SPAWNED )
			continue;

		if( !e->r.client->resp.chase.active || e->r.client->resp.chase.target != entnum )
			continue;

		Q_snprintfz( entry, sizeof( entry ), "%i ", PLAYERNUM( e ) );
		ADD_SCOREBOARD_ENTRY( scoreboardString, len, entry );
	}
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:32,代码来源:p_hud.cpp

示例8: R_PrintGLExtensionsString

/*
* R_PrintGLExtensionsString
*/
static void R_PrintGLExtensionsString( const char *name, const char *str )
{
    size_t len, p;

    Com_Printf( "%s: ", name );

    if( str && *str )
    {
        for( len = strlen( str ), p = 0; p < len;  )
        {
            char chunk[512];

            Q_snprintfz( chunk, sizeof( chunk ), "%s", str + p );
            p += strlen( chunk );

            Com_Printf( "%s", chunk );
        }
    }
    else
    {
        Com_Printf( "none" );
    }

    Com_Printf( "\n" );
}
开发者ID:Turupawn,项目名称:DogeWarsow,代码行数:28,代码来源:r_register.c

示例9: CG_SC_ChannelAdd

/*
* CG_SC_ChannelAdd
*/
static void CG_SC_ChannelAdd( void )
{
	char menuparms[MAX_STRING_CHARS];

	Q_snprintfz( menuparms, sizeof( menuparms ), "menu_tvchannel_add %s\n", trap_Cmd_Args() );
	trap_Cmd_ExecuteText( EXEC_NOW, menuparms );
}
开发者ID:hettoo,项目名称:racesow,代码行数:10,代码来源:cg_cmds.c

示例10: Q_strncpyz

/*
* CG_SC_RaceDemoName
*/
static const char *CG_SC_RaceDemoName( unsigned int raceTime )
{
	unsigned int hour, min, sec, milli;

	static char name[MAX_STRING_CHARS];
	char mapname[MAX_CONFIGSTRING_CHARS];

	milli = raceTime;

	hour = milli/3600000;
	milli -= hour*3600000;
	min = milli/60000;
	milli -= min*60000;
	sec = milli/1000;
	milli -= sec*1000;

	// lowercase mapname
	Q_strncpyz( mapname, cgs.configStrings[CS_MAPNAME], sizeof( mapname ) );
	Q_strlwr( mapname );

	// make file path
	// "gametype/map/map_time_random"
	Q_snprintfz( name, sizeof( name ), "%s/%s/%s_%02u-%02u-%02u-%003u_%04i",
		gs.gametypeName,
		mapname,
		mapname, hour, min, sec, milli,	(int)brandom( 0, 9999 )
		);

	return name;
}
开发者ID:hettoo,项目名称:racesow,代码行数:33,代码来源:cg_cmds.c

示例11: Con_DrawInput

/*
* Con_DrawInput
*
* The input line scrolls horizontally if typing goes beyond the right edge
*/
static void Con_DrawInput( int vislines )
{
    char draw_search_text[MAXCMDLINE*2+4];
    const char *text = key_lines[edit_line];
    int smallCharHeight = SCR_strHeight( cls.fontSystemSmall );
    int text_y = vislines - 14 - smallCharHeight;
    const int left_margin = 8, right_margin = 8;
    int promptwidth = SCR_strWidth( "]", cls.fontSystemSmall, 1 );
    int cursorwidth = SCR_strWidth( "_", cls.fontSystemSmall, 1 );
    int input_width = viddef.width - left_margin - right_margin;
    int prewidth;	// width of input line before cursor

    if( cls.key_dest != key_console )
        return;

    if( search_text[0] ) {
        text = draw_search_text;
        Q_snprintfz( draw_search_text, sizeof( draw_search_text ), "%s : %s", key_lines[edit_line], search_text );
    }

    prewidth = SCR_strWidth( text, cls.fontSystemSmall, key_linepos );

    // don't let the cursor go beyond the left screen edge
    clamp_high( input_prestep, prewidth - promptwidth);
    // don't let it go beyond the right screen edge
    clamp_low( input_prestep, prewidth - ( input_width - cursorwidth ) );

    SCR_DrawClampString( left_margin - input_prestep,
                         text_y, text, left_margin, text_y,
                         viddef.width - right_margin, viddef.height, cls.fontSystemSmall, colorWhite );

    if( (int)( cls.realtime>>8 )&1 )
        SCR_DrawRawChar( left_margin + prewidth - input_prestep, text_y, '_',
                         cls.fontSystemSmall, colorWhite );
}
开发者ID:Turupawn,项目名称:DogeWarsow,代码行数:40,代码来源:console.c

示例12: GLimp_CreateWindow

static void GLimp_CreateWindow( void )
{
	HWND parentHWND = glw_state.parenthWnd;
#ifdef WITH_UTF8
	WNDCLASSW wc;
#else
	WNDCLASS  wc;
#endif

	Q_snprintfz( glw_state.windowClassName, sizeof( glw_state.windowClassName ), "%sWndClass", glw_state.applicationName );
#ifdef WITH_UTF8
	MultiByteToWideChar( CP_UTF8, 0, glw_state.windowClassName, -1, glw_state.windowClassNameW, sizeof( glw_state.windowClassNameW ) );
	glw_state.windowClassNameW[sizeof( glw_state.windowClassNameW )/sizeof( glw_state.windowClassNameW[0] ) - 1] = 0;
#endif

	/* Register the frame class */
	wc.style         = 0;
	wc.lpfnWndProc   = (WNDPROC)glw_state.wndproc;
	wc.cbClsExtra    = 0;
	wc.cbWndExtra    = 0;
	wc.hInstance     = glw_state.hInstance;
	wc.hIcon         = LoadIcon( glw_state.hInstance, MAKEINTRESOURCE( glw_state.applicationIconResourceID ) );
	wc.hCursor       = LoadCursor( NULL, IDC_ARROW );
	wc.hbrBackground = (HBRUSH)GetStockObject( BLACK_BRUSH );
	wc.lpszMenuName  = 0;
#ifdef WITH_UTF8
	wc.lpszClassName = (LPCWSTR)glw_state.windowClassNameW;
	if( !RegisterClassW( &wc ) )
#else
	wc.lpszClassName = (LPCSTR)glw_state.windowClassName;
	if( !RegisterClass( &wc ) )
#endif
		Sys_Error( "Couldn't register window class" );

	glw_state.hWnd =
#ifdef WITH_UTF8
		CreateWindowExW(
#else
		CreateWindowEx(
#endif
	        0,
#ifdef WITH_UTF8
	        glw_state.windowClassNameW,
	        glw_state.applicationNameW,
#else
	        glw_state.windowClassName,
	        glw_state.applicationName,
#endif
			0,
	        0, 0, 0, 0,
	        parentHWND,
	        NULL,
	        glw_state.hInstance,
	        NULL );

	if( !glw_state.hWnd )
		Sys_Error( "Couldn't create window" );

	GLimp_SetWindowSize( glConfig.fullScreen, glConfig.borderless );
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:60,代码来源:win_glw.c

示例13: Mode

void VideoDataSource::updateVideoModeList( void )
{
	qboolean qwideScreen;
	char resolution[64];
	int i, width, height;

	// lists must be clear before
	modesList.clear();

	// native desktop resolution
	modesList.push_back( Mode( toString( -2 ), "desktop" ) );

    for( i = 0; trap::VID_GetModeInfo( &width, &height, &qwideScreen, i ); i++ ) ;
	for( i = 0; trap::VID_GetModeInfo( &width, &height, &qwideScreen, i ); i++ )
    {
		Q_snprintfz( resolution, sizeof( resolution ), "%s%i x %i", ( qwideScreen ? "W " : "" ), width, height );

		// save resolution and index
		Mode m( toString( i ), resolution );
		modesList.push_back( m );
    }

	// custom resolution
	modesList.push_back( Mode( toString( -1 ), "custom" ) );

	// notify updates
	int size = modesList.size();
	for( int i = 0; i < size; i++ )
		NotifyRowAdd( TABLE_NAME, i, 1 );
}
开发者ID:Kaperstone,项目名称:warsow,代码行数:30,代码来源:ui_video_datasource.cpp

示例14: FormatFloat

static std::string FormatFloat( double value, const std::string &options, size_t width, size_t precision )
{
    bool leftJustify = options.find("l") != std::string::npos;
    bool padWithZero = options.find("0") != std::string::npos;
    bool alwaysSign  = options.find("+") != std::string::npos;
    bool spaceOnSign = options.find(" ") != std::string::npos;
    bool expSmall    = options.find("e") != std::string::npos;
    bool expLarge    = options.find("E") != std::string::npos;

    std::string fmt = "%";
    if( leftJustify ) fmt += "-";
    if( alwaysSign ) fmt += "+";
    if( spaceOnSign ) fmt += " ";
    if( padWithZero ) fmt += "0";

    fmt += "*.*";

    if( expSmall ) fmt += "e";
    else if( expLarge ) fmt += "E";
    else fmt += "f";

    std::string buf;
    buf.resize(width+precision+50);

    Q_snprintfz(&buf[0], buf.size(), fmt.c_str(), width, precision, value);
    buf.resize(strlen(&buf[0]));

    return buf;
}
开发者ID:Clever-Boy,项目名称:qfusion,代码行数:29,代码来源:addon_stringutils.cpp

示例15: CL_PingServer_f

/*
* CL_PingServer_f
*/
void CL_PingServer_f( void )
{
	char *address_string;
	char requestString[64];
	netadr_t adr;
	serverlist_t *pingserver;
	socket_t *socket;

	if( Cmd_Argc() < 2 )
		Com_Printf( "Usage: pingserver [ip:port]\n" );

	address_string = Cmd_Argv( 1 );

	if( !NET_StringToAddress( address_string, &adr ) )
		return;

	pingserver = CL_ServerFindInList( masterList, address_string );
	if( !pingserver )
		pingserver = CL_ServerFindInList( favoritesList, address_string );
	if( !pingserver )
		return;

	// never request a second ping while awaiting for a ping reply
	if( pingserver->pingTimeStamp + SERVER_PINGING_TIMEOUT > Sys_Milliseconds() )
		return;

	pingserver->pingTimeStamp = Sys_Milliseconds();

	Q_snprintfz( requestString, sizeof( requestString ), "info %i %s %s", SERVERBROWSER_PROTOCOL_VERSION,
		filter_allow_full ? "full" : "",
		filter_allow_empty ? "empty" : "" );

	socket = ( adr.type == NA_IP6 ? &cls.socket_udp6 : &cls.socket_udp );
	Netchan_OutOfBandPrint( socket, &adr, requestString );
}
开发者ID:codetwister,项目名称:qfusion,代码行数:38,代码来源:cl_serverlist.c


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