mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-07-04 05:55:47 -07:00
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.
This commit is contained in:
parent
298f207e5b
commit
8480cfc35f
2 changed files with 2 additions and 56 deletions
|
|
@ -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<Condition*>(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());
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue