Skip to content

Commit

Permalink
Merge branch 'master' into blackops
Browse files Browse the repository at this point in the history
  • Loading branch information
nekonomicon committed Jul 20, 2024
2 parents d7f9ca7 + ee304c9 commit c4b9b7e
Show file tree
Hide file tree
Showing 10 changed files with 81 additions and 31 deletions.
29 changes: 15 additions & 14 deletions cl_dll/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ void WeaponsResource::LoadWeaponSprites( WEAPON *pWeapon )
{
int i, iRes;

if( ScreenWidth < 640 )
iRes = 320;
else
iRes = 640;
iRes = GetSpriteRes( ScreenWidth, ScreenHeight );

char sz[256];

Expand Down Expand Up @@ -323,21 +320,24 @@ 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 = Q_max( gHR.iHistoryGap, gHUD.GetSpriteRect( m_HUD_bucket0 ).bottom - gHUD.GetSpriteRect( m_HUD_bucket0 ).top );
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();

if( ScreenWidth >= 640 )
{
giABWidth = 20;
giABHeight = 4;
}
const int res = GetSpriteRes( ScreenWidth, ScreenHeight );
int factor;
if( res >= 2560 )
factor = 4;
else if( res >= 1280 )
factor = 3;
else if( res >= 640 )
factor = 2;
else
{
giABWidth = 10;
giABHeight = 2;
}
factor = 1;

giABWidth = 10 * factor;
giABHeight = 2 * factor;

return 1;
}
Expand Down Expand Up @@ -876,6 +876,7 @@ int CHudAmmo::Draw( float flTime )

// Does this weapon have a clip?
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
y += gHUD.m_iHudNumbersYOffset; // a1ba: fix HL25 HUD vertical inconsistensy

// Does weapon have any ammo at all?
if( m_pWeapon->iAmmoType > 0 )
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/ammohistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ int HistoryResource::DrawAmmoHistory( float flTime )

// Draw the pic
int ypos = ScreenHeight - (AMMO_PICKUP_PICK_HEIGHT + (AMMO_PICKUP_GAP * i));
int xpos = ScreenWidth - 24;
int xpos = ScreenWidth - (rcPic.right - rcPic.left);
if( spr && *spr ) // weapon isn't loaded yet so just don't draw the pic
{
// the dll has to make sure it has sent info the weapons you need
Expand All @@ -142,7 +142,7 @@ int HistoryResource::DrawAmmoHistory( float flTime )
// do not draw black console string
if( !( ( hud_textmode->value == 2 ) && ( scale < 200 ) ) )
// Draw the number
gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b );
gHUD.DrawHudNumberString( xpos - 14, ypos, xpos - 104, rgAmmoHistory[i].iCount, r, g, b );
}
else if( rgAmmoHistory[i].type == HISTSLOT_WEAP )
{
Expand Down
8 changes: 6 additions & 2 deletions cl_dll/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ int CHudBattery::Draw( float flTime )
int iOffset = ( m_prc1->bottom - m_prc1->top ) / 6;

y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = ScreenWidth / 5;

if( gHUD.IsHL25( )) // a1ba: HL25 style
x = ( m_prc1->right - m_prc1->left ) * 3;
else
x = ScreenWidth / 5;

// make sure we have the right sprite handles
if( !m_hSprite1 )
Expand All @@ -127,7 +131,7 @@ int CHudBattery::Draw( float flTime )
}

x += ( m_prc1->right - m_prc1->left );
x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b );
x = gHUD.DrawHudNumber( x, y + gHUD.m_iHudNumbersYOffset, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b );

return 1;
}
21 changes: 21 additions & 0 deletions cl_dll/cl_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,27 @@ inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex(
#define Q_min(a, b) (((a) < (b)) ? (a) : (b))
#define fabs(x) ((x) > 0 ? (x) : 0 - (x))

inline int GetSpriteRes( int width, int height )
{
int i;

if( width < 640 )
i = 320;
else if( width < 1280 || !gHUD.m_pAllowHD->value )
i = 640;
else
{
if( height <= 720 )
i = 640;
else if( width <= 2560 || height <= 1600 )
i = 1280;
else
i = 2560;
}

return Q_min( i, gHUD.m_iMaxRes );
}

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

#define DotProduct(x, y) ((x)[0] * (y)[0] + (x)[1] * (y)[1] + (x)[2] * (y)[2])
Expand Down
4 changes: 2 additions & 2 deletions cl_dll/health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,14 @@ int CHudHealth::Draw( float flTime )

x = CrossWidth + HealthWidth / 2;

x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b );
x = gHUD.DrawHudNumber( x, y + gHUD.m_iHudNumbersYOffset, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b );

x += HealthWidth / 2;

int iHeight = gHUD.m_iFontHeight;
int iWidth = HealthWidth / 10;
UnpackRGB( r, g, b, RGB_YELLOWISH );
FillRGBA( x, y, iWidth, iHeight, r, g, b, a );
FillRGBA( x, y + gHUD.m_iHudNumbersYOffset, iWidth, iHeight, r, g, b, a );
}

DrawDamage( flTime );
Expand Down
23 changes: 18 additions & 5 deletions cl_dll/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,7 @@ void CHud::Init( void )
default_fov = CVAR_CREATE( "default_fov", "90", FCVAR_ARCHIVE );
m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE );
m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE );
m_pAllowHD = CVAR_CREATE ( "hud_allow_hd", "1", FCVAR_ARCHIVE );
cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" );
cl_viewbob = CVAR_CREATE( "cl_viewbob", "1", FCVAR_ARCHIVE );

Expand Down Expand Up @@ -514,16 +515,28 @@ void CHud::VidInit( void )
m_hsprLogo = 0;
m_hsprCursor = 0;

if( ScreenWidth < 640 )
m_iRes = 320;
else
m_iRes = 640;
// a1ba: don't break the loading order here and
// don't cause memory leak but check
// maximum HUD sprite resolution we have
m_iMaxRes = 640;
client_sprite_t *pSpriteList = m_pSpriteList ? m_pSpriteList :
SPR_GetList( "sprites/hud.txt", &m_iSpriteCountAllRes );
if( pSpriteList )
{
for( int i = 0; i < m_iSpriteCountAllRes; i++ )
{
if( m_iMaxRes < pSpriteList[i].iRes )
m_iMaxRes = pSpriteList[i].iRes;
}
}

m_iRes = GetSpriteRes( ScreenWidth, ScreenHeight );

// Only load this once
if( !m_pSpriteList )
{
// we need to load the hud.txt, and all sprites within
m_pSpriteList = SPR_GetList( "sprites/hud.txt", &m_iSpriteCountAllRes );
m_pSpriteList = pSpriteList;

if( m_pSpriteList )
{
Expand Down
11 changes: 11 additions & 0 deletions cl_dll/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include "wrect.h"
#include "cl_dll.h"
#include "ammo.h"
#include "cvardef.h"

#define DHN_DRAWZERO 1
#define DHN_2DIGITS 2
Expand Down Expand Up @@ -567,8 +568,11 @@ class CHud
int m_iFOV;
int m_Teamplay;
int m_iRes;
int m_iMaxRes;
int m_iHudNumbersYOffset;
cvar_t *m_pCvarStealMouse;
cvar_t *m_pCvarDraw;
cvar_t *m_pAllowHD;

int m_iFontHeight;
int DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b );
Expand Down Expand Up @@ -597,6 +601,13 @@ class CHud
{
return m_rgrcRects[index];
}

inline bool IsHL25( void )
{
// a1ba: only HL25 have higher resolution HUD spritesheets
// and only accept HUD style changes if user has allowed HD sprites
return m_iMaxRes > 640 && m_pAllowHD->value;
}

int GetSpriteIndex( const char *SpriteName ); // gets a sprite index, for use in the m_rghSprites[] array

Expand Down
2 changes: 2 additions & 0 deletions cl_dll/hud_redraw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ int CHud::Redraw( float flTime, int intermission )
// if no redrawing is necessary
// return 0;

m_iHudNumbersYOffset = IsHL25() ? m_iFontHeight * 0.2 : 0;

if( m_pCvarDraw->value )
{
HUDLIST *pList = m_pHudList;
Expand Down
7 changes: 1 addition & 6 deletions cl_dll/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,14 +123,9 @@ void VectorMA( const float *veca, float scale, const float *vecb, float *vecc )

HSPRITE LoadSprite( const char *pszName )
{
int i;
int i = GetSpriteRes( ScreenWidth, ScreenHeight );
char sz[256];

if( ScreenWidth < 640 )
i = 320;
else
i = 640;

sprintf( sz, pszName, i );

return SPR_Load( sz );
Expand Down
3 changes: 3 additions & 0 deletions dlls/ggrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,10 @@ void CGrenade::BounceTouch( CBaseEntity *pOther )
if( pev->framerate > 1.0f )
pev->framerate = 1.0f;
else if( pev->framerate < 0.5f )
{
pev->framerate = 0.0f;
pev->frame = 0.0f;
}
}

void CGrenade::SlideTouch( CBaseEntity *pOther )
Expand Down

0 comments on commit c4b9b7e

Please sign in to comment.