[Change] Load gfx_exterior for planets only on demand.

This commit is contained in:
Allanis 2013-07-23 12:49:50 +01:00
parent 11b31c9be7
commit 11e5607477
3 changed files with 11 additions and 4 deletions

View File

@ -60,6 +60,7 @@ static unsigned int land_visited = 0;
/* Land variables. */
int landed = 0;
Planet* land_planet = NULL;
static glTexture* gfx_exterior = NULL;
/* Mission computer stack. */
static Mission* mission_computer = NULL;
@ -1021,11 +1022,13 @@ void land(Planet* p) {
/* Change music. */
music_choose("land");
/* Load stuff. */
land_planet = p;
gfx_exterior = gl_newImage(p->gfx_exterior);
land_wid = window_create(p->name, -1, -1, LAND_WIDTH, LAND_HEIGHT);
/* Pretty display. */
window_addImage(land_wid, 20, -40, "imgPlanet", p->gfx_exterior, 1);
window_addImage(land_wid, 20, -40, "imgPlanet", gfx_exterior, 1);
window_addText(land_wid, 440, 80, LAND_WIDTH-460, 460, 0,
"txtPlanetDesc", &gl_smallFont, &cBlack, p->description);
/* Buttons. */
@ -1124,6 +1127,10 @@ void takeoff(void) {
save_all(); /* Must be before cleaning up planet. Duh! */
land_planet = NULL;
window_destroy(land_wid);
if(gfx_exterior != NULL) {
gl_freeTexture(gfx_exterior);
gfx_exterior = NULL;
}
landed = 0;
land_visited = 0;
hooks_run("takeoff");

View File

@ -489,9 +489,9 @@ static Planet* planet_pull(const char* name) {
}
else if(xml_isNode(cur, "exterior")) {
/* Load land gfx. */
snprintf(str, strlen(xml_get(cur))+sizeof(PLANET_GFX_EXTERIOR),
tmp->gfx_exterior = malloc(strlen(xml_get(cur))+sizeof(PLANET_GFX_EXTERIOR));
snprintf(tmp->gfx_exterior, strlen(xml_get(cur))+sizeof(PLANET_GFX_EXTERIOR),
PLANET_GFX_EXTERIOR"%s", xml_get(cur));
tmp->gfx_exterior = gl_newImage(str);
}
} while(xml_nextNode(cur));
}

View File

@ -67,7 +67,7 @@ typedef struct Planet_ {
int tech[PLANET_TECH_MAX];
glTexture* gfx_space; /* Graphics in space. */
glTexture* gfx_exterior; /* Graphics in the exterior. */
char* gfx_exterior; /* Don't actually load the texture. */
} Planet;
/* Star system flags. */