AIStateMachine fixes.

Things (one debug code only) that don't happen currently,
but that I ran into with AIMultiGrid.
This commit is contained in:
Aleric Inglewood
2013-10-16 00:05:35 +02:00
parent e40d622b8c
commit 811f670199
2 changed files with 14 additions and 2 deletions

View File

@@ -700,6 +700,10 @@ void AIStateMachine::multiplex(event_type event)
// Mark that we're added to this engine, and at the same time, that we're not added to the previous one. // Mark that we're added to this engine, and at the same time, that we're not added to the previous one.
state_w->current_engine = engine; state_w->current_engine = engine;
} }
#ifdef SHOW_ASSERT
// We are leaving the loop, but we're not idle. The statemachine should re-enter the loop again.
mDebugShouldRun = true;
#endif
} }
else else
{ {

View File

@@ -217,8 +217,16 @@ class AIStateMachine : public LLThreadSafeRefCount
{ } { }
protected: protected:
// The user should call finish() (or abort(), or kill() from the call back when finish_impl() calls run()), not delete a class derived from AIStateMachine directly. // The user should call finish() (or abort(), or kill() from the call back when finish_impl() calls run()),
virtual ~AIStateMachine() { llassert(multiplex_state_type_rat(mState)->base_state == bs_killed); } // not delete a class derived from AIStateMachine directly. Deleting it directly before calling run() is
// ok however.
virtual ~AIStateMachine()
{
#ifdef SHOW_ASSERT
base_state_type state = multiplex_state_type_rat(mState)->base_state;
llassert(state == bs_killed || state == bs_reset);
#endif
}
public: public:
// These functions may be called directly after creation, or from within finish_impl(), or from the call back function. // These functions may be called directly after creation, or from within finish_impl(), or from the call back function.