/* <9a1a9> ../engine/sv_log.c:162 */ void Log_Open(void) { time_t ltime; struct tm *today; char szFileBase[MAX_PATH]; char szTestFile[MAX_PATH]; int i; FileHandle_t fp; char *temp; if (!g_psvs.log.active || (sv_log_onefile.value != 0.0f && g_psvs.log.file)) return; if (mp_logfile.value == 0.0f) Con_Printf("Server logging data to console.\n"); else { Log_Close(); time(<ime); today = localtime(<ime); temp = Cvar_VariableString("logsdir"); if (!temp || Q_strlen(temp) <= 0 || Q_strstr(temp, ":") || Q_strstr(temp, "..")) Q_snprintf(szFileBase, sizeof(szFileBase), "logs/L%02i%02i", today->tm_mon + 1, today->tm_mday); else Q_snprintf(szFileBase, sizeof(szFileBase), "%s/L%02i%02i", temp, today->tm_mon + 1, today->tm_mday); for (i = 0; i < 1000; i++) { Q_snprintf(szTestFile, sizeof(szTestFile), "%s%03i.log", szFileBase, i); COM_FixSlashes(szTestFile); COM_CreatePath(szTestFile); fp = FS_OpenPathID(szTestFile, "r", "GAMECONFIG"); if (!fp) { COM_CreatePath(szTestFile); fp = FS_OpenPathID(szTestFile, "wt", "GAMECONFIG"); if (fp) { g_psvs.log.file = (void *)fp; Con_Printf("Server logging data to file %s\n", szTestFile); Log_Printf("Log file started (file \"%s\") (game \"%s\") (version \"%i/%s/%d\")\n", szTestFile, Info_ValueForKey(Info_Serverinfo(), "*gamedir"), PROTOCOL_VERSION, gpszVersionString, build_number()); } return; } FS_Close(fp); } Con_Printf("Unable to open logfiles under %s\nLogging disabled\n", szFileBase); g_psvs.log.active = FALSE; } }
/* <269e8> ../engine/filesystem_internal.cpp:292 */ void FS_Rename(const char *originalName, const char *newName) { char *cut; char localPath[512]; char newPath[512]; if (FS_GetLocalPath(originalName, localPath, ARRAYSIZE(localPath))) { Q_strcpy(newPath, localPath); cut = Q_strstr(newPath, originalName); if (cut) { *cut = 0; #ifdef REHLDS_CHECKS Q_strncat(newPath, newName, ARRAYSIZE(newPath) - Q_strlen(newPath)); newPath[ARRAYSIZE(newPath) - 1] = 0; #else Q_strcat(newPath, newName); #endif rename(localPath, newPath); } } }
/* ================= GL_CheckExtension ================= */ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cvarname, int r_ext ) { const dllfunc_t *func; convar_t *parm; MsgDev( D_NOTE, "GL_CheckExtension: %s ", name ); if( cvarname ) { // system config disable extensions parm = Cvar_Get( cvarname, "1", CVAR_GLCONFIG, va( "enable or disable %s", name )); if( parm->integer == 0 || ( gl_extensions->integer == 0 && r_ext != GL_OPENGL_110 )) { MsgDev( D_NOTE, "- disabled\n" ); GL_SetExtension( r_ext, 0 ); return; // nothing to process at } GL_SetExtension( r_ext, 1 ); } if(( name[2] == '_' || name[3] == '_' ) && !Q_strstr( glConfig.extensions_string, name )) { GL_SetExtension( r_ext, false ); // update render info MsgDev( D_NOTE, "- ^1failed\n" ); return; } GL_SetExtension( r_ext, true ); // predict extension state if( GL_Support( r_ext )) MsgDev( D_NOTE, "- ^2enabled\n" ); else MsgDev( D_NOTE, "- ^1failed\n" ); }
void AddLanguageGameDir( IFileSystem *pFileSystem, const char *pLocation, const char *pLanguage ) { #if !defined( DEDICATED ) char temp[MAX_PATH]; Q_snprintf( temp, sizeof(temp), "%s_%s", pLocation, pLanguage ); pFileSystem->AddSearchPath( temp, "GAME", PATH_ADD_TO_TAIL ); if ( IsPC() && !pFileSystem->IsSteam() ) { // also look in "..\localization\<folder>" if not running Steam char baseDir[MAX_PATH]; char *tempPtr = NULL, *gameDir = NULL; Q_strncpy( baseDir, pLocation, sizeof(baseDir) ); tempPtr = Q_strstr( baseDir, "\\game\\" ); if ( tempPtr ) { gameDir = tempPtr + Q_strlen( "\\game\\" ); *tempPtr = 0; Q_snprintf( temp, sizeof(temp), "%s%clocalization%c%s_%s", baseDir, CORRECT_PATH_SEPARATOR, CORRECT_PATH_SEPARATOR, gameDir, pLanguage ); pFileSystem->AddSearchPath( temp, "GAME", PATH_ADD_TO_TAIL ); } } #endif }
void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIndex ) { int i; // find an empty string slot for( i = 0; i < MAX_LINES; i++ ) { if( !*g_szLineBuffer[i] ) break; } if( i == MAX_LINES ) { // force scroll buffer up ScrollTextUp(); i = MAX_LINES - 1; } g_iNameLengths[i] = 0; g_pflNameColors[i] = NULL; // if it's a say message, search for the players name in the string if( *pszBuf == 2 && clientIndex > 0 ) { GetPlayerInfo( clientIndex, &g_PlayerInfoList[clientIndex] ); const char *pName = g_PlayerInfoList[clientIndex].name; if( pName ) { const char *nameInString = Q_strstr( pszBuf, pName ); if( nameInString ) { g_iNameLengths[i] = Q_strlen( pName ) + (nameInString - pszBuf); g_pflNameColors[i] = GetClientColor( clientIndex ); } } } Q_strncpy( g_szLineBuffer[i], pszBuf, max( iBufSize - 1, MAX_CHARS_PER_LINE - 1 )); // make sure the text fits in one line EnsureTextFitsInOneLineAndWrapIfHaveTo( i ); // Set scroll time if( i == 0 ) { flScrollTime = gHUD.m_flTime + m_HUD_saytext_time->value; } m_iFlags |= HUD_ACTIVE; PlaySound( "misc/talk.wav", 1 ); if( ScreenHeight >= 480 ) Y_START = ScreenHeight - 60; else Y_START = ScreenHeight - 45; Y_START -= (line_height * (MAX_LINES+1)); }
// // Name: CreateGameRule( GameModeID_enum GameMode ) // Author: Hekar Khani // Description: Initializes the gamerules based on // selected argument and enabled gamemodes // Notes: // void CreateGameRule( GameModeID_enum GameMode ) { Msg("=================================================\n"); Msg("[LF] Gamemode: "); switch( GameMode ) { //------------------------------------------------- #ifdef MOD_SF132 case GAMEMODE_SF132: CreateGameRulesObject( "CSF132GameRules" ); Msg("Sourceforts 132"); break; #endif // MOD_SF132 //------------------------------------------------- #ifdef MOD_CLASSIC case GAMEMODE_CLASSIC: CreateGameRulesObject( "CClassicGameRules" ); Msg("CTF\n"); break; #endif // MOD_CLASSIC case GAMEMODE_DOM: CreateGameRulesObject( "CDomGameRules" ); Msg("Domination\n"); break; //------------------------------------------------- default: //------------------------------------------------- #ifdef MOD_SF132 // Check if the mapname is prefixed as a SF132 map and use // the 132 gamerules if so if ( Q_strstr( gpGlobals->mapname.ToCStr(), "sf132_" ) ) { CreateGameRulesObject( "CSF132GameRules" ); SDKGameRules()->SetSourcefortsMap( true ); Msg("Sourceforts 132\n"); } else #endif // MOD_SF132 //------------------------------------------------- #ifdef MOD_CLASSIC { // The Classic gamerules work with 194 // and CTF based 195 maps CreateGameRulesObject( "CClassicGameRules" ); SDKGameRules()->SetSourcefortsMap( true ); Msg("Sourceforts 194\n"); } #endif // MOD_CLASSIC //------------------------------------------------- // This "break" is here in case MOD_SF132 // is enabled and MOD_CLASSIC is disabled break; } Msg("=================================================\n"); Assert( g_pGameRules ); g_pGameRules->Init(); }
//----------------------------------------------------------------------------- // Purpose: // Input : *raw - // *key - // keylen - // *value - // valuelen - // *duration - // Output : static bool //----------------------------------------------------------------------------- const char *SplitContext( const char *raw, char *key, int keylen, char *value, int valuelen, float *duration ) { char *colon1 = Q_strstr( raw, ":" ); if ( !colon1 ) { DevMsg( "SplitContext: warning, ignoring context '%s', missing colon separator!\n", raw ); *key = *value = 0; return NULL; } int len = colon1 - raw; Q_strncpy( key, raw, MIN( len + 1, keylen ) ); key[ MIN( len, keylen - 1 ) ] = 0; bool last = false; char *end = Q_strstr( colon1 + 1, "," ); if ( !end ) { int remaining = Q_strlen( colon1 + 1 ); end = colon1 + 1 + remaining; last = true; } char *colon2 = Q_strstr( colon1 + 1, ":" ); if ( colon2 && ( colon2 < end ) ) { if ( duration ) *duration = atof( colon2 + 1 ); len = MIN( colon2 - ( colon1 + 1 ), valuelen - 1 ); Q_strncpy( value, colon1 + 1, len + 1 ); value[ len ] = 0; } else { if ( duration ) *duration = 0.0; len = MIN( end - ( colon1 + 1 ), valuelen - 1 ); Q_strncpy( value, colon1 + 1, len + 1 ); value[ len ] = 0; } return last ? NULL : end + 1; }
static int CC_asw_teleport_autocomplete( char const *partial, char commands[ COMMAND_COMPLETION_MAXITEMS ][ COMMAND_COMPLETION_ITEM_LENGTH ] ) { if ( !g_pGameRules ) { return 0; } char const *cmdname = "asw_teleport"; char *substring = (char *)partial; if ( Q_strstr( partial, cmdname ) ) { substring = (char *)partial + strlen( cmdname ) + 1; } int checklen = Q_strlen( substring ); CUtlSymbolTable entries( 0, 0, true ); CUtlVector< CUtlSymbol > symbols; CBaseEntity *pos = NULL; while ( ( pos = gEntList.NextEnt( pos ) ) != NULL ) { // Check target name against partial string if ( pos->GetEntityName() == NULL_STRING ) continue; if ( Q_strnicmp( STRING( pos->GetEntityName() ), substring, checklen ) ) continue; CUtlSymbol sym = entries.AddString( STRING( pos->GetEntityName() ) ); int idx = symbols.Find( sym ); if ( idx == symbols.InvalidIndex() ) { symbols.AddToTail( sym ); } // Too many if ( symbols.Count() >= COMMAND_COMPLETION_MAXITEMS ) break; } // Now fill in the results for ( int i = 0; i < symbols.Count(); i++ ) { char const *name = entries.String( symbols[ i ] ); char buf[ 512 ]; Q_strncpy( buf, name, sizeof( buf ) ); Q_strlower( buf ); Q_snprintf( commands[ i ], COMMAND_COMPLETION_ITEM_LENGTH, "%s %s", cmdname, buf ); } return symbols.Count(); }
/* <35df2> ../engine/host.c:516 */ void Host_WriteCustomConfig(void) { #ifndef SWDS FILE *f; kbutton_t *ml; kbutton_t *jl; #endif char configname[261]; Q_snprintf(configname, 257, "%s", Cmd_Args()); if (Q_strstr(configname, "..") || !Q_stricmp(configname, "config") || !Q_stricmp(configname, "autoexec") || !Q_stricmp(configname, "listenserver") || !Q_stricmp(configname, "server") || !Q_stricmp(configname, "userconfig")) { Con_Printf("skipping writecfg output, invalid filename given\n"); } #ifndef SWDS else { if (host_initialized && g_pcls.state != ca_dedicated) { if (Key_CountBindings() < 2) Con_Printf("skipping config.cfg output, no keys bound\n"); else { Q_strcat(configname, ".cfg"); f = FS_OpenPathID(configname, "w", "GAMECONFIG"); if (!f) { Con_Printf("Couldn't write %s.\n", configname); return; } FS_FPrintf(f, "unbindall\n"); Key_WriteBindings(f); Cvar_WriteVariables(f); Info_WriteVars(f); ml = ClientDLL_FindKey("in_mlook"); jl = ClientDLL_FindKey("in_jlook"); if (ml && ml->state & 1) FS_FPrintf(f, "+mlook\n"); if (jl && jl->state & 1) FS_FPrintf(f, "+jlook\n"); FS_Close(f); Con_Printf("%s successfully created!\n", configname); } } } #endif // SWDS }
/* <845bc> ../engine/r_studio.c:5809 */ int R_GetStudioBounds(const char *filename, float *mins, float *maxs) { int iret = 0; qboolean usingReadBuffer = 0; for (int i = 0; i < 3; i++) mins[0] = maxs[0] = vec3_origin[i]; if (!Q_strstr(filename, "models") || !Q_strstr(filename, ".mdl")) return 0; FileHandle_t fp = FS_Open(filename, "rb"); if (!fp) return 0; int length; char *pBuffer = (char *)FS_GetReadBuffer(fp, &length); if (pBuffer) usingReadBuffer = 1; else pBuffer = (char*) COM_LoadFile(filename, 5, 0); if (pBuffer) { if (LittleLong(*(unsigned int *)pBuffer) == 'TSDI') iret = R_StudioComputeBounds((unsigned char*)pBuffer, mins, maxs); #ifndef REHLDS_FIXES //wrong release memory code else COM_FreeFile(pBuffer); #endif } if (usingReadBuffer) FS_ReleaseReadBuffer(fp, pBuffer); else COM_FreeFile(pBuffer); FS_Close(fp); return iret; }
const char* DotaObjective::GetLane() { const char* objectiveName = this->m_creepMakerName.ToCStr(); if (objectiveName==NULL) return NULL; if (Q_strstr(objectiveName, "left") != NULL) { return "LEFT"; } if (Q_strstr(objectiveName, "center") != NULL) { return "CENTER"; } if (Q_strstr(objectiveName, "right") != NULL) { return "RIGHT"; } return NULL; }
/* <18af50> ../cstrike/dlls/training_gamerules.cpp:293 */ void CBaseGrenCatch::__MAKE_VHOOK(Touch)(CBaseEntity *pOther) { if (!pOther) { return; } if (Q_strstr(STRING(pev->model), "flash") != NULL) { m_fFlashTouched = true; } }
/* ==================== Mod_GetStudioBounds ==================== */ qboolean Mod_GetStudioBounds( const char *name, vec3_t mins, vec3_t maxs ) { int result = false; byte *f; if( !Q_strstr( name, "models" ) || !Q_strstr( name, ".mdl" )) return false; f = FS_LoadFile( name, NULL, false ); if( !f ) return false; if( *(uint *)f == IDSTUDIOHEADER ) { VectorClear( mins ); VectorClear( maxs ); Mod_StudioComputeBounds( f, mins, maxs ); result = true; } Mem_Free( f ); return result; }
void PrefetchScriptSound( const char *soundname ) { int soundIndex = soundemitterbase->GetSoundIndex( soundname ); if ( !soundemitterbase->IsValidIndex( soundIndex ) ) { if ( Q_stristr( soundname, ".wav" ) || Q_strstr( soundname, ".mp3" ) ) { CBaseEntity::PrefetchSound( soundname ); } return; } InternalPrefetchWaves( soundIndex ); }
void CServerRemoteAccess::GetMapList(CUtlBuffer &value) { const char *findfn; char *extension; char curDir[MAX_PATH]; char mapName[MAX_PATH]; char mapwild[64]; Q_strcpy(mapwild, "maps/*.bsp"); for (findfn = Sys_FindFirst(mapwild, 0); findfn; findfn = Sys_FindNext(0)) { Q_snprintf(curDir, ARRAYSIZE(curDir), "maps/%s", findfn); #ifdef REHLDS_CHECKS curDir[ARRAYSIZE(curDir) - 1] = 0; #endif FS_GetLocalPath(curDir, curDir, ARRAYSIZE(curDir)); if (Q_strstr(curDir, com_gamedir)) { #ifdef REHLDS_CHECKS Q_strncpy(mapName, findfn, ARRAYSIZE(mapName)); mapName[ARRAYSIZE(mapName) - 1] = 0; #else Q_strcpy(mapName, findfn); #endif extension = Q_strstr(mapName, ".bsp"); if (extension) *extension = 0; value.PutString(mapName); value.PutString("\n"); } } Sys_FindClose(); value.PutChar(0); }
const char *stripClass(const char *str) { const int BufLen = 256; static char string[ BufLen ]; const char pattern[] = "class "; int curlen = Q_strlen(str); Q_strncpy(string, str, curlen); string[ curlen ] = '\0'; curlen = (Q_strstr(string, pattern) != NULL) ? Q_strlen(pattern) : 0; return &string[ curlen ]; }
virtual void FireGameEvent_Internal( IGameEvent *event ) { if ( !CBasePlayer::GetLocalPlayer() ) return; if ( Q_strstr(event->GetName(), "player_") ) { if ( event->GetInt("userid") == CBasePlayer::GetLocalPlayer()->GetUserID() ) m_iKillCount = 0; } else if ( !Q_stricmp(event->GetName(), "round_start") ) { m_iKillCount = 0; } }
/* ================= GL_CheckExtension ================= */ void GL_CheckExtension( const char *name, const dllfunc_t *funcs, const char *cvarname, int r_ext ) { const dllfunc_t *func; convar_t *parm; MsgDev( D_NOTE, "GL_CheckExtension: %s ", name ); if( cvarname ) { // system config disable extensions parm = Cvar_Get( cvarname, "1", CVAR_GLCONFIG, va( "enable or disable %s", name )); if( parm->integer == 0 || ( gl_extensions->integer == 0 && r_ext != GL_OPENGL_110 )) { MsgDev( D_NOTE, "- disabled\n" ); GL_SetExtension( r_ext, 0 ); return; // nothing to process at } GL_SetExtension( r_ext, 1 ); } if(( name[2] == '_' || name[3] == '_' ) && !Q_strstr( glConfig.extensions_string, name )) { GL_SetExtension( r_ext, false ); // update render info MsgDev( D_NOTE, "- ^1failed\n" ); return; } // clear exports for( func = funcs; func && func->name; func++ ) *func->func = NULL; GL_SetExtension( r_ext, true ); // predict extension state for( func = funcs; func && func->name != NULL; func++ ) { // functions are cleared before all the extensions are evaluated if(!(*func->func = (void *)GL_GetProcAddress( func->name ))) GL_SetExtension( r_ext, false ); // one or more functions are invalid, extension will be disabled } if( GL_Support( r_ext )) MsgDev( D_NOTE, "- ^2enabled\n" ); else MsgDev( D_NOTE, "- ^1failed\n" ); }
// // Name: CC_BalanceMacroReport( const CCommand& args ) // Author: Hekar Khani // Description: ConCommand to display a simple report of the current balance macros // Notes: // void CC_BalanceMacroReport( const CCommand& args ) { ConCommandBase *Command = cvar->GetCommands(); for ( ; Command != NULL; Command = Command->GetNext()) { ConVar *convar = dynamic_cast< ConVar * > ( Command ); if ( !convar ) { continue; } const char *convarname = convar->GetName(); if ( Q_strstr( convarname, "lfm" ) ) { Msg( "Name: %s\t\tValue: %s\t\tDesc: %s\n", convar->GetName(), convar->GetString(), convar->GetHelpText() ); } } }
int Q_StrReplace( const char *str, char *output, int size, const char *original, const char *replace ) { char *pos = NULL; if( ( pos = Q_strstr( str, original ) ) == NULL ) return FALSE; Q_strncpy( output, str, clamp( pos - str, 0, size - 1 ) ); output[ clamp( pos - str, 0, size - 1 ) ] = '\0'; Q_snprintf( output + clamp( pos - str, 0, size - 1 ), size, "%s%s", replace, pos + strlen( original ) ); return TRUE; }
// // Name: CC_BalanceMacroReport( const CCommand& args ) // Author: Hekar Khani // Description: ConCommand to display a report of the current balance macros in CSV format // Notes: // void CC_BalanceMacroReportCSV( const CCommand& args ) { // HODO: add ability to write to file ConCommandBase *Command = cvar->GetCommands(); for ( ; Command != NULL; Command = Command->GetNext()) { ConVar *convar = dynamic_cast< ConVar * > ( Command ); if ( !convar ) { continue; } Msg( "Convar, Value, Description\n" ); const char *convarname = convar->GetName(); if ( Q_strstr( convarname, "lfm" ) ) { Msg( "%s, %s, %s\n", convar->GetName(), convar->GetString(), convar->GetHelpText() ); } } }
//============================================================================= void ControllerOptionsButtons::RecalculateBindingLabels( void ) { // Populate the bindings labels with the currently bound keys EditablePanel *pContainer = dynamic_cast<EditablePanel *>( FindChildByName( "LabelContainer" ) ); if ( !pContainer ) return; // for every button on the controller for ( int i=0;i<sizeof(sControllerBindings) / sizeof( ControllerBindingMap );i++ ) { // what is it bound to? vgui::KeyCode code = sControllerBindings[i].m_keyCode; //int nJoystick = m_iActiveUserSlot; code = ButtonCodeToJoystickButtonCode( code, m_iActiveUserSlot ); const char *pBinding = engine->Key_BindingForKey( code ); if ( !pBinding ) { // key is not bound to anything pContainer->SetControlString( sControllerBindings[i].m_pszLabelName, L"<Not Bound>" ); continue; } // find the localized string for this binding and set the label text for( int j=0;j<sizeof( sBindingToDisplay ) / sizeof( BindingDisplayMap );j++ ) { const BindingDisplayMap *entry = &( sBindingToDisplay[ j ] ); if ( Q_strstr( pBinding, entry->pszBinding ) ) { Label *pLabel = dynamic_cast< Label * >( pContainer->FindChildByName( sControllerBindings[i].m_pszLabelName ) ); if ( pLabel ) { pLabel->SetText( entry->pszDisplay ); } } } } }
void CExpression::CreateNewBitmap( int modelindex ) { MatSysWindow *pWnd = g_pMatSysWindow; if ( !pWnd ) return; StudioModel *model = models->GetStudioModel( modelindex ); if ( !model ) return; CStudioHdr *hdr = models->GetStudioHeader( modelindex ); if ( !hdr ) return; char filename[ 256 ]; strcpy( filename, GetBitmapFilename( modelindex ) ); if ( !Q_strstr( filename, ".bmp" ) ) return; models->CreateNewBitmap( modelindex, filename, 0, 128, true, this, &m_Bitmap[ modelindex ] ); }
qboolean Info_RemoveKey( char *s, const char *key ) { char *start; char pkey[MAX_INFO_STRING]; char value[MAX_INFO_STRING]; char *o; if( Q_strstr( key, "\\" )) return false; while( 1 ) { start = s; if( *s == '\\' ) s++; o = pkey; while( *s != '\\' ) { if( !*s ) return false; *o++ = *s++; } *o = 0; s++; o = value; while( *s != '\\' && *s ) { if( !*s ) return false; *o++ = *s++; } *o = 0; if( !Q_strcmp( key, pkey )) { Q_strcpy( start, s ); // remove this part return true; } if( !*s ) return false; } }
/* <18bb28> ../cstrike/dlls/training_gamerules.cpp:462 */ void CFuncWeaponCheck::__MAKE_VHOOK(KeyValue)(KeyValueData *pkvd) { if (FStrEq(pkvd->szKeyName, "trigger_items")) { sTriggerWithItems = ALLOC_STRING(pkvd->szValue); pkvd->fHandled = TRUE; } else if (FStrEq(pkvd->szKeyName, "trigger_noitems")) { sTriggerNoItems = ALLOC_STRING(pkvd->szValue); pkvd->fHandled = TRUE; } else if (FStrEq(pkvd->szKeyName, "trigger_noitems_delay")) { pev->speed = Q_atof(pkvd->szValue); pkvd->fHandled = TRUE; } else if (Q_strstr(pkvd->szKeyName, "item") != NULL) { if (iItemCount < MAX_ITEM_COUNTS) { sItemName[ iItemCount++ ] = ALLOC_STRING(pkvd->szValue); } pkvd->fHandled = TRUE; } else if (FStrEq(pkvd->szKeyName, "master")) { sMaster = ALLOC_STRING(pkvd->szValue); pkvd->fHandled = TRUE; } else if (FStrEq(pkvd->szKeyName, "any_weapon")) { iAnyWeapon = Q_atoi(pkvd->szValue); pkvd->fHandled = TRUE; } else CBaseEntity::KeyValue(pkvd); }
// monitor output from our process to determine which part of the build we're in void CASW_Map_Builder::UpdateProgress() { // copy the new chars into our buffer int newcharslen = Q_strlen(m_szProcessBuffer); for (int i=0;i<newcharslen;i++) { m_szOutputBuffer[m_iOutputBufferPos++] = m_szProcessBuffer[i]; // if we go over the end of our output buffer, then shift everything back by half the buffer and continue if (m_iOutputBufferPos >= MAP_BUILD_OUTPUT_BUFFER_SIZE) { for (int k=0;k<MAP_BUILD_OUTPUT_BUFFER_HALF_SIZE;k++) { m_szOutputBuffer[k] = m_szOutputBuffer[k + MAP_BUILD_OUTPUT_BUFFER_HALF_SIZE]; } m_iOutputBufferPos = MAP_BUILD_OUTPUT_BUFFER_HALF_SIZE; } } // now scan our buffer for progress messages in reverse order int iNumSearch = NELEMS(s_szProgressTerms); for (int iSearch=iNumSearch-1;iSearch>m_iCurrentBuildSearch;iSearch--) { char *pos = Q_strstr(m_szOutputBuffer, s_szProgressTerms[iSearch]); if ( pos ) { //Msg("Output (%s) matched (%s) result %s at %d\n", m_szOutputBuffer, s_szProgressTerms[iSearch], pos, pos - m_szOutputBuffer); m_iCurrentBuildSearch = iSearch; m_flProgress = float(iSearch) / float (iNumSearch); if (Q_strlen(s_szStatusLabels[iSearch]) > 0) { Q_snprintf( m_szStatusMessage, sizeof(m_szStatusMessage), "%s", s_szStatusLabels[iSearch] ); } break; } } }
HSOUNDSCRIPTHANDLE PrecacheScriptSound( const char *soundname ) { int soundIndex = soundemitterbase->GetSoundIndex( soundname ); if ( !soundemitterbase->IsValidIndex( soundIndex ) ) { if ( Q_stristr( soundname, ".wav" ) || Q_strstr( soundname, ".mp3" ) ) { g_bPermitDirectSoundPrecache = true; CBaseEntity::PrecacheSound( soundname ); g_bPermitDirectSoundPrecache = false; return SOUNDEMITTER_INVALID_HANDLE; } #if !defined( CLIENT_DLL ) if ( soundname[ 0 ] ) { static CUtlSymbolTable s_PrecacheScriptSoundFailures; // Make sure we only show the message once if ( UTL_INVAL_SYMBOL == s_PrecacheScriptSoundFailures.Find( soundname ) ) { DevMsg( "PrecacheScriptSound '%s' failed, no such sound script entry\n", soundname ); s_PrecacheScriptSoundFailures.AddString( soundname ); } } #endif return (HSOUNDSCRIPTHANDLE)soundIndex; } #if !defined( CLIENT_DLL ) LogPrecache( soundname ); #endif InternalPrecacheWaves( soundIndex ); return (HSOUNDSCRIPTHANDLE)soundIndex; }
qboolean Sys_DebuggerPresent( void ) { char buf[1024]; qboolean debugger_present = false; int status_fd = open( "/proc/self/status", O_RDONLY ); if ( status_fd == -1 ) return 0; ssize_t num_read = read( status_fd, buf, sizeof( buf ) ); if ( num_read > 0 ) { static const char TracerPid[] = "TracerPid:"; char *tracer_pid; buf[num_read] = 0; tracer_pid = Q_strstr( buf, TracerPid ); if ( tracer_pid ) debugger_present = !!Q_atoi( tracer_pid + sizeof( TracerPid )); } return debugger_present; }
void GL_InitExtensions( void ) { // initialize gl extensions GL_CheckExtension( "OpenGL 1.1.0", opengl_110funcs, NULL, GL_OPENGL_110 ); // get our various GL strings glConfig.vendor_string = pglGetString( GL_VENDOR ); glConfig.renderer_string = pglGetString( GL_RENDERER ); glConfig.version_string = pglGetString( GL_VERSION ); glConfig.extensions_string = pglGetString( GL_EXTENSIONS ); MsgDev( D_INFO, "Video: %s\n", glConfig.renderer_string ); // initalize until base opengl functions loaded GL_CheckExtension( "glDrawRangeElements", drawrangeelementsfuncs, "gl_drawrangeelments", GL_DRAW_RANGEELEMENTS_EXT ); if( !GL_Support( GL_DRAW_RANGEELEMENTS_EXT )) GL_CheckExtension( "GL_EXT_draw_range_elements", drawrangeelementsextfuncs, "gl_drawrangeelments", GL_DRAW_RANGEELEMENTS_EXT ); // multitexture glConfig.max_texture_units = glConfig.max_texture_coords = glConfig.max_teximage_units = 1; GL_CheckExtension( "GL_ARB_multitexture", multitexturefuncs, "gl_arb_multitexture", GL_ARB_MULTITEXTURE ); if( GL_Support( GL_ARB_MULTITEXTURE )) { pglGetIntegerv( GL_MAX_TEXTURE_UNITS_ARB, &glConfig.max_texture_units ); GL_CheckExtension( "GL_ARB_texture_env_combine", NULL, "gl_texture_env_combine", GL_ENV_COMBINE_EXT ); if( !GL_Support( GL_ENV_COMBINE_EXT )) GL_CheckExtension( "GL_EXT_texture_env_combine", NULL, "gl_texture_env_combine", GL_ENV_COMBINE_EXT ); if( GL_Support( GL_ENV_COMBINE_EXT )) GL_CheckExtension( "GL_ARB_texture_env_dot3", NULL, "gl_texture_env_dot3", GL_DOT3_ARB_EXT ); } else { GL_CheckExtension( "GL_SGIS_multitexture", sgis_multitexturefuncs, "gl_sgis_multitexture", GL_ARB_MULTITEXTURE ); if( GL_Support( GL_ARB_MULTITEXTURE )) glConfig.max_texture_units = 2; } if( glConfig.max_texture_units == 1 ) GL_SetExtension( GL_ARB_MULTITEXTURE, false ); // 3d texture support GL_CheckExtension( "GL_EXT_texture3D", texture3dextfuncs, "gl_texture_3d", GL_TEXTURE_3D_EXT ); if( GL_Support( GL_TEXTURE_3D_EXT )) { pglGetIntegerv( GL_MAX_3D_TEXTURE_SIZE, &glConfig.max_3d_texture_size ); if( glConfig.max_3d_texture_size < 32 ) { GL_SetExtension( GL_TEXTURE_3D_EXT, false ); MsgDev( D_ERROR, "GL_EXT_texture3D reported bogus GL_MAX_3D_TEXTURE_SIZE, disabled\n" ); } } GL_CheckExtension( "GL_SGIS_generate_mipmap", NULL, "gl_sgis_generate_mipmaps", GL_SGIS_MIPMAPS_EXT ); // hardware cubemaps GL_CheckExtension( "GL_ARB_texture_cube_map", NULL, "gl_texture_cubemap", GL_TEXTURECUBEMAP_EXT ); if( GL_Support( GL_TEXTURECUBEMAP_EXT )) { pglGetIntegerv( GL_MAX_CUBE_MAP_TEXTURE_SIZE_ARB, &glConfig.max_cubemap_size ); // check for seamless cubemaps too GL_CheckExtension( "GL_ARB_seamless_cube_map", NULL, "gl_seamless_cubemap", GL_ARB_SEAMLESS_CUBEMAP ); } // point particles extension GL_CheckExtension( "GL_EXT_point_parameters", pointparametersfunc, NULL, GL_EXT_POINTPARAMETERS ); GL_CheckExtension( "GL_ARB_texture_non_power_of_two", NULL, "gl_texture_npot", GL_ARB_TEXTURE_NPOT_EXT ); GL_CheckExtension( "GL_ARB_texture_compression", texturecompressionfuncs, "gl_dds_hardware_support", GL_TEXTURE_COMPRESSION_EXT ); GL_CheckExtension( "GL_EXT_compiled_vertex_array", compiledvertexarrayfuncs, "gl_cva_support", GL_CUSTOM_VERTEX_ARRAY_EXT ); if( !GL_Support( GL_CUSTOM_VERTEX_ARRAY_EXT )) GL_CheckExtension( "GL_SGI_compiled_vertex_array", compiledvertexarrayfuncs, "gl_cva_support", GL_CUSTOM_VERTEX_ARRAY_EXT ); GL_CheckExtension( "GL_EXT_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT ); if( !GL_Support( GL_CLAMPTOEDGE_EXT )) GL_CheckExtension("GL_SGIS_texture_edge_clamp", NULL, "gl_clamp_to_edge", GL_CLAMPTOEDGE_EXT ); glConfig.max_texture_anisotropy = 0.0f; GL_CheckExtension( "GL_EXT_texture_filter_anisotropic", NULL, "gl_ext_anisotropic_filter", GL_ANISOTROPY_EXT ); if( GL_Support( GL_ANISOTROPY_EXT )) pglGetFloatv( GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &glConfig.max_texture_anisotropy ); GL_CheckExtension( "GL_EXT_texture_lod_bias", NULL, "gl_ext_texture_lodbias", GL_TEXTURE_LODBIAS ); if( GL_Support( GL_TEXTURE_LODBIAS )) pglGetFloatv( GL_MAX_TEXTURE_LOD_BIAS_EXT, &glConfig.max_texture_lodbias ); GL_CheckExtension( "GL_ARB_texture_border_clamp", NULL, "gl_ext_texborder_clamp", GL_CLAMP_TEXBORDER_EXT ); GL_CheckExtension( "GL_EXT_blend_minmax", blendequationfuncs, "gl_ext_customblend", GL_BLEND_MINMAX_EXT ); GL_CheckExtension( "GL_EXT_blend_subtract", blendequationfuncs, "gl_ext_customblend", GL_BLEND_SUBTRACT_EXT ); GL_CheckExtension( "glStencilOpSeparate", gl2separatestencilfuncs, "gl_separate_stencil", GL_SEPARATESTENCIL_EXT ); if( !GL_Support( GL_SEPARATESTENCIL_EXT )) GL_CheckExtension("GL_ATI_separate_stencil", atiseparatestencilfuncs, "gl_separate_stencil", GL_SEPARATESTENCIL_EXT ); GL_CheckExtension( "GL_EXT_stencil_two_side", stenciltwosidefuncs, "gl_stenciltwoside", GL_STENCILTWOSIDE_EXT ); GL_CheckExtension( "GL_ARB_vertex_buffer_object", vbofuncs, "gl_vertex_buffer_object", GL_ARB_VERTEX_BUFFER_OBJECT_EXT ); // we don't care if it's an extension or not, they are identical functions, so keep it simple in the rendering code #ifndef __ANDROID__ if( pglDrawRangeElementsEXT == NULL ) pglDrawRangeElementsEXT = pglDrawRangeElements; #endif GL_CheckExtension( "GL_ARB_texture_env_add", NULL, "gl_texture_env_add", GL_TEXTURE_ENV_ADD_EXT ); // vp and fp shaders GL_CheckExtension( "GL_ARB_shader_objects", shaderobjectsfuncs, "gl_shaderobjects", GL_SHADER_OBJECTS_EXT ); GL_CheckExtension( "GL_ARB_shading_language_100", NULL, "gl_glslprogram", GL_SHADER_GLSL100_EXT ); GL_CheckExtension( "GL_ARB_vertex_shader", vertexshaderfuncs, "gl_vertexshader", GL_VERTEX_SHADER_EXT ); GL_CheckExtension( "GL_ARB_fragment_shader", NULL, "gl_pixelshader", GL_FRAGMENT_SHADER_EXT ); GL_CheckExtension( "GL_ARB_depth_texture", NULL, "gl_depthtexture", GL_DEPTH_TEXTURE ); GL_CheckExtension( "GL_ARB_shadow", NULL, "gl_arb_shadow", GL_SHADOW_EXT ); GL_CheckExtension( "GL_ARB_texture_float", NULL, "gl_arb_texture_float", GL_ARB_TEXTURE_FLOAT_EXT ); GL_CheckExtension( "GL_ARB_depth_buffer_float", NULL, "gl_arb_depth_float", GL_ARB_DEPTH_FLOAT_EXT ); // occlusion queries GL_CheckExtension( "GL_ARB_occlusion_query", occlusionfunc, "gl_occlusion_queries", GL_OCCLUSION_QUERIES_EXT ); if( GL_Support( GL_SHADER_GLSL100_EXT )) { pglGetIntegerv( GL_MAX_TEXTURE_COORDS_ARB, &glConfig.max_texture_coords ); pglGetIntegerv( GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &glConfig.max_teximage_units ); } else { // just get from multitexturing glConfig.max_texture_coords = glConfig.max_teximage_units = glConfig.max_texture_units; } // rectangle textures support if( Q_strstr( glConfig.extensions_string, "GL_NV_texture_rectangle" )) { glConfig.texRectangle = GL_TEXTURE_RECTANGLE_NV; pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_NV, &glConfig.max_2d_rectangle_size ); } #ifndef __ANDROID__ else if( Q_strstr( glConfig.extensions_string, "GL_EXT_texture_rectangle" )) { glConfig.texRectangle = GL_TEXTURE_RECTANGLE_EXT; pglGetIntegerv( GL_MAX_RECTANGLE_TEXTURE_SIZE_EXT, &glConfig.max_2d_rectangle_size ); } #endif else glConfig.texRectangle = glConfig.max_2d_rectangle_size = 0; // no rectangle glConfig.max_2d_texture_size = 0; pglGetIntegerv( GL_MAX_TEXTURE_SIZE, &glConfig.max_2d_texture_size ); if( glConfig.max_2d_texture_size <= 0 ) glConfig.max_2d_texture_size = 256; Cvar_Get( "gl_max_texture_size", "0", CVAR_INIT, "opengl texture max dims" ); Cvar_Set( "gl_max_texture_size", va( "%i", glConfig.max_2d_texture_size )); pglGetIntegerv( GL_MAX_VERTEX_UNIFORM_COMPONENTS_ARB, &glConfig.max_vertex_uniforms ); pglGetIntegerv( GL_MAX_VERTEX_ATTRIBS_ARB, &glConfig.max_vertex_attribs ); // MCD has buffering issues if(Q_strstr( glConfig.renderer_string, "gdi" )) Cvar_SetFloat( "gl_finish", 1 ); Cvar_Set( "gl_anisotropy", va( "%f", bound( 0, gl_texture_anisotropy->value, glConfig.max_texture_anisotropy ))); // software mipmap generator does wrong result with NPOT textures ... if( !GL_Support( GL_SGIS_MIPMAPS_EXT )) GL_SetExtension( GL_ARB_TEXTURE_NPOT_EXT, false ); if( GL_Support( GL_TEXTURE_COMPRESSION_EXT )) Image_AddCmdFlags( IL_DDS_HARDWARE ); glw_state.initialized = true; tr.framecount = tr.visframecount = 1; }
/* <5e43> ../engine/cmd.c:347 */ void Cmd_Exec_f(void) { const char *pszFileName; const char *pszFileExt; char *pszFileData; int nAddLen; FileHandle_t hFile; if (Cmd_Argc() != 2) { Con_Printf("exec <filename> : execute a script file\n"); return; } pszFileName = Cmd_Argv(1); if (!pszFileName || pszFileName[0] == 0) { return; } if (Q_strstr(pszFileName, "\\") || Q_strstr(pszFileName, ":") || Q_strstr(pszFileName, "~") || Q_strstr(pszFileName, "..") || *pszFileName == '/') { Con_Printf("exec %s: invalid path.\n", pszFileName); return; } pszFileExt = COM_FileExtension((char *)pszFileName); if (Q_stricmp(pszFileExt, "cfg") && Q_stricmp(pszFileExt, "rc")) { Con_Printf("exec %s: not a .cfg or .rc file\n", pszFileName); return; } hFile = FS_OpenPathID(pszFileName, "rb", "GAMECONFIG"); if (!hFile) { hFile = FS_OpenPathID(pszFileName, "rb", "GAME"); } if (!hFile) { hFile = FS_Open(pszFileName, "rb"); } if (!hFile) { if (!Q_strstr(pszFileName, "autoexec.cfg") && !Q_strstr(pszFileName, "userconfig.cfg") && !Q_strstr(pszFileName, "hw/opengl.cfg") && !Q_strstr(pszFileName, "joystick.cfg") && !Q_strstr(pszFileName, "game.cfg")) { Con_Printf("couldn't exec %s\n", pszFileName); } return; } nAddLen = FS_Size(hFile); pszFileData = (char *)Mem_Malloc(nAddLen + 1); if (!pszFileData) { Con_Printf("exec: not enough space for %s", pszFileName); FS_Close(hFile); return; } FS_Read(pszFileData, nAddLen, 1, hFile); pszFileData[nAddLen] = 0; FS_Close(hFile); Con_DPrintf("execing %s\n", pszFileName); if (cmd_text.cursize + nAddLen + 2 < cmd_text.maxsize) { Cbuf_InsertTextLines(pszFileData); } else { char *pszDataPtr = pszFileData; while (true) { Cbuf_Execute(); // TODO: This doesn't obey the rule to first execute commands from the file, and then the others in the buffer pszDataPtr = COM_ParseLine(pszDataPtr); if (com_token[0] == 0) { break; } Cbuf_InsertTextLines(com_token); } } Mem_Free(pszFileData); }