Changeset 27702

Timestamp:
Jun 14, 2023, 4:58:37 PM (14 months ago)
Author:
phosit
Message:

Remove FSM conditions.
FSM conditions aren't used. So this removes dead code.

Accepted By: @wraitii

Differential Revision: https://code.wildfiregames.com/D4959

Location:
ps/trunk/source/network
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/network/FSM.cpp

    r27385 r27702  
    4444{
    4545    m_Actions.clear();
    46     m_Conditions.clear();
    4746}
    4847
     
    5857}
    5958
    60 void CFsmTransition::RegisterCondition(void* pCondition, void* pContext)
    61 {
    62     CallbackFunction callback;
    63 
    64     // Add condition at the end of conditions list
    65     callback.pFunction = pCondition;
    66     callback.pContext = pContext;
    67 
    68     m_Conditions.push_back(callback);
    69 }
    70 
    7159void CFsmTransition::SetEvent(CFsmEvent* pEvent)
    7260{
     
    7765{
    7866    m_NextState = nextState;
    79 }
    80 
    81 bool CFsmTransition::ApplyConditions() const
    82 {
    83     bool eval = true;
    84 
    85     CallbackList::const_iterator it = m_Conditions.begin();
    86     for (; it != m_Conditions.end(); ++it)
    87     {
    88         if (it->pFunction)
    89         {
    90             // Evaluate condition
    91             Condition* condition = reinterpret_cast<Condition*>(it->pFunction);
    92             eval &= condition(it->pContext);
    93         }
    94     }
    95 
    96     return eval;
    9767}
    9868
     
    286256    }
    287257
    288     // Valid transition?
    289     if (!pTransition->ApplyConditions())
    290         return false;
    291 
    292258    // Save the default state transition (actions might call SetNextState
    293259    // to override this)
  • ps/trunk/source/network/FSM.h

    r27385 r27702  
    3131class CFsm;
    3232
    33 using Condition = bool(void* pContext);
    3433using Action = bool(void* pContext, const CFsmEvent* pEvent);
    3534
     
    7776
    7877/**
    79  * An association of event, condition, action and next state.
     78 * An association of event, action and next state.
    8079 */
    8180class CFsmTransition
     
    9594
    9695    /**
    97      * Registers a condition which will be evaluated when the transition occurs.
    98      * @param pCondition the predicate which will be executed.
    99      * @param pContext data passed to the predicate.
    100      */
    101     void RegisterCondition(void* pCondition, void* pContext);
    102 
    103     /**
    10496     * Set event for which transition will occur.
    10597     */
     
    128120        return m_Actions;
    129121    }
    130 
    131     const CallbackList& GetConditions() const
    132     {
    133         return m_Conditions;
    134     }
    135 
    136     /**
    137      * Evaluates conditions for the transition.
    138      * @return whether all the conditions are true.
    139      */
    140     bool ApplyConditions() const;
    141122
    142123    /**
     
    152133    CFsmEvent* m_Event;
    153134    CallbackList m_Actions;
    154     CallbackList m_Conditions;
    155135};
    156136
     
    181161
    182162    /**
    183      * Clear event, action and condition lists and reset state machine.
     163     * Clear event, action lists and reset state machine.
    184164     */
    185165    void Shutdown();
Note: See TracChangeset for help on using the changeset viewer.