Skip to content

Commit

Permalink
Some fixes for FoV, HUD, egon flare and new compilers. (#52)
Browse files Browse the repository at this point in the history
* Fix warnings.

* Merge some fixes from https://github.com/Fograin/hl-subs-mod.
  • Loading branch information
nekonomicon authored and a1batross committed Mar 31, 2018
1 parent 3401f54 commit 9d7ab6a
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 12 deletions.
41 changes: 40 additions & 1 deletion cl_dll/ev_hldm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,17 @@ enum EGON_FIREMODE

BEAM *pBeam;
BEAM *pBeam2;
TEMPENTITY *pFlare; // Vit_amiN: egon's beam flare

void EV_EgonFlareCallback( struct tempent_s *ent, float frametime, float currenttime )
{
float delta = currenttime - ent->tentOffset.z; // time past since the last scale
if( delta >= ent->tentOffset.y )
{
ent->entity.curstate.scale += ent->tentOffset.x * delta;
ent->tentOffset.z = currenttime;
}
}

void EV_EgonFire( event_args_t *args )
{
Expand Down Expand Up @@ -1451,7 +1462,7 @@ void EV_EgonFire( event_args_t *args )
if( EV_IsLocal( idx ) )
gEngfuncs.pEventAPI->EV_WeaponAnimation( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 );

if( iStartup == 1 && EV_IsLocal( idx ) && !pBeam && !pBeam2 && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction.
if( iStartup == 1 && EV_IsLocal( idx ) && !( pBeam || pBeam2 || pFlare ) && cl_lw->value ) //Adrian: Added the cl_lw check for those lital people that hate weapon prediction.
{
vec3_t vecSrc, vecEnd, angles, forward, right, up;
pmtrace_t tr;
Expand Down Expand Up @@ -1499,8 +1510,16 @@ void EV_EgonFire( event_args_t *args )
pBeam->flags |= ( FBEAM_SINENOISE );

pBeam2 = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 5.0, 0.08, 0.7, 25, 0, 0, r, g, b );

// Vit_amiN: egon beam flare
pFlare = gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, gEngfuncs.pEventAPI->EV_FindModelIndex( EGON_FLARE_SPRITE ), kRenderGlow, kRenderFxNoDissipation, 1.0, 99999, FTENT_SPRCYCLE | FTENT_PERSIST );
}
}

if( pFlare ) // Vit_amiN: store the last mode for EV_EgonStop()
{
pFlare->tentOffset.x = ( iFireMode == FIRE_WIDE ) ? 1.0f : 0.0f;
}
}

void EV_EgonStop( event_args_t *args )
Expand Down Expand Up @@ -1529,6 +1548,26 @@ void EV_EgonStop( event_args_t *args )
pBeam2->die = 0.0;
pBeam2 = NULL;
}

if( pFlare ) // Vit_amiN: egon beam flare
{
pFlare->die = gEngfuncs.GetClientTime();

if( gEngfuncs.GetMaxClients() == 1 || !(pFlare->flags & FTENT_NOMODEL) )
{
if( pFlare->tentOffset.x != 0.0f ) // true for iFireMode == FIRE_WIDE
{
pFlare->callback = &EV_EgonFlareCallback;
pFlare->fadeSpeed = 2.0; // fade out will take 0.5 sec
pFlare->tentOffset.x = 10.0; // scaling speed per second
pFlare->tentOffset.y = 0.1; // min time between two scales
pFlare->tentOffset.z = pFlare->die; // the last callback run time
pFlare->flags = FTENT_FADEOUT | FTENT_CLIENTCUSTOM;
}
}

pFlare = NULL;
}
}
}
//======================
Expand Down
3 changes: 2 additions & 1 deletion cl_dll/health.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,8 @@ int CHudHealth::Draw( float flTime )

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

DrawDamage( flTime );
Expand Down
25 changes: 24 additions & 1 deletion cl_dll/hl/hl_objects.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

extern BEAM *pBeam;
extern BEAM *pBeam2;
extern TEMPENTITY *pFlare; // Vit_amiN: egon's energy flare
void HUD_GetLastOrg( float *org );

void UpdateBeams( void )
Expand Down Expand Up @@ -75,6 +76,28 @@ void UpdateBeams( void )
pBeam2->target = tr.endpos;
pBeam2->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.
}

if( pFlare ) // Vit_amiN: beam flare
{
pFlare->entity.origin = tr.endpos;
pFlare->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case.

if( gEngfuncs.GetMaxClients() != 1 ) // Singleplayer always draws the egon's energy beam flare
{
pFlare->flags |= FTENT_NOMODEL;

if( !( tr.allsolid || tr.ent <= 0 || tr.fraction == 1.0 ) ) // Beam hit some non-world entity
{
physent_t *pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent );

// Not the world, let's assume that we hit something organic ( dog, cat, uncle joe, etc )
if( pEntity && !( pEntity->solid == SOLID_BSP || pEntity->movetype == MOVETYPE_PUSHSTEP ) )
{
pFlare->flags &= ~FTENT_NOMODEL;
}
}
}
}
}

/*
Expand All @@ -86,6 +109,6 @@ Add game specific, client-side objects here
*/
void Game_AddObjects( void )
{
if( pBeam && pBeam2 )
if( pBeam || pBeam2 || pFlare ) // Vit_amiN: egon flare added
UpdateBeams();
}
2 changes: 2 additions & 0 deletions cl_dll/hl/hl_weapons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@

extern globalvars_t *gpGlobals;
extern int g_iUser1;
extern bool g_hasPredictedFOV; // Vit_amiN: from HUD

// Pool of client side entities/entvars_t
static entvars_t ev[32];
Expand Down Expand Up @@ -881,6 +882,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm
to->client.fuser2 = player.m_flNextAmmoBurn;
to->client.fuser3 = player.m_flAmmoStartCharge;
to->client.maxspeed = player.pev->maxspeed;
g_hasPredictedFOV = true; // Vit_amiN: ready

//HL Weapons
to->client.vuser1[0] = player.ammo_9mm;
Expand Down
3 changes: 2 additions & 1 deletion cl_dll/hud.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf )
}

float g_lastFOV = 0.0;
bool g_hasPredictedFOV = false; // Vit_amiN: it'll became true after the first prediction

/*
============
Expand Down Expand Up @@ -514,7 +515,7 @@ int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf )
int def_fov = CVAR_GET_FLOAT( "default_fov" );

//Weapon prediction already takes care of changing the fog. ( g_lastFOV ).
if( cl_lw && cl_lw->value )
if( g_hasPredictedFOV )
return 1;

g_lastFOV = newfov;
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/hud.h
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ class CHudScoreboard : public CHudBase
void InitHUDData( void );
int VidInit( void );
int Draw( float flTime );
int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, char *team = NULL ); // returns the ypos where it finishes drawing
int DrawPlayers( int xoffset, float listslot, int nameoffset = 0, const char *team = NULL ); // returns the ypos where it finishes drawing
void UserCmd_ShowScores( void );
void UserCmd_HideScores( void );
int MsgFunc_ScoreInfo( const char *pszName, int iSize, void *pbuf );
Expand Down
16 changes: 15 additions & 1 deletion cl_dll/hud_msg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@

extern BEAM *pBeam;
extern BEAM *pBeam2;
extern TEMPENTITY *pFlare; // Vit_amiN

extern float g_lastFOV; // Vit_amiN
extern bool g_hasPredictedFOV; // Vit_amiN

/// USER-DEFINED SERVER MESSAGE HANDLERS

Expand All @@ -48,6 +52,11 @@ int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf )
// reset concussion effect
m_iConcussionEffect = 0;

// Vit_amiN: reset the FOV
m_iFOV = 0; // default_fov
g_lastFOV = 0.0f;
g_hasPredictedFOV = false;

return 1;
}

Expand All @@ -72,6 +81,7 @@ void CHud::MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf )

//Probably not a good place to put this.
pBeam = pBeam2 = NULL;
pFlare = NULL; // Vit_amiN: clear egon's beam flare
}

int CHud::MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf )
Expand Down Expand Up @@ -107,10 +117,14 @@ int CHud::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf )

int CHud::MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf )
{
int r, g, b;
BEGIN_READ( pbuf, iSize );
m_iConcussionEffect = READ_BYTE();
if( m_iConcussionEffect )
this->m_StatusIcons.EnableIcon( "dmg_concuss", 255, 160, 0 );
{
UnpackRGB( r, g, b, RGB_YELLOWISH ); // Vit_amiN: fixed
this->m_StatusIcons.EnableIcon( "dmg_concuss", r, g, b );
}
else
this->m_StatusIcons.DisableIcon( "dmg_concuss" );
return 1;
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/input_goldsource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1368,7 +1368,7 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd )
// y=ax^b; where a = 300 and b = 1.3
// also x values are in increments of 800 (so this is factored out)
// then bounds check result to level out excessively high spin rates
fTemp = 300.0 * pow(abs(fAxisValue) / 800.0, 1.3);
fTemp = 300.0 * pow(fabs(fAxisValue) / 800.0, 1.3);
if (fTemp > 14000.0)
fTemp = 14000.0;
// restore direction information
Expand Down
2 changes: 1 addition & 1 deletion cl_dll/scoreboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ int CHudScoreboard::Draw( float fTime )
extern float *GetClientColor( int client );

// returns the ypos where it finishes drawing
int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, char *team )
int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, const char *team )
{
int can_show_packetloss = 0;
int FAR_RIGHT;
Expand Down
3 changes: 2 additions & 1 deletion dlls/monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,8 @@ void CBaseMonster::StartMonster( void )
SetThink( &CBaseMonster::CallMonsterThink );
pev->nextthink += RANDOM_FLOAT( 0.1, 0.4 ); // spread think times.

if( !FStringNull( pev->targetname ) )// wait until triggered
// Vit_amiN: fixed -- now it doesn't touch any scripted_sequence target
if( !FStringNull( pev->targetname ) && !m_pCine )// wait until triggered
{
SetState( MONSTERSTATE_IDLE );
// UNDONE: Some scripted sequence monsters don't have an idle?
Expand Down
18 changes: 15 additions & 3 deletions dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1860,6 +1860,7 @@ void CBasePlayer::PreThink( void )
{
CBaseEntity *pTrain = CBaseEntity::Instance( pev->groundentity );
float vel;
int iGearId; // Vit_amiN: keeps the train control HUD in sync

if( !pTrain )
{
Expand Down Expand Up @@ -1900,10 +1901,12 @@ void CBasePlayer::PreThink( void )
pTrain->Use( this, this, USE_SET, (float)vel );
}

if( vel )
iGearId = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse );

if( iGearId != ( m_iTrain & 0x0F ) ) // Vit_amiN: speed changed
{
m_iTrain = TrainSpeed( (int)pTrain->pev->speed, pTrain->pev->impulse );
m_iTrain |= TRAIN_ACTIVE|TRAIN_NEW;
m_iTrain = iGearId;
m_iTrain |= TRAIN_ACTIVE | TRAIN_NEW;
}
}
else if( m_iTrain & TRAIN_ACTIVE )
Expand Down Expand Up @@ -2919,6 +2922,8 @@ void CBasePlayer::Precache( void )

if( gInitHUD )
m_fInitHUD = TRUE;

pev->fov = m_iFOV; // Vit_amiN: restore the FOV on level change or map/saved game load
}

int CBasePlayer::Save( CSave &save )
Expand Down Expand Up @@ -3326,6 +3331,8 @@ void CBasePlayer::ForceClientDllUpdate( void )
{
m_iClientHealth = -1;
m_iClientBattery = -1;
m_iClientHideHUD = -1; // Vit_amiN: forcing to update
m_iClientFOV = -1; // Vit_amiN: force client weapons to be sent
m_iTrain |= TRAIN_NEW; // Force new train message.
m_fWeapon = FALSE; // Force weapon send
m_fKnownItem = FALSE; // Force weaponinit messages.
Expand Down Expand Up @@ -3890,6 +3897,11 @@ void CBasePlayer::UpdateClientData( void )
WRITE_BYTE( m_iFlashBattery );
MESSAGE_END();

// Vit_amiN: the geiger state could run out of sync, too
MESSAGE_BEGIN( MSG_ONE, gmsgGeigerRange, NULL, pev );
WRITE_BYTE( 0 );
MESSAGE_END();

InitStatusBar();
}

Expand Down

0 comments on commit 9d7ab6a

Please sign in to comment.