From 11e5607477dede85f835faeb9d4a7d17c1aca3b3 Mon Sep 17 00:00:00 2001 From: Allanis Date: Tue, 23 Jul 2013 12:49:50 +0100 Subject: [PATCH] [Change] Load gfx_exterior for planets only on demand. --- src/land.c | 9 ++++++++- src/space.c | 4 ++-- src/space.h | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/land.c b/src/land.c index ed5d46b..cec0ee9 100644 --- a/src/land.c +++ b/src/land.c @@ -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"); diff --git a/src/space.c b/src/space.c index 96bbace..3ffdc70 100644 --- a/src/space.c +++ b/src/space.c @@ -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)); } diff --git a/src/space.h b/src/space.h index a9ae244..6a66499 100644 --- a/src/space.h +++ b/src/space.h @@ -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. */