Team Fortress 2 Source Code as on 22/4/2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

128 lines
3.8 KiB

  1. //========= Copyright Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef MAPRESLISTGENERATOR_H
  7. #define MAPRESLISTGENERATOR_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "filesystem.h"
  12. #include "utlvector.h"
  13. #include "utlsymbol.h"
  14. #include "utlstring.h"
  15. // Map list creation
  16. // Map entry
  17. struct maplist_map_t
  18. {
  19. char name[64];
  20. };
  21. // General purpose maplist generator.
  22. // aMaps: Utlvector you'd like filled with the maps.
  23. // bUseMapListFile: true if you want to use a maplist file, vs parsing the maps directory or using +map
  24. // pMapFile: If you're using a maplist file, this should be the filename of it
  25. // pSystemMsg: Used to preface and debug messages
  26. // iCurrentMap: The map in the list to begin at. Handles the -startmap parameter for you.
  27. bool BuildGeneralMapList( CUtlVector<maplist_map_t> *aMaps, bool bUseMapListFile, const char *pMapFile, char *pSystemMsg, int *iCurrentMap );
  28. // initialization
  29. void MapReslistGenerator_Init();
  30. void MapReslistGenerator_Shutdown();
  31. void MapReslistGenerator_BuildMapList();
  32. //-----------------------------------------------------------------------------
  33. // Purpose: Handles collating lists of resources on level load
  34. // Used to generate reslists for steam
  35. //-----------------------------------------------------------------------------
  36. class CMapReslistGenerator
  37. {
  38. public:
  39. CMapReslistGenerator();
  40. // initializes the object to enable reslist generation
  41. void EnableReslistGeneration( bool usemaplistfile );
  42. // starts the reslist generation (starts cycling maps)
  43. void StartReslistGeneration();
  44. void BuildMapList();
  45. void Shutdown();
  46. // call every frame if we're enabled, just so that the next map can be triggered at the right time
  47. void RunFrame();
  48. // returns true if reslist generation is enabled
  49. bool IsEnabled() { return m_bLoggingEnabled; }
  50. bool IsLoggingToMap() { return m_bLoggingEnabled && !m_bLogToEngineList; }
  51. // call to mark level load/end
  52. void OnLevelLoadStart(const char *levelName);
  53. void OnLevelLoadEnd();
  54. void OnPlayerSpawn();
  55. // call to mark resources as being precached
  56. void OnResourcePrecached(const char *relativePathFileName);
  57. void OnModelPrecached(const char *relativePathFileName);
  58. void OnSoundPrecached(const char *relativePathFileName);
  59. char const *LogPrefix();
  60. void EnableDeletionsTracking();
  61. void TrackDeletions( const char *fullPathFileName );
  62. bool ShouldRebuildCaches();
  63. char const *GetResListDirectory() const;
  64. void SetAutoQuit( bool bState );
  65. private:
  66. static void TrackDeletionsLoggingFunc(const char *fullPathFileName, const char *options);
  67. static void FileSystemLoggingFunc(const char *fullPathFileName, const char *options);
  68. void OnResourcePrecachedFullPath(const char *fullPathFileName);
  69. void BuildEngineLogFromReslist();
  70. void LogToEngineReslist( char const *pLine );
  71. void WriteMapLog();
  72. void SetPrefix( char const *mapname );
  73. void SpewTrackedDeletionsLog();
  74. void DoQuit();
  75. bool m_bTrackingDeletions;
  76. bool m_bLoggingEnabled;
  77. bool m_bUsingMapList;
  78. bool m_bRestartOnTransition;
  79. // true for engine, false for map
  80. bool m_bLogToEngineList;
  81. bool m_bAutoQuit;
  82. // list of all maps to scan
  83. CUtlVector<maplist_map_t> m_Maps;
  84. int m_iCurrentMap;
  85. float m_flNextMapRunTime;
  86. int m_iFrameCountdownToRunningNextMap;
  87. CUtlSymbolTable m_AlreadyWrittenFileNames;
  88. int m_iPauseTimeBetweenMaps;
  89. int m_iPauseFramesBetweenMaps;
  90. char m_szPrefix[64];
  91. char m_szLevelName[64];
  92. CUtlSymbolTable m_DeletionList;
  93. CUtlRBTree< CUtlSymbol > m_DeletionListWarnings;
  94. CUtlSymbolTable m_DeletionListWarningsSymbols;
  95. CUtlRBTree< CUtlString, int > m_MapLog;
  96. CUtlRBTree< CUtlString, int > m_EngineLog;
  97. CUtlString m_sResListDir;
  98. };
  99. // singleton accessor
  100. CMapReslistGenerator &MapReslistGenerator();
  101. #endif // MAPRESLISTGENERATOR_H