Skip to content

Commit

Permalink
Merge pull request ValveSoftware#1 from JoelTroch/feature/linux-fix
Browse files Browse the repository at this point in the history
Add fixes for Linux
  • Loading branch information
Solokiller committed Sep 3, 2018
2 parents f430059 + 39524f6 commit b1c0a9f
Show file tree
Hide file tree
Showing 102 changed files with 372 additions and 348 deletions.
8 changes: 4 additions & 4 deletions cl_dll/MOTD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ int CHudMOTD :: Draw( float fTime )
fElapsed = gHUD.m_flTime - sfLastTime;

// Don't let time go negative ( level transition? )
fElapsed = max( 0.0, fElapsed );
fElapsed = V_max( 0.0, fElapsed );
// Don't let time go hugely positive ( first connection to active server ? )
fElapsed = min( 1.0, fElapsed );
fElapsed = V_min( 1.0, fElapsed );

// Remember last timestamp
sfLastTime = gHUD.m_flTime;
Expand All @@ -90,7 +90,7 @@ int CHudMOTD :: Draw( float fTime )
m_flActiveRemaining -= fElapsed;

// find the top of where the MOTD should be drawn, so the whole thing is centered in the screen
int ypos = max(((ScreenHeight - (m_iLines * LINE_HEIGHT)) / 2) - 40, 30 ); // shift it up slightly
int ypos = V_max(((ScreenHeight - (m_iLines * LINE_HEIGHT)) / 2) - 40, 30 ); // shift it up slightly
char *ch = m_szMOTD;
while ( *ch )
{
Expand Down Expand Up @@ -139,7 +139,7 @@ int CHudMOTD :: MsgFunc_MOTD( const char *pszName, int iSize, void *pbuf )
{
m_iFlags |= HUD_ACTIVE;

MOTD_DISPLAY_TIME = max( 10, CVAR_GET_FLOAT( "motd_display_time" ) );
MOTD_DISPLAY_TIME = V_max( 10, CVAR_GET_FLOAT( "motd_display_time" ) );

m_flActiveRemaining = MOTD_DISPLAY_TIME;

Expand Down
10 changes: 5 additions & 5 deletions cl_dll/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->hInactive = SPR_Load(sz);
pWeapon->rcInactive = p->rc;

gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
gHR.iHistoryGap = V_max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
}
else
pWeapon->hInactive = 0;
Expand All @@ -176,7 +176,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->hAmmo = SPR_Load(sz);
pWeapon->rcAmmo = p->rc;

gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
gHR.iHistoryGap = V_max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
}
else
pWeapon->hAmmo = 0;
Expand All @@ -188,7 +188,7 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
pWeapon->hAmmo2 = SPR_Load(sz);
pWeapon->rcAmmo2 = p->rc;

gHR.iHistoryGap = max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
gHR.iHistoryGap = V_max( gHR.iHistoryGap, pWeapon->rcActive.bottom - pWeapon->rcActive.top );
}
else
pWeapon->hAmmo2 = 0;
Expand Down Expand Up @@ -320,7 +320,7 @@ int CHudAmmo::VidInit(void)
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;

gHR.iHistoryGap = max( gHR.iHistoryGap, gHUD.GetSpriteRect(m_HUD_bucket0).bottom - gHUD.GetSpriteRect(m_HUD_bucket0).top);
gHR.iHistoryGap = V_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
gWR.LoadAllWeaponSprites();
Expand Down Expand Up @@ -862,7 +862,7 @@ int CHudAmmo::Draw(float flTime)

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) V_max( MIN_ALPHA, m_fFade );

if (m_fFade > 0)
m_fFade -= (gHUD.m_flTimeDelta * 20);
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/ammo_secondary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ int CHudAmmoSecondary :: Draw(float flTime)
// draw secondary ammo icons above normal ammo readout
int a, x, y, r, g, b, AmmoWidth;
UnpackRGB( r, g, b, RGB_YELLOWISH );
a = (int) max( MIN_ALPHA, m_fFade );
a = (int) V_max( MIN_ALPHA, m_fFade );
if (m_fFade > 0)
m_fFade -= (gHUD.m_flTimeDelta * 20); // slowly lower alpha to fade out icons
ScaleColors( r, g, b, a );
Expand Down Expand Up @@ -141,7 +141,7 @@ int CHudAmmoSecondary :: MsgFunc_SecAmmoVal( const char *pszName, int iSize, voi
int count = 0;
for ( int i = 0; i < MAX_SEC_AMMO_VALUES; i++ )
{
count += max( 0, m_iAmmoAmounts[i] );
count += V_max( 0, m_iAmmoAmounts[i] );
}

if ( count == 0 )
Expand Down
8 changes: 4 additions & 4 deletions cl_dll/ammohistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
{
if ( rgAmmoHistory[i].type )
{
rgAmmoHistory[i].DisplayTime = min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );
rgAmmoHistory[i].DisplayTime = V_min( rgAmmoHistory[i].DisplayTime, gHUD.m_flTime + HISTORY_DRAW_TIME );

if ( rgAmmoHistory[i].DisplayTime <= flTime )
{ // pic drawing time has expired
Expand All @@ -126,7 +126,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime )
int r, g, b;
UnpackRGB(r,g,b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, min(scale, 255) );
ScaleColors(r, g, b, V_min(scale, 255) );

// Draw the pic
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
Expand Down Expand Up @@ -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

float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, min(scale, 255) );
ScaleColors(r, g, b, V_min(scale, 255) );

int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (weap->rcInactive.right - weap->rcInactive.left);
Expand All @@ -172,7 +172,7 @@ int HistoryResource :: DrawAmmoHistory( float flTime )

UnpackRGB(r,g,b, RGB_YELLOWISH);
float scale = (rgAmmoHistory[i].DisplayTime - flTime) * 80;
ScaleColors(r, g, b, min(scale, 255) );
ScaleColors(r, g, b, V_min(scale, 255) );

int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - (rect.right - rect.left) - 10;
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ int CHudBattery::Draw(float flTime)
if ( m_iBatMax > 0 )
fScale = 1.0 / (float)m_iBatMax;

rc.top += m_iHeight * ((float)(m_iBatMax-(min(m_iBatMax,m_iBat))) * fScale); // battery can go from 0 to m_iBatMax so * fScale goes from 0 to 1
rc.top += m_iHeight * ((float)(m_iBatMax-(V_min(m_iBatMax,m_iBat))) * fScale); // battery can go from 0 to m_iBatMax so * fScale goes from 0 to 1
#else
rc.top += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
rc.top += m_iHeight * ((float)(100-(V_min(100,m_iBat))) * 0.01); // battery can go from 0 to 100 so * 0.01 goes from 0 to 1
#endif

UnpackRGB(r,g,b, RGB_YELLOWISH);
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/cl_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ inline int safe_sprintf( char *dst, int len_dst, const char *format, ...)
inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); }
inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); }

#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define V_max(a, b) (((a) > (b)) ? (a) : (b))
#define V_min(a, b) (((a) < (b)) ? (a) : (b))

void ScaleColors( int &r, int &g, int &b, int a );

Expand Down
2 changes: 1 addition & 1 deletion cl_dll/death.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ int CHudDeathNotice :: Draw( float flTime )
continue;
}

rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );
rgDeathNoticeList[i].flDisplayTime = V_min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME );

// Only draw if the viewport will let me
if ( gViewPort && gViewPort->AllowedToPrintText() )
Expand Down
26 changes: 13 additions & 13 deletions cl_dll/health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,25 +267,25 @@ void CHudHealth::CalcDamageDirection(vec3_t vecFrom)
if (side > 0)
{
if (side > 0.3)
m_fAttackFront = max(m_fAttackFront, side);
m_fAttackFront = V_max(m_fAttackFront, side);
}
else
{
float f = fabs(side);
if (f > 0.3)
m_fAttackRear = max(m_fAttackRear, f);
m_fAttackRear = V_max(m_fAttackRear, f);
}

if (front > 0)
{
if (front > 0.3)
m_fAttackRight = max(m_fAttackRight, front);
m_fAttackRight = V_max(m_fAttackRight, front);
}
else
{
float f = fabs(front);
if (f > 0.3)
m_fAttackLeft = max(m_fAttackLeft, f);
m_fAttackLeft = V_max(m_fAttackLeft, f);
}
}
}
Expand All @@ -307,57 +307,57 @@ int CHudHealth::DrawPain(float flTime)
if (m_fAttackFront > 0.4)
{
GetPainColor(r,g,b);
shade = a * max( m_fAttackFront, 0.5 );
shade = a * V_max( m_fAttackFront, 0.5 );
ScaleColors(r, g, b, shade);
SPR_Set(m_hSprite, r, g, b );

x = ScreenWidth/2 - SPR_Width(m_hSprite, 0)/2;
y = ScreenHeight/2 - SPR_Height(m_hSprite,0) * 3;
SPR_DrawAdditive(0, x, y, NULL);
m_fAttackFront = max( 0, m_fAttackFront - fFade );
m_fAttackFront = V_max( 0, m_fAttackFront - fFade );
} else
m_fAttackFront = 0;

if (m_fAttackRight > 0.4)
{
GetPainColor(r,g,b);
shade = a * max( m_fAttackRight, 0.5 );
shade = a * V_max( m_fAttackRight, 0.5 );
ScaleColors(r, g, b, shade);
SPR_Set(m_hSprite, r, g, b );

x = ScreenWidth/2 + SPR_Width(m_hSprite, 1) * 2;
y = ScreenHeight/2 - SPR_Height(m_hSprite,1)/2;
SPR_DrawAdditive(1, x, y, NULL);
m_fAttackRight = max( 0, m_fAttackRight - fFade );
m_fAttackRight = V_max( 0, m_fAttackRight - fFade );
} else
m_fAttackRight = 0;

if (m_fAttackRear > 0.4)
{
GetPainColor(r,g,b);
shade = a * max( m_fAttackRear, 0.5 );
shade = a * V_max( m_fAttackRear, 0.5 );
ScaleColors(r, g, b, shade);
SPR_Set(m_hSprite, r, g, b );

x = ScreenWidth/2 - SPR_Width(m_hSprite, 2)/2;
y = ScreenHeight/2 + SPR_Height(m_hSprite,2) * 2;
SPR_DrawAdditive(2, x, y, NULL);
m_fAttackRear = max( 0, m_fAttackRear - fFade );
m_fAttackRear = V_max( 0, m_fAttackRear - fFade );
} else
m_fAttackRear = 0;

if (m_fAttackLeft > 0.4)
{
GetPainColor(r,g,b);
shade = a * max( m_fAttackLeft, 0.5 );
shade = a * V_max( m_fAttackLeft, 0.5 );
ScaleColors(r, g, b, shade);
SPR_Set(m_hSprite, r, g, b );

x = ScreenWidth/2 - SPR_Width(m_hSprite, 3) * 3;
y = ScreenHeight/2 - SPR_Height(m_hSprite,3)/2;
SPR_DrawAdditive(3, x, y, NULL);

m_fAttackLeft = max( 0, m_fAttackLeft - fFade );
m_fAttackLeft = V_max( 0, m_fAttackLeft - fFade );
} else
m_fAttackLeft = 0;

Expand Down Expand Up @@ -398,7 +398,7 @@ int CHudHealth::DrawDamage(float flTime)

if ( m_bitsDamage & giDmgFlags[i] )
{
pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire );
pdmg->fExpire = V_min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire );

if ( pdmg->fExpire <= flTime // when the time has expired
&& a < 40 ) // and the flash is at the low point of the cycle
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ BOOL CBasePlayerWeapon :: DefaultReload( int iClipSize, int iAnim, float fDelay,
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
return FALSE;

int j = min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
int j = V_min(iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);

if (j == 0)
return FALSE;
Expand Down Expand Up @@ -328,7 +328,7 @@ void CBasePlayerWeapon::ItemPostFrame( void )
{
#if 0 // FIXME, need ammo on client to make this work right
// complete the reload.
int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);
int j = V_min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]);

// Add them to the clip
m_iClip += j;
Expand Down

0 comments on commit b1c0a9f

Please sign in to comment.