Merge pull request #1618 from zsilencer/bugfixes

Bugfixes
This commit is contained in:
Ted John 2015-07-14 23:51:14 +01:00
commit b96e48ce62
11 changed files with 44 additions and 29 deletions

View File

@ -39,6 +39,7 @@ rct_ride_music_params gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC];
rct_ride_music_params *gRideMusicParamsListEnd;
void *gCrowdSoundChannel = 0;
void *gTitleMusicChannel = 0;
bool gGameSoundsOff = false;
void audio_init(int i)
{
@ -1423,7 +1424,7 @@ int get_dsound_devices()
int sound_play_panned(int sound_id, int ebx, sint16 x, sint16 y, sint16 z)
{
int result = 0;
if (RCT2_GLOBAL(0x009AF59D, uint8) & 1) {
if (gConfigSound.sound) {
RCT2_GLOBAL(0x00F438AD, uint8) = 0;
int volume = 0;
if (ebx == 0x8001) {
@ -1557,7 +1558,7 @@ void start_title_music()
break;
}
if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) && RCT2_GLOBAL(0x009AF59D, uint8) & 1
if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)) && gConfigSound.sound
&& RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO) {
if (!RCT2_GLOBAL(0x009AF600, uint8)) {
#ifdef USE_MIXER
@ -1809,13 +1810,11 @@ void audio_close()
/* rct2: 0x006BAB8A */
void toggle_all_sounds(){
// When all sound code is reversed replace with gConfigSound.sound
RCT2_GLOBAL(0x009AF59D, uint8) ^= 1;
if (RCT2_GLOBAL(0x009AF59D, uint8) == 0) {
gConfigSound.sound = !gConfigSound.sound;
if (!gConfigSound.sound) {
stop_title_music();
pause_sounds();
}
else{
} else {
unpause_sounds();
}
}
@ -1826,15 +1825,11 @@ void toggle_all_sounds(){
*/
void pause_sounds()
{
// When all sound code is reversed replace with gConfigSound.sound
RCT2_GLOBAL(0x009AF59C, uint8) = 1;
if (RCT2_GLOBAL(0x009AF59C, uint8) == 1) {
stop_other_sounds();
stop_vehicle_sounds();
stop_ride_music();
stop_crowd_sound();
}
gConfigSound.sound = 0;
gGameSoundsOff = 1;
stop_other_sounds();
stop_vehicle_sounds();
stop_ride_music();
stop_crowd_sound();
}
/**
@ -1843,9 +1838,7 @@ void pause_sounds()
*/
void unpause_sounds()
{
// When all sound code is reversed replace with gConfigSound.sound
RCT2_GLOBAL(0x009AF59C, uint8) = 0;
gConfigSound.sound = 1;
gGameSoundsOff = 0;
}
/**

View File

@ -156,6 +156,7 @@ extern rct_ride_music_params gRideMusicParamsList[AUDIO_MAX_RIDE_MUSIC];
extern rct_ride_music_params *gRideMusicParamsListEnd;
extern void *gCrowdSoundChannel;
extern void *gTitleMusicChannel;
extern bool gGameSoundsOff;
void audio_timefunc(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2, int channel);
int CALLBACK audio_timer_callback(UINT uTimerID, UINT uMsg, DWORD_PTR dwUser, DWORD_PTR dw1, DWORD_PTR dw2);

View File

@ -568,7 +568,7 @@ void SDLCALL Mixer::Callback(void* arg, uint8* stream, int length)
void Mixer::MixChannel(Channel& channel, uint8* data, int length)
{
if (channel.source && channel.source->Length() > 0 && !channel.done) {
if (channel.source && channel.source->Length() > 0 && !channel.done && gConfigSound.sound) {
AudioFormat streamformat = channel.source->Format();
int loaded = 0;
SDL_AudioCVT cvt;

View File

@ -202,6 +202,7 @@ config_property_definition _soundDefinitions[] = {
{ offsetof(sound_configuration, ride_music), "ride_music", CONFIG_VALUE_TYPE_BOOLEAN, true, NULL },
{ offsetof(sound_configuration, master_volume), "master_volume", CONFIG_VALUE_TYPE_UINT8, 100, NULL },
{ offsetof(sound_configuration, music_volume), "music_volume", CONFIG_VALUE_TYPE_UINT8, 100, NULL },
{ offsetof(sound_configuration, device), "audio_device", CONFIG_VALUE_TYPE_STRING, { .value_string = NULL }, NULL },
};
config_property_definition _cheatDefinitions[] = {

View File

@ -175,6 +175,7 @@ typedef struct {
uint8 ride_music;
uint8 master_volume;
uint8 music_volume;
utf8string device;
} sound_configuration;
typedef struct {

View File

@ -191,13 +191,23 @@ bool openrct2_initialise()
addhook(0x006E7499, (int)gfx_redraw_screen_rect, 0, (int[]){ EAX, EBX, EDX, EBP, END }, 0); // remove when 0x6E7FF3 is decompiled
addhook(0x006B752C, (int)ride_crash, 0, (int[]){ EDX, EBX, END }, 0); // remove when all callers are decompiled
addhook(0x0069A42F, (int)peep_window_state_update, 0, (int[]){ ESI, END }, 0); // remove when all callers are decompiled
addhook(0x006BB76E, (int)sound_play_panned, 0, (int[]){EAX, EBX, ECX, EDX, EBP, END}, EAX); // remove when all callers are decompiled
if (!rct2_init())
return false;
openrct2_copy_original_user_files_over();
Mixer_Init(NULL);
char* devicename = gConfigSound.device;
if (strlen(devicename) == 0) {
devicename = NULL;
}
Mixer_Init(devicename);
for (int i = 0; i < gAudioDeviceCount; i++) {
if (strcmp(gAudioDevices[i].name, gConfigSound.device) == 0) {
RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) = i;
}
}
return true;
}

View File

@ -25,6 +25,7 @@
#include "../localisation/localisation.h"
#include "../management/finance.h"
#include "../management/news_item.h"
#include "../config.h"
#include "../openrct2.h"
#include "../ride/ride.h"
#include "../scenario.h"
@ -4494,10 +4495,10 @@ void peep_update_crowd_noise()
if (!(RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0)))
return;
if (RCT2_GLOBAL(0x009AF59C, uint8) != 0)
if (gGameSoundsOff)
return;
if (!(RCT2_GLOBAL(0x009AF59D, uint8) & (1 << 0)))
if (!gConfigSound.sound)
return;
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)

View File

@ -3143,7 +3143,7 @@ void ride_set_map_tooltip(rct_map_element *mapElement)
*/
int ride_music_params_update(sint16 x, sint16 y, sint16 z, uint8 rideIndex, uint16 sampleRate, uint32 position, uint8 *tuneId)
{
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !RCT2_GLOBAL(0x009AF59C, uint8) && RCT2_GLOBAL(0x00F438A4, rct_viewport*) != (rct_viewport*)-1) {
if(!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_SCENARIO_EDITOR) && !gGameSoundsOff && RCT2_GLOBAL(0x00F438A4, rct_viewport*) != (rct_viewport*)-1) {
RCT2_GLOBAL(0x009AF47C, uint16) = sampleRate;
sint16 v11;
sint16 v12;
@ -3373,7 +3373,7 @@ void ride_music_update_final()
int ebx;
if (!(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 2)) {
if ((RCT2_GLOBAL(0x009AF284, uint32) & (1 << 0))) {
if (!RCT2_GLOBAL(0x009AF59C, uint8) && RCT2_GLOBAL(0x009AF59D, uint8) & 1 && RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) && !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 1)) {
if (!gGameSoundsOff && gConfigSound.sound && RCT2_GLOBAL(RCT2_ADDRESS_CONFIG_MUSIC, uint8) && !(RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & 1)) {
// set to stop music if volume <= 1 ?
while (1) {
int v8 = 0;

View File

@ -21,6 +21,7 @@
#include "../addresses.h"
#include "../audio/audio.h"
#include "../audio/mixer.h"
#include "../config.h"
#include "../interface/viewport.h"
#include "../world/sprite.h"
#include "ride.h"
@ -166,7 +167,7 @@ int sub_6BC2F3(rct_vehicle* vehicle)
*/
void vehicle_sounds_update()
{
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1 && !RCT2_GLOBAL(0x009AF59C, uint8) && RCT2_GLOBAL(0x009AF59D, uint8) & 1) {
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) != -1 && !gGameSoundsOff && gConfigSound.sound) {
RCT2_GLOBAL(0x00F438A4, rct_viewport*) = (rct_viewport*)-1;
rct_viewport* viewport = (rct_viewport*)-1;
rct_window* window = RCT2_GLOBAL(RCT2_ADDRESS_NEW_WINDOW_PTR, rct_window*);

View File

@ -961,10 +961,16 @@ static void window_options_dropdown(rct_window *w, int widgetIndex, int dropdown
#ifdef USE_MIXER
if (dropdownIndex == 0) {
Mixer_Init(NULL);
gConfigSound.device = NULL;
}
else {
Mixer_Init(gAudioDevices[dropdownIndex].name);
char* devicename = gAudioDevices[dropdownIndex].name;
Mixer_Init(devicename);
SafeFree(gConfigSound.device);
gConfigSound.device = malloc(strlen(devicename) + 1);
strcpy(gConfigSound.device, devicename);
}
config_save_default();
#endif
}
/*#ifdef _MSC_VER

View File

@ -21,6 +21,7 @@
#include "../addresses.h"
#include "../audio/audio.h"
#include "../audio/mixer.h"
#include "../config.h"
#include "../drawing/drawing.h"
#include "../localisation/date.h"
#include "../scenario.h"
@ -242,9 +243,9 @@ void climate_update_sound()
{
if (RCT2_GLOBAL(RCT2_ADDRESS_CURRENT_SOUND_DEVICE, uint32) == 0xFFFFFFFF)
return;
if (RCT2_GLOBAL(0x009AF59C, uint8) != 0)
if (gGameSoundsOff)
return;
if (!(RCT2_GLOBAL(0x009AF59D, uint8) & 1))
if (!gConfigSound.sound)
return;
if (RCT2_GLOBAL(RCT2_ADDRESS_SCREEN_FLAGS, uint8) & SCREEN_FLAGS_TITLE_DEMO)
return;