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.

87 lines
2.2 KiB

  1. //====== Copyright c 1996-2007, Valve Corporation, All rights reserved. =======//
  2. //
  3. // Purpose:
  4. //
  5. // $NoKeywords: $
  6. //
  7. //=============================================================================//
  8. #ifndef VMFMESHDATASUPPORT_H
  9. #define VMFMESHDATASUPPORT_H
  10. #ifdef _WIN32
  11. #pragma once
  12. #endif
  13. //////////////////////////////////////////////////////////////////////////
  14. //
  15. // Special implementation of custom load/save chunks for entities
  16. //
  17. //////////////////////////////////////////////////////////////////////////
  18. #include "vmfentitysupport.h"
  19. class CVmfMeshDataSupport_SaveLoadHandler : public IMapEntitySaveLoadHandler
  20. {
  21. public:
  22. CVmfMeshDataSupport_SaveLoadHandler();
  23. ~CVmfMeshDataSupport_SaveLoadHandler();
  24. public:
  25. virtual int GetCustomSectionVer() { return 1; }
  26. public:
  27. virtual void SetCurrentEntity( IMapEntity_Type_t *pEntity ) { m_pEntity = pEntity; }
  28. public:
  29. virtual ChunkFileResult_t LoadKeyValueBegin( CChunkFile *pFile );
  30. virtual ChunkFileResult_t LoadKeyValue( const char *szKey, const char *szValue );
  31. virtual ChunkFileResult_t LoadKeyValueEnd( CChunkFile *pFile, ChunkFileResult_t eLoadResult );
  32. protected:
  33. ChunkFileResult_t LoadKeyValue_Hdr( const char *szKey, const char *szValue );
  34. ChunkFileResult_t LoadKeyValue_Ver1( const char *szKey, const char *szValue );
  35. protected:
  36. ChunkFileResult_t WriteDataChunk( CChunkFile *pFile, char const *szHash );
  37. ChunkFileResult_t WriteBufferData( CChunkFile *pFile, CUtlBuffer &bufData, char const *szPrefix );
  38. void LoadInitHeader();
  39. bool LoadHaveHeader();
  40. ChunkFileResult_t LoadHaveLines( int numHaveLines );
  41. ChunkFileResult_t LoadSaveFullData();
  42. protected:
  43. virtual ChunkFileResult_t OnFileDataLoaded( CUtlBuffer &bufData ) = 0;
  44. virtual ChunkFileResult_t OnFileDataWriting( CChunkFile *pFile, char const *szHash );
  45. protected:
  46. enum State
  47. {
  48. LOAD_VERSION = 0,
  49. LOAD_HDR_END
  50. };
  51. enum StateVer1
  52. {
  53. LOAD_HASH = LOAD_HDR_END + 1,
  54. LOAD_PREFIX,
  55. LOAD_HEADER,
  56. LOAD_DATA
  57. };
  58. int m_eLoadState;
  59. int m_iLoadVer;
  60. struct Header_t
  61. {
  62. char sHash[ MAX_PATH ];
  63. char sPrefix[ MAX_PATH ];
  64. int numBytes;
  65. int numEncBytes;
  66. int numLines;
  67. int numHaveLines;
  68. }
  69. m_hLoadHeader;
  70. CUtlBuffer m_bufLoadData;
  71. IMapEntity_Type_t *m_pEntity;
  72. };
  73. #endif // #ifndef VMFMESHDATASUPPORT_H