1
0
mirror of https://github.com/alliedmodders/hl2sdk.git synced 2024-12-23 01:59:43 +08:00

Fixed compilation of tier1 caused by min/max.

This commit is contained in:
Ted Wang 2021-08-25 15:34:39 -07:00 committed by David Anderson
parent c33f7155e9
commit eea4d13b82
6 changed files with 19 additions and 19 deletions

View File

@ -106,7 +106,7 @@ public:
m_errorStack[m_errorIndex] = symName; m_errorStack[m_errorIndex] = symName;
} }
m_errorIndex++; m_errorIndex++;
m_maxErrorIndex = max( m_maxErrorIndex, (m_errorIndex-1) ); m_maxErrorIndex = V_max( m_maxErrorIndex, (m_errorIndex-1) );
return m_errorIndex-1; return m_errorIndex-1;
} }

View File

@ -219,8 +219,8 @@ int FindDiffsForLargeFiles(uint8 const *NewBlock, uint8 const *OldBlock,
int match_of=b->dataptr-lastmatchend; int match_of=b->dataptr-lastmatchend;
if ((match_of>-32768) && (match_of<32767)) if ((match_of>-32768) && (match_of<32767))
{ {
int max_mlength=min(65535,OldBlock+OldSize-b->dataptr); int max_mlength=V_min(65535,OldBlock+OldSize-b->dataptr);
max_mlength=min(max_mlength,NewBlock+NewSize-walk); max_mlength=V_min(max_mlength,NewBlock+NewSize-walk);
int i; int i;
for(i=0;i<max_mlength;i++) for(i=0;i<max_mlength;i++)
if (walk[i]!=b->dataptr[i]) if (walk[i]!=b->dataptr[i])
@ -355,8 +355,8 @@ int FindDiffs(uint8 const *NewBlock, uint8 const *OldBlock,
int match_of=b->dataptr-lastmatchend; int match_of=b->dataptr-lastmatchend;
if ((match_of>-32768) && (match_of<32767)) if ((match_of>-32768) && (match_of<32767))
{ {
int max_mlength=min(65535,OldBlock+OldSize-b->dataptr); int max_mlength=V_min(65535,OldBlock+OldSize-b->dataptr);
max_mlength=min(max_mlength,NewBlock+NewSize-walk); max_mlength=V_min(max_mlength,NewBlock+NewSize-walk);
int i; int i;
for(i=0;i<max_mlength;i++) for(i=0;i<max_mlength;i++)
if (walk[i]!=b->dataptr[i]) if (walk[i]!=b->dataptr[i])
@ -467,7 +467,7 @@ int FindDiffsLowMemory(uint8 const *NewBlock, uint8 const *OldBlock,
uint16 hash1=(walk[0]+walk[1]+walk[2]+walk[3]) & (NELEMS(old_data_hash)-1); uint16 hash1=(walk[0]+walk[1]+walk[2]+walk[3]) & (NELEMS(old_data_hash)-1);
if (old_data_hash[hash1]) if (old_data_hash[hash1])
{ {
int max_bytes_to_compare=min(NewBlock+NewSize-walk,OldBlock+OldSize-old_data_hash[hash1]); int max_bytes_to_compare=V_min(NewBlock+NewSize-walk,OldBlock+OldSize-old_data_hash[hash1]);
int nmatches; int nmatches;
for(nmatches=0;nmatches<max_bytes_to_compare;nmatches++) for(nmatches=0;nmatches<max_bytes_to_compare;nmatches++)
if (walk[nmatches]!=old_data_hash[hash1][nmatches]) if (walk[nmatches]!=old_data_hash[hash1][nmatches])

View File

@ -249,7 +249,7 @@ void *CUtlMemoryPool::Alloc( size_t amount )
} }
} }
m_BlocksAllocated++; m_BlocksAllocated++;
m_PeakAlloc = max(m_PeakAlloc, m_BlocksAllocated); m_PeakAlloc = V_max(m_PeakAlloc, m_BlocksAllocated);
returnBlock = m_pHeadOfFreeList; returnBlock = m_pHeadOfFreeList;

View File

@ -928,7 +928,7 @@ char *V_strncat(char *pDest, const char *pSrc, size_t destBufferSize, int max_ch
} }
else else
{ {
charstocopy = (size_t)min( max_chars_to_copy, (int)srclen ); charstocopy = (size_t)V_min( max_chars_to_copy, (int)srclen );
} }
if ( len + charstocopy >= destBufferSize ) if ( len + charstocopy >= destBufferSize )
@ -960,7 +960,7 @@ wchar_t *V_wcsncat( INOUT_Z_CAP(cchDest) wchar_t *pDest, const wchar_t *pSrc, si
} }
else else
{ {
charstocopy = (size_t)min( max_chars_to_copy, (int)srclen ); charstocopy = (size_t)V_min( max_chars_to_copy, (int)srclen );
} }
if ( len + charstocopy >= cchDest ) if ( len + charstocopy >= cchDest )
@ -1020,7 +1020,7 @@ char *V_pretifymem( float value, int digitsafterdecimal /*= 2*/, bool usebinaryo
char val[ 32 ]; char val[ 32 ];
// Clamp to >= 0 // Clamp to >= 0
digitsafterdecimal = max( digitsafterdecimal, 0 ); digitsafterdecimal = V_max( digitsafterdecimal, 0 );
// If it's basically integral, don't do any decimals // If it's basically integral, don't do any decimals
if ( FloatMakePositive( value - (int)value ) < 0.00001 ) if ( FloatMakePositive( value - (int)value ) < 0.00001 )
@ -1439,7 +1439,7 @@ int _V_UnicodeToUCS2( const wchar_t *pUnicode, int cubSrcInBytes, char *pUCS2, i
#ifdef _WIN32 #ifdef _WIN32
// Figure out which buffer is smaller and convert from bytes to character // Figure out which buffer is smaller and convert from bytes to character
// counts. // counts.
int cchResult = min( (size_t)cubSrcInBytes/sizeof(wchar_t), cubDestSizeInBytes/sizeof(wchar_t) ); int cchResult = V_min( (size_t)cubSrcInBytes/sizeof(wchar_t), cubDestSizeInBytes/sizeof(wchar_t) );
wchar_t *pDest = (wchar_t*)pUCS2; wchar_t *pDest = (wchar_t*)pUCS2;
wcsncpy( pDest, pUnicode, cchResult ); wcsncpy( pDest, pUnicode, cchResult );
// Make sure we NULL-terminate. // Make sure we NULL-terminate.
@ -1599,7 +1599,7 @@ unsigned char V_nibble( char c )
void V_hextobinary( char const *in, int numchars, byte *out, int maxoutputbytes ) void V_hextobinary( char const *in, int numchars, byte *out, int maxoutputbytes )
{ {
int len = V_strlen( in ); int len = V_strlen( in );
numchars = min( len, numchars ); numchars = V_min( len, numchars );
// Make sure it's even // Make sure it's even
numchars = ( numchars ) & ~0x1; numchars = ( numchars ) & ~0x1;
@ -1710,7 +1710,7 @@ void V_FileBase( const char *in, char *out, int maxlen )
// Length of new sting // Length of new sting
len = end - start + 1; len = end - start + 1;
int maxcopy = min( len + 1, maxlen ); int maxcopy = V_min( len + 1, maxlen );
// Copy partial string // Copy partial string
V_strncpy( out, &in[start], maxcopy ); V_strncpy( out, &in[start], maxcopy );
@ -1754,7 +1754,7 @@ void V_StripExtension( const char *in, char *out, int outSize )
if (end > 0 && !PATHSEPARATOR( in[end] ) && end < outSize) if (end > 0 && !PATHSEPARATOR( in[end] ) && end < outSize)
{ {
int nChars = min( end, outSize-1 ); int nChars = V_min( end, outSize-1 );
if ( out != in ) if ( out != in )
{ {
memcpy( out, in, nChars ); memcpy( out, in, nChars );
@ -2001,7 +2001,7 @@ bool V_ExtractFilePath (const char *path, char *dest, int destSize )
src--; src--;
} }
int copysize = min( src - path, destSize - 1 ); int copysize = V_min( src - path, destSize - 1 );
memcpy( dest, path, copysize ); memcpy( dest, path, copysize );
dest[copysize] = 0; dest[copysize] = 0;
@ -2392,7 +2392,7 @@ char* AllocString( const char *pStr, int nMaxChars )
if ( nMaxChars == -1 ) if ( nMaxChars == -1 )
allocLen = strlen( pStr ) + 1; allocLen = strlen( pStr ) + 1;
else else
allocLen = min( (int)strlen(pStr), nMaxChars ) + 1; allocLen = V_min( (int)strlen(pStr), nMaxChars ) + 1;
char *pOut = new char[allocLen]; char *pOut = new char[allocLen];
V_strncpy( pOut, pStr, allocLen ); V_strncpy( pOut, pStr, allocLen );

View File

@ -640,7 +640,7 @@ void CUtlBuffer::GetStringInternal( char *pString, size_t maxLenInChars )
return; return;
} }
const size_t nCharsToRead = min( (size_t)nLen, maxLenInChars ) - 1; const size_t nCharsToRead = V_min( (size_t)nLen, maxLenInChars ) - 1;
Get( pString, nCharsToRead ); Get( pString, nCharsToRead );
pString[nCharsToRead] = 0; pString[nCharsToRead] = 0;

View File

@ -234,7 +234,7 @@ CUtlSymbol CUtlSymbolTable::AddString( const char* pString )
if ( iPool == -1 ) if ( iPool == -1 )
{ {
// Add a new pool. // Add a new pool.
int newPoolSize = max( len, MIN_STRING_POOL_SIZE ); int newPoolSize = V_max( len, MIN_STRING_POOL_SIZE );
StringPool_t *pPool = (StringPool_t*)malloc( sizeof( StringPool_t ) + newPoolSize - 1 ); StringPool_t *pPool = (StringPool_t*)malloc( sizeof( StringPool_t ) + newPoolSize - 1 );
pPool->m_TotalLen = newPoolSize; pPool->m_TotalLen = newPoolSize;
pPool->m_SpaceUsed = 0; pPool->m_SpaceUsed = 0;