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