- replaced MIN/MAX in common code.

This commit is contained in:
Christoph Oelckers 2021-10-30 10:46:17 +02:00
commit eb69bbcae0
63 changed files with 200 additions and 236 deletions

View file

@ -579,7 +579,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
// Make sure one source is capable of stereo output with the rest doing
// mono, without running out of voices
attribs.Push(ALC_MONO_SOURCES);
attribs.Push(std::max<ALCint>(snd_channels, 2) - 1);
attribs.Push(max<ALCint>(snd_channels, 2) - 1);
attribs.Push(ALC_STEREO_SOURCES);
attribs.Push(1);
if(ALC.SOFT_HRTF)
@ -681,7 +681,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
// At least Apple's OpenAL implementation returns zeroes,
// although it can generate reasonable number of sources.
const int numChannels = std::max<int>(snd_channels, 2);
const int numChannels = max<int>(snd_channels, 2);
int numSources = numMono + numStereo;
if (0 == numSources)
@ -689,7 +689,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
numSources = numChannels;
}
Sources.Resize(std::min<int>(numChannels, numSources));
Sources.Resize(min<int>(numChannels, numSources));
for(unsigned i = 0;i < Sources.Size();i++)
{
alGenSources(1, &Sources[i]);
@ -1346,7 +1346,7 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
float gain = GetRolloff(rolloff, dist * distscale);
// Don't let the ref distance go to 0, or else distance attenuation is
// lost with the inverse distance model.
alSourcef(source, AL_REFERENCE_DISTANCE, std::max<float>(gain*dist, 0.0004f));
alSourcef(source, AL_REFERENCE_DISTANCE, max<float>(gain*dist, 0.0004f));
alSourcef(source, AL_MAX_DISTANCE, std::numeric_limits<float>::max());
alSourcef(source, AL_ROLLOFF_FACTOR, 1.f);
}
@ -1466,9 +1466,9 @@ void OpenALSoundRenderer::ChannelPitch(FISoundChannel *chan, float pitch)
ALuint source = GET_PTRID(chan->SysChannel);
if (WasInWater && !(chan->ChanFlags & CHANF_UI))
alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f)*PITCH_MULT);
alSourcef(source, AL_PITCH, max(pitch, 0.0001f)*PITCH_MULT);
else
alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f));
alSourcef(source, AL_PITCH, max(pitch, 0.0001f));
}
void OpenALSoundRenderer::StopChannel(FISoundChannel *chan)
@ -1622,7 +1622,7 @@ void OpenALSoundRenderer::UpdateSoundParams3D(SoundListener *listener, FISoundCh
{
float dist = sqrtf(dist_sqr);
float gain = GetRolloff(&chan->Rolloff, dist * chan->DistanceScale);
alSourcef(source, AL_REFERENCE_DISTANCE, std::max<float>(gain*dist, 0.0004f));
alSourcef(source, AL_REFERENCE_DISTANCE, max<float>(gain*dist, 0.0004f));
}
alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);

View file

@ -407,7 +407,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source,
sfx = &S_sfx[sound_id];
// Scale volume according to SNDINFO data.
volume = std::min(volume * sfx->Volume, 1.f);
volume = min(volume * sfx->Volume, 1.f);
if (volume <= 0)
return NULL;
@ -847,7 +847,7 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_
CalcPosVel(chan, &chanorigin, NULL);
// scale the limit distance with the attenuation. An attenuation of 0 means the limit distance is infinite and all sounds within the level are inside the limit.
float attn = std::min(chan->DistanceScale, attenuation);
float attn = min(chan->DistanceScale, attenuation);
if (attn <= 0 || (chanorigin - pos).LengthSquared() <= limit_range / attn)
{
count++;
@ -1074,8 +1074,8 @@ void SoundEngine::ChangeSoundPitch(int sourcetype, const void *source, int chann
void SoundEngine::SetPitch(FSoundChan *chan, float pitch)
{
assert(chan != nullptr);
GSnd->ChannelPitch(chan, std::max(0.0001f, pitch));
chan->Pitch = std::max(1, int(float(DEFAULT_PITCH) * pitch));
GSnd->ChannelPitch(chan, max(0.0001f, pitch));
chan->Pitch = max(1, int(float(DEFAULT_PITCH) * pitch));
}
//==========================================================================