//-----------------------------------------------------------------------------
// CMaterialFileChangeWatcher implementation.
//-----------------------------------------------------------------------------
void CMaterialFileChangeWatcher::Init( CTextureSystem *pSystem, int context )
{
	m_pTextureSystem = pSystem;
	m_Context = context;

	m_Watcher.Init( this );
	
	char searchPaths[1024 * 16];
	if ( g_pFullFileSystem->GetSearchPath( "GAME", false, searchPaths, sizeof( searchPaths ) ) > 0 )
	{
		CUtlVector<char*> searchPathList;
		V_SplitString( searchPaths, ";", searchPathList );

		for ( int i=0; i < searchPathList.Count(); i++ )
		{
			m_Watcher.AddDirectory( searchPathList[i], "materials", true );
		}
		
		searchPathList.PurgeAndDeleteElements();
	}
	else
	{
		Warning( "Error in GetSearchPath. Dynamic material list updating will not be available." );
	}
}
static const char *WeaponNameFixer(const char *token, char *out, int size)
{
	//heres some special stuff to use more common names that are inside ()'s
	// (sort of hacky)
	vgui::Label *temp = new vgui::Label(NULL,"TEMP",token);
	temp->GetText(out,size);
	CUtlVector<char *>szCont;
	V_SplitString(out, "(", szCont);
	if(szCont.Count()>1)
	{
		V_StrSubst(szCont[1],")","",out,size);
	}
	temp->DeletePanel();

	return (const char *)out;
}
FSReturnCode_t FileSystem_LoadSearchPaths( CFSSearchPathsInit &initInfo )
{
	if ( !initInfo.m_pFileSystem || !initInfo.m_pDirectoryName )
		return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_LoadSearchPaths: Invalid parameters specified." );

	KeyValues *pMainFile, *pFileSystemInfo, *pSearchPaths;
	FSReturnCode_t retVal = LoadGameInfoFile( initInfo.m_pDirectoryName, pMainFile, pFileSystemInfo, pSearchPaths );
	if ( retVal != FS_OK )
		return retVal;
	
	// All paths except those marked with |gameinfo_path| are relative to the base dir.
	char baseDir[MAX_PATH];
	if ( !FileSystem_GetBaseDir( baseDir, sizeof( baseDir ) ) )
		return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetBaseDir failed." );

	// The MOD directory is always the one that contains gameinfo.txt
	Q_strncpy( initInfo.m_ModPath, initInfo.m_pDirectoryName, sizeof( initInfo.m_ModPath ) );

	#define GAMEINFOPATH_TOKEN		"|gameinfo_path|"
	#define BASESOURCEPATHS_TOKEN	"|all_source_engine_paths|"

	const char *pszExtraSearchPath = CommandLine()->ParmValue( "-insert_search_path" );
	if ( pszExtraSearchPath )
	{
		CUtlStringList vecPaths;
		V_SplitString( pszExtraSearchPath, ",", vecPaths );
		FOR_EACH_VEC( vecPaths, idxExtraPath )
		{
			char szAbsSearchPath[MAX_PATH];
			Q_StripPrecedingAndTrailingWhitespace( vecPaths[ idxExtraPath ] );
			V_MakeAbsolutePath( szAbsSearchPath, sizeof( szAbsSearchPath ), vecPaths[ idxExtraPath ], baseDir );
			V_FixSlashes( szAbsSearchPath );
			if ( !V_RemoveDotSlashes( szAbsSearchPath ) )
				Error( "Bad -insert_search_path - Can't resolve pathname for '%s'", szAbsSearchPath );
			V_StripTrailingSlash( szAbsSearchPath );
			FileSystem_AddLoadedSearchPath( initInfo, "GAME", szAbsSearchPath, false );
			FileSystem_AddLoadedSearchPath( initInfo, "MOD", szAbsSearchPath, false );
		}
	}
Пример #4
0
void GameRulesHelper::OnServerActivated()
{
	
	printf("Doin stuf\n");
	m_pGameRulesProxy = UTIL_FindEntityByClassname(nullptr, "dota_gamerules");
	m_pGameManagerProxy = UTIL_FindEntityByClassname(nullptr, "dota_gamemanager");

	auto *pSendTable = ((IServerUnknown *) m_pGameRulesProxy)->GetNetworkable()->GetServerClass()->m_pTable;
	auto *pManagerSendTable = ((IServerUnknown *)m_pGameManagerProxy)->GetNetworkable()->GetServerClass()->m_pTable;

	if (!s_bHaveOffsets)
	{
		m_Offsets.m_nSeriesType = UTIL_FindInSendTable(pSendTable, "m_nSeriesType");
		m_Offsets.m_nRadiantSeriesWins = UTIL_FindInSendTable(pSendTable, "m_nRadiantSeriesWins");
		m_Offsets.m_nDireSeriesWins = UTIL_FindInSendTable(pSendTable, "m_nDireSeriesWins");
		m_Offsets.m_nGameState = UTIL_FindInSendTable(pSendTable, "m_nGameState");
		m_Offsets.m_fGameTime = UTIL_FindInSendTable(pSendTable, "m_fGameTime");
		m_Offsets.m_nGGTeam = UTIL_FindInSendTable(pSendTable, "m_nGGTeam");
		m_Offsets.m_flGGEndsAtTime = UTIL_FindInSendTable(pSendTable, "m_flGGEndsAtTime");
		m_Offsets.m_iGameMode = UTIL_FindInSendTable(pSendTable, "m_iGameMode");
		m_Offsets.m_bGamePaused = UTIL_FindInSendTable(pSendTable, "m_bGamePaused");
		m_Offsets.m_iPauseTeam = UTIL_FindInSendTable(pSendTable, "m_iPauseTeam");
		m_Offsets.m_StableHeroAvailable = UTIL_FindInSendTable(pManagerSendTable, "m_StableHeroAvailable");
		m_Offsets.m_CurrentHeroAvailable = UTIL_FindInSendTable(pManagerSendTable, "m_CurrentHeroAvailable");
		m_Offsets.m_CulledHeroes = UTIL_FindInSendTable(pManagerSendTable, "m_CulledHeroes");

		s_bHaveOffsets = true;
	}

	m_pGameRules = nullptr;
	m_pGameManager = nullptr;

	for (int i = 0; i < pSendTable->GetNumProps(); i++)
	{
		auto pProp = pSendTable->GetProp(i);

		if (pProp->GetDataTable() && !Q_strcmp("dota_gamerules_data", pProp->GetName()))
		{
			auto proxyFn = pProp->GetDataTableProxyFn();
			if (proxyFn)
			{
				CSendProxyRecipients recp;
				m_pGameRules = proxyFn(NULL, NULL, NULL, &recp, 0);
			}

			break;
		}
	}

	for (int i = 0; i < pManagerSendTable->GetNumProps(); i++)
	{
		auto pProp = pManagerSendTable->GetProp(i);

		if (pProp->GetDataTable() && !Q_strcmp("dota_gamemanager_data", pProp->GetName()))
		{
			auto proxyFn = pProp->GetDataTableProxyFn();

			if (proxyFn)
			{
				CSendProxyRecipients recp;
				m_pGameManager = proxyFn(NULL, NULL, NULL, &recp, 0);
				printf("Manager name: %d\n", m_pGameManager);
			}

			break;
		}
	}

	const char *pszBannedHeroes = CommandLine()->ParmValue("-d2bannedheroes", "");
	if (pszBannedHeroes && pszBannedHeroes[0])
	{
		V_SplitString(pszBannedHeroes, ",", bannedHeroes);
	}

	BanThem();
}
Пример #5
0
void CNB_Select_Level_Panel::UpdateLevelList() 
{
	const char *mapcfile = m_pMapListFile;

	// Check the time of the mapcycle file and re-populate the list of level names if the file has been modified
	const int nMapCycleTimeStamp = filesystem->GetPathTime( mapcfile, "GAME" );

	char *szDefaultMapName = "sdk_teams_hdr";

	if ( 0 == nMapCycleTimeStamp )
	{
		// Map cycle file does not exist, make a list containing only the default map
		m_MapList.AddToTail( szDefaultMapName );
	}
	else
	{
		// Clear out existing map list. Not using Purge() because I don't think that it will do a 'delete []'
		for ( int i = 0; i < m_MapList.Count(); i++ )
		{
			delete [] m_MapList[i];
		}

		m_MapList.RemoveAll();

		// Repopulate map list from mapcycle file
		int nFileLength;
		char *aFileList = (char*)UTIL_LoadFileForMe( mapcfile, &nFileLength );
		if ( aFileList && nFileLength )
		{
			V_SplitString( aFileList, "\n", m_MapList );

			for ( int i = 0; i < m_MapList.Count(); i++ )
			{
				bool bIgnore = false;

				// Strip out the spaces in the name
				StripChar( m_MapList[i] , '\r');
				StripChar( m_MapList[i] , ' ');
						
				/*
				if ( !engine->IsMapValid( m_MapList[i] ) )
				{
					bIgnore = true;

					// If the engine doesn't consider it a valid map remove it from the lists
					char szWarningMessage[MAX_PATH];
					V_snprintf( szWarningMessage, MAX_PATH, "Invalid map '%s' included in map cycle file. Ignored.\n", m_MapList[i] );
					Warning( szWarningMessage );
				}
				else */if ( !Q_strncmp( m_MapList[i], "//", 2 ) )
				{
					bIgnore = true;
				}

				if ( bIgnore )
				{
					delete [] m_MapList[i];
					m_MapList.Remove( i );
					--i;
				}
			}

			UTIL_FreeFile( (byte *)aFileList );
		}

		// If somehow we have no maps in the list then add the default one
		if ( 0 == m_MapList.Count() )
		{
			m_MapList.AddToTail( szDefaultMapName );
		}

		// Now rebuild the level entry list
		//m_pHorizList->m_Entries.PurgeAndDeleteElements();

		// Create entries
		for ( int i = 0; i < m_MapList.Count(); i++ )
		{
			if ( m_pHorizList->m_Entries.Count() <= i )
			{
				CNB_Select_Level_Entry *pEntry = new CNB_Select_Level_Entry( NULL, "Select_Level_Entry", m_MapList[i] );
				m_pHorizList->AddEntry( pEntry );
			}
			else
			{
				CNB_Select_Level_Entry *pEntry = dynamic_cast<CNB_Select_Level_Entry*>( m_pHorizList->m_Entries[i].Get() );
				pEntry->SetMap( m_MapList[i] );
			}
		}
	}
}
Пример #6
0
	void CMultiplayRules::GetNextLevelName( char *pszNextMap, int bufsize, bool bRandom /* = false */ )
	{
		const char *mapcfile = mapcyclefile.GetString();
		Assert( mapcfile != NULL );

		// Check the time of the mapcycle file and re-populate the list of level names if the file has been modified
		const int nMapCycleTimeStamp = filesystem->GetPathTime( mapcfile, "GAME" );

		if ( 0 == nMapCycleTimeStamp )
		{
			// Map cycle file does not exist, make a list containing only the current map
			char *szCurrentMapName = new char[32];
			Q_strncpy( szCurrentMapName, STRING(gpGlobals->mapname), 32 );
			m_MapList.AddToTail( szCurrentMapName );
		}
		else
		{
			// If map cycle file has changed or this is the first time through ...
			if ( m_nMapCycleTimeStamp != nMapCycleTimeStamp )
			{
				// Reset map index and map cycle timestamp
				m_nMapCycleTimeStamp = nMapCycleTimeStamp;
				m_nMapCycleindex = 0;

				// Clear out existing map list. Not using Purge() because I don't think that it will do a 'delete []'
				for ( int i = 0; i < m_MapList.Count(); i++ )
				{
					delete [] m_MapList[i];
				}

				m_MapList.RemoveAll();

				// Repopulate map list from mapcycle file
				int nFileLength;
				char *aFileList = (char*)UTIL_LoadFileForMe( mapcfile, &nFileLength );
				if ( aFileList && nFileLength )
				{
					V_SplitString( aFileList, "\n", m_MapList );

					for ( int i = 0; i < m_MapList.Count(); i++ )
					{
						bool bIgnore = false;

						// Strip out the spaces in the name
						StripChar( m_MapList[i] , '\r');
						StripChar( m_MapList[i] , ' ');
						
						if ( !engine->IsMapValid( m_MapList[i] ) )
						{
							bIgnore = true;

							// If the engine doesn't consider it a valid map remove it from the lists
							char szWarningMessage[MAX_PATH];
							V_snprintf( szWarningMessage, MAX_PATH, "Invalid map '%s' included in map cycle file. Ignored.\n", m_MapList[i] );
							Warning( szWarningMessage );
						}
						else if ( !Q_strncmp( m_MapList[i], "//", 2 ) )
						{
							bIgnore = true;
						}

						if ( bIgnore )
						{
							delete [] m_MapList[i];
							m_MapList.Remove( i );
							--i;
						}
					}

					UTIL_FreeFile( (byte *)aFileList );
				}
			}
		}

		// If somehow we have no maps in the list then add the current one
		if ( 0 == m_MapList.Count() )
		{
			char *szDefaultMapName = new char[32];
			Q_strncpy( szDefaultMapName, STRING(gpGlobals->mapname), 32 );
			m_MapList.AddToTail( szDefaultMapName );
		}

		if ( bRandom )
		{
			m_nMapCycleindex = RandomInt( 0, m_MapList.Count() - 1 );
		}

		// Here's the return value
		Q_strncpy( pszNextMap, m_MapList[m_nMapCycleindex], bufsize);
	}