-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvphysics_saverestore.h
128 lines (95 loc) · 5.35 KB
/
vphysics_saverestore.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#ifndef VPHYSICS_SAVERESTORE_H
#define VPHYSICS_SAVERESTORE_H
#if defined( _WIN32 )
#pragma once
#endif
#include "datamap.h"
#include "utlmap.h"
#include "isaverestore.h"
#include "utlvector.h"
//-------------------------------------
class ISave;
class IRestore;
class CPhysicsObject;
class CPhysicsFluidController;
class CPhysicsSpring;
class CPhysicsConstraint;
class CPhysicsConstraintGroup;
class CShadowController;
class CPlayerController;
class CPhysicsMotionController;
class CVehicleController;
struct physsaveparams_t;
struct physrestoreparams_t;
class ISaveRestoreOps;
//-----------------------------------------------------------------------------
// Purpose: Fixes up pointers beteween vphysics objects
//-----------------------------------------------------------------------------
class CVPhysPtrSaveRestoreOps : public CDefSaveRestoreOps
{
public:
CVPhysPtrSaveRestoreOps();
void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave );
void PreRestore();
void PostRestore();
void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore );
};
extern CVPhysPtrSaveRestoreOps g_VPhysPtrSaveRestoreOps;
//lwss - edit these macros for new typedescription_t
//#define DEFINE_VPHYSPTR(name) \
// { FIELD_CUSTOM, #name, { offsetof(classNameTypedef,name), 0 }, 1, FTYPEDESC_SAVE, NULL, &g_VPhysPtrSaveRestoreOps, NULL }
#define DEFINE_VPHYSPTR(name) \
{ FIELD_CUSTOM, #name, offsetof(classNameTypedef,name), 1, FTYPEDESC_SAVE, NULL, &g_VPhysPtrSaveRestoreOps, NULL }
//#define DEFINE_VPHYSPTR_ARRAY(name,count) \
// { FIELD_CUSTOM, #name, { offsetof(classNameTypedef,name), 0 }, count, FTYPEDESC_SAVE, NULL, &g_VPhysPtrSaveRestoreOps, NULL }
#define DEFINE_VPHYSPTR_ARRAY(name,count) \
{ FIELD_CUSTOM, #name, offsetof(classNameTypedef,name), count, FTYPEDESC_SAVE, NULL, &g_VPhysPtrSaveRestoreOps, NULL }
//lwss end
//-----------------------------------------------------------------------------
class CVPhysPtrUtlVectorSaveRestoreOps : public CVPhysPtrSaveRestoreOps
{
public:
void Save( const SaveRestoreFieldInfo_t &fieldInfo, ISave *pSave );
void Restore( const SaveRestoreFieldInfo_t &fieldInfo, IRestore *pRestore );
private:
typedef CUtlVector<int> VPhysPtrVector;
};
extern CVPhysPtrUtlVectorSaveRestoreOps g_VPhysPtrUtlVectorSaveRestoreOps;
//lwss edit this macro for new typedescription_t
//#define DEFINE_VPHYSPTR_UTLVECTOR(name) \
// { FIELD_CUSTOM, #name, { offsetof(classNameTypedef,name), 0 }, 1, FTYPEDESC_SAVE, NULL, &g_VPhysPtrUtlVectorSaveRestoreOps, NULL }
#define DEFINE_VPHYSPTR_UTLVECTOR(name) \
{ FIELD_CUSTOM, #name, offsetof(classNameTypedef,name), 1, FTYPEDESC_SAVE, NULL, &g_VPhysPtrUtlVectorSaveRestoreOps, NULL }
//lwss end
//-----------------------------------------------------------------------------
typedef bool (*PhysSaveFunc_t)( const physsaveparams_t ¶ms, void *pCastedObject ); // second parameter for convenience
typedef bool (*PhysRestoreFunc_t)( const physrestoreparams_t ¶ms, void **ppCastedObject );
bool SavePhysicsObject( const physsaveparams_t ¶ms, CPhysicsObject *pObject );
bool RestorePhysicsObject( const physrestoreparams_t ¶ms, CPhysicsObject **ppObject );
bool SavePhysicsFluidController( const physsaveparams_t ¶ms, CPhysicsFluidController *pFluidObject );
bool RestorePhysicsFluidController( const physrestoreparams_t ¶ms, CPhysicsFluidController **ppFluidObject );
bool SavePhysicsSpring( const physsaveparams_t ¶ms, CPhysicsSpring *pSpring );
bool RestorePhysicsSpring( const physrestoreparams_t ¶ms, CPhysicsSpring **ppSpring );
bool SavePhysicsConstraint( const physsaveparams_t ¶ms, CPhysicsConstraint *pConstraint );
bool RestorePhysicsConstraint( const physrestoreparams_t ¶ms, CPhysicsConstraint **ppConstraint );
bool SavePhysicsConstraintGroup( const physsaveparams_t ¶ms, CPhysicsConstraintGroup *pConstraintGroup );
bool RestorePhysicsConstraintGroup( const physrestoreparams_t ¶ms, CPhysicsConstraintGroup **ppConstraintGroup );
void PostRestorePhysicsConstraintGroup();
bool SavePhysicsShadowController( const physsaveparams_t ¶ms, IPhysicsShadowController *pShadowController );
bool RestorePhysicsShadowController( const physrestoreparams_t ¶ms, IPhysicsShadowController **ppShadowController );
bool RestorePhysicsShadowControllerInternal( const physrestoreparams_t ¶ms, IPhysicsShadowController **ppShadowController, CPhysicsObject *pObject );
bool SavePhysicsPlayerController( const physsaveparams_t ¶ms, CPlayerController *pPlayerController );
bool RestorePhysicsPlayerController( const physrestoreparams_t ¶ms, CPlayerController **ppPlayerController );
bool SavePhysicsMotionController( const physsaveparams_t ¶ms, IPhysicsMotionController *pMotionController );
bool RestorePhysicsMotionController( const physrestoreparams_t ¶ms, IPhysicsMotionController **ppMotionController );
bool SavePhysicsVehicleController( const physsaveparams_t ¶ms, CVehicleController *pVehicleController );
bool RestorePhysicsVehicleController( const physrestoreparams_t ¶ms, CVehicleController **ppVehicleController );
//-----------------------------------------------------------------------------
ISaveRestoreOps* MaterialIndexDataOps();
#endif // VPHYSICS_SAVERESTORE_H