Counter Strike : Global Offensive Source Code
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.

130 lines
3.9 KiB

  1. //========= Copyright � 1996-2005, 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. bool IsCreatingForXbox();
  52. // call to mark level load/end
  53. void OnLevelLoadStart(const char *levelName);
  54. void OnLevelLoadEnd();
  55. void OnLevelShutdown();
  56. void OnPlayerSpawn();
  57. void OnFullyConnected();
  58. // call to mark resources as being precached
  59. void OnResourcePrecached(const char *relativePathFileName);
  60. void OnModelPrecached(const char *relativePathFileName);
  61. void OnSoundPrecached(const char *relativePathFileName);
  62. char const *LogPrefix();
  63. void EnableDeletionsTracking();
  64. void TrackDeletions( const char *fullPathFileName );
  65. bool ShouldRebuildCaches();
  66. char const *GetResListDirectory() const;
  67. void SetAutoQuit( bool bState );
  68. private:
  69. static void TrackDeletionsLoggingFunc(const char *fullPathFileName, const char *options);
  70. static void FileSystemLoggingFunc(const char *fullPathFileName, const char *options);
  71. void OnResourcePrecachedFullPath(const char *fullPathFileName);
  72. void BuildEngineLogFromReslist();
  73. void LogToEngineReslist( char const *pLine );
  74. void WriteMapLog();
  75. void SetPrefix( char const *mapname );
  76. void SpewTrackedDeletionsLog();
  77. void DoQuit();
  78. bool m_bTrackingDeletions;
  79. bool m_bLoggingEnabled;
  80. bool m_bUsingMapList;
  81. bool m_bRestartOnTransition;
  82. bool m_bCreatingForXbox;
  83. // true for engine, false for map
  84. bool m_bLogToEngineList;
  85. bool m_bAutoQuit;
  86. // list of all maps to scan
  87. CUtlVector<maplist_map_t> m_Maps;
  88. int m_iCurrentMap;
  89. float m_flNextMapRunTime;
  90. CUtlSymbolTable m_AlreadyWrittenFileNames;
  91. int m_iPauseTimeBetweenMaps;
  92. char m_szPrefix[64];
  93. char m_szLevelName[MAX_PATH];
  94. CUtlSymbolTable m_DeletionList;
  95. CUtlRBTree< CUtlSymbol > m_DeletionListWarnings;
  96. CUtlSymbolTable m_DeletionListWarningsSymbols;
  97. CUtlRBTree< CUtlString, int > m_MapLog;
  98. CUtlRBTree< CUtlString, int > m_EngineLog;
  99. CUtlString m_sResListDir;
  100. };
  101. // singleton accessor
  102. CMapReslistGenerator &MapReslistGenerator();
  103. #endif // MAPRESLISTGENERATOR_H