Index: source/network/FSM.h =================================================================== --- source/network/FSM.h +++ source/network/FSM.h @@ -30,7 +30,6 @@ class CFsmTransition; class CFsm; -using Condition = bool(void* pContext); using Action = bool(void* pContext, const CFsmEvent* pEvent); struct CallbackFunction @@ -76,7 +75,7 @@ /** - * An association of event, condition, action and next state. + * An association of event, action and next state. */ class CFsmTransition { @@ -93,13 +92,6 @@ */ void RegisterAction(void* pAction, void* pContext); - /** - * Registers a condition which will be evaluated when the transition occurs. - * @param pCondition the predicate which will be executed. - * @param pContext data passed to the predicate. - */ - void RegisterCondition(void* pCondition, void* pContext); - /** * Set event for which transition will occur. */ @@ -128,17 +120,6 @@ return m_Actions; } - const CallbackList& GetConditions() const - { - return m_Conditions; - } - - /** - * Evaluates conditions for the transition. - * @return whether all the conditions are true. - */ - bool ApplyConditions() const; - /** * Executes actions for the transition. * @note If there are no actions, assume true. @@ -151,7 +132,6 @@ unsigned int m_NextState; CFsmEvent* m_Event; CallbackList m_Actions; - CallbackList m_Conditions; }; /** @@ -180,7 +160,7 @@ virtual void Setup(); /** - * Clear event, action and condition lists and reset state machine. + * Clear event, action lists and reset state machine. */ void Shutdown(); Index: source/network/FSM.cpp =================================================================== --- source/network/FSM.cpp +++ source/network/FSM.cpp @@ -43,7 +43,6 @@ CFsmTransition::~CFsmTransition() { m_Actions.clear(); - m_Conditions.clear(); } void CFsmTransition::RegisterAction(void* pAction, void* pContext) @@ -57,17 +56,6 @@ m_Actions.push_back(callback); } -void CFsmTransition::RegisterCondition(void* pCondition, void* pContext) -{ - CallbackFunction callback; - - // Add condition at the end of conditions list - callback.pFunction = pCondition; - callback.pContext = pContext; - - m_Conditions.push_back(callback); -} - void CFsmTransition::SetEvent(CFsmEvent* pEvent) { m_Event = pEvent; @@ -78,24 +66,6 @@ m_NextState = nextState; } -bool CFsmTransition::ApplyConditions() const -{ - bool eval = true; - - CallbackList::const_iterator it = m_Conditions.begin(); - for (; it != m_Conditions.end(); ++it) - { - if (it->pFunction) - { - // Evaluate condition - Condition* condition = reinterpret_cast(it->pFunction); - eval &= condition(it->pContext); - } - } - - return eval; -} - bool CFsmTransition::RunActions() const { bool result = true; @@ -285,10 +255,6 @@ pEvent->SetParamRef(pEventParam); } - // Valid transition? - if (!pTransition->ApplyConditions()) - return false; - // Save the default state transition (actions might call SetNextState // to override this) SetNextState(pTransition->GetNextState());