From 64b49baad86610e226ceb6b07c9b7514ab2a2641 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 18 Jan 2017 01:56:07 +0500 Subject: [PATCH] Fix build. --- cl_dll/hl/hl_baseentity.cpp | 1 + dlls/gearbox/ctf_gamerules.cpp | 15 +++++++------- dlls/gearbox/ctf_gamerules.h | 16 ++++++--------- dlls/gearbox/ctf_items.cpp | 7 ------- dlls/gearbox/ctf_items.h | 7 ------- dlls/gearbox/ctf_powerups.cpp | 17 +++++----------- dlls/gearbox/ctf_powerups.h | 6 ------ dlls/gearbox/gearbox_player.h | 6 +----- dlls/gearbox/geneworm.cpp | 4 ++-- dlls/gearbox/ropes.cpp | 5 +++-- dlls/weapons.cpp | 37 ++++++++++++++++++++++++++++++++++ dlls/weapons.h | 5 +++++ 12 files changed, 68 insertions(+), 58 deletions(-) diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index 9a47110f..fc306838 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -314,6 +314,7 @@ int CBasePlayerItem::Restore( class CRestore & ) { return 1; } int CBasePlayerItem::Save( class CSave & ) { return 1; } int CBasePlayerWeapon::Restore( class CRestore & ) { return 1; } int CBasePlayerWeapon::Save( class CSave & ) { return 1; } +float CBasePlayerWeapon::GetNextAttackDelay( float flTime ) { return flTime; } void CBasePlayerItem::SetObjectCollisionBox( void ) { } void CBasePlayerItem::FallInit( void ) { } void CBasePlayerItem::FallThink( void ) { } diff --git a/dlls/gearbox/ctf_gamerules.cpp b/dlls/gearbox/ctf_gamerules.cpp index 3cc4d2bd..0f13be53 100644 --- a/dlls/gearbox/ctf_gamerules.cpp +++ b/dlls/gearbox/ctf_gamerules.cpp @@ -20,8 +20,6 @@ This contains all the gamerules for the Half-Life: Opposing force CTF Gamemode. */ -#ifdef GEARBOX_CTF - #define NUM_TEAMS 2 char *sTeamNames[] = @@ -76,6 +74,7 @@ edict_t *EntSelectSpawnPoint(CBaseEntity *pPlayer, bool bCheckDM) #endif extern edict_t *RuneSelectSpawnPoint(void); +#ifndef NO_VOICEGAMEMGR class CCTFGameMgrHelper : public IVoiceGameMgrHelper { public: @@ -85,6 +84,7 @@ public: } }; static CCTFGameMgrHelper g_GameMgrHelper; +#endif extern DLL_GLOBAL BOOL g_fGameOver; @@ -98,9 +98,10 @@ char* GetTeamName(int team) CCTFMultiplay::CCTFMultiplay() { +#ifndef NO_VOICEGAMEMGR // CHalfLifeMultiplay already initialized it - just override its helper callback. m_VoiceGameMgr.SetHelper(&g_GameMgrHelper); - +#endif m_DisableDeathMessages = FALSE; m_DisableDeathPenalty = FALSE; @@ -149,8 +150,9 @@ extern cvar_t timeleft, fragsleft; void CCTFMultiplay::Think(void) { +#ifndef NO_VOICEGAMEMGR m_VoiceGameMgr.Update(gpGlobals->frametime); - +#endif ///// Check game rules ///// static int last_frags; static int last_time; @@ -310,9 +312,10 @@ void DropRune(CBasePlayer *pPlayer); //========================================================= BOOL CCTFMultiplay::ClientCommand(CBasePlayer *pPlayer, const char *pcmd) { +#ifndef NO_VOICEGAMEMGR if (m_VoiceGameMgr.ClientCommand(pPlayer, pcmd)) return TRUE; - +#endif if (FStrEq(pcmd, "menuselect")) { if (CMD_ARGC() < 2) @@ -1686,5 +1689,3 @@ void CCTFMultiplay::RecountTeams(void) } } } - -#endif // GEARBOX_CTF diff --git a/dlls/gearbox/ctf_gamerules.h b/dlls/gearbox/ctf_gamerules.h index 0a02d996..72db91cd 100644 --- a/dlls/gearbox/ctf_gamerules.h +++ b/dlls/gearbox/ctf_gamerules.h @@ -3,12 +3,11 @@ #ifndef CTF_GAMERULES_H #define CTF_GAMERULES_H -#if defined ( GEARBOX_CTF ) - #define BLUE 2 #define RED 1 - +#ifndef NO_VOICEGAMEMGR #include "voice_gamemgr.h" +#endif // Standard Scoring #define TEAM_CAPTURE_CAPTURE_BONUS 5 // what you get for capture @@ -75,7 +74,7 @@ #define PLAYER_MAX_HEALTH_VALUE 100 #define PLAYER_MAX_ARMOR_VALUE 100 -class CCTFMultiplay : public CGearboxMultiplay +class CCTFMultiplay : public CHalfLifeMultiplay { public: CCTFMultiplay(); @@ -118,9 +117,9 @@ public: int iRedTeamScore; float m_flFlagStatusTime; - +#ifndef NO_VOICEGAMEMGR CVoiceGameMgr m_VoiceGameMgr; - +#endif private: void RecountTeams(void); @@ -129,7 +128,4 @@ private: BOOL m_teamLimit; // This means the server set only some teams as valid char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH]; }; - -#endif // GEARBOX_CTF - -#endif // CTF_GAMERULES_H \ No newline at end of file +#endif // CTF_GAMERULES_H diff --git a/dlls/gearbox/ctf_items.cpp b/dlls/gearbox/ctf_items.cpp index 8b15900d..bc457a7a 100644 --- a/dlls/gearbox/ctf_items.cpp +++ b/dlls/gearbox/ctf_items.cpp @@ -20,10 +20,6 @@ This contains the Flag entity information for the Half-Life : Opposing force CTF */ - - -#if defined ( GEARBOX_CTF ) - #include "extdll.h" #include "util.h" #include "cbase.h" @@ -723,6 +719,3 @@ void CCarriedFlagTeam2::Spawn(void) LINK_ENTITY_TO_CLASS(carried_flag_team1, CCarriedFlagTeam1); LINK_ENTITY_TO_CLASS(carried_flag_team2, CCarriedFlagTeam2); - - -#endif // GEARBOX_CTF \ No newline at end of file diff --git a/dlls/gearbox/ctf_items.h b/dlls/gearbox/ctf_items.h index 50eeb85d..92de9a22 100644 --- a/dlls/gearbox/ctf_items.h +++ b/dlls/gearbox/ctf_items.h @@ -12,9 +12,6 @@ * without written permission from Valve LLC. * ****/ - -#if defined ( GEARBOX_CTF ) - #ifndef CTF_ITEMS_H #define CTF_ITEMS_H @@ -124,8 +121,4 @@ class CCarriedFlagTeam2 : public CCarriedFlag { void Spawn(void); }; - - #endif // CTF_ITEMS_H - -#endif // GEARBOX_CTF \ No newline at end of file diff --git a/dlls/gearbox/ctf_powerups.cpp b/dlls/gearbox/ctf_powerups.cpp index 9952993b..58329345 100644 --- a/dlls/gearbox/ctf_powerups.cpp +++ b/dlls/gearbox/ctf_powerups.cpp @@ -19,11 +19,6 @@ This contains the Flag entity information for the Half-Life : Opposing force CTF Gamemode. */ - - -#ifdef GEARBOX_CTF - - #include "extdll.h" #include "util.h" #include "cbase.h" @@ -231,18 +226,18 @@ void CPowerupCTFBase::RuneTouch(CBaseEntity *pOther) if (pOther->pev->team != m_teamNo - 1) return; } - +/* //Only one per customer if (pPlayer->m_iRuneStatus) { ClientPrint(pOther->pev, HUD_PRINTCENTER, "You already have a rune!\n"); return; } - +*/ if (!m_bTouchable) return; - pPlayer->m_iRuneStatus = m_iRuneFlag; //Add me the rune flag + //pPlayer->m_iRuneStatus = m_iRuneFlag; //Add me the rune flag ClientPrint(pOther->pev, HUD_PRINTCENTER, "You got the rune of %s!\n", STRING(m_iszPrintName)); @@ -260,10 +255,10 @@ void CPowerupCTFBase::RuneTouch(CBaseEntity *pOther) EMIT_SOUND(ENT(pev), CHAN_ITEM, "weapons/ammopickup2.wav", 1, ATTN_NORM); //Update my client side rune hud thingy. - MESSAGE_BEGIN(MSG_ONE, gmsgRuneStatus, NULL, pOther->pev); +/* MESSAGE_BEGIN(MSG_ONE, gmsgRuneStatus, NULL, pOther->pev); WRITE_BYTE(pPlayer->m_iRuneStatus); MESSAGE_END(); - +*/ //And Remove this entity UTIL_Remove(this); } @@ -478,5 +473,3 @@ void SpawnRunes(void) g_bSpawnedRunes = TRUE; } - -#endif // GEARBOX_CTF \ No newline at end of file diff --git a/dlls/gearbox/ctf_powerups.h b/dlls/gearbox/ctf_powerups.h index 80d1e809..068ed12c 100644 --- a/dlls/gearbox/ctf_powerups.h +++ b/dlls/gearbox/ctf_powerups.h @@ -12,9 +12,6 @@ * without written permission from Valve LLC. * ****/ - -#if defined ( GEARBOX_CTF ) - #ifndef CTF_POWERUPS_H #define CTF_POWERUPS_H @@ -121,7 +118,4 @@ public: m_iszPrintName = MAKE_STRING("Portable HEV"); } }; - #endif // CTF_POWERUPS_H - -#endif // GEARBOX_CTF \ No newline at end of file diff --git a/dlls/gearbox/gearbox_player.h b/dlls/gearbox/gearbox_player.h index 1252c982..512488c5 100644 --- a/dlls/gearbox/gearbox_player.h +++ b/dlls/gearbox/gearbox_player.h @@ -15,12 +15,10 @@ #ifndef GEARBOX_PLAYER_H #define GEARBOX_PLAYER_H -#ifdef GEARBOX_CTF enum Player_Menu { Team_Menu, Team_Menu_IG, }; -#endif #define PFLAG_ONROPE ( 1 << 6 ) @@ -42,7 +40,6 @@ private: BOOL m_fInXen; BOOL m_fIsFrozen; -#if defined ( GEARBOX_CTF ) public: int m_bHasFlag; void ShowMenu(int bitsValidSlots, int nDisplayTime, BOOL fNeedMore, char *pszText); @@ -73,11 +70,10 @@ public: void Service_Grapple(void); private: -#endif friend class CDisplacer; friend class CTriggerXenReturn; friend class CPlayerFreeze; }; -#endif // GEARBOX_PLAYER_H \ No newline at end of file +#endif // GEARBOX_PLAYER_H diff --git a/dlls/gearbox/geneworm.cpp b/dlls/gearbox/geneworm.cpp index 47660768..29c4cf6a 100644 --- a/dlls/gearbox/geneworm.cpp +++ b/dlls/gearbox/geneworm.cpp @@ -216,7 +216,7 @@ const char *CGeneWorm::pEyePainSounds[] = "geneworm/geneworm_shot_in_eye.wav", }; -const char* CGeneWorm::pHitVolumes[] +const char* CGeneWorm::pHitVolumes[] = { "GeneWormRightSlash", "GeneWormCenterSlash", @@ -629,4 +629,4 @@ float CGeneWorm::MyEnemyHeight(void) } return GENEWORM_LEVEL1_HEIGHT; -} \ No newline at end of file +} diff --git a/dlls/gearbox/ropes.cpp b/dlls/gearbox/ropes.cpp index 6e569297..37467e8e 100644 --- a/dlls/gearbox/ropes.cpp +++ b/dlls/gearbox/ropes.cpp @@ -244,7 +244,8 @@ void CRope::RopeThink(void) ApplyFunctor(Functor_SetSegmentFxNormal); - int index = FindClosestSegment(((CBasePlayer*)pEntity)->GetGunPosition(), 16, 0, m_nSegments - 1); + Vector v = ((CBasePlayer*)pEntity)->GetGunPosition(); + int index = FindClosestSegment(v, 16, 0, m_nSegments - 1); if (index >= 0 && index < m_nSegments) { CRopeSegment* pClosestSegment = m_pSegments[index]; @@ -341,4 +342,4 @@ void CRope::ApplyFunctor(void(*functor)(CRopeSegment* pSegment), int startIndex, void CRope::ApplyFunctor(void(*functor)(CRopeSegment* pSegment)) { ApplyFunctor(functor, 0, -1); -} \ No newline at end of file +} diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 8ab6d8e4..41b12407 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -655,6 +655,11 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fInReload = FALSE; } + if( !( m_pPlayer->pev->button & IN_ATTACK ) ) + { + m_flLastFireTime = 0.0f; + } + if( ( m_pPlayer->pev->button & IN_ATTACK2 ) && CanAttack( m_flNextSecondaryAttack, gpGlobals->time, UseDecrement() ) ) { if( pszAmmo2() && !m_pPlayer->m_rgAmmo[SecondaryAmmoIndex()] ) @@ -986,6 +991,7 @@ BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, i m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flLastFireTime = 0.0f; return TRUE; } @@ -1173,6 +1179,37 @@ void CBasePlayerWeapon::RetireWeapon( void ) g_pGameRules->GetNextBestWeapon( m_pPlayer, this ); } +//========================================================================= +// GetNextAttackDelay - An accurate way of calcualting the next attack time. +//========================================================================= +float CBasePlayerWeapon::GetNextAttackDelay( float delay ) +{ + if( m_flLastFireTime == 0 || m_flNextPrimaryAttack == -1 ) + { + // At this point, we are assuming that the client has stopped firing + // and we are going to reset our book keeping variables. + m_flLastFireTime = gpGlobals->time; + m_flPrevPrimaryAttack = delay; + } + + // calculate the time between this shot and the previous + float flTimeBetweenFires = gpGlobals->time - m_flLastFireTime; + float flCreep = 0.0f; + if( flTimeBetweenFires > 0 ) + flCreep = flTimeBetweenFires - m_flPrevPrimaryAttack; // postive or negative + + // save the last fire time + m_flLastFireTime = gpGlobals->time; + + float flNextAttack = UTIL_WeaponTimeBase() + delay - flCreep; + // we need to remember what the m_flNextPrimaryAttack time is set to for each shot, + // store it as m_flPrevPrimaryAttack. + m_flPrevPrimaryAttack = flNextAttack - UTIL_WeaponTimeBase(); + //char szMsg[256]; + //_snprintf( szMsg, sizeof(szMsg), "next attack time: %0.4f\n", gpGlobals->time + flNextAttack ); + //OutputDebugString( szMsg ); + return flNextAttack; +} //********************************************************* // weaponbox code: //********************************************************* diff --git a/dlls/weapons.h b/dlls/weapons.h index 4d88315d..fc341714 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -376,6 +376,7 @@ public: void PrintState( void ); virtual CBasePlayerItem *GetWeaponPtr( void ) { return (CBasePlayerItem *)this; }; + float GetNextAttackDelay( float delay ); float m_flPumpTime; int m_fInSpecialReload; // Are we in the middle of a reload for the shotguns @@ -390,6 +391,10 @@ public: int m_fInReload; // Are we in the middle of a reload; int m_iDefaultAmmo;// how much ammo you get when you pick up this weapon as placed by a level designer. + + // hle time creep vars + float m_flPrevPrimaryAttack; + float m_flLastFireTime; }; class CBasePlayerAmmo : public CBaseEntity