1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2025-12-21 23:03:04 +01:00

Fix intro crash. Caused by incorrect pointer address. Fixed crash on freeing unallocated memory. Fixed audio issue when channels set to zero.

This commit is contained in:
Duncan Frost
2015-01-18 19:13:21 +00:00
parent 1ece6e4a70
commit e6f966f395
3 changed files with 25 additions and 25 deletions

View File

@@ -693,9 +693,10 @@ int sound_prepare(int sound_id, rct_sound *sound, int channels, int software)
rct_sound_effect* sound_effect = sound_get_effect(sound_id); rct_sound_effect* sound_effect = sound_get_effect(sound_id);
if (sound_effect) { if (sound_effect) {
if (sound_effect_loadvars(sound_effect, &bufferdesc.lpwfxFormat, &buffer, &bufferdesc.dwBufferBytes)) { if (sound_effect_loadvars(sound_effect, &bufferdesc.lpwfxFormat, &buffer, &bufferdesc.dwBufferBytes)) {
if (channels == 0){
bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STATIC; bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_STATIC;
if (channels) { }
if (channels == 2) { else if (channels == 2) {
bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D | DSBCAPS_STATIC; bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRL3D | DSBCAPS_STATIC;
} else { } else {
bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY | DSBCAPS_STATIC; bufferdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_CTRLVOLUME | DSBCAPS_CTRLPAN | DSBCAPS_CTRLFREQUENCY | DSBCAPS_STATIC;
@@ -719,7 +720,6 @@ int sound_prepare(int sound_id, rct_sound *sound, int channels, int software)
sound->dsbuffer->lpVtbl->Release(sound->dsbuffer); sound->dsbuffer->lpVtbl->Release(sound->dsbuffer);
sound->dsbuffer = 0; sound->dsbuffer = 0;
} }
}
sound->dsbuffer = 0; sound->dsbuffer = 0;
} }
} }

View File

@@ -136,7 +136,7 @@ void gfx_transpose_palette(int pal, unsigned char product)
rct_g1_element g1 = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[pal]; rct_g1_element g1 = RCT2_ADDRESS(RCT2_ADDRESS_G1_ELEMENTS, rct_g1_element)[pal];
int width = g1.width; int width = g1.width;
int x = g1.x_offset; int x = g1.x_offset;
uint8* dest_pointer = (uint8*)&(RCT2_ADDRESS(0x014124680,uint8)[x]); uint8* dest_pointer = (uint8*)&(RCT2_ADDRESS(0x01424680, uint8)[x * 4]);
uint8* source_pointer = g1.offset; uint8* source_pointer = g1.offset;
for (; width > 0; width--) { for (; width > 0; width--) {

View File

@@ -70,7 +70,7 @@ __declspec(dllexport) int StartOpenRCT(HINSTANCE hInstance, HINSTANCE hPrevInsta
// Get command line arguments in standard form // Get command line arguments in standard form
argv = CommandLineToArgvA(lpCmdLine, &argc); argv = CommandLineToArgvA(lpCmdLine, &argc);
runGame = cmdline_run(argv, argc); runGame = cmdline_run(argv, argc);
LocalFree(argv); //LocalFree(argv);
if (runGame) if (runGame)
openrct2_launch(); openrct2_launch();