Memory leak fixes.
This commit is contained in:
parent
b72810310c
commit
dd88df4bc7
|
@ -647,8 +647,11 @@ static void setRandomShieldHue(Effect *e)
|
|||
}
|
||||
|
||||
void destroyEffects(void)
|
||||
{
|
||||
if (effectsToDraw)
|
||||
{
|
||||
free(effectsToDraw);
|
||||
}
|
||||
|
||||
effectsToDraw = NULL;
|
||||
}
|
||||
|
|
|
@ -22,18 +22,20 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
|
||||
static void executeNextLine(ScriptRunner *runner);
|
||||
|
||||
static cJSON *scriptJSON;
|
||||
static cJSON *scriptJSON, *rootJSON;
|
||||
static ScriptRunner head;
|
||||
static ScriptRunner *tail;
|
||||
|
||||
void initScript(cJSON *scriptNode)
|
||||
void initScript(cJSON *root)
|
||||
{
|
||||
cJSON *function;
|
||||
|
||||
memset(&head, 0, sizeof(ScriptRunner));
|
||||
tail = &head;
|
||||
|
||||
scriptJSON = scriptNode;
|
||||
rootJSON = root;
|
||||
|
||||
scriptJSON = cJSON_GetObjectItem(root, "script");
|
||||
|
||||
if (scriptJSON)
|
||||
{
|
||||
|
@ -281,11 +283,11 @@ void destroyScript(void)
|
|||
{
|
||||
ScriptRunner *scriptRunner;
|
||||
|
||||
if (scriptJSON)
|
||||
if (rootJSON)
|
||||
{
|
||||
cJSON_Delete(scriptJSON);
|
||||
cJSON_Delete(rootJSON);
|
||||
|
||||
scriptJSON = NULL;
|
||||
rootJSON = NULL;
|
||||
}
|
||||
|
||||
while (head.next)
|
||||
|
|
|
@ -126,7 +126,7 @@ void loadMission(char *filename)
|
|||
battle.unwinnable = getJSONValue(root, "unwinnable", 0);
|
||||
battle.waypointAutoAdvance = getJSONValue(root, "waypointAutoAdvance", 0);
|
||||
|
||||
initScript(cJSON_GetObjectItem(root, "script"));
|
||||
initScript(root);
|
||||
|
||||
/* music, planet, and background loading must come last, so AUTO works properly */
|
||||
|
||||
|
|
|
@ -225,11 +225,15 @@ static void handleKeyboard(void)
|
|||
|
||||
static void campaign(void)
|
||||
{
|
||||
destroyBattle();
|
||||
|
||||
initGalacticMap();
|
||||
}
|
||||
|
||||
static void challenges(void)
|
||||
{
|
||||
destroyBattle();
|
||||
|
||||
game.currentMission = NULL;
|
||||
|
||||
initChallengeHome();
|
||||
|
|
|
@ -60,6 +60,7 @@ extern void clearInput(void);
|
|||
extern void initTrophiesDisplay(void);
|
||||
extern void drawTrophies(void);
|
||||
extern void doTrophies(void);
|
||||
extern void destroyBattle(void);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
Loading…
Reference in New Issue