diff --git a/src/addresses.h b/src/addresses.h index 2d6dc983a5..efb780f9e5 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -157,8 +157,8 @@ #define RCT2_ADDRESS_DSOUND_BUFFERS 0x009E1AB0 #define RCT2_ADDRESS_NUM_DSOUND_DEVICES 0x009E2B88 #define RCT2_ADDRESS_DSOUND_DEVICES 0x009E2B8C -#define RCT2_ADDRESS_SOUNDLIST_END 0x009E2B98 -#define RCT2_ADDRESS_SOUNDLIST_BEGIN 0x009E2B9C +#define RCT2_ADDRESS_SOUNDLIST_BEGIN 0x009E2B98 +#define RCT2_ADDRESS_SOUNDLIST_END 0x009E2B9C #define RCT2_ADDRESS_CMDLINE 0x009E2D98 diff --git a/src/audio.c b/src/audio.c index 20cface0b3..79836d5531 100644 --- a/src/audio.c +++ b/src/audio.c @@ -220,7 +220,7 @@ int sound_set_volume(rct_sound* sound, int volume) void sound_stop(rct_sound* sound) { if(sound->dsbuffer){ - sound->dsbuffer->lpVtbl->Release(sound); + sound->dsbuffer->lpVtbl->Release(sound->dsbuffer); sound->dsbuffer = 0; sound_remove(sound); } @@ -232,28 +232,29 @@ void sound_stop(rct_sound* sound) */ rct_sound* sound_remove(rct_sound* sound) { - rct_sound* result = RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*); + printf("sound_remove called\n"); + rct_sound* result = RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*); if(sound == result){ - if(sound == RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*)){ - RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = 0; + if(sound == RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*)){ RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) = 0; + RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = 0; } - result = sound->prev; - RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) = result; + result = sound->next; + RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = result; } else{ - while(result->prev != sound){ - result = result->prev; + while(result->next != sound){ + result = result->next; } - if(sound == RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*)){ - RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_BEGIN, rct_sound*) = result; - result->prev = 0; + if(sound == RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*)){ + RCT2_GLOBAL(RCT2_ADDRESS_SOUNDLIST_END, rct_sound*) = result; + result->next = 0; } else{ - result->prev = sound->prev; + result->next = sound->next; } } - sound->prev = 0; + sound->next = 0; return result; } diff --git a/src/audio.h b/src/audio.h index cc91894958..1d1985832c 100644 --- a/src/audio.h +++ b/src/audio.h @@ -47,13 +47,14 @@ typedef struct { /** * Represents a prepared sound. */ -typedef struct { +typedef struct rct_sound rct_sound; +struct rct_sound { LPDIRECTSOUNDBUFFER dsbuffer; int id; int has_caps; int var_0C; - struct rct_sound* prev; -} rct_sound; + rct_sound* next; +}; void get_dsound_devices(); int sound_prepare(int sound_id, rct_sound *sound, int var_8, int var_c);