[Fix] Should eliminate the possibility of pilots getting destroyed by a

hook while being updated.
This commit is contained in:
Allanis 2014-05-27 15:52:06 +01:00
parent 2ff980a937
commit 35f8570f83
2 changed files with 14 additions and 5 deletions

View File

@ -386,9 +386,13 @@ void missions_update(const double dt) {
}
}
/* Clean up a mission. */
/**
* @brief Clean up a mission.
* @param misn Mission to clean up.
*/
void mission_cleanup(Mission* misn) {
int i;
if(misn->id != 0)
hook_rmParent(misn->id); /* Remove existing hooks. */

View File

@ -1821,6 +1821,12 @@ void pilots_update(double dt) {
for(i = 0; i < pilot_nstack; i++) {
p = pilot_stack[i];
/* Destroy pilot and go on. */
if(pilot_isFlag(p, PILOT_DELETE)) {
pilot_destroy(p);
continue;
}
/* See if should think. */
if(p->think && !pilot_isDisabled(p)) {
/* Hyperspace gets special treatment. */
@ -1834,10 +1840,9 @@ void pilots_update(double dt) {
else
p->think(p);
}
/* Just update the pilot. */
if(p->update) { /* Update. */
if(pilot_isFlag(p, PILOT_DELETE))
pilot_destroy(p);
else
p->update(p, dt);
}
}