- fixed VOC loader. Its 16 bit code did not work because it set the variable to -16 instead of 16.

- removed a few MAX calls with std::max.
This commit is contained in:
Christoph Oelckers 2019-12-17 00:05:35 +01:00
parent e82565373f
commit 639e9d3cd4
4 changed files with 11 additions and 9 deletions

View file

@ -409,7 +409,7 @@ std::pair<SoundHandle,bool> SoundRenderer::LoadSoundVoc(uint8_t *sfxdata, int le
if (codec == 0)
bits = 8;
else if (codec == 4)
bits = -16;
bits = 16;
else okay = false;
len += blocksize - 2;
}
@ -460,7 +460,7 @@ std::pair<SoundHandle,bool> SoundRenderer::LoadSoundVoc(uint8_t *sfxdata, int le
if (codec == 0)
bits = 8;
else if (codec == 4)
bits = -16;
bits = 16;
else okay = false;
len += blocksize - 12;
} else okay = false;

View file

@ -2,6 +2,7 @@
#define __SNDINT_H
#include <stdio.h>
#include <stdint.h>
#include "vectors.h"
#include "tarray.h"

View file

@ -576,7 +576,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(MAX<ALCint>(*snd_channels, 2) - 1);
attribs.Push(std::max<ALCint>(snd_channels, 2) - 1);
attribs.Push(ALC_STEREO_SOURCES);
attribs.Push(1);
if(ALC.SOFT_HRTF)
@ -686,7 +686,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
// At least Apple's OpenAL implementation returns zeroes,
// although it can generate reasonable number of sources.
const int numChannels = MAX<int>(*snd_channels, 2);
const int numChannels = std::max<int>(snd_channels, 2);
int numSources = numMono + numStereo;
if (0 == numSources)
@ -694,7 +694,7 @@ OpenALSoundRenderer::OpenALSoundRenderer()
numSources = numChannels;
}
Sources.Resize(MIN<int>(numChannels, numSources));
Sources.Resize(std::min<int>(numChannels, numSources));
for(unsigned i = 0;i < Sources.Size();i++)
{
alGenSources(1, &Sources[i]);
@ -917,6 +917,7 @@ void OpenALSoundRenderer::SetSfxVolume(float volume)
{
SfxVolume = volume;
if (!soundEngine) return;
FSoundChan *schan = soundEngine->GetChannels();
while(schan)
{
@ -1523,7 +1524,7 @@ FISoundChannel *OpenALSoundRenderer::StartSound3D(SoundHandle sfx, SoundListener
* distance that corresponds to the area radius. */
alSourcef(source, AL_SOURCE_RADIUS, (chanflags&SNDF_AREA) ?
// Clamp in case the max distance is <= the area radius
1.f/MAX<float>(GetRolloff(rolloff, AREA_SOUND_RADIUS), 0.00001f) : 0.f
1.f/std::max<float>(GetRolloff(rolloff, AREA_SOUND_RADIUS), 0.00001f) : 0.f
);
}
else if((chanflags&SNDF_AREA) && dist_sqr < AREA_SOUND_RADIUS*AREA_SOUND_RADIUS)
@ -1670,9 +1671,9 @@ void OpenALSoundRenderer::ChannelPitch(FISoundChannel *chan, float pitch)
ALuint source = GET_PTRID(chan->SysChannel);
if (WasInWater && !(chan->ChanFlags & CHANF_UI))
alSourcef(source, AL_PITCH, MAX(pitch, 0.0001f)*PITCH_MULT);
alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f)*PITCH_MULT);
else
alSourcef(source, AL_PITCH, MAX(pitch, 0.0001f));
alSourcef(source, AL_PITCH, std::max(pitch, 0.0001f));
}
void OpenALSoundRenderer::FreeSource(ALuint source)

View file

@ -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();