- replaced MIN/MAX in common code.

This commit is contained in:
Christoph Oelckers 2021-10-30 10:46:17 +02:00
commit eb69bbcae0
63 changed files with 200 additions and 236 deletions

View file

@ -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;
}
@ -1060,7 +1060,7 @@ void md5Update(FileReader& file, MD5Context& md5, unsigned len)
while (len > 0)
{
t = std::min<unsigned>(len, sizeof(readbuf));
t = min<unsigned>(len, sizeof(readbuf));
len -= t;
t = (long)file.Read(readbuf, t);
md5.Update(readbuf, t);

View file

@ -509,7 +509,7 @@ class DecompressorLZSS : public DecompressorBase
// Partial overlap: Copy in 2 or 3 chunks.
do
{
unsigned int copy = std::min<unsigned int>(len, pos+1);
unsigned int copy = min<unsigned int>(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<unsigned int>(Stream.InternalOut, AvailOut);
unsigned int copy = min<unsigned int>(Stream.InternalOut, AvailOut);
if(copy > 0)
{
memcpy(Out, Stream.WindowData, copy);

View file

@ -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<int>(len, 768);
int PaletteSize = min<int>(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<size_t>(768, lump.GetSize()));
memcpy(buffer, lumpmem, min<size_t>(768, lump.GetSize()));
return 256;
}
}

View file

@ -93,41 +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<class T>
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<class T>
inline
const T MAX (const T a, const T b)
{
return a > b ? a : b;
}
#endif //__TEMPLATES_H__