fixed the sound controller's sound selection.

In this case the game-side resource ID was silently cast to a sound ID but it needs explicit conversion.
This commit is contained in:
Christoph Oelckers 2022-11-26 09:08:58 +01:00
parent c60fea678d
commit 797c122363
3 changed files with 15 additions and 2 deletions

View file

@ -75,6 +75,18 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Raze, SetReverbDelay, FX_SetReverbDelay)
return 0;
}
int Raze_FindSoundByResID(int id)
{
return soundEngine->FindSoundByResID(id).index();
}
DEFINE_ACTION_FUNCTION_NATIVE(_Raze, FindSoundByResID, Raze_FindSoundByResID)
{
PARAM_PROLOGUE;
PARAM_INT(i);
ACTION_RETURN_INT(Raze_FindSoundByResID(i));
}
//=============================================================================
//
// internal sector struct - no longer identical with on-disk format

View file

@ -57,7 +57,7 @@ class DukeSoundController : DukeActor
if (distance < maxdist && self.temp_data[0] == 0)
{
// Start playing an ambience sound.
self.PlayActorSound(self.lotag, CHAN_AUTO, CHANF_LOOP);
self.PlayActorSound(Raze.FindSoundByResID(self.lotag), CHAN_AUTO, CHANF_LOOP);
self.temp_data[0] = 1; // AMBIENT_SFX_PLAYING
}
else if (distance >= maxdist && self.temp_data[0] == 1)
@ -72,7 +72,7 @@ class DukeSoundController : DukeActor
if (self.temp_data[4] > 0) self.temp_data[4]--;
else if (sec == p.actor.sector)
{
Duke.PlaySound(self.lotag + uint(Duke.global_random()) % uint(self.hitag + 1));
Duke.PlaySound(Raze.FindSoundByResID(self.lotag + uint(Duke.global_random()) % uint(self.hitag + 1)));
self.temp_data[4] = 26 * 40 + (Duke.global_random() % (26 * 40));
}
}

View file

@ -153,6 +153,7 @@ struct Raze
native static int SoundEnabled();
native static void SetReverb(int r);
native static void SetReverbDelay(int d);
native static Sound FindSoundByResID(int id);
native static sectortype updatesector(Vector2 pos, sectortype lastsect, double maxdist = 96);