From 8480cfc35f3cc1c7e6620d23dc33cc6bbef974d6 Mon Sep 17 00:00:00 2001 From: phosit Date: Wed, 14 Jun 2023 14:58:37 +0000 Subject: [PATCH] Remove FSM conditions. FSM conditions aren't used. So this removes dead code. Accepted By: @wraitii Differential Revision: https://code.wildfiregames.com/D4959 This was SVN commit r27702. --- source/network/FSM.cpp | 34 ---------------------------------- source/network/FSM.h | 24 ++---------------------- 2 files changed, 2 insertions(+), 56 deletions(-) diff --git a/source/network/FSM.cpp b/source/network/FSM.cpp index 5d4c49bd13..43bd00abfd 100644 --- a/source/network/FSM.cpp +++ b/source/network/FSM.cpp @@ -43,7 +43,6 @@ CFsmTransition::CFsmTransition(unsigned int state) CFsmTransition::~CFsmTransition() { m_Actions.clear(); - m_Conditions.clear(); } void CFsmTransition::RegisterAction(void* pAction, void* pContext) @@ -57,17 +56,6 @@ void CFsmTransition::RegisterAction(void* pAction, void* pContext) 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 @@ void CFsmTransition::SetNextState(unsigned int nextState) 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 @@ bool CFsm::Update(unsigned int eventType, void* pEventParam) 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()); diff --git a/source/network/FSM.h b/source/network/FSM.h index ce3fc22518..52dab678f2 100644 --- a/source/network/FSM.h +++ b/source/network/FSM.h @@ -30,7 +30,6 @@ class CFsmEvent; class CFsmTransition; class CFsm; -using Condition = bool(void* pContext); using Action = bool(void* pContext, const CFsmEvent* pEvent); struct CallbackFunction @@ -76,7 +75,7 @@ private: /** - * An association of event, condition, action and next state. + * An association of event, action and next state. */ class CFsmTransition { @@ -93,13 +92,6 @@ public: */ 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 @@ public: 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 @@ private: unsigned int m_NextState; CFsmEvent* m_Event; CallbackList m_Actions; - CallbackList m_Conditions; }; /** @@ -180,7 +160,7 @@ public: virtual void Setup(); /** - * Clear event, action and condition lists and reset state machine. + * Clear event, action lists and reset state machine. */ void Shutdown();