Replace min/max macros by Q_min/Q_max to make newer C++ stdlib happy

This commit is contained in:
Alibek Omarov 2023-09-06 03:52:02 +03:00
parent 137f3923ca
commit c56b92f9e6
35 changed files with 126 additions and 124 deletions

View file

@ -157,7 +157,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->hInactive = SPR_Load(sz); pWeapon->hInactive = SPR_Load(sz);
pWeapon->rcInactive = p->rc; pWeapon->rcInactive = p->rc;
gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); gHR.iHistoryGap = Q_max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
} }
else else
pWeapon->hInactive = 0; pWeapon->hInactive = 0;
@ -179,7 +179,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->hAmmo = SPR_Load(sz); pWeapon->hAmmo = SPR_Load(sz);
pWeapon->rcAmmo = p->rc; pWeapon->rcAmmo = p->rc;
gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); gHR.iHistoryGap = Q_max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
} }
else else
pWeapon->hAmmo = 0; pWeapon->hAmmo = 0;
@ -190,7 +190,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->hAmmobullet = SPR_Load(sz); pWeapon->hAmmobullet = SPR_Load(sz);
pWeapon->rcAmmobullet = p->rc; pWeapon->rcAmmobullet = p->rc;
gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); gHR.iHistoryGap = Q_max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
} }
else else
pWeapon->hAmmobullet2 = 0; pWeapon->hAmmobullet2 = 0;
@ -201,7 +201,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->hAmmobullet2 = SPR_Load(sz); pWeapon->hAmmobullet2 = SPR_Load(sz);
pWeapon->rcAmmobullet2 = p->rc; pWeapon->rcAmmobullet2 = p->rc;
gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); gHR.iHistoryGap = Q_max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
} }
else else
pWeapon->hAmmobullet2 = 0; pWeapon->hAmmobullet2 = 0;
@ -213,7 +213,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->hAmmo2 = SPR_Load(sz); pWeapon->hAmmo2 = SPR_Load(sz);
pWeapon->rcAmmo2 = p->rc; pWeapon->rcAmmo2 = p->rc;
gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top ); gHR.iHistoryGap = Q_max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
} }
else else
pWeapon->hAmmo2 = 0; pWeapon->hAmmo2 = 0;
@ -347,7 +347,7 @@ int CHudAmmo::VidInit(void)
giBucketWidth = gHUD.GetSpriteRect(m_HUD_bucket0).right - gHUD.GetSpriteRect(m_HUD_bucket0).left; giBucketWidth = gHUD.GetSpriteRect(m_HUD_bucket0).right - gHUD.GetSpriteRect(m_HUD_bucket0).left;
giBucketHeight = gHUD.GetSpriteRect(m_HUD_bucket0).bottom - gHUD.GetSpriteRect(m_HUD_bucket0).top; giBucketHeight = gHUD.GetSpriteRect(m_HUD_bucket0).bottom - gHUD.GetSpriteRect(m_HUD_bucket0).top;
gHR.iHistoryGap = max( gHR.iHistoryGap, gHUD.GetSpriteRect(m_HUD_bucket0).bottom - gHUD.GetSpriteRect(m_HUD_bucket0).top); gHR.iHistoryGap = Q_max( gHR.iHistoryGap, gHUD.GetSpriteRect(m_HUD_bucket0).bottom - gHUD.GetSpriteRect(m_HUD_bucket0).top);
// If we've already loaded weapons, let's get new sprites // If we've already loaded weapons, let's get new sprites
gWR.LoadAllWeaponSprites(); gWR.LoadAllWeaponSprites();
@ -900,7 +900,7 @@ int CHudAmmo::Draw(float flTime)
AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left; AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
a = (int) max( MIN_ALPHA, m_fFade ); a = (int) Q_max( MIN_ALPHA, m_fFade );
if (m_fFade > 0) if (m_fFade > 0)
m_fFade -= (gHUD.m_flTimeDelta * 20); m_fFade -= (gHUD.m_flTimeDelta * 20);

View file

@ -61,7 +61,7 @@ int CHudAmmoSecondary :: Draw(float flTime)
// draw secondary ammo icons above normal ammo readout // draw secondary ammo icons above normal ammo readout
int a, x, y, r, g, b, AmmoWidth; int a, x, y, r, g, b, AmmoWidth;
UnpackRGB( r, g, b, RGB_WHITE ); UnpackRGB( r, g, b, RGB_WHITE );
a = (int) max( MIN_ALPHA, m_fFade ); a = (int) Q_max( MIN_ALPHA, m_fFade );
if (m_fFade > 0) if (m_fFade > 0)
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
ScaleColors( r, g, b, a ); ScaleColors( r, g, b, a );
@ -141,7 +141,7 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, voi
int count = 0; int count = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ ) for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
{ {
count += max( 0, m_iAmmoAmounts[i] ); count += Q_max( 0, m_iAmmoAmounts[i] );
} }
if ( count == 0 ) if ( count == 0 )

View file

@ -111,7 +111,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
{ {
if ( rgAmmoHistory[i].type ) if ( rgAmmoHistory[i].type )
{ {
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME ); rgAmmoHistory[i].DisplayTime = Q_min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
if ( rgAmmoHistory[i].DisplayTime <= flTime ) if ( rgAmmoHistory[i].DisplayTime <= flTime )
{ // pic drawing time has expired { // pic drawing time has expired
@ -126,7 +126,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
int r, g, b; int r, g, b;
UnpackRGB(r,g,b, RGB_WHITE); UnpackRGB(r,g,b, RGB_WHITE);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, min(scale, 255) ); ScaleColors(r, g, b, Q_min(scale, 255) );
// Draw the pic // Draw the pic
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
@ -154,7 +154,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red UnpackRGB(r,g,b, RGB_REDISH); // if the weapon doesn't have ammo, display it as red
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, min(scale, 255) ); ScaleColors(r, g, b, Q_min(scale, 255) );
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left); int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
@ -172,7 +172,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
UnpackRGB(r,g,b, RGB_WHITE); UnpackRGB(r,g,b, RGB_WHITE);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80; float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, min(scale, 255) ); ScaleColors(r, g, b, Q_min(scale, 255) );
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i)); int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (rect.right - rect.left) - 10; int xpos = ScreenWidth - (rect.right - rect.left) - 10;

View file

@ -123,8 +123,8 @@ void CenterPrint(const char*);
inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); } inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }
#define max(a, b) (((a) > (b)) ? (a) : (b)) #define Q_max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b)) #define Q_min(a, b) (((a) < (b)) ? (a) : (b))
#define fabs(x) ((x) > 0 ? (x) : 0 - (x)) #define fabs(x) ((x) > 0 ? (x) : 0 - (x))
void ScaleColors( int &r, int &g, int &b, int a ); void ScaleColors( int &r, int &g, int &b, int a );

View file

@ -121,7 +121,7 @@ int CHudDeathNotice :: Draw( float flTime )
continue; continue;
} }
rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME ); rgDeathNoticeList[i].flDisplayTime = Q_min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
// Only draw if the viewport will let me // Only draw if the viewport will let me
if ( gViewPort && gViewPort->AllowedToPrintText() ) if ( gViewPort && gViewPort->AllowedToPrintText() )

View file

@ -273,25 +273,25 @@ void CHudHealth::CalcDamageDirection(vec3_t vecFrom)
if (side > 0) if (side > 0)
{ {
if (side > 0.3) if (side > 0.3)
m_fAttackFront = max(m_fAttackFront, side); m_fAttackFront = Q_max(m_fAttackFront, side);
} }
else else
{ {
float f = fabs(side); float f = fabs(side);
if (f > 0.3) if (f > 0.3)
m_fAttackRear = max(m_fAttackRear, f); m_fAttackRear = Q_max(m_fAttackRear, f);
} }
if (front > 0) if (front > 0)
{ {
if (front > 0.3) if (front > 0.3)
m_fAttackRight = max(m_fAttackRight, front); m_fAttackRight = Q_max(m_fAttackRight, front);
} }
else else
{ {
float f = fabs(front); float f = fabs(front);
if (f > 0.3) if (f > 0.3)
m_fAttackLeft = max(m_fAttackLeft, f); m_fAttackLeft = Q_max(m_fAttackLeft, f);
} }
} }
} }
@ -313,49 +313,49 @@ int CHudHealth::DrawPain(float flTime)
if (m_fAttackFront > 0.4) if (m_fAttackFront > 0.4)
{ {
GetPainColor(r,g,b); GetPainColor(r,g,b);
shade = a * max( m_fAttackFront, 0.5 ); shade = a * Q_max( m_fAttackFront, 0.5 );
ScaleColors(r, g, b, shade); ScaleColors(r, g, b, shade);
SPR_Set(m_hDamageSprite, r, g, b ); SPR_Set(m_hDamageSprite, r, g, b );
x = ScreenWidth/2 - SPR_Width(m_hDamageSprite, 0)/2; x = ScreenWidth/2 - SPR_Width(m_hDamageSprite, 0)/2;
y = ScreenHeight/2 - SPR_Height(m_hDamageSprite,0) * 3; y = ScreenHeight/2 - SPR_Height(m_hDamageSprite,0) * 3;
SPR_DrawAdditive(0, x, y, NULL); SPR_DrawAdditive(0, x, y, NULL);
m_fAttackFront = max( 0, m_fAttackFront - fFade ); m_fAttackFront = Q_max( 0, m_fAttackFront - fFade );
} else } else
m_fAttackFront = 0; m_fAttackFront = 0;
if (m_fAttackRight > 0.4) if (m_fAttackRight > 0.4)
{ {
GetPainColor(r,g,b); GetPainColor(r,g,b);
shade = a * max( m_fAttackRight, 0.5 ); shade = a * Q_max( m_fAttackRight, 0.5 );
ScaleColors(r, g, b, shade); ScaleColors(r, g, b, shade);
SPR_Set(m_hDamageSprite, r, g, b ); SPR_Set(m_hDamageSprite, r, g, b );
x = ScreenWidth/2 + SPR_Width(m_hDamageSprite, 1) * 2; x = ScreenWidth/2 + SPR_Width(m_hDamageSprite, 1) * 2;
y = ScreenHeight/2 - SPR_Height(m_hDamageSprite,1)/2; y = ScreenHeight/2 - SPR_Height(m_hDamageSprite,1)/2;
SPR_DrawAdditive(1, x, y, NULL); SPR_DrawAdditive(1, x, y, NULL);
m_fAttackRight = max( 0, m_fAttackRight - fFade ); m_fAttackRight = Q_max( 0, m_fAttackRight - fFade );
} else } else
m_fAttackRight = 0; m_fAttackRight = 0;
if (m_fAttackRear > 0.4) if (m_fAttackRear > 0.4)
{ {
GetPainColor(r,g,b); GetPainColor(r,g,b);
shade = a * max( m_fAttackRear, 0.5 ); shade = a * Q_max( m_fAttackRear, 0.5 );
ScaleColors(r, g, b, shade); ScaleColors(r, g, b, shade);
SPR_Set(m_hDamageSprite, r, g, b ); SPR_Set(m_hDamageSprite, r, g, b );
x = ScreenWidth/2 - SPR_Width(m_hDamageSprite, 2)/2; x = ScreenWidth/2 - SPR_Width(m_hDamageSprite, 2)/2;
y = ScreenHeight/2 + SPR_Height(m_hDamageSprite,2) * 2; y = ScreenHeight/2 + SPR_Height(m_hDamageSprite,2) * 2;
SPR_DrawAdditive(2, x, y, NULL); SPR_DrawAdditive(2, x, y, NULL);
m_fAttackRear = max( 0, m_fAttackRear - fFade ); m_fAttackRear = Q_max( 0, m_fAttackRear - fFade );
} else } else
m_fAttackRear = 0; m_fAttackRear = 0;
if (m_fAttackLeft > 0.4) if (m_fAttackLeft > 0.4)
{ {
GetPainColor(r,g,b); GetPainColor(r,g,b);
shade = a * max( m_fAttackLeft, 0.5 ); shade = a * Q_max( m_fAttackLeft, 0.5 );
ScaleColors(r, g, b, shade); ScaleColors(r, g, b, shade);
SPR_Set(m_hDamageSprite, r, g, b ); SPR_Set(m_hDamageSprite, r, g, b );
@ -363,7 +363,7 @@ int CHudHealth::DrawPain(float flTime)
y = ScreenHeight/2 - SPR_Height(m_hDamageSprite,3)/2; y = ScreenHeight/2 - SPR_Height(m_hDamageSprite,3)/2;
SPR_DrawAdditive(3, x, y, NULL); SPR_DrawAdditive(3, x, y, NULL);
m_fAttackLeft = max( 0, m_fAttackLeft - fFade ); m_fAttackLeft = Q_max( 0, m_fAttackLeft - fFade );
} else } else
m_fAttackLeft = 0; m_fAttackLeft = 0;
@ -402,7 +402,7 @@ int CHudHealth::DrawDamage(float flTime)
if ( m_bitsDamage & giDmgFlags[i] ) if ( m_bitsDamage & giDmgFlags[i] )
{ {
pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire ); pdmg->fExpire = Q_min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire );
if ( pdmg->fExpire <= flTime // when the time has expired if ( pdmg->fExpire <= flTime // when the time has expired
&& a < 40 ) // and the flash is at the low point of the cycle && a < 40 ) // and the flash is at the low point of the cycle

View file

@ -79,7 +79,7 @@ void CHud::Think(void)
// think about default fov // think about default fov
if ( m_iFOV == 0 ) if ( m_iFOV == 0 )
{ // only let players adjust up in fov, and only if they are not overriden by something else { // only let players adjust up in fov, and only if they are not overriden by something else
m_iFOV = max( default_fov->value, 90 ); m_iFOV = Q_max( default_fov->value, 90 );
} }
} }

View file

@ -103,10 +103,10 @@ int CHudSayText :: Draw( float flTime )
return 1; return 1;
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + SCROLL_SPEED ); flScrollTime = Q_min( flScrollTime, flTime + SCROLL_SPEED );
// make sure the scrolltime is within reasonable bounds, to guard against the clock being reset // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset
flScrollTime = min( flScrollTime, flTime + SCROLL_SPEED ); flScrollTime = Q_min( flScrollTime, flTime + SCROLL_SPEED );
if ( flScrollTime <= flTime ) if ( flScrollTime <= flTime )
{ {
@ -132,8 +132,8 @@ int CHudSayText :: Draw( float flTime )
static char buf[MAX_PLAYER_NAME_LENGTH+32]; static char buf[MAX_PLAYER_NAME_LENGTH+32];
// draw the first x characters in the player color // draw the first x characters in the player color
strncpy( buf, g_szLineBuffer[i], min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) ); strncpy( buf, g_szLineBuffer[i], Q_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+32) );
buf[ min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31) ] = 0; buf[ Q_min(g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31) ] = 0;
gEngfuncs.pfnDrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] ); gEngfuncs.pfnDrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] );
int x = DrawConsoleString( LINE_START, y, buf ); int x = DrawConsoleString( LINE_START, y, buf );
@ -207,7 +207,7 @@ void CHudSayText :: SayTextPrint( const char *pszBuf, int iBufSize, int clientIn
} }
} }
strncpy( g_szLineBuffer[i], pszBuf, max(iBufSize -1, MAX_CHARS_PER_LINE-1) ); strncpy( g_szLineBuffer[i], pszBuf, Q_max(iBufSize -1, MAX_CHARS_PER_LINE-1) );
// make sure the text fits in one line // make sure the text fits in one line
EnsureTextFitsInOneLineAndWrapIfHaveTo( i ); EnsureTextFitsInOneLineAndWrapIfHaveTo( i );

View file

@ -202,7 +202,7 @@ int CHudStatusBar :: Draw( float fTime )
// let user set status ID bar centering // let user set status ID bar centering
if ( (i == STATUSBAR_ID_LINE) && CVAR_GET_FLOAT("hud_centerid") ) if ( (i == STATUSBAR_ID_LINE) && CVAR_GET_FLOAT("hud_centerid") )
{ {
x = max( 0, max(2, (ScreenWidth - TextWidth)) / 2 ); x = Q_max( 0, Q_max(2, (ScreenWidth - TextWidth)) / 2 );
y = (ScreenHeight / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid")); y = (ScreenHeight / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid"));
} }

View file

@ -212,7 +212,7 @@ BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay,
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
return FALSE; return FALSE;
int j = min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = Q_min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
if (j == 0) if (j == 0)
return FALSE; return FALSE;
@ -387,7 +387,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
{ {
#if 0 // FIXME, need ammo on client to make this work right #if 0 // FIXME, need ammo on client to make this work right
// complete the reload. // complete the reload.
int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = Q_min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
// Add them to the clip // Add them to the clip
m_iClip += j; m_iClip += j;

View file

@ -469,7 +469,7 @@ void ScorePanel::RebuildTeams()
if ( g_TeamInfo[j].name[0] == '\0' ) if ( g_TeamInfo[j].name[0] == '\0' )
break; break;
} }
m_iNumTeams = max( j, m_iNumTeams ); m_iNumTeams = Q_max( j, m_iNumTeams );
strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME ); strncpy( g_TeamInfo[j].name, g_PlayerExtraInfo[i].teamname, MAX_TEAM_NAME );
g_TeamInfo[j].players = 0; g_TeamInfo[j].players = 0;

View file

@ -61,7 +61,7 @@ public:
_image[1]->getTextSize(w2, t2); _image[1]->getTextSize(w2, t2);
wide = w1 + w2; wide = w1 + w2;
tall = max(t1, t2); tall = Q_max(t1, t2);
setSize(wide, tall); setSize(wide, tall);
} }

View file

@ -155,7 +155,7 @@ public:
// Space for buttons // Space for buttons
height -= YRES(20); height -= YRES(20);
height = max( 0, height ); height = Q_max( 0, height );
rowcount = height / CELL_HEIGHT; rowcount = height / CELL_HEIGHT;

View file

@ -206,8 +206,8 @@ float V_CalcBob ( struct ref_params_s *pparams )
bob = sqrt( vel[0] * vel[0] + vel[1] * vel[1] ) * cl_bob->value; bob = sqrt( vel[0] * vel[0] + vel[1] * vel[1] ) * cl_bob->value;
bob = bob * 0.3 + bob * 0.7 * sin(cycle); bob = bob * 0.3 + bob * 0.7 * sin(cycle);
bob = min( bob, 4 ); bob = Q_min( bob, 4 );
bob = max( bob, -7 ); bob = Q_max( bob, -7 );
return bob; return bob;
} }
@ -583,7 +583,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
double frac; double frac;
frac = ( t - ViewInterp.AngleTime[ foundidx & ORIGIN_MASK] ) / dt; frac = ( t - ViewInterp.AngleTime[ foundidx & ORIGIN_MASK] ) / dt;
frac = min( 1.0, frac ); frac = Q_min( 1.0, frac );
// interpolate angles // interpolate angles
InterpolateAngles( ViewInterp.Angles[ foundidx & ORIGIN_MASK ], ViewInterp.Angles[ (foundidx + 1) & ORIGIN_MASK ], pparams->cl_viewangles, frac ); InterpolateAngles( ViewInterp.Angles[ foundidx & ORIGIN_MASK ], ViewInterp.Angles[ (foundidx + 1) & ORIGIN_MASK ], pparams->cl_viewangles, frac );
@ -841,7 +841,7 @@ void V_CalcNormalRefdef ( struct ref_params_s *pparams )
if ( dt > 0.0 ) if ( dt > 0.0 )
{ {
frac = ( t - ViewInterp.OriginTime[ foundidx & ORIGIN_MASK] ) / dt; frac = ( t - ViewInterp.OriginTime[ foundidx & ORIGIN_MASK] ) / dt;
frac = min( 1.0, frac ); frac = Q_min( 1.0, frac );
VectorSubtract( ViewInterp.Origins[ ( foundidx + 1 ) & ORIGIN_MASK ], ViewInterp.Origins[ foundidx & ORIGIN_MASK ], delta ); VectorSubtract( ViewInterp.Origins[ ( foundidx + 1 ) & ORIGIN_MASK ], ViewInterp.Origins[ foundidx & ORIGIN_MASK ], delta );
VectorMA( ViewInterp.Origins[ foundidx & ORIGIN_MASK ], frac, delta, neworg ); VectorMA( ViewInterp.Origins[ foundidx & ORIGIN_MASK ], frac, delta, neworg );
@ -1052,7 +1052,7 @@ void V_CalcSpectatorRefdef ( struct ref_params_s *pparams )
double frac; double frac;
frac = ( t - ViewInterp.AngleTime[ foundidx & ORIGIN_MASK] ) / dt; frac = ( t - ViewInterp.AngleTime[ foundidx & ORIGIN_MASK] ) / dt;
frac = min( 1.0, frac ); frac = Q_min( 1.0, frac );
// interpolate angles // interpolate angles
InterpolateAngles( ViewInterp.Angles[ foundidx & ORIGIN_MASK ], ViewInterp.Angles[ (foundidx + 1) & ORIGIN_MASK ], vecNewViewAngles, frac ); InterpolateAngles( ViewInterp.Angles[ foundidx & ORIGIN_MASK ], ViewInterp.Angles[ (foundidx + 1) & ORIGIN_MASK ], vecNewViewAngles, frac );
@ -1101,7 +1101,7 @@ void V_CalcSpectatorRefdef ( struct ref_params_s *pparams )
if ( dt > 0.0 ) if ( dt > 0.0 )
{ {
frac = ( t - ViewInterp.OriginTime[ foundidx & ORIGIN_MASK] ) / dt; frac = ( t - ViewInterp.OriginTime[ foundidx & ORIGIN_MASK] ) / dt;
frac = min( 1.0, frac ); frac = Q_min( 1.0, frac );
VectorSubtract( ViewInterp.Origins[ ( foundidx + 1 ) & ORIGIN_MASK ], ViewInterp.Origins[ foundidx & ORIGIN_MASK ], delta ); VectorSubtract( ViewInterp.Origins[ ( foundidx + 1 ) & ORIGIN_MASK ], ViewInterp.Origins[ foundidx & ORIGIN_MASK ], delta );
VectorMA( ViewInterp.Origins[ foundidx & ORIGIN_MASK ], frac, delta, neworg ); VectorMA( ViewInterp.Origins[ foundidx & ORIGIN_MASK ], frac, delta, neworg );
@ -1243,7 +1243,7 @@ void V_DropPunchAngle ( float frametime, float *ev_punchangle )
len = VectorNormalize ( ev_punchangle ); len = VectorNormalize ( ev_punchangle );
len -= (10.0 + len * 0.5) * frametime; len -= (10.0 + len * 0.5) * frametime;
len = max( len, 0.0 ); len = Q_max( len, 0.0 );
VectorScale ( ev_punchangle, len, ev_punchangle ); VectorScale ( ev_punchangle, len, ev_punchangle );
} }

View file

@ -1562,12 +1562,12 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info )
item->m_iId = II.iId; item->m_iId = II.iId;
item->m_iClip = gun->m_iClip; item->m_iClip = gun->m_iClip;
item->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle, -0.001 ); item->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle, -0.001 );
item->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack, -0.001 ); item->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack, -0.001 );
item->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack, -0.001 ); item->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack, -0.001 );
item->m_fInReload = gun->m_fInReload; item->m_fInReload = gun->m_fInReload;
item->m_fInSpecialReload = gun->m_fInSpecialReload; item->m_fInSpecialReload = gun->m_fInSpecialReload;
item->fuser1 = max( gun->pev->fuser1, -0.001 ); item->fuser1 = Q_max( gun->pev->fuser1, -0.001 );
item->fuser2 = gun->m_flStartThrow; item->fuser2 = gun->m_flStartThrow;
item->fuser3 = gun->m_flReleaseThrow; item->fuser3 = gun->m_flReleaseThrow;
item->iuser2 = gun->m_fInAttack; item->iuser2 = gun->m_fInAttack;

View file

@ -744,7 +744,7 @@ void CGib :: BounceGibTouch ( CBaseEntity *pOther )
float volume; float volume;
float zvel = fabs(pev->velocity.z); float zvel = fabs(pev->velocity.z);
volume = 0.8 * min(1.0, ((float)zvel) / 450.0); volume = 0.8 * Q_min(1.0, ((float)zvel) / 450.0);
CBreakable::MaterialSoundRandom( edict(), (Materials)m_material, volume ); CBreakable::MaterialSoundRandom( edict(), (Materials)m_material, volume );
} }

View file

@ -294,12 +294,12 @@ void CBeam::RelinkBeam( void )
{ {
const Vector &startPos = GetStartPos(), &endPos = GetEndPos(); const Vector &startPos = GetStartPos(), &endPos = GetEndPos();
pev->mins.x = min( startPos.x, endPos.x ); pev->mins.x = Q_min( startPos.x, endPos.x );
pev->mins.y = min( startPos.y, endPos.y ); pev->mins.y = Q_min( startPos.y, endPos.y );
pev->mins.z = min( startPos.z, endPos.z ); pev->mins.z = Q_min( startPos.z, endPos.z );
pev->maxs.x = max( startPos.x, endPos.x ); pev->maxs.x = Q_max( startPos.x, endPos.x );
pev->maxs.y = max( startPos.y, endPos.y ); pev->maxs.y = Q_max( startPos.y, endPos.y );
pev->maxs.z = max( startPos.z, endPos.z ); pev->maxs.z = Q_max( startPos.z, endPos.z );
pev->mins = pev->mins - pev->origin; pev->mins = pev->mins - pev->origin;
pev->maxs = pev->maxs - pev->origin; pev->maxs = pev->maxs - pev->origin;
@ -312,12 +312,12 @@ void CBeam::SetObjectCollisionBox( void )
{ {
const Vector &startPos = GetStartPos(), &endPos = GetEndPos(); const Vector &startPos = GetStartPos(), &endPos = GetEndPos();
pev->absmin.x = min( startPos.x, endPos.x ); pev->absmin.x = Q_min( startPos.x, endPos.x );
pev->absmin.y = min( startPos.y, endPos.y ); pev->absmin.y = Q_min( startPos.y, endPos.y );
pev->absmin.z = min( startPos.z, endPos.z ); pev->absmin.z = Q_min( startPos.z, endPos.z );
pev->absmax.x = max( startPos.x, endPos.x ); pev->absmax.x = Q_max( startPos.x, endPos.x );
pev->absmax.y = max( startPos.y, endPos.y ); pev->absmax.y = Q_max( startPos.y, endPos.y );
pev->absmax.z = max( startPos.z, endPos.z ); pev->absmax.z = Q_max( startPos.z, endPos.z );
} }
#endif #endif

View file

@ -49,15 +49,17 @@ typedef int BOOL;
#define MAX_PATH PATH_MAX #define MAX_PATH PATH_MAX
#include <limits.h> #include <limits.h>
#include <stdarg.h> #include <stdarg.h>
#ifndef min #ifndef _vsnprintf
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif
#ifndef max
#define max(a,b) (((a) > (b)) ? (a) : (b))
#define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d) #define _vsnprintf(a,b,c,d) vsnprintf(a,b,c,d)
#endif #endif
#endif //_WIN32 #endif //_WIN32
// a1ba: C++11 made it impossible to macro min/max
// so change it's name to be a bit more future-proof
// and don't hack platform-specific C++ headers
#define Q_min(a,b) (((a) < (b)) ? (a) : (b))
#define Q_max(a,b) (((a) > (b)) ? (a) : (b))
// Misc C-runtime library headers // Misc C-runtime library headers
#include "stdio.h" #include "stdio.h"
#include "stdlib.h" #include "stdlib.h"

View file

@ -613,9 +613,9 @@ float CHalfLifeMultiplay::ModifyTiltedDamage(CBaseEntity *pAttacker,CBaseEntity
// Damage reduction range // Damage reduction range
if( iDamageType == DMG_BULLET ) if( iDamageType == DMG_BULLET )
fTiltedDamage = max( 0, fTiltedDamage - (vecDistance.Length()/30.0f) ); fTiltedDamage = Q_max( 0, fTiltedDamage - (vecDistance.Length()/30.0f) );
else if( iDamageType == DMG_BUCKSHOT ) else if( iDamageType == DMG_BUCKSHOT )
fTiltedDamage = max( 0, fTiltedDamage - (vecDistance.Length()/25.0f) ); fTiltedDamage = Q_max( 0, fTiltedDamage - (vecDistance.Length()/25.0f) );
// Each person incurs a 5% damage penalty // Each person incurs a 5% damage penalty
// if not on the ground // if not on the ground
@ -1570,15 +1570,15 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle )
if ( s && s[0] ) if ( s && s[0] )
{ {
item->minplayers = atoi( s ); item->minplayers = atoi( s );
item->minplayers = max( item->minplayers, 0 ); item->minplayers = Q_max( item->minplayers, 0 );
item->minplayers = min( item->minplayers, gpGlobals->maxClients ); item->minplayers = Q_min( item->minplayers, gpGlobals->maxClients );
} }
s = g_engfuncs.pfnInfoKeyValue( szBuffer, "maxplayers" ); s = g_engfuncs.pfnInfoKeyValue( szBuffer, "maxplayers" );
if ( s && s[0] ) if ( s && s[0] )
{ {
item->maxplayers = atoi( s ); item->maxplayers = atoi( s );
item->maxplayers = max( item->maxplayers, 0 ); item->maxplayers = Q_max( item->maxplayers, 0 );
item->maxplayers = min( item->maxplayers, gpGlobals->maxClients ); item->maxplayers = Q_min( item->maxplayers, gpGlobals->maxClients );
} }
// Remove keys // Remove keys

View file

@ -802,7 +802,7 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd )
m_weaponNames[i] = ALLOC_STRING(tmp); m_weaponNames[i] = ALLOC_STRING(tmp);
m_weaponCount[i] = atoi(pkvd->szValue); m_weaponCount[i] = atoi(pkvd->szValue);
m_weaponCount[i] = max(1,m_weaponCount[i]); m_weaponCount[i] = Q_max(1,m_weaponCount[i]);
pkvd->fHandled = TRUE; pkvd->fHandled = TRUE;
break; break;
} }

View file

@ -1956,7 +1956,7 @@ void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, f
while (flTotal > 0.001) while (flTotal > 0.001)
{ {
// don't walk more than 16 units or stairs stop working // don't walk more than 16 units or stairs stop working
flStep = min( 16.0, flTotal ); flStep = Q_min( 16.0, flTotal );
UTIL_MoveToOrigin ( ENT(pev), m_Route[ m_iRouteIndex ].vecLocation, flStep, MOVE_NORMAL ); UTIL_MoveToOrigin ( ENT(pev), m_Route[ m_iRouteIndex ].vecLocation, flStep, MOVE_NORMAL );
flTotal -= flStep; flTotal -= flStep;
} }

View file

@ -784,12 +784,12 @@ void inline CalcBounds(int &Lower, int &Upper, int Goal, int Best)
int Temp = 2*Goal - Best; int Temp = 2*Goal - Best;
if (Best > Goal) if (Best > Goal)
{ {
Lower = max(0, Temp); Lower = Q_max(0, Temp);
Upper = Best; Upper = Best;
} }
else else
{ {
Upper = min(255, Temp); Upper = Q_min(255, Temp);
Lower = Best; Lower = Best;
} }
} }
@ -942,7 +942,7 @@ int CGraph :: FindNearestNode ( const Vector &vecOrigin, int afNodeTypes )
} }
} }
for (i = max(m_minY,halfY+1); i <= m_maxY; i++) for (i = Q_max(m_minY,halfY+1); i <= m_maxY; i++)
{ {
for (j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++) for (j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++)
{ {
@ -958,7 +958,7 @@ int CGraph :: FindNearestNode ( const Vector &vecOrigin, int afNodeTypes )
} }
} }
for (i = min(m_maxZ,halfZ); i >= m_minZ; i--) for (i = Q_min(m_maxZ,halfZ); i >= m_minZ; i--)
{ {
for (j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++) for (j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++)
{ {
@ -974,7 +974,7 @@ int CGraph :: FindNearestNode ( const Vector &vecOrigin, int afNodeTypes )
} }
} }
for (i = max(m_minX,halfX+1); i <= m_maxX; i++) for (i = Q_max(m_minX,halfX+1); i <= m_maxX; i++)
{ {
for (j = m_RangeStart[0][i]; j <= m_RangeEnd[0][i]; j++) for (j = m_RangeStart[0][i]; j <= m_RangeEnd[0][i]; j++)
{ {
@ -991,7 +991,7 @@ int CGraph :: FindNearestNode ( const Vector &vecOrigin, int afNodeTypes )
} }
} }
for (i = min(m_maxY,halfY); i >= m_minY; i--) for (i = Q_min(m_maxY,halfY); i >= m_minY; i--)
{ {
for (j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++) for (j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++)
{ {
@ -1007,7 +1007,7 @@ int CGraph :: FindNearestNode ( const Vector &vecOrigin, int afNodeTypes )
} }
} }
for (i = max(m_minZ,halfZ+1); i <= m_maxZ; i++) for (i = Q_max(m_minZ,halfZ+1); i <= m_maxZ; i++)
{ {
for (j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++) for (j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++)
{ {

View file

@ -2202,7 +2202,7 @@ void CBasePlayer::CheckTimeBasedDamage()
// after the player has been drowning and finally takes a breath // after the player has been drowning and finally takes a breath
if (m_idrowndmg > m_idrownrestored) if (m_idrowndmg > m_idrownrestored)
{ {
int idif = min(m_idrowndmg - m_idrownrestored, 10); int idif = Q_min(m_idrowndmg - m_idrownrestored, 10);
TakeHealth(idif, DMG_GENERIC); TakeHealth(idif, DMG_GENERIC);
m_idrownrestored += idif; m_idrownrestored += idif;
@ -2583,23 +2583,23 @@ pt_end:
if ( gun && gun->UseDecrement() ) if ( gun && gun->UseDecrement() )
{ {
gun->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); gun->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 );
gun->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); gun->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 );
if ( gun->m_flTimeWeaponIdle != 1000 ) if ( gun->m_flTimeWeaponIdle != 1000 )
{ {
gun->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); gun->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 );
} }
if ( gun->pev->fuser1 != 1000 ) if ( gun->pev->fuser1 != 1000 )
{ {
gun->pev->fuser1 = max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); gun->pev->fuser1 = Q_max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 );
} }
// Only decrement if not flagged as NO_DECREMENT // Only decrement if not flagged as NO_DECREMENT
// if ( gun->m_flPumpTime != 1000 ) // if ( gun->m_flPumpTime != 1000 )
// { // {
// gun->m_flPumpTime = max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); // gun->m_flPumpTime = Q_max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 );
// } // }
} }
@ -3711,7 +3711,7 @@ int CBasePlayer :: GiveAmmo( int iCount, char *szName, int iMax )
if ( i < 0 || i >= MAX_AMMO_SLOTS ) if ( i < 0 || i >= MAX_AMMO_SLOTS )
return -1; return -1;
int iAdd = min( iCount, iMax - m_rgAmmo[i] ); int iAdd = Q_min( iCount, iMax - m_rgAmmo[i] );
if ( iAdd < 1 ) if ( iAdd < 1 )
return i; return i;
@ -3851,7 +3851,7 @@ void CBasePlayer::SendAmmoUpdate(void)
// send "Ammo" update message // send "Ammo" update message
MESSAGE_BEGIN( MSG_ONE, gmsgAmmoX, NULL, pev ); MESSAGE_BEGIN( MSG_ONE, gmsgAmmoX, NULL, pev );
WRITE_BYTE( i ); WRITE_BYTE( i );
WRITE_BYTE( max( min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte WRITE_BYTE( Q_max( Q_min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte
MESSAGE_END(); MESSAGE_END();
} }
} }
@ -3923,7 +3923,7 @@ void CBasePlayer :: UpdateClientData( void )
if (pev->health != m_iClientHealth) if (pev->health != m_iClientHealth)
{ {
int iHealth = max( pev->health, 0 ); // make sure that no negative health values are sent int iHealth = Q_max( pev->health, 0 ); // make sure that no negative health values are sent
// send "health" update message // send "health" update message
MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, pev ); MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, pev );

View file

@ -1563,7 +1563,7 @@ void TEXTURETYPE_Process(const char *pszFilename)
continue; continue;
// null-terminate name and save in sentences array // null-terminate name and save in sentences array
j = min (j, CBTEXTURENAMEMAX-1+i); j = Q_min (j, CBTEXTURENAMEMAX-1+i);
buffer[j] = 0; buffer[j] = 0;
char szTextureName[CBTEXTURENAMEMAX]; char szTextureName[CBTEXTURENAMEMAX];

View file

@ -453,7 +453,7 @@ void CBaseTurret::EyeOff( )
{ {
if (m_eyeBrightness > 0) if (m_eyeBrightness > 0)
{ {
m_eyeBrightness = max( 0, m_eyeBrightness - 30 ); m_eyeBrightness = Q_max( 0, m_eyeBrightness - 30 );
m_pEyeGlow->SetBrightness( m_eyeBrightness ); m_pEyeGlow->SetBrightness( m_eyeBrightness );
} }
} }

View file

@ -1158,7 +1158,7 @@ void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color,
WRITE_COORD( direction.y ); WRITE_COORD( direction.y );
WRITE_COORD( direction.z ); WRITE_COORD( direction.z );
WRITE_BYTE( color ); WRITE_BYTE( color );
WRITE_BYTE( min( amount, 255 ) ); WRITE_BYTE( Q_min( amount, 255 ) );
MESSAGE_END(); MESSAGE_END();
} }
@ -1205,7 +1205,7 @@ void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color,
WRITE_SHORT( g_sModelIndexBloodSpray ); // initial sprite model WRITE_SHORT( g_sModelIndexBloodSpray ); // initial sprite model
WRITE_SHORT( g_sModelIndexBloodDrop ); // droplet sprite models WRITE_SHORT( g_sModelIndexBloodDrop ); // droplet sprite models
WRITE_BYTE( color ); // color index into host_basepal WRITE_BYTE( color ); // color index into host_basepal
WRITE_BYTE( min( max( 3, amount / 10 ), 16 ) ); // size WRITE_BYTE( Q_min( Q_max( 3, amount / 10 ), 16 ) ); // size
MESSAGE_END();*/ MESSAGE_END();*/
} }

View file

@ -600,7 +600,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )
{ {
// complete the reload. // complete the reload.
int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = Q_min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
// Add them to the clip // Add them to the clip
m_iClip += j; m_iClip += j;
@ -827,7 +827,7 @@ BOOL CBasePlayerWeapon :: AddPrimaryAmmo( int iCount, char *szName, int iMaxClip
else if (m_iClip == 0) else if (m_iClip == 0)
{ {
int i; int i;
i = min( m_iClip + iCount, iMaxClip ) - m_iClip; i = Q_min( m_iClip + iCount, iMaxClip ) - m_iClip;
m_iClip += i; m_iClip += i;
iIdAmmo = m_pPlayer->GiveAmmo( iCount - i, szName, iMaxCarry ); iIdAmmo = m_pPlayer->GiveAmmo( iCount - i, szName, iMaxCarry );
} }
@ -917,7 +917,7 @@ BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay,
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0) if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
return FALSE; return FALSE;
int j = min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = Q_min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
if (j == 0) if (j == 0)
return FALSE; return FALSE;
@ -1379,7 +1379,7 @@ int CWeaponBox::GiveAmmo( int iCount, char *szName, int iMax, int *pIndex/* = NU
if (pIndex) if (pIndex)
*pIndex = i; *pIndex = i;
int iAdd = min( iCount, iMax - m_rgAmmo[i]); int iAdd = Q_min( iCount, iMax - m_rgAmmo[i]);
if (iCount == 0 || iAdd > 0) if (iCount == 0 || iAdd > 0)
{ {
m_rgAmmo[i] += iAdd; m_rgAmmo[i] += iAdd;

View file

@ -72,7 +72,7 @@ void CAkimboWeapon::ItemPostFrame()
if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )
{ {
// complete the reload. // complete the reload.
int j = min( iMaxClip(), m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] ); int j = Q_min( iMaxClip(), m_pPlayer->m_rgAmmo[ m_iPrimaryAmmoType ] );
// For animations sake, if we are putting an odd number of bullets in, // For animations sake, if we are putting an odd number of bullets in,
// swap the current hand to the right hand // swap the current hand to the right hand

View file

@ -81,7 +81,7 @@ void CAutomatic::ItemPostFrame()
if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )
{ {
// complete the reload. // complete the reload.
int j = min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = Q_min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
// account for a bullet in the gun // account for a bullet in the gun
if(m_iClip != 0) if(m_iClip != 0)
@ -287,7 +287,7 @@ void CSmg9::PrimaryAttack()
{ {
Vector accVector(m_flAccuracy,0,0); Vector accVector(m_flAccuracy,0,0);
for(int i = 0;i < min(m_iClip,SMG9_BURST_COUNT);i++) for(int i = 0;i < Q_min(m_iClip,SMG9_BURST_COUNT);i++)
{ {
PLAYBACK_EVENT_FULL(flags, PLAYBACK_EVENT_FULL(flags,
m_pPlayer->edict(), m_pPlayer->edict(),
@ -1148,8 +1148,8 @@ void CG11::PrimaryAttack()
else else
{ {
spread = m_flBurstAccuracy; spread = m_flBurstAccuracy;
bulletcount = min(m_iClip,3); bulletcount = Q_min(m_iClip,3);
m_iClip -= min(m_iClip,3); m_iClip -= Q_min(m_iClip,3);
m_iAllowFire = FALSE; m_iAllowFire = FALSE;
rof = m_flRateOfFire + 0.2f; rof = m_flRateOfFire + 0.2f;
} }
@ -1527,7 +1527,7 @@ void CBoltRifle::ItemPostFrame()
if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )
{ {
// complete the reload. // complete the reload.
int j = min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = Q_min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
m_iClip = 0; m_iClip = 0;
@ -1997,7 +1997,7 @@ void CSten::ItemPostFrame()
if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )
{ {
// complete the reload. // complete the reload.
int j = min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = Q_min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
m_iClip = 0; m_iClip = 0;

View file

@ -376,7 +376,7 @@ void CMolotovCocktail::ThrowMolotov()
m_bJustThrown = TRUE; m_bJustThrown = TRUE;
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
float flVelocity = min(900,(gpGlobals->time - m_flStartAttack) * 350); float flVelocity = Q_min(900,(gpGlobals->time - m_flStartAttack) * 350);
CMolotov::ShootMolotov(m_usFire1,m_pPlayer, CMolotov::ShootMolotov(m_usFire1,m_pPlayer,
m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16, m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16,
@ -528,7 +528,7 @@ void CTimedExplosiveWeapon::ThrowExplosive( float flFuse )
m_flStartAttack = -1.0f; m_flStartAttack = -1.0f;
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
float flVelocity = min(700,(gpGlobals->time - m_flStartAttack) * 250); float flVelocity = Q_min(700,(gpGlobals->time - m_flStartAttack) * 250);
if( m_iExplosiveType == ET_FRAG ) if( m_iExplosiveType == ET_FRAG )
{ {

View file

@ -484,7 +484,7 @@ void CThrowingKnife::ThrowObject()
m_bJustThrown = TRUE; m_bJustThrown = TRUE;
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
float flVelocity = min(2300,(gpGlobals->time - m_flStartAttack) * 1800); float flVelocity = Q_min(2300,(gpGlobals->time - m_flStartAttack) * 1800);
CThrownMelee::ThrowObject(m_pPlayer,m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16, CThrownMelee::ThrowObject(m_pPlayer,m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16,
gpGlobals->v_forward * flVelocity, gpGlobals->v_forward * flVelocity,
@ -1055,7 +1055,7 @@ void CSpear::ThrowObject()
#endif #endif
#ifndef CLIENT_DLL #ifndef CLIENT_DLL
float flVelocity = min(1500,(gpGlobals->time - m_flStartAttack) * 900); float flVelocity = Q_min(1500,(gpGlobals->time - m_flStartAttack) * 900);
CThrownMelee *pMelee = CThrownMelee::ThrowObject(m_pPlayer,m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16, CThrownMelee *pMelee = CThrownMelee::ThrowObject(m_pPlayer,m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16,
gpGlobals->v_forward * flVelocity, gpGlobals->v_forward * flVelocity,

View file

@ -64,7 +64,7 @@ void CShotgun::ItemPostFrame()
if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )
{ {
// complete the reload. // complete the reload.
int j = min( 1, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = Q_min( 1, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
// Add them to the clip // Add them to the clip
m_iClip += j; m_iClip += j;

View file

@ -107,9 +107,9 @@ void CSidearm::ItemPostFrame()
// complete the reload. // complete the reload.
if(m_iId == WEAPON_RUGER) if(m_iId == WEAPON_RUGER)
j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); j = Q_min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
else else
j = min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); j = Q_min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
// remove all ammo from gun. // remove all ammo from gun.
if(m_iId != WEAPON_RUGER) if(m_iId != WEAPON_RUGER)
@ -1438,7 +1438,7 @@ void CHandcannon::ItemPostFrame()
if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) if ((m_fInReload) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) )
{ {
// complete the reload. // complete the reload.
int j = min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); int j = Q_min( iMaxClip(), m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
m_iClip = 0; m_iClip = 0;

View file

@ -706,7 +706,7 @@ void CVoiceStatus::RepositionLabels()
// Setup the background label to fit everything in. // Setup the background label to fit everything in.
int border = 2; int border = 2;
int bgWide = textWide + iconWide + border*3; int bgWide = textWide + iconWide + border*3;
int bgTall = max( textTall, iconTall ) + border*2; int bgTall = Q_max( textTall, iconTall ) + border*2;
pLabel->m_pBackground->setBounds( ScreenWidth - bgWide - 8, y, bgWide, bgTall ); pLabel->m_pBackground->setBounds( ScreenWidth - bgWide - 8, y, bgWide, bgTall );
// Put the text at the left. // Put the text at the left.

View file

@ -135,8 +135,8 @@ typedef struct hull_s
// double to float warning // double to float warning
#pragma warning(disable : 4244) #pragma warning(disable : 4244)
#define max(a, b) (((a) > (b)) ? (a) : (b)) #define Q_max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b)) #define Q_min(a, b) (((a) < (b)) ? (a) : (b))
// up / down // up / down
#define PITCH 0 #define PITCH 0
// left / right // left / right
@ -292,7 +292,7 @@ void PM_ProcessMaterials(char *pszFilename)
continue; continue;
// null-terminate name and save in sentences array // null-terminate name and save in sentences array
j = min (j, CBTEXTURENAMEMAX-1+i); j = Q_min (j, CBTEXTURENAMEMAX-1+i);
buffer[j] = 0; buffer[j] = 0;
strcpy(&(szTextureName[0]),&(buffer[i])); strcpy(&(szTextureName[0]),&(buffer[i]));
@ -2278,7 +2278,7 @@ void PM_Duck( void )
pmove->bInDuck = true; pmove->bInDuck = true;
} }
time = max( 0.0, ( 1.0 - (float)pmove->flDuckTime / 1000.0 ) ); time = Q_max( 0.0, ( 1.0 - (float)pmove->flDuckTime / 1000.0 ) );
if ( pmove->bInDuck ) if ( pmove->bInDuck )
{ {
@ -3041,7 +3041,7 @@ void PM_DropPunchAngle ( vec3_t punchangle )
len = VectorNormalize ( punchangle ); len = VectorNormalize ( punchangle );
len -= (10.0 + len * 0.5) * pmove->frametime; len -= (10.0 + len * 0.5) * pmove->frametime;
len = max( len, 0.0 ); len = Q_max( len, 0.0 );
VectorScale ( punchangle, len, punchangle); VectorScale ( punchangle, len, punchangle);
} }
@ -3065,7 +3065,7 @@ void PM_CheckParamters( void )
maxspeed = pmove->clientmaxspeed; //atof( pmove->PM_Info_ValueForKey( pmove->physinfo, "maxspd" ) ); maxspeed = pmove->clientmaxspeed; //atof( pmove->PM_Info_ValueForKey( pmove->physinfo, "maxspd" ) );
if ( maxspeed != 0.0 ) if ( maxspeed != 0.0 )
{ {
pmove->maxspeed = min( maxspeed, pmove->maxspeed ); pmove->maxspeed = Q_min( maxspeed, pmove->maxspeed );
} }
if ( ( spd != 0.0 ) && if ( ( spd != 0.0 ) &&