(svn r12249) [NoAI] -Fix: finally found why closing the game gave an assert() on running AIs
--- a/src/ai/ai_threads.cpp Mon Feb 25 14:03:14 2008 +0000
+++ b/src/ai/ai_threads.cpp Mon Feb 25 14:34:16 2008 +0000
@@ -130,6 +130,8 @@
/* XXX -- It might be nice to throw an exception, as it is easier to handle */
//throw std::exception();
//NOT_REACHED();
+
+ main->SwitchToThis(RUNNING);
return;
}
assert(this->state == RUNNING);
@@ -315,8 +317,6 @@
/*virtual*/ ~AIThread_MT()
{
DEBUG(ai, 3, "-AIThread_MT(%d) from thr %u", this->fiber_id, ThreadObject::CurrentId());
- bool wait_ok = this->thr->IsCurrent() ? true : this->thr->WaitForStop();
- assert(wait_ok);
this->evt_go.Detach();
}
@@ -406,6 +406,8 @@
assert(cur->fiber_id == MAIN_THREAD);
assert(this->state == SUSPENDED);
this->SwitchToThis(STOPPING);
+ assert(this->state == SUSPENDED);
+ this->state = STOPPED;
}
/**
@@ -592,6 +594,8 @@
assert(cur->fiber_id == MAIN_THREAD);
assert(this->state == SUSPENDED);
this->SwitchToThis(STOPPING);
+ assert(this->state == SUSPENDED);
+ this->state = STOPPED;
this->DeleteFiber();
}