Browse Source

Some fixes for FoV, HUD, egon flare and new compilers. (#52)

* Fix warnings.

* Merge some fixes from https://github.com/Fograin/hl-subs-mod.
caseclosed
Andrey Akhmichin 7 years ago committed by Alibek Omarov
parent
commit
9d7ab6acf4
  1. 41
      cl_dll/ev_hldm.cpp
  2. 3
      cl_dll/health.cpp
  3. 25
      cl_dll/hl/hl_objects.cpp
  4. 2
      cl_dll/hl/hl_weapons.cpp
  5. 3
      cl_dll/hud.cpp
  6. 2
      cl_dll/hud.h
  7. 16
      cl_dll/hud_msg.cpp
  8. 2
      cl_dll/input_goldsource.cpp
  9. 2
      cl_dll/scoreboard.cpp
  10. 3
      dlls/monsters.cpp
  11. 18
      dlls/player.cpp

41
cl_dll/ev_hldm.cpp

@ -1414,6 +1414,17 @@ enum EGON_FIREMODE @@ -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 )
{
@ -1451,7 +1462,7 @@ void EV_EgonFire( event_args_t *args ) @@ -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;
@ -1499,8 +1510,16 @@ void EV_EgonFire( event_args_t *args ) @@ -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 )
@ -1529,6 +1548,26 @@ void EV_EgonStop( event_args_t *args ) @@ -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;
}
}
}
//======================

3
cl_dll/health.cpp

@ -231,7 +231,8 @@ int CHudHealth::Draw( float flTime ) @@ -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 );

25
cl_dll/hl/hl_objects.cpp

@ -29,6 +29,7 @@ @@ -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 )
@ -75,6 +76,28 @@ void UpdateBeams( void ) @@ -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;
}
}
}
}
}
/*
@ -86,6 +109,6 @@ Add game specific, client-side objects here @@ -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
cl_dll/hl/hl_weapons.cpp

@ -34,6 +34,7 @@ @@ -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];
@ -881,6 +882,7 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm @@ -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;

3
cl_dll/hud.cpp

@ -413,6 +413,7 @@ int CHud::MsgFunc_Logo( const char *pszName, int iSize, void *pbuf ) @@ -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
/*
============
@ -514,7 +515,7 @@ int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ) @@ -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;

2
cl_dll/hud.h

@ -230,7 +230,7 @@ public: @@ -230,7 +230,7 @@ public:
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 );

16
cl_dll/hud_msg.cpp

@ -25,6 +25,10 @@ @@ -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
@ -48,6 +52,11 @@ int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ) @@ -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;
}
@ -72,6 +81,7 @@ void CHud::MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) @@ -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 )
@ -107,10 +117,14 @@ int CHud::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ) @@ -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;

2
cl_dll/input_goldsource.cpp

@ -1368,7 +1368,7 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) @@ -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

2
cl_dll/scoreboard.cpp

@ -337,7 +337,7 @@ int CHudScoreboard::Draw( float fTime ) @@ -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;

3
dlls/monsters.cpp

@ -2118,7 +2118,8 @@ void CBaseMonster::StartMonster( void ) @@ -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?

18
dlls/player.cpp

@ -1860,6 +1860,7 @@ void CBasePlayer::PreThink( void ) @@ -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 )
{
@ -1900,10 +1901,12 @@ void CBasePlayer::PreThink( void ) @@ -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 )
@ -2919,6 +2922,8 @@ void CBasePlayer::Precache( void ) @@ -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 )
@ -3326,6 +3331,8 @@ void CBasePlayer::ForceClientDllUpdate( void ) @@ -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.
@ -3890,6 +3897,11 @@ void CBasePlayer::UpdateClientData( void ) @@ -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();
}

Loading…
Cancel
Save