[Change] Some cleanup with loading.
This commit is contained in:
parent
2dc53af39c
commit
f63605d605
@ -54,6 +54,8 @@ int indjoystick = -1;
|
||||
char* namjoystick = NULL;
|
||||
|
||||
// Prototypes.
|
||||
static void load_all(void);
|
||||
static void unload_all(void);
|
||||
void main_loop(void);
|
||||
static void display_fps(const double dt);
|
||||
static void window_caption(void);
|
||||
@ -153,13 +155,7 @@ int main(int argc, char** argv) {
|
||||
toolkit_init(); // Init the toolkit.
|
||||
|
||||
// Data loading.
|
||||
commodity_load();
|
||||
factions_load();
|
||||
spfx_load();
|
||||
outfit_load();
|
||||
ships_load();
|
||||
fleet_load();
|
||||
space_load();
|
||||
load_all();
|
||||
|
||||
menu_main();
|
||||
|
||||
@ -180,18 +176,18 @@ int main(int argc, char** argv) {
|
||||
main_loop();
|
||||
}
|
||||
|
||||
// Unload data.
|
||||
// Clean up some stuff.
|
||||
player_cleanup(); // Cleans up the player stuff.
|
||||
gui_free(); // Free up the gui.
|
||||
weapon_exit(); // Destroy all active weapons.
|
||||
space_exit(); // Clean up the universe!!!
|
||||
pilots_free(); // Free the pilots, they where locked up D:
|
||||
gui_free(); // Free up the gui.
|
||||
fleet_free();
|
||||
ships_free();
|
||||
outfit_free();
|
||||
spfx_free(); // Remove the special effects.
|
||||
factions_free();
|
||||
commodity_free();
|
||||
space_exit(); // Cleans up the universe itself.
|
||||
|
||||
// Unload data.
|
||||
unload_all();
|
||||
|
||||
// Cleanup opengl fonts.
|
||||
gl_freeFont(NULL);
|
||||
gl_freeFont(&gl_smallFont);
|
||||
|
||||
@ -208,6 +204,27 @@ int main(int argc, char** argv) {
|
||||
exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
void load_all(void) {
|
||||
// Ordering of these is very important as they are interdependent.
|
||||
commodity_load();
|
||||
factions_load();
|
||||
spfx_load();
|
||||
outfit_load();
|
||||
ships_load();
|
||||
fleet_load();
|
||||
space_load();
|
||||
}
|
||||
|
||||
void unload_all(void) {
|
||||
// Data unloading - order should not matter, but inverse load_all is good.
|
||||
fleet_free();
|
||||
ships_free();
|
||||
outfit_free();
|
||||
spfx_free(); // Remove the special effects.
|
||||
factions_free();
|
||||
commodity_free();
|
||||
}
|
||||
|
||||
// Slip main loop from main() for secondary loop hack in toolkit.c.
|
||||
void main_loop(void) {
|
||||
sound_update(); // Do sound stuff.
|
||||
|
@ -138,11 +138,15 @@ void player_destroyed(void);
|
||||
|
||||
// Prompt player name.
|
||||
void player_new(void) {
|
||||
int i;
|
||||
// Let's not seg fault due to a lack of environment.
|
||||
player_setFlag(PLAYER_DESTROYED);
|
||||
vectnull(&player_cam);
|
||||
gl_bindCamera(&player_cam);
|
||||
|
||||
for(i = 0; i < msg_max; i++)
|
||||
memset(msg_stack[i].str, '\0', MSG_SIZE_MAX);
|
||||
|
||||
// Cleanup player stuff if we'll be re-creating.
|
||||
player_cleanup();
|
||||
|
||||
@ -318,11 +322,12 @@ void player_message(const char* fmt, ...) {
|
||||
if(fmt == NULL) return; // Message not valid.
|
||||
|
||||
// Copy old messages back.
|
||||
for(i = 1; i < msg_max; i++)
|
||||
for(i = 1; i < msg_max; i++) {
|
||||
if(msg_stack[msg_max-i-1].str[0] != '\0') {
|
||||
strcpy(msg_stack[msg_max-i].str, msg_stack[msg_max-i-1].str);
|
||||
msg_stack[msg_max-i].t = msg_stack[msg_max-i-1].t;
|
||||
}
|
||||
}
|
||||
// Add the new one.
|
||||
va_start(ap, fmt);
|
||||
vsprintf(msg_stack[0].str, fmt, ap);
|
||||
|
@ -739,6 +739,12 @@ void space_exit(void) {
|
||||
free(systems_stack[i].planets);
|
||||
}
|
||||
free(systems_stack);
|
||||
systems_stack = NULL;
|
||||
systems_nstack = 0;
|
||||
|
||||
if(stars) free(stars);
|
||||
|
||||
stars = NULL;
|
||||
nstars = 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user