diff --git a/src/am_map.cpp b/src/am_map.cpp index 148648ae8..4259f0548 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -29,7 +29,7 @@ #include #include "doomdef.h" -#include "templates.h" + #include "g_level.h" #include "st_stuff.h" #include "p_local.h" diff --git a/src/common/2d/v_2ddrawer.cpp b/src/common/2d/v_2ddrawer.cpp index 612eef005..182712349 100644 --- a/src/common/2d/v_2ddrawer.cpp +++ b/src/common/2d/v_2ddrawer.cpp @@ -33,7 +33,7 @@ */ #include -#include "templates.h" + #include "v_2ddrawer.h" #include "vectors.h" #include "vm.h" @@ -455,7 +455,7 @@ void F2DDrawer::AddTexture(FGameTexture* img, DrawParms& parms) // Note that this only works for unflipped and unrotated full textures. if (parms.windowleft > 0 || parms.windowright < parms.texwidth) { - double wi = std::min(parms.windowright, parms.texwidth); + double wi = min(parms.windowright, parms.texwidth); x += parms.windowleft * xscale; w -= (parms.texwidth - wi + parms.windowleft) * xscale; diff --git a/src/common/2d/v_2ddrawer.h b/src/common/2d/v_2ddrawer.h index 74d5935a6..f662de7ac 100644 --- a/src/common/2d/v_2ddrawer.h +++ b/src/common/2d/v_2ddrawer.h @@ -306,8 +306,8 @@ public: void UploadData(F2DDrawer::TwoDVertex *vertices, int vertcount, int *indices, int indexcount) { - mVertexBuffer->SetData(vertcount * sizeof(*vertices), vertices, false); - mIndexBuffer->SetData(indexcount * sizeof(unsigned int), indices, false); + mVertexBuffer->SetData(vertcount * sizeof(*vertices), vertices, BufferUsageType::Stream); + mIndexBuffer->SetData(indexcount * sizeof(unsigned int), indices, BufferUsageType::Stream); } std::pair GetBufferObjects() const diff --git a/src/common/2d/v_draw.cpp b/src/common/2d/v_draw.cpp index 9c53e754b..4a99b8cac 100644 --- a/src/common/2d/v_draw.cpp +++ b/src/common/2d/v_draw.cpp @@ -36,7 +36,7 @@ #include #include "v_draw.h" #include "vm.h" -#include "templates.h" + #include "texturemanager.h" #include "r_videoscale.h" #include "c_cvars.h" @@ -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)); } @@ -357,7 +357,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetClipRect) if (numret > 1) ret[1].SetInt(y); if (numret > 2) ret[2].SetInt(w); if (numret > 3) ret[3].SetInt(h); - return MIN(numret, 4); + return min(numret, 4); } @@ -460,7 +460,7 @@ DEFINE_ACTION_FUNCTION(_Screen, GetFullscreenRect) if (numret >= 2) ret[1].SetFloat(rect.top); if (numret >= 3) ret[2].SetFloat(rect.width); if (numret >= 4) ret[3].SetFloat(rect.height); - return MIN(numret, 4); + return min(numret, 4); } @@ -905,7 +905,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_Alpha: - parms->Alpha = (float)(MIN(1., ListGetDouble(tags))); + parms->Alpha = (float)(min(1., ListGetDouble(tags))); break; case DTA_AlphaChannel: @@ -1090,7 +1090,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double break; case DTA_ShadowAlpha: - //parms->shadowAlpha = (float)MIN(1., ListGetDouble(tags)); + //parms->shadowAlpha = (float)min(1., ListGetDouble(tags)); break; case DTA_ShadowColor: @@ -1286,10 +1286,10 @@ static void VirtualToRealCoords(F2DDrawer *drawer, double Width, double Height, { case 1: default: - myratio = MIN(64.0f / 27.0f, myratio); + myratio = min(64.0f / 27.0f, myratio); break; case 0: - myratio = MIN(16.0f / 9.0f, myratio); + myratio = min(16.0f / 9.0f, myratio); case -1: break; } @@ -1348,7 +1348,7 @@ DEFINE_ACTION_FUNCTION(_Screen, VirtualToRealCoords) VirtualToRealCoords(twod, x, y, w, h, vw, vh, vbottom, handleaspect); if (numret >= 1) ret[0].SetVector2(DVector2(x, y)); if (numret >= 2) ret[1].SetVector2(DVector2(w, h)); - return MIN(numret, 2); + return min(numret, 2); } void VirtualToRealCoordsInt(F2DDrawer *drawer, int &x, int &y, int &w, int &h, @@ -1529,8 +1529,9 @@ DEFINE_ACTION_FUNCTION(_Screen, Dim) PARAM_INT(y1); PARAM_INT(w); PARAM_INT(h); + PARAM_INT(style); if (!twod->HasBegun2D()) ThrowAbortException(X_OTHER, "Attempt to draw to screen outside a draw function"); - Dim(twod, color, float(amount), x1, y1, w, h); + Dim(twod, color, float(amount), x1, y1, w, h, &LegacyRenderStyles[style]); return 0; } @@ -1593,7 +1594,7 @@ DEFINE_ACTION_FUNCTION(_Screen, DrawLineFrame) void V_CalcCleanFacs(int designwidth, int designheight, int realwidth, int realheight, int* cleanx, int* cleany, int* _cx1, int* _cx2) { if (designheight < 240 && realheight >= 480) designheight = 240; - *cleanx = *cleany = std::min(realwidth / designwidth, realheight / designheight); + *cleanx = *cleany = min(realwidth / designwidth, realheight / designheight); } diff --git a/src/common/audio/music/i_music.cpp b/src/common/audio/music/i_music.cpp index b73c630ca..26989992d 100644 --- a/src/common/audio/music/i_music.cpp +++ b/src/common/audio/music/i_music.cpp @@ -43,7 +43,7 @@ #include "m_argv.h" #include "filesystem.h" #include "c_dispatch.h" -#include "templates.h" + #include "stats.h" #include "cmdlib.h" #include "c_cvars.h" diff --git a/src/common/audio/sound/oalsound.cpp b/src/common/audio/sound/oalsound.cpp index 252688572..4ef36cb4d 100644 --- a/src/common/audio/sound/oalsound.cpp +++ b/src/common/audio/sound/oalsound.cpp @@ -36,7 +36,7 @@ #include #include "c_cvars.h" -#include "templates.h" + #include "oalsound.h" #include "c_dispatch.h" #include "v_text.h" @@ -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) @@ -689,7 +689,7 @@ OpenALSoundRenderer::OpenALSoundRenderer() numSources = numChannels; } - Sources.Resize(std::min(numChannels, numSources)); + Sources.Resize(min(numChannels, numSources)); for(unsigned i = 0;i < Sources.Size();i++) { alGenSources(1, &Sources[i]); @@ -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/src/common/audio/sound/s_environment.cpp b/src/common/audio/sound/s_environment.cpp index d2e52e21a..c5f1a5cf7 100644 --- a/src/common/audio/sound/s_environment.cpp +++ b/src/common/audio/sound/s_environment.cpp @@ -34,7 +34,7 @@ #include "s_soundinternal.h" #include "sc_man.h" -#include "templates.h" + #include "cmdlib.h" diff --git a/src/common/audio/sound/s_reverbedit.cpp b/src/common/audio/sound/s_reverbedit.cpp index 25993a400..398d4f2f5 100644 --- a/src/common/audio/sound/s_reverbedit.cpp +++ b/src/common/audio/sound/s_reverbedit.cpp @@ -36,7 +36,7 @@ #include "s_soundinternal.h" #include "sc_man.h" #include "cmdlib.h" -#include "templates.h" + #include "filesystem.h" #include "i_system.h" #include "printf.h" diff --git a/src/common/audio/sound/s_sound.cpp b/src/common/audio/sound/s_sound.cpp index f6acbb885..46119a322 100644 --- a/src/common/audio/sound/s_sound.cpp +++ b/src/common/audio/sound/s_sound.cpp @@ -36,7 +36,7 @@ #include #include -#include "templates.h" + #include "s_soundinternal.h" #include "m_swap.h" #include "superfasthash.h" @@ -407,7 +407,7 @@ FSoundChan *SoundEngine::StartSound(int type, const void *source, sfx = &S_sfx[sound_id]; // Scale volume according to SNDINFO data. - volume = std::min(volume * sfx->Volume, 1.f); + volume = min(volume * sfx->Volume, 1.f); if (volume <= 0) return NULL; @@ -847,7 +847,7 @@ bool SoundEngine::CheckSoundLimit(sfxinfo_t *sfx, const FVector3 &pos, int near_ CalcPosVel(chan, &chanorigin, NULL); // scale the limit distance with the attenuation. An attenuation of 0 means the limit distance is infinite and all sounds within the level are inside the limit. - float attn = std::min(chan->DistanceScale, attenuation); + float attn = min(chan->DistanceScale, attenuation); if (attn <= 0 || (chanorigin - pos).LengthSquared() <= limit_range / attn) { count++; @@ -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/src/common/console/c_bind.cpp b/src/common/console/c_bind.cpp index b390dc122..a83951cca 100644 --- a/src/common/console/c_bind.cpp +++ b/src/common/console/c_bind.cpp @@ -41,7 +41,7 @@ #include "c_dispatch.h" #include "configfile.h" #include "filesystem.h" -#include "templates.h" + #include "i_time.h" #include "printf.h" #include "sc_man.h" diff --git a/src/common/console/c_buttons.cpp b/src/common/console/c_buttons.cpp index 0ea14dd46..860824ca5 100644 --- a/src/common/console/c_buttons.cpp +++ b/src/common/console/c_buttons.cpp @@ -34,7 +34,7 @@ */ #include "c_buttons.h" -#include "templates.h" + #include "c_dispatch.h" #include "printf.h" #include "cmdlib.h" diff --git a/src/common/console/c_commandbuffer.cpp b/src/common/console/c_commandbuffer.cpp index bf459350f..b079d7f76 100644 --- a/src/common/console/c_commandbuffer.cpp +++ b/src/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/src/common/console/c_console.cpp b/src/common/console/c_console.cpp index 5cafbb080..b40708808 100644 --- a/src/common/console/c_console.cpp +++ b/src/common/console/c_console.cpp @@ -34,7 +34,7 @@ #include -#include "templates.h" + #include "version.h" #include "c_bind.h" #include "c_console.h" @@ -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/src/common/console/c_dispatch.cpp b/src/common/console/c_dispatch.cpp index ce9f2cef7..004c5be3e 100644 --- a/src/common/console/c_dispatch.cpp +++ b/src/common/console/c_dispatch.cpp @@ -39,7 +39,7 @@ #include #include -#include "templates.h" + #include "cmdlib.h" #include "c_console.h" #include "c_dispatch.h" @@ -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/src/common/console/c_tabcomplete.cpp b/src/common/console/c_tabcomplete.cpp index ca8339062..eccd64b03 100644 --- a/src/common/console/c_tabcomplete.cpp +++ b/src/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/src/common/engine/i_net.cpp b/src/common/engine/i_net.cpp index 94388656f..64fd4acaf 100644 --- a/src/common/engine/i_net.cpp +++ b/src/common/engine/i_net.cpp @@ -75,7 +75,7 @@ #include "cmdlib.h" #include "printf.h" #include "i_interface.h" -#include "templates.h" + #include "i_net.h" diff --git a/src/common/engine/palettecontainer.cpp b/src/common/engine/palettecontainer.cpp index 41a92735d..73fb2bdb9 100644 --- a/src/common/engine/palettecontainer.cpp +++ b/src/common/engine/palettecontainer.cpp @@ -37,7 +37,7 @@ #include "m_crc32.h" #include "printf.h" #include "colormatcher.h" -#include "templates.h" + #include "palettecontainer.h" #include "files.h" @@ -565,9 +565,9 @@ bool FRemapTable::AddDesaturation(int start, int end, double r1, double g1, doub GPalette.BaseColors[c].g * 143 + GPalette.BaseColors[c].b * 37) / 256.0; - PalEntry pe = PalEntry( MIN(255, int(r1 + intensity*r2)), - MIN(255, int(g1 + intensity*g2)), - MIN(255, int(b1 + intensity*b2))); + PalEntry pe = PalEntry( min(255, int(r1 + intensity*r2)), + min(255, int(g1 + intensity*g2)), + min(255, int(b1 + intensity*b2))); int cc = GPalette.Remap[c]; diff --git a/src/common/engine/renderstyle.cpp b/src/common/engine/renderstyle.cpp index 1a29292ea..e31538b4f 100644 --- a/src/common/engine/renderstyle.cpp +++ b/src/common/engine/renderstyle.cpp @@ -32,7 +32,7 @@ ** */ -#include "templates.h" +#include "basics.h" #include "renderstyle.h" #include "c_cvars.h" diff --git a/src/common/engine/sc_man.cpp b/src/common/engine/sc_man.cpp index f24f25d92..29b0b445b 100644 --- a/src/common/engine/sc_man.cpp +++ b/src/common/engine/sc_man.cpp @@ -40,11 +40,11 @@ #include "engineerrors.h" #include "sc_man.h" #include "cmdlib.h" -#include "templates.h" + #include "printf.h" #include "name.h" #include "v_text.h" -#include "templates.h" + #include "zstring.h" #include "name.h" #include diff --git a/src/common/filesystem/file_rff.cpp b/src/common/filesystem/file_rff.cpp index c69b50246..e8c4fce81 100644 --- a/src/common/filesystem/file_rff.cpp +++ b/src/common/filesystem/file_rff.cpp @@ -34,7 +34,7 @@ */ #include "resourcefile.h" -#include "templates.h" + #include "printf.h" //========================================================================== @@ -219,7 +219,7 @@ int FRFFLump::FillCache() if (Flags & LUMPF_COMPRESSED) { - int cryptlen = MIN (LumpSize, 256); + int cryptlen = min (LumpSize, 256); uint8_t *data = (uint8_t *)Cache; for (int i = 0; i < cryptlen; ++i) diff --git a/src/common/filesystem/file_zip.cpp b/src/common/filesystem/file_zip.cpp index b3acb8d13..812e61783 100644 --- a/src/common/filesystem/file_zip.cpp +++ b/src/common/filesystem/file_zip.cpp @@ -36,7 +36,7 @@ #include #include "file_zip.h" #include "cmdlib.h" -#include "templates.h" + #include "printf.h" #include "w_zip.h" @@ -124,7 +124,7 @@ static uint32_t Zip_FindCentralDir(FileReader &fin) uint32_t uPosFound=0; FileSize = (uint32_t)fin.GetLength(); - uMaxBack = MIN(0xffff, FileSize); + uMaxBack = min(0xffff, FileSize); uBackRead = 4; while (uBackRead < uMaxBack) @@ -137,7 +137,7 @@ static uint32_t Zip_FindCentralDir(FileReader &fin) uBackRead += BUFREADCOMMENT; uReadPos = FileSize - uBackRead; - uReadSize = MIN((BUFREADCOMMENT + 4), (FileSize - uReadPos)); + uReadSize = min((BUFREADCOMMENT + 4), (FileSize - uReadPos)); if (fin.Seek(uReadPos, FileReader::SeekSet) != 0) break; @@ -266,7 +266,7 @@ bool FZipFile::Open(bool quiet, LumpFilterInfo* filter) // at least one of the more common definition lumps must be present. for (auto &p : filter->requiredPrefixes) { - if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == name.Len() - strlen(p)) + if (name.IndexOf(name0 + p) == 0 || name.LastIndexOf(p) == ptrdiff_t(name.Len() - strlen(p))) { foundspeciallump = true; break; diff --git a/src/common/fonts/font.cpp b/src/common/fonts/font.cpp index 6ddbe41d4..9dc4fee33 100644 --- a/src/common/fonts/font.cpp +++ b/src/common/fonts/font.cpp @@ -40,7 +40,7 @@ #include #include -#include "templates.h" + #include "m_swap.h" #include "v_font.h" #include "printf.h" @@ -686,7 +686,7 @@ int FFont::GetColorTranslation (EColorRange range, PalEntry *color) const { // Single pic fonts do not set up their translation table and must always return 0. if (Translations.Size() == 0) return 0; - assert(Translations.Size() == NumTextColors); + assert(Translations.Size() == (unsigned)NumTextColors); if (noTranslate) { @@ -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/src/common/fonts/v_font.cpp b/src/common/fonts/v_font.cpp index 0042f48c3..a9c6d1cf6 100644 --- a/src/common/fonts/v_font.cpp +++ b/src/common/fonts/v_font.cpp @@ -39,7 +39,7 @@ #include #include -#include "templates.h" + #include "m_swap.h" #include "v_font.h" #include "filesystem.h" diff --git a/src/common/menu/menudef.cpp b/src/common/menu/menudef.cpp index ef3397df0..f22f9f9b7 100644 --- a/src/common/menu/menudef.cpp +++ b/src/common/menu/menudef.cpp @@ -50,7 +50,7 @@ #include "texturemanager.h" #include "printf.h" #include "i_interface.h" -#include "templates.h" + bool CheckSkipGameOptionBlock(FScanner& sc); diff --git a/src/common/models/models_voxel.cpp b/src/common/models/models_voxel.cpp index 2be0521ad..809d25400 100644 --- a/src/common/models/models_voxel.cpp +++ b/src/common/models/models_voxel.cpp @@ -210,8 +210,8 @@ void FVoxelModel::AddFace(int x1, int y1, int z1, int x2, int y2, int z2, int x3 unsigned int indx[4]; vert.packedNormal = 0; // currently this is not being used for voxels. - vert.u = (((col & 15) * 255 / 16) + 7) / 255.f; - vert.v = (((col / 16) * 255 / 16) + 7) / 255.f; + vert.u = (((col & 15) + 0.5f) / 16.f); + vert.v = (((col / 16) + 0.5f) / 16.f); vert.x = x1 - PivotX; vert.z = -y1 + PivotY; diff --git a/src/common/objects/dobjgc.cpp b/src/common/objects/dobjgc.cpp index 58b27c4b7..91cfafaef 100644 --- a/src/common/objects/dobjgc.cpp +++ b/src/common/objects/dobjgc.cpp @@ -57,7 +57,7 @@ // HEADER FILES ------------------------------------------------------------ #include "dobject.h" -#include "templates.h" + #include "c_dispatch.h" #include "menu.h" #include "stats.h" @@ -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/src/common/platform/posix/cocoa/i_input.mm b/src/common/platform/posix/cocoa/i_input.mm index c329da3b9..ebda85a2e 100644 --- a/src/common/platform/posix/cocoa/i_input.mm +++ b/src/common/platform/posix/cocoa/i_input.mm @@ -644,7 +644,7 @@ void ProcessMouseButtonEvent(NSEvent* theEvent) break; } - event.data1 = MIN(KEY_MOUSE1 + [theEvent buttonNumber], NSInteger(KEY_MOUSE8)); + event.data1 = min(KEY_MOUSE1 + [theEvent buttonNumber], NSInteger(KEY_MOUSE8)); D_PostEvent(&event); } diff --git a/src/common/platform/posix/cocoa/i_joystick.cpp b/src/common/platform/posix/cocoa/i_joystick.cpp index 9a003acac..2bbfedb1d 100644 --- a/src/common/platform/posix/cocoa/i_joystick.cpp +++ b/src/common/platform/posix/cocoa/i_joystick.cpp @@ -39,7 +39,7 @@ #include "i_system.h" #include "m_argv.h" #include "m_joy.h" -#include "templates.h" + #include "v_text.h" #include "printf.h" #include "keydef.h" diff --git a/src/common/platform/posix/cocoa/i_main.mm b/src/common/platform/posix/cocoa/i_main.mm index b113aaa3b..727edef78 100644 --- a/src/common/platform/posix/cocoa/i_main.mm +++ b/src/common/platform/posix/cocoa/i_main.mm @@ -73,23 +73,6 @@ void Mac_I_FatalError(const char* const message) } -#if MAC_OS_X_VERSION_MAX_ALLOWED < 101000 - -// Available since 10.9 with no public declaration/definition until 10.10 - -struct NSOperatingSystemVersion -{ - NSInteger majorVersion; - NSInteger minorVersion; - NSInteger patchVersion; -}; - -@interface NSProcessInfo(OperatingSystemVersion) -- (NSOperatingSystemVersion)operatingSystemVersion; -@end - -#endif // before 10.10 - static bool ReadSystemVersionFromPlist(NSOperatingSystemVersion& version) { #if MAC_OS_X_VERSION_MAX_ALLOWED < 110000 @@ -169,9 +152,6 @@ void I_DetectOS() case 10: switch (version.minorVersion) { - case 9: name = "OS X Mavericks"; break; - case 10: name = "OS X Yosemite"; break; - case 11: name = "OS X El Capitan"; break; case 12: name = "macOS Sierra"; break; case 13: name = "macOS High Sierra"; break; case 14: name = "macOS Mojave"; break; @@ -196,9 +176,7 @@ void I_DetectOS() sysctlbyname("hw.model", model, &size, nullptr, 0); const char* const architecture = -#ifdef __i386__ - "32-bit Intel"; -#elif defined __x86_64__ +#ifdef __x86_64__ "64-bit Intel"; #elif defined __aarch64__ "64-bit ARM"; diff --git a/src/common/platform/posix/cocoa/i_video.mm b/src/common/platform/posix/cocoa/i_video.mm index 193466f0d..8f730e488 100644 --- a/src/common/platform/posix/cocoa/i_video.mm +++ b/src/common/platform/posix/cocoa/i_video.mm @@ -969,7 +969,7 @@ bool I_GetVulkanPlatformExtensions(unsigned int *count, const char **names) else { const bool result = *count >= extensionCount; - *count = std::min(*count, extensionCount); + *count = min(*count, extensionCount); for (unsigned int i = 0; i < *count; ++i) { diff --git a/src/common/platform/posix/cocoa/st_console.mm b/src/common/platform/posix/cocoa/st_console.mm index af26ae172..1c45776e6 100644 --- a/src/common/platform/posix/cocoa/st_console.mm +++ b/src/common/platform/posix/cocoa/st_console.mm @@ -510,7 +510,7 @@ void FConsoleWindow::NetProgress(const int count) if (m_netMaxPos > 1) { [m_netCountText setStringValue:[NSString stringWithFormat:@"%d / %d", m_netCurPos, m_netMaxPos]]; - [m_netProgressBar setDoubleValue:MIN(m_netCurPos, m_netMaxPos)]; + [m_netProgressBar setDoubleValue:min(m_netCurPos, m_netMaxPos)]; } } diff --git a/src/common/platform/posix/sdl/i_joystick.cpp b/src/common/platform/posix/sdl/i_joystick.cpp index fe4b25eb6..0fa33ba63 100644 --- a/src/common/platform/posix/sdl/i_joystick.cpp +++ b/src/common/platform/posix/sdl/i_joystick.cpp @@ -34,7 +34,7 @@ #include "basics.h" #include "cmdlib.h" -#include "templates.h" + #include "m_joy.h" #include "keydef.h" diff --git a/src/common/platform/win32/base_sysfb.cpp b/src/common/platform/win32/base_sysfb.cpp index 3cb8858a3..9c9bb4a54 100644 --- a/src/common/platform/win32/base_sysfb.cpp +++ b/src/common/platform/win32/base_sysfb.cpp @@ -39,7 +39,7 @@ #include "gl_sysfb.h" #include "hardware.h" -#include "templates.h" + #include "version.h" #include "c_console.h" #include "v_video.h" diff --git a/src/common/platform/win32/gl_sysfb.cpp b/src/common/platform/win32/gl_sysfb.cpp index 17822d213..8aa266883 100644 --- a/src/common/platform/win32/gl_sysfb.cpp +++ b/src/common/platform/win32/gl_sysfb.cpp @@ -39,7 +39,7 @@ #include "gl_sysfb.h" #include "hardware.h" -#include "templates.h" + #include "version.h" #include "c_console.h" #include "v_video.h" diff --git a/src/common/platform/win32/i_dijoy.cpp b/src/common/platform/win32/i_dijoy.cpp index 79b6fcf8f..e4021cc10 100644 --- a/src/common/platform/win32/i_dijoy.cpp +++ b/src/common/platform/win32/i_dijoy.cpp @@ -45,7 +45,7 @@ #include "i_input.h" #include "d_eventbase.h" -#include "templates.h" + #include "gameconfigfile.h" #include "cmdlib.h" #include "v_text.h" diff --git a/src/common/platform/win32/i_rawps2.cpp b/src/common/platform/win32/i_rawps2.cpp index 2a7547f3e..90e575a71 100644 --- a/src/common/platform/win32/i_rawps2.cpp +++ b/src/common/platform/win32/i_rawps2.cpp @@ -38,7 +38,7 @@ #include "i_input.h" #include "d_eventbase.h" -#include "templates.h" + #include "gameconfigfile.h" #include "m_argv.h" #include "cmdlib.h" diff --git a/src/common/platform/win32/i_system.cpp b/src/common/platform/win32/i_system.cpp index 103b26f31..1de30932d 100644 --- a/src/common/platform/win32/i_system.cpp +++ b/src/common/platform/win32/i_system.cpp @@ -73,7 +73,7 @@ #include "i_input.h" #include "c_dispatch.h" -#include "templates.h" + #include "gameconfigfile.h" #include "v_font.h" #include "i_system.h" @@ -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/src/common/platform/win32/i_xinput.cpp b/src/common/platform/win32/i_xinput.cpp index 7085de82f..2e8b79dc3 100644 --- a/src/common/platform/win32/i_xinput.cpp +++ b/src/common/platform/win32/i_xinput.cpp @@ -40,7 +40,7 @@ #include "i_input.h" #include "d_eventbase.h" -#include "templates.h" + #include "gameconfigfile.h" #include "m_argv.h" #include "cmdlib.h" diff --git a/src/common/platform/win32/st_start.cpp b/src/common/platform/win32/st_start.cpp index f36371a9b..71ff4b1cd 100644 --- a/src/common/platform/win32/st_start.cpp +++ b/src/common/platform/win32/st_start.cpp @@ -41,7 +41,7 @@ #include "st_start.h" #include "cmdlib.h" -#include "templates.h" + #include "i_system.h" #include "i_input.h" #include "hardware.h" @@ -351,7 +351,7 @@ void FBasicStartupScreen :: NetProgress(int count) mysnprintf (buf, countof(buf), "%d/%d", NetCurPos, NetMaxPos); SetDlgItemTextA (NetStartPane, IDC_NETSTARTCOUNT, buf); - SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, std::min(NetCurPos, NetMaxPos), 0); + SendDlgItemMessage (NetStartPane, IDC_NETSTARTPROGRESS, PBM_SETPOS, min(NetCurPos, NetMaxPos), 0); } } diff --git a/src/common/platform/win32/st_start_util.cpp b/src/common/platform/win32/st_start_util.cpp index 8c6074863..bfad11662 100644 --- a/src/common/platform/win32/st_start_util.cpp +++ b/src/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/src/common/platform/win32/win32basevideo.cpp b/src/common/platform/win32/win32basevideo.cpp index fc2ae67c4..b579b21f3 100644 --- a/src/common/platform/win32/win32basevideo.cpp +++ b/src/common/platform/win32/win32basevideo.cpp @@ -35,7 +35,7 @@ #include #include "hardware.h" -#include "templates.h" + #include "version.h" #include "c_console.h" #include "v_video.h" diff --git a/src/common/platform/win32/win32glvideo.cpp b/src/common/platform/win32/win32glvideo.cpp index abc9768cc..3508f07da 100644 --- a/src/common/platform/win32/win32glvideo.cpp +++ b/src/common/platform/win32/win32glvideo.cpp @@ -40,7 +40,7 @@ #include "gl_sysfb.h" #include "hardware.h" -#include "templates.h" + #include "version.h" #include "c_console.h" #include "v_video.h" diff --git a/src/common/rendering/gl/gl_buffers.cpp b/src/common/rendering/gl/gl_buffers.cpp index 47970b401..9338fee98 100644 --- a/src/common/rendering/gl/gl_buffers.cpp +++ b/src/common/rendering/gl/gl_buffers.cpp @@ -76,16 +76,20 @@ void GLBuffer::Bind() } -void GLBuffer::SetData(size_t size, const void *data, bool staticdata) +void GLBuffer::SetData(size_t size, const void *data, BufferUsageType usage) { Bind(); - if (data != nullptr) + if (usage == BufferUsageType::Static) { - glBufferData(mUseType, size, data, staticdata? GL_STATIC_DRAW : GL_STREAM_DRAW); + glBufferData(mUseType, size, data, GL_STATIC_DRAW); } - else + else if (usage == BufferUsageType::Stream) { - mPersistent = screen->BuffersArePersistent() && !staticdata; + glBufferData(mUseType, size, data, GL_STREAM_DRAW); + } + else if (usage == BufferUsageType::Persistent) + { + mPersistent = screen->BuffersArePersistent(); if (mPersistent) { glBufferStorage(mUseType, size, nullptr, GL_MAP_WRITE_BIT | GL_MAP_PERSISTENT_BIT | GL_MAP_COHERENT_BIT); @@ -93,10 +97,15 @@ void GLBuffer::SetData(size_t size, const void *data, bool staticdata) } else { - glBufferData(mUseType, size, nullptr, staticdata ? GL_STATIC_DRAW : GL_STREAM_DRAW); + glBufferData(mUseType, size, nullptr, GL_STREAM_DRAW); map = nullptr; } - if (!staticdata) nomap = false; + nomap = false; + } + else if (usage == BufferUsageType::Mappable) + { + glBufferData(mUseType, size, nullptr, GL_STATIC_DRAW); + map = nullptr; } buffersize = size; InvalidateBufferState(); @@ -134,7 +143,7 @@ void GLBuffer::Unmap() void *GLBuffer::Lock(unsigned int size) { // This initializes this buffer as a static object with no data. - SetData(size, nullptr, true); + SetData(size, nullptr, BufferUsageType::Mappable); return glMapBufferRange(mUseType, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT); } @@ -158,7 +167,7 @@ void GLBuffer::Resize(size_t newsize) glUnmapBuffer(mUseType); glGenBuffers(1, &mBufferId); - SetData(newsize, nullptr, false); + SetData(newsize, nullptr, BufferUsageType::Persistent); glBindBuffer(GL_COPY_READ_BUFFER, oldbuffer); // copy contents and delete the old buffer. diff --git a/src/common/rendering/gl/gl_buffers.h b/src/common/rendering/gl/gl_buffers.h index 0141ece5f..d0c2b62c8 100644 --- a/src/common/rendering/gl/gl_buffers.h +++ b/src/common/rendering/gl/gl_buffers.h @@ -24,7 +24,7 @@ protected: GLBuffer(int usetype); ~GLBuffer(); - void SetData(size_t size, const void *data, bool staticdata) override; + void SetData(size_t size, const void *data, BufferUsageType usage) override; void SetSubData(size_t offset, size_t size, const void *data) override; void Map() override; void Unmap() override; diff --git a/src/common/rendering/gl/gl_debug.cpp b/src/common/rendering/gl/gl_debug.cpp index c6c3adbfc..38625e73d 100644 --- a/src/common/rendering/gl/gl_debug.cpp +++ b/src/common/rendering/gl/gl_debug.cpp @@ -19,7 +19,7 @@ ** 3. This notice may not be removed or altered from any source distribution. */ -#include "templates.h" + #include "gl_system.h" #include "gl_debug.h" #include "stats.h" diff --git a/src/common/rendering/gl/gl_framebuffer.cpp b/src/common/rendering/gl/gl_framebuffer.cpp index ab72ce6b3..9fd8690d1 100644 --- a/src/common/rendering/gl/gl_framebuffer.cpp +++ b/src/common/rendering/gl/gl_framebuffer.cpp @@ -36,7 +36,7 @@ #include "gl_system.h" #include "v_video.h" #include "m_png.h" -#include "templates.h" + #include "i_time.h" #include "gl_interface.h" diff --git a/src/common/rendering/gl/gl_hwtexture.cpp b/src/common/rendering/gl/gl_hwtexture.cpp index 0043a67b8..a23ef82cc 100644 --- a/src/common/rendering/gl/gl_hwtexture.cpp +++ b/src/common/rendering/gl/gl_hwtexture.cpp @@ -34,7 +34,7 @@ */ #include "gl_system.h" -#include "templates.h" + #include "c_cvars.h" #include "hw_material.h" diff --git a/src/common/rendering/gl/gl_postprocess.cpp b/src/common/rendering/gl/gl_postprocess.cpp index 949fee4b0..f5ec0bfae 100644 --- a/src/common/rendering/gl/gl_postprocess.cpp +++ b/src/common/rendering/gl/gl_postprocess.cpp @@ -33,7 +33,7 @@ #include "flatvertices.h" #include "r_videoscale.h" #include "v_video.h" -#include "templates.h" + #include "hw_vrmodes.h" #include "v_draw.h" diff --git a/src/common/rendering/gl/gl_postprocessstate.cpp b/src/common/rendering/gl/gl_postprocessstate.cpp index 2e6a04f05..e490e8708 100644 --- a/src/common/rendering/gl/gl_postprocessstate.cpp +++ b/src/common/rendering/gl/gl_postprocessstate.cpp @@ -19,7 +19,7 @@ ** 3. This notice may not be removed or altered from any source distribution. */ -#include "templates.h" + #include "gl_system.h" #include "gl_interface.h" #include "gl_postprocessstate.h" diff --git a/src/common/rendering/gl/gl_renderbuffers.cpp b/src/common/rendering/gl/gl_renderbuffers.cpp index a1d8899bb..08c3de3c1 100644 --- a/src/common/rendering/gl/gl_renderbuffers.cpp +++ b/src/common/rendering/gl/gl_renderbuffers.cpp @@ -30,7 +30,7 @@ #include "gl_postprocessstate.h" #include "gl_shaderprogram.h" #include "gl_buffers.h" -#include "templates.h" + #include EXTERN_CVAR(Int, gl_debug_level) @@ -952,7 +952,7 @@ void GLPPRenderState::Draw() { if (!shader->Uniforms) shader->Uniforms.reset(screen->CreateDataBuffer(POSTPROCESS_BINDINGPOINT, false, false)); - shader->Uniforms->SetData(Uniforms.Data.Size(), Uniforms.Data.Data()); + shader->Uniforms->SetData(Uniforms.Data.Size(), Uniforms.Data.Data(), BufferUsageType::Static); static_cast(shader->Uniforms.get())->BindBase(); } diff --git a/src/common/rendering/gl/gl_renderstate.cpp b/src/common/rendering/gl/gl_renderstate.cpp index c660fb98e..d742f35fd 100644 --- a/src/common/rendering/gl/gl_renderstate.cpp +++ b/src/common/rendering/gl/gl_renderstate.cpp @@ -25,7 +25,7 @@ ** */ -#include "templates.h" + #include "gl_system.h" #include "gl_interface.h" #include "hw_cvars.h" diff --git a/src/common/rendering/gl/gl_renderstate.h b/src/common/rendering/gl/gl_renderstate.h index 948255d71..9cfe3d7a2 100644 --- a/src/common/rendering/gl/gl_renderstate.h +++ b/src/common/rendering/gl/gl_renderstate.h @@ -107,7 +107,7 @@ public: void EnableDrawBuffers(int count, bool apply = false) override { - count = std::min(count, 3); + count = min(count, 3); if (mNumDrawBuffers != count) { static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; diff --git a/src/common/rendering/gl/gl_shaderprogram.cpp b/src/common/rendering/gl/gl_shaderprogram.cpp index eb322fb94..2b6df3254 100644 --- a/src/common/rendering/gl/gl_shaderprogram.cpp +++ b/src/common/rendering/gl/gl_shaderprogram.cpp @@ -263,7 +263,7 @@ FString FShaderProgram::PatchShader(ShaderType type, const FString &code, const // If we have 4.2, always use it because it adds important new syntax. if (maxGlslVersion < 420 && gl.glslversion >= 4.2f) maxGlslVersion = 420; - int shaderVersion = std::min((int)round(gl.glslversion * 10) * 10, maxGlslVersion); + int shaderVersion = min((int)round(gl.glslversion * 10) * 10, maxGlslVersion); patchedCode.AppendFormat("#version %d\n", shaderVersion); // TODO: Find some way to add extension requirements to the patching diff --git a/src/common/rendering/gl/gl_stereo3d.cpp b/src/common/rendering/gl/gl_stereo3d.cpp index c81a8e66a..1d98874e3 100644 --- a/src/common/rendering/gl/gl_stereo3d.cpp +++ b/src/common/rendering/gl/gl_stereo3d.cpp @@ -34,7 +34,7 @@ #include "gl_framebuffer.h" #include "gl_shaderprogram.h" #include "gl_buffers.h" -#include "templates.h" + EXTERN_CVAR(Int, vr_mode) EXTERN_CVAR(Float, vid_saturation) diff --git a/src/common/rendering/gles/gles_buffers.cpp b/src/common/rendering/gles/gles_buffers.cpp index f3ffcfcc6..de815ea34 100644 --- a/src/common/rendering/gles/gles_buffers.cpp +++ b/src/common/rendering/gles/gles_buffers.cpp @@ -93,8 +93,9 @@ void GLBuffer::Bind() } -void GLBuffer::SetData(size_t size, const void* data, bool staticdata) +void GLBuffer::SetData(size_t size, const void* data, BufferUsageType usage) { + bool staticdata = (usage == BufferUsageType::Static || usage == BufferUsageType::Mappable); if (isData || !gles.useMappedBuffers) { if (memory) @@ -175,7 +176,7 @@ void GLBuffer::Unmap() void *GLBuffer::Lock(unsigned int size) { // This initializes this buffer as a static object with no data. - SetData(size, nullptr, true); + SetData(size, nullptr, BufferUsageType::Mappable); if (!isData && gles.useMappedBuffers) { return glMapBufferRange(mUseType, 0, size, GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT | GL_MAP_UNSYNCHRONIZED_BIT); diff --git a/src/common/rendering/gles/gles_buffers.h b/src/common/rendering/gles/gles_buffers.h index 0bd205351..d9e01ece6 100644 --- a/src/common/rendering/gles/gles_buffers.h +++ b/src/common/rendering/gles/gles_buffers.h @@ -26,7 +26,7 @@ protected: GLBuffer(int usetype); ~GLBuffer(); - void SetData(size_t size, const void *data, bool staticdata) override; + void SetData(size_t size, const void *data, BufferUsageType usage) override; void SetSubData(size_t offset, size_t size, const void *data) override; void Map() override; void Unmap() override; diff --git a/src/common/rendering/gles/gles_framebuffer.cpp b/src/common/rendering/gles/gles_framebuffer.cpp index 3a74ee6bc..3391a6f02 100644 --- a/src/common/rendering/gles/gles_framebuffer.cpp +++ b/src/common/rendering/gles/gles_framebuffer.cpp @@ -36,7 +36,7 @@ #include "gles_system.h" #include "v_video.h" #include "m_png.h" -#include "templates.h" + #include "i_time.h" #include "gles_framebuffer.h" @@ -122,7 +122,7 @@ void OpenGLFrameBuffer::InitializeState() { static bool first=true; - mPipelineNbr = gl_pipeline_depth == 0? std::min(4, HW_MAX_PIPELINE_BUFFERS) : clamp(*gl_pipeline_depth, 1, HW_MAX_PIPELINE_BUFFERS); + mPipelineNbr = gl_pipeline_depth == 0? min(4, HW_MAX_PIPELINE_BUFFERS) : clamp(*gl_pipeline_depth, 1, HW_MAX_PIPELINE_BUFFERS); mPipelineType = 1; InitGLES(); diff --git a/src/common/rendering/gles/gles_hwtexture.cpp b/src/common/rendering/gles/gles_hwtexture.cpp index 00370481b..a342f24c2 100644 --- a/src/common/rendering/gles/gles_hwtexture.cpp +++ b/src/common/rendering/gles/gles_hwtexture.cpp @@ -34,7 +34,7 @@ */ #include "gles_system.h" -#include "templates.h" + #include "c_cvars.h" #include "hw_material.h" diff --git a/src/common/rendering/gles/gles_postprocess.cpp b/src/common/rendering/gles/gles_postprocess.cpp index a618c3b2e..b53de2f50 100644 --- a/src/common/rendering/gles/gles_postprocess.cpp +++ b/src/common/rendering/gles/gles_postprocess.cpp @@ -32,7 +32,7 @@ #include "flatvertices.h" #include "r_videoscale.h" #include "v_video.h" -#include "templates.h" + #include "hw_vrmodes.h" #include "v_draw.h" @@ -159,7 +159,7 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma) mPresentShader->Uniforms.SetData(); - for (int n = 0; n < mPresentShader->Uniforms.mFields.size(); n++) + for (size_t n = 0; n < mPresentShader->Uniforms.mFields.size(); n++) { int index = -1; UniformFieldDesc desc = mPresentShader->Uniforms.mFields[n]; @@ -175,6 +175,8 @@ void FGLRenderer::DrawPresentTexture(const IntRect &box, bool applyGamma) case UniformType::Vec2: glUniform2fv(loc,1 , ((GLfloat*)(((char*)(&mPresentShader->Uniforms)) + desc.Offset))); break; + default: + break; } } diff --git a/src/common/rendering/gles/gles_postprocessstate.cpp b/src/common/rendering/gles/gles_postprocessstate.cpp index 216406125..ea8921837 100644 --- a/src/common/rendering/gles/gles_postprocessstate.cpp +++ b/src/common/rendering/gles/gles_postprocessstate.cpp @@ -19,7 +19,7 @@ ** 3. This notice may not be removed or altered from any source distribution. */ -#include "templates.h" + #include "gles_system.h" #include "gles_postprocessstate.h" diff --git a/src/common/rendering/gles/gles_renderbuffers.cpp b/src/common/rendering/gles/gles_renderbuffers.cpp index 91f8ce462..1d8147ae1 100644 --- a/src/common/rendering/gles/gles_renderbuffers.cpp +++ b/src/common/rendering/gles/gles_renderbuffers.cpp @@ -28,7 +28,7 @@ #include "gles_postprocessstate.h" #include "gles_shaderprogram.h" #include "gles_buffers.h" -#include "templates.h" + #include EXTERN_CVAR(Int, gl_debug_level) diff --git a/src/common/rendering/gles/gles_renderstate.cpp b/src/common/rendering/gles/gles_renderstate.cpp index 78bfc23de..961ec8121 100644 --- a/src/common/rendering/gles/gles_renderstate.cpp +++ b/src/common/rendering/gles/gles_renderstate.cpp @@ -25,7 +25,7 @@ ** */ -#include "templates.h" + #include "gles_system.h" #include "hw_cvars.h" #include "flatvertices.h" @@ -35,6 +35,9 @@ #include "gles_renderbuffers.h" #include "gles_hwtexture.h" #include "gles_buffers.h" +#include "gles_renderer.h" +#include "gles_samplers.h" + #include "hw_clock.h" #include "printf.h" @@ -116,13 +119,13 @@ bool FGLRenderState::ApplyShader() addLights = (int(lightPtr[3]) - int(lightPtr[2])) / LIGHT_VEC4_NUM; // Here we limit the number of lights, but dont' change the light data so priority has to be mod, sub then add - if (modLights > gles.maxlights) + if (modLights > (int)gles.maxlights) modLights = gles.maxlights; - if (modLights + subLights > gles.maxlights) + if (modLights + subLights > (int)gles.maxlights) subLights = gles.maxlights - modLights; - if (modLights + subLights + addLights > gles.maxlights) + if (modLights + subLights + addLights > (int)gles.maxlights) addLights = gles.maxlights - modLights - subLights; totalLights = modLights + subLights + addLights; @@ -332,7 +335,7 @@ bool FGLRenderState::ApplyShader() // Calculate the total number of vec4s we need int totalVectors = totalLights * LIGHT_VEC4_NUM; - if (totalVectors > gles.numlightvectors) + if (totalVectors > (int)gles.numlightvectors) totalVectors = gles.numlightvectors; glUniform4fv(activeShader->cur->lights_index, totalVectors, lightPtr); @@ -479,6 +482,7 @@ void FGLRenderState::ApplyMaterial(FMaterial *mat, int clampmode, int translatio for (int i = 1; i < 3; i++) { auto systex = static_cast(mat->GetLayer(i, translation, &layer)); + GLRenderer->mSamplerManager->Bind(i, CLAMP_NONE, 255); systex->Bind(i, false); maxbound = i; } @@ -720,10 +724,13 @@ void FGLRenderState::ClearScreen() bool FGLRenderState::SetDepthClamp(bool on) { bool res = mLastDepthClamp; - /* - if (!on) glDisable(GL_DEPTH_CLAMP); - else glEnable(GL_DEPTH_CLAMP); - */ + + if (gles.depthClampAvailable) + { + if (!on) glDisable(GL_DEPTH_CLAMP); + else glEnable(GL_DEPTH_CLAMP); + } + mLastDepthClamp = on; return res; } diff --git a/src/common/rendering/gles/gles_renderstate.h b/src/common/rendering/gles/gles_renderstate.h index 7b7768541..4dd8516ec 100644 --- a/src/common/rendering/gles/gles_renderstate.h +++ b/src/common/rendering/gles/gles_renderstate.h @@ -109,7 +109,7 @@ public: void EnableDrawBuffers(int count, bool apply = false) override { /* - count = std::min(count, 3); + count = min(count, 3); if (mNumDrawBuffers != count) { static GLenum buffers[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; diff --git a/src/common/rendering/gles/gles_samplers.cpp b/src/common/rendering/gles/gles_samplers.cpp index 1e3b16d2d..c088657c7 100644 --- a/src/common/rendering/gles/gles_samplers.cpp +++ b/src/common/rendering/gles/gles_samplers.cpp @@ -119,8 +119,26 @@ uint8_t FSamplerManager::Bind(int texunit, int num, int lastval) break; case CLAMP_NOFILTER: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + break; + case CLAMP_NOFILTER_X: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + break; + case CLAMP_NOFILTER_Y: + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + break; + case CLAMP_NOFILTER_XY: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); diff --git a/src/common/rendering/gles/gles_shaderprogram.cpp b/src/common/rendering/gles/gles_shaderprogram.cpp index 26906f57a..6aa9ec172 100644 --- a/src/common/rendering/gles/gles_shaderprogram.cpp +++ b/src/common/rendering/gles/gles_shaderprogram.cpp @@ -272,7 +272,7 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program Uniforms.UniformLocation.resize(Uniforms.mFields.size()); - for (int n = 0; n < Uniforms.mFields.size(); n++) + for (size_t n = 0; n < Uniforms.mFields.size(); n++) { int index = -1; UniformFieldDesc desc = Uniforms.mFields[n]; diff --git a/src/common/rendering/gles/gles_shaderprogram.h b/src/common/rendering/gles/gles_shaderprogram.h index a8dc97428..e46418054 100644 --- a/src/common/rendering/gles/gles_shaderprogram.h +++ b/src/common/rendering/gles/gles_shaderprogram.h @@ -88,7 +88,7 @@ public: void SetData() { if (mBuffer != nullptr) - mBuffer->SetData(sizeof(T), &Values); + mBuffer->SetData(sizeof(T), &Values, BufferUsageType::Static); } IDataBuffer* GetBuffer() const diff --git a/src/common/rendering/gles/gles_system.cpp b/src/common/rendering/gles/gles_system.cpp index a01b8b92c..79f6e0a48 100644 --- a/src/common/rendering/gles/gles_system.cpp +++ b/src/common/rendering/gles/gles_system.cpp @@ -62,7 +62,6 @@ static PROC(WINAPI* getprocaddress)(LPCSTR name); static void* LoadGLES2Proc(const char* name) { - HINSTANCE hGetProcIDDLL = LoadLibraryA("libGLESv2.dll"); int error = GetLastError(); @@ -71,6 +70,7 @@ static void* LoadGLES2Proc(const char* name) if (!addr) { //exit(1); + return nullptr; } else { @@ -182,10 +182,12 @@ namespace OpenGLESRenderer #if USE_GLES2 gles.depthStencilAvailable = CheckExtension("GL_OES_packed_depth_stencil"); gles.npotAvailable = CheckExtension("GL_OES_texture_npot"); + gles.depthClampAvailable = CheckExtension("GL_EXT_depth_clamp"); #else gles.depthStencilAvailable = true; gles.npotAvailable = true; gles.useMappedBuffers = true; + gles.depthClampAvailable = true; #endif gles.numlightvectors = (gles.maxlights * LIGHT_VEC4_NUM); diff --git a/src/common/rendering/gles/gles_system.h b/src/common/rendering/gles/gles_system.h index 021499362..d7f6ed139 100644 --- a/src/common/rendering/gles/gles_system.h +++ b/src/common/rendering/gles/gles_system.h @@ -42,6 +42,7 @@ GLAPI PFNGLUNMAPBUFFEROESPROC glUnmapBuffer; #define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 #define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 #define GL_BGRA 0x80E1 +#define GL_DEPTH_CLAMP 0x864F #else #include "gl_load/gl_load.h" @@ -69,6 +70,7 @@ namespace OpenGLESRenderer bool depthStencilAvailable; bool npotAvailable; bool forceGLSLv100; + bool depthClampAvailable; int max_texturesize; char* vendorstring; char* modelstring; diff --git a/src/common/rendering/hwrenderer/data/buffers.h b/src/common/rendering/hwrenderer/data/buffers.h index 79f7db8c5..95116d993 100644 --- a/src/common/rendering/hwrenderer/data/buffers.h +++ b/src/common/rendering/hwrenderer/data/buffers.h @@ -47,6 +47,14 @@ struct FVertexBufferAttribute int offset; }; +enum class BufferUsageType +{ + Static, // initial data is not null, staticdata is true + Stream, // initial data is not null, staticdata is false + Persistent, // initial data is null, staticdata is false + Mappable // initial data is null, staticdata is true +}; + class IBuffer { protected: @@ -58,7 +66,7 @@ public: IBuffer &operator=(const IBuffer &) = delete; virtual ~IBuffer() = default; - virtual void SetData(size_t size, const void *data, bool staticdata = true) = 0; + virtual void SetData(size_t size, const void *data, BufferUsageType type) = 0; virtual void SetSubData(size_t offset, size_t size, const void *data) = 0; virtual void *Lock(unsigned int size) = 0; virtual void Unlock() = 0; diff --git a/src/common/rendering/hwrenderer/data/flatvertices.cpp b/src/common/rendering/hwrenderer/data/flatvertices.cpp index 72c4504f9..210b9c64e 100644 --- a/src/common/rendering/hwrenderer/data/flatvertices.cpp +++ b/src/common/rendering/hwrenderer/data/flatvertices.cpp @@ -81,7 +81,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height, int pipelineNbr): mIndexBuffer = screen->CreateIndexBuffer(); int data[4] = {}; - mIndexBuffer->SetData(4, data); // On Vulkan this may not be empty, so set some dummy defaults to avoid crashes. + mIndexBuffer->SetData(4, data, BufferUsageType::Static); // On Vulkan this may not be empty, so set some dummy defaults to avoid crashes. for (int n = 0; n < mPipelineNbr; n++) @@ -89,7 +89,7 @@ FFlatVertexBuffer::FFlatVertexBuffer(int width, int height, int pipelineNbr): mVertexBufferPipeline[n] = screen->CreateVertexBuffer(); unsigned int bytesize = BUFFER_SIZE * sizeof(FFlatVertex); - mVertexBufferPipeline[n]->SetData(bytesize, nullptr, false); + mVertexBufferPipeline[n]->SetData(bytesize, nullptr, BufferUsageType::Persistent); static const FVertexBufferAttribute format[] = { { 0, VATTR_VERTEX, VFmt_Float3, (int)myoffsetof(FFlatVertex, x) }, diff --git a/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp b/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp index e0283d58e..9f7bb66c2 100644 --- a/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp +++ b/src/common/rendering/hwrenderer/data/hw_lightbuffer.cpp @@ -64,7 +64,7 @@ FLightBuffer::FLightBuffer(int pipelineNbr): for (int n = 0; n < mPipelineNbr; n++) { mBufferPipeline[n] = screen->CreateDataBuffer(LIGHTBUF_BINDINGPOINT, mBufferType, false); - mBufferPipeline[n]->SetData(mByteSize, nullptr, false); + mBufferPipeline[n]->SetData(mByteSize, nullptr, BufferUsageType::Persistent); } Clear(); diff --git a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp index c5e5fb09b..26eaa2d2c 100644 --- a/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp +++ b/src/common/rendering/hwrenderer/data/hw_shadowmap.cpp @@ -117,7 +117,7 @@ void IShadowMap::UploadLights() if (mLightList == nullptr) mLightList = screen->CreateDataBuffer(LIGHTLIST_BINDINGPOINT, true, false); - mLightList->SetData(sizeof(float) * mLights.Size(), &mLights[0]); + mLightList->SetData(sizeof(float) * mLights.Size(), &mLights[0], BufferUsageType::Stream); } @@ -129,11 +129,11 @@ void IShadowMap::UploadAABBTree() if (!mNodesBuffer) mNodesBuffer = screen->CreateDataBuffer(LIGHTNODES_BINDINGPOINT, true, false); - mNodesBuffer->SetData(mAABBTree->NodesSize(), mAABBTree->Nodes()); + mNodesBuffer->SetData(mAABBTree->NodesSize(), mAABBTree->Nodes(), BufferUsageType::Static); if (!mLinesBuffer) mLinesBuffer = screen->CreateDataBuffer(LIGHTLINES_BINDINGPOINT, true, false); - mLinesBuffer->SetData(mAABBTree->LinesSize(), mAABBTree->Lines()); + mLinesBuffer->SetData(mAABBTree->LinesSize(), mAABBTree->Lines(), BufferUsageType::Static); } else if (mAABBTree->Update()) { diff --git a/src/common/rendering/hwrenderer/data/hw_skydome.cpp b/src/common/rendering/hwrenderer/data/hw_skydome.cpp index 5d5ee8000..9bbe5787f 100644 --- a/src/common/rendering/hwrenderer/data/hw_skydome.cpp +++ b/src/common/rendering/hwrenderer/data/hw_skydome.cpp @@ -98,7 +98,7 @@ std::pair& R_GetSkyCapColor(FGameTexture* tex) const uint32_t* buffer = (const uint32_t*)bitmap.GetPixels(); if (buffer) { - sky.Colors.first = averageColor((uint32_t*)buffer, w * MIN(30, h), 0); + sky.Colors.first = averageColor((uint32_t*)buffer, w * min(30, h), 0); if (h > 30) { sky.Colors.second = averageColor(((uint32_t*)buffer) + (h - 30) * w, w * 30, 0); @@ -130,7 +130,7 @@ FSkyVertexBuffer::FSkyVertexBuffer() { 0, VATTR_COLOR, VFmt_Byte4, (int)myoffsetof(FSkyVertex, color) } }; mVertexBuffer->SetFormat(1, 3, sizeof(FSkyVertex), format); - mVertexBuffer->SetData(mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], true); + mVertexBuffer->SetData(mVertices.Size() * sizeof(FSkyVertex), &mVertices[0], BufferUsageType::Static); } FSkyVertexBuffer::~FSkyVertexBuffer() diff --git a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp index c37306b8a..89a5a8436 100644 --- a/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp +++ b/src/common/rendering/hwrenderer/data/hw_viewpointbuffer.cpp @@ -43,7 +43,7 @@ HWViewpointBuffer::HWViewpointBuffer(int pipelineNbr): for (int n = 0; n < mPipelineNbr; n++) { mBufferPipeline[n] = screen->CreateDataBuffer(VIEWPOINT_BINDINGPOINT, false, true); - mBufferPipeline[n]->SetData(mByteSize, nullptr, false); + mBufferPipeline[n]->SetData(mByteSize, nullptr, BufferUsageType::Persistent); } Clear(); diff --git a/src/common/rendering/hwrenderer/data/shaderuniforms.h b/src/common/rendering/hwrenderer/data/shaderuniforms.h index 2543b52b1..92995fcaa 100644 --- a/src/common/rendering/hwrenderer/data/shaderuniforms.h +++ b/src/common/rendering/hwrenderer/data/shaderuniforms.h @@ -129,7 +129,7 @@ public: void SetData() { if (mBuffer != nullptr) - mBuffer->SetData(sizeof(T), &Values); + mBuffer->SetData(sizeof(T), &Values, BufferUsageType::Static); } IDataBuffer* GetBuffer() const diff --git a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp index 219bb9bd6..5034b7935 100644 --- a/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp +++ b/src/common/rendering/hwrenderer/postprocessing/hw_postprocess.cpp @@ -26,7 +26,7 @@ #include "hwrenderer/postprocessing/hw_postprocessshader.h" #include #include "texturemanager.h" -#include "templates.h" + #include "stats.h" Postprocess hw_postprocess; @@ -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/src/common/rendering/i_modelvertexbuffer.h b/src/common/rendering/i_modelvertexbuffer.h index 170291511..929826ca9 100644 --- a/src/common/rendering/i_modelvertexbuffer.h +++ b/src/common/rendering/i_modelvertexbuffer.h @@ -1,6 +1,6 @@ #pragma once -#include "templates.h" + struct FModelVertex { diff --git a/src/common/rendering/polyrenderer/backend/poly_buffers.cpp b/src/common/rendering/polyrenderer/backend/poly_buffers.cpp index 82c336e2a..10ebef0d0 100644 --- a/src/common/rendering/polyrenderer/backend/poly_buffers.cpp +++ b/src/common/rendering/polyrenderer/backend/poly_buffers.cpp @@ -56,7 +56,7 @@ void PolyBuffer::Reset() { } -void PolyBuffer::SetData(size_t size, const void *data, bool staticdata) +void PolyBuffer::SetData(size_t size, const void *data, BufferUsageType usage) { mData.resize(size); map = mData.data(); diff --git a/src/common/rendering/polyrenderer/backend/poly_buffers.h b/src/common/rendering/polyrenderer/backend/poly_buffers.h index 2f3d2cc74..c364586fa 100644 --- a/src/common/rendering/polyrenderer/backend/poly_buffers.h +++ b/src/common/rendering/polyrenderer/backend/poly_buffers.h @@ -20,7 +20,7 @@ public: static void ResetAll(); void Reset(); - void SetData(size_t size, const void *data, bool staticdata) override; + void SetData(size_t size, const void *data, BufferUsageType usage) override; void SetSubData(size_t offset, size_t size, const void *data) override; void Resize(size_t newsize) override; diff --git a/src/common/rendering/polyrenderer/backend/poly_framebuffer.cpp b/src/common/rendering/polyrenderer/backend/poly_framebuffer.cpp index a71523a46..cbe49da6f 100644 --- a/src/common/rendering/polyrenderer/backend/poly_framebuffer.cpp +++ b/src/common/rendering/polyrenderer/backend/poly_framebuffer.cpp @@ -22,7 +22,7 @@ #include "v_video.h" #include "m_png.h" -#include "templates.h" + #include "r_videoscale.h" #include "i_time.h" #include "v_text.h" @@ -111,7 +111,7 @@ void PolyFrameBuffer::InitializeState() mScreenQuad.VertexBuffer->SetFormat(1, 3, sizeof(ScreenQuadVertex), format); mScreenQuad.IndexBuffer = screen->CreateIndexBuffer(); - mScreenQuad.IndexBuffer->SetData(6 * sizeof(uint32_t), indices, false); + mScreenQuad.IndexBuffer->SetData(6 * sizeof(uint32_t), indices, BufferUsageType::Stream); CheckCanvas(); } @@ -219,8 +219,8 @@ void PolyFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::functionGetWidth(), image->GetWidth()); - bounds.height = std::min(tex->GetHeight(), image->GetHeight()); + bounds.width = min(tex->GetWidth(), image->GetWidth()); + bounds.height = min(tex->GetHeight(), image->GetHeight()); renderFunc(bounds); @@ -254,7 +254,7 @@ void PolyFrameBuffer::PostProcessScene(bool swscene, int fixedcm, float flash, c { 0.0f, (float)mScreenViewport.height, 0.0f, 1.0f }, { (float)mScreenViewport.width, (float)mScreenViewport.height, 1.0f, 1.0f } }; - mScreenQuad.VertexBuffer->SetData(4 * sizeof(ScreenQuadVertex), vertices, false); + mScreenQuad.VertexBuffer->SetData(4 * sizeof(ScreenQuadVertex), vertices, BufferUsageType::Stream); mRenderState->SetVertexBuffer(mScreenQuad.VertexBuffer, 0, 0); mRenderState->SetIndexBuffer(mScreenQuad.IndexBuffer); diff --git a/src/common/rendering/polyrenderer/backend/poly_hwtexture.cpp b/src/common/rendering/polyrenderer/backend/poly_hwtexture.cpp index 0e56303fe..3b931aa46 100644 --- a/src/common/rendering/polyrenderer/backend/poly_hwtexture.cpp +++ b/src/common/rendering/polyrenderer/backend/poly_hwtexture.cpp @@ -20,7 +20,7 @@ ** */ -#include "templates.h" + #include "c_cvars.h" #include "hw_material.h" #include "hw_cvars.h" diff --git a/src/common/rendering/polyrenderer/backend/poly_renderstate.cpp b/src/common/rendering/polyrenderer/backend/poly_renderstate.cpp index 14077e489..38411e559 100644 --- a/src/common/rendering/polyrenderer/backend/poly_renderstate.cpp +++ b/src/common/rendering/polyrenderer/backend/poly_renderstate.cpp @@ -23,7 +23,7 @@ #include "polyrenderer/backend/poly_renderstate.h" #include "polyrenderer/backend/poly_framebuffer.h" #include "polyrenderer/backend/poly_hwtexture.h" -#include "templates.h" + #include "hw_skydome.h" #include "hw_viewpointuniforms.h" #include "hw_lightbuffer.h" diff --git a/src/common/rendering/polyrenderer/drawers/poly_thread.cpp b/src/common/rendering/polyrenderer/drawers/poly_thread.cpp index 338b12139..502705ca5 100644 --- a/src/common/rendering/polyrenderer/drawers/poly_thread.cpp +++ b/src/common/rendering/polyrenderer/drawers/poly_thread.cpp @@ -21,7 +21,7 @@ */ #include -#include "templates.h" + #include "filesystem.h" #include "v_video.h" @@ -100,10 +100,10 @@ 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.right = MIN(MIN(viewport_x + viewport_width, scissor.right), dest_width); - clip.bottom = MIN(MIN(viewport_y + viewport_height, scissor.bottom), dest_height); + 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); } void PolyTriangleThreadData::PushStreamData(const StreamData &data, const PolyPushConstants &constants) @@ -206,11 +206,11 @@ void PolyTriangleThreadData::SetStencil(int stencilRef, int op) StencilTestValue = stencilRef; if (op == SOP_Increment) { - StencilWriteValue = MIN(stencilRef + 1, (int)255); + StencilWriteValue = min(stencilRef + 1, (int)255); } else if (op == SOP_Decrement) { - StencilWriteValue = MAX(stencilRef - 1, (int)0); + StencilWriteValue = max(stencilRef - 1, (int)0); } else // SOP_Keep { @@ -453,8 +453,8 @@ void PolyTriangleThreadData::DrawShadedLine(const ShadedTriVertex *const* vert) { float clipdistance1 = clipdistance[0 * numclipdistances + p]; float clipdistance2 = clipdistance[1 * numclipdistances + p]; - if (clipdistance1 < 0.0f) t1 = MAX(-clipdistance1 / (clipdistance2 - clipdistance1), t1); - if (clipdistance2 < 0.0f) t2 = MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), t2); + if (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,8 +792,8 @@ 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 t2 = (clipdistance2 < 0.0f) ? MIN(1.0f + clipdistance2 / (clipdistance1 - clipdistance2), 1.0f) : 1.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 for (int k = 0; k < 3; k++) diff --git a/src/common/rendering/polyrenderer/drawers/poly_thread.h b/src/common/rendering/polyrenderer/drawers/poly_thread.h index 8d7b8bce6..abaa43e32 100644 --- a/src/common/rendering/polyrenderer/drawers/poly_thread.h +++ b/src/common/rendering/polyrenderer/drawers/poly_thread.h @@ -85,16 +85,16 @@ 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; } int count_for_thread(int first_line, int count) { - count = MIN(count, numa_end_y - first_line); + count = min(count, numa_end_y - first_line); int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; - return MAX(c, 0); + return max(c, 0); } struct Scanline diff --git a/src/common/rendering/polyrenderer/drawers/poly_triangle.cpp b/src/common/rendering/polyrenderer/drawers/poly_triangle.cpp index 986ac946a..8c142a06d 100644 --- a/src/common/rendering/polyrenderer/drawers/poly_triangle.cpp +++ b/src/common/rendering/polyrenderer/drawers/poly_triangle.cpp @@ -21,7 +21,7 @@ */ #include -#include "templates.h" + #include "filesystem.h" #include "v_video.h" diff --git a/src/common/rendering/polyrenderer/drawers/screen_blend.cpp b/src/common/rendering/polyrenderer/drawers/screen_blend.cpp index afe540289..536acb7b0 100644 --- a/src/common/rendering/polyrenderer/drawers/screen_blend.cpp +++ b/src/common/rendering/polyrenderer/drawers/screen_blend.cpp @@ -336,10 +336,10 @@ void BlendColorAdd_Src_One(int y, int x0, int x1, PolyTriangleThreadData* thread uint32_t srcscale = APART(src); srcscale += srcscale >> 7; - uint32_t a = MIN((((APART(src) * srcscale) + 127) >> 8) + APART(dst), 255); - uint32_t r = MIN((((RPART(src) * srcscale) + 127) >> 8) + RPART(dst), 255); - uint32_t g = MIN((((GPART(src) * srcscale) + 127) >> 8) + GPART(dst), 255); - uint32_t b = MIN((((BPART(src) * srcscale) + 127) >> 8) + BPART(dst), 255); + uint32_t a = min((((APART(src) * srcscale) + 127) >> 8) + APART(dst), 255); + uint32_t r = min((((RPART(src) * srcscale) + 127) >> 8) + RPART(dst), 255); + uint32_t g = min((((GPART(src) * srcscale) + 127) >> 8) + GPART(dst), 255); + uint32_t b = min((((BPART(src) * srcscale) + 127) >> 8) + BPART(dst), 255); line[x] = MAKEARGB(a, r, g, b); } @@ -382,10 +382,10 @@ void BlendColorAdd_SrcCol_One(int y, int x0, int x1, PolyTriangleThreadData* thr srcscale_g += srcscale_g >> 7; srcscale_b += srcscale_b >> 7; - uint32_t a = MIN((((APART(src) * srcscale_a) + 127) >> 8) + APART(dst), 255); - uint32_t r = MIN((((RPART(src) * srcscale_r) + 127) >> 8) + RPART(dst), 255); - uint32_t g = MIN((((GPART(src) * srcscale_g) + 127) >> 8) + GPART(dst), 255); - uint32_t b = MIN((((BPART(src) * srcscale_b) + 127) >> 8) + BPART(dst), 255); + uint32_t a = min((((APART(src) * srcscale_a) + 127) >> 8) + APART(dst), 255); + uint32_t r = min((((RPART(src) * srcscale_r) + 127) >> 8) + RPART(dst), 255); + uint32_t g = min((((GPART(src) * srcscale_g) + 127) >> 8) + GPART(dst), 255); + uint32_t b = min((((BPART(src) * srcscale_b) + 127) >> 8) + BPART(dst), 255); line[x] = MAKEARGB(a, r, g, b); } @@ -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/src/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp b/src/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp index 5aa4855d6..6cb9ee2cb 100644 --- a/src/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp +++ b/src/common/rendering/polyrenderer/drawers/screen_scanline_setup.cpp @@ -21,7 +21,7 @@ */ #include -#include "templates.h" + #include "poly_thread.h" #include "screen_scanline_setup.h" #include @@ -124,7 +124,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread) // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) __m128 Lx = _mm_sub_ps(lightposX, _mm_loadu_ps(&worldposX[x])); __m128 Ly = _mm_sub_ps(lightposY, _mm_loadu_ps(&worldposY[x])); __m128 Lz = _mm_sub_ps(lightposZ, _mm_loadu_ps(&worldposZ[x])); @@ -179,7 +179,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread) // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) float Lx = lightposX - worldposX[x]; float Ly = lightposY - worldposY[x]; float Lz = lightposZ - worldposZ[x]; @@ -191,7 +191,7 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread) float rcp_dist = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(dist2))); #endif float dist = dist2 * rcp_dist; - float distance_attenuation = 256.0f - MIN(dist * light_radius, 256.0f); + float distance_attenuation = 256.0f - min(dist * light_radius, 256.0f); // The simple light type float simple_attenuation = distance_attenuation; @@ -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); @@ -211,9 +211,9 @@ static void WriteDynLightArray(int x0, int x1, PolyTriangleThreadData* thread) lit_b += (BPART(light_color) * attenuation) >> 8; } - lit_r = MIN(lit_r, 255); - lit_g = MIN(lit_g, 255); - lit_b = MIN(lit_b, 255); + lit_r = min(lit_r, 255); + lit_g = min(lit_g, 255); + lit_b = min(lit_b, 255); lightarray[x] = MAKEARGB(lit_a, lit_r, lit_g, lit_b); // Palette version: @@ -255,7 +255,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar uint32_t* lightarray = thread->scanline.lightarray; for (int x = x0; x < x1; x++) { - uint32_t l = MIN(lightpos >> 8, 256); + uint32_t l = min(lightpos >> 8, 256); uint32_t r = vColorR[x]; uint32_t g = vColorG[x]; @@ -273,9 +273,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar g += (uint32_t)(constants->uDynLightColor.Y * 255.0f); b += (uint32_t)(constants->uDynLightColor.Z * 255.0f); - r = MIN(r, 255); - g = MIN(g, 255); - b = MIN(b, 255); + r = min(r, 255); + g = min(g, 255); + b = min(b, 255); } lightarray[x] = MAKEARGB(a, r, g, b); @@ -287,7 +287,7 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar uint32_t* lightarray = thread->scanline.lightarray; for (int x = x0; x < x1; x++) { - uint32_t l = MIN((FRACUNIT - clamp(shade - MIN(maxvis, lightpos), 0, maxlight)) >> 8, 256); + uint32_t l = min((FRACUNIT - clamp(shade - min(maxvis, lightpos), 0, maxlight)) >> 8, 256); uint32_t r = vColorR[x]; uint32_t g = vColorG[x]; uint32_t b = vColorB[x]; @@ -304,9 +304,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar g += (uint32_t)(constants->uDynLightColor.Y * 255.0f); b += (uint32_t)(constants->uDynLightColor.Z * 255.0f); - r = MIN(r, 255); - g = MIN(g, 255); - b = MIN(b, 255); + r = min(r, 255); + g = min(g, 255); + b = min(b, 255); } lightarray[x] = MAKEARGB(a, r, g, b); @@ -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: @@ -365,9 +365,9 @@ static void WriteLightArray(int y, int x0, int x1, const TriDrawTriangleArgs* ar g += (uint32_t)(constants->uDynLightColor.Y * 255.0f); b += (uint32_t)(constants->uDynLightColor.Z * 255.0f); - r = MIN(r, 255); - g = MIN(g, 255); - b = MIN(b, 255); + r = min(r, 255); + g = min(g, 255); + b = min(b, 255); } lightarray[x] = MAKEARGB(a, r, g, b); diff --git a/src/common/rendering/polyrenderer/drawers/screen_shader.cpp b/src/common/rendering/polyrenderer/drawers/screen_shader.cpp index 7e225bef1..00ba5d743 100644 --- a/src/common/rendering/polyrenderer/drawers/screen_shader.cpp +++ b/src/common/rendering/polyrenderer/drawers/screen_shader.cpp @@ -21,7 +21,7 @@ */ #include -#include "templates.h" + #include "poly_thread.h" #include "screen_scanline_setup.h" #include @@ -291,9 +291,9 @@ static void FuncNormal_AddColor(int x0, int x1, PolyTriangleThreadData* thread) uint32_t texel = fragcolor[x]; fragcolor[x] = MAKEARGB( APART(texel), - MIN(r + RPART(texel), (uint32_t)255), - MIN(g + GPART(texel), (uint32_t)255), - MIN(b + BPART(texel), (uint32_t)255)); + min(r + RPART(texel), (uint32_t)255), + min(g + GPART(texel), (uint32_t)255), + min(b + BPART(texel), (uint32_t)255)); } } @@ -309,9 +309,9 @@ static void FuncNormal_AddObjectColor(int x0, int x1, PolyTriangleThreadData* th uint32_t texel = fragcolor[x]; fragcolor[x] = MAKEARGB( APART(texel), - MIN((r * RPART(texel)) >> 8, (uint32_t)255), - MIN((g * GPART(texel)) >> 8, (uint32_t)255), - MIN((b * BPART(texel)) >> 8, (uint32_t)255)); + min((r * RPART(texel)) >> 8, (uint32_t)255), + min((g * GPART(texel)) >> 8, (uint32_t)255), + min((b * BPART(texel)) >> 8, (uint32_t)255)); } } @@ -331,9 +331,9 @@ static void FuncNormal_AddObjectColor2(int x0, int x1, PolyTriangleThreadData* t uint32_t texel = fragcolor[x]; fragcolor[x] = MAKEARGB( APART(texel), - MIN((r * RPART(texel)) >> 8, (uint32_t)255), - MIN((g * GPART(texel)) >> 8, (uint32_t)255), - MIN((b * BPART(texel)) >> 8, (uint32_t)255)); + min((r * RPART(texel)) >> 8, (uint32_t)255), + min((g * GPART(texel)) >> 8, (uint32_t)255), + min((b * BPART(texel)) >> 8, (uint32_t)255)); } } @@ -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);*/ @@ -594,9 +594,9 @@ static void MainFP(int x0, int x1, PolyTriangleThreadData* thread) b = (BPART(fragcolor[x]) * b + 127) >> 8; // frag.rgb = frag.rgb + uFogColor.rgb; - r = MIN(r + fogR, (uint32_t)255); - g = MIN(g + fogG, (uint32_t)255); - b = MIN(b + fogB, (uint32_t)255); + r = min(r + fogR, (uint32_t)255); + g = min(g + fogG, (uint32_t)255); + b = min(b + fogB, (uint32_t)255); fragcolor[x] = MAKEARGB(a, r, g, b); } diff --git a/src/common/rendering/polyrenderer/drawers/screen_triangle.cpp b/src/common/rendering/polyrenderer/drawers/screen_triangle.cpp index 53c9afabe..9cfa4b5c2 100644 --- a/src/common/rendering/polyrenderer/drawers/screen_triangle.cpp +++ b/src/common/rendering/polyrenderer/drawers/screen_triangle.cpp @@ -21,7 +21,7 @@ */ #include -#include "templates.h" + #include "filesystem.h" #include "v_video.h" @@ -207,17 +207,17 @@ 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); + int clipbottom = min(thread->clip.bottom, thread->numa_end_y); int topY = (int)(sortedVertices[0]->y + 0.5f); int midY = (int)(sortedVertices[1]->y + 0.5f); int bottomY = (int)(sortedVertices[2]->y + 0.5f); - topY = MAX(topY, cliptop); - midY = MIN(midY, clipbottom); - bottomY = MIN(bottomY, clipbottom); + topY = max(topY, cliptop); + midY = min(midY, clipbottom); + bottomY = min(bottomY, clipbottom); if (topY >= bottomY) return; diff --git a/src/common/rendering/r_thread.cpp b/src/common/rendering/r_thread.cpp index 0415bd40c..09ecde78b 100644 --- a/src/common/rendering/r_thread.cpp +++ b/src/common/rendering/r_thread.cpp @@ -21,7 +21,7 @@ */ #include -#include "templates.h" + #include "i_system.h" #include "filesystem.h" #include "v_video.h" diff --git a/src/common/rendering/r_thread.h b/src/common/rendering/r_thread.h index 87319cf0c..f1e49d416 100644 --- a/src/common/rendering/r_thread.h +++ b/src/common/rendering/r_thread.h @@ -27,7 +27,7 @@ #include #include #include -#include "templates.h" + #include "c_cvars.h" #include "basics.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; } @@ -86,9 +86,9 @@ public: // The number of lines to be rendered by this thread int count_for_thread(int first_line, int count) { - count = MIN(count, numa_end_y - first_line); + count = min(count, numa_end_y - first_line); int c = (count - skipped_by_thread(first_line) + num_cores - 1) / num_cores; - return MAX(c, 0); + return max(c, 0); } // Calculate the dest address for the first line to be rendered by this thread diff --git a/src/common/rendering/r_videoscale.cpp b/src/common/rendering/r_videoscale.cpp index 1f5a7bb38..f94621e9d 100644 --- a/src/common/rendering/r_videoscale.cpp +++ b/src/common/rendering/r_videoscale.cpp @@ -34,7 +34,7 @@ #include "c_dispatch.h" #include "c_cvars.h" #include "v_video.h" -#include "templates.h" + #include "r_videoscale.h" #include "cmdlib.h" #include "v_draw.h" @@ -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/src/common/rendering/v_framebuffer.cpp b/src/common/rendering/v_framebuffer.cpp index d1f148f1b..c0ebb4c25 100644 --- a/src/common/rendering/v_framebuffer.cpp +++ b/src/common/rendering/v_framebuffer.cpp @@ -186,7 +186,7 @@ void DFrameBuffer::SetViewportRects(IntRect *bounds) int screenWidth = GetWidth(); int screenHeight = GetHeight(); float scaleX, scaleY; - scaleX = std::min(clientWidth / (float)screenWidth, clientHeight / ((float)screenHeight * ViewportPixelAspect())); + scaleX = min(clientWidth / (float)screenWidth, clientHeight / ((float)screenHeight * ViewportPixelAspect())); scaleY = scaleX * ViewportPixelAspect(); mOutputLetterbox.width = (int)round(screenWidth * scaleX); mOutputLetterbox.height = (int)round(screenHeight * scaleY); diff --git a/src/common/rendering/v_video.cpp b/src/common/rendering/v_video.cpp index 047894466..4a8638593 100644 --- a/src/common/rendering/v_video.cpp +++ b/src/common/rendering/v_video.cpp @@ -61,7 +61,7 @@ #include "texturemanager.h" #include "i_interface.h" #include "v_draw.h" -#include "templates.h" + EXTERN_CVAR(Int, menu_resolution_custom_width) EXTERN_CVAR(Int, menu_resolution_custom_height) @@ -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(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/src/common/rendering/vulkan/renderer/vk_renderbuffers.cpp b/src/common/rendering/vulkan/renderer/vk_renderbuffers.cpp index aa2479721..97fd7f3bf 100644 --- a/src/common/rendering/vulkan/renderer/vk_renderbuffers.cpp +++ b/src/common/rendering/vulkan/renderer/vk_renderbuffers.cpp @@ -240,13 +240,8 @@ void VkRenderBuffers::CreateShadowmap() ImageBuilder builder; builder.setSize(gl_shadowmap_quality, 1024); - builder.setFormat(SceneNormalFormat); + builder.setFormat(VK_FORMAT_R32_SFLOAT); builder.setUsage(VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_SAMPLED_BIT); - if (!builder.isFormatSupported(fb->device, VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT)) - { - SceneNormalFormat = VK_FORMAT_R8G8B8A8_UNORM; - builder.setFormat(SceneNormalFormat); - } Shadowmap.Image = builder.create(fb->device); Shadowmap.Image->SetDebugName("VkRenderBuffers.Shadowmap"); diff --git a/src/common/rendering/vulkan/renderer/vk_renderstate.cpp b/src/common/rendering/vulkan/renderer/vk_renderstate.cpp index a2df4a28e..c5ff77831 100644 --- a/src/common/rendering/vulkan/renderer/vk_renderstate.cpp +++ b/src/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/src/common/rendering/vulkan/renderer/vk_streambuffer.cpp b/src/common/rendering/vulkan/renderer/vk_streambuffer.cpp index b393867c3..5a40be371 100644 --- a/src/common/rendering/vulkan/renderer/vk_streambuffer.cpp +++ b/src/common/rendering/vulkan/renderer/vk_streambuffer.cpp @@ -30,7 +30,7 @@ VkStreamBuffer::VkStreamBuffer(size_t structSize, size_t count) mBlockSize = static_cast((structSize + screen->uniformblockalignment - 1) / screen->uniformblockalignment * screen->uniformblockalignment); UniformBuffer = (VKDataBuffer*)GetVulkanFrameBuffer()->CreateDataBuffer(-1, false, false); - UniformBuffer->SetData(mBlockSize * count, nullptr, false); + UniformBuffer->SetData(mBlockSize * count, nullptr, BufferUsageType::Persistent); } VkStreamBuffer::~VkStreamBuffer() diff --git a/src/common/rendering/vulkan/system/vk_buffers.cpp b/src/common/rendering/vulkan/system/vk_buffers.cpp index 420be91f1..420b19f87 100644 --- a/src/common/rendering/vulkan/system/vk_buffers.cpp +++ b/src/common/rendering/vulkan/system/vk_buffers.cpp @@ -46,8 +46,13 @@ VKBuffer::~VKBuffer() mBuffer->Unmap(); auto fb = GetVulkanFrameBuffer(); - if (fb && mBuffer) - fb->FrameDeleteList.Buffers.push_back(std::move(mBuffer)); + if (fb) + { + if (mBuffer) + fb->FrameDeleteList.Buffers.push_back(std::move(mBuffer)); + if (mStaging) + fb->FrameDeleteList.Buffers.push_back(std::move(mStaging)); + } } void VKBuffer::ResetAll() @@ -64,67 +69,91 @@ void VKBuffer::Reset() mStaging.reset(); } -void VKBuffer::SetData(size_t size, const void *data, bool staticdata) +void VKBuffer::SetData(size_t size, const void *data, BufferUsageType usage) { auto fb = GetVulkanFrameBuffer(); - size = 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 (staticdata) + // 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) { + fb->FrameDeleteList.Buffers.push_back(std::move(mBuffer)); + mBuffer = {}; + } + if (mStaging) + { + fb->FrameDeleteList.Buffers.push_back(std::move(mStaging)); + mStaging = {}; + } + + if (usage == BufferUsageType::Static || usage == BufferUsageType::Stream) + { + // Note: we could recycle buffers here for the stream usage type to improve performance + mPersistent = false; - { - BufferBuilder builder; - builder.setUsage(VK_BUFFER_USAGE_TRANSFER_DST_BIT | mBufferType, VMA_MEMORY_USAGE_GPU_ONLY); - builder.setSize(size); - mBuffer = builder.create(fb->device); - } + BufferBuilder builder; + builder.setUsage(VK_BUFFER_USAGE_TRANSFER_DST_BIT | mBufferType, VMA_MEMORY_USAGE_GPU_ONLY); + builder.setSize(bufsize); + mBuffer = builder.create(fb->device); - { - BufferBuilder builder; - builder.setUsage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY); - builder.setSize(size); - mStaging = builder.create(fb->device); - } + BufferBuilder builder2; + builder2.setUsage(VK_BUFFER_USAGE_TRANSFER_SRC_BIT, VMA_MEMORY_USAGE_CPU_ONLY); + builder2.setSize(bufsize); + mStaging = builder2.create(fb->device); - void *dst = mStaging->Map(0, size); - memcpy(dst, data, size); - mStaging->Unmap(); + if (data) + { + void* dst = mStaging->Map(0, bufsize); + memcpy(dst, data, size); + mStaging->Unmap(); + } fb->GetTransferCommands()->copyBuffer(mStaging.get(), mBuffer.get()); } - else + else if (usage == BufferUsageType::Persistent) { - mPersistent = screen->BuffersArePersistent(); + mPersistent = true; BufferBuilder builder; - builder.setUsage(mBufferType, VMA_MEMORY_USAGE_UNKNOWN, mPersistent ? VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT : 0); + builder.setUsage(mBufferType, VMA_MEMORY_USAGE_UNKNOWN, VMA_ALLOCATION_CREATE_DEDICATED_MEMORY_BIT | VMA_ALLOCATION_CREATE_MAPPED_BIT); builder.setMemoryType( VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); - builder.setSize(size); + builder.setSize(bufsize); mBuffer = builder.create(fb->device); - if (mPersistent) + map = mBuffer->Map(0, bufsize); + if (data) + memcpy(map, data, size); + } + else if (usage == BufferUsageType::Mappable) + { + mPersistent = false; + + BufferBuilder builder; + builder.setUsage(mBufferType, VMA_MEMORY_USAGE_UNKNOWN, 0); + builder.setMemoryType( + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT, + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT); + builder.setSize(bufsize); + mBuffer = builder.create(fb->device); + + if (data) { - map = mBuffer->Map(0, size); - if (data) - memcpy(map, data, size); - } - else if (data) - { - void *dst = mBuffer->Map(0, size); + void* dst = mBuffer->Map(0, bufsize); memcpy(dst, data, size); mBuffer->Unmap(); } } + buffersize = size; } 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) @@ -145,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(); @@ -193,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) { @@ -214,7 +243,7 @@ void VKBuffer::Unlock() if (!mBuffer) { map = nullptr; - SetData(mStaticUpload.Size(), mStaticUpload.Data(), true); + SetData(mStaticUpload.Size(), mStaticUpload.Data(), BufferUsageType::Static); mStaticUpload.Clear(); } else if (!mPersistent) diff --git a/src/common/rendering/vulkan/system/vk_buffers.h b/src/common/rendering/vulkan/system/vk_buffers.h index d85391b3c..78f850148 100644 --- a/src/common/rendering/vulkan/system/vk_buffers.h +++ b/src/common/rendering/vulkan/system/vk_buffers.h @@ -19,7 +19,7 @@ public: static void ResetAll(); void Reset(); - void SetData(size_t size, const void *data, bool staticdata) override; + void SetData(size_t size, const void *data, BufferUsageType usage) override; void SetSubData(size_t offset, size_t size, const void *data) override; void Resize(size_t newsize) override; diff --git a/src/common/rendering/vulkan/system/vk_builders.h b/src/common/rendering/vulkan/system/vk_builders.h index 434c5758f..1ce120cb2 100644 --- a/src/common/rendering/vulkan/system/vk_builders.h +++ b/src/common/rendering/vulkan/system/vk_builders.h @@ -578,7 +578,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/src/common/rendering/vulkan/system/vk_device.cpp b/src/common/rendering/vulkan/system/vk_device.cpp index f6ce072af..be83d8937 100644 --- a/src/common/rendering/vulkan/system/vk_device.cpp +++ b/src/common/rendering/vulkan/system/vk_device.cpp @@ -377,9 +377,11 @@ VkBool32 VulkanDevice::DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT mess seenMessages.insert(msg); const char *typestr; + bool showcallstack = false; if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT) { typestr = "vulkan error"; + showcallstack = true; } else if (messageSeverity & VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT) { @@ -398,11 +400,12 @@ VkBool32 VulkanDevice::DebugCallback(VkDebugUtilsMessageSeverityFlagBitsEXT mess typestr = "vulkan"; } - Printf("\n"); + if (showcallstack) + Printf("\n"); Printf(TEXTCOLOR_RED "[%s] ", typestr); Printf(TEXTCOLOR_WHITE "%s\n", msg.GetChars()); - if (vk_debug_callstack) + if (vk_debug_callstack && showcallstack) { FString callstack = JitCaptureStackTrace(0, true); if (!callstack.IsEmpty()) diff --git a/src/common/rendering/vulkan/system/vk_framebuffer.cpp b/src/common/rendering/vulkan/system/vk_framebuffer.cpp index b8e821242..978969186 100644 --- a/src/common/rendering/vulkan/system/vk_framebuffer.cpp +++ b/src/common/rendering/vulkan/system/vk_framebuffer.cpp @@ -309,7 +309,7 @@ void VulkanFrameBuffer::WaitForCommands(bool finish, bool uploadOnly) swapChain->QueuePresent(presentImageIndex, mRenderFinishedSemaphore.get()); } - int numWaitFences = MIN(mNextSubmit, (int)maxConcurrentSubmitCount); + int numWaitFences = min(mNextSubmit, (int)maxConcurrentSubmitCount); if (numWaitFences > 0) { @@ -345,8 +345,8 @@ void VulkanFrameBuffer::RenderTextureView(FCanvasTexture* tex, std::functionGetWidth(), image->Image->width); - bounds.height = std::min(tex->GetHeight(), image->Image->height); + bounds.width = min(tex->GetWidth(), image->Image->width); + bounds.height = min(tex->GetHeight(), image->Image->height); renderFunc(bounds); @@ -703,7 +703,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; @@ -796,7 +796,7 @@ void VulkanFrameBuffer::CreateFanToTrisIndexBuffer() } FanToTrisIndexBuffer.reset(CreateIndexBuffer()); - FanToTrisIndexBuffer->SetData(sizeof(uint32_t) * data.Size(), data.Data()); + FanToTrisIndexBuffer->SetData(sizeof(uint32_t) * data.Size(), data.Data(), BufferUsageType::Static); } void VulkanFrameBuffer::UpdateShadowMap() diff --git a/src/common/rendering/vulkan/system/vk_swapchain.cpp b/src/common/rendering/vulkan/system/vk_swapchain.cpp index dcacd1620..789259695 100644 --- a/src/common/rendering/vulkan/system/vk_swapchain.cpp +++ b/src/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, min(surfaceCapabilities.maxImageExtent.width, actualExtent.width)); + actualExtent.height = max(surfaceCapabilities.minImageExtent.height, min(surfaceCapabilities.maxImageExtent.height, actualExtent.height)); if (actualExtent.width == 0 || actualExtent.height == 0) { swapChain = VK_NULL_HANDLE; @@ -176,9 +176,9 @@ bool VulkanSwapChain::CreateSwapChain(VkSwapchainKHR oldSwapChain) // When vsync is on we only want two images. This creates a slight performance penalty in exchange for reduced input latency (less mouse lag). // When vsync is off we want three images as it allows us to generate new images even during the vertical blanking period where one entry is being used by the presentation engine. if (swapChainPresentMode == VK_PRESENT_MODE_MAILBOX_KHR || swapChainPresentMode == VK_PRESENT_MODE_IMMEDIATE_KHR) - imageCount = std::min(imageCount, (uint32_t)3); + imageCount = min(imageCount, (uint32_t)3); else - imageCount = std::min(imageCount, (uint32_t)2); + imageCount = min(imageCount, (uint32_t)2); VkSwapchainCreateInfoKHR swapChainCreateInfo = {}; swapChainCreateInfo.sType = VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR; diff --git a/src/common/rendering/vulkan/textures/vk_hwtexture.cpp b/src/common/rendering/vulkan/textures/vk_hwtexture.cpp index 276f9fd09..c62a7173e 100644 --- a/src/common/rendering/vulkan/textures/vk_hwtexture.cpp +++ b/src/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"); @@ -400,14 +400,16 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state) WriteDescriptors update; MaterialLayerInfo *layer; auto systex = static_cast(GetLayer(0, state.mTranslation, &layer)); - update.addCombinedImageSampler(descriptor.get(), 0, systex->GetImage(layer->layerTexture, state.mTranslation, layer->scaleFlags)->View.get(), sampler, systex->mImage.Layout); + auto systeximage = systex->GetImage(layer->layerTexture, state.mTranslation, layer->scaleFlags); + update.addCombinedImageSampler(descriptor.get(), 0, systeximage->View.get(), sampler, systeximage->Layout); if (!(layer->scaleFlags & CTF_Indexed)) { for (int i = 1; i < numLayers; i++) { auto systex = static_cast(GetLayer(i, 0, &layer)); - update.addCombinedImageSampler(descriptor.get(), i, systex->GetImage(layer->layerTexture, 0, layer->scaleFlags)->View.get(), sampler, systex->mImage.Layout); + auto systeximage = systex->GetImage(layer->layerTexture, 0, layer->scaleFlags); + update.addCombinedImageSampler(descriptor.get(), i, systeximage->View.get(), sampler, systeximage->Layout); } } else @@ -415,7 +417,8 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state) for (int i = 1; i < 3; i++) { auto systex = static_cast(GetLayer(i, translation, &layer)); - update.addCombinedImageSampler(descriptor.get(), i, systex->GetImage(layer->layerTexture, 0, layer->scaleFlags)->View.get(), sampler, systex->mImage.Layout); + auto systeximage = systex->GetImage(layer->layerTexture, 0, layer->scaleFlags); + update.addCombinedImageSampler(descriptor.get(), i, systeximage->View.get(), sampler, systeximage->Layout); } numLayers = 3; } @@ -423,7 +426,7 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state) auto dummyImage = fb->GetRenderPassManager()->GetNullTextureView(); for (int i = numLayers; i < SHADER_MIN_REQUIRED_TEXTURE_LAYERS; i++) { - update.addCombinedImageSampler(descriptor.get(), i, dummyImage, sampler, systex->mImage.Layout); + update.addCombinedImageSampler(descriptor.get(), i, dummyImage, sampler, VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL); } update.updateSets(fb->device); diff --git a/src/common/rendering/vulkan/textures/vk_imagetransition.cpp b/src/common/rendering/vulkan/textures/vk_imagetransition.cpp index a135a3f0f..a5f289296 100644 --- a/src/common/rendering/vulkan/textures/vk_imagetransition.cpp +++ b/src/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/src/common/scripting/backend/codegen.cpp b/src/common/scripting/backend/codegen.cpp index 5be4b48be..185c79d59 100644 --- a/src/common/scripting/backend/codegen.cpp +++ b/src/common/scripting/backend/codegen.cpp @@ -43,7 +43,7 @@ #include "texturemanager.h" #include "m_random.h" #include "v_font.h" -#include "templates.h" + extern FRandom pr_exrandom; FMemArena FxAlloc(65536); @@ -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/src/common/scripting/core/symbols.cpp b/src/common/scripting/core/symbols.cpp index c6e38551f..be0b11e18 100644 --- a/src/common/scripting/core/symbols.cpp +++ b/src/common/scripting/core/symbols.cpp @@ -35,7 +35,7 @@ #include #include "dobject.h" -#include "templates.h" + #include "serializer.h" #include "types.h" #include "vm.h" @@ -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/src/common/scripting/core/types.cpp b/src/common/scripting/core/types.cpp index 260aff106..3fb97cb32 100644 --- a/src/common/scripting/core/types.cpp +++ b/src/common/scripting/core/types.cpp @@ -1702,7 +1702,7 @@ bool PArray::ReadValue(FSerializer &ar, const char *key, void *addr) const { bool readsomething = false; unsigned count = ar.ArraySize(); - unsigned loop = std::min(count, ElementCount); + unsigned loop = min(count, ElementCount); uint8_t *addrb = (uint8_t *)addr; for(unsigned i=0;iNumRegD, sfunc->NumRegF, sfunc->NumRegA, sfunc->NumRegS, sfunc->MaxParam); VMDumpConstants(dump, sfunc); diff --git a/src/common/scripting/frontend/zcc_parser.cpp b/src/common/scripting/frontend/zcc_parser.cpp index e176c646e..0d1928653 100644 --- a/src/common/scripting/frontend/zcc_parser.cpp +++ b/src/common/scripting/frontend/zcc_parser.cpp @@ -40,7 +40,7 @@ #include "version.h" #include "zcc_parser.h" #include "zcc_compile.h" -#include "templates.h" + TArray Includes; TArray IncludeLocs; diff --git a/src/common/scripting/interface/vmnatives.cpp b/src/common/scripting/interface/vmnatives.cpp index 13f3e2558..c326b2e1b 100644 --- a/src/common/scripting/interface/vmnatives.cpp +++ b/src/common/scripting/interface/vmnatives.cpp @@ -41,7 +41,7 @@ #include "c_cvars.h" #include "c_bind.h" #include "c_dispatch.h" -#include "templates.h" + #include "menu.h" #include "vm.h" #include "gstrings.h" @@ -80,7 +80,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, StatusbarToRealCoords, StatusbarTo if (numret > 1) ret[1].SetFloat(y); if (numret > 2) ret[2].SetFloat(w); if (numret > 3) ret[3].SetFloat(h); - return MIN(4, numret); + return min(4, numret); } void SBar_DrawTexture(DStatusBarCore* self, int texid, double x, double y, int flags, double alpha, double w, double h, double scaleX, double scaleY, int style, int color, int translation, double clipwidth) @@ -228,7 +228,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(DStatusBarCore, TransformRect, SBar_TransformRect) if (numret > 1) ret[1].SetFloat(y); if (numret > 2) ret[2].SetFloat(w); if (numret > 3) ret[3].SetFloat(h); - return MIN(4, numret); + return min(4, numret); } static void SBar_Fill(DStatusBarCore* self, int color, double x, double y, double w, double h, int flags) @@ -437,7 +437,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(_TexMan, GetSize, GetTextureSize) x = GetTextureSize(texid, &y); if (numret > 0) ret[0].SetInt(x); if (numret > 1) ret[1].SetInt(y); - return MIN(numret, 2); + return min(numret, 2); } //========================================================================== @@ -941,7 +941,7 @@ DEFINE_ACTION_FUNCTION(FKeyBindings, GetKeysForCommand) self->GetKeysForCommand(cmd.GetChars(), &k1, &k2); if (numret > 0) ret[0].SetInt(k1); if (numret > 1) ret[1].SetInt(k2); - return MIN(numret, 2); + return min(numret, 2); } DEFINE_ACTION_FUNCTION(FKeyBindings, GetAllKeysForCommand) diff --git a/src/common/scripting/jit/jit_runtime.cpp b/src/common/scripting/jit/jit_runtime.cpp index b0a9dc488..a646ebf9b 100644 --- a/src/common/scripting/jit/jit_runtime.cpp +++ b/src/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) @@ -803,7 +803,7 @@ static int CaptureStackTrace(int max_frames, void **out_frames) #elif defined(WIN32) // JIT isn't supported here, so just do nothing. - return 0;//return RtlCaptureStackBackTrace(0, MIN(max_frames, 32), out_frames, nullptr); + return 0;//return RtlCaptureStackBackTrace(0, min(max_frames, 32), out_frames, nullptr); #else return backtrace(out_frames, max_frames); #endif diff --git a/src/common/scripting/vm/vmframe.cpp b/src/common/scripting/vm/vmframe.cpp index 4b50f9b21..1fc82549d 100644 --- a/src/common/scripting/vm/vmframe.cpp +++ b/src/common/scripting/vm/vmframe.cpp @@ -37,7 +37,7 @@ #include "v_text.h" #include "stats.h" #include "c_dispatch.h" -#include "templates.h" + #include "vmintern.h" #include "types.h" #include "jit.h" @@ -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/src/common/statusbar/base_sbar.cpp b/src/common/statusbar/base_sbar.cpp index e63c21fb2..9ea4a6d26 100644 --- a/src/common/statusbar/base_sbar.cpp +++ b/src/common/statusbar/base_sbar.cpp @@ -35,7 +35,7 @@ #include -#include "templates.h" + #include "base_sbar.h" #include "printf.h" #include "v_draw.h" @@ -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; @@ -489,7 +489,7 @@ void DStatusBarCore::DrawGraphic(FGameTexture* tex, double x, double y, int flag if (boxwidth <= 0 || (boxheight > 0 && scale2 < scale1)) scale1 = scale2; } - else scale1 = MIN(scale1, scale2); + else scale1 = min(scale1, scale2); boxwidth = texwidth * scale1; boxheight = texheight * scale1; diff --git a/src/common/textures/animtexture.cpp b/src/common/textures/animtexture.cpp index 8f8add3f7..039021641 100644 --- a/src/common/textures/animtexture.cpp +++ b/src/common/textures/animtexture.cpp @@ -34,7 +34,7 @@ #include "animtexture.h" #include "bitmap.h" #include "texturemanager.h" -#include "templates.h" + //========================================================================== // diff --git a/src/common/textures/bitmap.h b/src/common/textures/bitmap.h index 36d520771..88df40307 100644 --- a/src/common/textures/bitmap.h +++ b/src/common/textures/bitmap.h @@ -37,7 +37,7 @@ #define __BITMAP_H__ #include "basics.h" -#include "templates.h" + #include "palentry.h" struct FCopyInfo; @@ -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; } }; @@ -473,21 +473,21 @@ struct bBlend struct bAdd { - static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = MIN((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); } + static __forceinline void OpC(uint8_t &d, uint8_t s, uint8_t a, FCopyInfo *i) { d = min((d*BLENDUNIT + s*i->alpha) >> BLENDBITS, 255); } static __forceinline void OpA(uint8_t &d, uint8_t s, FCopyInfo *i) { d = s; } static __forceinline bool ProcessAlpha0() { return false; } }; 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/src/common/textures/formats/fontchars.cpp b/src/common/textures/formats/fontchars.cpp index 44a72ca6e..a48600437 100644 --- a/src/common/textures/formats/fontchars.cpp +++ b/src/common/textures/formats/fontchars.cpp @@ -113,7 +113,7 @@ TArray FFontChar2::CreatePalettedPixels(int) if (runlen != 0) { uint8_t color = lump.ReadUInt8(); - color = MIN(color, max); + color = min(color, max); *dest_p = color; dest_p += dest_adv; x--; @@ -137,7 +137,7 @@ TArray FFontChar2::CreatePalettedPixels(int) { uint8_t color = lump.ReadUInt8(); setlen = (-code) + 1; - setval = MIN(color, max); + setval = min(color, max); } } } diff --git a/src/common/textures/formats/pngtexture.cpp b/src/common/textures/formats/pngtexture.cpp index 294e218aa..dd0976a8e 100644 --- a/src/common/textures/formats/pngtexture.cpp +++ b/src/common/textures/formats/pngtexture.cpp @@ -35,7 +35,7 @@ */ #include "files.h" -#include "templates.h" + #include "m_png.h" #include "bitmap.h" #include "imagehelpers.h" @@ -244,7 +244,7 @@ FPNGTexture::FPNGTexture (FileReader &lump, int lumpnum, int width, int height, break; case MAKE_ID('P','L','T','E'): - PaletteSize = MIN (len / 3, 256); + PaletteSize = min (len / 3, 256); StartOfPalette = (uint32_t)lump.Tell(); lump.Seek(len, FileReader::SeekCur); break; @@ -762,7 +762,7 @@ FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans) lump->Seek (len, FileReader::SeekCur); else { - PaletteSize = std::min (len / 3, 256); + PaletteSize = min (len / 3, 256); for(int i = 0; i < PaletteSize; i++) { pe[i].r = lump->ReadUInt8(); @@ -794,4 +794,4 @@ FBitmap FPNGFileTexture::GetBgraBitmap(const PalEntry *remap, int *trans) bmp.CopyPixelDataRGB(0, 0, Pixels.Data(), Width, Height, 3, pixwidth, 0, CF_RGB); } return bmp; -} +} \ No newline at end of file diff --git a/src/common/textures/formats/tgatexture.cpp b/src/common/textures/formats/tgatexture.cpp index 80c7b04a8..d2e12e1aa 100644 --- a/src/common/textures/formats/tgatexture.cpp +++ b/src/common/textures/formats/tgatexture.cpp @@ -35,7 +35,7 @@ #include "files.h" #include "filesystem.h" -#include "templates.h" + #include "bitmap.h" #include "imagehelpers.h" #include "image.h" @@ -153,7 +153,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe { b&=~128; lump.Read(data, bytesperpixel); - for (int i=MIN(Size, (b+1)); i>0; i--) + for (int i=min(Size, (b+1)); i>0; i--) { buffer[0] = data[0]; if (bytesperpixel>=2) buffer[1] = data[1]; @@ -164,7 +164,7 @@ void FTGATexture::ReadCompressed(FileReader &lump, uint8_t * buffer, int bytespe } else { - lump.Read(buffer, MIN(Size, (b+1))*bytesperpixel); + lump.Read(buffer, min(Size, (b+1))*bytesperpixel); buffer += (b+1)*bytesperpixel; } Size -= b+1; diff --git a/src/common/textures/gametexture.cpp b/src/common/textures/gametexture.cpp index 29d1ee2dd..c5979a7a9 100644 --- a/src/common/textures/gametexture.cpp +++ b/src/common/textures/gametexture.cpp @@ -37,7 +37,7 @@ #include "printf.h" #include "files.h" #include "filesystem.h" -#include "templates.h" + #include "textures.h" #include "bitmap.h" #include "colormatcher.h" diff --git a/src/common/textures/hw_ihwtexture.cpp b/src/common/textures/hw_ihwtexture.cpp index aebf387d4..296bfd40d 100644 --- a/src/common/textures/hw_ihwtexture.cpp +++ b/src/common/textures/hw_ihwtexture.cpp @@ -34,7 +34,7 @@ */ #include "hw_ihwtexture.h" -#include "templates.h" +#include "basics.h" #include "tarray.h" #include "xs_Float.h" @@ -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/src/common/textures/imagetexture.cpp b/src/common/textures/imagetexture.cpp index 5ec15c7b5..261333c98 100644 --- a/src/common/textures/imagetexture.cpp +++ b/src/common/textures/imagetexture.cpp @@ -35,7 +35,7 @@ #include "files.h" #include "filesystem.h" -#include "templates.h" + #include "bitmap.h" #include "image.h" #include "textures.h" diff --git a/src/common/textures/m_png.cpp b/src/common/textures/m_png.cpp index e58742da4..8467a5d42 100644 --- a/src/common/textures/m_png.cpp +++ b/src/common/textures/m_png.cpp @@ -246,7 +246,7 @@ bool M_AppendPNGText (FileWriter *file, const char *keyword, const char *text) { struct { uint32_t len, id; char key[80]; } head; int len = (int)strlen (text); - int keylen = std::min ((int)strlen (keyword), 79); + int keylen = min ((int)strlen (keyword), 79); uint32_t crc; head.len = BigLong(len + keylen + 1); @@ -329,7 +329,7 @@ char *M_GetPNGText (PNGHandle *png, const char *keyword) if (strncmp (keyword, png->TextChunks[i], 80) == 0) { // Woo! A match was found! - keylen = std::min (80, strlen (keyword) + 1); + keylen = min (80, strlen (keyword) + 1); textlen = strlen (png->TextChunks[i] + keylen) + 1; char *str = new char[textlen]; strcpy (str, png->TextChunks[i] + keylen); @@ -351,7 +351,7 @@ bool M_GetPNGText (PNGHandle *png, const char *keyword, char *buffer, size_t buf if (strncmp (keyword, png->TextChunks[i], 80) == 0) { // Woo! A match was found! - keylen = std::min (80, strlen (keyword) + 1); + keylen = min (80, strlen (keyword) + 1); strncpy (buffer, png->TextChunks[i] + keylen, buffsize); return true; } @@ -566,7 +566,7 @@ bool M_ReadIDAT (FileReader &file, uint8_t *buffer, int width, int height, int p if (stream.avail_in == 0 && chunklen > 0) { stream.next_in = chunkbuffer; - stream.avail_in = (uInt)file.Read (chunkbuffer, std::min(chunklen,sizeof(chunkbuffer))); + stream.avail_in = (uInt)file.Read (chunkbuffer, min(chunklen,sizeof(chunkbuffer))); chunklen -= stream.avail_in; } diff --git a/src/common/textures/texture.cpp b/src/common/textures/texture.cpp index 6d24f1154..5b88c3cef 100644 --- a/src/common/textures/texture.cpp +++ b/src/common/textures/texture.cpp @@ -37,7 +37,7 @@ #include "printf.h" #include "files.h" #include "filesystem.h" -#include "templates.h" + #include "textures.h" #include "bitmap.h" #include "colormatcher.h" @@ -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/src/common/textures/texturemanager.cpp b/src/common/textures/texturemanager.cpp index c4fcfd841..65e267b84 100644 --- a/src/common/textures/texturemanager.cpp +++ b/src/common/textures/texturemanager.cpp @@ -37,7 +37,7 @@ #include "filesystem.h" #include "printf.h" #include "c_cvars.h" -#include "templates.h" + #include "gstrings.h" #include "textures.h" #include "texturemanager.h" diff --git a/src/common/utility/basics.h b/src/common/utility/basics.h index 703a84c30..29ee19593 100644 --- a/src/common/utility/basics.h +++ b/src/common/utility/basics.h @@ -105,3 +105,4 @@ enum EStateUseFlags using std::min; using std::max; +using std::clamp; diff --git a/src/common/utility/cmdlib.cpp b/src/common/utility/cmdlib.cpp index 9551cbf42..5e43336e2 100644 --- a/src/common/utility/cmdlib.cpp +++ b/src/common/utility/cmdlib.cpp @@ -248,7 +248,7 @@ bool GetFileInfo(const char* pathname, size_t *size, time_t *time) bool res = _wstat64(wstr.c_str(), &info) == 0; #endif if (!res || (info.st_mode & S_IFDIR)) return false; - if (size) *size = info.st_size; + if (size) *size = (size_t)info.st_size; if (time) *time = info.st_mtime; return res; } @@ -866,6 +866,10 @@ FString ExpandEnvVars(const char *searchpathstring) FString NicePath(const char *path) { #ifdef _WIN32 + if (*path == '\0') + { + return FString("."); + } return ExpandEnvVars(path); #else if (path == NULL || *path == '\0') @@ -1060,7 +1064,7 @@ void md5Update(FileReader& file, MD5Context& md5, unsigned len) while (len > 0) { - t = std::min(len, sizeof(readbuf)); + t = min(len, sizeof(readbuf)); len -= t; t = (long)file.Read(readbuf, t); md5.Update(readbuf, t); diff --git a/src/common/utility/files.cpp b/src/common/utility/files.cpp index e93262214..6f915a2ce 100644 --- a/src/common/utility/files.cpp +++ b/src/common/utility/files.cpp @@ -34,7 +34,7 @@ */ #include "files.h" -#include "templates.h" // just for 'clamp' + // just for 'clamp' #include "zstring.h" diff --git a/src/common/utility/files_decompress.cpp b/src/common/utility/files_decompress.cpp index c79d762e6..7d7d65442 100644 --- a/src/common/utility/files_decompress.cpp +++ b/src/common/utility/files_decompress.cpp @@ -42,7 +42,7 @@ #include #include "files.h" -#include "templates.h" + #include "zstring.h" #include "cmdlib.h" @@ -509,7 +509,7 @@ class DecompressorLZSS : public DecompressorBase // Partial overlap: Copy in 2 or 3 chunks. do { - unsigned int copy = std::min(len, pos+1); + unsigned int copy = min(len, pos+1); memcpy(Stream.InternalBuffer, copyStart, copy); Stream.InternalBuffer += copy; Stream.InternalOut += copy; @@ -575,7 +575,7 @@ public: break; } - unsigned int copy = std::min(Stream.InternalOut, AvailOut); + unsigned int copy = min(Stream.InternalOut, AvailOut); if(copy > 0) { memcpy(Out, Stream.WindowData, copy); diff --git a/src/common/utility/palette.cpp b/src/common/utility/palette.cpp index 3b6e71e55..28115a521 100644 --- a/src/common/utility/palette.cpp +++ b/src/common/utility/palette.cpp @@ -39,7 +39,7 @@ #include "files.h" #include "filesystem.h" #include "printf.h" -#include "templates.h" + #include "m_png.h" /****************************/ @@ -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) { @@ -802,9 +802,9 @@ void UpdateSpecialColormap(PalEntry* BaseColors, unsigned int index, float r1, f BaseColors[c].g * 143 + BaseColors[c].b * 37) / 256.0; - PalEntry pe = PalEntry(std::min(255, int(r1 + intensity * r2)), - std::min(255, int(g1 + intensity * g2)), - std::min(255, int(b1 + intensity * b2))); + PalEntry pe = PalEntry(min(255, int(r1 + intensity * r2)), + min(255, int(g1 + intensity * g2)), + min(255, int(b1 + intensity * b2))); cm->Colormap[c] = BestColor((uint32_t*)BaseColors, pe.r, pe.g, pe.b); } @@ -813,9 +813,9 @@ void UpdateSpecialColormap(PalEntry* BaseColors, unsigned int index, float r1, f // This table is used by the texture composition code for (int i = 0; i < 256; i++) { - cm->GrayscaleToColor[i] = PalEntry(std::min(255, int(r1 + i * r2)), - std::min(255, int(g1 + i * g2)), - std::min(255, int(b1 + i * b2))); + cm->GrayscaleToColor[i] = PalEntry(min(255, int(r1 + i * r2)), + min(255, int(g1 + i * g2)), + min(255, int(b1 + i * b2))); } } @@ -911,7 +911,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer) fr.Seek(len, FileReader::SeekCur); else { - int PaletteSize = MIN(len, 768); + int PaletteSize = min(len, 768); fr.Read(buffer, PaletteSize); return PaletteSize / 3; } @@ -930,7 +930,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer) sc.MustGetString(); sc.MustGetNumber(); // version - ignore sc.MustGetNumber(); - int colors = MIN(256, sc.Number) * 3; + int colors = min(256, sc.Number) * 3; for (int i = 0; i < colors; i++) { sc.MustGetNumber(); @@ -944,7 +944,7 @@ int ReadPalette(int lumpnum, uint8_t* buffer) } else { - memcpy(buffer, lumpmem, MIN(768, lump.GetSize())); + memcpy(buffer, lumpmem, min(768, lump.GetSize())); return 256; } } diff --git a/src/common/utility/r_memory.cpp b/src/common/utility/r_memory.cpp index 99a75d0f7..383cdbeb4 100644 --- a/src/common/utility/r_memory.cpp +++ b/src/common/utility/r_memory.cpp @@ -21,7 +21,7 @@ */ #include -#include "templates.h" + #include "r_memory.h" #include diff --git a/src/common/utility/s_playlist.cpp b/src/common/utility/s_playlist.cpp index d284a3e90..d457d0137 100644 --- a/src/common/utility/s_playlist.cpp +++ b/src/common/utility/s_playlist.cpp @@ -37,7 +37,7 @@ #include "cmdlib.h" #include "s_playlist.h" -#include "templates.h" + #include "v_text.h" #include "files.h" diff --git a/src/common/utility/templates.h b/src/common/utility/templates.h index 3f3e596f0..22b9f3d3f 100644 --- a/src/common/utility/templates.h +++ b/src/common/utility/templates.h @@ -93,54 +93,5 @@ const ClassType *BinarySearch (const ClassType *first, int max, return NULL; } -//========================================================================== -// -// MIN -// -// Returns the minimum of a and b. -//========================================================================== - -#ifdef MIN -#undef MIN -#endif - -template -inline -const T MIN (const T a, const T b) -{ - return a < b ? a : b; -} - -//========================================================================== -// -// 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; -} - -//========================================================================== -// -// clamp -// -// Clamps in to the range [min,max]. -//========================================================================== - -template -inline constexpr -T clamp (const T in, const X min, const Y max) -{ - return in <= (T) min ? (T) min : in >= (T) max ? (T) max : in; -} #endif //__TEMPLATES_H__ 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_iwad.cpp b/src/d_iwad.cpp index 567c7df45..b1b0e88de 100644 --- a/src/d_iwad.cpp +++ b/src/d_iwad.cpp @@ -221,6 +221,24 @@ void FIWadManager::ParseIWadInfo(const char *fn, const char *data, int datasize, sc.MustGetString(); iwad->Song = sc.String; } + else if (sc.Compare("LoadLights")) + { + sc.MustGetStringName("="); + sc.MustGetNumber(); + iwad->LoadLights = sc.Number; + } + else if (sc.Compare("LoadBrightmaps")) + { + sc.MustGetStringName("="); + sc.MustGetNumber(); + iwad->LoadBrightmaps = sc.Number; + } + else if (sc.Compare("LoadWidescreen")) + { + sc.MustGetStringName("="); + sc.MustGetNumber(); + iwad->LoadWidescreen = sc.Number; + } else { sc.ScriptError("Unknown keyword '%s'", sc.String); @@ -805,6 +823,12 @@ const FIWADInfo *FIWadManager::FindIWAD(TArray &wadfiles, const char *i GameStartupInfo.BkColor = iwad_info->BkColor; GameStartupInfo.FgColor = iwad_info->FgColor; } + if (GameStartupInfo.LoadWidescreen == -1) + GameStartupInfo.LoadWidescreen = iwad_info->LoadWidescreen; + if (GameStartupInfo.LoadLights == -1) + GameStartupInfo.LoadLights = iwad_info->LoadLights; + if (GameStartupInfo.LoadBrightmaps == -1) + GameStartupInfo.LoadBrightmaps = iwad_info->LoadBrightmaps; if (GameStartupInfo.Type == 0) GameStartupInfo.Type = iwad_info->StartupType; if (GameStartupInfo.Song.IsEmpty()) GameStartupInfo.Song = iwad_info->Song; I_SetIWADInfo(); diff --git a/src/d_main.h b/src/d_main.h index e2159af64..ba614b2bb 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -90,6 +90,9 @@ struct FIWADInfo TArray Lumps; // Lump names for identification TArray DeleteLumps; // Lumps which must be deleted from the directory. int flags = 0; + int LoadWidescreen = -1; + int LoadBrightmaps = -1; + int LoadLights = -1; }; struct FFoundWadInfo 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_dumpinfo.cpp b/src/g_dumpinfo.cpp index 6cdcc593b..a026863de 100644 --- a/src/g_dumpinfo.cpp +++ b/src/g_dumpinfo.cpp @@ -390,7 +390,7 @@ CCMD(skyfog) if (argv.argc() > 1) { // Do this only on the primary level. - primaryLevel->skyfog = MAX(0, (int)strtoull(argv[1], NULL, 0)); + primaryLevel->skyfog = max(0, (int)strtoull(argv[1], NULL, 0)); } } diff --git a/src/g_game.cpp b/src/g_game.cpp index f394d1a85..dac60dbf3 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -29,7 +29,7 @@ #include #include "i_time.h" -#include "templates.h" + #include "version.h" #include "doomdef.h" #include "doomstat.h" @@ -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_level.cpp b/src/g_level.cpp index 09bf8400f..6df8b0844 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -33,7 +33,7 @@ */ #include -#include "templates.h" + #include "d_main.h" #include "g_level.h" #include "g_game.h" diff --git a/src/g_statusbar/hudmessages.cpp b/src/g_statusbar/hudmessages.cpp index ba9b7a190..ccf6174c3 100644 --- a/src/g_statusbar/hudmessages.cpp +++ b/src/g_statusbar/hudmessages.cpp @@ -32,7 +32,7 @@ ** */ -#include "templates.h" + #include "doomdef.h" #include "sbar.h" #include "c_cvars.h" @@ -340,7 +340,7 @@ void DHUDMessage::ResetText (const char *text) for (auto &line : Lines) { Height += Font->GetHeight (); - Width = MAX (Width, line.Width); + Width = max (Width, line.Width); } } @@ -751,7 +751,7 @@ void DHUDMessageTypeOnFadeOut::Serialize(FSerializer &arc) LineLen = CurrLine = 0; } - clamp(LineVisible, 0, LineLen); + LineVisible = clamp(LineVisible, 0, LineLen); } } 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/g_statusbar/shared_sbar.cpp b/src/g_statusbar/shared_sbar.cpp index e6f386b7c..d4b94f3a4 100644 --- a/src/g_statusbar/shared_sbar.cpp +++ b/src/g_statusbar/shared_sbar.cpp @@ -35,7 +35,7 @@ #include -#include "templates.h" + #include "sbar.h" #include "c_cvars.h" #include "c_dispatch.h" @@ -531,7 +531,7 @@ DVector2 DBaseStatusBar::GetHUDScale() const // Since status bars and HUDs can be designed for non 320x200 screens this needs to be factored in here. // The global scaling factors are for resources at 320x200, so if the actual ones are higher resolution // the resulting scaling factor needs to be reduced accordingly. - int realscale = MAX(1, (320 * scale) / hres); + int realscale = max(1, (320 * scale) / hres); return{ double(realscale), double(realscale * (hud_aspectscale ? 1.2 : 1.)) }; } diff --git a/src/gamedata/d_dehacked.cpp b/src/gamedata/d_dehacked.cpp index a82146ad5..8dd52cf95 100644 --- a/src/gamedata/d_dehacked.cpp +++ b/src/gamedata/d_dehacked.cpp @@ -44,7 +44,7 @@ #include #include "doomtype.h" -#include "templates.h" + #include "doomstat.h" #include "info.h" #include "d_dehacked.h" diff --git a/src/gamedata/decallib.cpp b/src/gamedata/decallib.cpp index 807945545..e765959b8 100644 --- a/src/gamedata/decallib.cpp +++ b/src/gamedata/decallib.cpp @@ -40,7 +40,7 @@ #include "m_random.h" #include "weightedlist.h" #include "statnums.h" -#include "templates.h" + #include "a_sharedglobal.h" #include "gi.h" #include "b_bot.h" diff --git a/src/gamedata/g_mapinfo.cpp b/src/gamedata/g_mapinfo.cpp index 3b823c59e..ef526b301 100644 --- a/src/gamedata/g_mapinfo.cpp +++ b/src/gamedata/g_mapinfo.cpp @@ -34,7 +34,7 @@ */ #include -#include "templates.h" + #include "g_level.h" #include "filesystem.h" #include "cmdlib.h" 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/gamedata/r_defs.h b/src/gamedata/r_defs.h index 44a0afd83..857e6448c 100644 --- a/src/gamedata/r_defs.h +++ b/src/gamedata/r_defs.h @@ -31,7 +31,7 @@ #define __R_DEFS_H__ #include "doomdef.h" -#include "templates.h" + #include "m_bbox.h" #include "dobjgc.h" #include "r_data/r_translate.h" diff --git a/src/gamedata/textures/anim_switches.cpp b/src/gamedata/textures/anim_switches.cpp index 7767539ab..21c6ff14e 100644 --- a/src/gamedata/textures/anim_switches.cpp +++ b/src/gamedata/textures/anim_switches.cpp @@ -32,7 +32,7 @@ ** */ -#include "templates.h" + #include "textures.h" #include "s_sound.h" #include "r_state.h" diff --git a/src/gamedata/textures/buildloader.cpp b/src/gamedata/textures/buildloader.cpp index 047ad14be..bfcc63225 100644 --- a/src/gamedata/textures/buildloader.cpp +++ b/src/gamedata/textures/buildloader.cpp @@ -36,7 +36,7 @@ #include "files.h" #include "filesystem.h" -#include "templates.h" + #include "cmdlib.h" #include "colormatcher.h" #include "bitmap.h" @@ -178,7 +178,7 @@ void AddTiles(const FString& pathprefix, const void* tiles, FRemapTable *remap) } speed = (anm >> 24) & 15; - speed = MAX(1, (1 << speed) * 1000 / 120); // Convert from 120 Hz to 1000 Hz. + speed = max(1, (1 << speed) * 1000 / 120); // Convert from 120 Hz to 1000 Hz. TexAnim.AddSimpleAnim(texnum, picanm[pic] & 63, type, speed); } diff --git a/src/hu_scores.cpp b/src/hu_scores.cpp index 6e662ab6b..c7fa10cdb 100644 --- a/src/hu_scores.cpp +++ b/src/hu_scores.cpp @@ -37,7 +37,7 @@ #include "c_console.h" #include "teaminfo.h" -#include "templates.h" + #include "v_video.h" #include "doomstat.h" #include "g_level.h" @@ -149,7 +149,7 @@ static int FontScale; void HU_DrawScores (player_t *player) { displayFont = NewSmallFont; - FontScale = MAX(screen->GetHeight() / 400, 1); + FontScale = max(screen->GetHeight() / 400, 1); if (deathmatch) { @@ -273,11 +273,11 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER HU_GetPlayerWidths(maxnamewidth, maxscorewidth, maxiconheight); height = displayFont->GetHeight() * FontScale; - lineheight = MAX(height, maxiconheight * CleanYfac); + lineheight = max(height, maxiconheight * CleanYfac); ypadding = (lineheight - height + 1) / 2; bottom = StatusBar->GetTopOfStatusbar(); - y = MAX(48*CleanYfac, (bottom - MAXPLAYERS * (height + CleanYfac + 1)) / 2); + y = max(48*CleanYfac, (bottom - MAXPLAYERS * (height + CleanYfac + 1)) / 2); HU_DrawTimeRemaining (bottom - height); @@ -304,7 +304,7 @@ static void HU_DoDrawScores (player_t *player, player_t *sortedplayers[MAXPLAYER } } - int scorexwidth = twod->GetWidth() / MAX(8, numTeams); + int scorexwidth = twod->GetWidth() / max(8, numTeams); int numscores = 0; int scorex; diff --git a/src/intermission/intermission.cpp b/src/intermission/intermission.cpp index bca2de20f..64a538878 100644 --- a/src/intermission/intermission.cpp +++ b/src/intermission/intermission.cpp @@ -50,7 +50,7 @@ #include "d_net.h" #include "g_levellocals.h" #include "utf8.h" -#include "templates.h" + #include "s_music.h" #include "texturemanager.h" #include "v_draw.h" @@ -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..21da9462a 100644 --- a/src/maploader/glnodes.cpp +++ b/src/maploader/glnodes.cpp @@ -43,7 +43,7 @@ #endif #include -#include "templates.h" + #include "m_argv.h" #include "c_dispatch.h" #include "m_swap.h" @@ -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 8b386220f..d4a35c20d 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/maploader/specials.cpp b/src/maploader/specials.cpp index 280eba279..b0a076131 100644 --- a/src/maploader/specials.cpp +++ b/src/maploader/specials.cpp @@ -67,7 +67,7 @@ #include -#include "templates.h" + #include "doomdef.h" #include "doomstat.h" #include "d_event.h" @@ -452,7 +452,7 @@ static void SetupSectorDamage(sector_t *sector, int damage, int interval, int le if (sector->damageamount == 0 && !(sector->Flags & (SECF_EXIT1|SECF_EXIT2))) { sector->damageamount = damage; - sector->damageinterval = MAX(1, interval); + sector->damageinterval = max(1, interval); sector->leakydamage = leakchance; sector->damagetype = type; sector->Flags = (sector->Flags & ~SECF_DAMAGEFLAGS) | (flags & SECF_DAMAGEFLAGS); diff --git a/src/menu/doommenu.cpp b/src/menu/doommenu.cpp index 24fb66cfb..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(); @@ -1312,7 +1312,7 @@ void SetDefaultMenuColors() cls = PClass::FindClass(gameinfo.MenuDelegateClass); if (!cls) - I_FatalError("%s: Undefined menu delegate class", gameinfo.HelpMenuClass.GetChars()); + I_FatalError("%s: Undefined menu delegate class", gameinfo.MenuDelegateClass.GetChars()); if (!cls->IsDescendantOf("MenuDelegateBase")) I_FatalError("'%s' does not inherit from MenuDelegateBase", gameinfo.MenuDelegateClass.GetChars()); menuDelegate = cls->CreateNew(); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index d05865820..41aaa4aa5 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -30,7 +30,7 @@ #include // for alloca() #endif -#include "templates.h" + #include "d_player.h" #include "m_argv.h" #include "g_game.h" diff --git a/src/p_states.cpp b/src/p_states.cpp index 2e52243b1..6c3ff2f33 100644 --- a/src/p_states.cpp +++ b/src/p_states.cpp @@ -39,6 +39,7 @@ #include "v_text.h" #include "thingdef.h" #include "r_state.h" +#include "templates.h" // stores indices for symbolic state labels for some old-style DECORATE functions. @@ -79,7 +80,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/a_dynlight.cpp b/src/playsim/a_dynlight.cpp index 8a5838f1d..6c1e72fd3 100644 --- a/src/playsim/a_dynlight.cpp +++ b/src/playsim/a_dynlight.cpp @@ -395,7 +395,7 @@ void FDynamicLight::UpdateLocation() if (lighttype == FlickerLight || lighttype == RandomFlickerLight || lighttype == PulseLight) { - intensity = float(MAX(GetIntensity(), GetSecondaryIntensity())); + intensity = float(max(GetIntensity(), GetSecondaryIntensity())); } else { diff --git a/src/playsim/actor.h b/src/playsim/actor.h index e604cbfeb..e83c0966d 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -30,7 +30,7 @@ #define __P_MOBJ_H__ // Basics. -#include "templates.h" + // We need the thinker_t stuff. #include "dthinker.h" @@ -1301,7 +1301,7 @@ public: double RenderRadius() const { - return MAX(radius, renderradius); + return max(radius, renderradius); } DVector3 PosRelative(int grp) const; @@ -1453,7 +1453,7 @@ public: // Better have it in one place, if something needs to be changed about the formula. double DistanceBySpeed(AActor *dest, double speed) const { - return MAX(1., Distance2D(dest) / speed); + return max(1., Distance2D(dest) / speed); } int ApplyDamageFactor(FName damagetype, int damage) const; 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/fragglescript/t_func.cpp b/src/playsim/fragglescript/t_func.cpp index e0d85cfab..effbd5d3c 100644 --- a/src/playsim/fragglescript/t_func.cpp +++ b/src/playsim/fragglescript/t_func.cpp @@ -34,7 +34,7 @@ //--------------------------------------------------------------------------- // -#include "templates.h" + #include "p_local.h" #include "t_script.h" #include "sbar.h" diff --git a/src/playsim/mapthinkers/a_lightning.cpp b/src/playsim/mapthinkers/a_lightning.cpp index 9f2504f09..854e26212 100644 --- a/src/playsim/mapthinkers/a_lightning.cpp +++ b/src/playsim/mapthinkers/a_lightning.cpp @@ -26,7 +26,7 @@ #include "doomstat.h" #include "p_lnspec.h" #include "m_random.h" -#include "templates.h" + #include "s_sound.h" #include "p_acs.h" #include "r_sky.h" @@ -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_lights.cpp b/src/playsim/mapthinkers/a_lights.cpp index 68c417446..e53f1a5c5 100644 --- a/src/playsim/mapthinkers/a_lights.cpp +++ b/src/playsim/mapthinkers/a_lights.cpp @@ -26,7 +26,7 @@ //----------------------------------------------------------------------------- -#include "templates.h" + #include "m_random.h" #include "doomdef.h" diff --git a/src/playsim/mapthinkers/a_quake.cpp b/src/playsim/mapthinkers/a_quake.cpp index b906665e8..93aff41ec 100644 --- a/src/playsim/mapthinkers/a_quake.cpp +++ b/src/playsim/mapthinkers/a_quake.cpp @@ -22,7 +22,7 @@ // Hexen's earthquake system, significantly enhanced // -#include "templates.h" + #include "doomtype.h" #include "doomstat.h" #include "p_local.h" @@ -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..dd5a2bb0a 100644 --- a/src/playsim/p_3dfloors.cpp +++ b/src/playsim/p_3dfloors.cpp @@ -35,7 +35,7 @@ ** */ -#include "templates.h" + #include "p_local.h" #include "p_lnspec.h" #include "p_maputl.h" @@ -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..315ded0c9 100644 --- a/src/playsim/p_3dmidtex.cpp +++ b/src/playsim/p_3dmidtex.cpp @@ -35,7 +35,7 @@ */ -#include "templates.h" + #include "p_3dmidtex.h" #include "p_local.h" #include "p_terrain.h" @@ -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..3fe51585d 100644 --- a/src/playsim/p_enemy.cpp +++ b/src/playsim/p_enemy.cpp @@ -31,7 +31,7 @@ #include -#include "templates.h" + #include "m_random.h" #include "doomdef.h" @@ -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_linkedsectors.cpp b/src/playsim/p_linkedsectors.cpp index 5d327643e..1b5a958e5 100644 --- a/src/playsim/p_linkedsectors.cpp +++ b/src/playsim/p_linkedsectors.cpp @@ -33,7 +33,7 @@ ** */ -#include "templates.h" + #include "p_local.h" #include "p_lnspec.h" #include "p_spec.h" diff --git a/src/playsim/p_map.cpp b/src/playsim/p_map.cpp index a6784e00e..0cc2a524f 100644 --- a/src/playsim/p_map.cpp +++ b/src/playsim/p_map.cpp @@ -61,7 +61,7 @@ #include #include -#include "templates.h" + #include "m_bbox.h" #include "m_random.h" @@ -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..d2bc9aba1 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -58,7 +58,7 @@ // HEADER FILES ------------------------------------------------------------ #include -#include "templates.h" + #include "m_random.h" #include "doomdef.h" @@ -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_pspr.cpp b/src/playsim/p_pspr.cpp index 91a07d8ec..97e58bd68 100644 --- a/src/playsim/p_pspr.cpp +++ b/src/playsim/p_pspr.cpp @@ -36,7 +36,7 @@ #include "s_sound.h" #include "doomstat.h" #include "p_pspr.h" -#include "templates.h" + #include "g_level.h" #include "d_player.h" #include "serializer_doom.h" 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_spec.cpp b/src/playsim/p_spec.cpp index 147a34db1..ab682f171 100644 --- a/src/playsim/p_spec.cpp +++ b/src/playsim/p_spec.cpp @@ -67,7 +67,7 @@ #include -#include "templates.h" + #include "doomdef.h" #include "doomstat.h" #include "d_event.h" diff --git a/src/playsim/p_switch.cpp b/src/playsim/p_switch.cpp index 51dda852c..b73d92793 100644 --- a/src/playsim/p_switch.cpp +++ b/src/playsim/p_switch.cpp @@ -32,7 +32,7 @@ ** */ -#include "templates.h" + #include "doomdef.h" #include "p_local.h" 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..d1a0b42a4 100644 --- a/src/playsim/p_user.cpp +++ b/src/playsim/p_user.cpp @@ -58,7 +58,7 @@ ** */ -#include "templates.h" + #include "doomdef.h" #include "d_event.h" #include "p_local.h" @@ -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/colormaps.cpp b/src/r_data/colormaps.cpp index b46a9b49c..0a616add0 100644 --- a/src/r_data/colormaps.cpp +++ b/src/r_data/colormaps.cpp @@ -42,7 +42,7 @@ #include "filesystem.h" #include "r_sky.h" #include "colormaps.h" -#include "templates.h" + #include "c_cvars.h" CUSTOM_CVAR(Bool, cl_customizeinvulmap, false, CVAR_ARCHIVE|CVAR_NOINITCALL) @@ -156,7 +156,7 @@ void R_InitColormaps (bool allowCustomColormap) g /= 256; b /= 256; // The calculated average is too dark so brighten it according to the palettes's overall brightness - int maxcol = MAX(MAX(palette_brightness, r), MAX(g, b)); + int maxcol = max(max(palette_brightness, r), max(g, b)); fakecmaps[j].blend = PalEntry (255, r * 255 / maxcol, g * 255 / maxcol, b * 255 / maxcol); } diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index 6be82c77d..087f0552f 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -35,7 +35,7 @@ #include #include "sc_man.h" -#include "templates.h" + #include "filesystem.h" #include "gi.h" #include "r_state.h" diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index 43d846a4d..c626a13eb 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -524,6 +524,10 @@ static void ParseModelDefLump(int Lump) { smf.flags |= MDL_USEACTORROLL; } + else if (sc.Compare("noperpixellighting")) + { + smf.flags |= MDL_NOPERPIXELLIGHTING; + } else if (sc.Compare("rotating")) { smf.flags |= MDL_ROTATING; diff --git a/src/r_data/models.h b/src/r_data/models.h index 715ca73be..2ce9744ca 100644 --- a/src/r_data/models.h +++ b/src/r_data/models.h @@ -55,6 +55,7 @@ enum MDL_BADROTATION = 128, MDL_DONTCULLBACKFACES = 256, MDL_USEROTATIONCENTER = 512, + MDL_NOPERPIXELLIGHTING = 1024, // forces a model to not use per-pixel lighting. useful for voxel-converted-to-model objects. }; FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped); 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..0f130e30a 100644 --- a/src/r_data/r_translate.cpp +++ b/src/r_data/r_translate.cpp @@ -34,7 +34,7 @@ #include -#include "templates.h" + #include "r_data/r_translate.h" #include "v_video.h" #include "g_game.h" @@ -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/r_data/r_vanillatrans.cpp b/src/r_data/r_vanillatrans.cpp index e969dd3d8..f63d7ee32 100644 --- a/src/r_data/r_vanillatrans.cpp +++ b/src/r_data/r_vanillatrans.cpp @@ -36,7 +36,7 @@ ** **/ -#include "templates.h" + #include "c_cvars.h" #include "filesystem.h" #include "doomtype.h" diff --git a/src/r_data/sprites.cpp b/src/r_data/sprites.cpp index 3b88669e8..b3b5cf451 100644 --- a/src/r_data/sprites.cpp +++ b/src/r_data/sprites.cpp @@ -452,7 +452,7 @@ void R_InitSpriteDefs () { // voxel applies to a specific frame j = vh->Frame - 'A'; sprtemp[j].Voxel = voxdef; - maxframe = MAX(maxframe, j); + maxframe = max(maxframe, j); } } } diff --git a/src/r_data/v_palette.cpp b/src/r_data/v_palette.cpp index 1c757e29e..74473d5a5 100644 --- a/src/r_data/v_palette.cpp +++ b/src/r_data/v_palette.cpp @@ -34,7 +34,7 @@ #include "g_level.h" -#include "templates.h" + #include "v_video.h" #include "filesystem.h" #include "i_video.h" diff --git a/src/rendering/2d/f_wipe.cpp b/src/rendering/2d/f_wipe.cpp index 320bb869d..c9d49d2ee 100644 --- a/src/rendering/2d/f_wipe.cpp +++ b/src/rendering/2d/f_wipe.cpp @@ -26,7 +26,7 @@ #include "v_video.h" #include "m_random.h" #include "f_wipe.h" -#include "templates.h" + #include "bitmap.h" #include "hw_material.h" #include "v_draw.h" @@ -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) @@ -160,7 +160,7 @@ public: bool Run(int ticks) override; private: - static const int WIDTH = 320, HEIGHT = 200; + static constexpr int WIDTH = 320, HEIGHT = 200; int y[WIDTH]; }; @@ -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..9fdba4179 100644 --- a/src/rendering/2d/v_blend.cpp +++ b/src/rendering/2d/v_blend.cpp @@ -34,7 +34,7 @@ #include -#include "templates.h" + #include "sbar.h" #include "c_cvars.h" #include "c_dispatch.h" @@ -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..718040b8e 100644 --- a/src/rendering/hwrenderer/doom_aabbtree.cpp +++ b/src/rendering/hwrenderer/doom_aabbtree.cpp @@ -57,10 +57,10 @@ 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_max.X = MAX(left.aabb_right, right.aabb_right); - aabb_max.Y = MAX(left.aabb_bottom, right.aabb_bottom); + 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,20 +137,20 @@ bool DoomLevelAABBTree::Update() float y2 = (float)line.v2->fY(); int nodeIndex = path[0]; - nodes[nodeIndex].aabb_left = MIN(x1, x2); - nodes[nodeIndex].aabb_right = MAX(x1, x2); - nodes[nodeIndex].aabb_top = MIN(y1, y2); - nodes[nodeIndex].aabb_bottom = MAX(y1, y2); + nodes[nodeIndex].aabb_left = min(x1, x2); + nodes[nodeIndex].aabb_right = max(x1, x2); + nodes[nodeIndex].aabb_top = min(y1, y2); + nodes[nodeIndex].aabb_bottom = max(y1, y2); for (unsigned int j = 1; j < path.Size(); j++) { 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_right = MAX(left.aabb_right, right.aabb_right); - cur.aabb_bottom = MAX(left.aabb_bottom, right.aabb_bottom); + 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); } treelines[i] = treeline; @@ -181,14 +181,14 @@ 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_max.X = MAX(aabb_max.X, x1); - aabb_max.X = MAX(aabb_max.X, x2); - aabb_max.Y = MAX(aabb_max.Y, y1); - aabb_max.Y = MAX(aabb_max.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); + aabb_max.Y = max(aabb_max.Y, y2); median += centroids[mapLines[lines[i]]]; } diff --git a/src/rendering/hwrenderer/hw_vertexbuilder.cpp b/src/rendering/hwrenderer/hw_vertexbuilder.cpp index 91c6bb3c6..718528afe 100644 --- a/src/rendering/hwrenderer/hw_vertexbuilder.cpp +++ b/src/rendering/hwrenderer/hw_vertexbuilder.cpp @@ -493,5 +493,5 @@ void CreateVBO(FFlatVertexBuffer* fvb, TArray& sectors) CreateVertices(fvb, sectors); fvb->mCurIndex = fvb->mIndex = fvb->vbo_shadowdata.Size(); fvb->Copy(0, fvb->mIndex); - fvb->mIndexBuffer->SetData(fvb->ibo_data.Size() * sizeof(uint32_t), &fvb->ibo_data[0]); + fvb->mIndexBuffer->SetData(fvb->ibo_data.Size() * sizeof(uint32_t), &fvb->ibo_data[0], BufferUsageType::Static); } diff --git a/src/rendering/hwrenderer/scene/hw_lighting.h b/src/rendering/hwrenderer/scene/hw_lighting.h index 2fd972b88..f4cc44380 100644 --- a/src/rendering/hwrenderer/scene/hw_lighting.h +++ b/src/rendering/hwrenderer/scene/hw_lighting.h @@ -2,7 +2,7 @@ #include "c_cvars.h" #include "v_palette.h" -#include "templates.h" + #include "r_utility.h" struct Colormap; diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index ddc50e760..b6a9c204b 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -489,7 +489,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp) inline void HWSprite::PutSprite(HWDrawInfo *di, bool translucent) { // That's a lot of checks... - if (modelframe && !modelframe->isVoxel && RenderStyle.BlendOp != STYLEOP_Shadow && gl_light_sprites && di->Level->HasDynamicLights && !di->isFullbrightScene() && !fullbright) + if (modelframe && !modelframe->isVoxel && !(modelframe->flags & MDL_NOPERPIXELLIGHTING) && RenderStyle.BlendOp != STYLEOP_Shadow && gl_light_sprites && di->Level->HasDynamicLights && !di->isFullbrightScene() && !fullbright) { hw_GetDynModelLight(actor, lightdata); dynlightindex = screen->mLights->UploadLights(lightdata); diff --git a/src/rendering/hwrenderer/scene/hw_walls.cpp b/src/rendering/hwrenderer/scene/hw_walls.cpp index bf62a7756..8c80aeab2 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; @@ -749,7 +749,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; @@ -1334,12 +1334,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; } } @@ -1370,8 +1370,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) && @@ -1385,8 +1385,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); } // @@ -1398,8 +1398,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))) { @@ -1411,8 +1411,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); } // @@ -1565,8 +1565,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 #include -#include "templates.h" + #include "doomdef.h" #include "d_net.h" #include "doomstat.h" diff --git a/src/rendering/swrenderer/drawers/r_draw.cpp b/src/rendering/swrenderer/drawers/r_draw.cpp index 797f65626..5fd8c5051 100644 --- a/src/rendering/swrenderer/drawers/r_draw.cpp +++ b/src/rendering/swrenderer/drawers/r_draw.cpp @@ -35,7 +35,7 @@ #include #include -#include "templates.h" + #include "doomdef.h" #include "filesystem.h" @@ -109,7 +109,7 @@ namespace swrenderer for (int k = 0; k < 256; ++k) { uint8_t v = (((k + 2) * a) + 256) >> 14; - table[k] = MIN(v, 64); + table[k] = min(v, 64); } table += 256; } @@ -212,8 +212,8 @@ namespace swrenderer { if (!r_fuzzscale) { - int yl = MAX(args.FuzzY1(), 1); - int yh = MIN(args.FuzzY2(), fuzzviewheight); + int yl = max(args.FuzzY1(), 1); + int yh = min(args.FuzzY2(), fuzzviewheight); if (yl <= yh) fuzzpos = (fuzzpos + yh - yl + 1) % FUZZTABLE; } diff --git a/src/rendering/swrenderer/drawers/r_draw_pal.cpp b/src/rendering/swrenderer/drawers/r_draw_pal.cpp index 8cc7a0fc8..375053145 100644 --- a/src/rendering/swrenderer/drawers/r_draw_pal.cpp +++ b/src/rendering/swrenderer/drawers/r_draw_pal.cpp @@ -36,7 +36,7 @@ #ifndef NO_SSE #include #endif -#include "templates.h" + #include "doomtype.h" #include "doomdef.h" #include "r_defs.h" @@ -107,7 +107,7 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) float Lxy2 = lights[i].x; // L.x*L.x + L.y*L.y float Lz = lights[i].z - viewpos_z; float dist2 = Lxy2 + Lz * Lz; @@ -117,7 +117,7 @@ namespace swrenderer float rcp_dist = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_set_ss(dist2))); #endif float dist = dist2 * rcp_dist; - float distance_attenuation = (256.0f - MIN(dist * lights[i].radius, 256.0f)); + float distance_attenuation = (256.0f - min(dist * lights[i].radius, 256.0f)); // The simple light type float simple_attenuation = distance_attenuation; @@ -139,9 +139,9 @@ namespace swrenderer uint32_t material_g = GPalette.BaseColors[material].g; uint32_t material_b = GPalette.BaseColors[material].b; - lit_r = MIN(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); - lit_g = MIN(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); - lit_b = MIN(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); + lit_r = min(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); + lit_g = min(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); + lit_b = min(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)]; } @@ -286,9 +286,9 @@ namespace swrenderer { uint8_t lit = colormap[pix]; - uint32_t r = MIN(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); - uint32_t g = MIN(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); - uint32_t b = MIN(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); + uint32_t r = min(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = min(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = min(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } frac += fracstep; @@ -352,9 +352,9 @@ namespace swrenderer { uint8_t lit = num_dynlights != 0 ? AddLightsColumn(dynlights, num_dynlights, viewpos_z, colormap[pix], pix) : colormap[pix]; - uint32_t r = MIN(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); - uint32_t g = MIN(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); - uint32_t b = MIN(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); + uint32_t r = min(GPalette.BaseColors[lit].r + GPalette.BaseColors[*dest].r, 255); + uint32_t g = min(GPalette.BaseColors[lit].g + GPalette.BaseColors[*dest].g, 255); + uint32_t b = min(GPalette.BaseColors[lit].b + GPalette.BaseColors[*dest].b, 255); *dest = RGB256k.RGB[r>>2][g>>2][b>>2]; } viewpos_z += step_viewpos_z; @@ -567,7 +567,7 @@ namespace swrenderer uint8_t fg = source0[sample_index]; uint32_t c = palette[fg]; - int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_top = max(min(frac >> (16 - start_fade), 256), 0); int inv_alpha_top = 256 - alpha_top; int c_red = RPART(c); int c_green = GPART(c); @@ -600,7 +600,7 @@ namespace swrenderer uint8_t fg = source0[sample_index]; uint32_t c = palette[fg]; - int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + int alpha_bottom = max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0); int inv_alpha_bottom = 256 - alpha_bottom; int c_red = RPART(c); int c_green = GPART(c); @@ -645,7 +645,7 @@ namespace swrenderer uint8_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } @@ -701,12 +701,12 @@ namespace swrenderer uint8_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } uint32_t c = palette[fg]; - int alpha_top = MAX(MIN(frac >> (16 - start_fade), 256), 0); + int alpha_top = max(min(frac >> (16 - start_fade), 256), 0); int inv_alpha_top = 256 - alpha_top; int c_red = RPART(c); int c_green = GPART(c); @@ -728,7 +728,7 @@ namespace swrenderer uint8_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } *dest = fg; @@ -745,12 +745,12 @@ namespace swrenderer uint8_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } uint32_t c = palette[fg]; - int alpha_bottom = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + int alpha_bottom = max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0); int inv_alpha_bottom = 256 - alpha_bottom; int c_red = RPART(c); int c_green = GPART(c); @@ -785,9 +785,9 @@ namespace swrenderer uint32_t material_g = GPalette.BaseColors[material].g; uint32_t material_b = GPalette.BaseColors[material].b; - lit_r = MIN(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); - lit_g = MIN(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); - lit_b = MIN(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); + lit_r = min(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); + lit_g = min(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); + lit_b = min(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)]; } @@ -836,9 +836,9 @@ namespace swrenderer uint32_t lit_g = GPART(dynlight); uint32_t lit_b = BPART(dynlight); uint32_t light = 256 - (args.Light() >> (FRACBITS - 8)); - lit_r = MIN(light + lit_r, 256); - lit_g = MIN(light + lit_g, 256); - lit_b = MIN(light + lit_b, 256); + lit_r = min(light + lit_r, 256); + lit_g = min(light + lit_g, 256); + lit_b = min(light + lit_b, 256); lit_r = lit_r - light; lit_g = lit_g - light; lit_b = lit_b - light; @@ -1011,9 +1011,9 @@ namespace swrenderer int src_g = ((srccolor >> 0) & 0xff) * srcalpha; int src_b = ((srccolor >> 8) & 0xff) * srcalpha; int bg = *dest; - int r = MAX((-src_r + palette[bg].r * destalpha)>>18, 0); - int g = MAX((-src_g + palette[bg].g * destalpha)>>18, 0); - int b = MAX((-src_b + palette[bg].b * destalpha)>>18, 0); + int r = max((-src_r + palette[bg].r * destalpha)>>18, 0); + int g = max((-src_g + palette[bg].g * destalpha)>>18, 0); + int b = max((-src_b + palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; @@ -1061,9 +1061,9 @@ namespace swrenderer int src_g = ((srccolor >> 0) & 0xff) * srcalpha; int src_b = ((srccolor >> 8) & 0xff) * srcalpha; int bg = *dest; - int r = MAX((src_r - palette[bg].r * destalpha)>>18, 0); - int g = MAX((src_g - palette[bg].g * destalpha)>>18, 0); - int b = MAX((src_b - palette[bg].b * destalpha)>>18, 0); + int r = max((src_r - palette[bg].r * destalpha)>>18, 0); + int g = max((src_g - palette[bg].g * destalpha)>>18, 0); + int b = max((src_b - palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; @@ -1113,9 +1113,9 @@ namespace swrenderer { uint32_t fg = colormap[source[frac >> FRACBITS]]; uint32_t bg = *dest; - uint32_t r = MIN((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); - uint32_t g = MIN((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); - uint32_t b = MIN((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); + uint32_t r = min((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); + uint32_t g = min((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); + uint32_t b = min((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1192,9 +1192,9 @@ namespace swrenderer { uint32_t fg = colormap[translation[source[frac >> FRACBITS]]]; uint32_t bg = *dest; - uint32_t r = MIN((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); - uint32_t g = MIN((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); - uint32_t b = MIN((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); + uint32_t r = min((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); + uint32_t g = min((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); + uint32_t b = min((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1331,9 +1331,9 @@ namespace swrenderer { int fg = colormap[source[frac >> FRACBITS]]; int bg = *dest; - int r = MIN((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); - int g = MIN((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); - int b = MIN((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); + int r = min((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); + int g = min((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); + int b = min((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1385,9 +1385,9 @@ namespace swrenderer { int fg = colormap[translation[source[frac >> FRACBITS]]]; int bg = *dest; - int r = MIN((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); - int g = MIN((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); - int b = MIN((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); + int r = min((palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 63); + int g = min((palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 63); + int b = min((palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 63); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1437,9 +1437,9 @@ namespace swrenderer { int fg = colormap[source[frac >> FRACBITS]]; int bg = *dest; - int r = MAX((palette[fg].r * srcalpha - palette[bg].r * destalpha)>>18, 0); - int g = MAX((palette[fg].g * srcalpha - palette[bg].g * destalpha)>>18, 0); - int b = MAX((palette[fg].b * srcalpha - palette[bg].b * destalpha)>>18, 0); + int r = max((palette[fg].r * srcalpha - palette[bg].r * destalpha)>>18, 0); + int g = max((palette[fg].g * srcalpha - palette[bg].g * destalpha)>>18, 0); + int b = max((palette[fg].b * srcalpha - palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1490,9 +1490,9 @@ namespace swrenderer { int fg = colormap[translation[source[frac >> FRACBITS]]]; int bg = *dest; - int r = MAX((palette[fg].r * srcalpha - palette[bg].r * destalpha)>>18, 0); - int g = MAX((palette[fg].g * srcalpha - palette[bg].g * destalpha)>>18, 0); - int b = MAX((palette[fg].b * srcalpha - palette[bg].b * destalpha)>>18, 0); + int r = max((palette[fg].r * srcalpha - palette[bg].r * destalpha)>>18, 0); + int g = max((palette[fg].g * srcalpha - palette[bg].g * destalpha)>>18, 0); + int b = max((palette[fg].b * srcalpha - palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1542,9 +1542,9 @@ namespace swrenderer { int fg = colormap[source[frac >> FRACBITS]]; int bg = *dest; - int r = MAX((-palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 0); - int g = MAX((-palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 0); - int b = MAX((-palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 0); + int r = max((-palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 0); + int g = max((-palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 0); + int b = max((-palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1595,9 +1595,9 @@ namespace swrenderer { int fg = colormap[translation[source[frac >> FRACBITS]]]; int bg = *dest; - int r = MAX((-palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 0); - int g = MAX((-palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 0); - int b = MAX((-palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 0); + int r = max((-palette[fg].r * srcalpha + palette[bg].r * destalpha)>>18, 0); + int g = max((-palette[fg].g * srcalpha + palette[bg].g * destalpha)>>18, 0); + int b = max((-palette[fg].b * srcalpha + palette[bg].b * destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; dest += pitch; frac += fracstep; @@ -1618,8 +1618,8 @@ namespace swrenderer int _fuzzviewheight = fuzzviewheight; int x = _x; - int yl = MAX(_yl, 1); - int yh = MIN(_yh, _fuzzviewheight); + int yl = max(_yl, 1); + int yh = min(_yh, _fuzzviewheight); int count = yh - yl + 1; if (count <= 0) return; @@ -1661,8 +1661,8 @@ namespace swrenderer int _fuzzpos = fuzzpos; int _fuzzviewheight = fuzzviewheight; - int yl = MAX(_yl, 1); - int yh = MIN(_yh, _fuzzviewheight); + int yl = max(_yl, 1); + int yh = min(_yh, _fuzzviewheight); int count = yh - yl + 1; @@ -1687,7 +1687,7 @@ namespace swrenderer if (available % fuzzstep != 0) next_wrap++; - int cnt = MIN(count, next_wrap); + int cnt = min(count, next_wrap); count -= cnt; do { @@ -1733,7 +1733,7 @@ namespace swrenderer if (available % fuzzstep != 0) next_wrap++; - int cnt = MIN(count, next_wrap); + int cnt = min(count, next_wrap); count -= cnt; do { @@ -1775,7 +1775,7 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // attenuation = 1 - MIN(dist * (1/radius), 1) + // attenuation = 1 - min(dist * (1/radius), 1) float Lyz2 = lights[i].y; // L.y*L.y + L.z*L.z float Lx = lights[i].x - viewpos_x; float dist2 = Lyz2 + Lx * Lx; @@ -1785,7 +1785,7 @@ namespace swrenderer float rcp_dist = _mm_cvtss_f32(_mm_rsqrt_ss(_mm_load_ss(&dist2))); #endif float dist = dist2 * rcp_dist; - float distance_attenuation = (256.0f - MIN(dist * lights[i].radius, 256.0f)); + float distance_attenuation = (256.0f - min(dist * lights[i].radius, 256.0f)); // The simple light type float simple_attenuation = distance_attenuation; @@ -1807,9 +1807,9 @@ namespace swrenderer uint32_t material_g = GPalette.BaseColors[material].g; uint32_t material_b = GPalette.BaseColors[material].b; - lit_r = MIN(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); - lit_g = MIN(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); - lit_b = MIN(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); + lit_r = min(GPalette.BaseColors[fg].r + ((lit_r * material_r) >> 8), 255); + lit_g = min(GPalette.BaseColors[fg].g + ((lit_g * material_g) >> 8), 255); + lit_b = min(GPalette.BaseColors[fg].b + ((lit_b * material_b) >> 8), 255); return RGB256k.All[((lit_r >> 2) << 12) | ((lit_g >> 2) << 6) | (lit_b >> 2)]; } @@ -2113,9 +2113,9 @@ namespace swrenderer spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2133,9 +2133,9 @@ namespace swrenderer spot = (((xfrac >> 16) * srcwidth) >> 16) * srcheight + (((yfrac >> 16) * srcheight) >> 16); uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2267,9 +2267,9 @@ namespace swrenderer { uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2293,9 +2293,9 @@ namespace swrenderer { uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2416,9 +2416,9 @@ namespace swrenderer spot = ((xfrac >> (32 - 6 - 6))&(63 * 64)) + (yfrac >> (32 - 6)); uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2436,9 +2436,9 @@ namespace swrenderer spot = (((xfrac >> 16) * srcwidth) >> 16) * srcheight + (((yfrac >> 16) * srcheight) >> 16); uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[source[spot]], source[spot]) : colormap[source[spot]]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest++ = RGB256k.RGB[r][g][b]; xfrac += xstep; @@ -2577,9 +2577,9 @@ namespace swrenderer { uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2603,9 +2603,9 @@ namespace swrenderer { uint32_t fg = num_dynlights != 0 ? AddLightsSpan(dynlights, num_dynlights, viewpos_x, colormap[texdata], texdata) : colormap[texdata]; uint32_t bg = *dest; - int r = MAX((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); - int g = MAX((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); - int b = MAX((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); + int r = max((palette[fg].r * _srcalpha + palette[bg].r * _destalpha)>>18, 0); + int g = max((palette[fg].g * _srcalpha + palette[bg].g * _destalpha)>>18, 0); + int b = max((palette[fg].b * _srcalpha + palette[bg].b * _destalpha)>>18, 0); *dest = RGB256k.RGB[r][g][b]; } dest++; @@ -2859,7 +2859,7 @@ namespace swrenderer if (count <= 0) return; - int particle_texture_index = MIN(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); + int particle_texture_index = min(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); const uint32_t *source = &particle_texture[particle_texture_index][(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE]; uint32_t particle_alpha = _alpha; @@ -3122,7 +3122,7 @@ namespace swrenderer uint32_t next_uv_wrap = available / texelStepY; if (available % texelStepY != 0) next_uv_wrap++; - uint32_t count = MIN(left, next_uv_wrap); + uint32_t count = min(left, next_uv_wrap); drawerargs.SetDest(x, y); drawerargs.SetCount(count); diff --git a/src/rendering/swrenderer/drawers/r_draw_rgba.cpp b/src/rendering/swrenderer/drawers/r_draw_rgba.cpp index b6360981c..0e43daadc 100644 --- a/src/rendering/swrenderer/drawers/r_draw_rgba.cpp +++ b/src/rendering/swrenderer/drawers/r_draw_rgba.cpp @@ -34,7 +34,7 @@ */ #include -#include "templates.h" + #include "doomdef.h" #include "filesystem.h" @@ -257,8 +257,8 @@ namespace swrenderer int _fuzzviewheight = fuzzviewheight; int x = _x; - int yl = MAX(_yl, 1); - int yh = MIN(_yh, _fuzzviewheight); + int yl = max(_yl, 1); + int yh = min(_yh, _fuzzviewheight); int count = yh - yl + 1; if (count <= 0) return; @@ -304,8 +304,8 @@ namespace swrenderer int _fuzzpos = fuzzpos; int _fuzzviewheight = fuzzviewheight; - int yl = MAX(_yl, 1); - int yh = MIN(_yh, _fuzzviewheight); + int yl = max(_yl, 1); + int yh = min(_yh, _fuzzviewheight); int count = yh - yl + 1; @@ -328,7 +328,7 @@ namespace swrenderer if (available % fuzzstep != 0) next_wrap++; - int cnt = MIN(count, next_wrap); + int cnt = min(count, next_wrap); count -= cnt; do { @@ -383,7 +383,7 @@ namespace swrenderer if (available % fuzzstep != 0) next_wrap++; - int cnt = MIN(count, next_wrap); + int cnt = min(count, next_wrap); count -= cnt; do { @@ -810,7 +810,7 @@ namespace swrenderer if (count <= 0) return; - int particle_texture_index = MIN(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); + int particle_texture_index = min(gl_particles_style, NUM_PARTICLE_TEXTURES - 1); const uint32_t *source = &particle_texture[particle_texture_index][(_fracposx >> FRACBITS) * PARTICLE_TEXTURE_SIZE]; uint32_t particle_alpha = _alpha; @@ -991,9 +991,9 @@ namespace swrenderer double xmagnitude = fabs(static_cast(texelStepX) * (1.0 / 0x1'0000'0000LL)); double ymagnitude = fabs(static_cast(texelStepY) * (1.0 / 0x1'0000'0000LL)); - double magnitude = MAX(ymagnitude, xmagnitude); + double magnitude = max(ymagnitude, xmagnitude); double min_lod = -1000.0; - double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + double lod = max(log2(magnitude) + r_lod_bias, min_lod); bool magnifying = lod < 0.0f; int mipmap_offset = 0; @@ -1006,8 +1006,8 @@ namespace swrenderer { mipmap_offset += mip_width * mip_height; level--; - mip_width = MAX(mip_width >> 1, 1); - mip_height = MAX(mip_height >> 1, 1); + mip_width = max(mip_width >> 1, 1); + mip_height = max(mip_height >> 1, 1); } } diff --git a/src/rendering/swrenderer/drawers/r_draw_sky32.h b/src/rendering/swrenderer/drawers/r_draw_sky32.h index df208afab..ea9dff4f7 100644 --- a/src/rendering/swrenderer/drawers/r_draw_sky32.h +++ b/src/rendering/swrenderer/drawers/r_draw_sky32.h @@ -91,7 +91,7 @@ namespace swrenderer uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; uint32_t fg = source0[sample_index]; - uint32_t alpha = MAX(MIN(frac >> (16 - start_fade), 256), 0); + uint32_t alpha = max(min(frac >> (16 - start_fade), 256), 0); uint32_t inv_alpha = 256 - alpha; BgraColor c = fg; @@ -122,7 +122,7 @@ namespace swrenderer uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; uint32_t fg = source0[sample_index]; - uint32_t alpha = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + uint32_t alpha = max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0); uint32_t inv_alpha = 256 - alpha; BgraColor c = fg; @@ -187,7 +187,7 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } @@ -220,11 +220,11 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } - uint32_t alpha = MAX(MIN(frac >> (16 - start_fade), 256), 0); + uint32_t alpha = max(min(frac >> (16 - start_fade), 256), 0); uint32_t inv_alpha = 256 - alpha; BgraColor c = fg; @@ -243,7 +243,7 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } *dest = fg; @@ -260,11 +260,11 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } - uint32_t alpha = MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0); + uint32_t alpha = max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0); uint32_t inv_alpha = 256 - alpha; BgraColor c = fg; diff --git a/src/rendering/swrenderer/drawers/r_draw_sky32_sse2.h b/src/rendering/swrenderer/drawers/r_draw_sky32_sse2.h index 998833416..bc2411b83 100644 --- a/src/rendering/swrenderer/drawers/r_draw_sky32_sse2.h +++ b/src/rendering/swrenderer/drawers/r_draw_sky32_sse2.h @@ -91,7 +91,7 @@ namespace swrenderer uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; uint32_t fg = source0[sample_index]; - __m128i alpha = _mm_set1_epi16(MAX(MIN(frac >> (16 - start_fade), 256), 0)); + __m128i alpha = _mm_set1_epi16(max(min(frac >> (16 - start_fade), 256), 0)); __m128i inv_alpha = _mm_sub_epi16(_mm_set1_epi16(256), alpha); __m128i c = _mm_unpacklo_epi8(_mm_cvtsi32_si128(fg), _mm_setzero_si128()); @@ -120,7 +120,7 @@ namespace swrenderer uint32_t sample_index = (((((uint32_t)frac) << 8) >> FRACBITS) * textureheight0) >> FRACBITS; uint32_t fg = source0[sample_index]; - __m128i alpha = _mm_set1_epi16(MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0)); + __m128i alpha = _mm_set1_epi16(max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0)); __m128i inv_alpha = _mm_sub_epi16(_mm_set1_epi16(256), alpha); __m128i c = _mm_unpacklo_epi8(_mm_cvtsi32_si128(fg), _mm_setzero_si128()); @@ -171,7 +171,7 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } @@ -216,11 +216,11 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } - __m128i alpha = _mm_set1_epi16(MAX(MIN(frac >> (16 - start_fade), 256), 0)); + __m128i alpha = _mm_set1_epi16(max(min(frac >> (16 - start_fade), 256), 0)); __m128i inv_alpha = _mm_sub_epi16(_mm_set1_epi16(256), alpha); __m128i c = _mm_unpacklo_epi8(_mm_cvtsi32_si128(fg), _mm_setzero_si128()); @@ -239,7 +239,7 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } *dest = fg; @@ -256,11 +256,11 @@ namespace swrenderer uint32_t fg = source0[sample_index]; if (fg == 0) { - uint32_t sample_index2 = MIN(sample_index, maxtextureheight1); + uint32_t sample_index2 = min(sample_index, maxtextureheight1); fg = source1[sample_index2]; } - __m128i alpha = _mm_set1_epi16(MAX(MIN(((2 << 24) - frac) >> (16 - start_fade), 256), 0)); + __m128i alpha = _mm_set1_epi16(max(min(((2 << 24) - frac) >> (16 - start_fade), 256), 0)); __m128i inv_alpha = _mm_sub_epi16(_mm_set1_epi16(256), alpha); __m128i c = _mm_unpacklo_epi8(_mm_cvtsi32_si128(fg), _mm_setzero_si128()); diff --git a/src/rendering/swrenderer/drawers/r_draw_span32.h b/src/rendering/swrenderer/drawers/r_draw_span32.h index 9534c496b..1c1e3e55d 100644 --- a/src/rendering/swrenderer/drawers/r_draw_span32.h +++ b/src/rendering/swrenderer/drawers/r_draw_span32.h @@ -94,8 +94,8 @@ namespace swrenderer break; texdata.source += texdata.width * texdata.height; - texdata.width = MAX(texdata.width / 2, 1); - texdata.height = MAX(texdata.height / 2, 1); + texdata.width = max(texdata.width / 2, 1); + texdata.height = max(texdata.height / 2, 1); level--; } } @@ -324,13 +324,13 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) float Lyz2 = light_y; // L.y*L.y + L.z*L.z float Lx = light_x - viewpos_x; float dist2 = Lyz2 + Lx * Lx; float rcp_dist = 1.f/sqrt(dist2); float dist = dist2 * rcp_dist; - float distance_attenuation = 256.0f - MIN(dist * light_radius, 256.0f); + float distance_attenuation = 256.0f - min(dist * light_radius, 256.0f); // The simple light type float simple_attenuation = distance_attenuation; @@ -348,13 +348,13 @@ namespace swrenderer lit.b += (light_color.b * attenuation) >> 8; } - lit.r = MIN(lit.r, 256); - lit.g = MIN(lit.g, 256); - lit.b = MIN(lit.b, 256); + lit.r = min(lit.r, 256); + lit.g = min(lit.g, 256); + lit.b = min(lit.b, 256); - fgcolor.r = MIN(fgcolor.r + ((material.r * lit.r) >> 8), 255); - fgcolor.g = MIN(fgcolor.g + ((material.g * lit.g) >> 8), 255); - fgcolor.b = MIN(fgcolor.b + ((material.b * lit.b) >> 8), 255); + fgcolor.r = min(fgcolor.r + ((material.r * lit.r) >> 8), 255); + fgcolor.g = min(fgcolor.g + ((material.g * lit.g) >> 8), 255); + fgcolor.b = min(fgcolor.b + ((material.b * lit.b) >> 8), 255); return fgcolor; } @@ -381,9 +381,9 @@ namespace swrenderer bgcolor.b = bgcolor.b * destalpha; BgraColor outcolor; - outcolor.r = MIN((fgcolor.r + bgcolor.r) >> 8, 255); - outcolor.g = MIN((fgcolor.g + bgcolor.g) >> 8, 255); - outcolor.b = MIN((fgcolor.b + bgcolor.b) >> 8, 255); + outcolor.r = min((fgcolor.r + bgcolor.r) >> 8, 255); + outcolor.g = min((fgcolor.g + bgcolor.g) >> 8, 255); + outcolor.b = min((fgcolor.b + bgcolor.b) >> 8, 255); return outcolor; } else @@ -405,21 +405,21 @@ namespace swrenderer BgraColor outcolor; if (BlendT::Mode == (int)SpanBlendModes::AddClamp) { - outcolor.r = MIN((fgcolor.r + bgcolor.r) >> 8, 255); - outcolor.g = MIN((fgcolor.g + bgcolor.g) >> 8, 255); - outcolor.b = MIN((fgcolor.b + bgcolor.b) >> 8, 255); + outcolor.r = min((fgcolor.r + bgcolor.r) >> 8, 255); + outcolor.g = min((fgcolor.g + bgcolor.g) >> 8, 255); + outcolor.b = min((fgcolor.b + bgcolor.b) >> 8, 255); } else if (BlendT::Mode == (int)SpanBlendModes::SubClamp) { - outcolor.r = MAX(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); } else if (BlendT::Mode == (int)SpanBlendModes::RevSubClamp) { - outcolor.r = MAX(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); } outcolor.a = 255; return outcolor; diff --git a/src/rendering/swrenderer/drawers/r_draw_span32_sse2.h b/src/rendering/swrenderer/drawers/r_draw_span32_sse2.h index 527545a9d..230ba8c13 100644 --- a/src/rendering/swrenderer/drawers/r_draw_span32_sse2.h +++ b/src/rendering/swrenderer/drawers/r_draw_span32_sse2.h @@ -94,8 +94,8 @@ namespace swrenderer break; texdata.source += texdata.width * texdata.height; - texdata.width = MAX(texdata.width / 2, 1); - texdata.height = MAX(texdata.height / 2, 1); + texdata.width = max(texdata.width / 2, 1); + texdata.height = max(texdata.height / 2, 1); level--; } } @@ -366,7 +366,7 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) __m128 Lyz2 = light_y; // L.y*L.y + L.z*L.z __m128 Lx = _mm_sub_ps(light_x, viewpos_x); __m128 dist2 = _mm_add_ps(Lyz2, _mm_mul_ps(Lx, Lx)); diff --git a/src/rendering/swrenderer/drawers/r_draw_sprite32.h b/src/rendering/swrenderer/drawers/r_draw_sprite32.h index 7fa300f82..6ae563dc6 100644 --- a/src/rendering/swrenderer/drawers/r_draw_sprite32.h +++ b/src/rendering/swrenderer/drawers/r_draw_sprite32.h @@ -143,9 +143,9 @@ namespace swrenderer shade_light.g = shade_constants.light_green; shade_light.b = shade_constants.light_blue; desaturate = shade_constants.desaturate; - lightcontrib.r = MIN(light + dynlight.r, 256) - light; - lightcontrib.g = MIN(light + dynlight.g, 256) - light; - lightcontrib.b = MIN(light + dynlight.b, 256) - light; + lightcontrib.r = min(light + dynlight.r, 256) - light; + lightcontrib.g = min(light + dynlight.g, 256) - light; + lightcontrib.b = min(light + dynlight.b, 256) - light; mlight.r = light; mlight.g = light; mlight.b = light; @@ -161,9 +161,9 @@ namespace swrenderer shade_light.b = 0; desaturate = 0; lightcontrib = 0; - mlight.r = MIN(light + dynlight.r, 256); - mlight.g = MIN(light + dynlight.g, 256); - mlight.b = MIN(light + dynlight.b, 256); + mlight.r = min(light + dynlight.r, 256); + mlight.g = min(light + dynlight.g, 256); + mlight.b = min(light + dynlight.b, 256); } int count = args.Count(); @@ -300,9 +300,9 @@ namespace swrenderer fgcolor.g = (((shade_fade.g + ((fgcolor.g * inv_desaturate + intensity) >> 8) * mlight.g) >> 8) * shade_light.g) >> 8; fgcolor.b = (((shade_fade.b + ((fgcolor.b * inv_desaturate + intensity) >> 8) * mlight.b) >> 8) * shade_light.b) >> 8; - fgcolor.r = MIN(fgcolor.r + lit_dynlight.r, 255); - fgcolor.g = MIN(fgcolor.g + lit_dynlight.g, 255); - fgcolor.b = MIN(fgcolor.b + lit_dynlight.b, 255); + fgcolor.r = min(fgcolor.r + lit_dynlight.r, 255); + fgcolor.g = min(fgcolor.g + lit_dynlight.g, 255); + fgcolor.b = min(fgcolor.b + lit_dynlight.b, 255); return fgcolor; } } @@ -332,9 +332,9 @@ namespace swrenderer { uint32_t alpha = ifgshade; BgraColor outcolor; - outcolor.r = MIN(((fgcolor.r * alpha) >> 8) + bgcolor.r, 255); - outcolor.g = MIN(((fgcolor.g * alpha) >> 8) + bgcolor.g, 255); - outcolor.b = MIN(((fgcolor.b * alpha) >> 8) + bgcolor.b, 255); + outcolor.r = min(((fgcolor.r * alpha) >> 8) + bgcolor.r, 255); + outcolor.g = min(((fgcolor.g * alpha) >> 8) + bgcolor.g, 255); + outcolor.b = min(((fgcolor.b * alpha) >> 8) + bgcolor.b, 255); outcolor.a = 255; return outcolor; } @@ -357,21 +357,21 @@ namespace swrenderer BgraColor outcolor; if (BlendT::Mode == (int)SpriteBlendModes::AddClamp) { - outcolor.r = MIN((fgcolor.r + bgcolor.r) >> 8, 255); - outcolor.g = MIN((fgcolor.g + bgcolor.g) >> 8, 255); - outcolor.b = MIN((fgcolor.b + bgcolor.b) >> 8, 255); + outcolor.r = min((fgcolor.r + bgcolor.r) >> 8, 255); + outcolor.g = min((fgcolor.g + bgcolor.g) >> 8, 255); + outcolor.b = min((fgcolor.b + bgcolor.b) >> 8, 255); } else if (BlendT::Mode == (int)SpriteBlendModes::SubClamp) { - outcolor.r = MAX(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); } else if (BlendT::Mode == (int)SpriteBlendModes::RevSubClamp) { - outcolor.r = MAX(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); } outcolor.a = 255; return outcolor; diff --git a/src/rendering/swrenderer/drawers/r_draw_wall32.h b/src/rendering/swrenderer/drawers/r_draw_wall32.h index 65f7025b2..92056a9b7 100644 --- a/src/rendering/swrenderer/drawers/r_draw_wall32.h +++ b/src/rendering/swrenderer/drawers/r_draw_wall32.h @@ -236,13 +236,13 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) float Lxy2 = light_x; // L.x*L.x + L.y*L.y float Lz = light_z - viewpos_z; float dist2 = Lxy2 + Lz * Lz; float rcp_dist = 1.f/sqrt(dist2); float dist = dist2 * rcp_dist; - float distance_attenuation = 256.0f - MIN(dist * light_radius, 256.0f); + float distance_attenuation = 256.0f - min(dist * light_radius, 256.0f); // The simple light type float simple_attenuation = distance_attenuation; @@ -260,13 +260,13 @@ namespace swrenderer lit.b += (light_color.b * attenuation) >> 8; } - lit.r = MIN(lit.r, 256); - lit.g = MIN(lit.g, 256); - lit.b = MIN(lit.b, 256); + lit.r = min(lit.r, 256); + lit.g = min(lit.g, 256); + lit.b = min(lit.b, 256); - fgcolor.r = MIN(fgcolor.r + ((material.r * lit.r) >> 8), 255); - fgcolor.g = MIN(fgcolor.g + ((material.g * lit.g) >> 8), 255); - fgcolor.b = MIN(fgcolor.b + ((material.b * lit.b) >> 8), 255); + fgcolor.r = min(fgcolor.r + ((material.r * lit.r) >> 8), 255); + fgcolor.g = min(fgcolor.g + ((material.g * lit.g) >> 8), 255); + fgcolor.b = min(fgcolor.b + ((material.b * lit.b) >> 8), 255); return fgcolor; } @@ -302,21 +302,21 @@ namespace swrenderer BgraColor outcolor; if (BlendT::Mode == (int)WallBlendModes::AddClamp) { - outcolor.r = MIN((fgcolor.r + bgcolor.r) >> 8, 255); - outcolor.g = MIN((fgcolor.g + bgcolor.g) >> 8, 255); - outcolor.b = MIN((fgcolor.b + bgcolor.b) >> 8, 255); + outcolor.r = min((fgcolor.r + bgcolor.r) >> 8, 255); + outcolor.g = min((fgcolor.g + bgcolor.g) >> 8, 255); + outcolor.b = min((fgcolor.b + bgcolor.b) >> 8, 255); } else if (BlendT::Mode == (int)WallBlendModes::SubClamp) { - outcolor.r = MAX(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(fgcolor.r - bgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(fgcolor.g - bgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(fgcolor.b - bgcolor.b) >> 8, 0); } else if (BlendT::Mode == (int)WallBlendModes::RevSubClamp) { - outcolor.r = MAX(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); - outcolor.g = MAX(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); - outcolor.b = MAX(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); + outcolor.r = max(int32_t(bgcolor.r - fgcolor.r) >> 8, 0); + outcolor.g = max(int32_t(bgcolor.g - fgcolor.g) >> 8, 0); + outcolor.b = max(int32_t(bgcolor.b - fgcolor.b) >> 8, 0); } outcolor.a = 255; return outcolor; diff --git a/src/rendering/swrenderer/drawers/r_draw_wall32_sse2.h b/src/rendering/swrenderer/drawers/r_draw_wall32_sse2.h index 4ea8d4d75..1860ba667 100644 --- a/src/rendering/swrenderer/drawers/r_draw_wall32_sse2.h +++ b/src/rendering/swrenderer/drawers/r_draw_wall32_sse2.h @@ -280,7 +280,7 @@ namespace swrenderer // L = light-pos // dist = sqrt(dot(L, L)) - // distance_attenuation = 1 - MIN(dist * (1/radius), 1) + // distance_attenuation = 1 - min(dist * (1/radius), 1) __m128 Lxy2 = light_x; // L.x*L.x + L.y*L.y __m128 Lz = _mm_sub_ps(light_z, viewpos_z); __m128 dist2 = _mm_add_ps(Lxy2, _mm_mul_ps(Lz, Lz)); diff --git a/src/rendering/swrenderer/line/r_farclip_line.cpp b/src/rendering/swrenderer/line/r_farclip_line.cpp index e0f027578..8b2cd07f2 100644 --- a/src/rendering/swrenderer/line/r_farclip_line.cpp +++ b/src/rendering/swrenderer/line/r_farclip_line.cpp @@ -20,7 +20,7 @@ #include #include -#include "templates.h" + #include "doomdef.h" #include "doomstat.h" @@ -155,7 +155,7 @@ namespace swrenderer for (int x = x1; x < x2; ++x) { short top = (clip3d->fakeFloor && m3DFloor.type == Fake3DOpaque::FakeCeiling) ? clip3d->fakeFloor->ceilingclip[x] : ceilingclip[x]; - short bottom = MIN(walltop.ScreenY[x], floorclip[x]); + short bottom = min(walltop.ScreenY[x], floorclip[x]); if (top < bottom) { mCeilingPlane->top[x] = top; @@ -177,7 +177,7 @@ namespace swrenderer for (int x = x1; x < x2; ++x) { - short top = MAX(wallbottom.ScreenY[x], ceilingclip[x]); + short top = max(wallbottom.ScreenY[x], ceilingclip[x]); short bottom = (clip3d->fakeFloor && m3DFloor.type == Fake3DOpaque::FakeFloor) ? clip3d->fakeFloor->floorclip[x] : floorclip[x]; if (top < bottom) { diff --git a/src/rendering/swrenderer/line/r_fogboundary.cpp b/src/rendering/swrenderer/line/r_fogboundary.cpp index 1a6e40519..ca8438bbb 100644 --- a/src/rendering/swrenderer/line/r_fogboundary.cpp +++ b/src/rendering/swrenderer/line/r_fogboundary.cpp @@ -22,7 +22,7 @@ #include #include -#include "templates.h" + #include "filesystem.h" #include "doomdef.h" @@ -110,13 +110,13 @@ namespace swrenderer { if (fake_dc_colormap != basecolormapdata) { - stop = MIN(t1, b2); + stop = min(t1, b2); while (t2 < stop) { int y = t2++; drawerargs.DrawFogBoundaryLine(thread, y, xr, spanend[y]); } - stop = MAX(b1, t2); + stop = max(b1, t2); while (b2 > stop) { int y = --b2; @@ -125,16 +125,16 @@ namespace swrenderer } else { - t2 = MAX(t2, MIN(t1, b2)); - b2 = MIN(b2, MAX(b1, t2)); + t2 = max(t2, min(t1, b2)); + b2 = min(b2, max(b1, t2)); } - stop = MIN(t2, b1); + stop = min(t2, b1); while (t1 < stop) { spanend[t1++] = x; } - stop = MAX(b2, t2); + stop = max(b2, t2); while (b1 > stop) { spanend[--b1] = x; diff --git a/src/rendering/swrenderer/line/r_line.cpp b/src/rendering/swrenderer/line/r_line.cpp index e2e08b268..5422c2760 100644 --- a/src/rendering/swrenderer/line/r_line.cpp +++ b/src/rendering/swrenderer/line/r_line.cpp @@ -22,7 +22,7 @@ #include #include -#include "templates.h" + #include "engineerrors.h" #include "doomdef.h" #include "doomstat.h" @@ -752,7 +752,7 @@ namespace swrenderer for (int x = x1; x < x2; ++x) { short top = (clip3d->fakeFloor && m3DFloor.type == Fake3DOpaque::FakeCeiling) ? clip3d->fakeFloor->ceilingclip[x] : ceilingclip[x]; - short bottom = MIN(walltop.ScreenY[x], floorclip[x]); + short bottom = min(walltop.ScreenY[x], floorclip[x]); if (top < bottom) { mCeilingPlane->top[x] = top; @@ -774,7 +774,7 @@ namespace swrenderer for (int x = x1; x < x2; ++x) { - short top = MAX(wallbottom.ScreenY[x], ceilingclip[x]); + short top = max(wallbottom.ScreenY[x], ceilingclip[x]); short bottom = (clip3d->fakeFloor && m3DFloor.type == Fake3DOpaque::FakeFloor) ? clip3d->fakeFloor->floorclip[x] : floorclip[x]; if (top < bottom) { @@ -804,7 +804,7 @@ namespace swrenderer { for (int x = x1; x < x2; ++x) { - walllower.ScreenY[x] = MIN(MAX(walllower.ScreenY[x], ceilingclip[x]), wallbottom.ScreenY[x]); + walllower.ScreenY[x] = min(max(walllower.ScreenY[x], ceilingclip[x]), wallbottom.ScreenY[x]); } memcpy(clip3d->fakeFloor->floorclip + x1, walllower.ScreenY + x1, (x2 - x1) * sizeof(short)); } @@ -816,7 +816,7 @@ namespace swrenderer { for (int x = x1; x < x2; ++x) { - wallupper.ScreenY[x] = MAX(MIN(wallupper.ScreenY[x], floorclip[x]), walltop.ScreenY[x]); + wallupper.ScreenY[x] = max(min(wallupper.ScreenY[x], floorclip[x]), walltop.ScreenY[x]); } memcpy(clip3d->fakeFloor->ceilingclip + x1, wallupper.ScreenY + x1, (x2 - x1) * sizeof(short)); } @@ -839,7 +839,7 @@ namespace swrenderer { // top wall for (int x = x1; x < x2; ++x) { - wallupper.ScreenY[x] = MAX(MIN(wallupper.ScreenY[x], floorclip[x]), walltop.ScreenY[x]); + wallupper.ScreenY[x] = max(min(wallupper.ScreenY[x], floorclip[x]), walltop.ScreenY[x]); } memcpy(ceilingclip + x1, wallupper.ScreenY + x1, (x2 - x1) * sizeof(short)); } @@ -852,7 +852,7 @@ namespace swrenderer { // bottom wall for (int x = x1; x < x2; ++x) { - walllower.ScreenY[x] = MIN(MAX(walllower.ScreenY[x], ceilingclip[x]), wallbottom.ScreenY[x]); + walllower.ScreenY[x] = min(max(walllower.ScreenY[x], ceilingclip[x]), wallbottom.ScreenY[x]); } memcpy(floorclip + x1, walllower.ScreenY + x1, (x2 - x1) * sizeof(short)); } diff --git a/src/rendering/swrenderer/line/r_renderdrawsegment.cpp b/src/rendering/swrenderer/line/r_renderdrawsegment.cpp index b4c5fa544..ca29e532d 100644 --- a/src/rendering/swrenderer/line/r_renderdrawsegment.cpp +++ b/src/rendering/swrenderer/line/r_renderdrawsegment.cpp @@ -21,7 +21,7 @@ // #include -#include "templates.h" + #include "doomdef.h" #include "m_bbox.h" @@ -122,20 +122,20 @@ namespace swrenderer top -= Thread->Viewport->viewpoint.Pos.Z; bot -= Thread->Viewport->viewpoint.Pos.Z; - ceilZ = MIN(ceilZ, top); - floorZ = MAX(floorZ, bot); + ceilZ = min(ceilZ, top); + floorZ = max(floorZ, bot); } // Clip wall by the current 3D floor render range. if (m3DFloor.clipTop) { double clipZ = m3DFloor.sclipTop - Thread->Viewport->viewpoint.Pos.Z; - ceilZ = MIN(ceilZ, clipZ); + ceilZ = min(ceilZ, clipZ); } if (m3DFloor.clipBottom) { double clipZ = m3DFloor.sclipBottom - Thread->Viewport->viewpoint.Pos.Z; - floorZ = MAX(floorZ, clipZ); + floorZ = max(floorZ, clipZ); } wallupper.Project(Thread->Viewport.get(), ceilZ, &ds->WallC); @@ -191,7 +191,7 @@ namespace swrenderer sector_t tempsec; const sector_t* lightsector = Thread->OpaquePass->FakeFlat(frontsector, &tempsec, nullptr, nullptr, nullptr, 0, 0, 0, 0); - fixed_t alpha = FLOAT2FIXED((float)MIN(curline->linedef->alpha, 1.)); + fixed_t alpha = FLOAT2FIXED((float)min(curline->linedef->alpha, 1.)); bool additive = (curline->linedef->flags & ML_ADDTRANS) != 0; RenderWallPart renderWallpart(Thread); @@ -614,16 +614,16 @@ namespace swrenderer double frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1); double frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2); double frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2); - top = MAX(frontcz1, frontcz2); - bot = MIN(frontfz1, frontfz2); + top = max(frontcz1, frontcz2); + bot = min(frontfz1, frontfz2); if (m3DFloor.clipTop) { - top = MIN(top, m3DFloor.sclipTop); + top = min(top, m3DFloor.sclipTop); } if (m3DFloor.clipBottom) { - bot = MAX(bot, m3DFloor.sclipBottom); + bot = max(bot, m3DFloor.sclipBottom); } } @@ -632,9 +632,9 @@ namespace swrenderer double texheight = tex->GetScaledHeight() / fabs(curline->sidedef->GetTextureYScale(side_t::mid)); double texturemid; if (curline->linedef->flags & ML_DONTPEGBOTTOM) - texturemid = MAX(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight; + texturemid = max(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)) + texheight; else - texturemid = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); + texturemid = min(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); double rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid); if (tex->useWorldPanning(curline->GetLevel())) rowoffset /= fabs(tex->GetScale().Y * curline->sidedef->GetTextureYScale(side_t::mid)); diff --git a/src/rendering/swrenderer/line/r_wallsetup.cpp b/src/rendering/swrenderer/line/r_wallsetup.cpp index 2f864581e..b0372d5b5 100644 --- a/src/rendering/swrenderer/line/r_wallsetup.cpp +++ b/src/rendering/swrenderer/line/r_wallsetup.cpp @@ -22,7 +22,7 @@ #include #include -#include "templates.h" + #include "doomdef.h" #include "doomstat.h" @@ -305,7 +305,7 @@ namespace swrenderer { for (int i = x1; i < x2; i++) { - ScreenY[i] = std::min(ScreenY[i], clip.sprbottomclip[i]); + ScreenY[i] = min(ScreenY[i], clip.sprbottomclip[i]); } } @@ -441,8 +441,8 @@ namespace swrenderer float yscale = GetYScale(sidedef, pic, side_t::mid); double cameraZ = viewport->viewpoint.Pos.Z; - double texZFloor = MAX(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)); - double texZCeiling = MIN(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); + double texZFloor = max(frontsector->GetPlaneTexZ(sector_t::floor), backsector->GetPlaneTexZ(sector_t::floor)); + double texZCeiling = min(frontsector->GetPlaneTexZ(sector_t::ceiling), backsector->GetPlaneTexZ(sector_t::ceiling)); double texturemid; if (yscale >= 0) diff --git a/src/rendering/swrenderer/plane/r_flatplane.cpp b/src/rendering/swrenderer/plane/r_flatplane.cpp index 9075fe910..be0313542 100644 --- a/src/rendering/swrenderer/plane/r_flatplane.cpp +++ b/src/rendering/swrenderer/plane/r_flatplane.cpp @@ -22,7 +22,7 @@ #include #include -#include "templates.h" + #include "engineerrors.h" #include "filesystem.h" #include "doomdef.h" @@ -178,9 +178,9 @@ namespace swrenderer double distance2 = viewport->PlaneDepth(y + 1, planeheight); double xmagnitude = fabs(ystepscale * (distance2 - distance) * viewport->FocalLengthX); double ymagnitude = fabs(xstepscale * (distance2 - distance) * viewport->FocalLengthX); - double magnitude = MAX(ymagnitude, xmagnitude); + double magnitude = max(ymagnitude, xmagnitude); double min_lod = -1000.0; - drawerargs.SetTextureLOD(MAX(log2(magnitude) + r_lod_bias, min_lod)); + drawerargs.SetTextureLOD(max(log2(magnitude) + r_lod_bias, min_lod)); } if (plane_shade) diff --git a/src/rendering/swrenderer/plane/r_planerenderer.cpp b/src/rendering/swrenderer/plane/r_planerenderer.cpp index f251d5c71..9875fe0fe 100644 --- a/src/rendering/swrenderer/plane/r_planerenderer.cpp +++ b/src/rendering/swrenderer/plane/r_planerenderer.cpp @@ -23,7 +23,7 @@ #include #include -#include "templates.h" + #include "filesystem.h" #include "doomdef.h" @@ -65,14 +65,14 @@ namespace swrenderer int stop; // Draw any spans that have just closed - stop = MIN(t1, b2); + stop = min(t1, b2); while (t2 < stop) { int y = t2++; int x2 = spanend[y]; RenderLine(y, xr, x2); } - stop = MAX(b1, t2); + stop = max(b1, t2); while (b2 > stop) { int y = --b2; @@ -81,12 +81,12 @@ namespace swrenderer } // Mark any spans that have just opened - stop = MIN(t2, b1); + stop = min(t2, b1); while (t1 < stop) { spanend[t1++] = x; } - stop = MAX(b2, t2); + stop = max(b2, t2); while (b1 > stop) { spanend[--b1] = x; diff --git a/src/rendering/swrenderer/plane/r_skyplane.cpp b/src/rendering/swrenderer/plane/r_skyplane.cpp index cc59301ad..c3ae7bf85 100644 --- a/src/rendering/swrenderer/plane/r_skyplane.cpp +++ b/src/rendering/swrenderer/plane/r_skyplane.cpp @@ -22,7 +22,7 @@ #include #include -#include "templates.h" + #include "filesystem.h" #include "doomdef.h" @@ -109,8 +109,8 @@ namespace swrenderer // giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024, // we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of // the texture as the cylinder's circumfrence. - sky1cyl = MAX(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024)); - sky2cyl = MAX(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024)); + sky1cyl = max(sskytex1->GetWidth(), fixed_t(sskytex1->GetScale().X * 1024)); + sky2cyl = max(sskytex2->GetWidth(), fixed_t(sskytex2->GetScale().Y * 1024)); } void RenderSkyPlane::Render(VisiblePlane *pl) @@ -199,7 +199,7 @@ namespace swrenderer skyflip = l->args[2] ? 0u : ~0u; int frontxscale = int(frontskytex->GetScale().X * 1024); - frontcyl = MAX(frontskytex->GetWidth(), frontxscale); + frontcyl = max(frontskytex->GetWidth(), frontxscale); if (Level->skystretch) { skymid = skymid * frontskytex->GetScaledHeight() / (SKYSTRETCH_HEIGHT + skyoffset); diff --git a/src/rendering/swrenderer/plane/r_slopeplane.cpp b/src/rendering/swrenderer/plane/r_slopeplane.cpp index 6bc8e946c..279009415 100644 --- a/src/rendering/swrenderer/plane/r_slopeplane.cpp +++ b/src/rendering/swrenderer/plane/r_slopeplane.cpp @@ -22,7 +22,7 @@ #include #include -#include "templates.h" + #include "filesystem.h" #include "doomdef.h" diff --git a/src/rendering/swrenderer/plane/r_visibleplane.cpp b/src/rendering/swrenderer/plane/r_visibleplane.cpp index 75c562194..c8517cac4 100644 --- a/src/rendering/swrenderer/plane/r_visibleplane.cpp +++ b/src/rendering/swrenderer/plane/r_visibleplane.cpp @@ -23,7 +23,7 @@ #include #include -#include "templates.h" + #include "filesystem.h" #include "doomdef.h" diff --git a/src/rendering/swrenderer/plane/r_visibleplanelist.cpp b/src/rendering/swrenderer/plane/r_visibleplanelist.cpp index a265be5d2..791ae8587 100644 --- a/src/rendering/swrenderer/plane/r_visibleplanelist.cpp +++ b/src/rendering/swrenderer/plane/r_visibleplanelist.cpp @@ -23,7 +23,7 @@ #include #include -#include "templates.h" + #include "filesystem.h" #include "doomdef.h" diff --git a/src/rendering/swrenderer/r_renderthread.cpp b/src/rendering/swrenderer/r_renderthread.cpp index 4c3e4d2c6..f19e0bc64 100644 --- a/src/rendering/swrenderer/r_renderthread.cpp +++ b/src/rendering/swrenderer/r_renderthread.cpp @@ -21,7 +21,7 @@ */ #include -#include "templates.h" + #include "doomdef.h" #include "m_bbox.h" diff --git a/src/rendering/swrenderer/r_swcolormaps.cpp b/src/rendering/swrenderer/r_swcolormaps.cpp index f488e4e82..0ce48fe5f 100644 --- a/src/rendering/swrenderer/r_swcolormaps.cpp +++ b/src/rendering/swrenderer/r_swcolormaps.cpp @@ -52,7 +52,7 @@ #include "r_data/colormaps.h" #include "r_swcolormaps.h" #include "v_video.h" -#include "templates.h" + #include "r_utility.h" #include "swrenderer/r_renderer.h" #include diff --git a/src/rendering/swrenderer/scene/r_3dfloors.cpp b/src/rendering/swrenderer/scene/r_3dfloors.cpp index 8196462f4..78c88b0ab 100644 --- a/src/rendering/swrenderer/scene/r_3dfloors.cpp +++ b/src/rendering/swrenderer/scene/r_3dfloors.cpp @@ -32,7 +32,7 @@ ** */ -#include "templates.h" + #include "doomdef.h" #include "p_local.h" #include "c_dispatch.h" diff --git a/src/rendering/swrenderer/scene/r_light.cpp b/src/rendering/swrenderer/scene/r_light.cpp index 5b8a689b2..2e6046ffb 100644 --- a/src/rendering/swrenderer/scene/r_light.cpp +++ b/src/rendering/swrenderer/scene/r_light.cpp @@ -23,7 +23,7 @@ #include #include -#include "templates.h" + #include "filesystem.h" #include "doomdef.h" @@ -149,7 +149,7 @@ namespace swrenderer bool nolightfade = !foggy && ((viewport->Level()->flags3 & LEVEL3_NOLIGHTFADE)); if (nolightfade) { - return (MAX(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8); + return (max(255 - lightlevel, 0) * NUMCOLORMAPS) << (FRACBITS - 8); } else { diff --git a/src/rendering/swrenderer/scene/r_light.h b/src/rendering/swrenderer/scene/r_light.h index d14c73b55..8f1d6adcc 100644 --- a/src/rendering/swrenderer/scene/r_light.h +++ b/src/rendering/swrenderer/scene/r_light.h @@ -43,12 +43,12 @@ // Convert a shade and visibility to a clamped colormap index. // Result is not fixed point. // Change R_CalcTiltedLighting() when this changes. -#define GETPALOOKUP(vis,shade) (clamp (((shade)-FLOAT2FIXED(MIN(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1)) +#define GETPALOOKUP(vis,shade) (clamp (((shade)-FLOAT2FIXED(min(MAXLIGHTVIS,double(vis))))>>FRACBITS, 0, NUMCOLORMAPS-1)) // Calculate the light multiplier for dc_light/ds_light // This is used instead of GETPALOOKUP when ds_colormap/dc_colormap is set to the base colormap // Returns a value between 0 and 1 in fixed point -#define LIGHTSCALE(vis,shade) FLOAT2FIXED(clamp((FIXED2DBL(shade) - (MIN(MAXLIGHTVIS,double(vis)))) / NUMCOLORMAPS, 0.0, (NUMCOLORMAPS-1)/(double)NUMCOLORMAPS)) +#define LIGHTSCALE(vis,shade) FLOAT2FIXED(clamp((FIXED2DBL(shade) - (min(MAXLIGHTVIS,double(vis)))) / NUMCOLORMAPS, 0.0, (NUMCOLORMAPS-1)/(double)NUMCOLORMAPS)) struct FSWColormap; @@ -82,7 +82,7 @@ namespace swrenderer // The vis value to pass into the GETPALOOKUP or LIGHTSCALE macros double WallVis(double screenZ, bool foggy) const { return WallGlobVis(foggy) / screenZ; } - double SpriteVis(double screenZ, bool foggy) const { return SpriteGlobVis(foggy) / MAX(screenZ, MINZ); } + double SpriteVis(double screenZ, bool foggy) const { return SpriteGlobVis(foggy) / max(screenZ, MINZ); } double FlatPlaneVis(int screenY, double planeheight, bool foggy, RenderViewport *viewport) const { return FlatPlaneGlobVis(foggy) / planeheight * fabs(viewport->CenterY - screenY); } double SlopePlaneGlobVis(bool foggy) const { return (NoLightFade && !foggy) ? 0.0f : TiltVisibility; } diff --git a/src/rendering/swrenderer/scene/r_opaque_pass.cpp b/src/rendering/swrenderer/scene/r_opaque_pass.cpp index 9bb69562c..dc6d22e7e 100644 --- a/src/rendering/swrenderer/scene/r_opaque_pass.cpp +++ b/src/rendering/swrenderer/scene/r_opaque_pass.cpp @@ -28,7 +28,7 @@ #include -#include "templates.h" + #include "doomdef.h" @@ -700,7 +700,7 @@ namespace swrenderer if (!(clip3d->fakeFloor->fakeFloor->flags & FF_RENDERPLANES)) continue; if (clip3d->fakeFloor->fakeFloor->alpha == 0) continue; if (clip3d->fakeFloor->fakeFloor->flags & FF_THISINSIDE && clip3d->fakeFloor->fakeFloor->flags & FF_INVERTSECTOR) continue; - fixed_t fakeAlpha = MIN(Scale(clip3d->fakeFloor->fakeFloor->alpha, OPAQUE, 255), OPAQUE); + fixed_t fakeAlpha = min(Scale(clip3d->fakeFloor->fakeFloor->alpha, OPAQUE, 255), OPAQUE); if (clip3d->fakeFloor->validcount != validcount) { clip3d->fakeFloor->validcount = validcount; @@ -764,7 +764,7 @@ namespace swrenderer if (!(clip3d->fakeFloor->fakeFloor->flags & FF_RENDERPLANES)) continue; if (clip3d->fakeFloor->fakeFloor->alpha == 0) continue; if (!(clip3d->fakeFloor->fakeFloor->flags & FF_THISINSIDE) && (clip3d->fakeFloor->fakeFloor->flags & (FF_SWIMMABLE | FF_INVERTSECTOR)) == (FF_SWIMMABLE | FF_INVERTSECTOR)) continue; - fixed_t fakeAlpha = MIN(Scale(clip3d->fakeFloor->fakeFloor->alpha, OPAQUE, 255), OPAQUE); + fixed_t fakeAlpha = min(Scale(clip3d->fakeFloor->fakeFloor->alpha, OPAQUE, 255), OPAQUE); if (clip3d->fakeFloor->validcount != validcount) { diff --git a/src/rendering/swrenderer/scene/r_portal.cpp b/src/rendering/swrenderer/scene/r_portal.cpp index f0c914671..f56c702a6 100644 --- a/src/rendering/swrenderer/scene/r_portal.cpp +++ b/src/rendering/swrenderer/scene/r_portal.cpp @@ -24,7 +24,7 @@ #include #include -#include "templates.h" + #include "doomdef.h" #include "d_net.h" #include "doomstat.h" diff --git a/src/rendering/swrenderer/scene/r_scene.cpp b/src/rendering/swrenderer/scene/r_scene.cpp index 2558a2f2a..7bc3bec2f 100644 --- a/src/rendering/swrenderer/scene/r_scene.cpp +++ b/src/rendering/swrenderer/scene/r_scene.cpp @@ -22,7 +22,7 @@ #include #include -#include "templates.h" + #include "v_draw.h" #include "filesystem.h" #include "doomdef.h" diff --git a/src/rendering/swrenderer/scene/r_translucent_pass.cpp b/src/rendering/swrenderer/scene/r_translucent_pass.cpp index 9d83549d0..101f53ef7 100644 --- a/src/rendering/swrenderer/scene/r_translucent_pass.cpp +++ b/src/rendering/swrenderer/scene/r_translucent_pass.cpp @@ -23,7 +23,7 @@ #include #include #include "p_lnspec.h" -#include "templates.h" + #include "doomdef.h" #include "m_swap.h" diff --git a/src/rendering/swrenderer/segments/r_clipsegment.cpp b/src/rendering/swrenderer/segments/r_clipsegment.cpp index 3afb4bab3..b08cab770 100644 --- a/src/rendering/swrenderer/segments/r_clipsegment.cpp +++ b/src/rendering/swrenderer/segments/r_clipsegment.cpp @@ -20,7 +20,7 @@ //----------------------------------------------------------------------------- #include -#include "templates.h" + #include "doomdef.h" #include "m_bbox.h" diff --git a/src/rendering/swrenderer/segments/r_drawsegment.cpp b/src/rendering/swrenderer/segments/r_drawsegment.cpp index fd7517d72..6905ebf44 100644 --- a/src/rendering/swrenderer/segments/r_drawsegment.cpp +++ b/src/rendering/swrenderer/segments/r_drawsegment.cpp @@ -20,7 +20,7 @@ //----------------------------------------------------------------------------- #include -#include "templates.h" + #include "doomdef.h" #include "m_bbox.h" @@ -104,21 +104,21 @@ namespace swrenderer DrawSegmentGroup group; group.BeginIndex = index; - group.EndIndex = MIN(index + groupSize, SegmentsCount()); + group.EndIndex = min(index + groupSize, SegmentsCount()); group.x1 = ds->x1; group.x2 = ds->x2; - group.neardepth = MIN(ds->WallC.sz1, ds->WallC.sz2); - group.fardepth = MAX(ds->WallC.sz1, ds->WallC.sz2); + group.neardepth = min(ds->WallC.sz1, ds->WallC.sz2); + group.fardepth = max(ds->WallC.sz1, ds->WallC.sz2); for (unsigned int groupIndex = group.BeginIndex + 1; groupIndex < group.EndIndex; groupIndex++) { ds = Segment(groupIndex); - group.x1 = MIN(group.x1, ds->x1); - group.x2 = MAX(group.x2, ds->x2); - group.neardepth = MIN(group.neardepth, ds->WallC.sz1); - group.neardepth = MIN(group.neardepth, ds->WallC.sz2); - group.fardepth = MAX(ds->WallC.sz1, group.fardepth); - group.fardepth = MAX(ds->WallC.sz2, group.fardepth); + group.x1 = min(group.x1, ds->x1); + group.x2 = max(group.x2, ds->x2); + group.neardepth = min(group.neardepth, ds->WallC.sz1); + group.neardepth = min(group.neardepth, ds->WallC.sz2); + group.fardepth = max(ds->WallC.sz1, group.fardepth); + group.fardepth = max(ds->WallC.sz2, group.fardepth); } for (int x = group.x1; x < group.x2; x++) diff --git a/src/rendering/swrenderer/segments/r_portalsegment.cpp b/src/rendering/swrenderer/segments/r_portalsegment.cpp index 6f69c7869..dbdd7892d 100644 --- a/src/rendering/swrenderer/segments/r_portalsegment.cpp +++ b/src/rendering/swrenderer/segments/r_portalsegment.cpp @@ -20,7 +20,7 @@ //----------------------------------------------------------------------------- #include -#include "templates.h" + #include "doomdef.h" #include "m_bbox.h" diff --git a/src/rendering/swrenderer/textures/r_swtexture.cpp b/src/rendering/swrenderer/textures/r_swtexture.cpp index 662c12d57..1336abfd2 100644 --- a/src/rendering/swrenderer/textures/r_swtexture.cpp +++ b/src/rendering/swrenderer/textures/r_swtexture.cpp @@ -364,8 +364,8 @@ void FSoftwareTexture::CreatePixelsBgraWithMipmaps() int buffersize = 0; for (int i = 0; i < levels; i++) { - int w = MAX(GetPhysicalWidth() >> i, 1); - int h = MAX(GetPhysicalHeight() >> i, 1); + int w = max(GetPhysicalWidth() >> i, 1); + int h = max(GetPhysicalHeight() >> i, 1); buffersize += w * h; } PixelsBgra.Resize(buffersize); @@ -379,7 +379,7 @@ int FSoftwareTexture::MipmapLevels() int heightbits = 0; while ((GetPhysicalHeight() >> heightbits) != 0) heightbits++; - return MAX(widthbits, heightbits); + return max(widthbits, heightbits); } //========================================================================== @@ -430,20 +430,20 @@ void FSoftwareTexture::GenerateBgraMipmaps() Color4f *dest = src + GetPhysicalWidth() * GetPhysicalHeight(); for (int i = 1; i < levels; i++) { - int srcw = MAX(GetPhysicalWidth() >> (i - 1), 1); - int srch = MAX(GetPhysicalHeight() >> (i - 1), 1); - int w = MAX(GetPhysicalWidth() >> i, 1); - int h = MAX(GetPhysicalHeight() >> i, 1); + int srcw = max(GetPhysicalWidth() >> (i - 1), 1); + int srch = max(GetPhysicalHeight() >> (i - 1), 1); + int w = max(GetPhysicalWidth() >> i, 1); + int h = max(GetPhysicalHeight() >> i, 1); // Downscale for (int x = 0; x < w; x++) { int sx0 = x * 2; - int sx1 = MIN((x + 1) * 2, srcw - 1); + int sx1 = min((x + 1) * 2, srcw - 1); for (int y = 0; y < h; y++) { int sy0 = y * 2; - int sy1 = MIN((y + 1) * 2, srch - 1); + int sy1 = min((y + 1) * 2, srch - 1); Color4f src00 = src[sy0 + sx0 * srch]; Color4f src01 = src[sy1 + sx0 * srch]; @@ -493,14 +493,14 @@ void FSoftwareTexture::GenerateBgraMipmaps() uint32_t *dest = PixelsBgra.Data() + GetPhysicalWidth() * GetPhysicalHeight(); for (int i = 1; i < levels; i++) { - int w = MAX(GetPhysicalWidth() >> i, 1); - int h = MAX(GetPhysicalHeight() >> i, 1); + int w = max(GetPhysicalWidth() >> i, 1); + int h = max(GetPhysicalHeight() >> i, 1); for (int j = 0; j < w * h; j++) { - uint32_t a = (uint32_t)clamp(powf(MAX(src[j].a, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t r = (uint32_t)clamp(powf(MAX(src[j].r, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t g = (uint32_t)clamp(powf(MAX(src[j].g, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); - uint32_t b = (uint32_t)clamp(powf(MAX(src[j].b, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t a = (uint32_t)clamp(powf(max(src[j].a, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t r = (uint32_t)clamp(powf(max(src[j].r, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t g = (uint32_t)clamp(powf(max(src[j].g, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); + uint32_t b = (uint32_t)clamp(powf(max(src[j].b, 0.0f), 1.0f / 2.2f) * 255.0f + 0.5f, 0.0f, 255.0f); dest[j] = (a << 24) | (r << 16) | (g << 8) | b; } src += w * h; diff --git a/src/rendering/swrenderer/textures/warpbuffer.h b/src/rendering/swrenderer/textures/warpbuffer.h index 114b8af00..778706850 100644 --- a/src/rendering/swrenderer/textures/warpbuffer.h +++ b/src/rendering/swrenderer/textures/warpbuffer.h @@ -43,7 +43,7 @@ void WarpBuffer(TYPE *Pixels, const TYPE *source, int width, int height, int xmu if (warptype == 1) { - TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * MAX(width, height)); + TYPE *buffer = (TYPE *)alloca(sizeof(TYPE) * max(width, height)); // [mxd] Rewrote to fix animation for NPo2 textures unsigned timebase = unsigned(time * Speed * 32 / 28); for (y = height - 1; y >= 0; y--) diff --git a/src/rendering/swrenderer/textures/warptexture.cpp b/src/rendering/swrenderer/textures/warptexture.cpp index ce3cb2f52..10e51ddb0 100644 --- a/src/rendering/swrenderer/textures/warptexture.cpp +++ b/src/rendering/swrenderer/textures/warptexture.cpp @@ -126,20 +126,20 @@ void FWarpTexture::GenerateBgraMipmapsFast() int levels = MipmapLevels(); for (int i = 1; i < levels; i++) { - int srcw = MAX(GetPhysicalWidth() >> (i - 1), 1); - int srch = MAX(GetPhysicalHeight() >> (i - 1), 1); - int w = MAX(GetPhysicalWidth() >> i, 1); - int h = MAX(GetPhysicalHeight() >> i, 1); + int srcw = max(GetPhysicalWidth() >> (i - 1), 1); + int srch = max(GetPhysicalHeight() >> (i - 1), 1); + int w = max(GetPhysicalWidth() >> i, 1); + int h = max(GetPhysicalHeight() >> i, 1); for (int x = 0; x < w; x++) { int sx0 = x * 2; - int sx1 = MIN((x + 1) * 2, srcw - 1); + int sx1 = min((x + 1) * 2, srcw - 1); for (int y = 0; y < h; y++) { int sy0 = y * 2; - int sy1 = MIN((y + 1) * 2, srch - 1); + int sy1 = min((y + 1) * 2, srch - 1); uint32_t src00 = src[sy0 + sx0 * srch]; uint32_t src01 = src[sy1 + sx0 * srch]; diff --git a/src/rendering/swrenderer/things/r_decal.cpp b/src/rendering/swrenderer/things/r_decal.cpp index ffe06c0a1..aa2a40b88 100644 --- a/src/rendering/swrenderer/things/r_decal.cpp +++ b/src/rendering/swrenderer/things/r_decal.cpp @@ -21,7 +21,7 @@ #include #include -#include "templates.h" + #include "doomdef.h" #include "doomstat.h" diff --git a/src/rendering/swrenderer/things/r_model.cpp b/src/rendering/swrenderer/things/r_model.cpp index 548dc7bab..4e61e362d 100644 --- a/src/rendering/swrenderer/things/r_model.cpp +++ b/src/rendering/swrenderer/things/r_model.cpp @@ -21,7 +21,7 @@ */ #include -#include "templates.h" + #include "doomdef.h" #include "sbar.h" #include "r_data/r_translate.h" diff --git a/src/rendering/swrenderer/things/r_particle.cpp b/src/rendering/swrenderer/things/r_particle.cpp index 6e9f2b00e..3986a8b2d 100644 --- a/src/rendering/swrenderer/things/r_particle.cpp +++ b/src/rendering/swrenderer/things/r_particle.cpp @@ -23,7 +23,7 @@ #include #include #include "p_lnspec.h" -#include "templates.h" + #include "doomdef.h" #include "m_swap.h" @@ -120,8 +120,8 @@ namespace swrenderer // calculate edges of the shape double psize = particle->size / 8.0; - x1 = MAX(renderportal->WindowLeft, thread->Viewport->viewwindow.centerx + xs_RoundToInt((tx - psize) * xscale)); - x2 = MIN(renderportal->WindowRight, thread->Viewport->viewwindow.centerx + xs_RoundToInt((tx + psize) * xscale)); + x1 = max(renderportal->WindowLeft, thread->Viewport->viewwindow.centerx + xs_RoundToInt((tx - psize) * xscale)); + x2 = min(renderportal->WindowRight, thread->Viewport->viewwindow.centerx + xs_RoundToInt((tx + psize) * xscale)); if (x1 >= x2) return; @@ -285,7 +285,7 @@ namespace swrenderer if (ds->drawsegclip.CurrentPortalUniq == CurrentPortalUniq) { RenderDrawSegment renderer(thread); - renderer.Render(ds, MAX(ds->x1, x1), MIN(ds->x2, x2), clip3DFloor); + renderer.Render(ds, max(ds->x1, x1), min(ds->x2, x2), clip3DFloor); } } } diff --git a/src/rendering/swrenderer/things/r_playersprite.cpp b/src/rendering/swrenderer/things/r_playersprite.cpp index f1fc735ab..45d3d5fa2 100644 --- a/src/rendering/swrenderer/things/r_playersprite.cpp +++ b/src/rendering/swrenderer/things/r_playersprite.cpp @@ -23,7 +23,7 @@ #include #include #include "p_lnspec.h" -#include "templates.h" + #include "doomdef.h" #include "m_swap.h" diff --git a/src/rendering/swrenderer/things/r_sprite.cpp b/src/rendering/swrenderer/things/r_sprite.cpp index 3602afa11..39c2e82e3 100644 --- a/src/rendering/swrenderer/things/r_sprite.cpp +++ b/src/rendering/swrenderer/things/r_sprite.cpp @@ -23,7 +23,7 @@ #include #include #include "p_lnspec.h" -#include "templates.h" + #include "doomdef.h" #include "m_swap.h" diff --git a/src/rendering/swrenderer/things/r_visiblesprite.cpp b/src/rendering/swrenderer/things/r_visiblesprite.cpp index 16e3435c5..9d12a83ee 100644 --- a/src/rendering/swrenderer/things/r_visiblesprite.cpp +++ b/src/rendering/swrenderer/things/r_visiblesprite.cpp @@ -23,7 +23,7 @@ #include #include #include "p_lnspec.h" -#include "templates.h" + #include "doomdef.h" #include "m_swap.h" @@ -61,8 +61,8 @@ namespace swrenderer DrawSegment *ds = segmentlist->TranslucentSegment(index); if (ds->drawsegclip.SubsectorDepth >= SubsectorDepth && ds->drawsegclip.CurrentPortalUniq == renderportal->CurrentPortalUniq) { - int r1 = MAX(ds->x1, 0); - int r2 = MIN(ds->x2, viewwidth - 1); + int r1 = max(ds->x1, 0); + int r2 = min(ds->x2, viewwidth - 1); RenderDrawSegment renderer(thread); renderer.Render(ds, r1, r2, clip3DFloor); @@ -200,17 +200,17 @@ namespace swrenderer { // seen below floor: clip top if (!spr->IsVoxel() && h > topclip) { - topclip = short(MIN(h, viewheight)); + topclip = short(min(h, viewheight)); } - hzt = MIN(hzt, hz); + hzt = min(hzt, hz); } else { // seen in the middle: clip bottom if (!spr->IsVoxel() && h < botclip) { - botclip = MAX(0, h); + botclip = max(0, h); } - hzb = MAX(hzb, hz); + hzb = max(hzb, hz); } } if (spr->FakeFlatStat != WaterFakeSide::BelowFloor && !(spr->heightsec->MoreFlags & SECMF_FAKEFLOORONLY)) @@ -222,17 +222,17 @@ namespace swrenderer { // seen above ceiling: clip bottom if (!spr->IsVoxel() && h < botclip) { - botclip = MAX(0, h); + botclip = max(0, h); } - hzb = MAX(hzb, hz); + hzb = max(hzb, hz); } else { // seen in the middle: clip top if (!spr->IsVoxel() && h > topclip) { - topclip = MIN(h, viewheight); + topclip = min(h, viewheight); } - hzt = MIN(hzt, hz); + hzt = min(hzt, hz); } } } @@ -242,7 +242,7 @@ namespace swrenderer int clip = xs_RoundToInt(viewport->CenterY - (spr->texturemid - spr->pic->GetHeight() + spr->floorclip) * spr->yscale); if (clip < botclip) { - botclip = MAX(0, clip); + botclip = max(0, clip); } } @@ -262,10 +262,10 @@ namespace swrenderer int h = xs_RoundToInt(viewport->CenterY - (hz - viewport->viewpoint.Pos.Z) * scale); if (h < botclip) { - botclip = MAX(0, h); + botclip = max(0, h); } } - hzb = MAX(hzb, clip3DFloor.sclipBottom); + hzb = max(hzb, clip3DFloor.sclipBottom); } if (clip3DFloor.clipTop) { @@ -283,10 +283,10 @@ namespace swrenderer int h = xs_RoundToInt(viewport->CenterY - (hz - viewport->viewpoint.Pos.Z) * scale); if (h > topclip) { - topclip = short(MIN(h, viewheight)); + topclip = short(min(h, viewheight)); } } - hzt = MIN(hzt, clip3DFloor.sclipTop); + hzt = min(hzt, clip3DFloor.sclipTop); } if (topclip >= botclip) @@ -322,8 +322,8 @@ namespace swrenderer DrawSegment *ds = segmentlist->TranslucentSegment(index); if (ds->drawsegclip.SubsectorDepth >= subsectordepth && ds->drawsegclip.CurrentPortalUniq == renderportal->CurrentPortalUniq) { - int r1 = MAX(ds->x1, 0); - int r2 = MIN(ds->x2, viewwidth - 1); + int r1 = max(ds->x1, 0); + int r2 = min(ds->x2, viewwidth - 1); RenderDrawSegment renderer(thread); renderer.Render(ds, r1, r2, clip3DFloor); @@ -341,8 +341,8 @@ namespace swrenderer continue; } - float neardepth = MIN(ds->WallC.sz1, ds->WallC.sz2); - float fardepth = MAX(ds->WallC.sz1, ds->WallC.sz2); + float neardepth = min(ds->WallC.sz1, ds->WallC.sz2); + float fardepth = max(ds->WallC.sz1, ds->WallC.sz2); // Check if sprite is in front of draw seg: if ((!spr->IsWallSprite() && neardepth > spr->depth) || ((spr->IsWallSprite() || fardepth > spr->depth) && @@ -351,8 +351,8 @@ namespace swrenderer { if (ds->drawsegclip.CurrentPortalUniq == renderportal->CurrentPortalUniq) { - int r1 = MAX(ds->x1, x1); - int r2 = MIN(ds->x2, x2); + int r1 = max(ds->x1, x1); + int r2 = min(ds->x2, x2); RenderDrawSegment renderer(thread); renderer.Render(ds, r1, r2, clip3DFloor); @@ -370,8 +370,8 @@ namespace swrenderer if (group.fardepth < spr->depth) { - int r1 = MAX(group.x1, x1); - int r2 = MIN(group.x2, x2); + int r1 = max(group.x1, x1); + int r2 = min(group.x2, x2); // Clip bottom short *clip1 = clipbot + r1; @@ -410,11 +410,11 @@ namespace swrenderer continue; } - int r1 = MAX(ds->x1, x1); - int r2 = MIN(ds->x2, x2); + int r1 = max(ds->x1, x1); + int r2 = min(ds->x2, x2); - float neardepth = MIN(ds->WallC.sz1, ds->WallC.sz2); - float fardepth = MAX(ds->WallC.sz1, ds->WallC.sz2); + float neardepth = min(ds->WallC.sz1, ds->WallC.sz2); + float fardepth = max(ds->WallC.sz1, ds->WallC.sz2); // Check if sprite is in front of draw seg: if ((!spr->IsWallSprite() && neardepth > spr->depth) || ((spr->IsWallSprite() || fardepth > spr->depth) && diff --git a/src/rendering/swrenderer/things/r_visiblespritelist.cpp b/src/rendering/swrenderer/things/r_visiblespritelist.cpp index 99c3748ce..9f4880640 100644 --- a/src/rendering/swrenderer/things/r_visiblespritelist.cpp +++ b/src/rendering/swrenderer/things/r_visiblespritelist.cpp @@ -23,7 +23,7 @@ #include #include #include "p_lnspec.h" -#include "templates.h" + #include "doomdef.h" #include "m_swap.h" diff --git a/src/rendering/swrenderer/things/r_voxel.cpp b/src/rendering/swrenderer/things/r_voxel.cpp index dc8ef9de1..fa5a38c68 100644 --- a/src/rendering/swrenderer/things/r_voxel.cpp +++ b/src/rendering/swrenderer/things/r_voxel.cpp @@ -32,7 +32,7 @@ // the GNU General Public License v3.0. #include -#include "templates.h" + #include "doomdef.h" #include "sbar.h" #include "r_data/r_translate.h" @@ -324,7 +324,7 @@ namespace swrenderer // Select mip level i = abs(DMulScale(dasprx - globalposx, cosang, daspry - globalposy, sinang, 6)); - i = DivScale(i, MIN(daxscale, dayscale), 6); + i = DivScale(i, min(daxscale, dayscale), 6); j = xs_Fix<13>::ToFix(viewport->FocalLengthX); for (k = 0; i >= j && k < voxobj->NumMips; ++k) { @@ -372,7 +372,7 @@ namespace swrenderer gyinc = DMulScale(sprcosang, cosang, sprsinang, sinang, 10); if ((abs(globalposz - dasprz) >> 10) >= abs(dazscale)) return; - x = 0; y = 0; j = MAX(mip->SizeX, mip->SizeY); + x = 0; y = 0; j = max(mip->SizeX, mip->SizeY); fixed_t *ggxinc = (fixed_t *)alloca((j + 1) * sizeof(fixed_t) * 2); fixed_t *ggyinc = ggxinc + (j + 1); for (i = 0; i <= j; i++) @@ -487,8 +487,8 @@ namespace swrenderer if (flags & DVF_FIND_X1X2) { - coverageX1 = MIN(coverageX1, lx); - coverageX2 = MAX(coverageX2, rx); + coverageX1 = min(coverageX1, lx); + coverageX2 = max(coverageX2, rx); continue; } @@ -550,9 +550,9 @@ namespace swrenderer else yinc = (((1 << 24) - 1) / (z2 - z1)) * zleng >> 8; } // [RH] Clip each column separately, not just by the first one. - for (int stripwidth = MIN(countof(z1a), rx - lx), lxt = lx; + for (int stripwidth = min(countof(z1a), rx - lx), lxt = lx; lxt < rx; - (lxt += countof(z1a)), stripwidth = MIN(countof(z1a), rx - lxt)) + (lxt += countof(z1a)), stripwidth = min(countof(z1a), rx - lxt)) { // Calculate top and bottom pixels locations for (int xxx = 0; xxx < stripwidth; ++xxx) @@ -560,7 +560,7 @@ namespace swrenderer if (zleng == 1) { yplc[xxx] = 0; - z1a[xxx] = MAX(z1, daumost[lxt + xxx]); + z1a[xxx] = max(z1, daumost[lxt + xxx]); } else { @@ -575,7 +575,7 @@ namespace swrenderer z1a[xxx] = z1; } } - z2a[xxx] = MIN(z2, dadmost[lxt + xxx]); + z2a[xxx] = min(z2, dadmost[lxt + xxx]); } const uint8_t *columnColors = col; @@ -991,8 +991,8 @@ namespace swrenderer int ztop = slab->ztop; int zbottom = ztop + slab->zleng; - //ztop = MAX(ztop, minZ); - //zbottom = MIN(zbottom, maxZ); + //ztop = max(ztop, minZ); + //zbottom = min(zbottom, maxZ); for (int z = ztop; z < zbottom; z++) { @@ -1023,10 +1023,10 @@ namespace swrenderer DVector3 screenPos = viewport->PointViewToScreen(viewPos); DVector2 screenExtent = viewport->ScaleViewToScreen({ extentX, extentY }, viewPos.Z, pixelstretch); - int x1 = MAX((int)(screenPos.X - screenExtent.X), 0); - int x2 = MIN((int)(screenPos.X + screenExtent.X + 0.5f), viewwidth - 1); - int y1 = MAX((int)(screenPos.Y - screenExtent.Y), 0); - int y2 = MIN((int)(screenPos.Y + screenExtent.Y + 0.5f), viewheight - 1); + int x1 = max((int)(screenPos.X - screenExtent.X), 0); + int x2 = min((int)(screenPos.X + screenExtent.X + 0.5f), viewwidth - 1); + int y1 = max((int)(screenPos.Y - screenExtent.Y), 0); + int y2 = min((int)(screenPos.Y + screenExtent.Y + 0.5f), viewheight - 1); int pixelsize = viewport->RenderTarget->IsBgra() ? 4 : 1; @@ -1034,8 +1034,8 @@ namespace swrenderer { for (int x = x1; x < x2; x++) { - int columnY1 = MAX(y1, (int)cliptop[x]); - int columnY2 = MIN(y2, (int)clipbottom[x]); + int columnY1 = max(y1, (int)cliptop[x]); + int columnY2 = min(y2, (int)clipbottom[x]); if (columnY1 < columnY2) { drawerargs.SetDest(x, columnY1); diff --git a/src/rendering/swrenderer/things/r_wallsprite.cpp b/src/rendering/swrenderer/things/r_wallsprite.cpp index bc14fc148..e00b38148 100644 --- a/src/rendering/swrenderer/things/r_wallsprite.cpp +++ b/src/rendering/swrenderer/things/r_wallsprite.cpp @@ -23,7 +23,7 @@ #include #include #include "p_lnspec.h" -#include "templates.h" + #include "doomdef.h" #include "m_swap.h" @@ -159,8 +159,8 @@ namespace swrenderer { auto spr = this; - int x1 = MAX(spr->x1, spr->wallc.sx1); - int x2 = MIN(spr->x2, spr->wallc.sx2); + int x1 = max(spr->x1, spr->wallc.sx1); + int x2 = min(spr->x2, spr->wallc.sx2); if (x1 >= x2) return; diff --git a/src/rendering/swrenderer/viewport/r_drawerargs.cpp b/src/rendering/swrenderer/viewport/r_drawerargs.cpp index cf12dc41f..9591b4498 100644 --- a/src/rendering/swrenderer/viewport/r_drawerargs.cpp +++ b/src/rendering/swrenderer/viewport/r_drawerargs.cpp @@ -81,7 +81,7 @@ namespace swrenderer shadeConstants.fade_green = mBaseColormap->Fade.g; shadeConstants.fade_blue = mBaseColormap->Fade.b; shadeConstants.fade_alpha = mBaseColormap->Fade.a; - shadeConstants.desaturate = MIN(abs(mBaseColormap->Desaturate), 255) * 255 / 256; + shadeConstants.desaturate = min(abs(mBaseColormap->Desaturate), 255) * 255 / 256; shadeConstants.simple_shade = (mBaseColormap->Color.d == 0x00ffffff && mBaseColormap->Fade.d == 0x00000000 && mBaseColormap->Desaturate == 0); } else diff --git a/src/rendering/swrenderer/viewport/r_drawerargs.h b/src/rendering/swrenderer/viewport/r_drawerargs.h index 0cd5d3d20..339e00e55 100644 --- a/src/rendering/swrenderer/viewport/r_drawerargs.h +++ b/src/rendering/swrenderer/viewport/r_drawerargs.h @@ -1,7 +1,7 @@ #pragma once -#include "templates.h" + #include "doomtype.h" #include "doomdef.h" #include "r_defs.h" diff --git a/src/rendering/swrenderer/viewport/r_spritedrawer.cpp b/src/rendering/swrenderer/viewport/r_spritedrawer.cpp index 316f6af91..8217eeaf5 100644 --- a/src/rendering/swrenderer/viewport/r_spritedrawer.cpp +++ b/src/rendering/swrenderer/viewport/r_spritedrawer.cpp @@ -70,8 +70,8 @@ namespace swrenderer iscale = -iscale; float vstepY = iscale / WallC.sz1 / (viewport->InvZtoScale / WallC.sz1); - int x1 = MAX(WallC.sx1, clipx1); - int x2 = MIN(WallC.sx2, clipx2); + int x1 = max(WallC.sx1, clipx1); + int x2 = min(WallC.sx2, clipx2); if (x1 >= x2) return; @@ -127,10 +127,10 @@ namespace swrenderer void SpriteDrawerArgs::DrawMasked2D(RenderThread* thread, double x0, double x1, double y0, double y1, FSoftwareTexture* tex, FRenderStyle style) { - int sx0 = MAX((int)x0, 0); - int sx1 = MIN((int)x1, viewwidth); - int sy0 = MAX((int)y0, 0); - int sy1 = MIN((int)y1, viewheight); + int sx0 = max((int)x0, 0); + int sx1 = min((int)x1, viewwidth); + int sy0 = max((int)y0, 0); + int sy1 = min((int)y1, viewheight); if (sx0 >= sx1 || sy0 >= sy1) return; @@ -169,9 +169,9 @@ namespace swrenderer { double xmagnitude = fabs(static_cast(texelStepX)* (1.0 / 0x1'0000'0000LL)); double ymagnitude = fabs(static_cast(texelStepY)* (1.0 / 0x1'0000'0000LL)); - double magnitude = MAX(ymagnitude, xmagnitude); + double magnitude = max(ymagnitude, xmagnitude); double min_lod = -1000.0; - double lod = MAX(log2(magnitude) + r_lod_bias, min_lod); + double lod = max(log2(magnitude) + r_lod_bias, min_lod); bool magnifying = lod < 0.0f; int mipmap_offset = 0; @@ -184,8 +184,8 @@ namespace swrenderer { mipmap_offset += mip_width * mip_height; level--; - mip_width = MAX(mip_width >> 1, 1); - mip_height = MAX(mip_height >> 1, 1); + mip_width = max(mip_width >> 1, 1); + mip_height = max(mip_height >> 1, 1); } } @@ -195,7 +195,7 @@ namespace swrenderer bool filter_nearest = (magnifying && !r_magfilter) || (!magnifying && !r_minfilter); if (filter_nearest) { - xoffset = MAX(MIN(xoffset, (mip_width << FRACBITS) - 1), 0); + xoffset = max(min(xoffset, (mip_width << FRACBITS) - 1), 0); int tx = xoffset >> FRACBITS; dc_source = (uint8_t*)(pixels + tx * mip_height); @@ -205,10 +205,10 @@ namespace swrenderer } else { - xoffset = MAX(MIN(xoffset - (FRACUNIT / 2), (mip_width << FRACBITS) - 1), 0); + xoffset = max(min(xoffset - (FRACUNIT / 2), (mip_width << FRACBITS) - 1), 0); int tx0 = xoffset >> FRACBITS; - int tx1 = MIN(tx0 + 1, mip_width - 1); + int tx1 = min(tx0 + 1, mip_width - 1); dc_source = (uint8_t*)(pixels + tx0 * mip_height); dc_source2 = (uint8_t*)(pixels + tx1 * mip_height); dc_textureheight = mip_height; @@ -233,8 +233,8 @@ namespace swrenderer if (flipY) std::swap(dc_yl, dc_yh); - dc_yl = std::max(dc_yl, cliptop); - dc_yh = std::min(dc_yh, clipbottom); + dc_yl = max(dc_yl, cliptop); + dc_yh = min(dc_yh, clipbottom); if (dc_yl <= dc_yh) { @@ -271,8 +271,8 @@ namespace swrenderer if (flipY) std::swap(dc_yl, dc_yh); - dc_yl = std::max(dc_yl, cliptop); - dc_yh = std::min(dc_yh, clipbottom); + dc_yl = max(dc_yl, cliptop); + dc_yh = min(dc_yh, clipbottom); if (dc_yl < dc_yh) { @@ -282,12 +282,12 @@ namespace swrenderer dc_yl--; fixed_t maxfrac = ((top + length) << FRACBITS) - 1; - dc_texturefrac = MAX(dc_texturefrac, 0); - dc_texturefrac = MIN(dc_texturefrac, maxfrac); + dc_texturefrac = max(dc_texturefrac, 0); + dc_texturefrac = min(dc_texturefrac, maxfrac); if (dc_iscale > 0) - dc_count = MIN(dc_count, (maxfrac - dc_texturefrac + dc_iscale - 1) / dc_iscale); + dc_count = min(dc_count, (maxfrac - dc_texturefrac + dc_iscale - 1) / dc_iscale); else if (dc_iscale < 0) - dc_count = MIN(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale)); + dc_count = min(dc_count, (dc_texturefrac - dc_iscale) / (-dc_iscale)); (thread->Drawers(dc_viewport)->*colfunc)(*this); } diff --git a/src/rendering/swrenderer/viewport/r_viewport.cpp b/src/rendering/swrenderer/viewport/r_viewport.cpp index 3fdbe558e..767627b4f 100644 --- a/src/rendering/swrenderer/viewport/r_viewport.cpp +++ b/src/rendering/swrenderer/viewport/r_viewport.cpp @@ -22,7 +22,7 @@ #include #include -#include "templates.h" + #include "filesystem.h" #include "doomdef.h" diff --git a/src/scripting/backend/codegen_doom.cpp b/src/scripting/backend/codegen_doom.cpp index 30385519c..1d008446c 100644 --- a/src/scripting/backend/codegen_doom.cpp +++ b/src/scripting/backend/codegen_doom.cpp @@ -44,7 +44,7 @@ #include "texturemanager.h" #include "m_random.h" #include "v_font.h" -#include "templates.h" + #include "actor.h" #include "p_lnspec.h" #include "g_levellocals.h" diff --git a/src/scripting/vmthunks.cpp b/src/scripting/vmthunks.cpp index b37114191..2f07d6d47 100644 --- a/src/scripting/vmthunks.cpp +++ b/src/scripting/vmthunks.cpp @@ -1786,7 +1786,7 @@ DEFINE_ACTION_FUNCTION_NATIVE(FWeaponSlots, LocateWeapon, LocateWeapon) if (numret >= 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..7d37c9952 100644 --- a/src/sound/s_advsound.cpp +++ b/src/sound/s_advsound.cpp @@ -34,7 +34,7 @@ // HEADER FILES ------------------------------------------------------------ -#include "templates.h" + #include "actor.h" #include "c_dispatch.h" #include "filesystem.h" @@ -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/sound/s_sndseq.cpp b/src/sound/s_sndseq.cpp index abe16c3c8..ed82d8a57 100644 --- a/src/sound/s_sndseq.cpp +++ b/src/sound/s_sndseq.cpp @@ -704,7 +704,7 @@ void S_ParseSndSeq (int levellump) delaybase = sc.Number; ScriptTemp.Push(MakeCommand(SS_CMD_DELAYRAND, sc.Number)); sc.MustGetNumber (); - ScriptTemp.Push(MAX(1, sc.Number - delaybase + 1)); + ScriptTemp.Push(max(1, sc.Number - delaybase + 1)); break; case SS_STRING_VOLUME: // volume is in range 0..100 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..30ead3424 100644 --- a/src/utility/nodebuilder/nodebuild_utility.cpp +++ b/src/utility/nodebuilder/nodebuild_utility.cpp @@ -698,10 +698,10 @@ 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 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 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 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); } //==================================================================== diff --git a/src/win32/i_steam.cpp b/src/win32/i_steam.cpp index 862cb584b..3aab30391 100644 --- a/src/win32/i_steam.cpp +++ b/src/win32/i_steam.cpp @@ -71,7 +71,7 @@ #include "d_net.h" #include "g_game.h" #include "c_dispatch.h" -#include "templates.h" + #include "gameconfigfile.h" #include "v_font.h" #include "g_level.h" diff --git a/wadsrc/static/zscript/engine/base.zs b/wadsrc/static/zscript/engine/base.zs index 95b678225..d4b896466 100644 --- a/wadsrc/static/zscript/engine/base.zs +++ b/wadsrc/static/zscript/engine/base.zs @@ -413,7 +413,7 @@ struct Screen native native static int GetWidth(); native static int GetHeight(); native static void Clear(int left, int top, int right, int bottom, Color color, int palcolor = -1); - native static void Dim(Color col, double amount, int x, int y, int w, int h); + native static void Dim(Color col, double amount, int x, int y, int w, int h, ERenderStyle style = STYLE_Translucent); native static vararg void DrawTexture(TextureID tex, bool animate, double x, double y, ...); native static vararg void DrawShape(TextureID tex, bool animate, Shape2D s, ...); diff --git a/wadsrc_widepix/static/.gitignore b/wadsrc_widepix/static/.gitignore deleted file mode 100644 index 3ce1f9a1d..000000000 --- a/wadsrc_widepix/static/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/psd -/reference diff --git a/wadsrc_widepix/static/filter/hacx/graphics/credit.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/graphics/credit.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/graphics/credit.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/graphics/credit.lmp diff --git a/wadsrc_widepix/static/filter/hacx/graphics/help.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/graphics/help.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/graphics/help.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/graphics/help.lmp diff --git a/wadsrc_widepix/static/filter/hacx/graphics/interpic.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/graphics/interpic.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/graphics/interpic.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/graphics/interpic.lmp diff --git a/wadsrc_widepix/static/filter/hacx/graphics/titlepic.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/graphics/titlepic.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/graphics/titlepic.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/graphics/titlepic.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGA0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGA0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGA0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGA0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGB0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGB0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGB0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGB0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGC0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGC0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGC0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGC0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGD0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGD0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGD0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGD0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGE0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGE0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGE0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGE0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGF0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGF0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGF0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGF0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGG0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGG0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGG0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGG0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGH0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGH0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGH0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGH0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGI0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGI0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGI0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGI0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/CRYGJ0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGJ0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/CRYGJ0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/CRYGJ0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/MISFA0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISFA0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/MISFA0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISFA0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/MISFB0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISFB0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/MISFB0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISFB0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/MISFC0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISFC0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/MISFC0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISFC0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/MISFD0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISFD0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/MISFD0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISFD0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/MISGA0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISGA0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/MISGA0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISGA0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/MISGB0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISGB0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/MISGB0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/MISGB0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/PISGE0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/PISGE0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/PISGE0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/PISGE0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/PLSGB0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/PLSGB0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/PLSGB0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/PLSGB0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2A0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2A0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2A0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2A0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2B0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2B0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2B0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2B0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2C0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2C0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2C0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2C0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2D0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2D0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2D0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2D0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2E0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2E0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2E0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2E0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2F0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2F0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2F0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2F0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2G0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2G0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2G0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2G0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2H0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2H0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2H0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2H0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2I0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2I0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2I0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2I0.lmp diff --git a/wadsrc_widepix/static/filter/hacx/sprites/SHT2J0.lmp b/wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2J0.lmp similarity index 100% rename from wadsrc_widepix/static/filter/hacx/sprites/SHT2J0.lmp rename to wadsrc_widepix/static/filter/hacx.hacx1/sprites/SHT2J0.lmp