mirror of
https://gitlab.com/dosowisko.net/libsuperderpy.git
synced 2024-12-12 20:18:00 +01:00
fix segfault on resuming from letter screen
This commit is contained in:
parent
f17b7bf100
commit
4792af13ec
1 changed files with 6 additions and 5 deletions
|
@ -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) {
|
||||
if (state == TM_ACTIONSTATE_INIT) {
|
||||
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(float)));
|
||||
float* f = (float*)action->arguments->value;
|
||||
float* f = (float*)malloc(sizeof(float));
|
||||
*f = 0;
|
||||
action->arguments = TM_AddToArgs(action->arguments, malloc(sizeof(ALLEGRO_AUDIO_STREAM*)));
|
||||
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
||||
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)malloc(sizeof(ALLEGRO_AUDIO_STREAM*));
|
||||
*stream = al_load_audio_stream(GetDataFilePath(GetLevelFilename(game, "levels/?/letter.flac")), 4, 1024);
|
||||
al_attach_audio_stream_to_mixer(*stream, game->audio.voice);
|
||||
al_set_audio_stream_playing(*stream, false);
|
||||
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;
|
||||
} else if (state == TM_ACTIONSTATE_DESTROY) {
|
||||
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)) {
|
||||
ALLEGRO_AUDIO_STREAM** stream = (ALLEGRO_AUDIO_STREAM**)action->arguments->next->value;
|
||||
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;
|
||||
*f+=5;
|
||||
|
|
Loading…
Reference in a new issue