From b02a6a3ec967520ef1e842c739001868e2731737 Mon Sep 17 00:00:00 2001 From: Mitch Richters Date: Sat, 30 Oct 2021 19:21:43 +1100 Subject: [PATCH] - Replace `MIN()` from `templates.h` with version provided in STL. --- source/common/2d/v_2ddrawer.cpp | 2 +- source/common/2d/v_draw.cpp | 20 +++++------ source/common/audio/sound/oalsound.cpp | 2 +- source/common/audio/sound/s_sound.cpp | 4 +-- source/common/engine/palettecontainer.cpp | 6 ++-- source/common/filesystem/file_rff.cpp | 2 +- source/common/filesystem/file_zip.cpp | 4 +-- source/common/platform/posix/cocoa/i_input.mm | 2 +- source/common/platform/posix/cocoa/i_video.mm | 2 +- .../common/platform/posix/cocoa/st_console.mm | 2 +- source/common/platform/win32/st_start.cpp | 2 +- source/common/rendering/gl/gl_renderstate.h | 2 +- .../common/rendering/gl/gl_shaderprogram.cpp | 2 +- .../rendering/gles/gles_framebuffer.cpp | 2 +- .../common/rendering/gles/gles_renderstate.h | 2 +- .../rendering/hwrenderer/data/hw_skydome.cpp | 2 +- .../polyrenderer/backend/poly_framebuffer.cpp | 4 +-- .../polyrenderer/drawers/poly_thread.cpp | 10 +++--- .../polyrenderer/drawers/poly_thread.h | 2 +- .../polyrenderer/drawers/screen_blend.cpp | 16 ++++----- .../drawers/screen_scanline_setup.cpp | 34 +++++++++---------- .../polyrenderer/drawers/screen_shader.cpp | 24 ++++++------- .../polyrenderer/drawers/screen_triangle.cpp | 6 ++-- source/common/rendering/r_thread.h | 2 +- source/common/rendering/v_framebuffer.cpp | 2 +- source/common/rendering/v_video.cpp | 2 +- .../vulkan/system/vk_framebuffer.cpp | 6 ++-- .../rendering/vulkan/system/vk_swapchain.cpp | 8 ++--- source/common/scripting/core/types.cpp | 2 +- .../common/scripting/interface/vmnatives.cpp | 8 ++--- source/common/scripting/jit/jit_runtime.cpp | 2 +- source/common/statusbar/base_sbar.cpp | 2 +- source/common/textures/bitmap.h | 2 +- source/common/textures/formats/fontchars.cpp | 4 +-- source/common/textures/formats/pngtexture.cpp | 4 +-- source/common/textures/formats/tgatexture.cpp | 4 +-- source/common/textures/m_png.cpp | 8 ++--- source/common/thirdparty/earcut.hpp | 12 +++---- .../libsmackerdec/src/SmackerDecoder.cpp | 2 +- source/common/utility/cmdlib.cpp | 2 +- source/common/utility/files_decompress.cpp | 4 +-- source/common/utility/palette.cpp | 18 +++++----- source/common/utility/templates.h | 18 ---------- source/core/gamecontrol.cpp | 2 +- source/core/mainloop.cpp | 2 +- source/core/nodebuilder/nodebuild.cpp | 4 +-- source/core/nodebuilder/nodebuild_utility.cpp | 4 +-- source/core/rendering/scene/hw_portal.h | 4 +-- source/core/rendering/scene/hw_walls.cpp | 4 +-- source/core/statusbar2.cpp | 2 +- source/games/blood/src/sound.cpp | 2 +- source/games/duke/src/input.cpp | 4 +-- source/games/duke/src/premap.cpp | 8 ++--- source/games/duke/src/sectors.cpp | 1 - source/games/exhumed/src/gun.cpp | 2 +- source/games/exhumed/src/object.cpp | 2 +- source/glbackend/glbackend.cpp | 2 +- 57 files changed, 145 insertions(+), 164 deletions(-) diff --git a/source/common/2d/v_2ddrawer.cpp b/source/common/2d/v_2ddrawer.cpp index 612eef005..ddbdba538 100644 --- a/source/common/2d/v_2ddrawer.cpp +++ b/source/common/2d/v_2ddrawer.cpp @@ -455,7 +455,7 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) // Note that this only works for unflipped and unrotated full textures. if (parms.windowleft > 0 || parms.windowright < parms.texwidth) { - double wi = std::min(parms.windowright, parms.texwidth); + double wi = min(parms.windowright, parms.texwidth); x += parms.windowleft * xscale; w -= (parms.texwidth - wi + parms.windowleft) * xscale; diff --git a/source/common/2d/v_draw.cpp b/source/common/2d/v_draw.cpp index 95ae345e6..b35e7723a 100644 --- a/source/common/2d/v_draw.cpp +++ b/source/common/2d/v_draw.cpp @@ -152,7 +152,7 @@ int GetUIScale(F2DDrawer *drawer, int altval) int vmax = drawer->GetHeight() / 200; int hmax = drawer->GetWidth() / 320; int max = std::max(vmax, hmax); - return std::max(1,MIN(scaleval, max)); + return std::max(1,min(scaleval, max)); } // The new console font is twice as high, so the scaling calculation must factor that in. @@ -173,7 +173,7 @@ int GetConScale(F2DDrawer* drawer, int altval) int vmax = drawer->GetHeight() / 400; int hmax = drawer->GetWidth() / 640; int max = std::max(vmax, hmax); - return std::max(1, MIN(scaleval, max)); + return std::max(1, min(scaleval, max)); } @@ -357,7 +357,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetClipRect) if (numret > 1) ret[1].SetInt(y); if (numret > 2) ret[2].SetInt(w); if (numret > 3) ret[3].SetInt(h); - return MIN(numret, 4); + return min(numret, 4); } @@ -460,7 +460,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetFullscreenRect) if (numret >= 2) ret[1].SetFloat(rect.top); if (numret >= 3) ret[2].SetFloat(rect.width); if (numret >= 4) ret[3].SetFloat(rect.height); - return MIN(numret, 4); + return min(numret, 4); } @@ -905,7 +905,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_Alpha: - parms->Alpha = (float)(MIN(1., ListGetDouble(tags))); + parms->Alpha = (float)(min(1., ListGetDouble(tags))); break; case DTA_AlphaChannel: @@ -1090,7 +1090,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_ShadowAlpha: - //parms->shadowAlpha = (float)MIN(1., ListGetDouble(tags)); + //parms->shadowAlpha = (float)min(1., ListGetDouble(tags)); break; case DTA_ShadowColor: @@ -1286,10 +1286,10 @@ static void VirtualToRealCoords(F2DDrawer *drawer, double Width, double Height, { case 1: default: - myratio = MIN(64.0f / 27.0f, myratio); + myratio = min(64.0f / 27.0f, myratio); break; case 0: - myratio = MIN(16.0f / 9.0f, myratio); + myratio = min(16.0f / 9.0f, myratio); case -1: break; } @@ -1348,7 +1348,7 @@ DEFINE_ACTION_FUNCTION(_Screen, VirtualToRealCoords) VirtualToRealCoords(twod, x, y, w, h, vw, vh, vbottom, handleaspect); if (numret >= 1) ret[0].SetVector2(DVector2(x, y)); if (numret >= 2) ret[1].SetVector2(DVector2(w, h)); - return MIN(numret, 2); + return min(numret, 2); } void VirtualToRealCoordsInt(F2DDrawer *drawer, int &x, int &y, int &w, int &h, @@ -1594,7 +1594,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawLineFrame) void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* _cx1, int* _cx2) { if (designheight < 240 && realheight >= 480) designheight = 240; - *cleanx = *cleany = std::min(realwidth / designwidth, realheight / designheight); + *cleanx = *cleany = min(realwidth / designwidth, realheight / designheight); } diff --git a/source/common/audio/sound/oalsound.cpp b/source/common/audio/sound/oalsound.cpp index 3d506099f..96b01c761 100644 --- a/source/common/audio/sound/oalsound.cpp +++ b/source/common/audio/sound/oalsound.cpp @@ -689,7 +689,7 @@ OpenALSoundRenderer::OpenALSoundRenderer() numSources = numChannels; } - Sources.Resize(std::min(numChannels, numSources)); + Sources.Resize(min(numChannels, numSources)); for(unsigned i = 0;i < Sources.Size();i++) { alGenSources(1, &Sources[i]); diff --git a/source/common/audio/sound/s_sound.cpp b/source/common/audio/sound/s_sound.cpp index c50c266be..55e281be1 100644 --- a/source/common/audio/sound/s_sound.cpp +++ b/source/common/audio/sound/s_sound.cpp @@ -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++; diff --git a/source/common/engine/palettecontainer.cpp b/source/common/engine/palettecontainer.cpp index 41a92735d..4793fd67c 100644 --- a/source/common/engine/palettecontainer.cpp +++ b/source/common/engine/palettecontainer.cpp @@ -565,9 +565,9 @@ bool FRemapTable::AddDesaturation(int start, int end, double r1, double g1, doub GPalette.BaseColors[c].g * 143 + GPalette.BaseColors[c].b * 37) / 256.0; - PalEntry pe = PalEntry( MIN(255, int(r1 + intensity*r2)), - MIN(255, int(g1 + intensity*g2)), - MIN(255, int(b1 + intensity*b2))); + PalEntry pe = PalEntry( min(255, int(r1 + intensity*r2)), + min(255, int(g1 + intensity*g2)), + min(255, int(b1 + intensity*b2))); int cc = GPalette.Remap[c]; diff --git a/source/common/filesystem/file_rff.cpp b/source/common/filesystem/file_rff.cpp index c69b50246..61603c800 100644 --- a/source/common/filesystem/file_rff.cpp +++ b/source/common/filesystem/file_rff.cpp @@ -219,7 +219,7 @@ int FRFFLump::FillCache() if (Flags & LUMPF_COMPRESSED) { - int cryptlen = MIN (LumpSize, 256); + int cryptlen = min (LumpSize, 256); uint8_t *data = (uint8_t *)Cache; for (int i = 0; i < cryptlen; ++i) diff --git a/source/common/filesystem/file_zip.cpp b/source/common/filesystem/file_zip.cpp index db5bdf902..32a3a7807 100644 --- a/source/common/filesystem/file_zip.cpp +++ b/source/common/filesystem/file_zip.cpp @@ -124,7 +124,7 @@ static uint32_t Zip_FindCentralDir(FileReader &fin) uint32_t uPosFound=0; FileSize = (uint32_t)fin.GetLength(); - uMaxBack = MIN(0xffff, FileSize); + uMaxBack = min(0xffff, FileSize); uBackRead = 4; while (uBackRead < uMaxBack) @@ -137,7 +137,7 @@ static uint32_t Zip_FindCentralDir(FileReader &fin) uBackRead += BUFREADCOMMENT; uReadPos = FileSize - uBackRead; - uReadSize = MIN((BUFREADCOMMENT + 4), (FileSize - uReadPos)); + uReadSize = min((BUFREADCOMMENT + 4), (FileSize - uReadPos)); if (fin.Seek(uReadPos, FileReader::SeekSet) != 0) break; diff --git a/source/common/platform/posix/cocoa/i_input.mm b/source/common/platform/posix/cocoa/i_input.mm index c329da3b9..ebda85a2e 100644 --- a/source/common/platform/posix/cocoa/i_input.mm +++ b/source/common/platform/posix/cocoa/i_input.mm @@ -644,7 +644,7 @@ void ProcessMouseButtonEvent(NSEvent* theEvent) break; } - event.data1 = MIN(KEY_MOUSE1 + [theEvent buttonNumber], NSInteger(KEY_MOUSE8)); + event.data1 = min(KEY_MOUSE1 + [theEvent buttonNumber], NSInteger(KEY_MOUSE8)); D_PostEvent(&event); } diff --git a/source/common/platform/posix/cocoa/i_video.mm b/source/common/platform/posix/cocoa/i_video.mm index 193466f0d..8f730e488 100644 --- a/source/common/platform/posix/cocoa/i_video.mm +++ b/source/common/platform/posix/cocoa/i_video.mm @@ -969,7 +969,7 @@ bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names) else { const bool result = *count >= extensionCount; - *count = std::min(*count, extensionCount); + *count = min(*count, extensionCount); for (unsigned int i = 0; i < *count; ++i) { diff --git a/source/common/platform/posix/cocoa/st_console.mm b/source/common/platform/posix/cocoa/st_console.mm index af26ae172..1c45776e6 100644 --- a/source/common/platform/posix/cocoa/st_console.mm +++ b/source/common/platform/posix/cocoa/st_console.mm @@ -510,7 +510,7 @@ void FConsoleWindow::NetProgress(const int count) if (m_netMaxPos > 1) { [m_netCountText setStringValue:[NSString stringWithFormat:@"%d / %d", m_netCurPos, m_netMaxPos]]; - [m_netProgressBar setDoubleValue:MIN(m_netCurPos, m_netMaxPos)]; + [m_netProgressBar setDoubleValue:min(m_netCurPos, m_netMaxPos)]; } } diff --git a/source/common/platform/win32/st_start.cpp b/source/common/platform/win32/st_start.cpp index f36371a9b..8e8acaeff 100644 --- a/source/common/platform/win32/st_start.cpp +++ b/source/common/platform/win32/st_start.cpp @@ -351,7 +351,7 @@ void FBasicStartupScreen :: NetProgress(int count) mysnprintf (buf, countof(buf), "%d/%d", NetCurPos, NetMaxPos); SetDlgItemTextA (NetStartPane, IDC_NETSTARTCOUNT, buf); - SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, std::min(NetCurPos, NetMaxPos), 0); + SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, min(NetCurPos, NetMaxPos), 0); } } diff --git a/source/common/rendering/gl/gl_renderstate.h b/source/common/rendering/gl/gl_renderstate.h index 948255d71..9cfe3d7a2 100644 --- a/source/common/rendering/gl/gl_renderstate.h +++ b/source/common/rendering/gl/gl_renderstate.h @@ -107,7 +107,7 @@ public: void EnableDrawBuffers(int count, bool apply = false) override { - count = std::min(count, 3); + count = min(count, 3); if (mNumDrawBuffers != count) { static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; diff --git a/source/common/rendering/gl/gl_shaderprogram.cpp b/source/common/rendering/gl/gl_shaderprogram.cpp index eb322fb94..2b6df3254 100644 --- a/source/common/rendering/gl/gl_shaderprogram.cpp +++ b/source/common/rendering/gl/gl_shaderprogram.cpp @@ -263,7 +263,7 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const // If we have 4.2, always use it because it adds important new syntax. if (maxGlslVersion < 420 && gl.glslversion >= 4.2f) maxGlslVersion = 420; - int shaderVersion = std::min((int)round(gl.glslversion * 10) * 10, maxGlslVersion); + int shaderVersion = min((int)round(gl.glslversion * 10) * 10, maxGlslVersion); patchedCode.AppendFormat("#version %d\n", shaderVersion); // TODO: Find some way to add extension requirements to the patching diff --git a/source/common/rendering/gles/gles_framebuffer.cpp b/source/common/rendering/gles/gles_framebuffer.cpp index 3a74ee6bc..80c252b63 100644 --- a/source/common/rendering/gles/gles_framebuffer.cpp +++ b/source/common/rendering/gles/gles_framebuffer.cpp @@ -122,7 +122,7 @@ void OpenGLFrameBuffer::InitializeState() { static bool first=true; - mPipelineNbr = gl_pipeline_depth == 0? std::min(4, HW_MAX_PIPELINE_BUFFERS) : clamp(*gl_pipeline_depth, 1, HW_MAX_PIPELINE_BUFFERS); + mPipelineNbr = gl_pipeline_depth == 0? min(4, HW_MAX_PIPELINE_BUFFERS) : clamp(*gl_pipeline_depth, 1, HW_MAX_PIPELINE_BUFFERS); mPipelineType = 1; InitGLES(); diff --git a/source/common/rendering/gles/gles_renderstate.h b/source/common/rendering/gles/gles_renderstate.h index 7b7768541..4dd8516ec 100644 --- a/source/common/rendering/gles/gles_renderstate.h +++ b/source/common/rendering/gles/gles_renderstate.h @@ -109,7 +109,7 @@ public: void EnableDrawBuffers(int count, bool apply = false) override { /* - count = std::min(count, 3); + count = min(count, 3); if (mNumDrawBuffers != count) { static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; diff --git a/source/common/rendering/hwrenderer/data/hw_skydome.cpp b/source/common/rendering/hwrenderer/data/hw_skydome.cpp index e9e1bc364..9bbe5787f 100644 --- a/source/common/rendering/hwrenderer/data/hw_skydome.cpp +++ b/source/common/rendering/hwrenderer/data/hw_skydome.cpp @@ -98,7 +98,7 @@ std::pair& R_GetSkyCapColor(FGameTexture* tex) const uint32_t* buffer = (const uint32_t*)bitmap.GetPixels(); if (buffer) { - sky.Colors.first = averageColor((uint32_t*)buffer, w * MIN(30, h), 0); + sky.Colors.first = averageColor((uint32_t*)buffer, w * min(30, h), 0); if (h > 30) { sky.Colors.second = averageColor(((uint32_t*)buffer) + (h - 30) * w, w * 30, 0); diff --git a/source/common/rendering/polyrenderer/backend/poly_framebuffer.cpp b/source/common/rendering/polyrenderer/backend/poly_framebuffer.cpp index 6f8ead0c5..683786570 100644 --- a/source/common/rendering/polyrenderer/backend/poly_framebuffer.cpp +++ b/source/common/rendering/polyrenderer/backend/poly_framebuffer.cpp @@ -219,8 +219,8 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::functionGetWidth(), image->GetWidth()); - bounds.height = std::min(tex->GetHeight(), image->GetHeight()); + bounds.width = min(tex->GetWidth(), image->GetWidth()); + bounds.height = min(tex->GetHeight(), image->GetHeight()); renderFunc(bounds); diff --git a/source/common/rendering/polyrenderer/drawers/poly_thread.cpp b/source/common/rendering/polyrenderer/drawers/poly_thread.cpp index cd622159e..38faabafb 100644 --- a/source/common/rendering/polyrenderer/drawers/poly_thread.cpp +++ b/source/common/rendering/polyrenderer/drawers/poly_thread.cpp @@ -102,8 +102,8 @@ void PolyTriangleThreadData::UpdateClip() { clip.left = max(max(viewport_x, scissor.left), 0); clip.top = max(max(viewport_y, scissor.top), 0); - clip.right = MIN(MIN(viewport_x + viewport_width, scissor.right), dest_width); - clip.bottom = MIN(MIN(viewport_y + viewport_height, scissor.bottom), dest_height); + clip.right = min(min(viewport_x + viewport_width, scissor.right), dest_width); + clip.bottom = min(min(viewport_y + viewport_height, scissor.bottom), dest_height); } void PolyTriangleThreadData::PushStreamData(const StreamData &data, const PolyPushConstants &constants) @@ -206,7 +206,7 @@ void PolyTriangleThreadData::SetStencil(int stencilRef, int op) StencilTestValue = stencilRef; if (op == SOP_Increment) { - StencilWriteValue = MIN(stencilRef + 1, (int)255); + StencilWriteValue = min(stencilRef + 1, (int)255); } else if (op == SOP_Decrement) { @@ -454,7 +454,7 @@ void PolyTriangleThreadData::DrawShadedLine(const ShadedTriVertex *const* vert) float clipdistance1 = clipdistance[0 * numclipdistances + p]; float clipdistance2 = clipdistance[1 * numclipdistances + p]; if (clipdistance1 < 0.0f) t1 = max(-clipdistance1 / (clipdistance2 - clipdistance1), t1); - if (clipdistance2 < 0.0f) t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); + if (clipdistance2 < 0.0f) t2 = min(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); if (t1 >= t2) return; } @@ -793,7 +793,7 @@ int PolyTriangleThreadData::ClipEdge(const ShadedTriVertex *const* verts) if ((clipdistance1 >= 0.0f || clipdistance2 >= 0.0f) && outputverts + 1 < max_additional_vertices) { float t1 = (clipdistance1 < 0.0f) ? max(-clipdistance1 / (clipdistance2 - clipdistance1), 0.0f) : 0.0f; - float t2 = (clipdistance2 < 0.0f) ? MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f) : 1.0f; + float t2 = (clipdistance2 < 0.0f) ? min(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f) : 1.0f; // add t1 vertex for (int k = 0; k < 3; k++) diff --git a/source/common/rendering/polyrenderer/drawers/poly_thread.h b/source/common/rendering/polyrenderer/drawers/poly_thread.h index 89ab7d1e0..abaa43e32 100644 --- a/source/common/rendering/polyrenderer/drawers/poly_thread.h +++ b/source/common/rendering/polyrenderer/drawers/poly_thread.h @@ -92,7 +92,7 @@ public: int count_for_thread(int first_line, int count) { - count = MIN(count, numa_end_y - first_line); + count = min(count, numa_end_y - first_line); int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; return max(c, 0); } diff --git a/source/common/rendering/polyrenderer/drawers/screen_blend.cpp b/source/common/rendering/polyrenderer/drawers/screen_blend.cpp index 0bd7396e0..536acb7b0 100644 --- a/source/common/rendering/polyrenderer/drawers/screen_blend.cpp +++ b/source/common/rendering/polyrenderer/drawers/screen_blend.cpp @@ -336,10 +336,10 @@ void BlendColorAdd_Src_One(int y, int x0, int x1, PolyTriangleThreadData* thread uint32_t srcscale = APART(src); srcscale += srcscale >> 7; - uint32_t a = MIN((((APART(src) * srcscale) + 127) >> 8) + APART(dst), 255); - uint32_t r = MIN((((RPART(src) * srcscale) + 127) >> 8) + RPART(dst), 255); - uint32_t g = MIN((((GPART(src) * srcscale) + 127) >> 8) + GPART(dst), 255); - uint32_t b = MIN((((BPART(src) * srcscale) + 127) >> 8) + BPART(dst), 255); + uint32_t a = min((((APART(src) * srcscale) + 127) >> 8) + APART(dst), 255); + uint32_t r = min((((RPART(src) * srcscale) + 127) >> 8) + RPART(dst), 255); + uint32_t g = min((((GPART(src) * srcscale) + 127) >> 8) + GPART(dst), 255); + uint32_t b = min((((BPART(src) * srcscale) + 127) >> 8) + BPART(dst), 255); line[x] = MAKEARGB(a, r, g, b); } @@ -382,10 +382,10 @@ void BlendColorAdd_SrcCol_One(int y, int x0, int x1, PolyTriangleThreadData* thr srcscale_g += srcscale_g >> 7; srcscale_b += srcscale_b >> 7; - uint32_t a = MIN((((APART(src) * srcscale_a) + 127) >> 8) + APART(dst), 255); - uint32_t r = MIN((((RPART(src) * srcscale_r) + 127) >> 8) + RPART(dst), 255); - uint32_t g = MIN((((GPART(src) * srcscale_g) + 127) >> 8) + GPART(dst), 255); - uint32_t b = MIN((((BPART(src) * srcscale_b) + 127) >> 8) + BPART(dst), 255); + uint32_t a = min((((APART(src) * srcscale_a) + 127) >> 8) + APART(dst), 255); + uint32_t r = min((((RPART(src) * srcscale_r) + 127) >> 8) + RPART(dst), 255); + uint32_t g = min((((GPART(src) * srcscale_g) + 127) >> 8) + GPART(dst), 255); + uint32_t b = min((((BPART(src) * srcscale_b) + 127) >> 8) + BPART(dst), 255); line[x] = MAKEARGB(a, r, g, b); } diff --git a/source/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp b/source/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp index f5a2e4216..bd5307792 100644 --- a/source/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp +++ b/source/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp @@ -124,7 +124,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread) // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) __m128 Lx = _mm_sub_ps(lightposX, _mm_loadu_ps(&worldposX[x])); __m128 Ly = _mm_sub_ps(lightposY, _mm_loadu_ps(&worldposY[x])); __m128 Lz = _mm_sub_ps(lightposZ, _mm_loadu_ps(&worldposZ[x])); @@ -179,7 +179,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread) // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) float Lx = lightposX - worldposX[x]; float Ly = lightposY - worldposY[x]; float Lz = lightposZ - worldposZ[x]; @@ -191,7 +191,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread) float rcp_dist = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(dist2))); #endif float dist = dist2 * rcp_dist; - float distance_attenuation = 256.0f - MIN(dist * light_radius, 256.0f); + float distance_attenuation = 256.0f - min(dist * light_radius, 256.0f); // The simple light type float simple_attenuation = distance_attenuation; @@ -211,9 +211,9 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread) lit_b += (BPART(light_color) * attenuation) >> 8; } - lit_r = MIN(lit_r, 255); - lit_g = MIN(lit_g, 255); - lit_b = MIN(lit_b, 255); + lit_r = min(lit_r, 255); + lit_g = min(lit_g, 255); + lit_b = min(lit_b, 255); lightarray[x] = MAKEARGB(lit_a, lit_r, lit_g, lit_b); // Palette version: @@ -255,7 +255,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar uint32_t* lightarray = thread->scanline.lightarray; for (int x = x0; x < x1; x++) { - uint32_t l = MIN(lightpos >> 8, 256); + uint32_t l = min(lightpos >> 8, 256); uint32_t r = vColorR[x]; uint32_t g = vColorG[x]; @@ -273,9 +273,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar g += (uint32_t)(constants->uDynLightColor.Y * 255.0f); b += (uint32_t)(constants->uDynLightColor.Z * 255.0f); - r = MIN(r, 255); - g = MIN(g, 255); - b = MIN(b, 255); + r = min(r, 255); + g = min(g, 255); + b = min(b, 255); } lightarray[x] = MAKEARGB(a, r, g, b); @@ -287,7 +287,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar uint32_t* lightarray = thread->scanline.lightarray; for (int x = x0; x < x1; x++) { - uint32_t l = MIN((FRACUNIT - clamp(shade - MIN(maxvis, lightpos), 0, maxlight)) >> 8, 256); + uint32_t l = min((FRACUNIT - clamp(shade - min(maxvis, lightpos), 0, maxlight)) >> 8, 256); uint32_t r = vColorR[x]; uint32_t g = vColorG[x]; uint32_t b = vColorB[x]; @@ -304,9 +304,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar g += (uint32_t)(constants->uDynLightColor.Y * 255.0f); b += (uint32_t)(constants->uDynLightColor.Z * 255.0f); - r = MIN(r, 255); - g = MIN(g, 255); - b = MIN(b, 255); + r = min(r, 255); + g = min(g, 255); + b = min(b, 255); } lightarray[x] = MAKEARGB(a, r, g, b); @@ -365,9 +365,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar g += (uint32_t)(constants->uDynLightColor.Y * 255.0f); b += (uint32_t)(constants->uDynLightColor.Z * 255.0f); - r = MIN(r, 255); - g = MIN(g, 255); - b = MIN(b, 255); + r = min(r, 255); + g = min(g, 255); + b = min(b, 255); } lightarray[x] = MAKEARGB(a, r, g, b); diff --git a/source/common/rendering/polyrenderer/drawers/screen_shader.cpp b/source/common/rendering/polyrenderer/drawers/screen_shader.cpp index 09f9ffdf3..023142cb9 100644 --- a/source/common/rendering/polyrenderer/drawers/screen_shader.cpp +++ b/source/common/rendering/polyrenderer/drawers/screen_shader.cpp @@ -291,9 +291,9 @@ static void FuncNormal_AddColor(int x0, int x1, PolyTriangleThreadData* thread) uint32_t texel = fragcolor[x]; fragcolor[x] = MAKEARGB( APART(texel), - MIN(r + RPART(texel), (uint32_t)255), - MIN(g + GPART(texel), (uint32_t)255), - MIN(b + BPART(texel), (uint32_t)255)); + min(r + RPART(texel), (uint32_t)255), + min(g + GPART(texel), (uint32_t)255), + min(b + BPART(texel), (uint32_t)255)); } } @@ -309,9 +309,9 @@ static void FuncNormal_AddObjectColor(int x0, int x1, PolyTriangleThreadData* th uint32_t texel = fragcolor[x]; fragcolor[x] = MAKEARGB( APART(texel), - MIN((r * RPART(texel)) >> 8, (uint32_t)255), - MIN((g * GPART(texel)) >> 8, (uint32_t)255), - MIN((b * BPART(texel)) >> 8, (uint32_t)255)); + min((r * RPART(texel)) >> 8, (uint32_t)255), + min((g * GPART(texel)) >> 8, (uint32_t)255), + min((b * BPART(texel)) >> 8, (uint32_t)255)); } } @@ -331,9 +331,9 @@ static void FuncNormal_AddObjectColor2(int x0, int x1, PolyTriangleThreadData* t uint32_t texel = fragcolor[x]; fragcolor[x] = MAKEARGB( APART(texel), - MIN((r * RPART(texel)) >> 8, (uint32_t)255), - MIN((g * GPART(texel)) >> 8, (uint32_t)255), - MIN((b * BPART(texel)) >> 8, (uint32_t)255)); + min((r * RPART(texel)) >> 8, (uint32_t)255), + min((g * GPART(texel)) >> 8, (uint32_t)255), + min((b * BPART(texel)) >> 8, (uint32_t)255)); } } @@ -594,9 +594,9 @@ static void MainFP(int x0, int x1, PolyTriangleThreadData* thread) b = (BPART(fragcolor[x]) * b + 127) >> 8; // frag.rgb = frag.rgb + uFogColor.rgb; - r = MIN(r + fogR, (uint32_t)255); - g = MIN(g + fogG, (uint32_t)255); - b = MIN(b + fogB, (uint32_t)255); + r = min(r + fogR, (uint32_t)255); + g = min(g + fogG, (uint32_t)255); + b = min(b + fogB, (uint32_t)255); fragcolor[x] = MAKEARGB(a, r, g, b); } diff --git a/source/common/rendering/polyrenderer/drawers/screen_triangle.cpp b/source/common/rendering/polyrenderer/drawers/screen_triangle.cpp index 545df6bd7..dfa82fd2c 100644 --- a/source/common/rendering/polyrenderer/drawers/screen_triangle.cpp +++ b/source/common/rendering/polyrenderer/drawers/screen_triangle.cpp @@ -209,15 +209,15 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs* args, PolyTriangleThreadDat int clipleft = thread->clip.left; int cliptop = max(thread->clip.top, thread->numa_start_y); int clipright = thread->clip.right; - int clipbottom = MIN(thread->clip.bottom, thread->numa_end_y); + int clipbottom = min(thread->clip.bottom, thread->numa_end_y); int topY = (int)(sortedVertices[0]->y + 0.5f); int midY = (int)(sortedVertices[1]->y + 0.5f); int bottomY = (int)(sortedVertices[2]->y + 0.5f); topY = max(topY, cliptop); - midY = MIN(midY, clipbottom); - bottomY = MIN(bottomY, clipbottom); + midY = min(midY, clipbottom); + bottomY = min(bottomY, clipbottom); if (topY >= bottomY) return; diff --git a/source/common/rendering/r_thread.h b/source/common/rendering/r_thread.h index 439e9638f..e5aea8541 100644 --- a/source/common/rendering/r_thread.h +++ b/source/common/rendering/r_thread.h @@ -86,7 +86,7 @@ public: // The number of lines to be rendered by this thread int count_for_thread(int first_line, int count) { - count = MIN(count, numa_end_y - first_line); + count = min(count, numa_end_y - first_line); int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; return max(c, 0); } diff --git a/source/common/rendering/v_framebuffer.cpp b/source/common/rendering/v_framebuffer.cpp index d1f148f1b..c0ebb4c25 100644 --- a/source/common/rendering/v_framebuffer.cpp +++ b/source/common/rendering/v_framebuffer.cpp @@ -186,7 +186,7 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) int screenWidth = GetWidth(); int screenHeight = GetHeight(); float scaleX, scaleY; - scaleX = std::min(clientWidth / (float)screenWidth, clientHeight / ((float)screenHeight * ViewportPixelAspect())); + scaleX = min(clientWidth / (float)screenWidth, clientHeight / ((float)screenHeight * ViewportPixelAspect())); scaleY = scaleX * ViewportPixelAspect(); mOutputLetterbox.width = (int)round(screenWidth * scaleX); mOutputLetterbox.height = (int)round(screenHeight * scaleY); diff --git a/source/common/rendering/v_video.cpp b/source/common/rendering/v_video.cpp index fe543b1a3..2d4e08942 100644 --- a/source/common/rendering/v_video.cpp +++ b/source/common/rendering/v_video.cpp @@ -275,7 +275,7 @@ void V_UpdateModeSize (int width, int height) // This reference size is being used so that on 800x450 (small 16:9) a scale of 2 gets used. - CleanXfac = max(std::min(screen->GetWidth() / 400, screen->GetHeight() / 240), 1); + CleanXfac = max(min(screen->GetWidth() / 400, screen->GetHeight() / 240), 1); if (CleanXfac >= 4) CleanXfac--; // Otherwise we do not have enough space for the episode/skill menus in some languages. CleanYfac = CleanXfac; CleanWidth = screen->GetWidth() / CleanXfac; diff --git a/source/common/rendering/vulkan/system/vk_framebuffer.cpp b/source/common/rendering/vulkan/system/vk_framebuffer.cpp index 7052831ee..160876da4 100644 --- a/source/common/rendering/vulkan/system/vk_framebuffer.cpp +++ b/source/common/rendering/vulkan/system/vk_framebuffer.cpp @@ -309,7 +309,7 @@ void VulkanFrameBuffer::WaitForCommands(bool finish, bool uploadOnly) swapChain->QueuePresent(presentImageIndex, mRenderFinishedSemaphore.get()); } - int numWaitFences = MIN(mNextSubmit, (int)maxConcurrentSubmitCount); + int numWaitFences = min(mNextSubmit, (int)maxConcurrentSubmitCount); if (numWaitFences > 0) { @@ -345,8 +345,8 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::functionGetWidth(), image->Image->width); - bounds.height = std::min(tex->GetHeight(), image->Image->height); + bounds.width = min(tex->GetWidth(), image->Image->width); + bounds.height = min(tex->GetHeight(), image->Image->height); renderFunc(bounds); diff --git a/source/common/rendering/vulkan/system/vk_swapchain.cpp b/source/common/rendering/vulkan/system/vk_swapchain.cpp index f3712894b..789259695 100644 --- a/source/common/rendering/vulkan/system/vk_swapchain.cpp +++ b/source/common/rendering/vulkan/system/vk_swapchain.cpp @@ -161,8 +161,8 @@ bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain) VkSurfaceCapabilitiesKHR surfaceCapabilities = GetSurfaceCapabilities(); actualExtent = { static_cast(width), static_cast(height) }; - actualExtent.width = max(surfaceCapabilities.minImageExtent.width, std::min(surfaceCapabilities.maxImageExtent.width, actualExtent.width)); - actualExtent.height = max(surfaceCapabilities.minImageExtent.height, std::min(surfaceCapabilities.maxImageExtent.height, actualExtent.height)); + actualExtent.width = max(surfaceCapabilities.minImageExtent.width, min(surfaceCapabilities.maxImageExtent.width, actualExtent.width)); + actualExtent.height = max(surfaceCapabilities.minImageExtent.height, min(surfaceCapabilities.maxImageExtent.height, actualExtent.height)); if (actualExtent.width == 0 || actualExtent.height == 0) { swapChain = VK_NULL_HANDLE; @@ -176,9 +176,9 @@ bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain) // When vsync is on we only want two images. This creates a slight performance penalty in exchange for reduced input latency (less mouse lag). // When vsync is off we want three images as it allows us to generate new images even during the vertical blanking period where one entry is being used by the presentation engine. if (swapChainPresentMode == VK_PRESENT_MODE_MAILBOX_KHR || swapChainPresentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) - imageCount = std::min(imageCount, (uint32_t)3); + imageCount = min(imageCount, (uint32_t)3); else - imageCount = std::min(imageCount, (uint32_t)2); + imageCount = min(imageCount, (uint32_t)2); VkSwapchainCreateInfoKHR swapChainCreateInfo = {}; swapChainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; diff --git a/source/common/scripting/core/types.cpp b/source/common/scripting/core/types.cpp index 260aff106..3fb97cb32 100644 --- a/source/common/scripting/core/types.cpp +++ b/source/common/scripting/core/types.cpp @@ -1702,7 +1702,7 @@ bool PArray::ReadValue(FSerializer &ar, const char *key, void *addr) const { bool readsomething = false; unsigned count = ar.ArraySize(); - unsigned loop = std::min(count, ElementCount); + unsigned loop = min(count, ElementCount); uint8_t *addrb = (uint8_t *)addr; for(unsigned i=0;i 1) ret[1].SetFloat(y); if (numret > 2) ret[2].SetFloat(w); if (numret > 3) ret[3].SetFloat(h); - return MIN(4, numret); + return min(4, numret); } void SBar_DrawTexture(DStatusBarCore* self, int texid, double x, double y, int flags, double alpha, double w, double h, double scaleX, double scaleY, int style, int color, int translation, double clipwidth) @@ -228,7 +228,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, TransformRect, SBar_TransformRect) if (numret > 1) ret[1].SetFloat(y); if (numret > 2) ret[2].SetFloat(w); if (numret > 3) ret[3].SetFloat(h); - return MIN(4, numret); + return min(4, numret); } static void SBar_Fill(DStatusBarCore* self, int color, double x, double y, double w, double h, int flags) @@ -437,7 +437,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetSize, GetTextureSize) x = GetTextureSize(texid, &y); if (numret > 0) ret[0].SetInt(x); if (numret > 1) ret[1].SetInt(y); - return MIN(numret, 2); + return min(numret, 2); } //========================================================================== @@ -941,7 +941,7 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, GetKeysForCommand) self->GetKeysForCommand(cmd.GetChars(), &k1, &k2); if (numret > 0) ret[0].SetInt(k1); if (numret > 1) ret[1].SetInt(k2); - return MIN(numret, 2); + return min(numret, 2); } DEFINE_ACTION_FUNCTION(FKeyBindings, GetAllKeysForCommand) diff --git a/source/common/scripting/jit/jit_runtime.cpp b/source/common/scripting/jit/jit_runtime.cpp index 1f0d95611..a646ebf9b 100644 --- a/source/common/scripting/jit/jit_runtime.cpp +++ b/source/common/scripting/jit/jit_runtime.cpp @@ -803,7 +803,7 @@ static int CaptureStackTrace(int max_frames, void **out_frames) #elif defined(WIN32) // JIT isn't supported here, so just do nothing. - return 0;//return RtlCaptureStackBackTrace(0, MIN(max_frames, 32), out_frames, nullptr); + return 0;//return RtlCaptureStackBackTrace(0, min(max_frames, 32), out_frames, nullptr); #else return backtrace(out_frames, max_frames); #endif diff --git a/source/common/statusbar/base_sbar.cpp b/source/common/statusbar/base_sbar.cpp index df0440b4c..383e8a148 100644 --- a/source/common/statusbar/base_sbar.cpp +++ b/source/common/statusbar/base_sbar.cpp @@ -489,7 +489,7 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag if (boxwidth <= 0 || (boxheight > 0 && scale2 < scale1)) scale1 = scale2; } - else scale1 = MIN(scale1, scale2); + else scale1 = min(scale1, scale2); boxwidth = texwidth * scale1; boxheight = texheight * scale1; diff --git a/source/common/textures/bitmap.h b/source/common/textures/bitmap.h index e41949a02..dc2054778 100644 --- a/source/common/textures/bitmap.h +++ b/source/common/textures/bitmap.h @@ -473,7 +473,7 @@ struct bBlend struct bAdd { - static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MIN((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = min((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; diff --git a/source/common/textures/formats/fontchars.cpp b/source/common/textures/formats/fontchars.cpp index 44a72ca6e..a48600437 100644 --- a/source/common/textures/formats/fontchars.cpp +++ b/source/common/textures/formats/fontchars.cpp @@ -113,7 +113,7 @@ TArray FFontChar2::CreatePalettedPixels(int) if (runlen != 0) { uint8_t color = lump.ReadUInt8(); - color = MIN(color, max); + color = min(color, max); *dest_p = color; dest_p += dest_adv; x--; @@ -137,7 +137,7 @@ TArray FFontChar2::CreatePalettedPixels(int) { uint8_t color = lump.ReadUInt8(); setlen = (-code) + 1; - setval = MIN(color, max); + setval = min(color, max); } } } diff --git a/source/common/textures/formats/pngtexture.cpp b/source/common/textures/formats/pngtexture.cpp index bf1cc88cd..b16057a8d 100644 --- a/source/common/textures/formats/pngtexture.cpp +++ b/source/common/textures/formats/pngtexture.cpp @@ -244,7 +244,7 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, int width, int height, break; case MAKE_ID('P','L','T','E'): - PaletteSize = MIN (len / 3, 256); + PaletteSize = min (len / 3, 256); StartOfPalette = (uint32_t)lump.Tell(); lump.Seek(len, FileReader::SeekCur); break; @@ -762,7 +762,7 @@ FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans) lump->Seek (len, FileReader::SeekCur); else { - PaletteSize = std::min (len / 3, 256); + PaletteSize = min (len / 3, 256); for(int i = 0; i < PaletteSize; i++) { pe[i].r = lump->ReadUInt8(); diff --git a/source/common/textures/formats/tgatexture.cpp b/source/common/textures/formats/tgatexture.cpp index 80c7b04a8..3f6c8b0d7 100644 --- a/source/common/textures/formats/tgatexture.cpp +++ b/source/common/textures/formats/tgatexture.cpp @@ -153,7 +153,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe { b&=~128; lump.Read(data, bytesperpixel); - for (int i=MIN(Size, (b+1)); i>0; i--) + for (int i=min(Size, (b+1)); i>0; i--) { buffer[0] = data[0]; if (bytesperpixel>=2) buffer[1] = data[1]; @@ -164,7 +164,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe } else { - lump.Read(buffer, MIN(Size, (b+1))*bytesperpixel); + lump.Read(buffer, min(Size, (b+1))*bytesperpixel); buffer += (b+1)*bytesperpixel; } Size -= b+1; diff --git a/source/common/textures/m_png.cpp b/source/common/textures/m_png.cpp index e58742da4..8467a5d42 100644 --- a/source/common/textures/m_png.cpp +++ b/source/common/textures/m_png.cpp @@ -246,7 +246,7 @@ bool M_AppendPNGText (FileWriter *file, const char *keyword, const char *text) { struct { uint32_t len, id; char key[80]; } head; int len = (int)strlen (text); - int keylen = std::min ((int)strlen (keyword), 79); + int keylen = min ((int)strlen (keyword), 79); uint32_t crc; head.len = BigLong(len + keylen + 1); @@ -329,7 +329,7 @@ char *M_GetPNGText (PNGHandle *png, const char *keyword) if (strncmp (keyword, png->TextChunks[i], 80) == 0) { // Woo! A match was found! - keylen = std::min (80, strlen (keyword) + 1); + keylen = min (80, strlen (keyword) + 1); textlen = strlen (png->TextChunks[i] + keylen) + 1; char *str = new char[textlen]; strcpy (str, png->TextChunks[i] + keylen); @@ -351,7 +351,7 @@ bool M_GetPNGText (PNGHandle *png, const char *keyword, char *buffer, size_t buf if (strncmp (keyword, png->TextChunks[i], 80) == 0) { // Woo! A match was found! - keylen = std::min (80, strlen (keyword) + 1); + keylen = min (80, strlen (keyword) + 1); strncpy (buffer, png->TextChunks[i] + keylen, buffsize); return true; } @@ -566,7 +566,7 @@ bool M_ReadIDAT (FileReader &file, uint8_t *buffer, int width, int height, int p if (stream.avail_in == 0 && chunklen > 0) { stream.next_in = chunkbuffer; - stream.avail_in = (uInt)file.Read (chunkbuffer, std::min(chunklen,sizeof(chunkbuffer))); + stream.avail_in = (uInt)file.Read (chunkbuffer, min(chunklen,sizeof(chunkbuffer))); chunklen -= stream.avail_in; } diff --git a/source/common/thirdparty/earcut.hpp b/source/common/thirdparty/earcut.hpp index e01a09102..e6dba7a38 100644 --- a/source/common/thirdparty/earcut.hpp +++ b/source/common/thirdparty/earcut.hpp @@ -184,8 +184,8 @@ void Earcut::operator()(const Polygon& points) { do { x = p->x; y = p->y; - minX = std::min(minX, x); - minY = std::min(minY, y); + minX = min(minX, x); + minY = min(minY, y); maxX = max(maxX, x); maxY = max(maxY, y); p = p->next; @@ -350,8 +350,8 @@ bool Earcut::isEarHashed(Node* ear) { if (area(a, b, c) >= 0) return false; // reflex, can't be an ear // triangle bbox; min & max are calculated like this for speed - const double minTX = std::min(a->x, std::min(b->x, c->x)); - const double minTY = std::min(a->y, std::min(b->y, c->y)); + const double minTX = min(a->x, min(b->x, c->x)); + const double minTY = min(a->y, min(b->y, c->y)); const double maxTX = max(a->x, max(b->x, c->x)); const double maxTY = max(a->y, max(b->y, c->y)); @@ -718,9 +718,9 @@ bool Earcut::intersects(const Node* p1, const Node* q1, const Node* p2, const template bool Earcut::onSegment(const Node* p, const Node* q, const Node* r) { return q->x <= max(p->x, r->x) && - q->x >= std::min(p->x, r->x) && + q->x >= min(p->x, r->x) && q->y <= max(p->y, r->y) && - q->y >= std::min(p->y, r->y); + q->y >= min(p->y, r->y); } template diff --git a/source/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp b/source/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp index c981d35a6..080635177 100644 --- a/source/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp +++ b/source/common/thirdparty/libsmackerdec/src/SmackerDecoder.cpp @@ -1144,7 +1144,7 @@ uint32_t SmackerDecoder::GetAudioData(uint32_t trackIndex, int16_t *audioBuffer) SmackerAudioTrack *track = &audioTracks[trackIndex]; if (track->bytesReadThisFrame) { - memcpy(audioBuffer, track->buffer, std::min(track->bufferSize, track->bytesReadThisFrame)); + memcpy(audioBuffer, track->buffer, min(track->bufferSize, track->bytesReadThisFrame)); } return track->bytesReadThisFrame; diff --git a/source/common/utility/cmdlib.cpp b/source/common/utility/cmdlib.cpp index 9551cbf42..38b502822 100644 --- a/source/common/utility/cmdlib.cpp +++ b/source/common/utility/cmdlib.cpp @@ -1060,7 +1060,7 @@ void md5Update(FileReader& file, MD5Context& md5, unsigned len) while (len > 0) { - t = std::min(len, sizeof(readbuf)); + t = min(len, sizeof(readbuf)); len -= t; t = (long)file.Read(readbuf, t); md5.Update(readbuf, t); diff --git a/source/common/utility/files_decompress.cpp b/source/common/utility/files_decompress.cpp index c79d762e6..275076876 100644 --- a/source/common/utility/files_decompress.cpp +++ b/source/common/utility/files_decompress.cpp @@ -509,7 +509,7 @@ class DecompressorLZSS : public DecompressorBase // Partial overlap: Copy in 2 or 3 chunks. do { - unsigned int copy = std::min(len, pos+1); + unsigned int copy = min(len, pos+1); memcpy(Stream.InternalBuffer, copyStart, copy); Stream.InternalBuffer += copy; Stream.InternalOut += copy; @@ -575,7 +575,7 @@ public: break; } - unsigned int copy = std::min(Stream.InternalOut, AvailOut); + unsigned int copy = min(Stream.InternalOut, AvailOut); if(copy > 0) { memcpy(Out, Stream.WindowData, copy); diff --git a/source/common/utility/palette.cpp b/source/common/utility/palette.cpp index 037535689..e1869562c 100644 --- a/source/common/utility/palette.cpp +++ b/source/common/utility/palette.cpp @@ -802,9 +802,9 @@ void UpdateSpecialColormap(PalEntry* BaseColors, unsigned int index, float r1, f BaseColors[c].g * 143 + BaseColors[c].b * 37) / 256.0; - PalEntry pe = PalEntry(std::min(255, int(r1 + intensity * r2)), - std::min(255, int(g1 + intensity * g2)), - std::min(255, int(b1 + intensity * b2))); + PalEntry pe = PalEntry(min(255, int(r1 + intensity * r2)), + min(255, int(g1 + intensity * g2)), + min(255, int(b1 + intensity * b2))); cm->Colormap[c] = BestColor((uint32_t*)BaseColors, pe.r, pe.g, pe.b); } @@ -813,9 +813,9 @@ void UpdateSpecialColormap(PalEntry* BaseColors, unsigned int index, float r1, f // This table is used by the texture composition code for (int i = 0; i < 256; i++) { - cm->GrayscaleToColor[i] = PalEntry(std::min(255, int(r1 + i * r2)), - std::min(255, int(g1 + i * g2)), - std::min(255, int(b1 + i * b2))); + cm->GrayscaleToColor[i] = PalEntry(min(255, int(r1 + i * r2)), + min(255, int(g1 + i * g2)), + min(255, int(b1 + i * b2))); } } @@ -911,7 +911,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer) fr.Seek(len, FileReader::SeekCur); else { - int PaletteSize = MIN(len, 768); + int PaletteSize = min(len, 768); fr.Read(buffer, PaletteSize); return PaletteSize / 3; } @@ -930,7 +930,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer) sc.MustGetString(); sc.MustGetNumber(); // version - ignore sc.MustGetNumber(); - int colors = MIN(256, sc.Number) * 3; + int colors = min(256, sc.Number) * 3; for (int i = 0; i < colors; i++) { sc.MustGetNumber(); @@ -944,7 +944,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer) } else { - memcpy(buffer, lumpmem, MIN(768, lump.GetSize())); + memcpy(buffer, lumpmem, min(768, lump.GetSize())); return 256; } } diff --git a/source/common/utility/templates.h b/source/common/utility/templates.h index 56cf80c7d..22b9f3d3f 100644 --- a/source/common/utility/templates.h +++ b/source/common/utility/templates.h @@ -93,23 +93,5 @@ const ClassType *BinarySearch (const ClassType *first, int max, return NULL; } -//========================================================================== -// -// MIN -// -// Returns the minimum of a and b. -//========================================================================== - -#ifdef MIN -#undef MIN -#endif - -template -inline -const T MIN (const T a, const T b) -{ - return a < b ? a : b; -} - #endif //__TEMPLATES_H__ diff --git a/source/core/gamecontrol.cpp b/source/core/gamecontrol.cpp index 757190555..94137dac7 100644 --- a/source/core/gamecontrol.cpp +++ b/source/core/gamecontrol.cpp @@ -1524,7 +1524,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetViewWindow) if (numret > 1) ret[1].SetInt(windowxy1.y); if (numret > 2) ret[2].SetInt(windowxy2.x - windowxy1.x + 1); if (numret > 3) ret[3].SetInt(windowxy2.y - windowxy1.y + 1); - return MIN(numret, 4); + return min(numret, 4); } DEFINE_ACTION_FUNCTION_NATIVE(_Raze, ShadeToLight, shadeToLight) diff --git a/source/core/mainloop.cpp b/source/core/mainloop.cpp index 4011c4952..bef3ff5e4 100644 --- a/source/core/mainloop.cpp +++ b/source/core/mainloop.cpp @@ -490,7 +490,7 @@ static void TicStabilityEnd() { using namespace std::chrono; uint64_t stabilityendtime = duration_cast(steady_clock::now().time_since_epoch()).count(); - stabilityticduration = std::min(stabilityendtime - stabilitystarttime, (uint64_t)1'000'000); + stabilityticduration = min(stabilityendtime - stabilitystarttime, (uint64_t)1'000'000); } //========================================================================== diff --git a/source/core/nodebuilder/nodebuild.cpp b/source/core/nodebuilder/nodebuild.cpp index 7b05ece87..26cb203dd 100644 --- a/source/core/nodebuilder/nodebuild.cpp +++ b/source/core/nodebuilder/nodebuild.cpp @@ -142,8 +142,8 @@ int FNodeBuilder::CreateNode (uint32_t set, unsigned int count, fixed_t bbox[4]) node.intchildren[0] = CreateNode (set1, count1, node.nb_bbox[0]); node.intchildren[1] = CreateNode (set2, count2, node.nb_bbox[1]); bbox[BOXTOP] = max(node.nb_bbox[0][BOXTOP], node.nb_bbox[1][BOXTOP]); - bbox[BOXBOTTOM] = MIN (node.nb_bbox[0][BOXBOTTOM], node.nb_bbox[1][BOXBOTTOM]); - bbox[BOXLEFT] = MIN (node.nb_bbox[0][BOXLEFT], node.nb_bbox[1][BOXLEFT]); + bbox[BOXBOTTOM] = min(node.nb_bbox[0][BOXBOTTOM], node.nb_bbox[1][BOXBOTTOM]); + bbox[BOXLEFT] = min(node.nb_bbox[0][BOXLEFT], node.nb_bbox[1][BOXLEFT]); bbox[BOXRIGHT] = max(node.nb_bbox[0][BOXRIGHT], node.nb_bbox[1][BOXRIGHT]); return (int)Nodes.Push (node); } diff --git a/source/core/nodebuilder/nodebuild_utility.cpp b/source/core/nodebuilder/nodebuild_utility.cpp index 29bb3d181..dbfe961a2 100644 --- a/source/core/nodebuilder/nodebuild_utility.cpp +++ b/source/core/nodebuilder/nodebuild_utility.cpp @@ -451,9 +451,9 @@ int FNodeBuilder::FVertexMap::InsertVertex (FNodeBuilder::FPrivVert &vert) // both sides of the boundary so that SelectVertexClose can find // it by checking in only one block. fixed64_t minx = max(MinX, fixed64_t(vert.x) - VERTEX_EPSILON); - fixed64_t maxx = MIN (MaxX, fixed64_t(vert.x) + VERTEX_EPSILON); + fixed64_t maxx = min(MaxX, fixed64_t(vert.x) + VERTEX_EPSILON); fixed64_t miny = max(MinY, fixed64_t(vert.y) - VERTEX_EPSILON); - fixed64_t maxy = MIN (MaxY, fixed64_t(vert.y) + VERTEX_EPSILON); + fixed64_t maxy = min(MaxY, fixed64_t(vert.y) + VERTEX_EPSILON); int blk[4] = { diff --git a/source/core/rendering/scene/hw_portal.h b/source/core/rendering/scene/hw_portal.h index ffe5c9494..8bbc65c92 100644 --- a/source/core/rendering/scene/hw_portal.h +++ b/source/core/rendering/scene/hw_portal.h @@ -96,8 +96,8 @@ struct BoundingRect double distanceTo(const BoundingRect& other) const { if (intersects(other)) return 0; - return max(std::min(fabs(left - other.right), fabs(right - other.left)), - std::min(fabs(top - other.bottom), fabs(bottom - other.top))); + return max(min(fabs(left - other.right), fabs(right - other.left)), + min(fabs(top - other.bottom), fabs(bottom - other.top))); } void addVertex(double x, double y) diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 074b61d1f..c6c9bf282 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -930,8 +930,8 @@ void HWWall::DoMidTexture(HWDrawInfo* di, walltype* wal, refheight = max(front->ceilingz, back->ceilingz); } - topleft = std::min(bch1,fch1); - topright = std::min(bch2,fch2); + topleft = min(bch1,fch1); + topright = min(bch2,fch2); bottomleft = max(bfh1,ffh1); bottomright = max(bfh2,ffh2); if (topleft<=bottomleft && topright<=bottomright) return; diff --git a/source/core/statusbar2.cpp b/source/core/statusbar2.cpp index c9c3f155c..8f10ed44e 100644 --- a/source/core/statusbar2.cpp +++ b/source/core/statusbar2.cpp @@ -109,7 +109,7 @@ void setViewport(int viewSize) reserved.top = xs_CRoundToInt((reserved.top * hud_scalefactor * ydim) / 200); reserved.statusbar = xs_CRoundToInt((reserved.statusbar * hud_scalefactor * ydim) / 200); - int xdimcorrect = std::min(Scale(ydim, 4, 3), xdim); + int xdimcorrect = min(Scale(ydim, 4, 3), xdim); if (viewSize > Hud_Stbar) { x0 = 0; diff --git a/source/games/blood/src/sound.cpp b/source/games/blood/src/sound.cpp index d3a626cb5..337261ac3 100644 --- a/source/games/blood/src/sound.cpp +++ b/source/games/blood/src/sound.cpp @@ -177,7 +177,7 @@ void sndStartSample(unsigned int nSound, int nVolume, int nChannel, bool bLoop, if (nVolume < 0) { auto udata = soundEngine->GetUserData(snd); - if (udata) nVolume = std::min(Scale(udata[2], 255, 100), 255); + if (udata) nVolume = min(Scale(udata[2], 255, 100), 255); else nVolume = 255; } if (bLoop) chanflags |= CHANF_LOOP; diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 12b1ee3a8..a76a37452 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -740,8 +740,8 @@ static void processVehicleInput(player_struct *p, ControlInfo* const hidInput, I if (p->OnBoat || !p->moto_underwater) { - p->vehForwardScale = std::min((buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe)) + hidInput->dz, 1.f); - p->vehReverseScale = std::min(buttonMap.ButtonDown(gamefunc_Move_Backward) + -hidInput->dz, 1.f); + p->vehForwardScale = min((buttonMap.ButtonDown(gamefunc_Move_Forward) || buttonMap.ButtonDown(gamefunc_Strafe)) + hidInput->dz, 1.f); + p->vehReverseScale = min(buttonMap.ButtonDown(gamefunc_Move_Backward) + -hidInput->dz, 1.f); p->vehBraking = buttonMap.ButtonDown(gamefunc_Run); } diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index e410615a6..2ab4edd2b 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -242,7 +242,7 @@ void resetplayerstats(int snum) if (numplayers < 2) { - ufospawn = isRRRA()? 3 : std::min(ud.player_skill*4+1, 32); + ufospawn = isRRRA()? 3 : min(ud.player_skill*4+1, 32); ufocnt = 0; hulkspawn = ud.player_skill + 1; } @@ -278,7 +278,7 @@ void resetweapons(int snum) p->curr_weapon = PISTOL_WEAPON; p->gotweapon[PISTOL_WEAPON] = true; p->gotweapon[KNEE_WEAPON] = true; - p->ammo_amount[PISTOL_WEAPON] = std::min(gs.max_ammo_amount[PISTOL_WEAPON], 48); + p->ammo_amount[PISTOL_WEAPON] = min(gs.max_ammo_amount[PISTOL_WEAPON], 48); p->gotweapon[HANDREMOTE_WEAPON] = true; p->last_weapon = -1; @@ -362,7 +362,7 @@ void resetinventory(int snum) if (numplayers < 2) { - ufospawn = std::min(ud.player_skill*4+1, 32); + ufospawn = min(ud.player_skill*4+1, 32); ufocnt = 0; hulkspawn = ud.player_skill + 1; } @@ -479,7 +479,7 @@ void resetprestat(int snum,int g) if (numplayers < 2) { - ufospawn = std::min(ud.player_skill*4+1, 32); + ufospawn = min(ud.player_skill*4+1, 32); ufocnt = 0; hulkspawn = ud.player_skill + 1; } diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index a2dc698cf..844e63ce3 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -39,7 +39,6 @@ source as it is released. #include "dukeactor.h" #include "interpolate.h" -using std::min; // PRIMITIVE BEGIN_DUKE_NS diff --git a/source/games/exhumed/src/gun.cpp b/source/games/exhumed/src/gun.cpp index bd7420cdb..2414f3735 100644 --- a/source/games/exhumed/src/gun.cpp +++ b/source/games/exhumed/src/gun.cpp @@ -442,7 +442,7 @@ void MoveWeapons(short nPlayer) PlayerList[nPlayer].field_3A = 3; PlayerList[nPlayer].field_3FOUR = 0; - PlayerList[nPlayer].nPistolClip = std::min(6, PlayerList[nPlayer].nAmmo[kWeaponPistol]); + PlayerList[nPlayer].nPistolClip = min(6, PlayerList[nPlayer].nAmmo[kWeaponPistol]); break; } else if (nWeapon == kWeaponGrenade) diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 1f5436beb..f84b4c6f3 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -663,7 +663,7 @@ void MoveSectorSprites(int nSector, int z) { int newz = sector[nSector].floorz; int oldz = newz - z; - int minz = std::min(newz, oldz); + int minz = min(newz, oldz); int maxz = max(newz, oldz); ExhumedSectIterator it(nSector); while (auto pActor = it.Next()) diff --git a/source/glbackend/glbackend.cpp b/source/glbackend/glbackend.cpp index 8b87857f2..1bb967363 100644 --- a/source/glbackend/glbackend.cpp +++ b/source/glbackend/glbackend.cpp @@ -165,7 +165,7 @@ void GLInstance::SetShade(int32_t shade, int numshades) // Ugh... This particular palette does not fade to black. Should be handled better. // It's really too bad that everything runs through here without being able to identify it anymore. renderState.drawblack = (!(g_gameType & GAMEFLAG_PSEXHUMED) || globalpal != 4) ? shade > numshades : false; - renderState.Shade = std::min(shade, numshades - 1); + renderState.Shade = min(shade, numshades - 1); } bool PolymostRenderState::Apply(FRenderState& state, GLState& oldState)