fix segfault on resuming from letter screen

This commit is contained in:
Sebastian Krzyszkowiak 2012-12-10 13:09:33 +01:00
parent f17b7bf100
commit 4792af13ec

View file

@ -170,15 +170,15 @@ bool PassLevel(struct Game *game, struct TM_Action *action, enum TM_ActionState
bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState state) { bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState state) {
if (state == TM_ACTIONSTATE_INIT) { if (state == TM_ACTIONSTATE_INIT) {
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float))); float* f = (float*)malloc(sizeof(float));
float* f = (float*)action->arguments->value;
*f = 0; *f = 0;
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(ALLEGRO_AUDIO_STREAM*))); ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)malloc(sizeof(ALLEGRO_AUDIO_STREAM*));
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
*stream = al_load_audio_stream(GetDataFilePath(GetLevelFilename(game, "levels/?/letter.flac")), 4, 1024); *stream = al_load_audio_stream(GetDataFilePath(GetLevelFilename(game, "levels/?/letter.flac")), 4, 1024);
al_attach_audio_stream_to_mixer(*stream, game->audio.voice); al_attach_audio_stream_to_mixer(*stream, game->audio.voice);
al_set_audio_stream_playing(*stream, false); al_set_audio_stream_playing(*stream, false);
al_set_audio_stream_gain(*stream, 2.00); al_set_audio_stream_gain(*stream, 2.00);
action->arguments = TM_AddToArgs(action->arguments, (void*)f);
action->arguments = TM_AddToArgs(action->arguments, (void*)stream);
action->arguments->next->next = NULL; action->arguments->next->next = NULL;
} else if (state == TM_ACTIONSTATE_DESTROY) { } else if (state == TM_ACTIONSTATE_DESTROY) {
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value; ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
@ -197,7 +197,8 @@ bool Letter(struct Game *game, struct TM_Action *action, enum TM_ActionState sta
} else if ((state == TM_ACTIONSTATE_RESUME) || (state == TM_ACTIONSTATE_START)) { } else if ((state == TM_ACTIONSTATE_RESUME) || (state == TM_ACTIONSTATE_START)) {
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value; ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
al_set_audio_stream_playing(*stream, true); al_set_audio_stream_playing(*stream, true);
} else if (state != TM_ACTIONSTATE_RUNNING) return false; }
if (state != TM_ACTIONSTATE_RUNNING) return false;
float* f = (float*)action->arguments->value; float* f = (float*)action->arguments->value;
*f+=5; *f+=5;