Rare Assert when clicking on a main hall option
Assert: "SCP_vector_inbounds(Sounds, idx)"
File: sound.cpp
Line: 1340
Attempt to get a sound that is not loaded, please report!
ntdll.dll! ZwWaitForSingleObject + 20 bytes
KERNELBASE.dll! WaitForSingleObjectEx + 142 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! SCP_DumpStack + 382 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! dump_stacktrace + 61 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! os::dialogs::AssertMessage + 637 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! snd_set_pos + 119 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! main_hall_mouse_grab_region + 562 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! main_hall_handle_mouse_location + 114 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! main_hall_do + 2719 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! game_do_state + 258 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! gameseq_process_events + 250 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! game_main + 724 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! SDL_main + 359 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! main_getcmdline + 245 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! invoke_main + 50 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! __scrt_common_main_seh + 302 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! __scrt_common_main + 14 bytes
fs2_open_23_3_0_x64_AVX2-DEBUG.exe! WinMainCRTStartup + 14 bytes
KERNEL32.DLL! BaseThreadInitThunk + 29 bytes
ntdll.dll! RtlUserThreadStart + 40 bytes
This occurs on these lines in snd_set_pos:
int idx = ds_get_sound_index(channel);
Assertion(SCP_vector_inbounds(Sounds, idx), "Attempt to get a sound that is not loaded, please report!");
This happens in JAD 2.22 when clicking on the Exit button. I haven't experienced it in other mods or on other buttons in this mod. When the Assert occurs, snd_handle is 1920, val is 0.0, as_pct is 1, channel is 1, idx is 303, and the size of Sounds is also 303.
The crash is pretty rare. It has happened a few times while testing, but I have not found a reliable way to reproduce it.
I hate our sound code, but I think I have tracked this down. Channel.sid is not the index into Sounds it is the index into sound_buffer
I cannot test right now to make sure that I have it right, but I'm pretty certain.
Oh very good 👍
Ok. Not sure how this code worked in the first placed. Using the id the code was using before should not work properly, but I tried replacing it and now there is no sound playing. I guess I didn't understand it after all.
EDIT: Nevermind, I think it was from some changes that I made trying to fix the problem based on the idea that it was pointer weirdness. The sounds are audible now.