Skip to content

Commit

Permalink
Merge remote-tracking branch 'gzdoom/master' into lightmaps2
Browse files Browse the repository at this point in the history
  • Loading branch information
dpjudas committed Nov 4, 2021
2 parents b52aea5 + fba5c78 commit 5dec391
Show file tree
Hide file tree
Showing 294 changed files with 1,077 additions and 1,031 deletions.
2 changes: 1 addition & 1 deletion src/am_map.cpp
Expand Up @@ -29,7 +29,7 @@
#include <array>

#include "doomdef.h"
#include "templates.h"

#include "g_level.h"
#include "st_stuff.h"
#include "p_local.h"
Expand Down
4 changes: 2 additions & 2 deletions src/common/2d/v_2ddrawer.cpp
Expand Up @@ -33,7 +33,7 @@
*/

#include <stdarg.h>
#include "templates.h"

#include "v_2ddrawer.h"
#include "vectors.h"
#include "vm.h"
Expand Down Expand Up @@ -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;

Expand Down
4 changes: 2 additions & 2 deletions src/common/2d/v_2ddrawer.h
Expand Up @@ -306,8 +306,8 @@ class F2DVertexBuffer

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<IVertexBuffer *, IIndexBuffer *> GetBufferObjects() const
Expand Down
29 changes: 15 additions & 14 deletions src/common/2d/v_draw.cpp
Expand Up @@ -36,7 +36,7 @@
#include <stdarg.h>
#include "v_draw.h"
#include "vm.h"
#include "templates.h"

#include "texturemanager.h"
#include "r_videoscale.h"
#include "c_cvars.h"
Expand Down Expand Up @@ -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.
Expand All @@ -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));
}


Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -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);
}


Expand Down Expand Up @@ -905,7 +905,7 @@ bool ParseDrawTextureTags(F2DDrawer *drawer, FGameTexture *img, double x, double
break;

case DTA_Alpha:
parms->Alpha = (float)(MIN<double>(1., ListGetDouble(tags)));
parms->Alpha = (float)(min<double>(1., ListGetDouble(tags)));
break;

case DTA_AlphaChannel:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

Expand Down Expand Up @@ -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);
}


Expand Down
2 changes: 1 addition & 1 deletion src/common/audio/music/i_music.cpp
Expand Up @@ -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"
Expand Down
16 changes: 8 additions & 8 deletions src/common/audio/sound/oalsound.cpp
Expand Up @@ -36,7 +36,7 @@
#include <chrono>

#include "c_cvars.h"
#include "templates.h"

#include "oalsound.h"
#include "c_dispatch.h"
#include "v_text.h"
Expand Down Expand Up @@ -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<ALCint>(snd_channels, 2) - 1);
attribs.Push(max<ALCint>(snd_channels, 2) - 1);
attribs.Push(ALC_STEREO_SOURCES);
attribs.Push(1);
if(ALC.SOFT_HRTF)
Expand Down Expand Up @@ -681,15 +681,15 @@ OpenALSoundRenderer::OpenALSoundRenderer()
// At least Apple's OpenAL implementation returns zeroes,
// although it can generate reasonable number of sources.

const int numChannels = std::max<int>(snd_channels, 2);
const int numChannels = max<int>(snd_channels, 2);
int numSources = numMono + numStereo;

if (0 == numSources)
{
numSources = numChannels;
}

Sources.Resize(std::min<int>(numChannels, numSources));
Sources.Resize(min<int>(numChannels, numSources));
for(unsigned i = 0;i < Sources.Size();i++)
{
alGenSources(1, &Sources[i]);
Expand Down Expand Up @@ -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<float>(gain*dist, 0.0004f));
alSourcef(source, AL_REFERENCE_DISTANCE, max<float>(gain*dist, 0.0004f));
alSourcef(source, AL_MAX_DISTANCE, std::numeric_limits<float>::max());
alSourcef(source, AL_ROLLOFF_FACTOR, 1.f);
}
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<float>(gain*dist, 0.0004f));
alSourcef(source, AL_REFERENCE_DISTANCE, max<float>(gain*dist, 0.0004f));
}

alSourcei(source, AL_SOURCE_RELATIVE, AL_FALSE);
Expand Down
2 changes: 1 addition & 1 deletion src/common/audio/sound/s_environment.cpp
Expand Up @@ -34,7 +34,7 @@

#include "s_soundinternal.h"
#include "sc_man.h"
#include "templates.h"

#include "cmdlib.h"


Expand Down
2 changes: 1 addition & 1 deletion src/common/audio/sound/s_reverbedit.cpp
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions src/common/audio/sound/s_sound.cpp
Expand Up @@ -36,7 +36,7 @@
#include <stdio.h>
#include <stdlib.h>

#include "templates.h"

#include "s_soundinternal.h"
#include "m_swap.h"
#include "superfasthash.h"
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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++;
Expand Down Expand Up @@ -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));
}

//==========================================================================
Expand Down
2 changes: 1 addition & 1 deletion src/common/console/c_bind.cpp
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/common/console/c_buttons.cpp
Expand Up @@ -34,7 +34,7 @@
*/

#include "c_buttons.h"
#include "templates.h"

#include "c_dispatch.h"
#include "printf.h"
#include "cmdlib.h"
Expand Down
2 changes: 1 addition & 1 deletion src/common/console/c_commandbuffer.cpp
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/common/console/c_console.cpp
Expand Up @@ -34,7 +34,7 @@

#include <string>

#include "templates.h"

#include "version.h"
#include "c_bind.h"
#include "c_console.h"
Expand Down Expand Up @@ -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
{
Expand Down
4 changes: 2 additions & 2 deletions src/common/console/c_dispatch.cpp
Expand Up @@ -39,7 +39,7 @@
#include <string.h>
#include <ctype.h>

#include "templates.h"

#include "cmdlib.h"
#include "c_console.h"
#include "c_dispatch.h"
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/common/console/c_tabcomplete.cpp
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/common/engine/i_net.cpp
Expand Up @@ -75,7 +75,7 @@
#include "cmdlib.h"
#include "printf.h"
#include "i_interface.h"
#include "templates.h"


#include "i_net.h"

Expand Down
8 changes: 4 additions & 4 deletions src/common/engine/palettecontainer.cpp
Expand Up @@ -37,7 +37,7 @@
#include "m_crc32.h"
#include "printf.h"
#include "colormatcher.h"
#include "templates.h"

#include "palettecontainer.h"
#include "files.h"

Expand Down Expand Up @@ -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];

Expand Down
2 changes: 1 addition & 1 deletion src/common/engine/renderstyle.cpp
Expand Up @@ -32,7 +32,7 @@
**
*/

#include "templates.h"
#include "basics.h"
#include "renderstyle.h"
#include "c_cvars.h"

Expand Down

0 comments on commit 5dec391

Please sign in to comment.