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
129
130
131
132
133
|
/******************************************************************************/
// dStateBase_c class
/******************************************************************************/
class dStateBase_c {
public:
dStateBase_c(const char *name);
virtual ~dStateBase_c();
virtual bool isInvalid();
virtual bool isEqualNotUsedForSomeReason(dStateBase_c *another);
virtual bool isEqual(dStateBase_c *another);
virtual bool isNotEqual(dStateBase_c *another);
virtual bool isSameStateName(const char *name);
virtual const char *getName();
virtual int getID();
static dStateBase_c mNoState;
private:
const char *mName;
int mID;
static int mLastID;
};
/******************************************************************************/
// dState_c<TOwner> : dStateBase_c class
/******************************************************************************/
template <class TOwner>
class dState_c : public dStateBase_c {
public:
typedef void (TOwner::*funcPtr)();
dState_c(const char *name, funcPtr begin, funcPtr execute, funcPtr end) : dStateBase_c(name) {
mBegin = begin;
mExecute = execute;
mEnd = end;
}
~dState_c();
bool isSameStateName(const char *name);
virtual void doBegin(TOwner *owner);
virtual void doExecute(TOwner *owner);
virtual void doEnd(TOwner *owner);
funcPtr mBegin;
funcPtr mExecute;
funcPtr mEnd;
};
template <class TOwner>
dState_c<TOwner>::~dState_c() { }
template <class TOwner>
bool dState_c<TOwner>::isSameStateName(const char *name) {
const char *p = strrchr(name, ':');
if (p)
name = p + 1;
int cmp = strcmp(strrchr(getName(), ':')+1, name);
if (cmp == 0)
return true;
else
return false;
}
template <class TOwner>
void dState_c<TOwner>::doBegin(TOwner *owner) {
(owner->*mBegin)();
}
template <class TOwner>
void dState_c<TOwner>::doExecute(TOwner *owner) {
(owner->*mExecute)();
}
template <class TOwner>
void dState_c<TOwner>::doEnd(TOwner *owner) {
(owner->*mEnd)();
}
/******************************************************************************/
// dStateMgrBase_c class
/******************************************************************************/
class dStateMgrBase_c {
public:
dStateMgrBase_c(void *one, void *two, dStateBase_c *pInitState);
virtual ~dStateMgrBase_c();
virtual void _vf0C();
virtual void execute();
virtual void _vf14();
virtual void setState(dStateBase_c *pNewState);
virtual void setField10ToOne();
virtual dStateBase_c *getField20();
virtual dStateBase_c *getField14();
virtual dStateBase_c *getCurrentState_maybe();
virtual dStateBase_c *getField18();
virtual bool _vf30() = 0;
virtual void _vf34() = 0;
virtual void _vf38() = 0;
virtual void _vf3C(dStateBase_c *pState) = 0;
private:
void *m04, *m08;
bool m0C, m0D, m0E, m0F, m10;
dStateBase_c *m14, *m18, *m1C;
dStateBase_c *m20; // maybe not a dStateBase_c?
};
/******************************************************************************/
// dStateMgr_c<TOwner> : dStateMgrBase_c class
/******************************************************************************/
template <class TOwner>
class dStateMgr_c : public dStateMgrBase_c {
public:
dStateMgr_c(void *one, void *two, dStateBase_c *pInitState);
~dStateMgr_c();
bool _vf30();
void _vf34();
void _vf38();
void _vf3C(dStateBase_c *pState);
};
// TODO: add template methods
|