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