timeline: add TM_CleanQueue and TM_CleanBackgroundQueue functions

This commit is contained in:
Sebastian Krzyszkowiak 2015-03-18 02:48:56 +01:00
parent 937981a1df
commit 25dcae6151
2 changed files with 17 additions and 3 deletions

View file

@ -290,8 +290,8 @@ void TM_AddDelay(struct Timeline* timeline, int delay) {
al_register_event_source(timeline->game->_priv.event_queue, al_get_timer_event_source(tmp->timer));
}
void TM_Destroy(struct Timeline* timeline) {
PrintConsole(timeline->game, "Timeline Manager[%s]: destroy", timeline->name);
void TM_CleanQueue(struct Timeline* timeline) {
PrintConsole(timeline->game, "Timeline Manager[%s]: cleaning queue", timeline->name);
struct TM_Action *tmp, *tmp2, *pom = timeline->queue;
tmp = NULL;
while (pom!=NULL) {
@ -316,6 +316,11 @@ void TM_Destroy(struct Timeline* timeline) {
tmp = tmp2;
}
}
}
void TM_CleanBackgroundQueue(struct Timeline* timeline) {
PrintConsole(timeline->game, "Timeline Manager[%s]: cleaning background queue", timeline->name);
struct TM_Action *tmp, *tmp2, *pom = timeline->queue;
tmp = NULL;
pom=timeline->background;
while (pom!=NULL) {
@ -340,7 +345,12 @@ void TM_Destroy(struct Timeline* timeline) {
tmp = tmp2;
}
}
}
void TM_Destroy(struct Timeline* timeline) {
TM_CleanQueue(timeline);
TM_CleanBackgroundQueue(timeline);
PrintConsole(timeline->game, "Timeline Manager[%s]: destroy", timeline->name);
free(timeline->name);
free(timeline);
}

View file

@ -84,6 +84,10 @@ struct TM_Action* TM_AddBackgroundAction(struct Timeline*, bool (*func)(struct G
struct TM_Action* TM_AddQueuedBackgroundAction(struct Timeline*, bool (*func)(struct Game*, struct TM_Action*, enum TM_ActionState), struct TM_Arguments* args, int delay, char* name);
/*! \brief Add delay to main queue. */
void TM_AddDelay(struct Timeline*, int delay);
/*! \brief Remove all actions from main queue. */
void TM_CleanQueue(struct Timeline*);
/*! \brief Remove all actions from background queue. */
void TM_CleanBackgroundQueue(struct Timeline*);
/*! \brief Destroy timeline. */
void TM_Destroy(struct Timeline*);
/*! \brief Add data to TM_Arguments queue. */