273 |
273 |
274 /* We want to skip the first tick, so switch back to the main fiber */ |
274 /* We want to skip the first tick, so switch back to the main fiber */ |
275 AIFiber *main = stFind(MAIN_FIBER); |
275 AIFiber *main = stFind(MAIN_FIBER); |
276 main->SwitchToState(RUNNING); |
276 main->SwitchToState(RUNNING); |
277 |
277 |
278 /* Start up the AI (this should be an infinite loop) */ |
278 if (this->state != STOPPING) { |
279 this->controller->Start(); |
279 /* Start up the AI (this should be an infinite loop) */ |
280 |
280 this->controller->Start(); |
281 /* If we come here, the AI exited because it wanted to */ |
281 |
282 DEBUG(ai, 1, "We've got a suicidal AI for player %d", this->fiber_id); |
282 /* If we come here, the AI exited because it wanted to */ |
283 |
283 DEBUG(ai, 1, "We've got a suicidal AI for player %d", this->fiber_id); |
284 /* Wait until we are killed nicely by the game */ |
284 |
285 while (this->state != STOPPING) { |
285 /* Wait until we are killed nicely by the game */ |
286 main->SwitchToState(RUNNING); |
286 while (this->state != STOPPING) { |
|
287 main->SwitchToState(RUNNING); |
|
288 } |
287 } |
289 } |
288 |
290 |
289 /* Suspend, and exit */ |
291 /* Suspend, and exit */ |
290 this->state = SUSPENDED; |
292 this->state = SUSPENDED; |
291 this->Exit(); |
293 this->Exit(); |