From 4f9eda189a20cca26135a13a353c360adfc1e0ae Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 15 Dec 2019 19:00:41 +0100 Subject: [PATCH] - a few sounds play, but it's still very buggy. --- source/common/gamecontrol.cpp | 1 + source/common/sound/s_sound.cpp | 2 +- source/duke3d/src/sounds.cpp | 12 +++++++++--- wadsrc/static/demolition/dsempty.lmp | Bin 0 -> 12 bytes 4 files changed, 11 insertions(+), 4 deletions(-) create mode 100644 wadsrc/static/demolition/dsempty.lmp diff --git a/source/common/gamecontrol.cpp b/source/common/gamecontrol.cpp index 653b07f25..fabfc7e81 100644 --- a/source/common/gamecontrol.cpp +++ b/source/common/gamecontrol.cpp @@ -473,6 +473,7 @@ int RunGame() GStrings.LoadStrings(); V_InitFonts(); C_CON_SetAliases(); + sfx_empty = fileSystem.FindFile("demolition/dsempty.lmp"); // this must be done outside the sound code because it's initialized late. Mus_Init(); InitStatistics(); M_Init(); diff --git a/source/common/sound/s_sound.cpp b/source/common/sound/s_sound.cpp index bab2bb214..35cd5af72 100644 --- a/source/common/sound/s_sound.cpp +++ b/source/common/sound/s_sound.cpp @@ -804,7 +804,7 @@ void SoundEngine::LoadSound3D(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer) { snd = GSnd->LoadSoundBuffered(pBuffer, true); } - else + else if (sfx->lumpnum >= 0) { auto sfxdata = ReadSound(sfx->lumpnum); int size = sfxdata.Size(); diff --git a/source/duke3d/src/sounds.cpp b/source/duke3d/src/sounds.cpp index 7e64c8f45..97db6de22 100644 --- a/source/duke3d/src/sounds.cpp +++ b/source/duke3d/src/sounds.cpp @@ -101,7 +101,7 @@ void cacheAllSounds(void) static inline int S_GetPitch(int num) { - auto const* snd = (sound_t*)soundEngine->GetUserData(num); + auto const* snd = (sound_t*)soundEngine->GetUserData(num+1); int const range = abs(snd->pitchEnd - snd->pitchStart); return (range == 0) ? snd->pitchStart : min(snd->pitchStart, snd->pitchEnd) + rand() % range; @@ -154,6 +154,7 @@ int S_DefineSound(unsigned index, const char *filename, int minpitch, int maxpit sndinf->volAdjust = clamp(distance, INT16_MIN, INT16_MAX); sfx->Volume = volume; sfx->NearLimit = 4; + sfx->bTentative = false; return 0; } @@ -227,8 +228,12 @@ boost: // Now calculate the virtual position in sound system coordinates. FVector3 sndvec = { float(pos->x - cam->x), (pos->z - cam->z) / 16.f, float(pos->y - cam->y) }; // distance vector. Note that the z-coordinate has different precision. FVector3 campos = { float(pos->x), (cam->z) / 16.f, float(cam->y) }; // camera position - sndvec *= float(sndist) / orgsndist; // adjust by what was calculated above; - *sndPos = campos + sndvec; // final sound pos - still in Build fixed point coordinates. + if (orgsndist > 0) + { + sndvec *= float(sndist) / orgsndist; // adjust by what was calculated above; + *sndPos = campos + sndvec; // final sound pos - still in Build fixed point coordinates. + } + else *sndPos = campos; *sndPos *= (1.f / 16); sndPos->Z = -sndPos->Z; // The sound engine works with Doom's coordinate system so do the necessary conversions } @@ -368,6 +373,7 @@ void S_Update(void) } listener.ListenerObject = ud.camerasprite == -1 ? nullptr : &sprite[ud.camerasprite]; soundEngine->SetListener(listener); + soundEngine->UpdateSounds((int)totalclock); } diff --git a/wadsrc/static/demolition/dsempty.lmp b/wadsrc/static/demolition/dsempty.lmp new file mode 100644 index 0000000000000000000000000000000000000000..cb6f1d2fce47a2fa04b442fe289b50d7e3ffbb40 GIT binary patch literal 12 RcmZQ(5Y%R2U|?tf0ssen0z?1+ literal 0 HcmV?d00001