From 314429a2fef654412dd1622d81fec9b691945609 Mon Sep 17 00:00:00 2001 From: Sebastian Krzyszkowiak Date: Sat, 7 Apr 2012 18:41:39 +0200 Subject: [PATCH] moar destroyin! --- src/level.c | 4 ++++ src/timeline.c | 32 ++++++++++++-------------------- 2 files changed, 16 insertions(+), 20 deletions(-) diff --git a/src/level.c b/src/level.c index 0aeb900..5c80d25 100644 --- a/src/level.c +++ b/src/level.c @@ -74,6 +74,7 @@ bool FadeIn(struct Game *game, struct TM_Action *action, enum TM_ActionState sta al_destroy_bitmap(fade_bitmap); free(fadeloop); TM_DestroyArgs(action->arguments); + action->arguments = NULL; } return false; } @@ -106,6 +107,7 @@ bool FadeOut(struct Game *game, struct TM_Action *action, enum TM_ActionState st game->gamestate = GAMESTATE_LOADING; game->loadstate = GAMESTATE_MAP; TM_DestroyArgs(action->arguments); + action->arguments = NULL; } return false; } @@ -126,6 +128,7 @@ bool napis2(struct Game *game, struct TM_Action *action, enum TM_ActionState sta if (*tmp>=al_get_display_width(game->display)) { *tmp=0; return true; } } else { TM_DestroyArgs(action->arguments); + action->arguments = NULL; } return false; } @@ -147,6 +150,7 @@ bool napis(struct Game *game, struct TM_Action *action, enum TM_ActionState stat } else { TM_AddBackgroundAction(&napis2, NULL, 0); TM_DestroyArgs(action->arguments); + action->arguments = NULL; } return false; } diff --git a/src/timeline.c b/src/timeline.c index 5b77f14..d827b65 100644 --- a/src/timeline.c +++ b/src/timeline.c @@ -144,22 +144,17 @@ void TM_Pause(bool pause) { void TM_Destroy() { if (!game) return; - // TODO: delete everything from queues - // maybe delete all args too? struct TM_Action *tmp, *tmp2, *pom = queue; tmp = NULL; while (pom!=NULL) { if (pom->active) { - if (*pom->function) { - (*pom->function)(game, pom, TM_ACTIONSTATE_DESTROY); - if (tmp) { - tmp->next = pom->next; - } else { - background = pom->next; - } - } else { - // TODO: handle delay + if (*pom->function) (*pom->function)(game, pom, TM_ACTIONSTATE_DESTROY); + else { + // TODO: handle delay } + } else { + TM_DestroyArgs(pom->arguments); + pom->arguments = NULL; } if ((!tmp) || (tmp->next==pom)) { tmp = pom; @@ -176,16 +171,13 @@ void TM_Destroy() { pom=background; while (pom!=NULL) { if (pom->active) { - if (*pom->function) { - (*pom->function)(game, pom, TM_ACTIONSTATE_DESTROY); - if (tmp) { - tmp->next = pom->next; - } else { - background = pom->next; - } - } else { - // TODO: handle delay + if (*pom->function) (*pom->function)(game, pom, TM_ACTIONSTATE_DESTROY); + else { + // TODO: handle delay } + } else { + TM_DestroyArgs(pom->arguments); + pom->arguments = NULL; } if ((!tmp) || (tmp->next==pom)) { tmp = pom;