[Fix] New player cleanup stuff.

This commit is contained in:
Allanis 2013-06-22 20:43:57 +01:00
parent c536ede0fb
commit d8705a6f7a
3 changed files with 20 additions and 2 deletions

View File

@ -1057,6 +1057,15 @@ void pilots_clean(void) {
pilots = 1;
}
void pilots_cleanAll(void) {
pilots_clean();
if(player != NULL) {
pilot_free(player);
player = NULL;
}
pilots = 0;
}
// Update all pilots.
void pilots_update(double dt) {
int i;

View File

@ -183,6 +183,7 @@ Pilot* pilot_copy(Pilot* src);
void pilot_destroy(Pilot* p);
void pilots_free(void);
void pilots_clean(void);
void pilots_cleanAll(void);
void pilot_free(Pilot* p);
int fleet_load(void); // TODO
void fleet_free(void);

View File

@ -377,10 +377,10 @@ void player_cleanup(void) {
player_clear();
// Cleanup name.
// Clean up name.
if(player_name != NULL) free(player_name);
// Cleanup messages.
// Clean up messages.
for(i = 0; i < msg_max; i++)
memset(msg_stack[i].str, '\0', MSG_SIZE_MAX);
@ -397,12 +397,20 @@ void player_cleanup(void) {
// Nothing left.
player_nstack = 0;
}
// Clean up missions.
if(missions_done != NULL) {
free(missions_done);
missions_done = NULL;
missions_ndone = 0;
missions_mdone = 0;
}
pilots_cleanAll();
if(player != NULL) {
pilot_free(player);
player = NULL;
}
}
// Initializes the player sound.