1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-15 11:03:00 +01:00

Fixed sound_remove, renamed variables, removed compiler warnings

This commit is contained in:
zsilencer
2014-08-24 01:56:54 -06:00
parent 11063c9623
commit 04e5a028d9
3 changed files with 20 additions and 18 deletions

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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);