// // Returns true if dll has been loaded with GTA. // bool IsRealDeal ( void ) { // Get current module full path char szBuffer[64000]; GetModuleFileName ( NULL, szBuffer, sizeof(szBuffer) - 1 ); WriteDebugEvent( SString( "ModuleFileName: %s", szBuffer ) ); if ( SStringX( szBuffer ).EndsWithI( "gta_sa.exe" ) || SStringX( szBuffer ).EndsWithI( "proxy_sa.exe" ) ) return true; return false; }
const SBindableKey* CKeyBinds::GetBindableFromKey ( const char* szKey ) { // Map for faster lookup static std::map < SString, const SBindableKey* > bindableKeyMap; // Init map if required if ( bindableKeyMap.empty () ) for ( int i = 0 ; *g_bkKeys [ i ].szKey != 0 ; i++ ) MapSet ( bindableKeyMap, SStringX ( g_bkKeys [ i ].szKey ).ToLower (), &g_bkKeys [ i ] ); return MapFindRef ( bindableKeyMap, SStringX ( szKey ).ToLower () ); }
const SBindableGTAControl* CKeyBinds::GetBindableFromControl ( const char* szControl ) { // Map for faster lookup static std::map < SString, const SBindableGTAControl* > bindableControlMap; // Init map if required if ( bindableControlMap.empty () ) for ( int i = 0 ; *g_bcControls [ i ].szControl != 0 ; i++ ) MapSet ( bindableControlMap, SStringX ( g_bcControls [ i ].szControl ).ToLower (), &g_bcControls [ i ] ); return MapFindRef ( bindableControlMap, SStringX ( szControl ).ToLower () ); }
////////////////////////////////////////////////////////// // // CheckLibVersions // // Ensure DLLs are the correct version // ////////////////////////////////////////////////////////// void CheckLibVersions( void ) { #if MTASA_VERSION_TYPE == VERSION_TYPE_RELEASE const char* moduleList [] = { "MTA\\loader.dll" ,"MTA\\cgui.dll" ,"MTA\\core.dll" ,"MTA\\game_sa.dll" ,"MTA\\multiplayer_sa.dll" ,"MTA\\netc.dll" ,"MTA\\xmll.dll" ,"MTA\\game_sa.dll" ,"mods\\deathmatch\\client.dll" ,"mods\\deathmatch\\pcre3.dll" }; SString strReqFileVersion; for ( uint i = 0 ; i < NUMELMS( moduleList ) ; i++ ) { SString strFilename = moduleList[i]; #ifdef MTA_DEBUG strFilename = ExtractBeforeExtension( strFilename ) + "_d." + ExtractExtension( strFilename ); #endif SLibVersionInfo fileInfo; if ( FileExists( CalcMTASAPath( strFilename ) ) ) { SString strFileVersion = "0.0.0.0"; if ( GetLibVersionInfo( CalcMTASAPath( strFilename ), &fileInfo ) ) strFileVersion = SString( "%d.%d.%d.%d", fileInfo.dwFileVersionMS >> 16, fileInfo.dwFileVersionMS & 0xFFFF , fileInfo.dwFileVersionLS >> 16, fileInfo.dwFileVersionLS & 0xFFFF ); if ( strReqFileVersion.empty() ) strReqFileVersion = strFileVersion; else if ( strReqFileVersion != strFileVersion ) { DisplayErrorMessageBox ( SStringX(_( "File version mismatch error." " Reinstall MTA:SA if you experience problems.\n" ) + SString( "\n[%s %s/%s]\n", *strFilename, *strFileVersion, *strReqFileVersion ) ), _E("CL40"), "bad-file-version" ); break; } } else { DisplayErrorMessageBox ( SStringX(_( "Some files are missing." " Reinstall MTA:SA if you experience problems.\n" ) + SString( "\n[%s]\n", *strFilename ) ), _E("CL41"), "missing-file" ); break; } }
std::vector<SString> SharedUtil::FindFiles(const SString& strMatch, bool bFiles, bool bDirectories, bool bSortByDate) { std::vector<SString> strResult; std::multimap<uint64, SString> sortMap; DIR* Dir; struct dirent* DirEntry; // Extract any filename matching characters SString strFileMatch; SString strSearchDirectory = PathJoin(PathConform(strMatch).SplitLeft("/", &strFileMatch, -1), "/"); if ((Dir = opendir(strSearchDirectory))) { while ((DirEntry = readdir(Dir)) != NULL) { // Skip dotted entries if (strcmp(DirEntry->d_name, ".") && strcmp(DirEntry->d_name, "..")) { struct stat Info; bool bIsDir = false; // Do wildcard matching if required if (!strFileMatch.empty() && !WildcardMatch(strFileMatch, DirEntry->d_name)) { continue; } SString strPath = PathJoin(strSearchDirectory, DirEntry->d_name); // Determine the file stats if (lstat(strPath, &Info) != -1) bIsDir = S_ISDIR(Info.st_mode); if (bIsDir ? bDirectories : bFiles) { if (bSortByDate) { SString strAbsPath = strSearchDirectory + DirEntry->d_name; struct stat attrib; stat(strAbsPath, &attrib); MapInsert(sortMap, (uint64)attrib.st_mtime, SStringX(DirEntry->d_name)); } else strResult.push_back(DirEntry->d_name); } } } closedir(Dir); } // Resolve sorted map if required if (!sortMap.empty()) { for (std::multimap<uint64, SString>::iterator iter = sortMap.begin(); iter != sortMap.end(); ++iter) strResult.push_back(iter->second); } return strResult; }
void CElement::SetCustomData ( const char* szName, const CLuaArgument& Variable, CLuaMain* pLuaMain, bool bSynchronized, CPlayer* pClient, bool bTriggerEvent ) { assert ( szName ); if ( strlen ( szName ) > MAX_CUSTOMDATA_NAME_LENGTH ) { // Don't allow it to be set if the name is too long CLogger::ErrorPrintf ( "Custom data name too long (%s)\n", *SStringX ( szName ).Left ( MAX_CUSTOMDATA_NAME_LENGTH + 1 ) ); return; } // Grab the old variable CLuaArgument oldVariable; const SCustomData * pData = m_pCustomData->Get ( szName ); if ( pData ) { oldVariable = pData->Variable; } // Set the new data m_pCustomData->Set ( szName, Variable, pLuaMain, bSynchronized ); if ( bTriggerEvent ) { // Trigger the onElementDataChange event on us CLuaArguments Arguments; Arguments.PushString ( szName ); Arguments.PushArgument ( oldVariable ); Arguments.PushArgument ( Variable ); CallEvent ( "onElementDataChange", Arguments, pClient ); } }
// // CFunctionUseLogger::OnFunctionUse // void CFunctionUseLogger::OnFunctionUse( lua_State* luaVM, const char* szFunctionName, const char* szArgs, uint uiArgsSize ) { if ( m_strLogFilename.empty() ) return; CResource* pResource = g_pGame->GetResourceManager()->GetResourceFromLuaState( luaVM ); SString strResourceName = pResource ? pResource->GetName() : "Unknown"; SString strKey( "%s-%s", szFunctionName, *strResourceName ); SFuncCallRecord* pItem = MapFind( m_FuncCallRecordMap, strKey ); if ( !pItem ) { // Create new entry for this resource/function combo MapSet( m_FuncCallRecordMap, strKey, SFuncCallRecord() ); pItem = MapFind( m_FuncCallRecordMap, strKey ); pItem->strFunctionName = szFunctionName; pItem->strResourceName = strResourceName; pItem->uiCallCount = 0; pItem->timeFirstUsed = CTickCount::Now(); } pItem->uiCallCount++; if ( pItem->strExampleArgs.empty() ) pItem->strExampleArgs = SStringX( szArgs ).Left( 40 ); }
void ASE::SetRuleValue ( const char* szKey, const char* szValue ) { // Limit szKey length SString strKeyTemp; if ( szKey && strlen ( szKey ) > MAX_RULE_KEY_LENGTH ) { strKeyTemp = SStringX ( szKey ).Left ( MAX_RULE_KEY_LENGTH ); szKey = *strKeyTemp; } if ( szKey && szKey [ 0 ] ) { // Limit szValue to 200 characters SString strValueTemp; if ( szValue && strlen ( szValue ) > MAX_RULE_VALUE_LENGTH ) { strValueTemp = SStringX ( szValue ).Left ( MAX_RULE_VALUE_LENGTH ); szValue = *strValueTemp; } list < CASERule* > ::iterator iter = m_Rules.begin (); for ( ; iter != m_Rules.end () ; iter++ ) { CASERule* pRule = *iter; if ( strcmp ( (*iter)->GetKey (), szKey ) == 0 ) { if ( szValue && szValue [ 0 ] ) { (*iter)->SetValue ( szValue ); } else { // Remove from the list delete pRule; m_Rules.erase ( iter ); } // And return return; } } m_Rules.push_back ( new CASERule ( szKey, szValue ) ); } }
void SharedUtil::AddReportLog ( uint uiId, const SString& strText ) { SString strPathFilename = PathJoin ( GetMTADataPath (), "report.log" ); MakeSureDirExists ( strPathFilename ); SString strMessage ( "%u: %s %s - %s\n", uiId, GetTimeString ( true, false ).c_str (), GetReportLogHeaderText ().c_str (), strText.c_str () ); FileAppend ( strPathFilename, &strMessage.at ( 0 ), strMessage.length () ); #if MTA_DEBUG OutputDebugLine ( SStringX ( "[ReportLog] " ) + strMessage ); #endif }
CMapEvent::CMapEvent ( CLuaMain* pMain, const char* szName, const CLuaFunctionRef& iLuaFunction, bool bPropagated, EEventPriorityType eventPriority, float fPriorityMod ) { // Init m_pMain = pMain; m_bDestroyFunction = false; m_iLuaFunction = iLuaFunction; m_bPropagated = bPropagated; m_bBeingDestroyed = false; m_eventPriority = eventPriority; m_fPriorityMod = fPriorityMod; m_strName.AssignLeft ( szName, MAPEVENT_MAX_LENGTH_NAME ); // Only allow dxSetAspectRatioAdjustmentEnabled during these events m_bAllowAspectRatioAdjustment = ( m_strName == "onClientRender" ) || ( m_strName == "onClientPreRender" ) || ( m_strName == "onClientHUDRender" ); // Force aspect ratio adjustment for 'customblips' resource m_bForceAspectRatioAdjustment = m_bAllowAspectRatioAdjustment && SStringX( pMain->GetScriptName() ) == "customblips"; }
MTAEXPORT int Run ( int iArgumentCount, char* szArguments [] ) { if ( iArgumentCount > 1 ) { if ( strcmp ( szArguments[1], "--version" ) == 0 || strcmp ( szArguments[1], "-v" ) == 0 ) { printf ( MTA_DM_FULL_STRING " v" MTA_DM_BUILDTAG_LONG "\n" ); return 1; } } #ifdef WIN32 // Disable critical error message boxes SetErrorMode ( SEM_FAILCRITICALERRORS ); #endif #ifdef WIN_x86 // Apply file hooks if not already done by the client bool bSkipFileHooks = false; for( int i = 1 ; i < iArgumentCount ; i++ ) bSkipFileHooks |= SStringX( szArguments[i] ).Contains( "--clientfeedback" ); if( !bSkipFileHooks ) AddUtf8FileHooks(); #endif // Create the server #ifdef WIN32 CServerImpl Server ( &g_CommandQueue ); #else CServerImpl Server; #endif // Run the main func int iReturn; do { iReturn = Server.Run ( iArgumentCount, szArguments ); } while ( iReturn == SERVER_RESET_RETURN ); // Done #ifdef WIN_x86 RemoveUtf8FileHooks(); #endif return iReturn; }
CAccessControlListRight* CAccessControlList::GetRight ( const char* szRightName, CAccessControlListRight::ERightType eRightType ) { unsigned int uiHash = HashString ( szRightName ); list < CAccessControlListRight* > ::iterator iter = m_Rights.begin (); for ( ; iter != m_Rights.end (); iter++ ) { CAccessControlListRight* pACLRight = *iter; if ( eRightType == pACLRight->GetRightType () ) { if ( pACLRight->GetRightNameHash () == uiHash && SStringX ( szRightName ) == pACLRight->GetRightName () ) { // Exact match return pACLRight; } } } return NULL; }
const char* ASE::GetRuleValue ( const char* szKey ) { // Limit szKey length SString strKeyTemp; if ( szKey && strlen ( szKey ) > MAX_RULE_KEY_LENGTH ) { strKeyTemp = SStringX ( szKey ).Left ( MAX_RULE_KEY_LENGTH ); szKey = *strKeyTemp; } list < CASERule* > ::iterator iter = m_Rules.begin (); for ( ; iter != m_Rules.end () ; iter++ ) { if ( strcmp ( (*iter)->GetKey (), szKey ) == 0 ) { return (*iter)->GetValue (); } } return NULL; }
bool CAccessControlList::RemoveRight ( const char* szRightName, CAccessControlListRight::ERightType eRightType ) { unsigned int uiHash = HashString ( szRightName ); list < CAccessControlListRight* > ::iterator iter = m_Rights.begin (); for ( ; iter != m_Rights.end (); iter++ ) { CAccessControlListRight* pACLRight = *iter; if ( pACLRight->GetRightNameHash () == uiHash && eRightType == pACLRight->GetRightType () && SStringX ( szRightName ) == pACLRight->GetRightName () ) { m_Rights.remove ( pACLRight ); delete pACLRight; OnChange (); return true; } } return false; }
// // Case insensitive version of Replace() // SString SString::ReplaceI(const char* szOld, const char* szNew, bool bSearchJustReplaced) const { SString strOldUpper = SStringX(szOld).ToUpper(); // Check if anything to replace first size_t idx = 0; if ((idx = this->ToUpper().find(strOldUpper, idx)) == npos) return *this; size_t iOldLength = strlen(szOld); size_t iNewLength = strlen(szNew); SString strResult = *this; do { strResult.replace(idx, iOldLength, szNew); if (!bSearchJustReplaced) idx += iNewLength; } while ((idx = strResult.ToUpper().find(strOldUpper, idx)) != npos); return strResult; }
bool ASE::RemoveRuleValue ( const char* szKey ) { // Limit szKey length SString strKeyTemp; if ( szKey && strlen ( szKey ) > MAX_RULE_KEY_LENGTH ) { strKeyTemp = SStringX ( szKey ).Left ( MAX_RULE_KEY_LENGTH ); szKey = *strKeyTemp; } list < CASERule* > ::iterator iter = m_Rules.begin (); for ( ; iter != m_Rules.end () ; iter++ ) { CASERule* pRule = *iter; if ( strcmp ( pRule->GetKey (), szKey ) == 0 ) { delete pRule; m_Rules.erase ( iter ); return true; } } return false; }
void SString::AssignLeft ( const char* szOther, uint uiMaxLength ) { assign ( SStringX ( szOther ).Left ( uiMaxLength ) ); }
// Get max anisotropic setting // g_pDeviceState->AdapterState.MaxAnisotropicSetting = 0; // Make sure device can do anisotropic minification and trilinear filtering if ((g_pDeviceState->DeviceCaps.TextureFilterCaps & D3DPTFILTERCAPS_MINFANISOTROPIC) && (g_pDeviceState->DeviceCaps.TextureFilterCaps & D3DPTFILTERCAPS_MIPFLINEAR)) { int iLevel = std::max<int>(1, g_pDeviceState->DeviceCaps.MaxAnisotropy); // Convert level 1/2/4/8/16 into setting 0/1/2/3/4 while (iLevel >>= 1) g_pDeviceState->AdapterState.MaxAnisotropicSetting++; } // Clipping is required for some graphic configurations g_pDeviceState->AdapterState.bRequiresClipping = SStringX(adaptIdent.Description).Contains("Intel"); WriteDebugEvent(SString("*** Using adapter: %s (Mem:%d KB, MaxAnisotropy:%d)", (const char*)g_pDeviceState->AdapterState.Name, g_pDeviceState->AdapterState.InstalledMemoryKB, g_pDeviceState->AdapterState.MaxAnisotropicSetting)); // Give a default value for the streaming memory setting if (g_pCore->GetCVars()->Exists("streaming_memory") == false) g_pCore->GetCVars()->Set("streaming_memory", g_pCore->GetMaxStreamingMemory()); // Call event handler CDirect3DEvents9::OnDirect3DDeviceCreate(pDevice); } CProxyDirect3DDevice9::~CProxyDirect3DDevice9() { WriteDebugEvent(SString("CProxyDirect3DDevice9::~CProxyDirect3DDevice9 %08x", this));
bool CAccessControlList::CanBeModifiedByScript ( void ) { // If this isn't horrible, I don't know what is return !SStringX ( GetName () ).BeginsWith ( "autoACL_" ); }
void ASE::SetGameType ( const char * szGameType ) { m_strGameType = SStringX ( szGameType ).Left ( MAX_ASE_GAME_TYPE_LENGTH ); }
void ASE::SetMapName ( const char * szMapName ) { m_strMapName = SStringX ( szMapName ).Left ( MAX_ASE_MAP_NAME_LENGTH ); }
// // Handle format exception // void SString::OnFormatException ( const char* szFormat ) { dassert( 0 ); // Replace format characters because it seems like a good idea *this = ( SStringX( "[Format exception] " ) + szFormat ).Replace( "%", "#" ); }
//////////////////////////////////////////////////////////////// // // CEffectTemplateImpl::CreateUnderlyingData // // // //////////////////////////////////////////////////////////////// void CEffectTemplateImpl::CreateUnderlyingData ( const SString& strFilename, const SString& strRootPath, SString& strOutStatus, bool bDebug ) { assert ( !m_pD3DEffect ); // Make defines bool bUsesRAWZ = CGraphics::GetSingleton ().GetRenderItemManager ()->GetDepthBufferFormat () == RFORMAT_RAWZ; std::vector < D3DXMACRO > macroList; macroList.push_back ( D3DXMACRO () ); macroList.back ().Name = "IS_DEPTHBUFFER_RAWZ"; macroList.back ().Definition = bUsesRAWZ ? "1" : "0"; macroList.push_back ( D3DXMACRO () ); macroList.back ().Name = NULL; macroList.back ().Definition = NULL; // Compile effect DWORD dwFlags = 0; // D3DXSHADER_PARTIALPRECISION, D3DXSHADER_DEBUG, D3DXFX_NOT_CLONEABLE; if ( bDebug ) dwFlags |= D3DXSHADER_DEBUG; SString strMetaPath = strFilename.Right ( strFilename.length () - strRootPath.length () ); CIncludeManager IncludeManager ( strRootPath, ExtractPath ( strMetaPath ) ); LPD3DXBUFFER pBufferErrors = NULL; HRESULT hr = D3DXCreateEffectFromFile( m_pDevice, ExtractFilename ( strMetaPath ), ¯oList[0], &IncludeManager, dwFlags, NULL, &m_pD3DEffect, &pBufferErrors ); // Handle compile errors strOutStatus = ""; if( pBufferErrors != NULL ) { strOutStatus = SStringX ( (CHAR*)pBufferErrors->GetBufferPointer() ).TrimEnd ( "\n" ); // Error messages sometimes contain the current directory. Remove that here. SString strCurrentDirectory = GetSystemCurrentDirectory(); strOutStatus = strOutStatus.ReplaceI ( strCurrentDirectory + "\\", "" ); strOutStatus = strOutStatus.ReplaceI ( strCurrentDirectory, "" ); } SAFE_RELEASE( pBufferErrors ); if( !m_pD3DEffect ) { if ( strOutStatus.empty () ) strOutStatus = SString ( "[D3DXCreateEffectFromFile failed (%08x)%s]", hr, *IncludeManager.m_strReport ); return; } // Find first valid technique D3DXHANDLE hTechnique = NULL; D3DXEFFECT_DESC EffectDesc; m_pD3DEffect->GetDesc ( &EffectDesc ); for ( uint uiAttempt = 0 ; true ; uiAttempt++ ) { SString strProblemInfo = ""; for ( uint i = 0 ; i < EffectDesc.Techniques ; i++ ) { SString strErrorExtra; D3DXHANDLE hTemp = m_pD3DEffect->GetTechnique ( i ); HRESULT hr = m_pD3DEffect->ValidateTechnique ( hTemp ); if ( SUCCEEDED( hr ) ) { // Check depth buffer rules if ( ValidateDepthBufferUsage ( hTemp, strErrorExtra ) ) { hTechnique = hTemp; break; } } // Update problem string D3DXTECHNIQUE_DESC TechniqueDesc; m_pD3DEffect->GetTechniqueDesc( hTemp, &TechniqueDesc ); strProblemInfo += SString ( "['%s' (%d/%d) failed (%08x)%s]", TechniqueDesc.Name, i, EffectDesc.Techniques, hr, *strErrorExtra ); } // Found valid technique if ( hTechnique ) break; // Error if can't find a valid technique after 2nd attempt if ( uiAttempt > 0 ) { strOutStatus = SString ( "No valid technique; [Techniques:%d %s]%s", EffectDesc.Techniques, *strProblemInfo, *IncludeManager.m_strReport ); SAFE_RELEASE ( m_pD3DEffect ); return; } // Try resetting samplers if 1st attempt failed LPDIRECT3DDEVICE9 pDevice; m_pD3DEffect->GetDevice ( &pDevice ); for ( uint i = 0 ; i < 16 ; i++ ) { pDevice->SetSamplerState ( i, D3DSAMP_MAGFILTER, D3DTEXF_LINEAR ); pDevice->SetSamplerState ( i, D3DSAMP_MINFILTER, D3DTEXF_LINEAR ); pDevice->SetSamplerState ( i, D3DSAMP_MIPFILTER, D3DTEXF_LINEAR ); } } // Set technique m_pD3DEffect->SetTechnique( hTechnique ); // Inform user of technique name D3DXTECHNIQUE_DESC TechniqueDesc; m_pD3DEffect->GetTechniqueDesc( hTechnique, &TechniqueDesc ); strOutStatus = TechniqueDesc.Name; if ( bDebug ) { // Disassemble effect LPD3DXBUFFER pDisassembly = NULL; if ( SUCCEEDED( D3DXDisassembleEffect( m_pD3DEffect, false, &pDisassembly ) ) && pDisassembly ) { LPVOID pData = pDisassembly->GetBufferPointer(); DWORD Size = pDisassembly->GetBufferSize(); if( pData && Size ) { SString strDisassemblyContents; strDisassemblyContents.assign ( (const char*)pData, Size - 1 ); FileSave ( strFilename + ".dis", strDisassemblyContents ); } SAFE_RELEASE( pDisassembly ); } } // Copy MD5s of all loaded files m_FileMD5Map = IncludeManager.m_FileMD5Map; dassert ( !HaveFilesChanged() ); }
////////////////////////////////////////////////////////// // // BeginD3DStuff // // Look all busy and important in case any graphic drivers are looking // ////////////////////////////////////////////////////////// void BeginD3DStuff( void ) { pD3D9 = Direct3DCreate9( D3D_SDK_VERSION ); if ( !pD3D9 ) { WriteDebugEvent( "D3DStuff - Direct3DCreate9 failed" ); return; } WriteDebugEvent( "D3DStuff -------------------------" ); WriteDebugEvent( SString( "D3DStuff - Direct3DCreate9: 0x%08x", pD3D9 ) ); bool bDetectedOptimus = false; bool bDetectedNVidia = false; // Get info about each connected adapter uint uiNumAdapters = pD3D9->GetAdapterCount(); WriteDebugEvent( SString( "D3DStuff - %d Adapters", uiNumAdapters ) ); for ( uint i = 0 ; i < uiNumAdapters ; i++ ) { D3DADAPTER_IDENTIFIER9 Identifier; D3DDISPLAYMODE DisplayMode; D3DCAPS9 Caps9; HRESULT hr1 = pD3D9->GetAdapterIdentifier( i, 0, &Identifier ); HRESULT hr2 = pD3D9->GetAdapterDisplayMode( i, &DisplayMode ); HRESULT hr3 = pD3D9->GetDeviceCaps( i, D3DDEVTYPE_HAL, &Caps9 ); UINT ModeCount = pD3D9->GetAdapterModeCount( i, D3DFMT_X8R8G8B8 ); HMONITOR hMonitor = pD3D9->GetAdapterMonitor( i ); if ( FAILED( hr1 ) || FAILED( hr2 ) || FAILED( hr3 ) ) { WriteDebugEvent( SString( "D3DStuff %d Failed GetAdapterIdentifier(%x) GetAdapterDisplayMode(%x) GetDeviceCaps(%x) ", i, hr1, hr2, hr3 ) ); continue; } // Detect Optimus combo if ( SStringX( Identifier.Driver ).BeginsWithI( "nv" ) && SStringX( Identifier.Description ).BeginsWithI( "Intel" ) ) { bDetectedOptimus = true; WriteDebugEvent( SString( "D3DStuff %d - Detected Optimus Combo", i ) ); } if ( GetModuleHandle( "nvd3d9wrap.dll" ) != NULL ) { bDetectedOptimus = true; WriteDebugEvent( SString( "D3DStuff %d - Detected nvd3d9wrap", i ) ); } if ( SStringX( Identifier.Driver ).BeginsWithI( "nv" ) ) { bDetectedNVidia = true; } WriteDebugEvent( SString( "D3DStuff %d Identifier - %s", i, *ToString( Identifier ) ) ); WriteDebugEvent( SString( "D3DStuff %d DisplayMode - %s", i, *ToString( DisplayMode ) ) ); WriteDebugEvent( SString( "D3DStuff %d hMonitor:0x%08x ModeCount:%d", i, hMonitor, ModeCount ) ); WriteDebugEvent( SString( "D3DStuff %d Caps9 - %s ", i, *ToString( Caps9 ) ) ); } if ( GetApplicationSettingInt( "nvhacks", "optimus-force-detection" ) ) bDetectedOptimus = true; if ( NvOptimusDetect() ) bDetectedOptimus = true; SetApplicationSettingInt( "nvhacks", "optimus", bDetectedOptimus ); SetApplicationSettingInt( "nvhacks", "nvidia", bDetectedNVidia ); if ( bDetectedOptimus ) { ShowOptimusDialog ( g_hInstance ); HideOptimusDialog (); } else { SetApplicationSettingInt( "nvhacks", "optimus-alt-startup", 0 ); SetApplicationSettingInt( "nvhacks", "optimus-rename-exe", 0 ); SetApplicationSettingInt( "nvhacks", "optimus-export-enablement", 0 ); SetApplicationSettingInt( "nvhacks", "optimus-force-windowed", 0 ); } }
// // Handle format invalid parameter // void SString::OnInvalidParameter ( const char* szFormat ) { dassert( 0 ); // Replace format characters because it seems like a good idea *this = ( SStringX( "[Invalid parameter] " ) + szFormat ).Replace( "%", "#" ); }
// // GetMajorVersionString // SString SharedUtil::GetMajorVersionString ( void ) { return SStringX ( MTA_DM_ASE_VERSION ).Left ( 3 ); }