[Fix] Should eliminate the possibility of pilots getting destroyed by a
hook while being updated.
This commit is contained in:
parent
2ff980a937
commit
35f8570f83
@ -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. */
|
||||
|
||||
|
11
src/pilot.c
11
src/pilot.c
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user