Skip to content
31 changes: 17 additions & 14 deletions cl_dll/ammo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,14 @@ void WeaponsResource :: LoadWeaponSprites( WEAPON *pWeapon )
{
int i, iRes;

if (ScreenWidth < 640)
iRes = 320;
else
if (ScreenWidth > 2560 && ScreenHeight > 1600)
iRes = 2560;
else if (ScreenWidth >= 1280 && ScreenHeight > 720)
iRes = 1280;
else if (ScreenWidth >= 640)
iRes = 640;
else
iRes = 320;

char sz[256];

Expand Down Expand Up @@ -327,16 +331,15 @@ int CHudAmmo::VidInit(void)
// If we've already loaded weapons, let's get new sprites
gWR.LoadAllWeaponSprites();

if (ScreenWidth >= 640)
{
giABWidth = 20;
giABHeight = 4;
}
else
{
giABWidth = 10;
giABHeight = 2;
}
int nScale = 1;
if (ScreenWidth > 2560 && ScreenHeight > 1600)
nScale = 4;
else if (ScreenWidth >= 1280 && ScreenHeight > 720)
nScale = 3;
else if (ScreenWidth >= 640)
nScale = 2;
giABWidth = 10 * nScale;
giABHeight = 2 * nScale;

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

ScaleColors(r, g, b, a );

// Does this weapon have a clip?
y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight/2;
y += (int)(gHUD.m_iFontHeight * 0.2f);

if (hud_weapon->value != 0.0f)
{
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/ammohistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,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) - 4;
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
SPR_Set( *spr, r, g, b );
Expand Down
7 changes: 5 additions & 2 deletions cl_dll/battery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,9 @@ 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;
int width = (m_prc1->right - m_prc1->left);
// this used to just be ScreenWidth/5 but that caused real issues at higher resolutions. Instead, base it on the width of this sprite.
x = 3 * width;

// make sure we have the right sprite handles
if ( !m_hSprite1 )
Expand All @@ -151,7 +153,8 @@ int CHudBattery::Draw(float flTime)
SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
}

x += (m_prc1->right - m_prc1->left);
x += width;
y += (int)(gHUD.m_iFontHeight * 0.2f);
x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);

return 1;
Expand Down
16 changes: 11 additions & 5 deletions cl_dll/death.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,12 @@ int CHudDeathNotice :: VidInit( void )

int CHudDeathNotice :: Draw( float flTime )
{
int x, y, r, g, b;
int x, y, r, g, b, texty;

int gap = 20;

rect_s sprite = gHUD.GetSpriteRect(m_HUD_d_skull);
gap = sprite.bottom - sprite.top;

for ( int i = 0; i < MAX_DEATHNOTICES; i++ )
{
Expand All @@ -118,10 +123,11 @@ int CHudDeathNotice :: Draw( float flTime )
if ( gViewPort && gViewPort->AllowedToPrintText() )
{
// Draw the death notice
y = DEATHNOTICE_TOP + 2 + (20 * i); //!!!
y = DEATHNOTICE_TOP + 2 + (gap * i); //!!!
texty = y + 4;

int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId;
x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left);
x = ScreenWidth - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left) - 4;

if ( !rgDeathNoticeList[i].iSuicide )
{
Expand All @@ -131,7 +137,7 @@ int CHudDeathNotice :: Draw( float flTime )
if ( rgDeathNoticeList[i].KillerColor )
x = 5 + gHUD.DrawConsoleStringWithColorTags(
x,
y,
texty,
rgDeathNoticeList[i].szKiller,
true,
rgDeathNoticeList[i].KillerColor[0],
Expand Down Expand Up @@ -168,7 +174,7 @@ int CHudDeathNotice :: Draw( float flTime )
rgDeathNoticeList[i].VictimColor[2]
);
else
x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
x = DrawConsoleString( x, texty, rgDeathNoticeList[i].szVictim );
}
}
}
Expand Down
43 changes: 30 additions & 13 deletions cl_dll/ev_hldm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v
{
// hit the world, try to play sound based on texture material type
char chTextureType = CHAR_TEX_CONCRETE;
cl_entity_t* cl_entity = NULL;
float fvol;
float fvolbar;
const char *rgsz[4];
Expand All @@ -116,12 +117,7 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v
chTextureType = 0;

// Player
if ( entity >= 1 && entity <= gEngfuncs.GetMaxClients() )
{
// hit body
chTextureType = CHAR_TEX_FLESH;
}
else if ( entity == 0 )
if (entity == 0)
{
// get texture from entity or world (world is ent(0))
pTextureName = (char *)gEngfuncs.pEventAPI->EV_TraceTexture( ptr->ent, vecSrc, vecEnd );
Expand Down Expand Up @@ -150,6 +146,19 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v
chTextureType = PM_FindTextureType( szbuffer );
}
}
else
{
// JoshA: Look up the entity and find the EFLAG_FLESH_SOUND flag.
// This broke at some point then TF:C added prediction.
//
// It used to use Classify of pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE
// to determine what sound to play, but that's server side and isn't available on the client
// and got lost in the translation to that.
// Now the server will replicate that state via an eflag.
cl_entity = gEngfuncs.GetEntityByIndex(entity);
if (cl_entity && !!(cl_entity->curstate.eflags & EFLAG_FLESH_SOUND))
chTextureType = CHAR_TEX_FLESH;
}

switch (chTextureType)
{
Expand Down Expand Up @@ -401,8 +410,16 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );

gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr );

// JoshA: Changed from PM_NORMAL to PM_NORMAL in prediction code as otherwise if you hit an NPC or player's
// bounding box but not one of their hitboxes, the shot won't hit on the server but it will
// play a hit sound on the client and not make a decal (as if it hit the NPC/player).
// We should mirror the way the server does the test here as close as possible.
//
// I initially thought I was just fixing some stupid Half-Life bug but no,
// this is *the* root cause of all the ghost shot bad prediction bugs in Half-Life Deathmatch!
//
// Also... CStrike was always using PM_NORMAL for all of these so it didn't have the problem.
gEngfuncs.pEventAPI->EV_PlayerTrace(vecSrc, vecEnd, PM_NORMAL, -1, &tr);
tracer = EV_HLDM_CheckTracer( idx, vecSrc, tr.endpos, forward, right, iBulletType, iTracerFreq, tracerCount );

// do damage, paint decals
Expand Down Expand Up @@ -913,7 +930,7 @@ void EV_FireGauss( event_args_t *args )
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );

gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecDest, PM_STUDIO_BOX, -1, &tr );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecDest, PM_NORMAL, -1, &tr );

gEngfuncs.pEventAPI->EV_PopPMStates();

Expand Down Expand Up @@ -1035,7 +1052,7 @@ void EV_FireGauss( event_args_t *args )
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );

gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( start, vecDest, PM_STUDIO_BOX, -1, &beam_tr );
gEngfuncs.pEventAPI->EV_PlayerTrace( start, vecDest, PM_NORMAL, -1, &beam_tr );

if ( !beam_tr.allsolid )
{
Expand All @@ -1044,7 +1061,7 @@ void EV_FireGauss( event_args_t *args )

// trace backwards to find exit point

gEngfuncs.pEventAPI->EV_PlayerTrace( beam_tr.endpos, tr.endpos, PM_STUDIO_BOX, -1, &beam_tr );
gEngfuncs.pEventAPI->EV_PlayerTrace( beam_tr.endpos, tr.endpos, PM_NORMAL, -1, &beam_tr );

VectorSubtract( beam_tr.endpos, tr.endpos, delta );

Expand Down Expand Up @@ -1240,7 +1257,7 @@ void EV_FireCrossbow2( event_args_t *args )
// Now add in all of the players.
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );
gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_NORMAL, -1, &tr );

//We hit something
if ( tr.fraction < 1.0 )
Expand Down Expand Up @@ -1445,7 +1462,7 @@ void EV_EgonFire( event_args_t *args )
gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 );

gEngfuncs.pEventAPI->EV_SetTraceHull( 2 );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_STUDIO_BOX, -1, &tr );
gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecEnd, PM_NORMAL, -1, &tr );

gEngfuncs.pEventAPI->EV_PopPMStates();

Expand Down
10 changes: 7 additions & 3 deletions cl_dll/geiger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,18 @@ int CHudGeiger::MsgFunc_Geiger(const char *pszName, int iSize, void *pbuf)
int CHudGeiger::Draw (float flTime)
{
int pct;
float flvol;
float flvol = 0;
int rg[3];
int i;

if (m_iGeigerRange <= 800 && m_iGeigerRange > 0)
if (m_iGeigerRange <= 1000 && m_iGeigerRange > 0)
{
// peicewise linear is better than continuous formula for this
if (m_iGeigerRange > 600)
if (m_iGeigerRange > 800)
{
pct = 0; // Con_Printf ( "range > 800\n );
}
else if (m_iGeigerRange > 600)
{
pct = 2;
flvol = 0.4; //Con_Printf ( "range > 600\n");
Expand Down
17 changes: 9 additions & 8 deletions cl_dll/health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ int CHudHealth::Draw(float flTime)

y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
x = CrossWidth /2;
y += (int)(gHUD.m_iFontHeight * 0.2f);

SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));
Expand Down Expand Up @@ -309,57 +310,57 @@ int CHudHealth::DrawPain(float flTime)
if (m_fAttackFront > 0.4)
{
GetPainColor(r,g,b);
shade = a * max( m_fAttackFront, 0.5 );
shade = a * max( m_fAttackFront, 0.5f );
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 = max( 0.0f, 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 * max( m_fAttackRight, 0.5f );
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 = max( 0.0f, 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 * max( m_fAttackRear, 0.5f );
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 = max( 0.0f, 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 * max( m_fAttackLeft, 0.5f );
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 = max( 0.0f, m_fAttackLeft - fFade );
} else
m_fAttackLeft = 0;

Expand Down
2 changes: 2 additions & 0 deletions cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,8 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
player.m_afButtonPressed = buttonsChanged & cmd->buttons;
// The ones not down are "released"
player.m_afButtonReleased = buttonsChanged & (~cmd->buttons);
player.pev->v_angle = cmd->viewangles;
player.pev->origin = from->client.origin;

// Set player variables that weapons code might check/alter
player.pev->button = cmd->buttons;
Expand Down
10 changes: 7 additions & 3 deletions cl_dll/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -653,10 +653,14 @@ void CHud :: VidInit( void )
m_hsprLogo = 0;
m_hsprCursor = 0;

if (ScreenWidth < 640)
m_iRes = 320;
else
if (ScreenWidth > 2560 && ScreenHeight > 1600)
m_iRes = 2560;
else if (ScreenWidth >= 1280 && ScreenHeight > 720)
m_iRes = 1280;
else if (ScreenWidth >= 640)
m_iRes = 640;
else
m_iRes = 320;

// Only load this once
if ( !m_pSpriteList )
Expand Down
15 changes: 10 additions & 5 deletions cl_dll/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,20 @@ void VectorMA (const float *veca, float scale, const float *vecb, float *vecc)

HSPRITE LoadSprite(const char *pszName)
{
int i;
int iRes;
char sz[256];

if (ScreenWidth < 640)
i = 320;
if (ScreenWidth > 2560 && ScreenHeight > 1600)
iRes = 2560;
else if (ScreenWidth >= 1280 && ScreenHeight > 720)
iRes = 1280;
else if (ScreenWidth >= 640)
iRes = 640;
else
i = 640;
iRes = 320;

sprintf(sz, pszName, i);

sprintf(sz, pszName, iRes);

return SPR_Load(sz);
}
Expand Down
Loading
Loading