From 1d0aed219e52c8e6a993ec265965737e3fee1ab7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 30 Oct 2021 10:16:52 +0200 Subject: [PATCH] - replaced MIN/MAX in all non-common code. --- src/console/c_cmds.cpp | 4 +-- src/d_net.cpp | 16 +++++------ src/events.cpp | 4 +-- src/g_game.cpp | 6 ++-- src/g_statusbar/sbarinfo.cpp | 13 +++++---- src/g_statusbar/sbarinfo_commands.cpp | 6 ++-- src/gamedata/info.cpp | 2 +- src/intermission/intermission.cpp | 4 +-- src/maploader/glnodes.cpp | 2 +- src/maploader/maploader.cpp | 8 +++--- src/menu/doommenu.cpp | 4 +-- src/p_states.cpp | 2 +- src/playsim/dthinker.cpp | 2 +- src/playsim/mapthinkers/a_lightning.cpp | 4 +-- src/playsim/mapthinkers/a_quake.cpp | 18 ++++++------ src/playsim/p_3dfloors.cpp | 2 +- src/playsim/p_3dmidtex.cpp | 4 +-- src/playsim/p_acs.cpp | 6 ++-- src/playsim/p_actionfunctions.cpp | 10 +++---- src/playsim/p_enemy.cpp | 4 +-- src/playsim/p_interaction.cpp | 8 +++--- src/playsim/p_map.cpp | 12 ++++---- src/playsim/p_maputl.cpp | 8 +++--- src/playsim/p_mobj.cpp | 10 +++---- src/playsim/p_secnodes.cpp | 2 +- src/playsim/p_sight.cpp | 4 +-- src/playsim/p_teleport.cpp | 2 +- src/playsim/p_user.cpp | 6 ++-- src/r_data/r_sections.h | 4 +-- src/r_data/r_translate.cpp | 14 +++++----- src/rendering/2d/f_wipe.cpp | 8 +++--- src/rendering/2d/v_blend.cpp | 6 ++-- src/rendering/hwrenderer/doom_aabbtree.cpp | 20 ++++++------- src/rendering/hwrenderer/scene/hw_walls.cpp | 28 +++++++++---------- src/rendering/swrenderer/line/r_wallsetup.cpp | 2 +- .../swrenderer/viewport/r_spritedrawer.cpp | 8 +++--- src/scripting/vmthunks.cpp | 6 ++-- src/serializer_doom.cpp | 2 +- src/sound/s_advsound.cpp | 2 +- src/sound/s_doomsound.cpp | 4 +-- src/utility/nodebuilder/nodebuild.cpp | 10 +++---- src/utility/nodebuilder/nodebuild_utility.cpp | 4 +-- src/wi_stuff.cpp | 2 +- 43 files changed, 147 insertions(+), 146 deletions(-) diff --git a/src/console/c_cmds.cpp b/src/console/c_cmds.cpp index 513434478..15e932d20 100644 --- a/src/console/c_cmds.cpp +++ b/src/console/c_cmds.cpp @@ -469,7 +469,7 @@ CCMD (puke) return; } int arg[4] = { 0, 0, 0, 0 }; - int argn = MIN(argc - 2, countof(arg)), i; + int argn = min(argc - 2, countof(arg)), i; for (i = 0; i < argn; ++i) { @@ -516,7 +516,7 @@ CCMD (pukename) always = true; argstart = 3; } - argn = MIN(argc - argstart, countof(arg)); + argn = min(argc - argstart, countof(arg)); for (i = 0; i < argn; ++i) { arg[i] = atoi(argv[argstart + i]); diff --git a/src/d_net.cpp b/src/d_net.cpp index 28e28637a..b6d8da2f5 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -222,7 +222,7 @@ static struct TicSpecial { int i; - specialsize = MAX(specialsize * 2, needed + 30); + specialsize = max(specialsize * 2, needed + 30); DPrintf (DMSG_NOTIFY, "Expanding special size to %zu\n", specialsize); @@ -1151,7 +1151,7 @@ void NetUpdate (void) netbuffer[k++] = lowtic; } - numtics = MAX(0, lowtic - realstart); + numtics = max(0, lowtic - realstart); if (numtics > BACKUPTICS) I_Error ("NetUpdate: Node %d missed too many tics", i); @@ -1160,7 +1160,7 @@ void NetUpdate (void) case 0: default: resendto[i] = lowtic; break; - case 1: resendto[i] = MAX(0, lowtic - 1); break; + case 1: resendto[i] = max(0, lowtic - 1); break; case 2: resendto[i] = nettics[i]; break; } @@ -1836,7 +1836,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); } // @@ -2750,7 +2750,7 @@ static void RunScript(uint8_t **stream, AActor *pawn, int snum, int argn, int al arg[i] = argval; } } - P_StartScript(pawn->Level, pawn, NULL, snum, primaryLevel->MapName, arg, MIN(countof(arg), argn), ACS_NET | always); + P_StartScript(pawn->Level, pawn, NULL, snum, primaryLevel->MapName, arg, min(countof(arg), argn), ACS_NET | always); } void Net_SkipCommand (int type, uint8_t **stream) @@ -2913,15 +2913,15 @@ int Net_GetLatency(int *ld, int *ad) localdelay = ((localdelay / BACKUPTICS) * ticdup) * (1000 / TICRATE); int severity = 0; - if (MAX(localdelay, arbitratordelay) > 200) + if (max(localdelay, arbitratordelay) > 200) { severity = 1; } - if (MAX(localdelay, arbitratordelay) > 400) + if (max(localdelay, arbitratordelay) > 400) { severity = 2; } - if (MAX(localdelay, arbitratordelay) >= ((BACKUPTICS / 2 - 1) * ticdup) * (1000 / TICRATE)) + if (max(localdelay, arbitratordelay) >= ((BACKUPTICS / 2 - 1) * ticdup) * (1000 / TICRATE)) { severity = 3; } diff --git a/src/events.cpp b/src/events.cpp index a9362e03b..6da8118bb 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -1249,7 +1249,7 @@ CCMD(event) else { int arg[3] = { 0, 0, 0 }; - int argn = MIN(argc - 2, countof(arg)); + int argn = min(argc - 2, countof(arg)); for (int i = 0; i < argn; i++) arg[i] = atoi(argv[2 + i]); // call locally @@ -1274,7 +1274,7 @@ CCMD(netevent) else { int arg[3] = { 0, 0, 0 }; - int argn = MIN(argc - 2, countof(arg)); + int argn = min(argc - 2, countof(arg)); for (int i = 0; i < argn; i++) arg[i] = atoi(argv[2 + i]); // call networked diff --git a/src/g_game.cpp b/src/g_game.cpp index f394d1a85..fe49f74a8 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -837,7 +837,7 @@ void G_AddViewPitch (int look, bool mouse) } else { - LocalViewPitch = MIN(LocalViewPitch + look, 0x78000000); + LocalViewPitch = min(LocalViewPitch + look, 0x78000000); } } else if (look < 0) @@ -849,7 +849,7 @@ void G_AddViewPitch (int look, bool mouse) } else { - LocalViewPitch = MAX(LocalViewPitch + look, -0x78000000); + LocalViewPitch = max(LocalViewPitch + look, -0x78000000); } } if (look != 0) @@ -1319,7 +1319,7 @@ void G_Ticker () // Do some more aggressive GC maintenance when the game ticker is inactive. if ((gamestate != GS_LEVEL && gamestate != GS_TITLELEVEL) || paused || P_CheckTickerPaused()) { - size_t ac = std::max(10, GC::AllocCount); + size_t ac = max(10, GC::AllocCount); for (size_t i = 0; i < ac; i++) { if (!GC::CheckGC()) break; diff --git a/src/g_statusbar/sbarinfo.cpp b/src/g_statusbar/sbarinfo.cpp index 7efaff641..d32b94bc2 100644 --- a/src/g_statusbar/sbarinfo.cpp +++ b/src/g_statusbar/sbarinfo.cpp @@ -34,6 +34,7 @@ */ #include "doomtype.h" +#include "basics.h" #include "doomstat.h" #include "v_font.h" #include "v_video.h" @@ -1235,7 +1236,7 @@ public: wrapper->StatusbarToRealCoords(dx, dy, w, h); if(clearDontDraw) - ClearRect(twod, static_cast(MAX(dx, dcx)), static_cast(MAX(dy, dcy)), static_cast(MIN(dcr,w+MAX(dx, dcx))), static_cast(MIN(dcb,MAX(dy, dcy)+h)), GPalette.BlackIndex, 0); + ClearRect(twod, static_cast(max(dx, dcx)), static_cast(max(dy, dcy)), static_cast(min(dcr,w+max(dx, dcx))), static_cast(min(dcb,max(dy, dcy)+h)), GPalette.BlackIndex, 0); else { if(alphaMap) @@ -1245,8 +1246,8 @@ public: DTA_DestHeightF, h, DTA_ClipLeft, static_cast(dcx), DTA_ClipTop, static_cast(dcy), - DTA_ClipRight, static_cast(MIN(INT_MAX, dcr)), - DTA_ClipBottom, static_cast(MIN(INT_MAX, dcb)), + DTA_ClipRight, static_cast(min(INT_MAX, dcr)), + DTA_ClipBottom, static_cast(min(INT_MAX, dcb)), DTA_TranslationIndex, translate ? GetTranslation() : 0, DTA_ColorOverlay, dim ? DIM_OVERLAY : 0, DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM, @@ -1262,8 +1263,8 @@ public: DTA_DestHeightF, h, DTA_ClipLeft, static_cast(dcx), DTA_ClipTop, static_cast(dcy), - DTA_ClipRight, static_cast(MIN(INT_MAX, dcr)), - DTA_ClipBottom, static_cast(MIN(INT_MAX, dcb)), + DTA_ClipRight, static_cast(min(INT_MAX, dcr)), + DTA_ClipBottom, static_cast(min(INT_MAX, dcb)), DTA_TranslationIndex, translate ? GetTranslation() : 0, DTA_ColorOverlay, dim ? DIM_OVERLAY : 0, DTA_CenterBottomOffset, (offsetflags & SBarInfoCommand::CENTER_BOTTOM) == SBarInfoCommand::CENTER_BOTTOM, @@ -1309,7 +1310,7 @@ public: } if(clearDontDraw) - ClearRect(twod, static_cast(rcx), static_cast(rcy), static_cast(MIN(rcr, rcx+w)), static_cast(MIN(rcb, rcy+h)), GPalette.BlackIndex, 0); + ClearRect(twod, static_cast(rcx), static_cast(rcy), static_cast(min(rcr, rcx+w)), static_cast(min(rcb, rcy+h)), GPalette.BlackIndex, 0); else { if(alphaMap) diff --git a/src/g_statusbar/sbarinfo_commands.cpp b/src/g_statusbar/sbarinfo_commands.cpp index 55cbefdbe..a6e084ea3 100644 --- a/src/g_statusbar/sbarinfo_commands.cpp +++ b/src/g_statusbar/sbarinfo_commands.cpp @@ -284,7 +284,7 @@ class CommandDrawImage : public SBarInfoCommandFlowControl if (Slots[armorType] > 0 && SlotsIncrement[armorType] > 0) { //combine the alpha values - alpha *= MIN(1., Slots[armorType] / SlotsIncrement[armorType]); + alpha *= min(1., Slots[armorType] / SlotsIncrement[armorType]); texture = statusBar->Images[image]; } else @@ -2796,7 +2796,7 @@ class CommandDrawBar : public SBarInfoCommand if(max != 0 && value > 0) { - value = MIN(value / max, 1.); + value = min(value / max, 1.); } else value = 0; @@ -2805,7 +2805,7 @@ class CommandDrawBar : public SBarInfoCommand // [BL] Since we used a percentage (in order to get the most fluid animation) // we need to establish a cut off point so the last pixel won't hang as the animation slows if(pixel == -1 && statusBar->Images[foreground]) - pixel = MAX(1 / 65536., 1./statusBar->Images[foreground]->GetDisplayWidth()); + pixel = std::max(1 / 65536., 1./statusBar->Images[foreground]->GetDisplayWidth()); if(fabs(drawValue - value) < pixel) drawValue = value; diff --git a/src/gamedata/info.cpp b/src/gamedata/info.cpp index 455a4cb22..c72d789ab 100644 --- a/src/gamedata/info.cpp +++ b/src/gamedata/info.cpp @@ -730,7 +730,7 @@ void PClassActor::SetPainChance(FName type, int chance) if (chance >= 0) { - ActorInfo()->PainChances.Push({ type, MIN(chance, 256) }); + ActorInfo()->PainChances.Push({ type, min(chance, 256) }); } } diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index bca2de20f..2a63588e5 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -386,7 +386,7 @@ void DIntermissionScreenText::Drawer () // line feed characters. int numrows; auto font = generic_ui ? NewSmallFont : SmallFont; - auto fontscale = MAX(generic_ui ? MIN(twod->GetWidth() / 640, twod->GetHeight() / 400) : MIN(twod->GetWidth() / 400, twod->GetHeight() / 250), 1); + auto fontscale = max(generic_ui ? min(twod->GetWidth() / 640, twod->GetHeight() / 400) : min(twod->GetWidth() / 400, twod->GetHeight() / 250), 1); int cleanwidth = twod->GetWidth() / fontscale; int cleanheight = twod->GetHeight() / fontscale; int refwidth = generic_ui ? 640 : 320; @@ -403,7 +403,7 @@ void DIntermissionScreenText::Drawer () int cx = (mTextX - refwidth/2) * fontscale + twod->GetWidth() / 2; int cy = (mTextY - refheight/2) * fontscale + twod->GetHeight() / 2; - cx = MAX(0, cx); + cx = max(0, cx); int startx = cx; if (usesDefault) diff --git a/src/maploader/glnodes.cpp b/src/maploader/glnodes.cpp index 843afeaa5..2ab09e929 100644 --- a/src/maploader/glnodes.cpp +++ b/src/maploader/glnodes.cpp @@ -708,7 +708,7 @@ static bool MatchHeader(const char * label, const char * hdata) if (memcmp(hdata, "LEVEL=", 6) == 0) { size_t labellen = strlen(label); - labellen = MIN(size_t(8), labellen); + labellen = min(size_t(8), labellen); if (strnicmp(hdata+6, label, labellen)==0 && (hdata[6+labellen]==0xa || hdata[6+labellen]==0xd)) diff --git a/src/maploader/maploader.cpp b/src/maploader/maploader.cpp index 7faaa01d1..14174a8cd 100644 --- a/src/maploader/maploader.cpp +++ b/src/maploader/maploader.cpp @@ -870,7 +870,7 @@ bool MapLoader::LoadSegs (MapData * map) if (vnum1 >= numvertexes || vnum2 >= numvertexes) { - throw badseg(0, i, MAX(vnum1, vnum2)); + throw badseg(0, i, max(vnum1, vnum2)); } li->v1 = &Level->vertexes[vnum1]; @@ -1890,7 +1890,7 @@ void MapLoader::LoadLineDefs2 (MapData * map) Level->sides.Alloc(count); memset(&Level->sides[0], 0, count * sizeof(side_t)); - sidetemp.Resize(MAX(count, Level->vertexes.Size())); + sidetemp.Resize(max(count, Level->vertexes.Size())); for (i = 0; i < count; i++) { sidetemp[i].a.special = sidetemp[i].a.tag = 0; @@ -1918,7 +1918,7 @@ void MapLoader::LoopSidedefs (bool firstloop) int i; int numsides = Level->sides.Size(); - sidetemp.Resize(MAX(Level->vertexes.Size(), numsides)); + sidetemp.Resize(max(Level->vertexes.Size(), numsides)); for (i = 0; i < (int)Level->vertexes.Size(); ++i) { @@ -2816,7 +2816,7 @@ void MapLoader::LoadReject (MapData * map, bool junk) else { // Check if the reject has some actual content. If not, free it. - rejectsize = MIN (rejectsize, neededsize); + rejectsize = min (rejectsize, neededsize); Level->rejectmatrix.Alloc(rejectsize); map->Read (ML_REJECT, &Level->rejectmatrix[0], rejectsize); diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index 0851323d4..e6a62f3c5 100644 --- a/src/menu/doommenu.cpp +++ b/src/menu/doommenu.cpp @@ -620,7 +620,7 @@ void M_StartupEpisodeMenu(FNewGameStartup *gs) if (*c == '$') c = GStrings(c + 1); int textwidth = ld->mFont->StringWidth(c); int textright = posx + textwidth; - if (posx + textright > 320) posx = std::max(0, 320 - textright); + if (posx + textright > 320) posx = max(0, 320 - textright); } for(unsigned i = 0; i < AllEpisodes.Size(); i++) @@ -1164,7 +1164,7 @@ void M_StartupSkillMenu(FNewGameStartup *gs) if (*c == '$') c = GStrings(c + 1); int textwidth = ld->mFont->StringWidth(c); int textright = posx + textwidth; - if (posx + textright > 320) posx = std::max(0, 320 - textright); + if (posx + textright > 320) posx = max(0, 320 - textright); } unsigned firstitem = ld->mItems.Size(); diff --git a/src/p_states.cpp b/src/p_states.cpp index 2e52243b1..778b13a19 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -79,7 +79,7 @@ DEFINE_ACTION_FUNCTION(FState, GetSpriteTexture) if (numret > 0) ret[0].SetInt(sprframe->Texture[rotation].GetIndex()); if (numret > 1) ret[1].SetInt(!!(sprframe->Flip & (1 << rotation))); if (numret > 2) ret[2].SetVector2(DVector2(scalex, scaley)); - return MIN(3, numret); + return min(3, numret); } diff --git a/src/playsim/dthinker.cpp b/src/playsim/dthinker.cpp index cabdf8668..d71e13880 100644 --- a/src/playsim/dthinker.cpp +++ b/src/playsim/dthinker.cpp @@ -247,7 +247,7 @@ void FThinkerCollection::RunThinkers(FLevelLocals *Level) Printf(TEXTCOLOR_YELLOW "Total, ms Averg, ms Calls Actor class\n"); Printf(TEXTCOLOR_YELLOW "---------- ---------- ------ --------------------\n"); - const unsigned count = MIN(profilelimit > 0 ? profilelimit : UINT_MAX, sorted.Size()); + const unsigned count = min(profilelimit > 0 ? profilelimit : UINT_MAX, sorted.Size()); for (unsigned i = 0; i < count; ++i) { diff --git a/src/playsim/mapthinkers/a_lightning.cpp b/src/playsim/mapthinkers/a_lightning.cpp index 9f2504f09..8fd3f3f16 100644 --- a/src/playsim/mapthinkers/a_lightning.cpp +++ b/src/playsim/mapthinkers/a_lightning.cpp @@ -157,11 +157,11 @@ void DLightningThinker::LightningFlash () LightningLightLevels[j] = tempSec->lightlevel; if (special == Light_IndoorLightning1) { - tempSec->SetLightLevel(MIN (tempSec->lightlevel+64, flashLight)); + tempSec->SetLightLevel(min (tempSec->lightlevel+64, flashLight)); } else if (special == Light_IndoorLightning2) { - tempSec->SetLightLevel(MIN (tempSec->lightlevel+32, flashLight)); + tempSec->SetLightLevel(min (tempSec->lightlevel+32, flashLight)); } else { diff --git a/src/playsim/mapthinkers/a_quake.cpp b/src/playsim/mapthinkers/a_quake.cpp index b906665e8..b612c8de9 100644 --- a/src/playsim/mapthinkers/a_quake.cpp +++ b/src/playsim/mapthinkers/a_quake.cpp @@ -210,8 +210,8 @@ double DEarthquake::GetModIntensity(double intensity, bool fake) const { // Defaults to middle of the road. divider = m_CountdownStart; - scalar = (m_Flags & QF_MAX) ? MAX(m_Countdown, m_CountdownStart - m_Countdown) - : MIN(m_Countdown, m_CountdownStart - m_Countdown); + scalar = (m_Flags & QF_MAX) ? max(m_Countdown, m_CountdownStart - m_Countdown) + : min(m_Countdown, m_CountdownStart - m_Countdown); } scalar = (scalar > divider) ? divider : scalar; @@ -311,20 +311,20 @@ int DEarthquake::StaticGetQuakeIntensities(double ticFrac, AActor *victim, FQuak if (!(quake->m_Flags & QF_WAVE)) { - jiggers.RollIntensity = MAX(r, jiggers.RollIntensity) * falloff; + jiggers.RollIntensity = max(r, jiggers.RollIntensity) * falloff; intensity *= falloff; if (quake->m_Flags & QF_RELATIVE) { - jiggers.RelIntensity.X = MAX(intensity.X, jiggers.RelIntensity.X); - jiggers.RelIntensity.Y = MAX(intensity.Y, jiggers.RelIntensity.Y); - jiggers.RelIntensity.Z = MAX(intensity.Z, jiggers.RelIntensity.Z); + jiggers.RelIntensity.X = max(intensity.X, jiggers.RelIntensity.X); + jiggers.RelIntensity.Y = max(intensity.Y, jiggers.RelIntensity.Y); + jiggers.RelIntensity.Z = max(intensity.Z, jiggers.RelIntensity.Z); } else { - jiggers.Intensity.X = MAX(intensity.X, jiggers.Intensity.X); - jiggers.Intensity.Y = MAX(intensity.Y, jiggers.Intensity.Y); - jiggers.Intensity.Z = MAX(intensity.Z, jiggers.Intensity.Z); + jiggers.Intensity.X = max(intensity.X, jiggers.Intensity.X); + jiggers.Intensity.Y = max(intensity.Y, jiggers.Intensity.Y); + jiggers.Intensity.Z = max(intensity.Z, jiggers.Intensity.Z); } } else diff --git a/src/playsim/p_3dfloors.cpp b/src/playsim/p_3dfloors.cpp index ece17634b..fa4d9b827 100644 --- a/src/playsim/p_3dfloors.cpp +++ b/src/playsim/p_3dfloors.cpp @@ -780,7 +780,7 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li double low1 = (open.lowfloorthroughportal & 1) ? open.lowfloor : lowestfloor[0]; double low2 = (open.lowfloorthroughportal & 2) ? open.lowfloor : lowestfloor[1]; - open.lowfloor = MIN(low1, low2); + open.lowfloor = min(low1, low2); } } } diff --git a/src/playsim/p_3dmidtex.cpp b/src/playsim/p_3dmidtex.cpp index 5d764d4e0..858998376 100644 --- a/src/playsim/p_3dmidtex.cpp +++ b/src/playsim/p_3dmidtex.cpp @@ -244,14 +244,14 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, do if(line->flags & ML_DONTPEGBOTTOM) { *ptexbot = y_offset + - MAX(line->frontsector->GetPlaneTexZ(sector_t::floor), line->backsector->GetPlaneTexZ(sector_t::floor)); + max(line->frontsector->GetPlaneTexZ(sector_t::floor), line->backsector->GetPlaneTexZ(sector_t::floor)); *ptextop = *ptexbot + textureheight; } else { *ptextop = y_offset + - MIN(line->frontsector->GetPlaneTexZ(sector_t::ceiling), line->backsector->GetPlaneTexZ(sector_t::ceiling)); + min(line->frontsector->GetPlaneTexZ(sector_t::ceiling), line->backsector->GetPlaneTexZ(sector_t::ceiling)); *ptexbot = *ptextop - textureheight; } diff --git a/src/playsim/p_acs.cpp b/src/playsim/p_acs.cpp index 674aad0f4..545bdd9c8 100644 --- a/src/playsim/p_acs.cpp +++ b/src/playsim/p_acs.cpp @@ -2454,7 +2454,7 @@ bool FBehavior::Init(FLevelLocals *Level, int lumpnum, FileReader * fr, int len, // Use unsigned iterator here to avoid issue with GCC 4.9/5.x // optimizer. Might be some undefined behavior in this code, // but I don't know what it is. - unsigned int initsize = MIN (ArrayStore[arraynum].ArraySize, (LittleLong(chunk[1])-4)/4); + unsigned int initsize = min (ArrayStore[arraynum].ArraySize, (LittleLong(chunk[1])-4)/4); int32_t *elems = ArrayStore[arraynum].Elements; for (unsigned int j = 0; j < initsize; ++j) { @@ -2532,7 +2532,7 @@ bool FBehavior::Init(FLevelLocals *Level, int lumpnum, FileReader * fr, int len, { int32_t *elems = ArrayStore[arraynum].Elements; // Ending zeros may be left out. - for (int j = MIN(LittleLong(chunk[1])-5, ArrayStore[arraynum].ArraySize); j > 0; --j, ++elems, ++chunkData) + for (int j = min(LittleLong(chunk[1])-5, ArrayStore[arraynum].ArraySize); j > 0; --j, ++elems, ++chunkData) { // For ATAG, a value of 0 = Integer, 1 = String, 2 = FunctionPtr // Our implementation uses the same tags for both String and FunctionPtr @@ -10309,7 +10309,7 @@ DLevelScript::DLevelScript (FLevelLocals *l, AActor *who, line_t *where, int num assert(code->VarCount >= code->ArgCount); Localvars.Resize(code->VarCount); memset(&Localvars[0], 0, code->VarCount * sizeof(int32_t)); - for (int i = 0; i < MIN(argcount, code->ArgCount); ++i) + for (int i = 0; i < min(argcount, code->ArgCount); ++i) { Localvars[i] = args[i]; } diff --git a/src/playsim/p_actionfunctions.cpp b/src/playsim/p_actionfunctions.cpp index af1c07e01..244dbca5e 100644 --- a/src/playsim/p_actionfunctions.cpp +++ b/src/playsim/p_actionfunctions.cpp @@ -1921,9 +1921,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burst) // base the number of shards on the size of the dead thing, so bigger // things break up into more shards than smaller things. // An self with radius 20 and height 64 creates ~40 chunks. - numChunks = MAX (4, int(self->radius * self->Height)/32); + numChunks = max (4, int(self->radius * self->Height)/32); i = (pr_burst.Random2()) % (numChunks/4); - for (i = MAX (24, numChunks + i); i >= 0; i--) + for (i = max (24, numChunks + i); i >= 0; i--) { double xo = (pr_burst() - 128) * self->radius / 128; double yo = (pr_burst() - 128) * self->radius / 128; @@ -2492,7 +2492,7 @@ DEFINE_ACTION_FUNCTION(AActor, CheckIfTargetInLOS) else { target = viewport; viewport = self; } } - fov = MIN(fov, 360.); + fov = min(fov, 360.); if (fov > 0) { @@ -4785,11 +4785,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FaceMovementDirection) { if (pdelta > 0) { - current -= MIN(pitchlimit, pdelta); + current -= min(pitchlimit, pdelta); } else //if (pdelta < 0) { - current += MIN(pitchlimit, -pdelta); + current += min(pitchlimit, -pdelta); } mobj->SetPitch(current, !!(flags & FMDF_INTERPOLATE)); } diff --git a/src/playsim/p_enemy.cpp b/src/playsim/p_enemy.cpp index b877bcd12..a3144b14a 100644 --- a/src/playsim/p_enemy.cpp +++ b/src/playsim/p_enemy.cpp @@ -2987,12 +2987,12 @@ void A_Face(AActor *self, AActor *other, DAngle max_turn, DAngle max_pitch, DAng { if (self->Angles.Pitch > other_pitch) { - max_pitch = MIN(max_pitch, (self->Angles.Pitch - other_pitch).Normalized360()); + max_pitch = min(max_pitch, (self->Angles.Pitch - other_pitch).Normalized360()); self->Angles.Pitch -= max_pitch; } else { - max_pitch = MIN(max_pitch, (other_pitch - self->Angles.Pitch).Normalized360()); + max_pitch = min(max_pitch, (other_pitch - self->Angles.Pitch).Normalized360()); self->Angles.Pitch += max_pitch; } } diff --git a/src/playsim/p_interaction.cpp b/src/playsim/p_interaction.cpp index a054b763c..b58ba727d 100644 --- a/src/playsim/p_interaction.cpp +++ b/src/playsim/p_interaction.cpp @@ -90,7 +90,7 @@ void P_TouchSpecialThing (AActor *special, AActor *toucher) // The pickup is at or above the toucher's feet OR // The pickup is below the toucher. - if (delta > toucher->Height || delta < MIN(-32., -special->Height)) + if (delta > toucher->Height || delta < min(-32., -special->Height)) { // out of reach return; } @@ -1467,7 +1467,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da } } - const int realdamage = MAX(0, damage); + const int realdamage = max(0, damage); target->Level->localEventManager->WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle); needevent = false; @@ -1475,7 +1475,7 @@ static int DamageMobj (AActor *target, AActor *inflictor, AActor *source, int da return realdamage; } } - return MAX(0, damage); + return max(0, damage); } static int DoDamageMobj(AActor *target, AActor *inflictor, AActor *source, int damage, FName mod, int flags, DAngle angle) @@ -1492,7 +1492,7 @@ static int DoDamageMobj(AActor *target, AActor *inflictor, AActor *source, int d target->Level->localEventManager->WorldThingDamaged(target, inflictor, source, realdamage, mod, flags, angle); } - return MAX(0, realdamage); + return max(0, realdamage); } DEFINE_ACTION_FUNCTION(AActor, DamageMobj) diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index a6784e00e..283fac9cf 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -2357,7 +2357,7 @@ bool P_TryMove(AActor *thing, const DVector2 &pos, // This is so that it does not walk off of things onto a drop off. if (thing->flags2 & MF2_ONMOBJ) { - floorz = MAX(thing->Z(), tm.floorz); + floorz = max(thing->Z(), tm.floorz); } if (floorz - tm.dropoffz > thing->MaxDropOffHeight && @@ -4035,8 +4035,8 @@ struct aim_t floorportalstate = false; } } - if (ceilingportalstate) EnterSectorPortal(sector_t::ceiling, 0, lastsector, toppitch, MIN(0., bottompitch)); - if (floorportalstate) EnterSectorPortal(sector_t::floor, 0, lastsector, MAX(0., toppitch), bottompitch); + if (ceilingportalstate) EnterSectorPortal(sector_t::ceiling, 0, lastsector, toppitch, min(0., bottompitch)); + if (floorportalstate) EnterSectorPortal(sector_t::floor, 0, lastsector, max(0., toppitch), bottompitch); FPathTraverse it(lastsector->Level, startpos.X, startpos.Y, aimtrace.X, aimtrace.Y, PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE | PT_DELTA, startfrac); intercept_t *in; @@ -4114,11 +4114,11 @@ struct aim_t // check portal in backsector when aiming up/downward is possible, the line doesn't have portals on both sides and there's actually a portal in the backsector if ((planestocheck & aim_up) && toppitch < 0 && open.top != LINEOPEN_MAX && !entersec->PortalBlocksMovement(sector_t::ceiling)) { - EnterSectorPortal(sector_t::ceiling, in->frac, entersec, toppitch, MIN(0., bottompitch)); + EnterSectorPortal(sector_t::ceiling, in->frac, entersec, toppitch, min(0., bottompitch)); } if ((planestocheck & aim_down) && bottompitch > 0 && open.bottom != LINEOPEN_MIN && !entersec->PortalBlocksMovement(sector_t::floor)) { - EnterSectorPortal(sector_t::floor, in->frac, entersec, MAX(0., toppitch), bottompitch); + EnterSectorPortal(sector_t::floor, in->frac, entersec, max(0., toppitch), bottompitch); } continue; // shot continues } @@ -6663,7 +6663,7 @@ void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) AActor *onmobj; if (!P_TestMobjZ(thing, true, &onmobj) && onmobj->Z() <= thing->Z()) { - thing->SetZ(MIN(thing->ceilingz - thing->Height, onmobj->Top())); + thing->SetZ(min(thing->ceilingz - thing->Height, onmobj->Top())); thing->UpdateRenderSectorList(); } } diff --git a/src/playsim/p_maputl.cpp b/src/playsim/p_maputl.cpp index 4f3af3c85..f99f2a6bb 100644 --- a/src/playsim/p_maputl.cpp +++ b/src/playsim/p_maputl.cpp @@ -527,10 +527,10 @@ void AActor::LinkToWorld(FLinkContext *ctx, bool spawningmapthing, sector_t *sec } else { // [RH] Link into every block this actor touches, not just the center one - x1 = MAX(0, x1); - y1 = MAX(0, y1); - x2 = MIN(Level->blockmap.bmapwidth - 1, x2); - y2 = MIN(Level->blockmap.bmapheight - 1, y2); + x1 = max(0, x1); + y1 = max(0, y1); + x2 = min(Level->blockmap.bmapwidth - 1, x2); + y2 = min(Level->blockmap.bmapheight - 1, y2); for (int y = y1; y <= y2; ++y) { for (int x = x1; x <= x2; ++x) diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index a9674122b..7eafb4526 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -1774,7 +1774,7 @@ bool P_SeekerMissile (AActor *actor, double thresh, double turnMax, bool precise DAngle pitch = 0.; if (!(actor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER))) { // Need to seek vertically - double dist = MAX(1., actor->Distance2D(target)); + double dist = max(1., actor->Distance2D(target)); // Aim at a player's eyes and at the middle of the actor for everything else. double aimheight = target->Height/2; if (target->player) @@ -1849,7 +1849,7 @@ double P_XYMovement (AActor *mo, DVector2 scroll) // preserve the direction instead of clamping x and y independently. double cx = mo->Vel.X == 0 ? 1. : clamp(mo->Vel.X, -maxmove, maxmove) / mo->Vel.X; double cy = mo->Vel.Y == 0 ? 1. : clamp(mo->Vel.Y, -maxmove, maxmove) / mo->Vel.Y; - double fac = MIN(cx, cy); + double fac = min(cx, cy); mo->Vel.X *= fac; mo->Vel.Y *= fac; @@ -2439,7 +2439,7 @@ void P_ZMovement (AActor *mo, double oldfloorz) } if (mo->Vel.Z < sinkspeed) { // Dropping too fast, so slow down toward sinkspeed. - mo->Vel.Z -= MAX(sinkspeed*2, -8.); + mo->Vel.Z -= max(sinkspeed*2, -8.); if (mo->Vel.Z > sinkspeed) { mo->Vel.Z = sinkspeed; @@ -2447,7 +2447,7 @@ void P_ZMovement (AActor *mo, double oldfloorz) } else if (mo->Vel.Z > sinkspeed) { // Dropping too slow/going up, so trend toward sinkspeed. - mo->Vel.Z = startvelz + MAX(sinkspeed/3, -8.); + mo->Vel.Z = startvelz + max(sinkspeed/3, -8.); if (mo->Vel.Z < sinkspeed) { mo->Vel.Z = sinkspeed; @@ -6693,7 +6693,7 @@ AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassAct th->VelFromAngle(); - double dist = source->DistanceBySpeed(dest, MAX(1., th->Speed)); + double dist = source->DistanceBySpeed(dest, max(1., th->Speed)); th->Vel.Z = (dest->Z() - source->Z()) / dist; if (th->flags4 & MF4_SPECTRAL) diff --git a/src/playsim/p_secnodes.cpp b/src/playsim/p_secnodes.cpp index 3e479e77c..f43b0e30e 100644 --- a/src/playsim/p_secnodes.cpp +++ b/src/playsim/p_secnodes.cpp @@ -390,7 +390,7 @@ void AActor::UpdateRenderSectorList() { int bx = Level->blockmap.GetBlockX(X()); int by = Level->blockmap.GetBlockY(Y()); - FBoundingBox bb(X(), Y(), MIN(radius*1.5, 128.)); // Don't go further than 128 map units, even for large actors + FBoundingBox bb(X(), Y(), min(radius*1.5, 128.)); // Don't go further than 128 map units, even for large actors // Are there any portals near the actor's position? if (Level->blockmap.isValidBlock(bx, by) && Level->PortalBlockmap(bx, by).neighborContainsLines) { diff --git a/src/playsim/p_sight.cpp b/src/playsim/p_sight.cpp index 0f1738f38..f75b1f61d 100644 --- a/src/playsim/p_sight.cpp +++ b/src/playsim/p_sight.cpp @@ -192,8 +192,8 @@ void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, doubl if (ff == 0) ff = front->floorplane.ZatPoint(x, y); if (bf == 0) bf = back->floorplane.ZatPoint(x, y); - open.bottom = MAX(ff, bf); - open.top = MIN(fc, bc); + open.bottom = max(ff, bf); + open.top = min(fc, bc); // we only want to know if there is an opening, not how large it is. open.range = open.bottom < open.top; diff --git a/src/playsim/p_teleport.cpp b/src/playsim/p_teleport.cpp index a5cec345a..4ea15d9ce 100644 --- a/src/playsim/p_teleport.cpp +++ b/src/playsim/p_teleport.cpp @@ -200,7 +200,7 @@ bool P_Teleport (AActor *thing, DVector3 pos, DAngle angle, int flags) // [RH] Zoom player's field of vision // [BC] && bHaltVelocity. if (telezoom && thing->player->mo == thing && !(flags & TELF_KEEPVELOCITY)) - thing->player->FOV = MIN (175.f, thing->player->DesiredFOV + 45.f); + thing->player->FOV = min (175.f, thing->player->DesiredFOV + 45.f); } } // [BC] && bHaltVelocity. diff --git a/src/playsim/p_user.cpp b/src/playsim/p_user.cpp index 9d976431b..618d72c6b 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -453,7 +453,7 @@ void player_t::SetSubtitle(int num, FSoundID soundid) if (text != nullptr) { SubtitleText = lumpname; - int sl = soundid == 0 ? 7000 : std::max(7000, S_GetMSLength(soundid)); + int sl = soundid == 0 ? 7000 : max(7000, S_GetMSLength(soundid)); SubtitleCounter = sl * TICRATE / 1000; } } @@ -623,8 +623,8 @@ EXTERN_CVAR(Bool, cl_oldfreelooklimit); static int GetSoftPitch(bool down) { - int MAX_DN_ANGLE = MIN(56, (int)maxviewpitch); // Max looking down angle - int MAX_UP_ANGLE = MIN(32, (int)maxviewpitch); // Max looking up angle + int MAX_DN_ANGLE = min(56, (int)maxviewpitch); // Max looking down angle + int MAX_UP_ANGLE = min(32, (int)maxviewpitch); // Max looking up angle return (down ? MAX_DN_ANGLE : ((cl_oldfreelooklimit) ? MAX_UP_ANGLE : MAX_DN_ANGLE)); } diff --git a/src/r_data/r_sections.h b/src/r_data/r_sections.h index 221d19e63..fd13a80e7 100644 --- a/src/r_data/r_sections.h +++ b/src/r_data/r_sections.h @@ -72,8 +72,8 @@ 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)), - 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/src/r_data/r_translate.cpp b/src/r_data/r_translate.cpp index cc847a963..252dc0ee0 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -144,7 +144,7 @@ int CreateBloodTranslation(PalEntry color) trans.Remap[0] = 0; for (i = 1; i < 256; i++) { - int bright = std::max(std::max(GPalette.BaseColors[i].r, GPalette.BaseColors[i].g), GPalette.BaseColors[i].b); + int bright = max(std::max(GPalette.BaseColors[i].r, GPalette.BaseColors[i].g), GPalette.BaseColors[i].b); PalEntry pe = PalEntry(255, color.r*bright/255, color.g*bright/255, color.b*bright/255); int entry = ColorMatcher.Pick(pe.r, pe.g, pe.b); @@ -484,7 +484,7 @@ static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerC // Build player sprite translation //h = 45.f; - v = MAX (0.1f, v); + v = max (0.1f, v); for (i = start; i <= end; i++) { @@ -498,7 +498,7 @@ static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerC float mv[18] = { .16f, .19f, .22f, .25f, .31f, .35f, .38f, .41f, .47f, .54f, .60f, .65f, .71f, .77f, .83f, .89f, .94f, 1.f }; // Build player sprite translation - v = MAX (0.1f, v); + v = max (0.1f, v); for (i = start; i <= end; i++) { @@ -513,12 +513,12 @@ static void R_CreatePlayerTranslation (float h, float s, float v, const FPlayerC if (gameinfo.gametype == GAME_Heretic) { // Build rain/lifegem translation - bases = MIN(bases * 1.3f, 1.f); - basev = MIN(basev * 1.3f, 1.f); + bases = min(bases * 1.3f, 1.f); + basev = min(basev * 1.3f, 1.f); for (i = 145; i <= 168; i++) { - s = MIN(bases, 0.8965f - 0.0962f * (float)(i - 161)); - v = MIN(1.f, (0.2102f + 0.0489f * (float)(i - 144)) * basev); + s = min(bases, 0.8965f - 0.0962f * (float)(i - 161)); + v = min(1.f, (0.2102f + 0.0489f * (float)(i - 144)) * basev); HSVtoRGB(&r, &g, &b, h, s, v); SetRemap(alttable, i, r, g, b); SetPillarRemap(pillartable, i, h, s, v); diff --git a/src/rendering/2d/f_wipe.cpp b/src/rendering/2d/f_wipe.cpp index 320bb869d..44a2dc1b5 100644 --- a/src/rendering/2d/f_wipe.cpp +++ b/src/rendering/2d/f_wipe.cpp @@ -74,11 +74,11 @@ int wipe_CalcBurn (uint8_t *burnarray, int width, int height, int density) { unsigned int offs = (a+b) & (width - 1); unsigned int v = M_Random(); - v = MIN(from[offs] + 4 + (v & 15) + (v >> 3) + (M_Random() & 31), 255u); + v = min(from[offs] + 4 + (v & 15) + (v >> 3) + (M_Random() & 31), 255u); from[offs] = from[width*2 + ((offs + width*3/2) & (width - 1))] = v; } - density = MIN(density + 10, width * 7); + density = min(density + 10, width * 7); from = burnarray; for (b = 0; b <= height; b += 2) @@ -289,7 +289,7 @@ bool Wiper_Melt::Run(int ticks) else if (y[i] < HEIGHT) { int dy = (y[i] < 16) ? y[i] + 1 : 8; - y[i] = MIN(y[i] + dy, HEIGHT); + y[i] = min(y[i] + dy, HEIGHT); done = false; } if (ticks == 0) @@ -311,7 +311,7 @@ bool Wiper_Melt::Run(int ticks) int w = startScreen->GetTexelWidth(); int h = startScreen->GetTexelHeight(); dpt.x = i * w / WIDTH; - dpt.y = MAX(0, y[i] * h / HEIGHT); + dpt.y = max(0, y[i] * h / HEIGHT); rect.left = dpt.x; rect.top = 0; rect.right = (i + 1) * w / WIDTH; diff --git a/src/rendering/2d/v_blend.cpp b/src/rendering/2d/v_blend.cpp index 88476cfc9..7f37a5685 100644 --- a/src/rendering/2d/v_blend.cpp +++ b/src/rendering/2d/v_blend.cpp @@ -141,7 +141,7 @@ void V_AddPlayerBlend (player_t *CPlayer, float blend[4], float maxinvalpha, int if (painFlash.a != 0) { - cnt = DamageToAlpha[MIN (CPlayer->damagecount * painFlash.a / 255, (uint32_t)113)]; + cnt = DamageToAlpha[min (CPlayer->damagecount * painFlash.a / 255, (uint32_t)113)]; // [BC] Allow users to tone down the intensity of the blood on the screen. cnt = (int)( cnt * blood_fade_scalar ); @@ -164,7 +164,7 @@ void V_AddPlayerBlend (player_t *CPlayer, float blend[4], float maxinvalpha, int if (CPlayer->poisoncount) { - cnt = MIN (CPlayer->poisoncount, 64); + cnt = min (CPlayer->poisoncount, 64); if (paletteflash & PF_POISON) { V_AddBlend(44/255.f, 92/255.f, 36/255.f, ((cnt + 7) >> 3) * 0.1f, blend); @@ -190,7 +190,7 @@ void V_AddPlayerBlend (player_t *CPlayer, float blend[4], float maxinvalpha, int } else { - cnt= MIN(CPlayer->hazardcount/8, 64); + cnt= min(CPlayer->hazardcount/8, 64); float r = ((Level->hazardcolor & 0xff0000) >> 16) / 255.f; float g = ((Level->hazardcolor & 0xff00) >> 8) / 255.f; float b = ((Level->hazardcolor & 0xff)) / 255.f; diff --git a/src/rendering/hwrenderer/doom_aabbtree.cpp b/src/rendering/hwrenderer/doom_aabbtree.cpp index 21256271d..5420e561e 100644 --- a/src/rendering/hwrenderer/doom_aabbtree.cpp +++ b/src/rendering/hwrenderer/doom_aabbtree.cpp @@ -57,8 +57,8 @@ DoomLevelAABBTree::DoomLevelAABBTree(FLevelLocals *lev) FVector2 aabb_min, aabb_max; const auto &left = nodes[staticroot]; const auto &right = nodes[dynamicroot]; - aabb_min.X = MIN(left.aabb_left, right.aabb_left); - aabb_min.Y = MIN(left.aabb_top, right.aabb_top); + aabb_min.X = min(left.aabb_left, right.aabb_left); + aabb_min.Y = min(left.aabb_top, right.aabb_top); aabb_max.X = MAX(left.aabb_right, right.aabb_right); aabb_max.Y = MAX(left.aabb_bottom, right.aabb_bottom); nodes.Push({ aabb_min, aabb_max, staticroot, dynamicroot }); @@ -137,9 +137,9 @@ bool DoomLevelAABBTree::Update() float y2 = (float)line.v2->fY(); int nodeIndex = path[0]; - nodes[nodeIndex].aabb_left = MIN(x1, x2); + nodes[nodeIndex].aabb_left = min(x1, x2); nodes[nodeIndex].aabb_right = MAX(x1, x2); - nodes[nodeIndex].aabb_top = MIN(y1, y2); + nodes[nodeIndex].aabb_top = min(y1, y2); nodes[nodeIndex].aabb_bottom = MAX(y1, y2); for (unsigned int j = 1; j < path.Size(); j++) @@ -147,8 +147,8 @@ bool DoomLevelAABBTree::Update() auto &cur = nodes[path[j]]; const auto &left = nodes[cur.left_node]; const auto &right = nodes[cur.right_node]; - cur.aabb_left = MIN(left.aabb_left, right.aabb_left); - cur.aabb_top = MIN(left.aabb_top, right.aabb_top); + cur.aabb_left = min(left.aabb_left, right.aabb_left); + cur.aabb_top = min(left.aabb_top, right.aabb_top); cur.aabb_right = MAX(left.aabb_right, right.aabb_right); cur.aabb_bottom = MAX(left.aabb_bottom, right.aabb_bottom); } @@ -181,10 +181,10 @@ int DoomLevelAABBTree::GenerateTreeNode(int *lines, int num_lines, const FVector float x2 = (float)maplines[mapLines[lines[i]]].v2->fX(); float y2 = (float)maplines[mapLines[lines[i]]].v2->fY(); - aabb_min.X = MIN(aabb_min.X, x1); - aabb_min.X = MIN(aabb_min.X, x2); - aabb_min.Y = MIN(aabb_min.Y, y1); - aabb_min.Y = MIN(aabb_min.Y, y2); + aabb_min.X = min(aabb_min.X, x1); + aabb_min.X = min(aabb_min.X, x2); + aabb_min.Y = min(aabb_min.Y, y1); + aabb_min.Y = min(aabb_min.Y, y2); aabb_max.X = MAX(aabb_max.X, x1); aabb_max.X = MAX(aabb_max.X, x2); aabb_max.Y = MAX(aabb_max.Y, y1); diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index f3ea5a2df..3ee54345d 100644 --- a/src/rendering/hwrenderer/scene/hw_walls.cpp +++ b/src/rendering/hwrenderer/scene/hw_walls.cpp @@ -705,7 +705,7 @@ bool HWWall::SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool trans if ((maplightbottomleftztop[1]) || (maplightbottomleft>ztop[0] && maplightbottomright(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1)); + float clen = max(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1)); float dch = ztop[1] - ztop[0]; float dfh = maplightbottomright - maplightbottomleft; @@ -745,7 +745,7 @@ bool HWWall::SplitWallComplex(HWDrawInfo *di, sector_t * frontsector, bool trans if ((maplightbottomleftzbottom[1]) || (maplightbottomleft>zbottom[0] && maplightbottomright(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1)); + float clen = max(fabsf(glseg.x2 - glseg.x1), fabsf(glseg.y2 - glseg.y1)); float dch = zbottom[1] - zbottom[0]; float dfh = maplightbottomright - maplightbottomleft; @@ -1283,12 +1283,12 @@ void HWWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary, rowoffset = tci.RowOffset(seg->sidedef->GetTextureYOffset(side_t::mid)); if ((seg->linedef->flags & ML_DONTPEGBOTTOM) >0) { - texturebottom = MAX(realfront->GetPlaneTexZ(sector_t::floor), realback->GetPlaneTexZ(sector_t::floor) + zalign) + rowoffset; + texturebottom = max(realfront->GetPlaneTexZ(sector_t::floor), realback->GetPlaneTexZ(sector_t::floor) + zalign) + rowoffset; texturetop = texturebottom + tci.mRenderHeight; } else { - texturetop = MIN(realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling) + zalign) + rowoffset; + texturetop = min(realfront->GetPlaneTexZ(sector_t::ceiling), realback->GetPlaneTexZ(sector_t::ceiling) + zalign) + rowoffset; texturebottom = texturetop - tci.mRenderHeight; } } @@ -1319,8 +1319,8 @@ void HWWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary, else { // texture is missing - use the higher plane - topleft = MAX(bch1,fch1); - topright = MAX(bch2,fch2); + topleft = max(bch1,fch1); + topright = max(bch2,fch2); } } else if ((bch1>fch1 || bch2>fch2) && @@ -1334,8 +1334,8 @@ void HWWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary, else { // But not if there can be visual artifacts. - topleft = MIN(bch1,fch1); - topright = MIN(bch2,fch2); + topleft = min(bch1,fch1); + topright = min(bch2,fch2); } // @@ -1347,8 +1347,8 @@ void HWWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary, if (!tex || !tex->isValid()) { // texture is missing - use the lower plane - bottomleft = MIN(bfh1,ffh1); - bottomright = MIN(bfh2,ffh2); + bottomleft = min(bfh1,ffh1); + bottomright = min(bfh2,ffh2); } else if (bfh1=ffh1 && bfh2>=ffh2))) { @@ -1360,8 +1360,8 @@ void HWWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary, else { // normal case - use the higher plane - bottomleft = MAX(bfh1,ffh1); - bottomright = MAX(bfh2,ffh2); + bottomleft = max(bfh1,ffh1); + bottomright = max(bfh2,ffh2); } // @@ -1514,8 +1514,8 @@ void HWWall::DoMidTexture(HWDrawInfo *di, seg_t * seg, bool drawfogboundary, int i,t=0; float v_factor=(zbottom[0]-ztop[0])/(tcs[LOLFT].v-tcs[UPLFT].v); // only split the vertical area of the polygon that does not contain slopes. - float splittopv = MAX(tcs[UPLFT].v, tcs[UPRGT].v); - float splitbotv = MIN(tcs[LOLFT].v, tcs[LORGT].v); + float splittopv = max(tcs[UPLFT].v, tcs[UPRGT].v); + float splitbotv = min(tcs[LOLFT].v, tcs[LORGT].v); // this is split vertically into sections. for(i=0;i= 1) ret[0].SetInt(retv); if (numret >= 2) ret[1].SetInt(slot); if (numret >= 3) ret[2].SetInt(index); - return MIN(numret, 3); + return min(numret, 3); } static PClassActor *GetWeapon(FWeaponSlots *self, int slot, int index) @@ -2123,7 +2123,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DBaseStatusBar, GetInventoryIcon, GetInventoryIcon FTextureID icon = FSetTextureID(GetInventoryIcon(item, flags, &applyscale)); if (numret >= 1) ret[0].SetInt(icon.GetIndex()); if (numret >= 2) ret[1].SetInt(applyscale); - return MIN(numret, 2); + return min(numret, 2); } //===================================================================================== @@ -2489,7 +2489,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetViewWindow) if (numret > 1) ret[1].SetInt(viewwindowy); if (numret > 2) ret[2].SetInt(viewwidth); if (numret > 3) ret[3].SetInt(viewheight); - return MIN(numret, 4); + return min(numret, 4); } DEFINE_ACTION_FUNCTION(_Console, MidPrint) diff --git a/src/serializer_doom.cpp b/src/serializer_doom.cpp index 4a011c28d..953bb9afc 100644 --- a/src/serializer_doom.cpp +++ b/src/serializer_doom.cpp @@ -117,7 +117,7 @@ FSerializer &SerializeArgs(FSerializer& arc, const char *key, int *args, int *de { if (val->IsArray()) { - unsigned int cnt = MIN(val->Size(), 5); + unsigned int cnt = min(val->Size(), 5); for (unsigned int i = 0; i < cnt; i++) { const rapidjson::Value &aval = (*val)[i]; diff --git a/src/sound/s_advsound.cpp b/src/sound/s_advsound.cpp index a982d9b67..eb441d60d 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -1008,7 +1008,7 @@ static void S_AddSNDINFO (int lump) sc.MustGetString (); sfx = soundEngine->FindSoundTentative (sc.String); sc.MustGetNumber (); - S_sfx[sfx].NearLimit = MIN(MAX(sc.Number, 0), 255); + S_sfx[sfx].NearLimit = min(max(sc.Number, 0), 255); if (sc.CheckFloat()) { S_sfx[sfx].LimitRange = float(sc.Float * sc.Float); diff --git a/src/sound/s_doomsound.cpp b/src/sound/s_doomsound.cpp index c8cbd4bb8..6b9549067 100644 --- a/src/sound/s_doomsound.cpp +++ b/src/sound/s_doomsound.cpp @@ -1004,11 +1004,11 @@ static void CalcSectorSoundOrg(const DVector3& listenpos, const sector_t* sec, i // Set sound vertical position based on channel. if (channum == CHAN_FLOOR) { - pos.Y = (float)MIN(sec->floorplane.ZatPoint(listenpos), listenpos.Z); + pos.Y = (float)min(sec->floorplane.ZatPoint(listenpos), listenpos.Z); } else if (channum == CHAN_CEILING) { - pos.Y = (float)MAX(sec->ceilingplane.ZatPoint(listenpos), listenpos.Z); + pos.Y = (float)max(sec->ceilingplane.ZatPoint(listenpos), listenpos.Z); } else if (channum == CHAN_INTERIOR) { diff --git a/src/utility/nodebuilder/nodebuild.cpp b/src/utility/nodebuilder/nodebuild.cpp index a097efd43..0efe38b0e 100644 --- a/src/utility/nodebuilder/nodebuild.cpp +++ b/src/utility/nodebuilder/nodebuild.cpp @@ -150,10 +150,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[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[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]); return (int)Nodes.Push (node); } else @@ -643,7 +643,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/src/utility/nodebuilder/nodebuild_utility.cpp b/src/utility/nodebuilder/nodebuild_utility.cpp index d94f84d07..5aff74b5b 100644 --- a/src/utility/nodebuilder/nodebuild_utility.cpp +++ b/src/utility/nodebuilder/nodebuild_utility.cpp @@ -699,9 +699,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/src/wi_stuff.cpp b/src/wi_stuff.cpp index 0172223ec..2393f0810 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -831,7 +831,7 @@ DEFINE_ACTION_FUNCTION(DStatusScreen, GetPlayerWidths) if (numret > 0) ret[0].SetInt(maxnamewidth); if (numret > 1) ret[1].SetInt(maxscorewidth); if (numret > 2) ret[2].SetInt(maxiconheight); - return MIN(numret, 3); + return min(numret, 3); } //====================================================================