diff options
| author | jussi | 2023-04-25 18:19:14 +0300 |
|---|---|---|
| committer | jussi | 2023-04-25 18:19:14 +0300 |
| commit | a9ce78128d919e9798d7d2ec043879a4c685a9d1 (patch) | |
| tree | 478e2e5f0536d4db3c5b13b4d8fd5c45b4bae19c /src/state.c | |
| parent | 8182c486e64f21c6f95b9108b0e506e603c2a65c (diff) | |
| download | reilua-enhanced-a9ce78128d919e9798d7d2ec043879a4c685a9d1.tar.gz reilua-enhanced-a9ce78128d919e9798d7d2ec043879a4c685a9d1.tar.bz2 reilua-enhanced-a9ce78128d919e9798d7d2ec043879a4c685a9d1.zip | |
Can now have multiple Music objects like other Raylib objects instead of just one.
Diffstat (limited to 'src/state.c')
| -rw-r--r-- | src/state.c | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/state.c b/src/state.c index 877464e..ed96115 100644 --- a/src/state.c +++ b/src/state.c @@ -42,6 +42,10 @@ bool stateInit( const char *exePath ) { state->soundAlloc = ALLOC_PAGE_SIZE; state->soundCount = 0; state->sounds = malloc( state->soundAlloc * sizeof( Sound* ) ); + /* Musics. */ + state->musicAlloc = ALLOC_PAGE_SIZE; + state->musicCount = 0; + state->musics = malloc( state->musicAlloc * sizeof( Music* ) ); /* Camera2D's. */ state->camera2DAlloc = ALLOC_PAGE_SIZE; state->camera2DCount = 0; @@ -157,6 +161,12 @@ void stateFree() { free( state->sounds[i] ); } } + for ( int i = 0; i < state->musicCount; ++i ) { + if ( state->musics[i] != NULL ) { + UnloadMusicStream( *state->musics[i] ); + free( state->musics[i] ); + } + } for ( int i = 0; i < state->camera2DCount; ++i ) { if ( state->camera2Ds[i] != NULL ) { free( state->camera2Ds[i] ); @@ -213,7 +223,6 @@ void stateFree() { if ( IsAudioDeviceReady() ) { CloseAudioDevice(); - UnloadMusicStream( state->music ); } if ( state->hasWindow ) { CloseWindow(); @@ -227,6 +236,7 @@ void stateFree() { free( state->fonts ); free( state->waves ); free( state->sounds ); + free( state->musics ); free( state->camera2Ds ); free( state->camera3Ds ); free( state->meshes ); |
