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; }
/* * 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; } }
/* * 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 ); }
/* * CG_WeaponModelUpdateRegistration */ static bool CG_WeaponModelUpdateRegistration( weaponinfo_t *weaponinfo, char *filename ) { int p; char scratch[MAX_QPATH]; for( p = 0; p < WEAPMODEL_PARTS; p++ ) { // md3 if( !weaponinfo->model[p] ) { Q_snprintfz( scratch, sizeof( scratch ), "models/weapons/%s%s.md3", filename, wmPartSufix[p] ); weaponinfo->model[p] = CG_RegisterModel( scratch ); } // skm if( !weaponinfo->model[p] ) { Q_snprintfz( scratch, sizeof( scratch ), "models/weapons/%s%s.iqm", filename, wmPartSufix[p] ); weaponinfo->model[p] = CG_RegisterModel( scratch ); } } // load failed if( !weaponinfo->model[HAND] ) { weaponinfo->name[0] = 0; for( p = 0; p < WEAPMODEL_PARTS; p++ ) weaponinfo->model[p] = NULL; return false; } // load animation script for the hand model Q_snprintfz( scratch, sizeof( scratch ), "models/weapons/%s.cfg", filename ); if( !CG_vWeap_ParseAnimationScript( weaponinfo, scratch ) ) CG_CreateHandDefaultAnimations( weaponinfo ); //create a tag_projection from tag_flash, to position fire effects CG_BuildProjectionOrigin( weaponinfo ); Vector4Set( weaponinfo->outlineColor, 0, 0, 0, 255 ); if( cg_debugWeaponModels->integer ) CG_Printf( "%sWEAPmodel: Loaded successful%s\n", S_COLOR_BLUE, S_COLOR_WHITE ); Q_strncpyz( weaponinfo->name, filename, sizeof( weaponinfo->name ) ); return true; }
/* * 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; }
/* * 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; }
/* * CG_Democam_ImportCams_f */ void CG_Democam_ImportCams_f( void ) { int name_size; char *customName; if( trap_Cmd_Argc() < 2 ) { CG_Printf( "Usage: importcams <filename> (relative to demos directory)\n" ); return; } // see if there is any script for this demo, and load it name_size = sizeof( char ) * ( strlen( "demos/" ) + strlen( trap_Cmd_Argv( 1 ) ) + strlen( ".cam" ) + 1 ); customName = ( char * )CG_Malloc( name_size ); Q_snprintfz( customName, name_size, "demos/%s", trap_Cmd_Argv( 1 ) ); COM_ReplaceExtension( customName, ".cam", name_size ); if( CG_LoadRecamScriptFile( customName ) ) { CG_Printf( "cam script imported\n" ); } else { CG_Printf( "CG_Democam_ImportCams_f: no valid file found\n" ); } }
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 ); } }
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 ); } }
/* * 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" ); }
/* * 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 ); }
/* * 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; }
/* * 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 ); }
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 ); }
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 ); }
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; }
/* * 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 ); }
static std::string FormatInt( asINT64 value, const std::string &options, asUINT width ) { 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 hexSmall = options.find("h") != std::string::npos; bool hexLarge = options.find("H") != std::string::npos; std::string fmt = "%"; if( leftJustify ) fmt += "-"; if( alwaysSign ) fmt += "+"; if( spaceOnSign ) fmt += " "; if( padWithZero ) fmt += "0"; fmt += "*"; if( hexSmall ) fmt += "x"; else if( hexLarge ) fmt += "X"; else fmt += "d"; std::string buf; buf.resize(width+20); Q_snprintfz(&buf[0], buf.size(), fmt.c_str(), width, value); buf.resize(strlen(&buf[0])); return buf; }
static const char *StatQuery_JsonToString( cJSON *obj ) { static char buffer[128]; if( !obj ) { Com_Printf( S_COLOR_YELLOW "StatQuery_JsonToString: obj == null\n" ); buffer[0] = '\0'; return buffer; } switch( obj->type ) { case cJSON_String: return obj->valuestring; case cJSON_Number: Q_snprintfz( buffer, sizeof( buffer ), "%f", obj->valuedouble ); break; case cJSON_True: return "1"; case cJSON_False: return "0"; default: Com_Printf( "StatQuery: Couldnt cast JSON type %s to string (object name %s)\n", StatQuery_JsonTypeToString( obj->type ), obj->string != 0 ? obj->string : "" ); buffer[0] = '\0'; } return buffer; }
/* * SV_SetServerConfigStrings */ void SV_SetServerConfigStrings( void ) { Q_snprintfz( sv.configstrings[CS_MAXCLIENTS], sizeof( sv.configstrings[0] ), "%i", sv_maxclients->integer ); Q_strncpyz( sv.configstrings[CS_TVSERVER], "0", sizeof( sv.configstrings[0] ) ); Q_strncpyz( sv.configstrings[CS_HOSTNAME], Cvar_String( "sv_hostname" ), sizeof( sv.configstrings[0] ) ); Q_strncpyz( sv.configstrings[CS_MODMANIFEST], Cvar_String( "sv_modmanifest" ), sizeof( sv.configstrings[0] ) ); }
/* ============== CG_DrawHUDNumeric ============== */ void CG_DrawHUDNumeric( int x, int y, int align, float *color, int charwidth, int charheight, int value ) { char num[16], *ptr; int length; int frame; // draw number string Q_snprintfz( num, sizeof( num ), "%i", value ); length = strlen( num ); if( !length ) return; x = CG_HorizontalAlignForWidth( x, align, charwidth * length ); y = CG_VerticalAlignForHeight( y, align, charheight ); ptr = num; while( *ptr && length ) { if( *ptr == '-' ) frame = STAT_MINUS; else frame = *ptr - '0'; trap_R_DrawStretchPic( x, y, charwidth, charheight, 0, 0, 1, 1, color, CG_MediaShader( cgs.media.sbNums[frame] ) ); x += charwidth; ptr++; length--; } }
static void MapsList_UpdateButton( menucommon_t *menuitem ) { m_listitem_t *item; menuitem->localdata[1] = menuitem->localdata[0] + mapList_selpos; item = UI_FindItemInScrollListWithId( &mapList, menuitem->localdata[1] ); if( item ) { if( menuitem->localdata[1] == mapList_cur_idx ) Q_snprintfz( menuitem->title, MAX_STRING_CHARS, "%s%s", S_COLOR_RED, item->name ); else Q_snprintfz( menuitem->title, MAX_STRING_CHARS, item->name ); } else Q_snprintfz( menuitem->title, MAX_STRING_CHARS, "" ); }
static asstring_t *objectString_AddString( asstring_t *first, const char *second, size_t seclen ) { asstring_t *self = objectString_FactoryBuffer( NULL, first->len + seclen ); Q_snprintfz( self->buffer, self->size, "%s%s", first->buffer, second ); return self; }
/* * R_StartCinematic */ unsigned int R_StartCinematic( const char *arg ) { char uploadName[128]; size_t name_size; r_cinhandle_t *handle, *hnode, *next; struct cinematics_s *cin; qboolean yuv; // find cinematics with the same name hnode = &r_cinematics_headnode; for( handle = hnode->prev; handle != hnode; handle = next ) { next = handle->prev; assert( handle->cin ); // reuse if( !Q_stricmp( handle->name, arg ) ) return handle->id; } // open the file, read header, etc cin = ri.CIN_Open( arg, ri.Sys_Milliseconds(), qtrue, &yuv, NULL ); // take a free cinematic handle if possible if( !r_free_cinematics || !cin ) return 0; handle = r_free_cinematics; r_free_cinematics = handle->next; // copy name name_size = strlen( arg ) + 1; handle->name = R_Malloc( name_size ); memcpy( handle->name, arg, name_size ); // copy upload name Q_snprintfz( uploadName, sizeof( uploadName ), "***r_cinematic%i***", handle->id-1 ); name_size = strlen( uploadName ) + 1; handle->uploadName = R_Malloc( name_size ); memcpy( handle->uploadName, uploadName, name_size ); handle->cin = cin; handle->new_frame = qfalse; handle->yuv = yuv; handle->image = NULL; handle->yuv_images[0] = handle->yuv_images[1] = handle->yuv_images[2] = NULL; handle->registrationSequence = rsh.registrationSequence; handle->pic = NULL; handle->cyuv = NULL; // put handle at the start of the list handle->prev = &r_cinematics_headnode; handle->next = r_cinematics_headnode.next; handle->next->prev = handle; handle->prev->next = handle; return handle->id; }
static void Say_Team_Drop( edict_t *who, char *buf, int buflen, const char *current_color ) { const gsitem_t *item = who->r.client->teamstate.last_drop_item; if( !item ) buf[0] = 0; else Q_snprintfz( buf, buflen, "%s%s%s", ( item->color ? item->color : "" ), item->shortname, current_color ); }
/* * RB_StatsMessage */ void RB_StatsMessage( char *msg, size_t size ) { Q_snprintfz( msg, size, "%4i verts %4i tris\n" "%4i draws %4i binds %4i progs", rb.stats.c_totalVerts, rb.stats.c_totalTris, rb.stats.c_totalDraws, rb.stats.c_totalBinds, rb.stats.c_totalPrograms ); }
/* * RB_StatsMessage */ void RB_StatsMessage( char *msg, size_t size ) { Q_snprintfz( msg, size, "%4i verts %4i tris\n" "%4i draws", rb.stats.c_totalVerts, rb.stats.c_totalTris, rb.stats.c_totalDraws ); }
/* * G_StatsMessage * * Generates stats message for the entity * The returned string must be freed by the caller using G_Free * Note: This string must never contain " characters */ char *G_StatsMessage( edict_t *ent ) { gclient_t *client; gsitem_t *item; int i, shot_weak, hit_weak, shot_strong, hit_strong, shot_total, hit_total; static char entry[MAX_TOKEN_CHARS]; assert( ent && ent->r.client ); client = ent->r.client; // message header Q_snprintfz( entry, sizeof( entry ), "%d", PLAYERNUM( ent ) ); for( i = WEAP_GUNBLADE; i < WEAP_TOTAL; i++ ) { item = GS_FindItemByTag( i ); assert( item ); hit_weak = hit_strong = 0; shot_weak = shot_strong = 0; if( item->weakammo_tag != AMMO_NONE ) { hit_weak = client->level.stats.accuracy_hits[item->weakammo_tag - AMMO_GUNBLADE]; shot_weak = client->level.stats.accuracy_shots[item->weakammo_tag - AMMO_GUNBLADE]; } if( item->ammo_tag != AMMO_NONE ) { hit_strong = client->level.stats.accuracy_hits[item->ammo_tag - AMMO_GUNBLADE]; shot_strong = client->level.stats.accuracy_shots[item->ammo_tag - AMMO_GUNBLADE]; } hit_total = hit_weak + hit_strong; shot_total = shot_weak + shot_strong; Q_strncatz( entry, va( " %d", shot_total ), sizeof( entry ) ); if( shot_total < 1 ) continue; Q_strncatz( entry, va( " %d", hit_total ), sizeof( entry ) ); // strong Q_strncatz( entry, va( " %d", shot_strong ), sizeof( entry ) ); if( shot_strong != shot_total ) Q_strncatz( entry, va( " %d", hit_strong ), sizeof( entry ) ); } Q_strncatz( entry, va( " %d %d", client->level.stats.total_damage_given, client->level.stats.total_damage_received ), sizeof( entry ) ); Q_strncatz( entry, va( " %d %d", client->level.stats.health_taken, client->level.stats.armor_taken ), sizeof( entry ) ); // add enclosing quote Q_strncatz( entry, "\"", sizeof( entry ) ); return entry; }
/* * L10n_LoadLangPOFile */ void L10n_LoadLangPOFile( const char *domainname, const char *filepath ) { podomain_t *podomain; pofile_t *pofile; podict_t *pofile_dict; char *tempfilename; const char *sep; size_t tempfilename_size; if( !domainname || !*domainname ) { return; } if( !filepath || !*filepath ) { return; } podomain = L10n_FindPODomain( domainname ); if( !podomain ) { podomain = L10n_CreatePODomain( domainname ); podomain->next = podomains_head; podomains_head = podomain; // store pointer to common domain for quick access if( podomain_common == NULL && !Q_stricmp( domainname, podomain_common_name ) ) { podomain_common = podomain; } } tempfilename_size = strlen( filepath ) + strlen( "/" ) + strlen( cl_lang->string ) + strlen( ".po" ) + 1; tempfilename = ( char * )L10n_Malloc( tempfilename_size ); sep = ( filepath[strlen( filepath ) - 1] == '/' ? "" : "/" ); Q_snprintfz( tempfilename, tempfilename_size, "%s%s%s.po", filepath, sep, cl_lang->string ); if( !COM_ValidateFilename( tempfilename ) ) { Com_Printf( S_COLOR_YELLOW "LoadLangPOFile failed: invalid filename '%s'\n", filepath ); return; } pofile = L10n_FindPOFile( podomain, tempfilename ); if( pofile ) { // already loaded return; } pofile_dict = L10n_LoadPODict( tempfilename ); if( pofile_dict ) { pofile = L10n_CreatePOFile( tempfilename ); pofile->dict = pofile_dict; pofile->next = podomain->pofiles_head; podomain->pofiles_head = pofile; } L10n_Free( tempfilename ); }
/* * R_ScreenShot_f */ void R_ScreenShot_f( void ) { int i; const char *name; const char *mediadir; size_t path_size; char *path; char timestamp_str[MAX_QPATH]; struct tm newtime; R_Localtime( time( NULL ), &newtime ); name = ri.Cmd_Argv( 1 ); mediadir = ri.FS_MediaDirectory( FS_MEDIA_IMAGES ); if( mediadir ) { path_size = strlen( mediadir ) + 1 /* '/' */ + strlen( glConfig.applicationName ) + 1 /* '/' */ + 1; path = alloca( path_size ); Q_snprintfz( path, path_size, "%s/%s/", mediadir, glConfig.applicationName ); } else { path_size = strlen( ri.FS_WriteDirectory() ) + 1 /* '/' */ + strlen( ri.FS_GameDirectory() ) + strlen( "/screenshots/" ) + 1; path = alloca( path_size ); Q_snprintfz( path, path_size, "%s/%s/screenshots/", ri.FS_WriteDirectory(), ri.FS_GameDirectory() ); } // validate timestamp string for( i = 0; i < 2; i++ ) { strftime( timestamp_str, sizeof( timestamp_str ), r_screenshot_fmtstr->string, &newtime ); if( !COM_ValidateRelativeFilename( timestamp_str ) ) { ri.Cvar_ForceSet( r_screenshot_fmtstr->name, r_screenshot_fmtstr->dvalue ); } else { break; } } // hm... shouldn't really happen, but check anyway if( i == 2 ) { ri.Cvar_ForceSet( r_screenshot_fmtstr->name, glConfig.screenshotPrefix ); } RF_ScreenShot( path, name, r_screenshot_fmtstr->string, ri.Cmd_Argc() >= 3 && !Q_stricmp( ri.Cmd_Argv( 2 ), "silent" ) ? true : false ); }