- fixed warnings in common code.

This commit is contained in:
Christoph Oelckers 2021-10-08 19:07:56 +02:00
parent 29769dd673
commit 39319a9582
7 changed files with 20 additions and 18 deletions

View File

@ -532,7 +532,7 @@ public:
SmkPlayer* pId = (SmkPlayer*)userdata; SmkPlayer* pId = (SmkPlayer*)userdata;
memcpy(buff, &pId->adata.samples[pId->adata.nRead], len); memcpy(buff, &pId->adata.samples[pId->adata.nRead], len);
pId->adata.nRead += len / 2; pId->adata.nRead += len / 2;
if (pId->adata.nRead >= countof(pId->adata.samples)) pId->adata.nRead = 0; if (pId->adata.nRead >= (int)countof(pId->adata.samples)) pId->adata.nRead = 0;
return true; return true;
} }
@ -541,7 +541,7 @@ public:
for (unsigned i = 0; i < count; i++) for (unsigned i = 0; i < count; i++)
{ {
adata.samples[adata.nWrite] = (audioBuffer[i] - 128) << 8; adata.samples[adata.nWrite] = (audioBuffer[i] - 128) << 8;
if (++adata.nWrite >= countof(adata.samples)) adata.nWrite = 0; if (++adata.nWrite >= (int)countof(adata.samples)) adata.nWrite = 0;
} }
} }
@ -551,7 +551,7 @@ public:
for (unsigned i = 0; i < count/2; i++) for (unsigned i = 0; i < count/2; i++)
{ {
adata.samples[adata.nWrite] = *ptr++; adata.samples[adata.nWrite] = *ptr++;
if (++adata.nWrite >= countof(adata.samples)) adata.nWrite = 0; if (++adata.nWrite >= (int)countof(adata.samples)) adata.nWrite = 0;
} }
} }
@ -789,7 +789,7 @@ DEFINE_ACTION_FUNCTION(_MoviePlayer, Create)
auto movie = OpenMovie(filename, *sndinf, frametime == -1? nullptr : frametimes, flags, error); auto movie = OpenMovie(filename, *sndinf, frametime == -1? nullptr : frametimes, flags, error);
if (!movie) if (!movie)
{ {
Printf(TEXTCOLOR_YELLOW, "%s", error.GetChars()); Printf(TEXTCOLOR_YELLOW "%s", error.GetChars());
} }
ACTION_RETURN_POINTER(movie); ACTION_RETURN_POINTER(movie);
} }

View File

@ -97,7 +97,7 @@ static bool StreamCallbackFunc(SoundStream* stream, void* buff, int len, void* u
InterplayDecoder* pId = (InterplayDecoder*)userdata; InterplayDecoder* pId = (InterplayDecoder*)userdata;
memcpy(buff, &pId->audio.samples[pId->audio.nRead], len); memcpy(buff, &pId->audio.samples[pId->audio.nRead], len);
pId->audio.nRead += len / 2; pId->audio.nRead += len / 2;
if (pId->audio.nRead >= countof(pId->audio.samples)) pId->audio.nRead = 0; if (pId->audio.nRead >= (int)countof(pId->audio.samples)) pId->audio.nRead = 0;
return true; return true;
} }
@ -364,7 +364,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock)
} }
audio.samples[audio.nWrite++] = predictor[ch]; audio.samples[audio.nWrite++] = predictor[ch];
if (audio.nWrite >= countof(audio.samples)) audio.nWrite = 0; if (audio.nWrite >= (int)countof(audio.samples)) audio.nWrite = 0;
} }
int ch = 0; int ch = 0;
@ -374,7 +374,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock)
predictor[ch] = clamp(predictor[ch], -32768, 32768); predictor[ch] = clamp(predictor[ch], -32768, 32768);
audio.samples[audio.nWrite++] = predictor[ch]; audio.samples[audio.nWrite++] = predictor[ch];
if (audio.nWrite >= countof(audio.samples)) audio.nWrite = 0; if (audio.nWrite >= (int)countof(audio.samples)) audio.nWrite = 0;
// toggle channel // toggle channel
ch ^= audio.nChannels - 1; ch ^= audio.nChannels - 1;
@ -442,7 +442,7 @@ bool InterplayDecoder::RunFrame(uint64_t clock)
} }
else else
{ {
if (opcodeSize != decodeMap.nSize) { if (opcodeSize != (int)decodeMap.nSize) {
delete[] decodeMap.pData; delete[] decodeMap.pData;
decodeMap.pData = new uint8_t[opcodeSize]; decodeMap.pData = new uint8_t[opcodeSize];
decodeMap.nSize = opcodeSize; decodeMap.nSize = opcodeSize;

View File

@ -266,7 +266,7 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter)
// at least one of the more common definition lumps must be present. // at least one of the more common definition lumps must be present.
for (auto &p : filter->requiredPrefixes) for (auto &p : filter->requiredPrefixes)
{ {
if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == name.Len() - strlen(p)) if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == ptrdiff_t(name.Len() - strlen(p)))
{ {
foundspeciallump = true; foundspeciallump = true;
break; break;

View File

@ -686,7 +686,7 @@ int FFont::GetColorTranslation (EColorRange range, PalEntry *color) const
{ {
// Single pic fonts do not set up their translation table and must always return 0. // Single pic fonts do not set up their translation table and must always return 0.
if (Translations.Size() == 0) return 0; if (Translations.Size() == 0) return 0;
assert(Translations.Size() == NumTextColors); assert(Translations.Size() == (unsigned)NumTextColors);
if (noTranslate) if (noTranslate)
{ {

View File

@ -159,7 +159,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
mPresentShader->Uniforms.SetData(); mPresentShader->Uniforms.SetData();
for (int n = 0; n < mPresentShader->Uniforms.mFields.size(); n++) for (size_t n = 0; n < mPresentShader->Uniforms.mFields.size(); n++)
{ {
int index = -1; int index = -1;
UniformFieldDesc desc = mPresentShader->Uniforms.mFields[n]; UniformFieldDesc desc = mPresentShader->Uniforms.mFields[n];
@ -175,6 +175,8 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma)
case UniformType::Vec2: case UniformType::Vec2:
glUniform2fv(loc,1 , ((GLfloat*)(((char*)(&mPresentShader->Uniforms)) + desc.Offset))); glUniform2fv(loc,1 , ((GLfloat*)(((char*)(&mPresentShader->Uniforms)) + desc.Offset)));
break; break;
default:
break;
} }
} }
@ -222,4 +224,4 @@ void FGLRenderer::ClearBorders()
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);
} }
} }

View File

@ -116,13 +116,13 @@ bool FGLRenderState::ApplyShader()
addLights = (int(lightPtr[3]) - int(lightPtr[2])) / LIGHT_VEC4_NUM; addLights = (int(lightPtr[3]) - int(lightPtr[2])) / LIGHT_VEC4_NUM;
// Here we limit the number of lights, but dont' change the light data so priority has to be mod, sub then add // Here we limit the number of lights, but dont' change the light data so priority has to be mod, sub then add
if (modLights > gles.maxlights) if (modLights > (int)gles.maxlights)
modLights = gles.maxlights; modLights = gles.maxlights;
if (modLights + subLights > gles.maxlights) if (modLights + subLights > (int)gles.maxlights)
subLights = gles.maxlights - modLights; subLights = gles.maxlights - modLights;
if (modLights + subLights + addLights > gles.maxlights) if (modLights + subLights + addLights > (int)gles.maxlights)
addLights = gles.maxlights - modLights - subLights; addLights = gles.maxlights - modLights - subLights;
totalLights = modLights + subLights + addLights; totalLights = modLights + subLights + addLights;
@ -332,7 +332,7 @@ bool FGLRenderState::ApplyShader()
// Calculate the total number of vec4s we need // Calculate the total number of vec4s we need
int totalVectors = totalLights * LIGHT_VEC4_NUM; int totalVectors = totalLights * LIGHT_VEC4_NUM;
if (totalVectors > gles.numlightvectors) if (totalVectors > (int)gles.numlightvectors)
totalVectors = gles.numlightvectors; totalVectors = gles.numlightvectors;
glUniform4fv(activeShader->cur->lights_index, totalVectors, lightPtr); glUniform4fv(activeShader->cur->lights_index, totalVectors, lightPtr);

View File

@ -272,7 +272,7 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program
Uniforms.UniformLocation.resize(Uniforms.mFields.size()); Uniforms.UniformLocation.resize(Uniforms.mFields.size());
for (int n = 0; n < Uniforms.mFields.size(); n++) for (size_t n = 0; n < Uniforms.mFields.size(); n++)
{ {
int index = -1; int index = -1;
UniformFieldDesc desc = Uniforms.mFields[n]; UniformFieldDesc desc = Uniforms.mFields[n];
@ -290,4 +290,4 @@ void FPresentShader::Bind()
mShader->Bind(); mShader->Bind();
} }
} }