From 9894729fc22eb21a7b0e3217e1baf9ca05153f0d Mon Sep 17 00:00:00 2001 From: Mitch Richters Date: Sat, 30 Oct 2021 19:15:01 +1100 Subject: [PATCH] - Replace `MAX()` from `templates.h` with version provided in STL. # Conflicts: # source/common/textures/hw_ihwtexture.cpp # source/common/utility/templates.h --- source/build/src/polymost.cpp | 2 +- source/common/2d/v_draw.cpp | 8 ++++---- source/common/audio/sound/oalsound.cpp | 12 ++++++------ source/common/audio/sound/s_sound.cpp | 4 ++-- source/common/console/c_commandbuffer.cpp | 2 +- source/common/console/c_console.cpp | 2 +- source/common/console/c_dispatch.cpp | 2 +- source/common/console/c_tabcomplete.cpp | 2 +- source/common/cutscenes/movieplayer.cpp | 2 +- source/common/fonts/font.cpp | 2 +- source/common/objects/dobjgc.cpp | 6 +++--- source/common/platform/posix/i_system.h | 2 +- source/common/platform/win32/i_system.cpp | 2 +- source/common/platform/win32/st_start_util.cpp | 2 +- .../postprocessing/hw_postprocess.cpp | 16 ++++++++-------- .../polyrenderer/drawers/poly_thread.cpp | 10 +++++----- .../polyrenderer/drawers/poly_thread.h | 4 ++-- .../polyrenderer/drawers/screen_blend.cpp | 8 ++++---- .../drawers/screen_scanline_setup.cpp | 4 ++-- .../polyrenderer/drawers/screen_shader.cpp | 4 ++-- .../polyrenderer/drawers/screen_triangle.cpp | 4 ++-- source/common/rendering/r_thread.h | 4 ++-- source/common/rendering/r_videoscale.cpp | 4 ++-- source/common/rendering/v_video.cpp | 6 +++--- .../vulkan/renderer/vk_renderstate.cpp | 2 +- .../rendering/vulkan/system/vk_buffers.cpp | 8 ++++---- .../rendering/vulkan/system/vk_builders.h | 2 +- .../rendering/vulkan/system/vk_framebuffer.cpp | 2 +- .../rendering/vulkan/system/vk_swapchain.cpp | 4 ++-- .../rendering/vulkan/textures/vk_hwtexture.cpp | 6 +++--- .../vulkan/textures/vk_imagetransition.cpp | 4 ++-- .../thirdparty/vk_mem_alloc/vk_mem_alloc.h | 4 ++-- source/common/scripting/backend/codegen.cpp | 2 +- source/common/scripting/core/symbols.cpp | 2 +- source/common/scripting/core/vmdisasm.cpp | 2 +- source/common/scripting/jit/jit_runtime.cpp | 2 +- source/common/scripting/vm/vmframe.cpp | 2 +- source/common/statusbar/base_sbar.cpp | 10 +++++----- source/common/textures/bitmap.h | 6 +++--- source/common/textures/hw_ihwtexture.cpp | 4 ++-- source/common/textures/texture.cpp | 2 +- source/common/thirdparty/earcut.hpp | 16 ++++++++-------- source/common/utility/palette.cpp | 2 +- source/common/utility/templates.h | 18 ------------------ source/core/d_net.cpp | 12 ++++++------ source/core/nodebuilder/nodebuild.cpp | 6 +++--- source/core/nodebuilder/nodebuild_utility.cpp | 4 ++-- source/core/palette.cpp | 4 ++-- source/core/rendering/scene/hw_portal.h | 2 +- source/core/rendering/scene/hw_walls.cpp | 4 ++-- source/games/duke/src/sectors.cpp | 1 - source/games/exhumed/src/object.cpp | 2 +- 52 files changed, 115 insertions(+), 134 deletions(-) diff --git a/source/build/src/polymost.cpp b/source/build/src/polymost.cpp index e20f47bf9..bfb409227 100644 --- a/source/build/src/polymost.cpp +++ b/source/build/src/polymost.cpp @@ -3894,7 +3894,7 @@ int32_t polymost_voxdraw(voxmodel_t* m, tspriteptr_t const tspr, bool rotate) GLInterface.EnableBlend(true); // else GLInterface.EnableBlend(false); } else pc[3] = 1.f; - GLInterface.SetShade(std::max(0, globalshade), numshades); + GLInterface.SetShade(max(0, globalshade), numshades); //------------ //transform to Build coords diff --git a/source/common/2d/v_draw.cpp b/source/common/2d/v_draw.cpp index a0438ad13..95ae345e6 100644 --- a/source/common/2d/v_draw.cpp +++ b/source/common/2d/v_draw.cpp @@ -151,8 +151,8 @@ int GetUIScale(F2DDrawer *drawer, int altval) // block scales that result in something larger than the current screen. int vmax = drawer->GetHeight() / 200; int hmax = drawer->GetWidth() / 320; - int max = MAX(vmax, hmax); - return MAX(1,MIN(scaleval, max)); + int max = std::max(vmax, hmax); + return std::max(1,MIN(scaleval, max)); } // The new console font is twice as high, so the scaling calculation must factor that in. @@ -172,8 +172,8 @@ int GetConScale(F2DDrawer* drawer, int altval) // block scales that result in something larger than the current screen. int vmax = drawer->GetHeight() / 400; int hmax = drawer->GetWidth() / 640; - int max = MAX(vmax, hmax); - return MAX(1, MIN(scaleval, max)); + int max = std::max(vmax, hmax); + return std::max(1, MIN(scaleval, max)); } diff --git a/source/common/audio/sound/oalsound.cpp b/source/common/audio/sound/oalsound.cpp index 252688572..3d506099f 100644 --- a/source/common/audio/sound/oalsound.cpp +++ b/source/common/audio/sound/oalsound.cpp @@ -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(snd_channels, 2) - 1); + attribs.Push(max(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(snd_channels, 2); + const int numChannels = max(snd_channels, 2); int numSources = numMono + numStereo; if (0 == numSources) @@ -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(gain*dist, 0.0004f)); + alSourcef(source, AL_REFERENCE_DISTANCE, max(gain*dist, 0.0004f)); alSourcef(source, AL_MAX_DISTANCE, std::numeric_limits::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(gain*dist, 0.0004f)); + alSourcef(source, AL_REFERENCE_DISTANCE, max(gain*dist, 0.0004f)); } alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE); diff --git a/source/common/audio/sound/s_sound.cpp b/source/common/audio/sound/s_sound.cpp index f6acbb885..c50c266be 100644 --- a/source/common/audio/sound/s_sound.cpp +++ b/source/common/audio/sound/s_sound.cpp @@ -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)); } //========================================================================== diff --git a/source/common/console/c_commandbuffer.cpp b/source/common/console/c_commandbuffer.cpp index bf459350f..b079d7f76 100644 --- a/source/common/console/c_commandbuffer.cpp +++ b/source/common/console/c_commandbuffer.cpp @@ -144,7 +144,7 @@ void FCommandBuffer::MakeStartPosGood() { // The cursor is in front of the visible part of the line n = CursorPosCells; } - StartPosCells = std::max(0, n); + StartPosCells = max(0, n); bool overflow; StartPos = CharsForCells(StartPosCells, &overflow); if (overflow) diff --git a/source/common/console/c_console.cpp b/source/common/console/c_console.cpp index 5cafbb080..4a3abb172 100644 --- a/source/common/console/c_console.cpp +++ b/source/common/console/c_console.cpp @@ -856,7 +856,7 @@ static bool C_HandleKey (event_t *ev, FCommandBuffer &buffer) { // Scroll console buffer down if (ev->subtype == EV_GUI_WheelDown) { - RowAdjust = std::max (0, RowAdjust - 3); + RowAdjust = max (0, RowAdjust - 3); } else { diff --git a/source/common/console/c_dispatch.cpp b/source/common/console/c_dispatch.cpp index ce9f2cef7..c63449221 100644 --- a/source/common/console/c_dispatch.cpp +++ b/source/common/console/c_dispatch.cpp @@ -1092,7 +1092,7 @@ void C_SearchForPullins(FExecList *exec, const char *file, FCommandLine &argv) lastSlash1 = strrchr(file, '/'); lastSlash2 = strrchr(file, '\\'); - lastSlash = MAX(lastSlash1, lastSlash2); + lastSlash = max(lastSlash1, lastSlash2); #endif for (int i = 1; i < argv.argc(); ++i) diff --git a/source/common/console/c_tabcomplete.cpp b/source/common/console/c_tabcomplete.cpp index ca8339062..eccd64b03 100644 --- a/source/common/console/c_tabcomplete.cpp +++ b/source/common/console/c_tabcomplete.cpp @@ -273,7 +273,7 @@ bool C_TabCompleteList () } } nummatches++; - maxwidth = std::max (maxwidth, strlen (TabCommands[i].TabName.GetChars())); + maxwidth = max (maxwidth, strlen (TabCommands[i].TabName.GetChars())); } } if (nummatches > 1) diff --git a/source/common/cutscenes/movieplayer.cpp b/source/common/cutscenes/movieplayer.cpp index e69773695..04cf6a2ca 100644 --- a/source/common/cutscenes/movieplayer.cpp +++ b/source/common/cutscenes/movieplayer.cpp @@ -562,7 +562,7 @@ public: } flags = flags_; Smacker_GetFrameSize(hSMK, nWidth, nHeight); - pFrame.Resize(nWidth * nHeight + std::max(nWidth, nHeight)); + pFrame.Resize(nWidth * nHeight + max(nWidth, nHeight)); float frameRate = Smacker_GetFrameRate(hSMK); nFrameNs = uint64_t(1'000'000'000 / frameRate); nFrames = Smacker_GetNumFrames(hSMK); diff --git a/source/common/fonts/font.cpp b/source/common/fonts/font.cpp index 5edd09eb1..0e1a2d3fb 100644 --- a/source/common/fonts/font.cpp +++ b/source/common/fonts/font.cpp @@ -936,7 +936,7 @@ int FFont::StringWidth(const uint8_t *string, int spacing) const } } - return std::max(maxw, w); + return max(maxw, w); } //========================================================================== diff --git a/source/common/objects/dobjgc.cpp b/source/common/objects/dobjgc.cpp index 58b27c4b7..8270286ef 100644 --- a/source/common/objects/dobjgc.cpp +++ b/source/common/objects/dobjgc.cpp @@ -348,7 +348,7 @@ static size_t SingleStep() State = GCS_Finalize; } //assert(old >= AllocBytes); - Estimate -= MAX(0, old - AllocBytes); + Estimate -= max(0, old - AllocBytes); return (GCSWEEPMAX - finalize_count) * GCSWEEPCOST + finalize_count * GCFINALIZECOST; } @@ -625,7 +625,7 @@ CCMD(gc) } else { - GC::Pause = MAX(1,atoi(argv[2])); + GC::Pause = max(1,atoi(argv[2])); } } else if (stricmp(argv[1], "stepmul") == 0) @@ -636,7 +636,7 @@ CCMD(gc) } else { - GC::StepMul = MAX(100, atoi(argv[2])); + GC::StepMul = max(100, atoi(argv[2])); } } } diff --git a/source/common/platform/posix/i_system.h b/source/common/platform/posix/i_system.h index b73261eaf..a64703ee2 100644 --- a/source/common/platform/posix/i_system.h +++ b/source/common/platform/posix/i_system.h @@ -66,7 +66,7 @@ static inline char *strlwr(char *str) } inline int I_GetNumaNodeCount() { return 1; } -inline int I_GetNumaNodeThreadCount(int numaNode) { return std::max(std::thread::hardware_concurrency(), 1); } +inline int I_GetNumaNodeThreadCount(int numaNode) { return max(std::thread::hardware_concurrency(), 1); } inline void I_SetThreadNumaNode(std::thread &thread, int numaNode) { } #endif diff --git a/source/common/platform/win32/i_system.cpp b/source/common/platform/win32/i_system.cpp index 103b26f31..e67f1c8a5 100644 --- a/source/common/platform/win32/i_system.cpp +++ b/source/common/platform/win32/i_system.cpp @@ -778,7 +778,7 @@ static HCURSOR CreateAlphaCursor(FBitmap &source, int leftofs, int topofs) // Find closest integer scale factor for the monitor DPI HDC screenDC = GetDC(0); int dpi = GetDeviceCaps(screenDC, LOGPIXELSX); - int scale = std::max((dpi + 96 / 2 - 1) / 96, 1); + int scale = max((dpi + 96 / 2 - 1) / 96, 1); ReleaseDC(0, screenDC); memset(&bi, 0, sizeof(bi)); diff --git a/source/common/platform/win32/st_start_util.cpp b/source/common/platform/win32/st_start_util.cpp index 8c6074863..bfad11662 100644 --- a/source/common/platform/win32/st_start_util.cpp +++ b/source/common/platform/win32/st_start_util.cpp @@ -831,7 +831,7 @@ void FStrifeStartupScreen::DrawStuff(int old_laser, int new_laser) ST_LASERSPACE_X + new_laser, ST_LASERSPACE_Y, ST_LASER_WIDTH, ST_LASER_HEIGHT); // The bot jumps up and down like crazy. - y = std::max(0, (new_laser >> 1) % 5 - 2); + y = max(0, (new_laser >> 1) % 5 - 2); if (y > 0) { ST_Util_ClearBlock(bitmap_info, 0xF0, ST_BOT_X, ST_BOT_Y, ST_BOT_WIDTH, y); diff --git a/source/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp b/source/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp index 219bb9bd6..2c6b262ab 100644 --- a/source/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp +++ b/source/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp @@ -326,9 +326,9 @@ void PPLensDistort::Render(PPRenderState *renderstate) // Scale factor to keep sampling within the input texture float r2 = aspect * aspect * 0.25f + 0.25f; float sqrt_r2 = sqrt(r2); - float f0 = 1.0f + MAX(r2 * (k[0] + kcube[0] * sqrt_r2), 0.0f); - float f2 = 1.0f + MAX(r2 * (k[2] + kcube[2] * sqrt_r2), 0.0f); - float f = MAX(f0, f2); + float f0 = 1.0f + max(r2 * (k[0] + kcube[0] * sqrt_r2), 0.0f); + float f2 = 1.0f + max(r2 * (k[2] + kcube[2] * sqrt_r2), 0.0f); + float f = max(f0, f2); float scale = 1.0f / f; LensUniforms uniforms; @@ -498,8 +498,8 @@ void PPCameraExposure::Render(PPRenderState *renderstate, int sceneWidth, int sc void PPCameraExposure::UpdateTextures(int width, int height) { - int firstwidth = MAX(width / 2, 1); - int firstheight = MAX(height / 2, 1); + int firstwidth = max(width / 2, 1); + int firstheight = max(height / 2, 1); if (ExposureLevels.size() > 0 && ExposureLevels[0].Viewport.width == firstwidth && ExposureLevels[0].Viewport.height == firstheight) { @@ -511,8 +511,8 @@ void PPCameraExposure::UpdateTextures(int width, int height) int i = 0; do { - width = MAX(width / 2, 1); - height = MAX(height / 2, 1); + width = max(width / 2, 1); + height = max(height / 2, 1); PPExposureLevel blevel; blevel.Viewport.left = 0; @@ -746,7 +746,7 @@ void PPAmbientOcclusion::Render(PPRenderState *renderstate, float m5, int sceneW LinearDepthUniforms linearUniforms; linearUniforms.SampleIndex = 0; linearUniforms.LinearizeDepthA = 1.0f / screen->GetZFar() - 1.0f / screen->GetZNear(); - linearUniforms.LinearizeDepthB = MAX(1.0f / screen->GetZNear(), 1.e-8f); + linearUniforms.LinearizeDepthB = max(1.0f / screen->GetZNear(), 1.e-8f); linearUniforms.InverseDepthRangeA = 1.0f; linearUniforms.InverseDepthRangeB = 0.0f; linearUniforms.Scale = sceneScale; diff --git a/source/common/rendering/polyrenderer/drawers/poly_thread.cpp b/source/common/rendering/polyrenderer/drawers/poly_thread.cpp index 338b12139..cd622159e 100644 --- a/source/common/rendering/polyrenderer/drawers/poly_thread.cpp +++ b/source/common/rendering/polyrenderer/drawers/poly_thread.cpp @@ -100,8 +100,8 @@ void PolyTriangleThreadData::SetScissor(int x, int y, int w, int h) void PolyTriangleThreadData::UpdateClip() { - clip.left = MAX(MAX(viewport_x, scissor.left), 0); - clip.top = MAX(MAX(viewport_y, scissor.top), 0); + 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); } @@ -210,7 +210,7 @@ void PolyTriangleThreadData::SetStencil(int stencilRef, int op) } else if (op == SOP_Decrement) { - StencilWriteValue = MAX(stencilRef - 1, (int)0); + StencilWriteValue = max(stencilRef - 1, (int)0); } else // SOP_Keep { @@ -453,7 +453,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 (clipdistance1 < 0.0f) t1 = max(-clipdistance1 / (clipdistance2 - clipdistance1), t1); if (clipdistance2 < 0.0f) t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); if (t1 >= t2) return; @@ -792,7 +792,7 @@ int PolyTriangleThreadData::ClipEdge(const ShadedTriVertex *const* verts) // Clip halfspace 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 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; // add t1 vertex diff --git a/source/common/rendering/polyrenderer/drawers/poly_thread.h b/source/common/rendering/polyrenderer/drawers/poly_thread.h index 8d7b8bce6..89ab7d1e0 100644 --- a/source/common/rendering/polyrenderer/drawers/poly_thread.h +++ b/source/common/rendering/polyrenderer/drawers/poly_thread.h @@ -85,7 +85,7 @@ public: int skipped_by_thread(int first_line) { - int clip_first_line = MAX(first_line, numa_start_y); + int clip_first_line = max(first_line, numa_start_y); int core_skip = (num_cores - (clip_first_line - core) % num_cores) % num_cores; return clip_first_line + core_skip - first_line; } @@ -94,7 +94,7 @@ public: { 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); + return max(c, 0); } struct Scanline diff --git a/source/common/rendering/polyrenderer/drawers/screen_blend.cpp b/source/common/rendering/polyrenderer/drawers/screen_blend.cpp index afe540289..0bd7396e0 100644 --- a/source/common/rendering/polyrenderer/drawers/screen_blend.cpp +++ b/source/common/rendering/polyrenderer/drawers/screen_blend.cpp @@ -514,10 +514,10 @@ void BlendColorRevSub_Src_One(int y, int x0, int x1, PolyTriangleThreadData* thr uint32_t srcscale = APART(src); srcscale += srcscale >> 7; - uint32_t a = MAX(APART(dst) - (((APART(src) * srcscale) + 127) >> 8), 0); - uint32_t r = MAX(RPART(dst) - (((RPART(src) * srcscale) + 127) >> 8), 0); - uint32_t g = MAX(GPART(dst) - (((GPART(src) * srcscale) + 127) >> 8), 0); - uint32_t b = MAX(BPART(dst) - (((BPART(src) * srcscale) + 127) >> 8), 0); + uint32_t a = max(APART(dst) - (((APART(src) * srcscale) + 127) >> 8), 0); + uint32_t r = max(RPART(dst) - (((RPART(src) * srcscale) + 127) >> 8), 0); + uint32_t g = max(GPART(dst) - (((GPART(src) * srcscale) + 127) >> 8), 0); + uint32_t b = max(BPART(dst) - (((BPART(src) * srcscale) + 127) >> 8), 0); 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 5aa4855d6..f5a2e4216 100644 --- a/source/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp +++ b/source/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp @@ -202,7 +202,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread) Ly *= rcp_dist; Lz *= rcp_dist; float dotNL = worldnormalX * Lx + worldnormalY * Ly + worldnormalZ * Lz; - float point_attenuation = MAX(dotNL, 0.0f) * distance_attenuation; + float point_attenuation = max(dotNL, 0.0f) * distance_attenuation; uint32_t attenuation = (uint32_t)(is_attenuated ? (int32_t)point_attenuation : (int32_t)simple_attenuation); @@ -327,7 +327,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar uint32_t g = thread->scanline.vColorG[x]; uint32_t b = thread->scanline.vColorB[x]; - float fogdist = MAX(16.0f, w[x]); + float fogdist = max(16.0f, w[x]); float fogfactor = std::exp2(constants->uFogDensity * fogdist); // brightening around the player for light mode 2: diff --git a/source/common/rendering/polyrenderer/drawers/screen_shader.cpp b/source/common/rendering/polyrenderer/drawers/screen_shader.cpp index 7e225bef1..09f9ffdf3 100644 --- a/source/common/rendering/polyrenderer/drawers/screen_shader.cpp +++ b/source/common/rendering/polyrenderer/drawers/screen_shader.cpp @@ -473,7 +473,7 @@ static void GetLightColor(int x0, int x1, PolyTriangleThreadData* thread) mulG += mulG >> 7; mulB += mulB >> 7; - float fogdist = MAX(16.0f, w[x]); + float fogdist = max(16.0f, w[x]); float fogfactor = std::exp2(uFogDensity * fogdist); uint32_t a = (APART(fg) * mulA + 127) >> 8; @@ -512,7 +512,7 @@ static void MainFP(int x0, int x1, PolyTriangleThreadData* thread) float fogfactor = 0.0f; if (constants->uFogEnabled != 0) { - fogdist = MAX(16.0f, w[x]); + fogdist = max(16.0f, w[x]); fogfactor = std::exp2(constants->uFogDensity * fogdist); } frag = vec4(uFogColor.rgb, (1.0 - fogfactor) * frag.a * 0.75 * vColor.a);*/ diff --git a/source/common/rendering/polyrenderer/drawers/screen_triangle.cpp b/source/common/rendering/polyrenderer/drawers/screen_triangle.cpp index 53c9afabe..545df6bd7 100644 --- a/source/common/rendering/polyrenderer/drawers/screen_triangle.cpp +++ b/source/common/rendering/polyrenderer/drawers/screen_triangle.cpp @@ -207,7 +207,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs* args, PolyTriangleThreadDat SortVertices(args, sortedVertices); int clipleft = thread->clip.left; - int cliptop = MAX(thread->clip.top, thread->numa_start_y); + 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); @@ -215,7 +215,7 @@ void ScreenTriangle::Draw(const TriDrawTriangleArgs* args, PolyTriangleThreadDat int midY = (int)(sortedVertices[1]->y + 0.5f); int bottomY = (int)(sortedVertices[2]->y + 0.5f); - topY = MAX(topY, cliptop); + topY = max(topY, cliptop); midY = MIN(midY, clipbottom); bottomY = MIN(bottomY, clipbottom); diff --git a/source/common/rendering/r_thread.h b/source/common/rendering/r_thread.h index 87319cf0c..439e9638f 100644 --- a/source/common/rendering/r_thread.h +++ b/source/common/rendering/r_thread.h @@ -78,7 +78,7 @@ public: // The number of lines to skip to reach the first line to be rendered by this thread int skipped_by_thread(int first_line) { - int clip_first_line = MAX(first_line, numa_start_y); + int clip_first_line = max(first_line, numa_start_y); int core_skip = (num_cores - (clip_first_line - core) % num_cores) % num_cores; return clip_first_line + core_skip - first_line; } @@ -88,7 +88,7 @@ public: { 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); + return max(c, 0); } // Calculate the dest address for the first line to be rendered by this thread diff --git a/source/common/rendering/r_videoscale.cpp b/source/common/rendering/r_videoscale.cpp index 1f5a7bb38..265003246 100644 --- a/source/common/rendering/r_videoscale.cpp +++ b/source/common/rendering/r_videoscale.cpp @@ -193,7 +193,7 @@ int ViewportScaledWidth(int width, int height) width = ((float)width/height > ActiveRatio(width, height)) ? (int)(height * ActiveRatio(width, height)) : width; height = ((float)width/height < ActiveRatio(width, height)) ? (int)(width / ActiveRatio(width, height)) : height; } - return (int)std::max((int32_t)min_width, (int32_t)(vid_scalefactor * vScaleTable[vid_scalemode].GetScaledWidth(width, height))); + return (int)max((int32_t)min_width, (int32_t)(vid_scalefactor * vScaleTable[vid_scalemode].GetScaledWidth(width, height))); } int ViewportScaledHeight(int width, int height) @@ -205,7 +205,7 @@ int ViewportScaledHeight(int width, int height) height = ((float)width/height < ActiveRatio(width, height)) ? (int)(width / ActiveRatio(width, height)) : height; width = ((float)width/height > ActiveRatio(width, height)) ? (int)(height * ActiveRatio(width, height)) : width; } - return (int)std::max((int32_t)min_height, (int32_t)(vid_scalefactor * vScaleTable[vid_scalemode].GetScaledHeight(width, height))); + return (int)max((int32_t)min_height, (int32_t)(vid_scalefactor * vScaleTable[vid_scalemode].GetScaledHeight(width, height))); } float ViewportPixelAspect() diff --git a/source/common/rendering/v_video.cpp b/source/common/rendering/v_video.cpp index 047894466..fe543b1a3 100644 --- a/source/common/rendering/v_video.cpp +++ b/source/common/rendering/v_video.cpp @@ -252,7 +252,7 @@ void DCanvas::Resize(int width, int height, bool optimizepitch) } else { - Pitch = width + MAX(0, CPU.DataL1LineSize - 8); + Pitch = width + max(0, CPU.DataL1LineSize - 8); } } int bytes_per_pixel = Bgra ? 4 : 1; @@ -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 = std::max(std::min(screen->GetWidth() / 400, screen->GetHeight() / 240), 1); + CleanXfac = max(std::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; @@ -292,7 +292,7 @@ void V_UpdateModeSize (int width, int height) else if (w < 1920) factor = 2; else factor = int(factor * 0.7); - CleanYfac_1 = CleanXfac_1 = factor;// MAX(1, int(factor * 0.7)); + CleanYfac_1 = CleanXfac_1 = factor;// max(1, int(factor * 0.7)); CleanWidth_1 = width / CleanXfac_1; CleanHeight_1 = height / CleanYfac_1; diff --git a/source/common/rendering/vulkan/renderer/vk_renderstate.cpp b/source/common/rendering/vulkan/renderer/vk_renderstate.cpp index a2df4a28e..c5ff77831 100644 --- a/source/common/rendering/vulkan/renderer/vk_renderstate.cpp +++ b/source/common/rendering/vulkan/renderer/vk_renderstate.cpp @@ -228,7 +228,7 @@ void VkRenderState::ApplyRenderPass(int dt) pipelineKey.ColorMask = mColorMask; pipelineKey.CullMode = mCullMode; pipelineKey.NumTextureLayers = mMaterial.mMaterial ? mMaterial.mMaterial->NumLayers() : 0; - pipelineKey.NumTextureLayers = std::max(pipelineKey.NumTextureLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS);// Always force minimum 8 textures as the shader requires it + pipelineKey.NumTextureLayers = max(pipelineKey.NumTextureLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS);// Always force minimum 8 textures as the shader requires it if (mSpecialEffect > EFF_NONE) { pipelineKey.SpecialEffect = mSpecialEffect; diff --git a/source/common/rendering/vulkan/system/vk_buffers.cpp b/source/common/rendering/vulkan/system/vk_buffers.cpp index ce1ac503d..420b19f87 100644 --- a/source/common/rendering/vulkan/system/vk_buffers.cpp +++ b/source/common/rendering/vulkan/system/vk_buffers.cpp @@ -73,7 +73,7 @@ void VKBuffer::SetData(size_t size, const void *data, BufferUsageType usage) { auto fb = GetVulkanFrameBuffer(); - size_t bufsize = std::max(size, (size_t)16); // For supporting zero byte buffers + size_t bufsize = max(size, (size_t)16); // For supporting zero byte buffers // If SetData is called multiple times we have to keep the old buffers alive as there might still be draw commands referencing them if (mBuffer) @@ -153,7 +153,7 @@ void VKBuffer::SetData(size_t size, const void *data, BufferUsageType usage) void VKBuffer::SetSubData(size_t offset, size_t size, const void *data) { - size = std::max(size, (size_t)16); // For supporting zero byte buffers + size = max(size, (size_t)16); // For supporting zero byte buffers auto fb = GetVulkanFrameBuffer(); if (mStaging) @@ -174,7 +174,7 @@ void VKBuffer::SetSubData(size_t offset, size_t size, const void *data) void VKBuffer::Resize(size_t newsize) { - newsize = std::max(newsize, (size_t)16); // For supporting zero byte buffers + newsize = max(newsize, (size_t)16); // For supporting zero byte buffers auto fb = GetVulkanFrameBuffer(); @@ -222,7 +222,7 @@ void VKBuffer::Unmap() void *VKBuffer::Lock(unsigned int size) { - size = std::max(size, (unsigned int)16); // For supporting zero byte buffers + size = max(size, (unsigned int)16); // For supporting zero byte buffers if (!mBuffer) { diff --git a/source/common/rendering/vulkan/system/vk_builders.h b/source/common/rendering/vulkan/system/vk_builders.h index af9cbc3eb..0b053e8d8 100644 --- a/source/common/rendering/vulkan/system/vk_builders.h +++ b/source/common/rendering/vulkan/system/vk_builders.h @@ -571,7 +571,7 @@ inline BufferBuilder::BufferBuilder() inline void BufferBuilder::setSize(size_t size) { - bufferInfo.size = std::max(size, (size_t)16); + bufferInfo.size = max(size, (size_t)16); } inline void BufferBuilder::setUsage(VkBufferUsageFlags bufferUsage, VmaMemoryUsage memoryUsage, VmaAllocationCreateFlags allocFlags) diff --git a/source/common/rendering/vulkan/system/vk_framebuffer.cpp b/source/common/rendering/vulkan/system/vk_framebuffer.cpp index 131a3e6fb..7052831ee 100644 --- a/source/common/rendering/vulkan/system/vk_framebuffer.cpp +++ b/source/common/rendering/vulkan/system/vk_framebuffer.cpp @@ -628,7 +628,7 @@ void VulkanFrameBuffer::UpdateGpuStats() if (q.endIndex <= q.startIndex) continue; - int64_t timeElapsed = std::max(static_cast(timestamps[q.endIndex] - timestamps[q.startIndex]), (int64_t)0); + int64_t timeElapsed = max(static_cast(timestamps[q.endIndex] - timestamps[q.startIndex]), (int64_t)0); double timeNS = timeElapsed * timestampPeriod; FString out; diff --git a/source/common/rendering/vulkan/system/vk_swapchain.cpp b/source/common/rendering/vulkan/system/vk_swapchain.cpp index dcacd1620..f3712894b 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 = std::max(surfaceCapabilities.minImageExtent.width, std::min(surfaceCapabilities.maxImageExtent.width, actualExtent.width)); - actualExtent.height = std::max(surfaceCapabilities.minImageExtent.height, std::min(surfaceCapabilities.maxImageExtent.height, actualExtent.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)); if (actualExtent.width == 0 || actualExtent.height == 0) { swapChain = VK_NULL_HANDLE; diff --git a/source/common/rendering/vulkan/textures/vk_hwtexture.cpp b/source/common/rendering/vulkan/textures/vk_hwtexture.cpp index dce6dcb6f..c62a7173e 100644 --- a/source/common/rendering/vulkan/textures/vk_hwtexture.cpp +++ b/source/common/rendering/vulkan/textures/vk_hwtexture.cpp @@ -218,8 +218,8 @@ int VkHardwareTexture::GetMipLevels(int w, int h) int levels = 1; while (w > 1 || h > 1) { - w = std::max(w >> 1, 1); - h = std::max(h >> 1, 1); + w = max(w >> 1, 1); + h = max(h >> 1, 1); levels++; } return levels; @@ -391,7 +391,7 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state) int numLayers = NumLayers(); auto fb = GetVulkanFrameBuffer(); - auto descriptor = fb->GetRenderPassManager()->AllocateTextureDescriptorSet(std::max(numLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS)); + auto descriptor = fb->GetRenderPassManager()->AllocateTextureDescriptorSet(max(numLayers, SHADER_MIN_REQUIRED_TEXTURE_LAYERS)); descriptor->SetDebugName("VkHardwareTexture.mDescriptorSets"); diff --git a/source/common/rendering/vulkan/textures/vk_imagetransition.cpp b/source/common/rendering/vulkan/textures/vk_imagetransition.cpp index a135a3f0f..a5f289296 100644 --- a/source/common/rendering/vulkan/textures/vk_imagetransition.cpp +++ b/source/common/rendering/vulkan/textures/vk_imagetransition.cpp @@ -117,8 +117,8 @@ void VkTextureImage::GenerateMipmaps(VulkanCommandBuffer *cmdbuffer) barrier0.execute(cmdbuffer, VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_TRANSFER_BIT); Layout = VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL; - int nextWidth = std::max(mipWidth >> 1, 1); - int nextHeight = std::max(mipHeight >> 1, 1); + int nextWidth = max(mipWidth >> 1, 1); + int nextHeight = max(mipHeight >> 1, 1); VkImageBlit blit = {}; blit.srcOffsets[0] = { 0, 0, 0 }; diff --git a/source/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.h b/source/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.h index fd4472286..d153f5ad2 100644 --- a/source/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.h +++ b/source/common/rendering/vulkan/thirdparty/vk_mem_alloc/vk_mem_alloc.h @@ -18473,8 +18473,8 @@ VkMemoryRequirements img2MemReq; vkGetImageMemoryRequirements(device, img2, &img2MemReq); VkMemoryRequirements finalMemReq = {}; -finalMemReq.size = std::max(img1MemReq.size, img2MemReq.size); -finalMemReq.alignment = std::max(img1MemReq.alignment, img2MemReq.alignment); +finalMemReq.size = max(img1MemReq.size, img2MemReq.size); +finalMemReq.alignment = max(img1MemReq.alignment, img2MemReq.alignment); finalMemReq.memoryTypeBits = img1MemReq.memoryTypeBits & img2MemReq.memoryTypeBits; // Validate if(finalMemReq.memoryTypeBits != 0) diff --git a/source/common/scripting/backend/codegen.cpp b/source/common/scripting/backend/codegen.cpp index 5be4b48be..2195d745a 100644 --- a/source/common/scripting/backend/codegen.cpp +++ b/source/common/scripting/backend/codegen.cpp @@ -8896,7 +8896,7 @@ ExpEmit FxVMFunctionCall::Emit(VMFunctionBuilder *build) ArgList.ShrinkToFit(); if (!staticcall) emitters.SetVirtualReg(selfemit.RegNum); - int resultcount = vmfunc->Proto->ReturnTypes.Size() == 0 ? 0 : std::max(AssignCount, 1); + int resultcount = vmfunc->Proto->ReturnTypes.Size() == 0 ? 0 : max(AssignCount, 1); assert((unsigned)resultcount <= vmfunc->Proto->ReturnTypes.Size()); for (int i = 0; i < resultcount; i++) diff --git a/source/common/scripting/core/symbols.cpp b/source/common/scripting/core/symbols.cpp index c6e38551f..0540c647c 100644 --- a/source/common/scripting/core/symbols.cpp +++ b/source/common/scripting/core/symbols.cpp @@ -345,7 +345,7 @@ PField *PSymbolTable::AddField(FName name, PType *type, uint32_t flags, unsigned // its fields. if (Align != nullptr) { - *Align = MAX(*Align, type->Align); + *Align = max(*Align, type->Align); } if (AddSymbol(field) == nullptr) diff --git a/source/common/scripting/core/vmdisasm.cpp b/source/common/scripting/core/vmdisasm.cpp index b3dbece6e..8fbf0aa8b 100644 --- a/source/common/scripting/core/vmdisasm.cpp +++ b/source/common/scripting/core/vmdisasm.cpp @@ -677,7 +677,7 @@ static int print_reg(FILE *out, int col, int arg, int mode, int immshift, const void DumpFunction(FILE *dump, VMScriptFunction *sfunc, const char *label, int labellen) { const char *marks = "======================================================="; - fprintf(dump, "\n%.*s %s %.*s", MAX(3, 38 - labellen / 2), marks, label, MAX(3, 38 - labellen / 2), marks); + fprintf(dump, "\n%.*s %s %.*s", max(3, 38 - labellen / 2), marks, label, max(3, 38 - labellen / 2), marks); fprintf(dump, "\nInteger regs: %-3d Float regs: %-3d Address regs: %-3d String regs: %-3d\nStack size: %d\n", sfunc->NumRegD, sfunc->NumRegF, sfunc->NumRegA, sfunc->NumRegS, sfunc->MaxParam); VMDumpConstants(dump, sfunc); diff --git a/source/common/scripting/jit/jit_runtime.cpp b/source/common/scripting/jit/jit_runtime.cpp index b0a9dc488..1f0d95611 100644 --- a/source/common/scripting/jit/jit_runtime.cpp +++ b/source/common/scripting/jit/jit_runtime.cpp @@ -56,7 +56,7 @@ static void *AllocJitMemory(size_t size) } else { - const size_t bytesToAllocate = std::max(size_t(1024 * 1024), size); + const size_t bytesToAllocate = max(size_t(1024 * 1024), size); size_t allocatedSize = 0; void *p = OSUtils::allocVirtualMemory(bytesToAllocate, &allocatedSize, OSUtils::kVMWritable | OSUtils::kVMExecutable); if (!p) diff --git a/source/common/scripting/vm/vmframe.cpp b/source/common/scripting/vm/vmframe.cpp index 4b50f9b21..75dab6305 100644 --- a/source/common/scripting/vm/vmframe.cpp +++ b/source/common/scripting/vm/vmframe.cpp @@ -746,7 +746,7 @@ ADD_STAT(VM) for (auto d : VMCycles) { added += d.TimeMS(); - peak = MAX(peak, d.TimeMS()); + peak = max(peak, d.TimeMS()); } for (auto d : VMCalls) addedc += d; memmove(&VMCycles[1], &VMCycles[0], 9 * sizeof(cycle_t)); diff --git a/source/common/statusbar/base_sbar.cpp b/source/common/statusbar/base_sbar.cpp index e63c21fb2..df0440b4c 100644 --- a/source/common/statusbar/base_sbar.cpp +++ b/source/common/statusbar/base_sbar.cpp @@ -293,11 +293,11 @@ static void ST_CalcCleanFacs(int designwidth, int designheight, int realwidth, i } // Use whichever pair of cwidth/cheight or width/height that produces less difference // between CleanXfac and CleanYfac. - cx1 = MAX(cwidth / designwidth, 1); - cy1 = MAX(cheight / designheight, 1); - cx2 = MAX(realwidth / designwidth, 1); - cy2 = MAX(realheight / designheight, 1); - if (abs(cx1 - cy1) <= abs(cx2 - cy2) || MAX(cx1, cx2) >= 4) + cx1 = max(cwidth / designwidth, 1); + cy1 = max(cheight / designheight, 1); + cx2 = max(realwidth / designwidth, 1); + cy2 = max(realheight / designheight, 1); + if (abs(cx1 - cy1) <= abs(cx2 - cy2) || max(cx1, cx2) >= 4) { // e.g. 640x360 looks better with this. *cleanx = cx1; *cleany = cy1; diff --git a/source/common/textures/bitmap.h b/source/common/textures/bitmap.h index 36d520771..e41949a02 100644 --- a/source/common/textures/bitmap.h +++ b/source/common/textures/bitmap.h @@ -460,7 +460,7 @@ struct bCopyAlpha struct bOverlay { static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = (s*a + d*(255-a))/255; } - static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = MAX(s,d); } + static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = max(s,d); } static __forceinline bool ProcessAlpha0() { return false; } }; @@ -480,14 +480,14 @@ struct bAdd struct bSubtract { - static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MAX((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = max((d*BLENDUNIT - s*i->alpha) >> BLENDBITS, 0); } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; struct bReverseSubtract { - static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MAX((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = max((-d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 0); } 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/hw_ihwtexture.cpp b/source/common/textures/hw_ihwtexture.cpp index f86daa5c1..296bfd40d 100644 --- a/source/common/textures/hw_ihwtexture.cpp +++ b/source/common/textures/hw_ihwtexture.cpp @@ -67,8 +67,8 @@ static void ResampleBoxPrecalc(TArray& boxes, int oldDim) const int src_p = int(dst * scale_factor_1); BoxPrecalc& precalc = boxes[dst]; - precalc.boxStart = clamp(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1); - precalc.boxEnd = clamp(max(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1); + precalc.boxStart = std::clamp(int(src_p - scale_factor_1 / 2.0 + 1), 0, oldDim - 1); + precalc.boxEnd = std::clamp(std::max(precalc.boxStart + 1, int(src_p + scale_factor_2)), 0, oldDim - 1); } } diff --git a/source/common/textures/texture.cpp b/source/common/textures/texture.cpp index 6d24f1154..6cee890db 100644 --- a/source/common/textures/texture.cpp +++ b/source/common/textures/texture.cpp @@ -387,7 +387,7 @@ FTextureBuffer FTexture::CreateTexBuffer(int translation, int flags) FContentIdBuilder builder; builder.id = 0; builder.imageID = GetImage()->GetId(); - builder.translation = MAX(0, translation); + builder.translation = max(0, translation); builder.expand = exx; result.mContentId = builder.id; } diff --git a/source/common/thirdparty/earcut.hpp b/source/common/thirdparty/earcut.hpp index 2c83e33bf..e01a09102 100644 --- a/source/common/thirdparty/earcut.hpp +++ b/source/common/thirdparty/earcut.hpp @@ -132,7 +132,7 @@ private: alloc_traits::deallocate(alloc, allocation, blockSize); } allocations.clear(); - blockSize = std::max(1, newBlockSize); + blockSize = max(1, newBlockSize); currentBlock = nullptr; currentIndex = blockSize; } @@ -186,13 +186,13 @@ void Earcut::operator()(const Polygon& points) { y = p->y; minX = std::min(minX, x); minY = std::min(minY, y); - maxX = std::max(maxX, x); - maxY = std::max(maxY, y); + maxX = max(maxX, x); + maxY = max(maxY, y); p = p->next; } while (p != outerNode); // minX, minY and size are later used to transform coords into integers for z-order calculation - inv_size = std::max(maxX - minX, maxY - minY); + inv_size = max(maxX - minX, maxY - minY); inv_size = inv_size != .0 ? (1. / inv_size) : .0; } @@ -352,8 +352,8 @@ bool Earcut::isEarHashed(Node* 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 maxTX = std::max(a->x, std::max(b->x, c->x)); - const double maxTY = std::max(a->y, std::max(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)); // z-order range for the current triangle bbox; const int32_t minZ = zOrder(minTX, minTY); @@ -717,9 +717,9 @@ bool Earcut::intersects(const Node* p1, const Node* q1, const Node* p2, const // for collinear points p, q, r, check if point q lies on segment pr template bool Earcut::onSegment(const Node* p, const Node* q, const Node* r) { - return q->x <= std::max(p->x, r->x) && + return q->x <= max(p->x, r->x) && q->x >= std::min(p->x, r->x) && - q->y <= std::max(p->y, r->y) && + q->y <= max(p->y, r->y) && q->y >= std::min(p->y, r->y); } diff --git a/source/common/utility/palette.cpp b/source/common/utility/palette.cpp index 3b6e71e55..037535689 100644 --- a/source/common/utility/palette.cpp +++ b/source/common/utility/palette.cpp @@ -500,7 +500,7 @@ PalEntry averageColor(const uint32_t* data, int size, int maxout) g = g / size; b = b / size; - int maxv = MAX(MAX(r, g), b); + int maxv = max(max(r, g), b); if (maxv && maxout) { diff --git a/source/common/utility/templates.h b/source/common/utility/templates.h index 7babf3f99..56cf80c7d 100644 --- a/source/common/utility/templates.h +++ b/source/common/utility/templates.h @@ -111,23 +111,5 @@ const T MIN (const T a, const T b) return a < b ? a : b; } -//========================================================================== -// -// MAX -// -// Returns the maximum of a and b. -//========================================================================== - -#ifdef MAX -#undef MAX -#endif - -template -inline -const T MAX (const T a, const T b) -{ - return a > b ? a : b; -} - #endif //__TEMPLATES_H__ diff --git a/source/core/d_net.cpp b/source/core/d_net.cpp index 041eada4f..af8e3bc94 100644 --- a/source/core/d_net.cpp +++ b/source/core/d_net.cpp @@ -234,7 +234,7 @@ static struct TicSpecial { int i; - specialsize = std::max(specialsize * 2, needed + 30); + specialsize = max(specialsize * 2, needed + 30); DPrintf (DMSG_NOTIFY, "Expanding special size to %zu\n", specialsize); @@ -1164,7 +1164,7 @@ void NetUpdate (void) netbuffer[k++] = lowtic; } - numtics = std::max(0, lowtic - realstart); + numtics = max(0, lowtic - realstart); if (numtics > BACKUPTICS) I_Error ("NetUpdate: Node %d missed too many tics", i); @@ -1173,7 +1173,7 @@ void NetUpdate (void) case 0: default: resendto[i] = lowtic; break; - case 1: resendto[i] = std::max(0, lowtic - 1); break; + case 1: resendto[i] = max(0, lowtic - 1); break; case 2: resendto[i] = nettics[i]; break; } @@ -1998,15 +1998,15 @@ int Net_GetLatency(int *ld, int *ad) localdelay = ((localdelay / BACKUPTICS) * ticdup) * (1000 / GameTicRate); int severity = 0; - if (std::max(localdelay, arbitratordelay) > 200) + if (max(localdelay, arbitratordelay) > 200) { severity = 1; } - if (std::max(localdelay, arbitratordelay) > 400) + if (max(localdelay, arbitratordelay) > 400) { severity = 2; } - if (std::max(localdelay, arbitratordelay) >= ((BACKUPTICS / 2 - 1) * ticdup) * (1000 / GameTicRate)) + if (max(localdelay, arbitratordelay) >= ((BACKUPTICS / 2 - 1) * ticdup) * (1000 / GameTicRate)) { severity = 3; } diff --git a/source/core/nodebuilder/nodebuild.cpp b/source/core/nodebuilder/nodebuild.cpp index f355cba9c..7b05ece87 100644 --- a/source/core/nodebuilder/nodebuild.cpp +++ b/source/core/nodebuilder/nodebuild.cpp @@ -141,10 +141,10 @@ int FNodeBuilder::CreateNode (uint32_t set, unsigned int count, fixed_t bbox[4]) D(PrintSet (2, set2)); 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[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[BOXRIGHT] = MAX (node.nb_bbox[0][BOXRIGHT], node.nb_bbox[1][BOXRIGHT]); + bbox[BOXRIGHT] = max(node.nb_bbox[0][BOXRIGHT], node.nb_bbox[1][BOXRIGHT]); return (int)Nodes.Push (node); } else @@ -630,7 +630,7 @@ int FNodeBuilder::Heuristic (node_t &node, uint32_t set, bool honorNoSplit) frac = 1 - frac; } int penalty = int(1 / frac); - score = MAX(score - penalty, 1); + score = std::max(score - penalty, 1); D(Printf ("Penalized splitter by %d for being near endpt of seg %d (%f).\n", penalty, i, frac)); } diff --git a/source/core/nodebuilder/nodebuild_utility.cpp b/source/core/nodebuilder/nodebuild_utility.cpp index 9f6f7e674..29bb3d181 100644 --- a/source/core/nodebuilder/nodebuild_utility.cpp +++ b/source/core/nodebuilder/nodebuild_utility.cpp @@ -450,9 +450,9 @@ int FNodeBuilder::FVertexMap::InsertVertex (FNodeBuilder::FPrivVert &vert) // If a vertex is near a block boundary, then it will be inserted on // 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 minx = max(MinX, 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 miny = max(MinY, 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/palette.cpp b/source/core/palette.cpp index cfb395ed0..036b1568b 100644 --- a/source/core/palette.cpp +++ b/source/core/palette.cpp @@ -488,9 +488,9 @@ void DrawFullscreenBlends() // These get prepended to the 2D drawer so they must be submitted in reverse order of drawing. if (tint_blood_r | tint_blood_g | tint_blood_b) { - PalEntry color2(255, std::max(-tint_blood_r, 0), std::max(-tint_blood_g, 0), std::max(-tint_blood_b, 0)); + PalEntry color2(255, max(-tint_blood_r, 0), max(-tint_blood_g, 0), max(-tint_blood_b, 0)); twod->AddColorOnlyQuad(0, 0, twod->GetWidth(), twod->GetHeight(), color2, &LegacyRenderStyles[STYLE_Subtract], true); - PalEntry color(255, std::max(tint_blood_r, 0), std::max(tint_blood_g, 0), std::max(tint_blood_b, 0)); + PalEntry color(255, max(tint_blood_r, 0), max(tint_blood_g, 0), max(tint_blood_b, 0)); twod->AddColorOnlyQuad(0, 0, twod->GetWidth(), twod->GetHeight(), color, &LegacyRenderStyles[STYLE_Add], true); } diff --git a/source/core/rendering/scene/hw_portal.h b/source/core/rendering/scene/hw_portal.h index 77278edfb..ffe5c9494 100644 --- a/source/core/rendering/scene/hw_portal.h +++ b/source/core/rendering/scene/hw_portal.h @@ -96,7 +96,7 @@ struct BoundingRect double distanceTo(const BoundingRect& other) const { if (intersects(other)) return 0; - return std::max(std::min(fabs(left - other.right), fabs(right - other.left)), + return max(std::min(fabs(left - other.right), fabs(right - other.left)), std::min(fabs(top - other.bottom), fabs(bottom - other.top))); } diff --git a/source/core/rendering/scene/hw_walls.cpp b/source/core/rendering/scene/hw_walls.cpp index 24d54c23b..074b61d1f 100644 --- a/source/core/rendering/scene/hw_walls.cpp +++ b/source/core/rendering/scene/hw_walls.cpp @@ -932,8 +932,8 @@ void HWWall::DoMidTexture(HWDrawInfo* di, walltype* wal, topleft = std::min(bch1,fch1); topright = std::min(bch2,fch2); - bottomleft = std::max(bfh1,ffh1); - bottomright = std::max(bfh2,ffh2); + bottomleft = max(bfh1,ffh1); + bottomright = max(bfh2,ffh2); if (topleft<=bottomleft && topright<=bottomright) return; type = seg->cstat & CSTAT_WALL_1WAY ? RENDERWALL_M1S : RENDERWALL_M2S; diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 8aeb1f6ba..a2dc698cf 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -40,7 +40,6 @@ source as it is released. #include "interpolate.h" using std::min; -using std::max; // PRIMITIVE BEGIN_DUKE_NS diff --git a/source/games/exhumed/src/object.cpp b/source/games/exhumed/src/object.cpp index 4f045bd53..1f5436beb 100644 --- a/source/games/exhumed/src/object.cpp +++ b/source/games/exhumed/src/object.cpp @@ -664,7 +664,7 @@ void MoveSectorSprites(int nSector, int z) int newz = sector[nSector].floorz; int oldz = newz - z; int minz = std::min(newz, oldz); - int maxz = std::max(newz, oldz); + int maxz = max(newz, oldz); ExhumedSectIterator it(nSector); while (auto pActor = it.Next()) {