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.

220 lines
6.2 KiB

  1. //========= Copyright (c) 1996-2005, Valve Corporation, All rights reserved. ============//
  2. //
  3. // Purpose:
  4. //
  5. //=============================================================================//
  6. #ifndef GAMEDATA_H
  7. #define GAMEDATA_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. #include "tier2/tokenreader.h"
  12. #include "gdclass.h"
  13. #include "inputoutput.h"
  14. #include "utlstring.h"
  15. #include "utlvector.h"
  16. #include "utlmap.h"
  17. class MDkeyvalue;
  18. class GameData;
  19. class KeyValues;
  20. //enum TEXTUREFORMAT;
  21. typedef void (*GameDataMessageFunc_t)(int level, const char *fmt, ...);
  22. // FGD-based AutoMaterialExclusion data
  23. struct FGDMatExlcusions_s
  24. {
  25. char szDirectory[MAX_PATH]; // Where we store the material exclusion directories
  26. bool bUserGenerated; // If the user specified this ( default: false -- FGD defined )
  27. };
  28. // FGD-based AutoVisGroup data
  29. struct FGDVisGroupsBaseClass_s
  30. {
  31. char szClass[MAX_PATH]; // i.e. Scene Logic, Sounds, etc "Custom\Point Entities\Lights"
  32. CUtlStringList szEntities; // i.e. func_viscluster
  33. };
  34. struct FGDAutoVisGroups_s
  35. {
  36. char szParent[MAX_PATH]; // i.e. Custom, SFM, etc
  37. CUtlVector< FGDVisGroupsBaseClass_s > m_Classes; // i.e. Scene Logic, Sounds, etc
  38. };
  39. #define MAX_DIRECTORY_SIZE 32
  40. //-----------------------------------------------------------------------------
  41. // Purpose: Contains the set of data that is loaded from a single FGD file.
  42. //-----------------------------------------------------------------------------
  43. class GameData
  44. {
  45. public:
  46. typedef enum
  47. {
  48. NAME_FIXUP_PREFIX = 0,
  49. NAME_FIXUP_POSTFIX,
  50. NAME_FIXUP_NONE
  51. } TNameFixup;
  52. GameData();
  53. ~GameData();
  54. BOOL Load(const char *pszFilename);
  55. GDclass *ClassForName(const char *pszName, int *piIndex = NULL);
  56. void ClearData();
  57. inline int GetMaxMapCoord(void);
  58. inline int GetMinMapCoord(void);
  59. inline bool IsGridNavActive(void);
  60. inline int GetGridNavEdgeSize(void);
  61. inline int GetGridNavOffsetX(void);
  62. inline int GetGridNavOffsetY(void);
  63. inline int GetTraceHeight(void);
  64. inline int GetClassCount();
  65. inline GDclass *GetClass(int nIndex);
  66. void BeginInstancing( int nPass );
  67. void BeginMapInstance( );
  68. GDclass *BeginInstanceRemap( const char *pszClassName, const char *pszInstancePrefix, Vector &Origin, QAngle &Angle );
  69. bool RemapKeyValue( const char *pszKey, const char *pszInValue, char *pszOutValue, TNameFixup NameFixup );
  70. bool RemapNameField( const char *pszInValue, char *pszOutValue, TNameFixup NameFixup );
  71. bool RemapInstanceField( const char *pszInValue, char *pszOutValue, TNameFixup NameFixup );
  72. bool LoadFGDMaterialExclusions( TokenReader &tr );
  73. bool LoadFGDAutoVisGroups( TokenReader &tr );
  74. CUtlVector< FGDMatExlcusions_s > m_FGDMaterialExclusions;
  75. CUtlVector< FGDAutoVisGroups_s > m_FGDAutoVisGroups;
  76. private:
  77. bool ParseMapSize(TokenReader &tr);
  78. bool ParseGridNav(TokenReader &tr);
  79. CUtlVector<GDclass *> m_Classes;
  80. int m_nMinMapCoord; // Min & max map bounds as defined by the FGD.
  81. int m_nMaxMapCoord;
  82. // Grid nav data
  83. bool m_bGridNavActive;
  84. int m_nGridNavEdgeSize;
  85. int m_nGridNavOffsetX;
  86. int m_nGridNavOffsetY;
  87. int m_nTraceHeight;
  88. // Instance Remapping
  89. int m_nRemapStage;
  90. Vector m_InstanceOrigin; // the origin offset of the instance
  91. QAngle m_InstanceAngle; // the rotation of the the instance
  92. matrix3x4_t m_InstanceMat; // matrix of the origin and rotation of rendering
  93. char m_InstancePrefix[ 128 ]; // the prefix used for the instance name remapping
  94. GDclass *m_InstanceClass; // the entity class that is being remapped
  95. int m_nNextNodeID;
  96. CUtlMap< int, int > m_NodeRemap;
  97. };
  98. //-----------------------------------------------------------------------------
  99. //-----------------------------------------------------------------------------
  100. inline int GameData::GetClassCount()
  101. {
  102. return m_Classes.Count();
  103. }
  104. //-----------------------------------------------------------------------------
  105. //-----------------------------------------------------------------------------
  106. inline GDclass *GameData::GetClass(int nIndex)
  107. {
  108. if (nIndex >= m_Classes.Count())
  109. return NULL;
  110. return m_Classes.Element(nIndex);
  111. }
  112. //-----------------------------------------------------------------------------
  113. // Purpose:
  114. //-----------------------------------------------------------------------------
  115. int GameData::GetMinMapCoord(void)
  116. {
  117. return m_nMinMapCoord;
  118. }
  119. //-----------------------------------------------------------------------------
  120. // Purpose:
  121. //-----------------------------------------------------------------------------
  122. int GameData::GetMaxMapCoord(void)
  123. {
  124. return m_nMaxMapCoord;
  125. }
  126. //-----------------------------------------------------------------------------
  127. // Purpose:
  128. //-----------------------------------------------------------------------------
  129. bool GameData::IsGridNavActive(void)
  130. {
  131. return m_bGridNavActive;
  132. }
  133. //-----------------------------------------------------------------------------
  134. // Purpose:
  135. //-----------------------------------------------------------------------------
  136. int GameData::GetGridNavEdgeSize(void)
  137. {
  138. return m_nGridNavEdgeSize;
  139. }
  140. //-----------------------------------------------------------------------------
  141. // Purpose:
  142. //-----------------------------------------------------------------------------
  143. int GameData::GetGridNavOffsetX(void)
  144. {
  145. return m_nGridNavOffsetX;
  146. }
  147. //-----------------------------------------------------------------------------
  148. // Purpose:
  149. //-----------------------------------------------------------------------------
  150. int GameData::GetGridNavOffsetY(void)
  151. {
  152. return m_nGridNavOffsetY;
  153. }
  154. //-----------------------------------------------------------------------------
  155. // Purpose:
  156. //-----------------------------------------------------------------------------
  157. int GameData::GetTraceHeight(void)
  158. {
  159. return m_nTraceHeight;
  160. }
  161. void GDSetMessageFunc(GameDataMessageFunc_t pFunc);
  162. bool GDError(TokenReader &tr, char *error, ...);
  163. bool GDSkipToken(TokenReader &tr, trtoken_t ttexpecting = TOKENNONE, const char *pszExpecting = NULL);
  164. bool GDGetToken(TokenReader &tr, char *pszStore, int nSize, trtoken_t ttexpecting = TOKENNONE, const char *pszExpecting = NULL);
  165. bool GDGetTokenDynamic(TokenReader &tr, char **pszStore, trtoken_t ttexpecting, const char *pszExpecting = NULL);
  166. #endif // GAMEDATA_H