/******************************************************************************/ // 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 : dStateBase_c class /******************************************************************************/ template 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 dState_c::~dState_c() { } template bool dState_c::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 void dState_c::doBegin(TOwner *owner) { (owner->*mBegin)(); } template void dState_c::doExecute(TOwner *owner) { (owner->*mExecute)(); } template void dState_c::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 : dStateMgrBase_c class /******************************************************************************/ template 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