From 09250f944cb248eb07a3b76904bf67c16eef55ad Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 28 Aug 2016 23:18:20 +0500 Subject: [PATCH 001/199] Merge forgotten change. --- dlls/barnacle.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/barnacle.cpp b/dlls/barnacle.cpp index 2a264bf7..3147e415 100644 --- a/dlls/barnacle.cpp +++ b/dlls/barnacle.cpp @@ -79,6 +79,7 @@ TYPEDESCRIPTION CBarnacle::m_SaveData[] = DEFINE_FIELD( CBarnacle, m_fLiftingPrey, FIELD_BOOLEAN ), DEFINE_FIELD( CBarnacle, m_flTongueAdj, FIELD_FLOAT ), DEFINE_FIELD( CBarnacle, m_flCachedLength, FIELD_FLOAT ), + DEFINE_FIELD( CBarnacle, m_fXenCandySpawned, FIELD_BOOLEAN ), }; IMPLEMENT_SAVERESTORE( CBarnacle, CBaseMonster ) From 3968b25371a71b8b8cebf9809b5c50549f72cc3f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 28 Aug 2016 23:53:38 +0500 Subject: [PATCH 002/199] Fix build. --- cl_dll/health.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index 55ac564c..0ee4309f 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -219,7 +219,7 @@ int CHudHealth::Draw( float flTime ) { HealthWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; - struct rect_s cross = gHUD.GetSpriteRect( m_HUD_cross ); + wrect_t cross = gHUD.GetSpriteRect( m_HUD_cross ); int CrossWidth = cross.right - cross.left; int CrossHeight = cross.bottom - cross.top; From e1483e1fcfa1083e8138f75c1355ff07297ef02d Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 29 Aug 2016 23:33:17 +0500 Subject: [PATCH 003/199] Merge some code from hlsdk2.4. --- dlls/weapons.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index ca91b778..5a592bf2 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -601,6 +601,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()] ) @@ -932,6 +937,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; } From 20af3536cb9762871657c9883810e7d39f4232da Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 23 Sep 2016 18:22:19 +0500 Subject: [PATCH 004/199] Nails damage fix. --- dlls/gamerules.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index 72a70fe3..eed8e07e 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -309,7 +309,7 @@ void CGameRules::RefreshSkillData ( void ) gSkillData.plrArm = GetSkillCvar( "sk_player_arm" ); // Nails - gSkillData.plrDmgNail = GetSkillCvar( "sk_plr_nail" ); + gSkillData.plrDmgNail = GetSkillCvar( "sk_9mmAR_bullet" ); } //========================================================= From 3d07512518eb096ae444ca372b313a4d19a46bdf Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 24 Sep 2016 04:55:24 +0500 Subject: [PATCH 005/199] Remove unneeded macros. --- dlls/poke646/cmlwbr.cpp | 5 ----- dlls/poke646/robocop.cpp | 25 +------------------------ 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/dlls/poke646/cmlwbr.cpp b/dlls/poke646/cmlwbr.cpp index 85e8d9bc..73bb104a 100644 --- a/dlls/poke646/cmlwbr.cpp +++ b/dlls/poke646/cmlwbr.cpp @@ -100,13 +100,8 @@ int CCmlwbr::GetItemInfo(ItemInfo *p) p->pszAmmo2 = NULL; p->iMaxAmmo2 = -1; p->iMaxClip = CMLWBR_MAX_CLIP; -#if !defined ( VENDETTA ) p->iSlot = 2; p->iPosition = 1; -#else - p->iSlot = 3; - p->iPosition = 0; -#endif // !defined ( VENDETTA ) p->iId = WEAPON_CMLWBR; p->iFlags = 0; p->iWeight = CMLWBR_WEIGHT; diff --git a/dlls/poke646/robocop.cpp b/dlls/poke646/robocop.cpp index deb253dc..d73528a4 100644 --- a/dlls/poke646/robocop.cpp +++ b/dlls/poke646/robocop.cpp @@ -467,12 +467,10 @@ void CRoboCop::Spawn() m_pTemp = NULL; -#if defined ( POKE646_DLL ) if (FStrEq(STRING(gpGlobals->mapname), "po_xen01") || FStrEq(STRING(gpGlobals->mapname), "pv_asl02")) { CreateRoboCopNodes( this ); } -#endif // defined ( POKE646_DLL ) MonsterInit(); @@ -552,7 +550,6 @@ BOOL CRoboCop::CheckMeleeAttack1(float flDot, float flDist) //========================================================= BOOL CRoboCop::CheckRangeAttack1(float flDot, float flDist) { -#if !defined ( VENDETTA ) if (m_flNextMortarAttack > gpGlobals->time) return FALSE; @@ -560,7 +557,6 @@ BOOL CRoboCop::CheckRangeAttack1(float flDot, float flDist) { return TRUE; } -#endif // !defined ( VENDETTA ) return FALSE; } @@ -643,13 +639,11 @@ Schedule_t* CRoboCop::GetSchedule() return GetScheduleOfType(SCHED_MELEE_ATTACK1); } -#if !defined ( VENDETTA ) // laser attack. if (HasConditions(bits_COND_CAN_RANGE_ATTACK1)) { return GetScheduleOfType(SCHED_RANGE_ATTACK1); } -#endif // !defined ( VENDETTA ) return GetScheduleOfType(SCHED_CHASE_ENEMY); } @@ -1383,22 +1377,6 @@ void CRoboCop::BeamUpdate(void) void CreateRoboCopNodes(CRoboCop* pOwner) { -#if defined ( VENDETTA ) - BEGIN_RC_SECTOR(0, pOwner) - ADD_RC_NODE(1920, -320, 744); - ADD_RC_NODE(2168, -264, 744); - ADD_RC_NODE(2272, -416, 744); - ADD_RC_NODE(2120, -504, 744); - ADD_RC_NODE(2392, -608, 744); - ADD_RC_NODE(2208, -640, 744); - ADD_RC_NODE(2032, -672, 744); - ADD_RC_NODE(2112, -832, 744); - ADD_RC_NODE(2272, -896, 744); - ADD_RC_NODE(2112, -960, 744); - ADD_RC_NODE(2120, -1080, 744); - ADD_RC_NODE(2120, -1192, 744); - END_RC_SECTOR() -#else BEGIN_RC_SECTOR(0, pOwner) ADD_RC_NODE(-256, 2272, 256); ADD_RC_NODE(-768, 2272, 256); @@ -1435,5 +1413,4 @@ void CreateRoboCopNodes(CRoboCop* pOwner) ADD_RC_NODE(-416, 1120, 256); ADD_RC_NODE(-256, 1184, 256); END_RC_SECTOR() -#endif // defined ( VENDETTA ) -} \ No newline at end of file +} From 2a0b98bc547226d07e48732a4a46657e6cf108e2 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 26 Sep 2016 17:29:10 +0500 Subject: [PATCH 006/199] Use different damage values for bradnailer and nailgun. Remove cvars which was not found in game. --- dlls/combat.cpp | 5 ++--- dlls/game.cpp | 10 ---------- dlls/gamerules.cpp | 3 --- dlls/poke646/bradnailer.cpp | 2 +- dlls/poke646/nail.cpp | 4 ++-- dlls/poke646/nailgun.cpp | 4 ++-- dlls/skill.h | 2 -- dlls/sound.cpp | 2 +- dlls/weapons.cpp | 3 ++- dlls/weapons.h | 3 ++- 10 files changed, 12 insertions(+), 26 deletions(-) diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 8ec628b0..ac1feddf 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -1523,9 +1523,11 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi { default: case BULLET_PLAYER_9MM: + case BULLET_PLAYER_NAIL1: pEntity->TraceAttack( pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_BULLET ); break; case BULLET_PLAYER_MP5: + case BULLET_PLAYER_NAIL2: pEntity->TraceAttack( pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET ); break; case BULLET_PLAYER_BUCKSHOT: @@ -1544,9 +1546,6 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi UTIL_DecalTrace( &tr, DECAL_GLASSBREAK1 + RANDOM_LONG( 0, 2 ) ); } - break; - case BULLET_PLAYER_NAIL: - pEntity->TraceAttack( pevAttacker, 0, vecDir, &tr, DMG_BULLET ); break; } } diff --git a/dlls/game.cpp b/dlls/game.cpp index cf79125a..38c54ddf 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -456,11 +456,6 @@ cvar_t sk_player_leg1 = { "sk_player_leg1","1" }; cvar_t sk_player_leg2 = { "sk_player_leg2","1" }; cvar_t sk_player_leg3 = { "sk_player_leg3","1" }; -// Nails -cvar_t sk_plr_nail1 = { "sk_plr_nail1", "0" }; -cvar_t sk_plr_nail2 = { "sk_plr_nail2", "0" }; -cvar_t sk_plr_nail3 = { "sk_plr_nail3", "0" }; - // END Cvars for Skill Level settings // Register your console variables here @@ -886,11 +881,6 @@ void GameDLLInit( void ) CVAR_REGISTER( &sk_player_leg2 ); CVAR_REGISTER( &sk_player_leg3 ); - // Nails - CVAR_REGISTER( &sk_plr_nail1 ); - CVAR_REGISTER( &sk_plr_nail2 ); - CVAR_REGISTER( &sk_plr_nail3 ); - // END REGISTER CVARS FOR SKILL LEVEL STUFF SERVER_COMMAND( "exec skill.cfg\n" ); diff --git a/dlls/gamerules.cpp b/dlls/gamerules.cpp index eed8e07e..cd42c5ea 100644 --- a/dlls/gamerules.cpp +++ b/dlls/gamerules.cpp @@ -307,9 +307,6 @@ void CGameRules::RefreshSkillData ( void ) gSkillData.plrStomach = GetSkillCvar( "sk_player_stomach" ); gSkillData.plrLeg = GetSkillCvar( "sk_player_leg" ); gSkillData.plrArm = GetSkillCvar( "sk_player_arm" ); - - // Nails - gSkillData.plrDmgNail = GetSkillCvar( "sk_9mmAR_bullet" ); } //========================================================= diff --git a/dlls/poke646/bradnailer.cpp b/dlls/poke646/bradnailer.cpp index 86164231..2c9f887e 100644 --- a/dlls/poke646/bradnailer.cpp +++ b/dlls/poke646/bradnailer.cpp @@ -221,7 +221,7 @@ void CBradnailer::Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL } Vector vecDir; - vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, Vector(flSpread, flSpread, flSpread), 8192, BULLET_PLAYER_NAIL, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed); + vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, Vector(flSpread, flSpread, flSpread), 8192, BULLET_PLAYER_NAIL1, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed); PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usFireBradnailer, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, fFastShoot, 0); diff --git a/dlls/poke646/nail.cpp b/dlls/poke646/nail.cpp index c134bbbd..6ec9f8ce 100644 --- a/dlls/poke646/nail.cpp +++ b/dlls/poke646/nail.cpp @@ -83,7 +83,7 @@ void CNail::NailTouch(CBaseEntity *pOther) // UNDONE: this needs to call TraceAttack instead ClearMultiDamage(); - pOther->TraceAttack(pevOwner, gSkillData.plrDmgNail, pev->velocity.Normalize(), &tr, DMG_NEVERGIB); + pOther->TraceAttack(pevOwner, 0, pev->velocity.Normalize(), &tr, DMG_NEVERGIB); ApplyMultiDamage(pev, pevOwner); @@ -130,4 +130,4 @@ void CNail::NailTouch(CBaseEntity *pOther) void CNail::NailThink(void) { pev->nextthink = gpGlobals->time + 0.1; -} \ No newline at end of file +} diff --git a/dlls/poke646/nailgun.cpp b/dlls/poke646/nailgun.cpp index bb49587a..ac2d11b4 100644 --- a/dlls/poke646/nailgun.cpp +++ b/dlls/poke646/nailgun.cpp @@ -156,7 +156,7 @@ void CNailgun::PrimaryAttack() Vector vecAiming = gpGlobals->v_forward; Vector vecDir; - vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_NAIL, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed); + vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_NAIL2, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed); int flags; #if defined( CLIENT_WEAPONS ) @@ -287,4 +287,4 @@ class CNailAmmoRound : public CBasePlayerAmmo return bResult; } }; -LINK_ENTITY_TO_CLASS(ammo_nailround, CNailAmmoRound); \ No newline at end of file +LINK_ENTITY_TO_CLASS(ammo_nailround, CNailAmmoRound); diff --git a/dlls/skill.h b/dlls/skill.h index 7b0a11a0..477fc60a 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -138,8 +138,6 @@ struct skilldata_t float plrStomach; float plrLeg; float plrArm; - - float plrDmgNail; }; extern DLL_GLOBAL skilldata_t gSkillData; diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 0eb49056..0e68ccf6 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -1739,7 +1739,7 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in return 0.0; // crowbar already makes this sound fvol = 1.0; fvolbar = 0.2; - if( iBulletType == BULLET_PLAYER_NAIL ) + if( iBulletType == BULLET_PLAYER_NAIL1 || iBulletType == BULLET_PLAYER_NAIL2 ) { rgsz[0] = "weapons/brad_hit1.wav"; rgsz[1] = "weapons/brad_hit2.wav"; diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 5a592bf2..07d6b568 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -170,7 +170,8 @@ void DecalGunshot( TraceResult *pTrace, int iBulletType ) case BULLET_MONSTER_MP5: case BULLET_PLAYER_BUCKSHOT: case BULLET_PLAYER_357: - case BULLET_PLAYER_NAIL: + case BULLET_PLAYER_NAIL1: + case BULLET_PLAYER_NAIL2: default: // smoke and decal UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) ); diff --git a/dlls/weapons.h b/dlls/weapons.h index 674b6df2..9a19f86f 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -144,7 +144,8 @@ typedef enum BULLET_PLAYER_357, // python BULLET_PLAYER_BUCKSHOT, // shotgun BULLET_PLAYER_CROWBAR, // crowbar swipe - BULLET_PLAYER_NAIL, // nails + BULLET_PLAYER_NAIL1, // bradnailer nails + BULLET_PLAYER_NAIL2, // nailgun nails BULLET_PLAYER_XS, // xen squasher BULLET_MONSTER_9MM, From d94bc0d5e02cc49fe5ccab43b62a98fe5bc5e143 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 9 Dec 2016 00:52:21 +0500 Subject: [PATCH 007/199] Remove vendetta code. --- dlls/doors.cpp | 58 ++++++++++---------------------------------------- 1 file changed, 11 insertions(+), 47 deletions(-) diff --git a/dlls/doors.cpp b/dlls/doors.cpp index f9219d02..bf7205ee 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -71,8 +71,6 @@ public: BYTE m_bLockedSentence; BYTE m_bUnlockedSound; BYTE m_bUnlockedSentence; - BOOL m_bIsEndBossDoor; - int m_iNumTimesItWasOpen; }; TYPEDESCRIPTION CBaseDoor::m_SaveData[] = @@ -85,9 +83,6 @@ TYPEDESCRIPTION CBaseDoor::m_SaveData[] = DEFINE_FIELD( CBaseDoor, m_bLockedSentence, FIELD_CHARACTER ), DEFINE_FIELD( CBaseDoor, m_bUnlockedSound, FIELD_CHARACTER ), DEFINE_FIELD( CBaseDoor, m_bUnlockedSentence, FIELD_CHARACTER ), - - DEFINE_FIELD( CBaseDoor, m_bIsEndBossDoor, FIELD_BOOLEAN ), - DEFINE_FIELD( CBaseDoor, m_iNumTimesItWasOpen, FIELD_INTEGER ), }; IMPLEMENT_SAVERESTORE( CBaseDoor, CBaseToggle ) @@ -321,18 +316,6 @@ void CBaseDoor::Spawn() } else // touchable button SetTouch( &CBaseDoor::DoorTouch ); - - m_bIsEndBossDoor = FALSE; - m_iNumTimesItWasOpen = 0; - - if( FStrEq( STRING( gpGlobals->mapname ), "pv_asl02" ) && FStrEq( STRING( pev->targetname ), "robogate" ) ) - { - m_bIsEndBossDoor = TRUE; - } - else - { - m_bIsEndBossDoor = FALSE; - } } void CBaseDoor::SetToggleState( int state ) @@ -678,41 +661,22 @@ void CBaseDoor::DoorHitTop( void ) ASSERT( m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_AT_TOP; - m_iNumTimesItWasOpen++; - - if( m_bIsEndBossDoor ) + // toggle-doors don't come down automatically, they wait for refire. + if( FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) ) { - if( m_iNumTimesItWasOpen < 2 ) - { - // In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open - pev->nextthink = pev->ltime + 1; - SetThink( &CBaseDoor::DoorGoDown ); - } - else - { - m_flWait = -1; - pev->nextthink = -1; - } + // Re-instate touch method, movement is complete + if( !FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY ) ) + SetTouch( &CBaseDoor::DoorTouch ); } else { - // toggle-doors don't come down automatically, they wait for refire. - if( FBitSet( pev->spawnflags, SF_DOOR_NO_AUTO_RETURN ) ) - { - // Re-instate touch method, movement is complete - if( !FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY ) ) - SetTouch( &CBaseDoor::DoorTouch ); - } - else - { - // In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open - pev->nextthink = pev->ltime + m_flWait; - SetThink( &CBaseDoor::DoorGoDown ); + // In flWait seconds, DoorGoDown will fire, unless wait is -1, then door stays open + pev->nextthink = pev->ltime + m_flWait; + SetThink( &CBaseDoor::DoorGoDown ); - if( m_flWait == -1 ) - { - pev->nextthink = -1; - } + if( m_flWait == -1 ) + { + pev->nextthink = -1; } } From 5171dfb7294641ad961c0d3b77327a3d1a977a28 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 9 Dec 2016 01:47:15 +0500 Subject: [PATCH 008/199] Fix traceattack. --- dlls/combat.cpp | 4 ++-- dlls/poke646/nail.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/combat.cpp b/dlls/combat.cpp index ac1feddf..373966f2 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -1524,11 +1524,11 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi default: case BULLET_PLAYER_9MM: case BULLET_PLAYER_NAIL1: - pEntity->TraceAttack( pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_BULLET ); + pEntity->TraceAttack( pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_NEVERGIB ); break; case BULLET_PLAYER_MP5: case BULLET_PLAYER_NAIL2: - pEntity->TraceAttack( pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_BULLET ); + pEntity->TraceAttack( pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_NEVERGIB ); break; case BULLET_PLAYER_BUCKSHOT: // make distance based! diff --git a/dlls/poke646/nail.cpp b/dlls/poke646/nail.cpp index 6ec9f8ce..237337af 100644 --- a/dlls/poke646/nail.cpp +++ b/dlls/poke646/nail.cpp @@ -83,7 +83,7 @@ void CNail::NailTouch(CBaseEntity *pOther) // UNDONE: this needs to call TraceAttack instead ClearMultiDamage(); - pOther->TraceAttack(pevOwner, 0, pev->velocity.Normalize(), &tr, DMG_NEVERGIB); + //pOther->TraceAttack(pevOwner, 0, pev->velocity.Normalize(), &tr, DMG_NEVERGIB); ApplyMultiDamage(pev, pevOwner); From d2257de3bf94535ea02e8b87af006b48b6f80f04 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 10 Feb 2017 01:02:16 +0500 Subject: [PATCH 009/199] Solution for bugged weapon animation. --- dlls/poke646/xensquasher.cpp | 2 +- dlls/world.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/poke646/xensquasher.cpp b/dlls/poke646/xensquasher.cpp index 99ba5084..922ed2b4 100644 --- a/dlls/poke646/xensquasher.cpp +++ b/dlls/poke646/xensquasher.cpp @@ -492,7 +492,7 @@ void CXenSquasher::WeaponIdle(void) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (93.0f / 30.0f); } - return; + //return; SendWeaponAnim(iAnim); } diff --git a/dlls/world.cpp b/dlls/world.cpp index fe119919..61747b53 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -654,6 +654,8 @@ void CWorld::Precache( void ) CVAR_SET_FLOAT( "mp_defaultteam", 0 ); } + CVAR_SET_FLOAT( "cl_lw", 0 ); //Temporary solution for weapon animation. + // g-cont. moved here so cheats will working on restore level g_flWeaponCheat = CVAR_GET_FLOAT( "sv_cheats" ); // Is the impulse 101 command allowed? } From 56b2a6bc4c74bac1ab6548b66de34344117b2015 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 13 Feb 2017 00:12:28 +0500 Subject: [PATCH 010/199] Other solution for weapon animation. --- dlls/poke646/bradnailer.cpp | 44 ++++++++++++++++++------------------ dlls/poke646/xensquasher.cpp | 38 +++++++++++++++---------------- dlls/weapons.h | 16 ++++++------- dlls/world.cpp | 2 -- 4 files changed, 49 insertions(+), 51 deletions(-) diff --git a/dlls/poke646/bradnailer.cpp b/dlls/poke646/bradnailer.cpp index 2c9f887e..e90e684c 100644 --- a/dlls/poke646/bradnailer.cpp +++ b/dlls/poke646/bradnailer.cpp @@ -102,7 +102,7 @@ void CBradnailer::Holster(int skiplocal /*= 0*/) { m_fInReload = FALSE;// cancel any reload in progress. - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + m_pPlayer->m_flNextAttack = gpGlobals->time + 0.5; SendWeaponAnim(BRADNAILER_HOLSTER); m_fInAttack = 0; @@ -117,7 +117,7 @@ void CBradnailer::SecondaryAttack(void) return; } - if (m_flNextSecondaryAttack > UTIL_WeaponTimeBase()) + if (m_flNextSecondaryAttack > gpGlobals->time) return; if (m_fInAttack == 0) @@ -130,14 +130,14 @@ void CBradnailer::SecondaryAttack(void) m_fInAttack = 1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.7; - m_flNextSecondaryAttack = GetNextAttackDelay(0.7); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 2.0; + m_flTimeWeaponIdle = gpGlobals->time + 0.7; + m_flNextSecondaryAttack = gpGlobals->time + 0.7; + m_flNextPrimaryAttack = gpGlobals->time + 2.0; return; } else if (m_fInAttack == 1) { - if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) + if (m_flTimeWeaponIdle < gpGlobals->time) { #ifndef CLIENT_DLL //ALERT(at_console, "Fire\n"); @@ -146,8 +146,8 @@ void CBradnailer::SecondaryAttack(void) m_fInAttack = 1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.2f; - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); + m_flTimeWeaponIdle = gpGlobals->time + 0.2f; + m_flNextPrimaryAttack = gpGlobals->time + 0.5; } } } @@ -156,7 +156,7 @@ void CBradnailer::PrimaryAttack(void) { if (m_fInAttack != 0) { - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); + m_flNextPrimaryAttack = gpGlobals->time + 0.5; return; } @@ -169,9 +169,9 @@ void CBradnailer::PrimaryAttack(void) Fire(0.01f, 0.3f, TRUE, FALSE); - m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.3f); + m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 0.3f; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); + m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); } void CBradnailer::Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL fFastShoot) @@ -182,11 +182,11 @@ void CBradnailer::Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else +//#if defined( CLIENT_WEAPONS ) +// flags = FEV_NOTHOST; +//#else flags = 0; -#endif +//#endif // player "shoot" animation m_pPlayer->SetAnimation(PLAYER_ATTACK1); @@ -253,7 +253,7 @@ void CBradnailer::Reload(void) if (m_fInAttack != 0) return; - if (m_flNextPrimaryAttack > UTIL_WeaponTimeBase()) + if (m_flNextPrimaryAttack > gpGlobals->time) return; if (m_pPlayer->ammo_nails <= 0) @@ -282,7 +282,7 @@ void CBradnailer::WeaponIdle(void) m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) + if (m_flTimeWeaponIdle > gpGlobals->time) return; if (m_fInAttack != 0) @@ -294,8 +294,8 @@ void CBradnailer::WeaponIdle(void) SendWeaponAnim(BRADNAILER_TILT_TO_UPRIGHT, UseDecrement()); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; - m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.5f); + m_flTimeWeaponIdle = gpGlobals->time + 0.5f; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 0.5f; } else { @@ -308,17 +308,17 @@ void CBradnailer::WeaponIdle(void) if (flRand <= 0.3 + 0 * 0.75) { iAnim = BRADNAILER_IDLE3; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0 / 16; + m_flTimeWeaponIdle = gpGlobals->time + 49.0 / 16; } else if (flRand <= 0.6 + 0 * 0.875) { iAnim = BRADNAILER_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 16.0; + m_flTimeWeaponIdle = gpGlobals->time + 60.0 / 16.0; } else { iAnim = BRADNAILER_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0; + m_flTimeWeaponIdle = gpGlobals->time + 40.0 / 16.0; } SendWeaponAnim(iAnim, 1); } diff --git a/dlls/poke646/xensquasher.cpp b/dlls/poke646/xensquasher.cpp index 922ed2b4..0654a704 100644 --- a/dlls/poke646/xensquasher.cpp +++ b/dlls/poke646/xensquasher.cpp @@ -168,7 +168,7 @@ void CXenSquasher::PrimaryAttack() StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = gpGlobals->time + 1.0; // m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.45; } @@ -205,24 +205,24 @@ void CXenSquasher::SecondaryAttack() m_fPrimaryFire = FALSE; m_iClip--;// take one ammo just to start the spin - m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase(); + m_pPlayer->m_flNextAmmoBurn = gpGlobals->time; // spin up m_pPlayer->m_iWeaponVolume = XS_PRIMARY_CHARGE_VOLUME; SendWeaponAnim(XS_SPINUP); m_fInAttack = 1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = gpGlobals->time + 0.5; m_pPlayer->m_flStartCharge = gpGlobals->time; - m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime(); + m_pPlayer->m_flAmmoStartCharge = gpGlobals->time + GetFullChargeTime(); - PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0); + PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0); m_iSoundState = SND_CHANGE_PITCH; } else if (m_fInAttack == 1) { - if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) + if (m_flTimeWeaponIdle < gpGlobals->time) { SendWeaponAnim(XS_SPIN); m_fInAttack = 2; @@ -231,10 +231,10 @@ void CXenSquasher::SecondaryAttack() else { // during the charging process, eat one bit of ammo every once in a while - if (UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000) + if (gpGlobals->time >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000) { m_iClip--; - m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; + m_pPlayer->m_flNextAmmoBurn = gpGlobals->time + 0.3; } if (m_iClip <= 0) @@ -242,12 +242,12 @@ void CXenSquasher::SecondaryAttack() // out of ammo! force the gun to fire StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = gpGlobals->time + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; return; } - if (UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge) + if (gpGlobals->time >= m_pPlayer->m_flAmmoStartCharge) { // don't eat any more ammo after gun is fully charged. m_pPlayer->m_flNextAmmoBurn = 1000; @@ -262,7 +262,7 @@ void CXenSquasher::SecondaryAttack() if (m_iSoundState == 0) ALERT(at_console, "sound state %d\n", m_iSoundState); - PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, (m_iSoundState == SND_CHANGE_PITCH) ? 1 : 0, 0); + PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, (m_iSoundState == SND_CHANGE_PITCH) ? 1 : 0, 0); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions @@ -276,7 +276,7 @@ void CXenSquasher::SecondaryAttack() EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/xs_moan3.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG(0, 0x3f)); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = gpGlobals->time + 1.0; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; #ifndef CLIENT_DLL @@ -376,13 +376,13 @@ void CXenSquasher::Fire(Vector vecOrigSrc, Vector vecDir, float flDamage) // The main firing event is sent unreliably so it won't be delayed. - PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usXSFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0); + PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usXSFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0); // This reliable event is used to stop the spinning sound // It's delayed by a fraction of second to make sure it is delayed by 1 frame on the client // It's sent reliably anyway, which could lead to other delays - PLAYBACK_EVENT_FULL(FEV_NOTHOST | FEV_RELIABLE, m_pPlayer->edict(), m_usXSFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1); + PLAYBACK_EVENT_FULL(0 | FEV_RELIABLE, m_pPlayer->edict(), m_usXSFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1); /*ALERT( at_console, "%f %f %f\n%f %f %f\n", @@ -463,14 +463,14 @@ void CXenSquasher::WeaponIdle(void) m_pPlayer->m_flPlayAftershock = 0.0; } - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) + if (m_flTimeWeaponIdle > gpGlobals->time) return; if (m_fInAttack != 0) { StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; + m_flTimeWeaponIdle = gpGlobals->time + 2.0; } else { @@ -479,17 +479,17 @@ void CXenSquasher::WeaponIdle(void) if (flRand <= 0.5) { iAnim = XS_IDLE; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (63.0f / 15.0f); + m_flTimeWeaponIdle = gpGlobals->time + (63.0f / 15.0f); } else if (flRand <= 0.75) { iAnim = XS_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (63.0f / 15.0f); + m_flTimeWeaponIdle = gpGlobals->time + (63.0f / 15.0f); } else { iAnim = XS_FIDGET; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (93.0f / 30.0f); + m_flTimeWeaponIdle = gpGlobals->time + (93.0f / 30.0f); } //return; diff --git a/dlls/weapons.h b/dlls/weapons.h index 9a19f86f..1f52154a 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -1000,11 +1000,11 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) - return TRUE; -#else +//#if defined( CLIENT_WEAPONS ) +// return TRUE; +//#else return FALSE; -#endif +//#endif } void Fire( float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL fFastShoot ); @@ -1135,11 +1135,11 @@ public: virtual BOOL UseDecrement( void ) { -#if defined( CLIENT_WEAPONS ) - return TRUE; -#else +//#if defined( CLIENT_WEAPONS ) +// return TRUE; +//#else return FALSE; -#endif +//#endif } private: diff --git a/dlls/world.cpp b/dlls/world.cpp index 61747b53..fe119919 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -654,8 +654,6 @@ void CWorld::Precache( void ) CVAR_SET_FLOAT( "mp_defaultteam", 0 ); } - CVAR_SET_FLOAT( "cl_lw", 0 ); //Temporary solution for weapon animation. - // g-cont. moved here so cheats will working on restore level g_flWeaponCheat = CVAR_GET_FLOAT( "sv_cheats" ); // Is the impulse 101 command allowed? } From 5fc940956a8b8a03a046fc3fcf902f6d90ebbb1b Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 13 Feb 2017 20:12:54 +0500 Subject: [PATCH 011/199] Time override. --- dlls/weapons.cpp | 12 ++++++++++++ dlls/weapons.h | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 07d6b568..e8538df1 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1556,6 +1556,15 @@ TYPEDESCRIPTION CSatchel::m_SaveData[] = IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon ) +TYPEDESCRIPTION CBradnailer::m_SaveData[] = +{ + DEFINE_FIELD( CBradnailer, m_flNextPrimaryAttack, FIELD_TIME ), + DEFINE_FIELD( CBradnailer, m_flNextSecondaryAttack, FIELD_TIME ), + DEFINE_FIELD( CBradnailer, m_flTimeWeaponIdle, FIELD_TIME ), +}; + +IMPLEMENT_SAVERESTORE( CBradnailer, CBasePlayerWeapon ) + TYPEDESCRIPTION CCmlwbr::m_SaveData[] = { DEFINE_FIELD( CCmlwbr, m_fInAttack, FIELD_INTEGER ), @@ -1567,6 +1576,9 @@ IMPLEMENT_SAVERESTORE( CCmlwbr, CBasePlayerWeapon ) TYPEDESCRIPTION CXenSquasher::m_SaveData[] = { DEFINE_FIELD( CXenSquasher, m_fInAttack, FIELD_INTEGER ), + DEFINE_FIELD( CXenSquasher, m_flNextPrimaryAttack, FIELD_TIME ), + DEFINE_FIELD( CXenSquasher, m_flNextSecondaryAttack, FIELD_TIME ), + DEFINE_FIELD( CXenSquasher, m_flTimeWeaponIdle, FIELD_TIME ), //DEFINE_FIELD( CGauss, m_flStartCharge, FIELD_TIME ), //DEFINE_FIELD( CGauss, m_flPlayAftershock, FIELD_TIME ), //DEFINE_FIELD( CGauss, m_flNextAmmoBurn, FIELD_TIME ), diff --git a/dlls/weapons.h b/dlls/weapons.h index 1f52154a..44520592 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -984,6 +984,11 @@ private: class CBradnailer : public CBasePlayerWeapon { public: +#ifndef CLIENT_DLL + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; +#endif void Spawn( void ); void Precache( void ); int iItemSlot( void ){ return 2; } From 3c3872237373b47aeb559f2880d0982df641e041 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 19 Feb 2017 19:21:49 +0500 Subject: [PATCH 012/199] Update player.cpp --- dlls/player.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/player.cpp b/dlls/player.cpp index 6ba3eb0c..d25776df 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -133,6 +133,11 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = DEFINE_FIELD( CBasePlayer, m_fHudVisible, FIELD_BOOLEAN ), DEFINE_FIELD( CBasePlayer, m_fUpdateHudVisibility, FIELD_BOOLEAN ), + // Xensquasher + DEFINE_FIELD( CBasePlayer, m_flStartCharge, FIELD_TIME ), + DEFINE_FIELD( CBasePlayer, m_flPlayAftershock, FIELD_TIME ), + DEFINE_FIELD( CBasePlayer, m_flNextAmmoBurn, FIELD_TIME ), + //DEFINE_FIELD( CBasePlayer, m_fDeadTime, FIELD_FLOAT ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_fGameHUDInitialized, FIELD_INTEGER ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_flStopExtraSoundTime, FIELD_TIME ), From e099224bc5948dd604632f1602017b99cb29cc90 Mon Sep 17 00:00:00 2001 From: mittorn Date: Wed, 29 Mar 2017 19:59:50 +0000 Subject: [PATCH 013/199] Use vgui2 functions for utf-8 print --- cl_dll/MOTD.cpp | 2 +- cl_dll/cl_util.h | 2 ++ cl_dll/hud_redraw.cpp | 29 +++++++++++++++++++++++++++++ cl_dll/scoreboard.cpp | 24 ++++++++++++------------ 4 files changed, 44 insertions(+), 13 deletions(-) diff --git a/cl_dll/MOTD.cpp b/cl_dll/MOTD.cpp index 6ab3a161..179ae4a8 100644 --- a/cl_dll/MOTD.cpp +++ b/cl_dll/MOTD.cpp @@ -103,7 +103,7 @@ int CHudMOTD::Draw( float fTime ) // find where to start drawing the line if( ( ypos > ROW_RANGE_MIN ) && ( ypos + LINE_HEIGHT <= ypos_r + height ) ) - gHUD.DrawHudString( xpos, ypos, xmax, ch, 255, 180, 0 ); + DrawUtfString( xpos, ypos, xmax, ch, 255, 180, 0 ); ypos += LINE_HEIGHT; diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 84488050..54dcede0 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -115,6 +115,8 @@ inline void GetConsoleStringSize( const char *string, int *width, int *height ) gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height ); } +int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ); + inline int ConsoleStringLen( const char *string ) { int _width = 0, _height = 0; diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index aed98455..b5314961 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -226,6 +226,35 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g return xpos; } + + +int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) +{ + // xash3d: reset unicode state + gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); + + // draw the string until we hit the null character or a newline character + for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) + { + int w = gHUD.m_scrinfo.charWidths['M']; + if( xpos + w > iMaxX ) + return xpos; + if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') ) + { + szIt++; + r = colors[*szIt - '0'][0]; + g = colors[*szIt - '0'][1]; + b = colors[*szIt - '0'][2]; + if( !*(++szIt) ) + return xpos; + } + int c = (unsigned int)(unsigned char)*szIt; + xpos += gEngfuncs.pfnVGUI2DrawCharacterAdditive( xpos, ypos, c, r, g, b, 0 ); + } + + return xpos; +} + int CHud::DrawHudStringLen( char *szIt ) { int l = 0; diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 2e0722f9..3a780baf 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -146,18 +146,18 @@ int CHudScoreboard::Draw( float fTime ) FAR_RIGHT += 5; gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); if( !gHUD.m_Teamplay ) - gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); + DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); else - gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 ); + DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Teams", 255, 140, 0 ); gHUD.DrawHudStringReverse( KILLS_RANGE_MAX + xpos_rel, ypos, 0, "kills", 255, 140, 0 ); - gHUD.DrawHudString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", 255, 140, 0 ); - gHUD.DrawHudString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 ); - gHUD.DrawHudString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 ); + DrawUtfString( DIVIDER_POS + xpos_rel, ypos, ScreenWidth, "/", 255, 140, 0 ); + DrawUtfString( DEATHS_RANGE_MIN + xpos_rel + 5, ypos, ScreenWidth, "deaths", 255, 140, 0 ); + DrawUtfString( PING_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "latency", 255, 140, 0 ); if( can_show_packetloss ) { - gHUD.DrawHudString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 ); + DrawUtfString( PL_RANGE_MAX + xpos_rel - 35, ypos, ScreenWidth, "pkt loss", 255, 140, 0 ); } list_slot += 1.2; @@ -272,7 +272,7 @@ int CHudScoreboard::Draw( float fTime ) } // draw their name (left to right) - gHUD.DrawHudString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b ); + DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, team_info->name, r, g, b ); // draw kills (right to left) xpos = KILLS_RANGE_MAX + xpos_rel; @@ -280,7 +280,7 @@ int CHudScoreboard::Draw( float fTime ) // draw divider xpos = DIVIDER_POS + xpos_rel; - gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b ); + DrawUtfString( xpos, ypos, xpos + 20, "/", r, g, b ); // draw deaths xpos = DEATHS_RANGE_MAX + xpos_rel; @@ -300,7 +300,7 @@ int CHudScoreboard::Draw( float fTime ) xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2) + PL_RANGE_MIN + xpos_rel + 25; sprintf( buf, " %d", team_info->packetloss ); - gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); + DrawUtfString( xpos, ypos, xpos+50, buf, r, g, b ); } team_info->already_drawn = TRUE; // set the already_drawn to be TRUE, so this team won't get drawn again @@ -400,7 +400,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, } // draw their name (left to right) - gHUD.DrawHudString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, pl_info->name, r, g, b ); + DrawUtfString( xpos + nameoffset, ypos, NAME_RANGE_MAX + xpos_rel, pl_info->name, r, g, b ); // draw kills (right to left) xpos = KILLS_RANGE_MAX + xpos_rel; @@ -408,7 +408,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, // draw divider xpos = DIVIDER_POS + xpos_rel; - gHUD.DrawHudString( xpos, ypos, xpos + 20, "/", r, g, b ); + DrawUtfString( xpos, ypos, xpos + 20, "/", r, g, b ); // draw deaths xpos = DEATHS_RANGE_MAX + xpos_rel; @@ -435,7 +435,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, xpos = ( ( PL_RANGE_MAX - PL_RANGE_MIN ) / 2 ) + PL_RANGE_MIN + xpos_rel + 25; - gHUD.DrawHudString( xpos, ypos, xpos+50, buf, r, g, b ); + DrawUtfString( xpos, ypos, xpos+50, buf, r, g, b ); } pl_info->name = NULL; // set the name to be NULL, so this client won't get drawn again From 409848b80fd02893f6eb34cd97e18cd93c2ada04 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 3 Apr 2017 21:16:25 +0500 Subject: [PATCH 014/199] Do not break menuselect behavior. --- dlls/client.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 21e5d810..5fb7c221 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -466,10 +466,10 @@ void ClientCommand( edict_t *pEntity ) edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); } - /*else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) + else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) { // MenuSelect returns true only if the command is properly handled, so don't print a warning - }*/ + } else if( FStrEq( pcmd, "VModEnable" ) ) { // clear 'Unknown command: VModEnable' in singleplayer From 4fbb070e7d59c8dc660f5895ba8470fe869cd49a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 4 Apr 2017 01:15:16 +0500 Subject: [PATCH 015/199] Implement cl_scoreboard_bg cvar. --- cl_dll/scoreboard.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 3a780baf..507e0415 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -26,6 +26,7 @@ #include #include +cvar_t *cl_scoreboard_bg; cvar_t *cl_showpacketloss; hud_player_info_t g_PlayerInfoList[MAX_PLAYERS + 1]; // player info from the engine extra_player_info_t g_PlayerExtraInfo[MAX_PLAYERS + 1]; // additional player info sent directly to the client dll @@ -59,6 +60,7 @@ int CHudScoreboard::Init( void ) InitHUDData(); + cl_scoreboard_bg = CVAR_CREATE( "cl_scoreboard_bg", "1", 0 ); cl_showpacketloss = CVAR_CREATE( "cl_showpacketloss", "0", FCVAR_ARCHIVE ); return 1; @@ -144,7 +146,8 @@ int CHudScoreboard::Draw( float fTime ) FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; FAR_RIGHT += 5; - gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); + if( cl_scoreboard_bg && cl_scoreboard_bg->value ) + gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); if( !gHUD.m_Teamplay ) DrawUtfString( xpos, ypos, NAME_RANGE_MAX + xpos_rel, "Player", 255, 140, 0 ); else From 6f8d64df898ba58f1d5c3cd6f81951f38d6f74dd Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 4 Apr 2017 01:43:21 +0500 Subject: [PATCH 016/199] Make cl_scoreboard_bg cvar archive. --- cl_dll/scoreboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 507e0415..b20e316c 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -60,7 +60,7 @@ int CHudScoreboard::Init( void ) InitHUDData(); - cl_scoreboard_bg = CVAR_CREATE( "cl_scoreboard_bg", "1", 0 ); + cl_scoreboard_bg = CVAR_CREATE( "cl_scoreboard_bg", "1", FCVAR_ARCHIVE ); cl_showpacketloss = CVAR_CREATE( "cl_showpacketloss", "0", FCVAR_ARCHIVE ); return 1; From 8163bced2c29e22629b3c3c3541d131fed00bfdf Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 12 Apr 2017 02:02:18 +0500 Subject: [PATCH 017/199] Do not break hud_takesshots cvar behavior. --- cl_dll/hud_redraw.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index b5314961..c30df36d 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -93,6 +93,13 @@ int CHud::Redraw( float flTime, int intermission ) if( m_flTimeDelta < 0 ) m_flTimeDelta = 0; + if( !m_iIntermission && intermission ) + { + // Take a screenshot if the client's got the cvar set + if( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 ) + m_flShotTime = flTime + 1.0; // Take a screenshot in a second + } + if( m_flShotTime && m_flShotTime < flTime ) { gEngfuncs.pfnClientCmd( "snapshot\n" ); From fc276ad52f51ec128352ac680ef9cbac038e6b23 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 16 Jun 2017 19:18:24 +0500 Subject: [PATCH 018/199] Do not use -frtti flag. --- dlls/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/Android.mk b/dlls/Android.mk index 7f107a12..7fcdf581 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -16,7 +16,7 @@ endif LOCAL_CFLAGS += -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf \ -fno-exceptions -DNO_VOICEGAMEMGR -w -LOCAL_CPPFLAGS := $(LOCAL_CFLAGS) -frtti +LOCAL_CPPFLAGS := $(LOCAL_CFLAGS) LOCAL_C_INCLUDES := $(SDL_PATH)/include \ $(LOCAL_PATH)/. \ From a522ae20c3dcb7b48381205254021796db914d14 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 26 Jun 2017 05:47:19 +0500 Subject: [PATCH 019/199] Merge some changes from git version of hlsdk. --- common/const.h | 11 +- common/cvardef.h | 3 +- dlls/buttons.cpp | 6 +- dlls/cbase.h | 4 +- dlls/client.cpp | 238 ++++++++++++++++++++++++++++------- dlls/crossbow.cpp | 4 +- dlls/crowbar.cpp | 9 +- dlls/doors.cpp | 9 +- dlls/extdll.h | 2 +- dlls/game.cpp | 2 + dlls/gauss.cpp | 4 +- dlls/handgrenade.cpp | 4 +- dlls/mp5.cpp | 4 +- dlls/multiplay_gamerules.cpp | 4 +- dlls/nihilanth.cpp | 18 ++- dlls/player.cpp | 115 +++++++++++++++-- dlls/player.h | 12 ++ dlls/rpg.cpp | 4 +- dlls/satchel.cpp | 6 +- dlls/saverestore.h | 2 +- dlls/shotgun.cpp | 10 +- dlls/squeakgrenade.cpp | 2 +- dlls/subs.cpp | 8 ++ dlls/triggers.cpp | 2 +- dlls/tripmine.cpp | 2 +- dlls/util.cpp | 4 +- dlls/util.h | 2 +- dlls/weapons.cpp | 36 ++++++ dlls/weapons.h | 5 + dlls/zombie.cpp | 6 +- engine/eiface.h | 17 +-- engine/shake.h | 4 +- engine/studio.h | 10 +- pm_shared/pm_defs.h | 2 +- pm_shared/pm_materials.h | 1 + pm_shared/pm_shared.c | 24 ++-- 36 files changed, 473 insertions(+), 123 deletions(-) diff --git a/common/const.h b/common/const.h index b885e44e..d29816e6 100644 --- a/common/const.h +++ b/common/const.h @@ -110,7 +110,9 @@ #define EF_NOINTERP 32 // don't interpolate the next frame #define EF_LIGHT 64 // rocket flare glow sprite #define EF_NODRAW 128 // don't draw entity - +#define EF_NIGHTVISION 256 // player nightvision +#define EF_SNIPERLASER 512 // sniper laser effect +#define EF_FIBERCAMERA 1024 // fiber camera #define EF_NOREFLECT (1<<24) // Entity won't reflecting in mirrors @@ -531,6 +533,7 @@ #define TEFIRE_FLAG_LOOP 4 // if set, sprite plays at 15 fps, otherwise plays at whatever rate stretches the animation over the sprite's duration. #define TEFIRE_FLAG_ALPHA 8 // if set, sprite is rendered alpha blended at 50% else, opaque #define TEFIRE_FLAG_PLANAR 16 // if set, all fire sprites have same initial Z instead of randomly filling a cube. +#define TEFIRE_FLAG_ADDITIVE 32 // if set, sprite is rendered non-opaque with additive #define TE_PLAYERATTACHMENT 124 // attaches a TENT to a player (this is a high-priority tent) // byte (entity index of player) @@ -621,8 +624,9 @@ #define CHAN_BODY 4 #define CHAN_STREAM 5 // allocate stream channel from the static or dynamic area #define CHAN_STATIC 6 // allocate channel from the static area -#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network +#define CHAN_NETWORKVOICE_BASE 7 // voice data coming across the network #define CHAN_NETWORKVOICE_END 500 // network voice data reserves slots (CHAN_NETWORKVOICE_BASE through CHAN_NETWORKVOICE_END). +#define CHAN_BOT 501 // channel used for bot chatter. // attenuation values #define ATTN_NONE 0 @@ -724,7 +728,8 @@ enum kRenderFxDeadPlayer, // kRenderAmt is the player index kRenderFxExplode, // Scale up really big! kRenderFxGlowShell, // Glowing Shell - kRenderFxClampMinScale // Keep this sprite from getting very small (SPRITES only!) + kRenderFxClampMinScale, // Keep this sprite from getting very small (SPRITES only!) + kRenderFxLightMultiplier //CTM !!!CZERO added to tell the studiorender that the value in iuser2 is a lightmultiplier }; typedef unsigned int func_t; diff --git a/common/cvardef.h b/common/cvardef.h index f822cc7a..c57b97a7 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -24,6 +24,7 @@ #define FCVAR_SPONLY (1<<6) // This cvar cannot be changed by clients connected to a multiplayer server. #define FCVAR_PRINTABLEONLY (1<<7) // This cvar's string cannot contain unprintable characters ( e.g., used for player name etc ). #define FCVAR_UNLOGGED (1<<8) // If this is a FCVAR_SERVER, don't log changes to the log file / console if we are creating a log +#define FCVAR_NOEXTRAWHITEPACE (1<<9) // strip trailing/leading white space from this cvar typedef struct cvar_s { @@ -34,4 +35,4 @@ typedef struct cvar_s struct cvar_s *next; } cvar_t; -#endif//CVARDEF_H \ No newline at end of file +#endif//CVARDEF_H diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 7b050add..3027f10e 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -1045,7 +1045,11 @@ void CMomentaryRotButton::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, US pev->ideal_yaw = CBaseToggle::AxisDelta( pev->spawnflags, pev->angles, m_start ) / m_flMoveDistance; UpdateAllButtons( pev->ideal_yaw, 1 ); - UpdateTarget( pev->ideal_yaw ); + + // Calculate destination angle and use it to predict value, this prevents sending target in wrong direction on retriggering + Vector dest = pev->angles + pev->avelocity * ( pev->nextthink - pev->ltime ); + float value1 = CBaseToggle::AxisDelta( pev->spawnflags, dest, m_start ) / m_flMoveDistance; + UpdateTarget( value1 ); } void CMomentaryRotButton::UpdateAllButtons( float value, int start ) diff --git a/dlls/cbase.h b/dlls/cbase.h index 47ce7595..617bbab9 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -280,8 +280,8 @@ public: #ifdef _DEBUG void FunctionCheck( void *pFunction, char *name ) { - if( pFunction && !NAME_FOR_FUNCTION( (unsigned long)( pFunction ) ) ) - ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (unsigned long)pFunction ); + if( pFunction && !NAME_FOR_FUNCTION( (size_t)( pFunction ) ) ) + ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (size_t)pFunction ); } BASEPTR ThinkSet( BASEPTR func, char *name ) diff --git a/dlls/client.cpp b/dlls/client.cpp index 5fb7c221..74be0ea3 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -48,6 +48,8 @@ extern void CopyToBodyQue( entvars_t* pev ); extern int giPrecacheGrunt; extern int gmsgSayText; +extern cvar_t allow_spectators; + extern int g_teamplay; void LinkUserMessages( void ); @@ -204,6 +206,97 @@ void ClientPutInServer( edict_t *pEntity ) #include "voice_gamemgr.h" extern CVoiceGameMgr g_VoiceGameMgr; #endif + +//----------------------------------------------------------------------------- +// Purpose: determine if a uchar32 represents a valid Unicode code point +//----------------------------------------------------------------------------- +bool Q_IsValidUChar32( unsigned int uVal ) +{ + // Values > 0x10FFFF are explicitly invalid; ditto for UTF-16 surrogate halves, + // values ending in FFFE or FFFF, or values in the 0x00FDD0-0x00FDEF reserved range + return ( uVal < 0x110000u ) && ( ( uVal - 0x00D800u ) > 0x7FFu ) && ( ( uVal & 0xFFFFu ) < 0xFFFEu ) && ( ( uVal - 0x00FDD0u ) > 0x1Fu ); +} + +// Decode one character from a UTF-8 encoded string. Treats 6-byte CESU-8 sequences +// as a single character, as if they were a correctly-encoded 4-byte UTF-8 sequence. +int Q_UTF8ToUChar32( const char *pUTF8_, unsigned int &uValueOut, bool &bErrorOut ) +{ + const unsigned char *pUTF8 = (const unsigned char*)pUTF8_; + + int nBytes = 1; + unsigned int uValue = pUTF8[0]; + unsigned int uMinValue = 0; + + // 0....... single byte + if( uValue < 0x80 ) + goto decodeFinishedNoCheck; + + // Expecting at least a two-byte sequence with 0xC0 <= first <= 0xF7 (110...... and 11110...) + if( ( uValue - 0xC0u ) > 0x37u || ( pUTF8[1] & 0xC0 ) != 0x80 ) + goto decodeError; + + uValue = ( uValue << 6 ) - ( 0xC0 << 6 ) + pUTF8[1] - 0x80; + nBytes = 2; + uMinValue = 0x80; + + // 110..... two-byte lead byte + if( !( uValue & ( 0x20 << 6 ) ) ) + goto decodeFinished; + + // Expecting at least a three-byte sequence + if( ( pUTF8[2] & 0xC0 ) != 0x80 ) + goto decodeError; + + uValue = ( uValue << 6 ) - ( 0x20 << 12 ) + pUTF8[2] - 0x80; + nBytes = 3; + uMinValue = 0x800; + + // 1110.... three-byte lead byte +decodeFinished: + if( uValue >= uMinValue && Q_IsValidUChar32( uValue ) ) + { +decodeFinishedNoCheck: + uValueOut = uValue; + bErrorOut = false; + return nBytes; + } +decodeError: + uValueOut = '?'; + bErrorOut = true; + return nBytes; + +decodeFinishedMaybeCESU8: + // Do we have a full UTF-16 surrogate pair that's been UTF-8 encoded afterwards? + // That is, do we have 0xD800-0xDBFF followed by 0xDC00-0xDFFF? If so, decode it all. + if( ( uValue - 0xD800u ) < 0x400u && pUTF8[3] == 0xED && (unsigned char)( pUTF8[4] - 0xB0 ) < 0x10 && ( pUTF8[5] & 0xC0 ) == 0x80 ) + { + uValue = 0x10000 + ( ( uValue - 0xD800u ) << 10 ) + ( (unsigned char)( pUTF8[4] - 0xB0 ) << 6 ) + pUTF8[5] - 0x80; + nBytes = 6; + uMinValue = 0x10000; + } + goto decodeFinished; +} + +//----------------------------------------------------------------------------- +// Purpose: Returns true if UTF-8 string contains invalid sequences. +//----------------------------------------------------------------------------- +bool Q_UnicodeValidate( const char *pUTF8 ) +{ + bool bError = false; + while( *pUTF8 ) + { + unsigned int uVal; + // Our UTF-8 decoder silently fixes up 6-byte CESU-8 (improperly re-encoded UTF-16) sequences. + // However, these are technically not valid UTF-8. So if we eat 6 bytes at once, it's an error. + int nCharSize = Q_UTF8ToUChar32( pUTF8, uVal, bError ); + if( bError || nCharSize == 6 ) + return false; + pUTF8 += nCharSize; + } + return true; +} + + //// HOST_SAY // String comes in as // say blah blah blah @@ -265,20 +358,13 @@ void Host_Say( edict_t *pEntity, int teamonly ) p[strlen( p ) - 1] = 0; } - // make sure the text has content - for( pc = p; pc != NULL && *pc != 0; pc++ ) - { - if( !isspace( *pc ) ) - { - pc = NULL; // we've found an alphanumeric character, so text is valid - break; - } - } - if( pc != NULL ) + if( !p || !p[0] || !Q_UnicodeValidate ( p ) ) return; // no character found, so say nothing // turn on color set 2 (color on, no sound) - if( teamonly ) + if( player->IsObserver() && ( teamonly ) ) + sprintf( text, "%c(SPEC) %s: ", 2, STRING( pEntity->v.netname ) ); + else if( teamonly ) sprintf( text, "%c(TEAM) %s: ", 2, STRING( pEntity->v.netname ) ); else sprintf( text, "%c%s: ", 2, STRING( pEntity->v.netname ) ); @@ -313,9 +399,14 @@ void Host_Say( edict_t *pEntity, int teamonly ) if( g_VoiceGameMgr.PlayerHasBlockedPlayer( client, player ) ) continue; #endif - if( teamonly && g_pGameRules->PlayerRelationship( client, CBaseEntity::Instance( pEntity ) ) != GR_TEAMMATE ) + if( !player->IsObserver() && teamonly && g_pGameRules->PlayerRelationship( client, CBaseEntity::Instance( pEntity ) ) != GR_TEAMMATE ) continue; + // Spectators can only talk to other specs + if( player->IsObserver() && teamonly ) + if ( !client->IsObserver() ) + continue; + MESSAGE_BEGIN( MSG_ONE, gmsgSayText, NULL, client->pev ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); @@ -459,12 +550,40 @@ void ClientCommand( edict_t *pEntity ) { GetClassPtr( (CBasePlayer *)pev )->SelectLastItem(); } - else if( FStrEq( pcmd, "spectate" ) && ( pev->flags & FL_PROXY ) ) // added for proxy support + else if( FStrEq( pcmd, "spectate" ) // clients wants to become a spectator { - CBasePlayer * pPlayer = GetClassPtr( (CBasePlayer *)pev ); + // always allow proxies to become a spectator + if( ( pev->flags & FL_PROXY ) || allow_spectators.value ) + { + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); - edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); - pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); + edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); + pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); + + // notify other clients of player switching to spectator mode + UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n", + ( pev->netname && STRING(pev->netname)[0] != 0 ) ? STRING(pev->netname) : "unconnected" ) ); + } + else + ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" ); + } + else if( FStrEq( pcmd, "specmode" ) ) // new spectator mode + { + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + + if( pPlayer->IsObserver() ) + pPlayer->Observer_SetMode( atoi( CMD_ARGV( 1 ) ) ); + } + else if( FStrEq( pcmd, "closemenus" ) ) + { + // just ignore it + } + else if( FStrEq( pcmd, "follownext" ) ) // follow next player + { + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + + if( pPlayer->IsObserver() ) + pPlayer->Observer_FindNextPlayer( atoi( CMD_ARGV( 1 ) ) ? true : false ); } else if( g_pGameRules->ClientCommand( GetClassPtr( (CBasePlayer *)pev ), pcmd ) ) { @@ -524,12 +643,15 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) // Set the name g_engfuncs.pfnSetClientKeyValue( ENTINDEX( pEntity ), infobuffer, "name", sName ); - char text[256]; - snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); - MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); - WRITE_BYTE( ENTINDEX( pEntity ) ); - WRITE_STRING( text ); - MESSAGE_END(); + if( gpGlobals->maxClients > 1 ) + { + char text[256]; + snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); + MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); + WRITE_BYTE( ENTINDEX( pEntity ) ); + WRITE_STRING( text ); + MESSAGE_END(); + } // team match? if( g_teamplay ) @@ -983,7 +1105,7 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h int i; // don't send if flagged for NODRAW and it's not the host getting the message - if( ( ent->v.effects == EF_NODRAW ) && ( ent != host ) ) + if( ( ent->v.effects & EF_NODRAW ) && ( ent != host ) ) return 0; // Ignore ents without valid / visible models @@ -1553,41 +1675,67 @@ engine sets cd to 0 before calling. */ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ) { - cd->flags = ent->v.flags; - cd->health = ent->v.health; + if( !ent || !ent->pvPrivateData ) + return; + entvars_t *pev = (entvars_t *)&ent->v; + CBasePlayer *pl = (CBasePlayer *)( CBasePlayer::Instance( pev ) ); + entvars_t *pevOrg = NULL; - cd->viewmodel = MODEL_INDEX( STRING( ent->v.viewmodel ) ); + // if user is spectating different player in First person, override some vars + if( pl && pl->pev->iuser1 == OBS_IN_EYE ) + { + if( pl->m_hObserverTarget ) + { + pevOrg = pev; + pev = pl->m_hObserverTarget->pev; + pl = (CBasePlayer *)(CBasePlayer::Instance( pev ) ); + } + } - cd->waterlevel = ent->v.waterlevel; - cd->watertype = ent->v.watertype; - cd->weapons = ent->v.weapons; + cd->flags = pev->flags; + cd->health = pev->health; + + cd->viewmodel = MODEL_INDEX( STRING( pev->viewmodel ) ); + + cd->waterlevel = pev->waterlevel; + cd->watertype = pev->watertype; + cd->weapons = pev->weapons; // Vectors - cd->origin = ent->v.origin; - cd->velocity = ent->v.velocity; - cd->view_ofs = ent->v.view_ofs; - cd->punchangle = ent->v.punchangle; + cd->origin = pev->origin; + cd->velocity = pev->velocity; + cd->view_ofs = pev->view_ofs; + cd->punchangle = pev->punchangle; - cd->bInDuck = ent->v.bInDuck; - cd->flTimeStepSound = ent->v.flTimeStepSound; - cd->flDuckTime = ent->v.flDuckTime; - cd->flSwimTime = ent->v.flSwimTime; - cd->waterjumptime = ent->v.teleport_time; + cd->bInDuck = pev->bInDuck; + cd->flTimeStepSound = pev->flTimeStepSound; + cd->flDuckTime = pev->flDuckTime; + cd->flSwimTime = pev->flSwimTime; + cd->waterjumptime = pev->teleport_time; strcpy( cd->physinfo, ENGINE_GETPHYSINFO( ent ) ); - cd->maxspeed = ent->v.maxspeed; - cd->fov = ent->v.fov; - cd->weaponanim = ent->v.weaponanim; + cd->maxspeed = pev->maxspeed; + cd->fov = pev->fov; + cd->weaponanim = pev->weaponanim; - cd->pushmsec = ent->v.pushmsec; + cd->pushmsec = pev->pushmsec; + // Spectator mode + if( pevOrg != NULL ) + { + // don't use spec vars from chased player + cd->iuser1 = pevOrg->iuser1; + cd->iuser2 = pevOrg->iuser2; + } + else + { + cd->iuser1 = pev->iuser1; + cd->iuser2 = pev->iuser2; + } #if defined( CLIENT_WEAPONS ) if( sendweapons ) { - entvars_t *pev = (entvars_t *)&ent->v; - CBasePlayer *pl = (CBasePlayer *)CBasePlayer::Instance( pev ); - if( pl ) { cd->m_flNextAttack = pl->m_flNextAttack; diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index 45fd922c..7a4686e7 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -353,7 +353,7 @@ void CCrossbow::PrimaryAttack( void ) // this function only gets called in multiplayer void CCrossbow::FireSniperBolt() { - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); if( m_iClip == 0 ) { @@ -451,7 +451,7 @@ void CCrossbow::FireBolt() // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75; diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 94f0066b..80a18d65 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -27,7 +27,7 @@ LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar ) -enum gauss_e +enum crowbar_e { CROWBAR_IDLE = 0, CROWBAR_DRAW, @@ -40,8 +40,7 @@ enum gauss_e CROWBAR_ATTACK3HIT }; - -void CCrowbar::Spawn( ) +void CCrowbar::Spawn() { Precache(); m_iId = WEAPON_CROWBAR; @@ -191,7 +190,7 @@ int CCrowbar::Swing( int fFirst ) if( fFirst ) { // miss - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); @@ -297,7 +296,7 @@ int CCrowbar::Swing( int fFirst ) m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME; #endif - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); SetThink( &CCrowbar::Smack ); pev->nextthink = UTIL_WeaponTimeBase() + 0.2; diff --git a/dlls/doors.cpp b/dlls/doors.cpp index bf7205ee..bdc82f06 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -1100,19 +1100,22 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP Vector move = m_vecPosition1 + ( value * ( m_vecPosition2 - m_vecPosition1 ) ); Vector delta = move - pev->origin; - float speed = delta.Length() * 10; + //float speed = delta.Length() * 10; + float speed = delta.Length() / 0.1; // move there in 0.1 sec if( speed != 0 ) { // This entity only thinks when it moves, so if it's thinking, it's in the process of moving - // play the sound when it starts moving + // play the sound when it starts moving(not yet thinking) if( pev->nextthink < pev->ltime || pev->nextthink == 0 ) EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); + // If we already moving to designated point, return + else if( move == m_vecFinalDest ) + return; LinearMove( move, speed ); SetMoveDone( &CMomentaryDoor::MomentaryMoveDone ); } - } void CMomentaryDoor::MomentaryMoveDone( void ) diff --git a/dlls/extdll.h b/dlls/extdll.h index cbc7ebb9..58349e32 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -44,7 +44,7 @@ #else // _WIN32 #define FALSE 0 #define TRUE (!FALSE) -typedef unsigned long ULONG; +typedef unsigned int ULONG; typedef unsigned char BYTE; typedef int BOOL; #define MAX_PATH PATH_MAX diff --git a/dlls/game.cpp b/dlls/game.cpp index 3aec1810..fb247903 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -39,6 +39,8 @@ cvar_t teamoverride = { "mp_teamoverride","1" }; cvar_t defaultteam = { "mp_defaultteam","0" }; cvar_t allowmonsters = { "mp_allowmonsters","0", FCVAR_SERVER }; +cvar_t allow_spectators = { "allow_spectators", "0", FCVAR_SERVER }; // 0 prevents players from being spectators + cvar_t mp_chattime = { "mp_chattime","10", FCVAR_SERVER }; // Engine Cvars diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 14aac39b..10149202 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -145,7 +145,7 @@ void CGauss::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; + m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); return; } @@ -183,7 +183,7 @@ void CGauss::SecondaryAttack() PlayEmptySound(); } - m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); return; } diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index 063b2886..96119b6b 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -170,7 +170,7 @@ void CHandGrenade::WeaponIdle( void ) m_flReleaseThrow = 0; m_flStartThrow = 0; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; @@ -180,7 +180,7 @@ void CHandGrenade::WeaponIdle( void ) // just threw last grenade // set attack times in the future, and weapon idle in the future so we can see the whole throw // animation, weapon idle will automatically retire the weapon for us. - m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5;// ensure that the animation can finish playing + m_flTimeWeaponIdle = m_flNextSecondaryAttack = m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 );// ensure that the animation can finish playing } return; } diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 7d05d5e1..7131f888 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -177,7 +177,7 @@ void CMP5::PrimaryAttack() // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.1 ); if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; @@ -227,7 +227,7 @@ void CMP5::SecondaryAttack( void ) #endif PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usMP52 ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1; + m_flNextPrimaryAttack = GetNextAttackDelay( 1 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5;// idle pretty soon after shooting. diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 929c2bf6..ebef51de 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -92,7 +92,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() if( IS_DEDICATED_SERVER() ) { // dedicated server - char *servercfgfile = (char *)CVAR_GET_STRING( "servercfgfile" ); + /*char *servercfgfile = (char *)CVAR_GET_STRING( "servercfgfile" ); if( servercfgfile && servercfgfile[0] ) { @@ -102,6 +102,8 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() sprintf( szCommand, "exec %s\n", servercfgfile ); SERVER_COMMAND( szCommand ); } + */ + // this code has been moved into engine, to only run server.cfg once } else { diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 58317b3c..ba1c6192 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -1185,8 +1185,22 @@ void CNihilanth::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ case USE_OFF: { CBaseEntity *pTouch = UTIL_FindEntityByTargetname( NULL, m_szDeadTouch ); - if( pTouch && m_hEnemy != NULL ) - pTouch->Touch( m_hEnemy ); + if( pTouch ) + { + if( m_hEnemy != NULL ) + { + pTouch->Touch( m_hEnemy ); + } + // if the player is using "notarget", the ending sequence won't fire unless we catch it here + else + { + CBaseEntity *pEntity = UTIL_FindEntityByClassname( NULL, "player" ); + if( pEntity != NULL && pEntity->IsAlive() ) + { + pTouch->Touch( pEntity ); + } + } + } } break; case USE_ON: diff --git a/dlls/player.cpp b/dlls/player.cpp index 2f097072..7d7363b5 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -34,6 +34,7 @@ #include "decals.h" #include "gamerules.h" #include "game.h" +#include "pm_shared.h" #include "hltv.h" // #define DUCKFIX @@ -201,7 +202,8 @@ void LinkUserMessages( void ) gmsgDamage = REG_USER_MSG( "Damage", 12 ); gmsgBattery = REG_USER_MSG( "Battery", 2); gmsgTrain = REG_USER_MSG( "Train", 1 ); - gmsgHudText = REG_USER_MSG( "HudText", -1 ); + //gmsgHudText = REG_USER_MSG( "HudTextPro", -1 ); + gmsgHudText = REG_USER_MSG( "HudText", -1 ); // we don't use the message but 3rd party addons may! gmsgSayText = REG_USER_MSG( "SayText", -1 ); gmsgTextMsg = REG_USER_MSG( "TextMsg", -1 ); gmsgWeaponList = REG_USER_MSG( "WeaponList", -1 ); @@ -785,6 +787,12 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) m_pLastItem = NULL; + if( m_pTank != NULL ) + { + m_pTank->Use( this, this, USE_OFF, 0 ); + m_pTank = NULL; + } + int i; CBasePlayerItem *pPendingItem; for( i = 0; i < MAX_ITEM_TYPES; i++ ) @@ -1297,6 +1305,9 @@ void CBasePlayer::PlayerDeathThink( void ) StartDeathCam(); } + if( pev->iuser1 ) // player is in spectator mode + return; + // wait for any button down, or mp_forcerespawn is set and the respawn time is up if( !fAnyButtonDown && !( g_pGameRules->IsMultiplayer() && forcerespawn.value > 0 && ( gpGlobals->time > ( m_fDeadTime + 5 ) ) ) ) return; @@ -1345,7 +1356,9 @@ void CBasePlayer::StartDeathCam( void ) } CopyToBodyQue( pev ); - StartObserver( pSpot->v.origin, pSpot->v.v_angle ); + + UTIL_SetOrigin( pev, pSpot->v.origin ); + pev->angles = pev->v_angle = pSpot->v.v_angle; } else { @@ -1353,23 +1366,89 @@ void CBasePlayer::StartDeathCam( void ) TraceResult tr; CopyToBodyQue( pev ); UTIL_TraceLine( pev->origin, pev->origin + Vector( 0, 0, 128 ), ignore_monsters, edict(), &tr ); - StartObserver( tr.vecEndPos, UTIL_VecToAngles( tr.vecEndPos - pev->origin ) ); - return; + + UTIL_SetOrigin( pev, tr.vecEndPos ); + pev->angles = pev->v_angle = UTIL_VecToAngles( tr.vecEndPos - pev->origin ); } + + // start death cam + m_afPhysicsFlags |= PFLAG_OBSERVER; + pev->view_ofs = g_vecZero; + pev->fixangle = TRUE; + pev->solid = SOLID_NOT; + pev->takedamage = DAMAGE_NO; + pev->movetype = MOVETYPE_NONE; + pev->modelindex = 0; } void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) { - m_afPhysicsFlags |= PFLAG_OBSERVER; + // clear any clientside entities attached to this player + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_KILLPLAYERATTACHMENTS ); + WRITE_BYTE( (BYTE)entindex() ); + MESSAGE_END(); + // Holster weapon immediately, to allow it to cleanup + if( m_pActiveItem ) + m_pActiveItem->Holster(); + + if( m_pTank != NULL ) + { + m_pTank->Use( this, this, USE_OFF, 0 ); + m_pTank = NULL; + } + + // clear out the suit message cache so we don't keep chattering + SetSuitUpdate( NULL, FALSE, 0 ); + + // Tell Ammo Hud that the player is dead + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0XFF ); + WRITE_BYTE( 0xFF ); + MESSAGE_END(); + + // reset FOV + m_iFOV = m_iClientFOV = 0; + pev->fov = m_iFOV; + MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); + WRITE_BYTE( 0 ); + MESSAGE_END(); + + // Setup flags + m_iHideHUD = ( HIDEHUD_HEALTH | HIDEHUD_WEAPONS ); + m_afPhysicsFlags |= PFLAG_OBSERVER; + pev->effects = EF_NODRAW; pev->view_ofs = g_vecZero; pev->angles = pev->v_angle = vecViewAngle; pev->fixangle = TRUE; pev->solid = SOLID_NOT; pev->takedamage = DAMAGE_NO; pev->movetype = MOVETYPE_NONE; - pev->modelindex = 0; + ClearBits( m_afPhysicsFlags, PFLAG_DUCKING ); + ClearBits( pev->flags, FL_DUCKING ); + pev->deadflag = DEAD_RESPAWNABLE; + pev->health = 1; + + // Clear out the status bar + m_fInitHUD = TRUE; + + pev->team = 0; + MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo ); + WRITE_BYTE( ENTINDEX(edict()) ); + WRITE_STRING( "" ); + MESSAGE_END(); + + // Remove all the player's stuff + RemoveAllItems( FALSE ); + + // Move them to the new position UTIL_SetOrigin( pev, vecPosition ); + + // Find a player to watch + m_flNextObserverInput = 0; + Observer_SetMode( m_iObserverLastMode ); } // @@ -1379,6 +1458,9 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) void CBasePlayer::PlayerUse( void ) { + if( IsObserver() ) + return; + // Was use pressed or released? if( !( ( pev->button | m_afButtonPressed | m_afButtonReleased) & IN_USE ) ) return; @@ -1747,6 +1829,16 @@ void CBasePlayer::PreThink( void ) CheckSuitUpdate(); + // Observer Button Handling + if( IsObserver() ) + { + Observer_HandleButtons(); + Observer_CheckTarget(); + Observer_CheckProperties(); + pev->impulse = 0; + return; + } + if( pev->deadflag >= DEAD_DYING ) { PlayerDeathThink(); @@ -3767,6 +3859,9 @@ void CBasePlayer::UpdateClientData( void ) g_pGameRules->InitHUD( this ); m_fGameHUDInitialized = TRUE; + + m_iObserverLastMode = OBS_ROAMING; + if( g_pGameRules->IsMultiplayer() ) { FireTargets( "game_playerjoin", this, this, USE_TOGGLE, 0 ); @@ -3807,7 +3902,10 @@ void CBasePlayer::UpdateClientData( void ) if( pev->health != m_iClientHealth ) { - int iHealth = max( pev->health, 0 ); // make sure that no negative health values are sent +#define clamp( val, min, max ) ( ((val) > (max)) ? (max) : ( ((val) < (min)) ? (min) : (val) ) ) + int iHealth = clamp( pev->health, 0, 255 ); // make sure that no negative health values are sent + if( pev->health > 0.0f && pev->health <= 1.0f ) + iHealth = 1; // send "health" update message MESSAGE_BEGIN( MSG_ONE, gmsgHealth, NULL, pev ); @@ -4336,7 +4434,8 @@ void CBasePlayer::DropPlayerItem( char *pszItemName ) // item we want to drop and hit a BREAK; pWeapon is the item. if( pWeapon ) { - g_pGameRules->GetNextBestWeapon( this, pWeapon ); + if( !g_pGameRules->GetNextBestWeapon( this, pWeapon ) ) + return; // can't drop the item they asked for, may be our last item or something we can't holster UTIL_MakeVectors( pev->angles ); diff --git a/dlls/player.h b/dlls/player.h index e75787ee..cb2bddf8 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -86,6 +86,18 @@ enum sbar_data class CBasePlayer : public CBaseMonster { public: + // Spectator camera + void Observer_FindNextPlayer( bool bReverse ); + void Observer_HandleButtons(); + void Observer_SetMode( int iMode ); + void Observer_CheckTarget(); + void Observer_CheckProperties(); + EHANDLE m_hObserverTarget; + float m_flNextObserverInput; + int m_iObserverWeapon; // weapon of current tracked target + int m_iObserverLastMode;// last used observer mode + int IsObserver() { return pev->iuser1; }; + int random_seed; // See that is shared between client & server for shared weapons code int m_iPlayerSound;// the index of the sound list slot reserved for this player diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 1fec5cf1..95c9132a 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -297,7 +297,7 @@ void CRpg::Reload( void ) // Set the next attack time into the future so that WeaponIdle will get called more often // than reload, allowing the RPG LTD to be updated - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); if( m_cActiveRockets && m_fSpotActive ) { @@ -463,7 +463,7 @@ void CRpg::PrimaryAttack() m_iClip--; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5; } else diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 48ec5b9a..05d1fc8c 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -354,7 +354,7 @@ void CSatchel::PrimaryAttack() } m_chargeReady = 2; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; break; @@ -401,7 +401,7 @@ void CSatchel::Throw( void ) m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; } } @@ -442,7 +442,7 @@ void CSatchel::WeaponIdle( void ) // use tripmine animations strcpy( m_pPlayer->m_szAnimExtention, "trip" ); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; m_chargeReady = 0; break; diff --git a/dlls/saverestore.h b/dlls/saverestore.h index f76613e8..a9ad2c54 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -59,7 +59,7 @@ public: void WriteVector( const char *pname, const float *value, int count ); // Save a vector void WritePositionVector( const char *pname, const Vector &value ); // Offset for landmark if necessary void WritePositionVector( const char *pname, const float *value, int count ); // array of pos vectors - void WriteFunction( const char *pname, const int *value, int count ); // Save a function pointer + void WriteFunction( const char *pname, void **value, int count ); // Save a function pointer int WriteEntVars( const char *pname, entvars_t *pev ); // Save entvars_t (entvars_t) int WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 8c96e99c..595561e2 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -119,7 +119,7 @@ void CShotgun::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); return; } @@ -172,7 +172,7 @@ void CShotgun::PrimaryAttack() if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.5; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.75; if( m_iClip != 0 ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0; @@ -187,7 +187,7 @@ void CShotgun::SecondaryAttack( void ) if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.15 ); return; } @@ -243,7 +243,7 @@ void CShotgun::SecondaryAttack( void ) if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.95; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.5; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.5; if( m_iClip != 0 ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0; @@ -269,7 +269,7 @@ void CShotgun::Reload( void ) m_fInSpecialReload = 1; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.0; + m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; return; } diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index 22200b74..30ddda62 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -533,7 +533,7 @@ void CSqueak::PrimaryAttack() m_fJustThrown = 1; - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.3 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; } } diff --git a/dlls/subs.cpp b/dlls/subs.cpp index bc7baf18..5ebe757b 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -415,6 +415,14 @@ After moving, set origin to exact final destination, call "move done" function */ void CBaseToggle::LinearMoveDone( void ) { + Vector delta = m_vecFinalDest - pev->origin; + float error = delta.Length(); + if( error > 0.03125 ) + { + LinearMove( m_vecFinalDest, 100 ); + return; + } + UTIL_SetOrigin( pev, m_vecFinalDest ); pev->velocity = g_vecZero; pev->nextthink = -1; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index d7f9483c..958f899f 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -688,7 +688,7 @@ void PlayCDTrack( int iTrack ) if( iTrack == -1 ) { - CLIENT_COMMAND( pClient, "cd pause\n" ); + CLIENT_COMMAND( pClient, "cd stop\n" ); } else { diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index f04d906a..e2ed0817 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -470,7 +470,7 @@ void CTripmine::PrimaryAttack( void ) }*/ - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.3 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } diff --git a/dlls/util.cpp b/dlls/util.cpp index d1fceb0a..4fc0d51a 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1886,7 +1886,7 @@ void CSave::WritePositionVector( const char *pname, const float *value, int coun } } -void CSave::WriteFunction( const char *pname, const int *data, int count ) +void CSave::WriteFunction( const char *pname, void **data, int count ) { const char *functionName; @@ -2042,7 +2042,7 @@ int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFi WriteInt( pTest->fieldName, (int *)(char *)pOutputData, pTest->fieldSize ); break; case FIELD_FUNCTION: - WriteFunction( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); + WriteFunction( pTest->fieldName, (void **)pOutputData, pTest->fieldSize ); break; default: ALERT( at_error, "Bad field type\n" ); diff --git a/dlls/util.h b/dlls/util.h index e8aee878..f8ae0b6a 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -37,7 +37,7 @@ extern globalvars_t *gpGlobals; #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) #if !defined __amd64__ || defined(CLIENT_DLL) -#define MAKE_STRING(str) ((int)(size_t)str - (int)(size_t)STRING(0)) +#define MAKE_STRING(str) ((size_t)str - (size_t)STRING(0)) #else #define MAKE_STRING ALLOC_STRING #endif diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index ff03bbfc..ee2a8547 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -612,6 +612,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()] ) @@ -943,6 +948,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; } @@ -1130,6 +1136,36 @@ 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 5112254a..3e6fc5ce 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -331,6 +331,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 @@ -345,6 +346,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 diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index 7fe416c7..b20293c1 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -169,13 +169,15 @@ void CZombie::IdleSound( void ) int pitch = 95 + RANDOM_LONG( 0, 9 ); // Play a random idle sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) -1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pIdleSounds[RANDOM_LONG( 0, ARRAYSIZE( pIdleSounds ) -1 )], 1.0, ATTN_NORM, 0, pitch ); } void CZombie::AttackSound( void ) { + int pitch = 95 + RANDOM_LONG( 0, 9 ); + // Play a random attack sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, 100 + RANDOM_LONG( -5, 5 ) ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, pAttackSounds[RANDOM_LONG( 0, ARRAYSIZE( pAttackSounds ) - 1 )], 1.0, ATTN_NORM, 0, pitch ); } //========================================================= diff --git a/engine/eiface.h b/engine/eiface.h index 903451f5..3419e5bd 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -57,7 +57,8 @@ typedef enum { force_exactfile, // File on client must exactly match server's file force_model_samebounds, // For model files only, the geometry must fit in the same bbox - force_model_specifybounds // For model files only, the geometry must fit in the specified bbox + force_model_specifybounds, // For model files only, the geometry must fit in the specified bbox + force_model_specifybounds_if_avail // For Steam model files only, the geometry must fit in the specified bbox (if the file is available) } FORCE_TYPE; // Returned by TraceLine @@ -88,7 +89,7 @@ typedef struct int fPlayTrack; } CDStatus; -typedef unsigned long CRC32_t; +typedef unsigned int CRC32_t; // Engine hands this to DLLs for functionality callbacks typedef struct enginefuncs_s @@ -156,7 +157,7 @@ typedef struct enginefuncs_s void (*pfnCVarSetString)( const char *szVarName, const char *szValue ); void (*pfnAlertMessage)( ALERT_TYPE atype, char *szFmt, ... ); void (*pfnEngineFprintf)( FILE *pfile, char *szFmt, ... ); - void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, long cb ); + void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, int cb ); void* (*pfnPvEntPrivateData)( edict_t *pEdict ); void (*pfnFreeEntPrivateData)( edict_t *pEdict ); const char *(*pfnSzFromIndex)( int iString ); @@ -171,8 +172,8 @@ typedef struct enginefuncs_s int (*pfnRegUserMsg)( const char *pszName, int iSize ); void (*pfnAnimationAutomove)( const edict_t* pEdict, float flTime ); void (*pfnGetBonePosition)( const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - unsigned long (*pfnFunctionFromName)( const char *pName ); - const char *(*pfnNameForFunction)( unsigned long function ); + unsigned int (*pfnFunctionFromName)( const char *pName ); + const char *(*pfnNameForFunction)( unsigned int function ); void (*pfnClientPrintf)( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients void (*pfnServerPrint)( const char *szMsg ); const char *(*pfnCmd_Args)( void ); // these 3 added @@ -183,7 +184,7 @@ typedef struct enginefuncs_s void (*pfnCRC32_ProcessBuffer)( CRC32_t *pulCRC, void *p, int len ); void (*pfnCRC32_ProcessByte)( CRC32_t *pulCRC, unsigned char ch ); CRC32_t (*pfnCRC32_Final)( CRC32_t pulCRC ); - long (*pfnRandomLong)( long lLow, long lHigh ); + int (*pfnRandomLong)( int lLow, int lHigh ); float (*pfnRandomFloat)( float flLow, float flHigh ); void (*pfnSetView)( const edict_t *pClient, const edict_t *pViewent ); float (*pfnTime)( void ); @@ -276,7 +277,7 @@ typedef struct KeyValueData_s char *szClassName; // in: entity classname char *szKeyName; // in: name of key char *szValue; // in: value of key - long fHandled; // out: DLL sets to true if key-value pair was understood + int fHandled; // out: DLL sets to true if key-value pair was understood } KeyValueData; @@ -354,7 +355,7 @@ typedef enum _fieldtypes FIELD_TYPECOUNT // MUST BE LAST } FIELDTYPE; -#ifndef offsetof +#if !defined(offsetof) && !defined(GNUC) #define offsetof(s,m) (size_t)&(((s *)0)->m) #endif diff --git a/engine/shake.h b/engine/shake.h index c644a476..b2e88a33 100644 --- a/engine/shake.h +++ b/engine/shake.h @@ -36,7 +36,7 @@ extern int gmsgFade; #define FFADE_OUT 0x0001 // Fade out (not in) #define FFADE_MODULATE 0x0002 // Modulate (don't blend) #define FFADE_STAYOUT 0x0004 // ignores the duration, stays faded out until new ScreenFade message received - +#define FFADE_LONGFADE 0x0008 // used to indicate the fade can be longer than 16 seconds (added for czero) // This structure is sent over the net to describe a screen fade event typedef struct @@ -47,4 +47,4 @@ typedef struct byte r, g, b, a; // fade to color ( max alpha ) } ScreenFade; -#endif // SHAKE_H \ No newline at end of file +#endif // SHAKE_H diff --git a/engine/studio.h b/engine/studio.h index b5b709bb..cd572419 100644 --- a/engine/studio.h +++ b/engine/studio.h @@ -33,14 +33,14 @@ Studio models are position independent, so the cache manager can move them. // studio limits #define MAXSTUDIOTRIANGLES 32768 // max triangles per model #define MAXSTUDIOVERTS 4096 // max vertices per submodel -#define MAXSTUDIOSEQUENCES 256 // total animation sequences +#define MAXSTUDIOSEQUENCES 2048 // total animation sequences #define MAXSTUDIOSKINS 256 // total textures #define MAXSTUDIOSRCBONES 512 // bones allowed at source movement #define MAXSTUDIOBONES 128 // total bones actually used #define MAXSTUDIOMODELS 32 // sub-models per model #define MAXSTUDIOBODYPARTS 32 // body parts per submodel #define MAXSTUDIOGROUPS 16 // sequence groups (e.g. barney01.mdl, barney02.mdl, e.t.c) -#define MAXSTUDIOANIMATIONS 512 // max frames per sequence +#define MAXSTUDIOANIMATIONS 2048 // max frames per sequence #define MAXSTUDIOMESHES 256 // max textures per model #define MAXSTUDIOEVENTS 1024 // events per model #define MAXSTUDIOPIVOTS 256 // pivot points @@ -214,10 +214,8 @@ typedef struct { char label[32]; // textual name char name[64]; // file name - cache_user_t cache; // cache index pointer -#ifndef __amd64 - int data; // hack for group 0 -#endif + int unused1; // // was "cache" - index pointer + int unused2; // was "data" - hack for group 0 } mstudioseqgroup_t; // sequence descriptions diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index d29bff19..cd17ce54 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -201,7 +201,7 @@ typedef struct playermove_s pmtrace_t (*PM_PlayerTrace)( float *start, float *end, int traceFlags, int ignore_pe ); #endif struct pmtrace_s *(*PM_TraceLine)( float *start, float *end, int flags, int usehulll, int ignore_pe ); - long (*RandomLong)( long lLow, long lHigh ); + int (*RandomLong)( int lLow, int lHigh ); float (*RandomFloat)( float flLow, float flHigh ); int (*PM_GetModelType)( struct model_s *mod ); void (*PM_GetModelBounds)( struct model_s *mod, float *mins, float *maxs ); diff --git a/pm_shared/pm_materials.h b/pm_shared/pm_materials.h index cd1051d2..e625b4fc 100644 --- a/pm_shared/pm_materials.h +++ b/pm_shared/pm_materials.h @@ -28,4 +28,5 @@ #define CHAR_TEX_COMPUTER 'P' #define CHAR_TEX_GLASS 'Y' #define CHAR_TEX_FLESH 'F' +#define CHAR_TEX_SNOW 'N' #endif//PM_MATERIALS_H diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index de855a50..7a1fb966 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -87,6 +87,8 @@ playermove_t *pmove = NULL; #define PLAYER_LONGJUMP_SPEED 350 // how fast we longjump +#define PLAYER_DUCKING_MULTIPLIER 0.333 + // double to float warning #pragma warning(disable : 4244) #define max(a, b) (((a) > (b)) ? (a) : (b)) @@ -2017,9 +2019,9 @@ void PM_Duck( void ) if( pmove->flags & FL_DUCKING ) { - pmove->cmd.forwardmove *= 0.333; - pmove->cmd.sidemove *= 0.333; - pmove->cmd.upmove *= 0.333; + pmove->cmd.forwardmove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.sidemove *= PLAYER_DUCKING_MULTIPLIER; + pmove->cmd.upmove *= PLAYER_DUCKING_MULTIPLIER; } if( ( pmove->cmd.buttons & IN_DUCK ) || ( pmove->bInDuck ) || ( pmove->flags & FL_DUCKING ) ) @@ -2110,16 +2112,24 @@ void PM_LadderMove( physent_t *pLadder ) { float forward = 0, right = 0; vec3_t vpn, v_right; + float flSpeed = MAX_CLIMB_SPEED; + + // they shouldn't be able to move faster than their maxspeed + if( flSpeed > pmove->maxspeed ) + flSpeed = pmove->maxspeed; AngleVectors( pmove->angles, vpn, v_right, NULL ); + + if( pmove->flags & FL_DUCKING ) + flSpeed *= PLAYER_DUCKING_MULTIPLIER; if( pmove->cmd.buttons & IN_BACK ) - forward -= MAX_CLIMB_SPEED; + forward -= flSpeed; if( pmove->cmd.buttons & IN_FORWARD ) - forward += MAX_CLIMB_SPEED; + forward += flSpeed; if( pmove->cmd.buttons & IN_MOVELEFT ) - right -= MAX_CLIMB_SPEED; + right -= flSpeed; if( pmove->cmd.buttons & IN_MOVERIGHT ) - right += MAX_CLIMB_SPEED; + right += flSpeed; if( pmove->cmd.buttons & IN_JUMP ) { From ecaba0de22483417add665dfbd47271ed058ff10 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 26 Jun 2017 07:06:27 +0500 Subject: [PATCH 020/199] Upload missing file. Fix build. --- cl_dll/com_weapons.cpp | 2 +- cl_dll/com_weapons.h | 2 +- cl_dll/hl/hl_baseentity.cpp | 1 + cl_dll/hl/hl_weapons.cpp | 21 --- dlls/Android.mk | 1 + dlls/CMakeLists.txt | 1 + dlls/Makefile | 1 + dlls/observer.cpp | 268 ++++++++++++++++++++++++++++++++++++ engine/cdll_int.h | 4 +- engine/menu_int.h | 4 +- 10 files changed, 278 insertions(+), 27 deletions(-) create mode 100644 dlls/observer.cpp diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index 4f539df9..cc693b88 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -283,7 +283,7 @@ unsigned short stub_PrecacheEvent( int type, const char *s ) return 0; } -const char *stub_NameForFunction( unsigned long function ) +const char *stub_NameForFunction( unsigned int function ) { return "func"; } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 7e1fdd77..4dd75203 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -34,7 +34,7 @@ void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); int stub_PrecacheModel( char* s ); int stub_PrecacheSound( char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); -const char *stub_NameForFunction( unsigned long function ); +const char *stub_NameForFunction( unsigned int function ); void stub_SetModel( struct edict_s *e, const char *m ); extern cvar_t *cl_lw; 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/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 6d555b4c..8c6909e3 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -560,27 +560,6 @@ void UTIL_ParticleLine( CBasePlayer *player, float *start, float *end, float lif gEngfuncs.pEfxAPI->R_ParticleLine( start, end, r, g, b, life ); } -/* -===================== -CBasePlayerWeapon::PrintState - -For debugging, print out state variables to log file -===================== -*/ -void CBasePlayerWeapon::PrintState( void ) -{ - COM_Log( "c:\\hl.log", "%.4f ", gpGlobals->time ); - COM_Log( "c:\\hl.log", "%.4f ", m_pPlayer->m_flNextAttack ); - COM_Log( "c:\\hl.log", "%.4f ", m_flNextPrimaryAttack ); - COM_Log( "c:\\hl.log", "%.4f ", m_flTimeWeaponIdle - gpGlobals->time ); - COM_Log( "c:\\hl.log", "%i ", m_iClip ); -} - -int RandomLong( int a, int b ) -{ - return gEngfuncs.pfnRandomLong( a, b ); -} - /* ===================== HUD_InitClientWeapons diff --git a/dlls/Android.mk b/dlls/Android.mk index 7fcdf581..b160c424 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -90,6 +90,7 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ multiplay_gamerules.cpp \ nihilanth.cpp \ nodes.cpp \ + observer.cpp \ osprey.cpp \ pathcorner.cpp \ plane.cpp \ diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index cc0063b4..e0b6a8b3 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -92,6 +92,7 @@ set (SVDLL_SOURCES multiplay_gamerules.cpp nihilanth.cpp nodes.cpp + observer.cpp osprey.cpp pathcorner.cpp plane.cpp diff --git a/dlls/Makefile b/dlls/Makefile index c75731d5..9c3a84f2 100644 --- a/dlls/Makefile +++ b/dlls/Makefile @@ -129,6 +129,7 @@ OBJ = \ $(DLL_OBJDIR)/multiplay_gamerules.o \ $(DLL_OBJDIR)/nihilanth.o \ $(DLL_OBJDIR)/nodes.o \ + $(DLL_OBJDIR)/observer.cpp \^M $(DLL_OBJDIR)/osprey.o \ $(DLL_OBJDIR)/pathcorner.o \ $(DLL_OBJDIR)/plane.o \ diff --git a/dlls/observer.cpp b/dlls/observer.cpp new file mode 100644 index 00000000..0eda7490 --- /dev/null +++ b/dlls/observer.cpp @@ -0,0 +1,268 @@ +//=========== (C) Copyright 1999 Valve, L.L.C. All rights reserved. =========== +// +// The copyright to the contents herein is the property of Valve, L.L.C. +// The contents may be used and/or copied only with the written permission of +// Valve, L.L.C., or in accordance with the terms and conditions stipulated in +// the agreement/contract under which the contents have been supplied. +// +// Purpose: Functionality for the observer chase camera +// +// $Workfile: $ +// $Date: $ +// +//----------------------------------------------------------------------------- +// $Log: $ +// +// $NoKeywords: $ +//============================================================================= +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "player.h" +#include "weapons.h" +#include "pm_shared.h" + +extern int gmsgCurWeapon; +extern int gmsgSetFOV; +// Find the next client in the game for this player to spectate +void CBasePlayer::Observer_FindNextPlayer( bool bReverse ) +{ + // MOD AUTHORS: Modify the logic of this function if you want to restrict the observer to watching + // only a subset of the players. e.g. Make it check the target's team. + int iStart; + if( m_hObserverTarget ) + iStart = ENTINDEX( m_hObserverTarget->edict() ); + else + iStart = ENTINDEX( edict() ); + int iCurrent = iStart; + m_hObserverTarget = NULL; + int iDir = bReverse ? -1 : 1; + + do + { + iCurrent += iDir; + + // Loop through the clients + if( iCurrent > gpGlobals->maxClients ) + iCurrent = 1; + if( iCurrent < 1 ) + iCurrent = gpGlobals->maxClients; + + CBaseEntity *pEnt = UTIL_PlayerByIndex( iCurrent ); + if( !pEnt ) + continue; + if( pEnt == this ) + continue; + // Don't spec observers or players who haven't picked a class yet + if( ( (CBasePlayer*)pEnt )->IsObserver() || ( pEnt->pev->effects & EF_NODRAW ) ) + continue; + + // MOD AUTHORS: Add checks on target here. + m_hObserverTarget = pEnt; + break; + }while( iCurrent != iStart ); + + // Did we find a target? + if( m_hObserverTarget ) + { + // Move to the target + UTIL_SetOrigin( pev, m_hObserverTarget->pev->origin ); + + // ALERT( at_console, "Now Tracking %s\n", STRING( m_hObserverTarget->pev->netname ) ); + + // Store the target in pev so the physics DLL can get to it + if( pev->iuser1 != OBS_ROAMING ) + pev->iuser2 = ENTINDEX( m_hObserverTarget->edict() ); + } +} + +// Handle buttons in observer mode +void CBasePlayer::Observer_HandleButtons() +{ + // Slow down mouse clicks + if( m_flNextObserverInput > gpGlobals->time ) + return; + + // Jump changes from modes: Chase to Roaming + if( m_afButtonPressed & IN_JUMP ) + { + if( pev->iuser1 == OBS_CHASE_LOCKED ) + Observer_SetMode( OBS_CHASE_FREE ); + else if( pev->iuser1 == OBS_CHASE_FREE ) + Observer_SetMode( OBS_IN_EYE ); + else if( pev->iuser1 == OBS_IN_EYE ) + Observer_SetMode( OBS_ROAMING ); + else if( pev->iuser1 == OBS_ROAMING ) + Observer_SetMode( OBS_MAP_FREE ); + else if( pev->iuser1 == OBS_MAP_FREE ) + Observer_SetMode( OBS_MAP_CHASE ); + else + Observer_SetMode( OBS_CHASE_FREE ); // don't use OBS_CHASE_LOCKED anymore + + m_flNextObserverInput = gpGlobals->time + 0.2; + } + + // Attack moves to the next player + if ( m_afButtonPressed & IN_ATTACK )//&& pev->iuser1 != OBS_ROAMING ) + { + Observer_FindNextPlayer( false ); + + m_flNextObserverInput = gpGlobals->time + 0.2; + } + + // Attack2 moves to the prev player + if ( m_afButtonPressed & IN_ATTACK2)// && pev->iuser1 != OBS_ROAMING ) + { + Observer_FindNextPlayer( true ); + + m_flNextObserverInput = gpGlobals->time + 0.2; + } +} + +void CBasePlayer::Observer_CheckTarget() +{ + if( pev->iuser1 == OBS_ROAMING ) + return; + + // try to find a traget if we have no current one + if( m_hObserverTarget == NULL ) + { + Observer_FindNextPlayer( false ); + + if( m_hObserverTarget == NULL ) + { + // no target found at all + + int lastMode = pev->iuser1; + + Observer_SetMode( OBS_ROAMING ); + + m_iObserverLastMode = lastMode; // don't overwrite users lastmode + + return; // we still have np target return + } + } + + CBasePlayer* target = (CBasePlayer*)( UTIL_PlayerByIndex( ENTINDEX( m_hObserverTarget->edict() ) ) ); + + if( !target ) + { + Observer_FindNextPlayer( false ); + return; + } + + // check taget + if( target->pev->deadflag == DEAD_DEAD ) + { + if( ( target->m_fDeadTime + 2.0f ) < gpGlobals->time ) + { + // 3 secs after death change target + Observer_FindNextPlayer( false ); + return; + } + } +} + +void CBasePlayer::Observer_CheckProperties() +{ + // try to find a traget if we have no current one + if( pev->iuser1 == OBS_IN_EYE && m_hObserverTarget != NULL ) + { + CBasePlayer* target = (CBasePlayer*)( UTIL_PlayerByIndex( ENTINDEX( m_hObserverTarget->edict() ) ) ); + + if( !target ) + return; + + int weapon = ( target->m_pActiveItem != NULL ) ? target->m_pActiveItem->m_iId : 0; + // use fov of tracked client + if( m_iFOV != target->m_iFOV || m_iObserverWeapon != weapon ) + { + m_iFOV = target->m_iFOV; + m_iClientFOV = m_iFOV; + // write fov before wepon data, so zoomed crosshair is set correctly + MESSAGE_BEGIN( MSG_ONE, gmsgSetFOV, NULL, pev ); + WRITE_BYTE( m_iFOV ); + MESSAGE_END(); + + m_iObserverWeapon = weapon; + //send weapon update + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( 1 ); // 1 = current weapon, not on target + WRITE_BYTE( m_iObserverWeapon ); + WRITE_BYTE( 0 ); // clip + MESSAGE_END(); + } + } + else + { + m_iFOV = 90; + + if( m_iObserverWeapon != 0 ) + { + m_iObserverWeapon = 0; + + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( 1 ); // 1 = current weapon + WRITE_BYTE( m_iObserverWeapon ); + WRITE_BYTE( 0 ); // clip + MESSAGE_END(); + } + } +} + +// Attempt to change the observer mode +void CBasePlayer::Observer_SetMode( int iMode ) +{ + + // Just abort if we're changing to the mode we're already in + if( iMode == pev->iuser1 ) + return; + + // is valid mode ? + if( iMode < OBS_CHASE_LOCKED || iMode > OBS_MAP_CHASE ) + iMode = OBS_IN_EYE; // now it is + // verify observer target again + if( m_hObserverTarget != NULL ) + { + CBaseEntity *pEnt = m_hObserverTarget; + + if( ( pEnt == this ) || ( pEnt == NULL ) ) + m_hObserverTarget = NULL; + else if( ( (CBasePlayer*)pEnt )->IsObserver() || ( pEnt->pev->effects & EF_NODRAW ) ) + m_hObserverTarget = NULL; + } + + // set spectator mode + pev->iuser1 = iMode; + + // if we are not roaming, we need a valid target to track + if( ( iMode != OBS_ROAMING ) && ( m_hObserverTarget == NULL ) ) + { + Observer_FindNextPlayer( false ); + + // if we didn't find a valid target switch to roaming + if( m_hObserverTarget == NULL ) + { + ClientPrint( pev, HUD_PRINTCENTER, "#Spec_NoTarget" ); + pev->iuser1 = OBS_ROAMING; + } + } + + // set target if not roaming + if( pev->iuser1 == OBS_ROAMING ) + { + pev->iuser2 = 0; + } + else + pev->iuser2 = ENTINDEX( m_hObserverTarget->edict() ); + + pev->iuser3 = 0; // clear second target from death cam + + // print spepctaor mode on client screen + + char modemsg[16]; + sprintf( modemsg,"#Spec_Mode%i", pev->iuser1 ); + ClientPrint( pev, HUD_PRINTCENTER, modemsg ); + + m_iObserverLastMode = iMode; +} diff --git a/engine/cdll_int.h b/engine/cdll_int.h index eaa7f4e8..a0dc59c2 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -211,7 +211,7 @@ typedef struct cl_enginefuncs_s void (*pfnPlaybackEvent)( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); void (*pfnWeaponAnim)( int iAnim, int body ); float (*pfnRandomFloat)( float flLow, float flHigh ); - long (*pfnRandomLong)( long lLow, long lHigh ); + int (*pfnRandomLong)( int lLow, int lHigh ); void (*pfnHookEvent)( char *name, void ( *pfnEvent )( struct event_args_s *args )); int (*Con_IsVisible) (); const char *(*pfnGetGameDirectory)( void ); @@ -311,4 +311,4 @@ typedef struct cl_enginefuncs_s } #endif -#endif//CDLL_INT_H \ No newline at end of file +#endif//CDLL_INT_H diff --git a/engine/menu_int.h b/engine/menu_int.h index 53b0725a..69c10ce4 100644 --- a/engine/menu_int.h +++ b/engine/menu_int.h @@ -155,7 +155,7 @@ typedef struct ui_enginefuncs_s // menu interface is freezed at version 0.75 // new functions starts here float (*pfnRandomFloat)( float flLow, float flHigh ); - long (*pfnRandomLong)( long lLow, long lHigh ); + int (*pfnRandomLong)( int lLow, int lHigh ); void (*pfnSetCursor)( void *hCursor ); // change cursor int (*pfnIsMapValid)( char *filename ); @@ -185,4 +185,4 @@ typedef struct typedef int (*MENUAPI)( UI_FUNCTIONS *pFunctionTable, ui_enginefuncs_t* engfuncs, ui_globalvars_t *pGlobals ); -#endif//MENU_INT_H \ No newline at end of file +#endif//MENU_INT_H From d217780789a2ca207bde3e8f50f7ec142f274b92 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 26 Jun 2017 07:41:01 +0500 Subject: [PATCH 021/199] Try fix build again. --- dlls/client.cpp | 3 ++- dlls/util.cpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 74be0ea3..72538b02 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -38,6 +38,7 @@ #include "weaponinfo.h" #include "usercmd.h" #include "netadr.h" +#include "pm_shared.h" extern DLL_GLOBAL ULONG g_ulModelIndexPlayer; extern DLL_GLOBAL BOOL g_fGameOver; @@ -550,7 +551,7 @@ void ClientCommand( edict_t *pEntity ) { GetClassPtr( (CBasePlayer *)pev )->SelectLastItem(); } - else if( FStrEq( pcmd, "spectate" ) // clients wants to become a spectator + else if( FStrEq( pcmd, "spectate" ) ) // clients wants to become a spectator { // always allow proxies to become a spectator if( ( pev->flags & FL_PROXY ) || allow_spectators.value ) diff --git a/dlls/util.cpp b/dlls/util.cpp index 4fc0d51a..9c7d9803 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1890,7 +1890,7 @@ void CSave::WriteFunction( const char *pname, void **data, int count ) { const char *functionName; - functionName = NAME_FOR_FUNCTION( *data ); + functionName = NAME_FOR_FUNCTION( (unsigned int)(size_t)*data ); if( functionName ) BufferField( pname, strlen( functionName ) + 1, functionName ); else From 2faa732aa1d3fa90937c0aac01e82cb836e2f34c Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 29 Jun 2017 18:56:03 +0500 Subject: [PATCH 022/199] Apply some @AlliedModders's patches. --- cl_dll/ammo.cpp | 4 +-- cl_dll/com_weapons.cpp | 8 ++--- cl_dll/com_weapons.h | 8 ++--- cl_dll/death.cpp | 17 +++++----- cl_dll/entity.cpp | 16 ++++----- cl_dll/ev_hldm.cpp | 30 ++++++++-------- cl_dll/geiger.cpp | 56 +++++++++++++++--------------- cl_dll/hl/hl_baseentity.cpp | 12 +++---- cl_dll/hl/hl_weapons.cpp | 8 ++--- cl_dll/hud.h | 12 +++---- cl_dll/hud_redraw.cpp | 10 +++--- cl_dll/message.cpp | 6 ++-- cl_dll/status_icons.cpp | 4 +-- cl_dll/text_message.cpp | 20 +++++------ cl_dll/view.cpp | 8 ++--- common/cvardef.h | 4 +-- dlls/activity.h | 2 +- dlls/activitymap.h | 2 +- dlls/aflock.cpp | 1 - dlls/agrunt.cpp | 6 ++-- dlls/animation.cpp | 6 ++-- dlls/apache.cpp | 5 ++- dlls/barnacle.cpp | 6 ++-- dlls/barney.cpp | 16 ++++----- dlls/basemonster.h | 4 +-- dlls/bigmomma.cpp | 7 ++-- dlls/bmodels.cpp | 4 +-- dlls/bullsquid.cpp | 12 +++---- dlls/buttons.cpp | 20 +++++------ dlls/cbase.cpp | 4 +-- dlls/cbase.h | 7 ++-- dlls/client.cpp | 26 ++++++-------- dlls/combat.cpp | 19 ++++++----- dlls/controller.cpp | 9 +++-- dlls/crossbow.cpp | 3 +- dlls/crowbar.cpp | 4 +-- dlls/decals.h | 2 +- dlls/doors.cpp | 24 ++++++------- dlls/effects.cpp | 18 +++++----- dlls/effects.h | 8 ++--- dlls/egon.cpp | 10 +++--- dlls/enginecallback.h | 8 +++++ dlls/extdll.h | 6 ++++ dlls/func_break.cpp | 13 ++++--- dlls/func_tank.cpp | 24 ++++++------- dlls/gargantua.cpp | 3 +- dlls/gauss.cpp | 9 +++-- dlls/genericmonster.cpp | 2 +- dlls/ggrenade.cpp | 14 ++++---- dlls/gman.cpp | 8 ++--- dlls/h_battery.cpp | 6 ++-- dlls/h_cine.cpp | 4 +-- dlls/h_cycler.cpp | 6 ++-- dlls/hassassin.cpp | 6 ++-- dlls/headcrab.cpp | 4 +-- dlls/healthkit.cpp | 6 ++-- dlls/hgrunt.cpp | 26 +++++++------- dlls/hornet.cpp | 6 ++-- dlls/houndeye.cpp | 2 +- dlls/ichthyosaur.cpp | 8 ++--- dlls/islave.cpp | 20 +++++------ dlls/leech.cpp | 2 +- dlls/lights.cpp | 17 +++++----- dlls/maprules.cpp | 14 ++++---- dlls/monsters.cpp | 22 ++++++------ dlls/monsterstate.cpp | 6 ++-- dlls/mpstubb.cpp | 4 +-- dlls/multiplay_gamerules.cpp | 16 ++++----- dlls/nihilanth.cpp | 44 ++++++++++++------------ dlls/nodes.cpp | 19 +++++++---- dlls/nodes.h | 4 ++- dlls/observer.cpp | 18 +++++----- dlls/osprey.cpp | 8 ++--- dlls/plats.cpp | 8 ++--- dlls/player.cpp | 66 ++++++++++++++++++------------------ dlls/player.h | 4 +-- dlls/satchel.cpp | 4 +-- dlls/saverestore.h | 11 ++++-- dlls/schedule.cpp | 22 ++++++------ dlls/scientist.cpp | 18 +++++----- dlls/scripted.cpp | 4 +-- dlls/skill.cpp | 5 ++- dlls/skill.h | 2 +- dlls/sound.cpp | 12 +++---- dlls/squadmonster.cpp | 12 +++---- dlls/squadmonster.h | 2 +- dlls/squeakgrenade.cpp | 18 +++++----- dlls/talkmonster.cpp | 32 ++++++++--------- dlls/talkmonster.h | 4 +-- dlls/teamplay_gamerules.cpp | 10 +++--- dlls/tentacle.cpp | 9 ++--- dlls/triggers.cpp | 10 +++--- dlls/tripmine.cpp | 8 ++--- dlls/turret.cpp | 18 +++++----- dlls/util.cpp | 20 +++++------ dlls/util.h | 9 ++--- dlls/vector.h | 14 ++++---- dlls/weapons.cpp | 4 +-- dlls/weapons.h | 8 +++-- dlls/world.cpp | 4 +-- dlls/xen.cpp | 6 ++-- dlls/zombie.cpp | 2 +- engine/custom.h | 6 ++++ engine/edict.h | 8 ++++- engine/eiface.h | 50 ++++++++++++++------------- engine/progdefs.h | 8 ++++- pm_shared/pm_debug.c | 2 ++ pm_shared/pm_debug.h | 6 ++++ pm_shared/pm_defs.h | 6 ++++ pm_shared/pm_info.h | 6 ++++ pm_shared/pm_math.c | 2 ++ pm_shared/pm_shared.c | 26 +++++++++----- pm_shared/pm_shared.h | 6 ++++ 113 files changed, 671 insertions(+), 604 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 988bd6fa..860cde42 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -877,11 +877,11 @@ int CHudAmmo::Draw( float flTime ) x = ScreenWidth - ( 8 * AmmoWidth ) - iIconWidth; x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b ); - wrect_t rc; + /*wrect_t rc; rc.top = 0; rc.left = 0; rc.right = AmmoWidth; - rc.bottom = 100; + rc.bottom = 100;*/ int iBarWidth = AmmoWidth / 10; diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index cc693b88..e50de419 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -41,7 +41,7 @@ COM_Log Log debug messages to file ( appends ) ==================== */ -void COM_Log( char *pszFile, char *fmt, ... ) +void COM_Log( const char *pszFile, const char *fmt, ... ) { va_list argptr; char string[1024]; @@ -111,7 +111,7 @@ HUD_PlaySound Play a sound, if we are seeing this command for the first time ===================== */ -void HUD_PlaySound( char *sound, float volume ) +void HUD_PlaySound( const char *sound, float volume ) { if( !g_runfuncs || !g_finalstate ) return; @@ -268,12 +268,12 @@ stub functions for such things as precaching. So we don't have to modify weapon is compiled into both game and client .dlls. ====================== */ -int stub_PrecacheModel( char* s ) +int stub_PrecacheModel( const char* s ) { return 0; } -int stub_PrecacheSound( char* s ) +int stub_PrecacheSound( const char* s ) { return 0; } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 4dd75203..8559e20b 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -20,7 +20,7 @@ extern "C" void _DLLEXPORT HUD_PostRunCmd( struct local_state_s *from, struct local_state_s *to, struct usercmd_s *cmd, int runfuncs, double time, unsigned int random_seed ); } -void COM_Log( char *pszFile, char *fmt, ... ); +void COM_Log( const char *pszFile, const char *fmt, ... ); int CL_IsDead( void ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); @@ -28,11 +28,11 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); int HUD_GetWeaponAnim( void ); void HUD_SendWeaponAnim( int iAnim, int body, int force ); -void HUD_PlaySound( char *sound, float volume ); +void HUD_PlaySound( const char *sound, float volume ); void HUD_PlaybackEvent( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); -int stub_PrecacheModel( char* s ); -int stub_PrecacheSound( char* s ); +int stub_PrecacheModel( const char* s ); +int stub_PrecacheSound( const char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); const char *stub_NameForFunction( unsigned int function ); void stub_SetModel( struct edict_s *e, const char *m ); diff --git a/cl_dll/death.cpp b/cl_dll/death.cpp index 455dfd36..579fc255 100644 --- a/cl_dll/death.cpp +++ b/cl_dll/death.cpp @@ -187,7 +187,8 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu gHUD.m_Scoreboard.GetAllPlayersInfo(); // Get the Killer's name - char *killer_name = g_PlayerInfoList[killer].name; + const char *killer_name = ""; + killer_name = g_PlayerInfoList[killer].name; if( !killer_name ) { killer_name = ""; @@ -201,11 +202,11 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu } // Get the Victim's name - char *victim_name = NULL; + const char *victim_name = ""; // If victim is -1, the killer killed a specific, non-player object (like a sentrygun) - if ( ( (char)victim ) != -1 ) + if( ( (char)victim ) != -1 ) victim_name = g_PlayerInfoList[victim].name; - if ( !victim_name ) + if( !victim_name ) { victim_name = ""; rgDeathNoticeList[i].szVictim[0] = 0; @@ -218,7 +219,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu } // Is it a non-player object kill? - if ( ( (char)victim ) == -1 ) + if( ( (char)victim ) == -1 ) { rgDeathNoticeList[i].iNonPlayerKill = TRUE; @@ -227,10 +228,10 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu } else { - if ( killer == victim || killer == 0 ) + if( killer == victim || killer == 0 ) rgDeathNoticeList[i].iSuicide = TRUE; - if ( !strcmp( killedwith, "d_teammate" ) ) + if( !strcmp( killedwith, "d_teammate" ) ) rgDeathNoticeList[i].iTeamKill = TRUE; } @@ -285,7 +286,7 @@ int CHudDeathNotice::MsgFunc_DeathMsg( const char *pszName, int iSize, void *pbu // replace the code names with the 'real' names if( !strcmp( killedwith + 2, "egon" ) ) strcpy( killedwith, "d_gluon gun" ); - if ( !strcmp( killedwith + 2, "gauss" ) ) + if( !strcmp( killedwith + 2, "gauss" ) ) strcpy( killedwith, "d_tau cannon" ); ConsolePrint( killedwith + 2 ); // skip over the "d_" part diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 07bd0ff3..303a9d25 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -585,10 +585,10 @@ void DLLEXPORT HUD_TempEntUpdate ( static int gTempEntFrame = 0; int i; TEMPENTITY *pTemp, *pnext, *pprev; - float freq, gravity, gravitySlow, life, fastFreq; + float /*freq,*/ gravity, gravitySlow, life, fastFreq; // Nothing to simulate - if ( !*ppTempEntActive ) + if( !*ppTempEntActive ) return; // in order to have tents collide with players, we have to run the player prediction code so @@ -601,7 +601,7 @@ void DLLEXPORT HUD_TempEntUpdate ( gEngfuncs.pEventAPI->EV_PushPMStates(); // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 ); + gEngfuncs.pEventAPI->EV_SetSolidPlayers( -1 ); // !!!BUGBUG -- This needs to be time based gTempEntFrame = ( gTempEntFrame + 1 ) & 31; @@ -623,7 +623,7 @@ void DLLEXPORT HUD_TempEntUpdate ( } pprev = NULL; - freq = client_time * 0.01; + //freq = client_time * 0.01; fastFreq = client_time * 5.5; gravity = -frametime * cl_gravity; gravitySlow = gravity * 0.5; @@ -709,12 +709,12 @@ void DLLEXPORT HUD_TempEntUpdate ( } else if( pTemp->flags & FTENT_SPIRAL ) { - float s, c; + /*float s, c; s = sin( pTemp->entity.baseline.origin[2] + fastFreq ); - c = cos( pTemp->entity.baseline.origin[2] + fastFreq ); + c = cos( pTemp->entity.baseline.origin[2] + fastFreq );*/ - pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (int)(size_t)pTemp ); - pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (int)(size_t)pTemp ); + pTemp->entity.origin[0] += pTemp->entity.baseline.origin[0] * frametime + 8 * sin( client_time * 20 + (size_t)pTemp ); + pTemp->entity.origin[1] += pTemp->entity.baseline.origin[1] * frametime + 4 * sin( client_time * 30 + (size_t)pTemp ); pTemp->entity.origin[2] += pTemp->entity.baseline.origin[2] * frametime; } else diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 9787a839..787e1be8 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -94,7 +94,7 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v char chTextureType = CHAR_TEX_CONCRETE; float fvol; float fvolbar; - char *rgsz[4]; + const char *rgsz[4]; int cnt; float fattn = ATTN_NORM; int entity; @@ -568,7 +568,7 @@ void EV_FireShotGunDouble( event_args_t *args ) vec3_t vecSrc, vecAiming; vec3_t vecSpread; vec3_t up, right, forward; - float flSpread = 0.01; + //float flSpread = 0.01; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -622,7 +622,7 @@ void EV_FireShotGunSingle( event_args_t *args ) vec3_t vecSrc, vecAiming; vec3_t vecSpread; vec3_t up, right, forward; - float flSpread = 0.01; + //float flSpread = 0.01; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -679,7 +679,7 @@ void EV_FireMP5( event_args_t *args ) int shell; vec3_t vecSrc, vecAiming; vec3_t up, right, forward; - float flSpread = 0.01; + //float flSpread = 0.01; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -769,7 +769,7 @@ void EV_FirePython( event_args_t *args ) vec3_t vecSrc, vecAiming; vec3_t up, right, forward; - float flSpread = 0.01; + //float flSpread = 0.01; idx = args->entindex; VectorCopy( args->origin, origin ); @@ -860,16 +860,16 @@ void EV_FireGauss( event_args_t *args ) vec3_t angles; vec3_t velocity; float flDamage = args->fparam1; - int primaryfire = args->bparam1; + //int primaryfire = args->bparam1; int m_fPrimaryFire = args->bparam1; - int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; + //int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; vec3_t vecSrc; vec3_t vecDest; - edict_t *pentIgnore; + //edict_t *pentIgnore; pmtrace_t tr, beam_tr; float flMaxFrac = 1.0; - int nTotal = 0; + //int nTotal = 0; int fHasPunched = 0; int fFirstBeam = 1; int nMaxHits = 10; @@ -980,7 +980,7 @@ void EV_FireGauss( event_args_t *args ) { float n; - pentIgnore = NULL; + //pentIgnore = NULL; n = -DotProduct( tr.plane.normal, forward ); @@ -1412,12 +1412,12 @@ BEAM *pBeam2; void EV_EgonFire( event_args_t *args ) { - int idx, iFireState, iFireMode; + int idx, /*iFireState,*/ iFireMode; vec3_t origin; idx = args->entindex; VectorCopy( args->origin, origin ); - iFireState = args->iparam1; + //iFireState = args->iparam1; iFireMode = args->iparam2; int iStartup = args->bparam1; @@ -1539,13 +1539,13 @@ enum hgun_e void EV_HornetGunFire( event_args_t *args ) { - int idx, iFireMode; + int idx; //, iFireMode; vec3_t origin, angles, vecSrc, forward, right, up; idx = args->entindex; VectorCopy( args->origin, origin ); VectorCopy( args->angles, angles ); - iFireMode = args->iparam1; + //iFireMode = args->iparam1; //Only play the weapon anims if I shot it. if( EV_IsLocal( idx ) ) @@ -1554,7 +1554,7 @@ void EV_HornetGunFire( event_args_t *args ) gEngfuncs.pEventAPI->EV_WeaponAnimation( HGUN_SHOOT, 1 ); } - switch( gEngfuncs.pfnRandomLong( 0 , 2 ) ) + switch( gEngfuncs.pfnRandomLong( 0, 2 ) ) { case 0: gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire1.wav", 1, ATTN_NORM, 0, 100 ); diff --git a/cl_dll/geiger.cpp b/cl_dll/geiger.cpp index 7ccaf1d3..097889b9 100644 --- a/cl_dll/geiger.cpp +++ b/cl_dll/geiger.cpp @@ -65,7 +65,7 @@ int CHudGeiger::Draw( float flTime ) { int pct; float flvol = 0.0f; - int rg[3]; + //int rg[3]; int i; if( m_iGeigerRange < 1000 && m_iGeigerRange > 0 ) @@ -79,61 +79,61 @@ int CHudGeiger::Draw( float flTime ) { pct = 2; flvol = 0.4; //Con_Printf( "range > 600\n" ); - rg[0] = 1; - rg[1] = 1; + //rg[0] = 1; + //rg[1] = 1; i = 2; } else if( m_iGeigerRange > 500 ) { pct = 4; flvol = 0.5; //Con_Printf( "range > 500\n" ); - rg[0] = 1; - rg[1] = 2; + //rg[0] = 1; + //rg[1] = 2; i = 2; } else if( m_iGeigerRange > 400 ) { pct = 8; flvol = 0.6; //Con_Printf( "range > 400\n" ); - rg[0] = 1; - rg[1] = 2; - rg[2] = 3; + //rg[0] = 1; + //rg[1] = 2; + //rg[2] = 3; i = 3; } else if( m_iGeigerRange > 300 ) { pct = 8; flvol = 0.7; //Con_Printf( "range > 300\n" ); - rg[0] = 2; - rg[1] = 3; - rg[2] = 4; + //rg[0] = 2; + //rg[1] = 3; + //rg[2] = 4; i = 3; } else if( m_iGeigerRange > 200 ) { pct = 28; flvol = 0.78; //Con_Printf( "range > 200\n" ); - rg[0] = 2; - rg[1] = 3; - rg[2] = 4; + //rg[0] = 2; + //rg[1] = 3; + //rg[2] = 4; i = 3; } else if( m_iGeigerRange > 150 ) { pct = 40; flvol = 0.80; //Con_Printf( "range > 150\n" ); - rg[0] = 3; - rg[1] = 4; - rg[2] = 5; + //rg[0] = 3; + //rg[1] = 4; + //rg[2] = 5; i = 3; } else if( m_iGeigerRange > 100 ) { pct = 60; flvol = 0.85; //Con_Printf( "range > 100\n" ); - rg[0] = 3; - rg[1] = 4; - rg[2] = 5; + //rg[0] = 3; + //rg[1] = 4; + //rg[2] = 5; i = 3; } else if( m_iGeigerRange > 75 ) @@ -141,29 +141,29 @@ int CHudGeiger::Draw( float flTime ) pct = 80; flvol = 0.9; //Con_Printf( "range > 75\n" ); //gflGeigerDelay = cl.time + GEIGERDELAY * 0.75; - rg[0] = 4; - rg[1] = 5; - rg[2] = 6; + //rg[0] = 4; + //rg[1] = 5; + //rg[2] = 6; i = 3; } else if( m_iGeigerRange > 50 ) { pct = 90; flvol = 0.95; //Con_Printf( "range > 50\n" ); - rg[0] = 5; - rg[1] = 6; + //rg[0] = 5; + //rg[1] = 6; i = 2; } else { pct = 95; flvol = 1.0; //Con_Printf( "range < 50\n" ); - rg[0] = 5; - rg[1] = 6; + //rg[0] = 5; + //rg[1] = 6; i = 2; } - flvol = ( flvol * ( (rand() & 127) ) / 255) + 0.25; // UTIL_RandomFloat(0.25, 0.5); + flvol = ( flvol * ( ( rand() & 127 ) ) / 255 ) + 0.25; // UTIL_RandomFloat( 0.25, 0.5 ); if( ( rand() & 127 ) < pct || ( rand() & 127 ) < pct ) { diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index fc306838..d24c0ef4 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -54,7 +54,7 @@ int CBaseEntity::IsDormant( void ) { return 0; } BOOL CBaseEntity::IsInWorld( void ) { return TRUE; } int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; } int CBaseEntity::DamageDecal( int bitsDamageType ) { return -1; } -CBaseEntity *CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } +CBaseEntity *CBaseEntity::Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } void CBaseEntity::SUB_Remove( void ) { } // CBaseDelay Stubs @@ -146,7 +146,7 @@ int CBaseMonster::CheckEnemy( CBaseEntity *pEnemy ) { return 0; } void CBaseMonster::PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { } BOOL CBaseMonster::PopEnemy() { return FALSE; } void CBaseMonster::SetActivity( Activity NewActivity ) { } -void CBaseMonster::SetSequenceByName( char *szSequence ) { } +void CBaseMonster::SetSequenceByName( const char *szSequence ) { } int CBaseMonster::CheckLocalMove( const Vector &vecStart, const Vector &vecEnd, CBaseEntity *pTarget, float *pflDist ) { return 0; } float CBaseMonster::OpenDoorAndWait( entvars_t *pevDoor ) { return 0.0; } void CBaseMonster::AdvanceRoute( float distance ) { } @@ -214,7 +214,7 @@ void CBaseMonster::MonsterInitDead( void ) { } BOOL CBaseMonster::BBoxFlat( void ) { return TRUE; } BOOL CBaseMonster::GetEnemy( void ) { return FALSE; } void CBaseMonster::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType) { } -CBaseEntity* CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; } +CBaseEntity* CBaseMonster::DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { return NULL; } BOOL CBaseMonster::ShouldFadeOnDeath( void ) { return FALSE; } void CBaseMonster::RadiusDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } void CBaseMonster::RadiusDamage( Vector vecSrc, entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int iClassIgnore, int bitsDamageType ) { } @@ -258,8 +258,8 @@ void CBasePlayer::PreThink(void) { } void CBasePlayer::CheckTimeBasedDamage() { } void CBasePlayer::UpdateGeigerCounter( void ) { } void CBasePlayer::CheckSuitUpdate() { } -void CBasePlayer::SetSuitUpdate(char *name, int fgroup, int iNoRepeatTime) { } -void CBasePlayer::UpdatePlayerSound ( void ) { } +void CBasePlayer::SetSuitUpdate( const char *name, int fgroup, int iNoRepeatTime ) { } +void CBasePlayer::UpdatePlayerSound( void ) { } void CBasePlayer::PostThink() { } void CBasePlayer::Precache( void ) { } int CBasePlayer::Save( CSave &save ) { return 0; } @@ -298,7 +298,7 @@ BOOL CBasePlayer::HasPlayerItem( CBasePlayerItem *pCheckItem ) { return FALSE; } BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) { return FALSE; } Vector CBasePlayer::GetGunPosition( void ) { return g_vecZero; } const char *CBasePlayer::TeamID( void ) { return ""; } -int CBasePlayer::GiveAmmo( int iCount, char *szName, int iMax ) { return 0; } +int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax ) { return 0; } void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { } void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 8c6909e3..8f8baea7 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -75,7 +75,7 @@ AlertMessage Print debug messages to console ====================== */ -void AlertMessage( ALERT_TYPE atype, char *szFmt, ... ) +void AlertMessage( ALERT_TYPE atype, const char *szFmt, ... ) { va_list argptr; static char string[1024]; @@ -96,7 +96,7 @@ bool bIsMultiplayer( void ) } //Just loads a v_ model. -void LoadVModel( char *szViewModel, CBasePlayer *m_pPlayer ) +void LoadVModel( const char *szViewModel, CBasePlayer *m_pPlayer ) { gEngfuncs.CL_LoadModel( szViewModel, &m_pPlayer->pev->viewmodel ); } @@ -208,7 +208,7 @@ CBasePlayerWeapon::DefaultDeploy ===================== */ -BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal, int body ) +BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWeaponModel, int iAnim, const char *szAnimExt, int skiplocal, int body ) { if( !CanDeploy() ) return FALSE; @@ -288,7 +288,7 @@ Only produces random numbers to match the server ones. */ Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker, int shared_rand ) { - float x = 0, y = 0, z; + float x = 0.0f, y = 0.0f, z; for( ULONG iShot = 1; iShot <= cShots; iShot++ ) { diff --git a/cl_dll/hud.h b/cl_dll/hud.h index ec236003..ab179bbb 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -480,7 +480,7 @@ public: int Init( void ); static char *LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ); static char *BufferedLocaliseTextString( const char *msg ); - char *LookupString( const char *msg_name, int *msg_dest = NULL ); + const char *LookupString( const char *msg_name, int *msg_dest = NULL ); int MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf ); }; @@ -541,8 +541,8 @@ public: //had to make these public so CHud could access them (to enable concussion icon) //could use a friend declaration instead... - void EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ); - void DisableIcon( char *pszIconName ); + void EnableIcon( const char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ); + void DisableIcon( const char *pszIconName ); private: typedef struct @@ -588,11 +588,11 @@ public: int m_iFontHeight; int DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b ); - int DrawHudString( int x, int y, int iMaxX, char *szString, int r, int g, int b ); - int DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ); + int DrawHudString( int x, int y, int iMaxX, const char *szString, int r, int g, int b ); + int DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b ); int DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r, int g, int b ); int GetNumWidth( int iNumber, int iFlags ); - int DrawHudStringLen( char *szIt ); + int DrawHudStringLen( const char *szIt ); void DrawDarkRectangle( int x, int y, int wide, int tall ); private: diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index c30df36d..5182b484 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -199,7 +199,7 @@ const unsigned char colors[8][3] = {240, 180, 24} }; -int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) +int CHud::DrawHudString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { if( hud_textmode->value == 2 ) { @@ -233,9 +233,7 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g return xpos; } - - -int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ) +int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { // xash3d: reset unicode state gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); @@ -262,7 +260,7 @@ int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int return xpos; } -int CHud::DrawHudStringLen( char *szIt ) +int CHud::DrawHudStringLen( const char *szIt ) { int l = 0; for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) @@ -280,7 +278,7 @@ int CHud::DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r } // draws a string from right to left (right-aligned) -int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, char *szString, int r, int g, int b ) +int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b ) { // find the end of the string for( char *szIt = szString; *szIt != 0; szIt++ ) diff --git a/cl_dll/message.cpp b/cl_dll/message.cpp index 5d52d413..ff8d97bf 100644 --- a/cl_dll/message.cpp +++ b/cl_dll/message.cpp @@ -29,7 +29,7 @@ DECLARE_MESSAGE( m_Message, GameTitle ) // 1 Global client_textmessage_t for custom messages that aren't in the titles.txt client_textmessage_t g_pCustomMessage; -char *g_pCustomName = "Custom"; +const char *g_pCustomName = "Custom"; char g_pCustomText[1024]; int CHudMessage::Init( void ) @@ -260,7 +260,7 @@ void CHudMessage::MessageDrawScan( client_textmessage_t *pMessage, float time ) width = 0; } else - width += gHUD.m_scrinfo.charWidths[*pText]; + width += gHUD.m_scrinfo.charWidths[(unsigned char)*pText]; pText++; length++; } @@ -310,7 +310,7 @@ int CHudMessage::Draw( float fTime ) { int i, drawn; client_textmessage_t *pMessage; - float endTime = 0; + float endTime = 0.0f; drawn = 0; diff --git a/cl_dll/status_icons.cpp b/cl_dll/status_icons.cpp index c960d5ef..4b2d9726 100644 --- a/cl_dll/status_icons.cpp +++ b/cl_dll/status_icons.cpp @@ -104,7 +104,7 @@ int CHudStatusIcons::MsgFunc_StatusIcon( const char *pszName, int iSize, void *p } // add the icon to the icon list, and set it's drawing color -void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ) +void CHudStatusIcons::EnableIcon( const char *pszIconName, unsigned char red, unsigned char green, unsigned char blue ) { int i; @@ -149,7 +149,7 @@ void CHudStatusIcons::EnableIcon( char *pszIconName, unsigned char red, unsigned } } -void CHudStatusIcons::DisableIcon( char *pszIconName ) +void CHudStatusIcons::DisableIcon( const char *pszIconName ) { // find the sprite is in the current list for( int i = 0; i < MAX_ICONSPRITES; i++ ) diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index af62a915..13b62577 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -45,7 +45,7 @@ int CHudTextMessage::Init( void ) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) { char *dst = dst_buffer; - for( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) + for( char *src = msg; *src != 0 && buffer_size > 0; buffer_size-- ) { if( *src == '#' ) { @@ -91,12 +91,12 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in char *CHudTextMessage::BufferedLocaliseTextString( const char *msg ) { static char dst_buffer[1024]; - LocaliseTextString( msg, dst_buffer, 1024 ); + LocaliseTextString( msg, dst_buffer, sizeof(dst_buffer) ); return dst_buffer; } // Simplified version of LocaliseTextString; assumes string is only one word -char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) +const char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) { if( !msg ) return ""; @@ -108,7 +108,7 @@ char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) client_textmessage_t *clmsg = TextMessageGet( msg + 1 ); if( !clmsg || !(clmsg->pMessage) ) - return (char*)msg; // lookup failed, so return the original string + return msg; // lookup failed, so return the original string if( msg_dest ) { @@ -118,12 +118,12 @@ char *CHudTextMessage::LookupString( const char *msg, int *msg_dest ) *msg_dest = -clmsg->effect; } - return (char*)clmsg->pMessage; + return clmsg->pMessage; } else { // nothing special about this message, so just return the same string - return (char*)msg; + return msg; } } @@ -167,16 +167,16 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf msg_text = strcpy( szBuf[0], msg_text ); // keep reading strings and using C format strings for subsituting the strings into the localised text string - char *sstr1 = LookupString( READ_STRING() ); + const char *sstr1 = LookupString( READ_STRING() ); sstr1 = strcpy( szBuf[1], sstr1 ); StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines - char *sstr2 = LookupString( READ_STRING() ); + const char *sstr2 = LookupString( READ_STRING() ); sstr2 = strcpy( szBuf[2], sstr2 ); StripEndNewlineFromString( sstr2 ); - char *sstr3 = LookupString( READ_STRING() ); + const char *sstr3 = LookupString( READ_STRING() ); sstr3 = strcpy( szBuf[3], sstr3 ); StripEndNewlineFromString( sstr3 ); - char *sstr4 = LookupString( READ_STRING() ); + const char *sstr4 = LookupString( READ_STRING() ); sstr4 = strcpy( szBuf[4], sstr4 ); StripEndNewlineFromString( sstr4 ); char *psz = szBuf[5]; diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index b581cc82..dcd2b1af 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -351,11 +351,11 @@ V_CalcIntermissionRefdef */ void V_CalcIntermissionRefdef( struct ref_params_s *pparams ) { - cl_entity_t *ent, *view; + cl_entity_t /**ent,*/ *view; float old; // ent is the player model ( visible when out of body ) - ent = gEngfuncs.GetLocalPlayer(); + //ent = gEngfuncs.GetLocalPlayer(); // view is the weapon model (only visible from inside body ) view = gEngfuncs.GetViewModel(); @@ -1307,7 +1307,7 @@ void V_GetMapChasePosition( int target, float *cl_angles, float *origin, float * int V_FindViewModelByWeaponModel( int weaponindex ) { - static char *modelmap[][2] = + static const char *modelmap[][2] = { { "models/p_crossbow.mdl", "models/v_crossbow.mdl" }, { "models/p_crowbar.mdl", "models/v_crowbar.mdl" }, @@ -1327,7 +1327,7 @@ int V_FindViewModelByWeaponModel( int weaponindex ) { NULL, NULL } }; - struct model_s * weaponModel = IEngineStudio.GetModelByIndex( weaponindex ); + struct model_s *weaponModel = IEngineStudio.GetModelByIndex( weaponindex ); if( weaponModel ) { diff --git a/common/cvardef.h b/common/cvardef.h index c57b97a7..e8a24581 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -28,8 +28,8 @@ typedef struct cvar_s { - char *name; - char *string; + const char *name; + const char *string; int flags; float value; struct cvar_s *next; diff --git a/dlls/activity.h b/dlls/activity.h index 58b2d8cd..5382d70d 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -99,7 +99,7 @@ typedef enum { typedef struct { int type; - char *name; + const char *name; } activity_map_t; extern activity_map_t activity_map[]; diff --git a/dlls/activitymap.h b/dlls/activitymap.h index 92cadae7..5f77c55a 100644 --- a/dlls/activitymap.h +++ b/dlls/activitymap.h @@ -93,5 +93,5 @@ _A( ACT_FLINCH_LEFTARM ), _A( ACT_FLINCH_RIGHTARM ), _A( ACT_FLINCH_LEFTLEG ), _A( ACT_FLINCH_RIGHTLEG ), -0, NULL +{ 0, NULL } }; diff --git a/dlls/aflock.cpp b/dlls/aflock.cpp index 1e317632..19998a9d 100644 --- a/dlls/aflock.cpp +++ b/dlls/aflock.cpp @@ -567,7 +567,6 @@ void CFlockingFlyer::FlockLeaderThink( void ) TraceResult tr; Vector vecDist;// used for general measurements Vector vecDir;// used for general measurements - int cProcessed = 0;// keep track of how many other boids we've processed float flLeftSide; float flRightSide; diff --git a/dlls/agrunt.cpp b/dlls/agrunt.cpp index 97804f68..c6583fb7 100644 --- a/dlls/agrunt.cpp +++ b/dlls/agrunt.cpp @@ -608,7 +608,7 @@ void CAGrunt::Spawn() //========================================================= void CAGrunt::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/agrunt.mdl" ); @@ -909,7 +909,7 @@ BOOL CAGrunt::FCanCheckAttacks( void ) //========================================================= BOOL CAGrunt::CheckMeleeAttack1( float flDot, float flDist ) { - if( HasConditions( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != NULL ) + if( HasConditions( bits_COND_SEE_ENEMY ) && flDist <= AGRUNT_MELEE_DIST && flDot >= 0.6 && m_hEnemy != 0 ) { return TRUE; } @@ -1160,7 +1160,7 @@ Schedule_t *CAGrunt::GetScheduleOfType( int Type ) case SCHED_FAIL: // no fail schedule specified, so pick a good generic one. { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // I have an enemy // !!!LATER - what if this enemy is really far away and i'm chasing him? diff --git a/dlls/animation.cpp b/dlls/animation.cpp index 86cb78ae..5454f0e8 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -268,8 +268,6 @@ int GetAnimationEvent( void *pmodel, entvars_t *pev, MonsterEvent_t *pMonsterEve if( !pstudiohdr || pev->sequence >= pstudiohdr->numseq || !pMonsterEvent ) return 0; - int events = 0; - mstudioseqdesc_t *pseqdesc; mstudioevent_t *pevent; @@ -351,7 +349,7 @@ float SetController( void *pmodel, entvars_t *pev, int iController, float flValu } } - int setting = 255 * ( flValue - pbonecontroller->start ) / ( pbonecontroller->end - pbonecontroller->start ); + int setting = (int)( 255 * ( flValue - pbonecontroller->start ) / ( pbonecontroller->end - pbonecontroller->start ) ); if( setting < 0 ) setting = 0; @@ -393,7 +391,7 @@ float SetBlending( void *pmodel, entvars_t *pev, int iBlender, float flValue ) } } - int setting = 255 * ( flValue - pseqdesc->blendstart[iBlender] ) / ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ); + int setting = (int)( 255 * ( flValue - pseqdesc->blendstart[iBlender] ) / ( pseqdesc->blendend[iBlender] - pseqdesc->blendstart[iBlender] ) ); if( setting < 0 ) setting = 0; diff --git a/dlls/apache.cpp b/dlls/apache.cpp index b64a8bae..aeeea30e 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -458,7 +458,7 @@ void CApache::HuntThink( void ) if( m_flGoalSpeed < 800 ) m_flGoalSpeed += 5; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // ALERT( at_console, "%s\n", STRING( m_hEnemy->pev->classname ) ); if( FVisible( m_hEnemy ) ) @@ -552,7 +552,7 @@ void CApache::HuntThink( void ) { if( m_flLastSeen + 60 > gpGlobals->time ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // make sure it's a good shot if( DotProduct( m_vecTarget, vecEst ) > .965 ) @@ -732,7 +732,6 @@ void CApache::Flight( void ) void CApache::FireRocket( void ) { static float side = 1.0; - static int count; if( m_iRockets <= 0 ) return; diff --git a/dlls/barnacle.cpp b/dlls/barnacle.cpp index 1e2aa785..ecc1f5d4 100644 --- a/dlls/barnacle.cpp +++ b/dlls/barnacle.cpp @@ -170,7 +170,7 @@ void CBarnacle::BarnacleThink( void ) #endif pev->nextthink = gpGlobals->time + 0.1; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // barnacle has prey. if( !m_hEnemy->IsAlive() ) @@ -183,7 +183,7 @@ void CBarnacle::BarnacleThink( void ) if( m_fLiftingPrey ) { - if( m_hEnemy != NULL && m_hEnemy->pev->deadflag != DEAD_NO ) + if( m_hEnemy != 0 && m_hEnemy->pev->deadflag != DEAD_NO ) { // crap, someone killed the prey on the way up. m_hEnemy = NULL; @@ -352,7 +352,7 @@ void CBarnacle::Killed( entvars_t *pevAttacker, int iGib ) pev->solid = SOLID_NOT; pev->takedamage = DAMAGE_NO; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { pVictim = m_hEnemy->MyMonsterPointer(); diff --git a/dlls/barney.cpp b/dlls/barney.cpp index b1c97090..3fc5aef0 100644 --- a/dlls/barney.cpp +++ b/dlls/barney.cpp @@ -221,7 +221,7 @@ void CBarney::RunTask( Task_t *pTask ) switch( pTask->iTask ) { case TASK_RANGE_ATTACK1: - if( m_hEnemy != NULL && ( m_hEnemy->IsPlayer() ) ) + if( m_hEnemy != 0 && ( m_hEnemy->IsPlayer() ) ) { pev->framerate = 1.5; } @@ -262,7 +262,7 @@ int CBarney::Classify( void ) //========================================================= void CBarney::AlertSound( void ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( FOkToSpeak() ) { @@ -504,7 +504,7 @@ int CBarney::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float // This is a heurstic to determine if the player intended to harm me // If I have an enemy, we can't establish intent (may just be crossfire) - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { // If the player was facing directly at me, or I'm already suspicious, get mad if( ( m_afMemory & bits_MEMORY_SUSPICIOUS ) || IsFacing( pevAttacker, pev->origin ) ) @@ -616,7 +616,7 @@ void CBarney::Killed( entvars_t *pevAttacker, int iGib ) GetAttachment( 0, vecGunPos, vecGunAngles ); - CBaseEntity *pGun = DropItem( "weapon_9mmhandgun", vecGunPos, vecGunAngles ); + DropItem( "weapon_9mmhandgun", vecGunPos, vecGunAngles ); } SetUse( NULL ); @@ -633,7 +633,7 @@ Schedule_t *CBarney::GetScheduleOfType( int Type ) switch( Type ) { case SCHED_ARM_WEAPON: - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // face enemy, then draw. return slBarneyEnemyDraw; @@ -721,7 +721,7 @@ Schedule_t *CBarney::GetSchedule( void ) return GetScheduleOfType( SCHED_SMALL_FLINCH ); } - if( m_hEnemy == NULL && IsFollowing() ) + if( m_hEnemy == 0 && IsFollowing() ) { if( !m_hTargetEnt->IsAlive() ) { @@ -783,10 +783,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display -- temporary, don't need to save - static char *m_szPoses[3]; + static const char *m_szPoses[3]; }; -char *CDeadBarney::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_stomach" }; +const char *CDeadBarney::m_szPoses[] = { "lying_on_back", "lying_on_side", "lying_on_stomach" }; void CDeadBarney::KeyValue( KeyValueData *pkvd ) { diff --git a/dlls/basemonster.h b/dlls/basemonster.h index ad05fccf..0d22104f 100644 --- a/dlls/basemonster.h +++ b/dlls/basemonster.h @@ -195,7 +195,7 @@ public: Task_t *GetTask( void ); virtual MONSTERSTATE GetIdealState( void ); virtual void SetActivity( Activity NewActivity ); - void SetSequenceByName( char *szSequence ); + void SetSequenceByName( const char *szSequence ); void SetState( MONSTERSTATE State ); virtual void ReportAIState( void ); @@ -327,6 +327,6 @@ public: BOOL ExitScriptedSequence(); BOOL CineCleanup(); - CBaseEntity* DropItem ( char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. + CBaseEntity* DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng );// drop an item. }; #endif // BASEMONSTER_H diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index 59f6cae2..a038c776 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -677,7 +677,7 @@ void CBigMomma::Precache() void CBigMomma::Activate( void ) { - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) Remember( bits_MEMORY_ADVANCE_NODE ); // Start 'er up } @@ -985,7 +985,7 @@ void CBigMomma::RunTask( Task_t *pTask ) { float distance; - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) TaskFail(); else { @@ -1002,7 +1002,7 @@ void CBigMomma::RunTask( Task_t *pTask ) } break; case TASK_WAIT_NODE: - if( m_hTargetEnt != NULL && ( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) ) + if( m_hTargetEnt != 0 && ( m_hTargetEnt->pev->spawnflags & SF_INFOBM_WAIT ) ) return; if( gpGlobals->time > m_flWaitFinished ) @@ -1056,7 +1056,6 @@ Vector VecCheckSplatToss( entvars_t *pev, const Vector &vecSpot1, Vector vecSpot float time = speed / flGravity; vecGrenadeVel = vecSpot2 - vecSpot1; vecGrenadeVel.z = 0; - float distance = vecGrenadeVel.Length(); // Travel half the distance to the target in that time (apex is at the midpoint) vecGrenadeVel = vecGrenadeVel * ( 0.5 / time ); diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index ee676679..6e8526f9 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -210,7 +210,7 @@ void CFuncIllusionary::KeyValue( KeyValueData *pkvd ) { if( FStrEq( pkvd->szKeyName, "skin" ) )//skin is used for content type { - pev->skin = atof( pkvd->szValue ); + pev->skin = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else @@ -614,7 +614,7 @@ void CFuncRotating::SpinDown( void ) // stop sound, we're done EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning /* Stop */ ), - 0, 0, SND_STOP, m_pitch ); + 0, 0, SND_STOP, (int)m_pitch ); SetThink( &CFuncRotating::Rotate ); Rotate(); diff --git a/dlls/bullsquid.cpp b/dlls/bullsquid.cpp index 18026b43..af3ab88a 100644 --- a/dlls/bullsquid.cpp +++ b/dlls/bullsquid.cpp @@ -248,7 +248,7 @@ int CBullsquid::IgnoreConditions( void ) iIgnore = bits_COND_SMELL | bits_COND_SMELL_FOOD; } - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) { @@ -287,7 +287,7 @@ int CBullsquid::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, flo // if the squid is running, has an enemy, was hurt by the enemy, hasn't been hurt in the last 3 seconds, and isn't too close to the enemy, // it will swerve. (whew). - if( m_hEnemy != NULL && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 ) + if( m_hEnemy != 0 && IsMoving() && pevAttacker == m_hEnemy->pev && gpGlobals->time - m_flLastHurtTime > 3 ) { flDist = ( pev->origin - m_hEnemy->pev->origin ).Length2D(); @@ -324,7 +324,7 @@ BOOL CBullsquid::CheckRangeAttack1( float flDot, float flDist ) if( flDist > 64 && flDist <= 784 && flDot >= 0.5 && gpGlobals->time >= m_flNextSpitTime ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( fabs( pev->origin.z - m_hEnemy->pev->origin.z ) > 256 ) { @@ -383,7 +383,7 @@ BOOL CBullsquid::CheckMeleeAttack2( float flDot, float flDist ) //========================================================= BOOL CBullsquid::FValidateHintType( short sHint ) { - int i; + size_t i; static short sSquidHints[] = { @@ -784,7 +784,7 @@ void CBullsquid::RunAI( void ) pev->skin = 1; } - if( m_hEnemy != NULL && m_Activity == ACT_RUN ) + if( m_hEnemy != 0 && m_Activity == ACT_RUN ) { // chasing enemy. Sprint for last bit if( ( pev->origin - m_hEnemy->pev->origin).Length2D() < SQUID_SPRINT_DIST ) @@ -1247,7 +1247,7 @@ MONSTERSTATE CBullsquid::GetIdealState( void ) COMBAT goes to ALERT upon death of enemy */ { - if( m_hEnemy != NULL && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) + if( m_hEnemy != 0 && ( iConditions & bits_COND_LIGHT_DAMAGE || iConditions & bits_COND_HEAVY_DAMAGE ) && FClassnameIs( m_hEnemy->pev, "monster_headcrab" ) ) { // if the squid has a headcrab enemy and something hurts it, it's going to forget about the crab for a while. m_hEnemy = NULL; diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 3027f10e..76f4ad91 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -275,7 +275,7 @@ IMPLEMENT_SAVERESTORE( CBaseButton, CBaseToggle ) void CBaseButton::Precache( void ) { - char *pszSound; + const char *pszSound; if( FBitSet( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF ) )// this button should spark in OFF state { @@ -381,22 +381,22 @@ void CBaseButton::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "locked_sound" ) ) { - m_bLockedSound = atof( pkvd->szValue ); + m_bLockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "locked_sentence" ) ) { - m_bLockedSentence = atof( pkvd->szValue ); + m_bLockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ) ) { - m_bUnlockedSound = atof( pkvd->szValue ); + m_bUnlockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ) ) { - m_bUnlockedSentence = atof( pkvd->szValue ); + m_bUnlockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "sounds" ) ) @@ -421,7 +421,7 @@ int CBaseButton::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl SetTouch( NULL ); m_hActivator = CBaseEntity::Instance( pevAttacker ); - if( m_hActivator == NULL ) + if( m_hActivator == 0 ) return 0; if( code == BUTTON_RETURN ) @@ -461,7 +461,7 @@ LINK_ENTITY_TO_CLASS( func_button, CBaseButton ) void CBaseButton::Spawn() { - char *pszSound; + const char *pszSound; //---------------------------------------------------- //determine sounds for buttons @@ -527,7 +527,7 @@ void CBaseButton::Spawn() char *ButtonSound( int sound ) { - char *pszSound; + const char *pszSound; switch( sound ) { @@ -869,7 +869,7 @@ LINK_ENTITY_TO_CLASS( func_rot_button, CRotButton ) void CRotButton::Spawn( void ) { - char *pszSound; + const char *pszSound; //---------------------------------------------------- //determine sounds for buttons //a sound of 0 should not make a sound @@ -1010,7 +1010,7 @@ void CMomentaryRotButton::Spawn( void ) UTIL_SetOrigin( pev, pev->origin ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - char *pszSound = ButtonSound( m_sounds ); + const char *pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); pev->noise = ALLOC_STRING( pszSound ); m_lastUsed = 0; diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 62b4eaa1..0cc10bdb 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -26,7 +26,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ); extern "C" void PM_Move ( struct playermove_s *ppmove, int server ); extern "C" void PM_Init ( struct playermove_s *ppmove ); -extern "C" char PM_FindTextureType( char *name ); +extern "C" char PM_FindTextureType( const char *name ); extern Vector VecBModelOrigin( entvars_t* pevBModel ); extern DLL_GLOBAL Vector g_vecAttackDir; @@ -739,7 +739,7 @@ int CBaseEntity::DamageDecal( int bitsDamageType ) // NOTE: szName must be a pointer to constant memory, e.g. "monster_class" because the entity // will keep a pointer to it after this call. -CBaseEntity *CBaseEntity::Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) +CBaseEntity *CBaseEntity::Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { edict_t *pent; CBaseEntity *pEntity; diff --git a/dlls/cbase.h b/dlls/cbase.h index 617bbab9..6c738bf5 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -177,7 +177,7 @@ public: virtual void AddPointsToTeam( int score, BOOL bAllowNegativeScore ) {} virtual BOOL AddPlayerItem( CBasePlayerItem *pItem ) { return 0; } virtual BOOL RemovePlayerItem( CBasePlayerItem *pItem ) { return 0; } - virtual int GiveAmmo( int iAmount, char *szName, int iMax ) { return -1; }; + virtual int GiveAmmo( int iAmount, const char *szName, int iMax ) { return -1; }; virtual float GetDelay( void ) { return 0; } virtual int IsMoving( void ) { return pev->velocity != g_vecZero; } virtual void OverrideReset( void ) {} @@ -314,7 +314,7 @@ public: // used by monsters that are created by the MonsterMaker virtual void UpdateOwner( void ) { return; }; - static CBaseEntity *Create( char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); + static CBaseEntity *Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner = NULL ); virtual BOOL FBecomeProne( void ) {return FALSE;}; edict_t *edict() { return ENT( pev ); }; @@ -655,8 +655,7 @@ class CSound; #include "basemonster.h" - -char *ButtonSound( int sound ); // get string of button sound number +const char *ButtonSound( int sound ); // get string of button sound number // // Generic Button diff --git a/dlls/client.cpp b/dlls/client.cpp index 72538b02..99f1913b 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -215,7 +215,7 @@ bool Q_IsValidUChar32( unsigned int uVal ) { // Values > 0x10FFFF are explicitly invalid; ditto for UTF-16 surrogate halves, // values ending in FFFE or FFFF, or values in the 0x00FDD0-0x00FDEF reserved range - return ( uVal < 0x110000u ) && ( ( uVal - 0x00D800u ) > 0x7FFu ) && ( ( uVal & 0xFFFFu ) < 0xFFFEu ) && ( ( uVal - 0x00FDD0u ) > 0x1Fu ); + return ( ( uVal - 0x0u ) < 0x110000u ) && ( (uVal - 0x00D800u) > 0x7FFu ) && ( (uVal & 0xFFFFu) < 0xFFFEu ) && ( ( uVal - 0x00FDD0u ) > 0x1Fu ); } // Decode one character from a UTF-8 encoded string. Treats 6-byte CESU-8 sequences @@ -423,7 +423,7 @@ void Host_Say( edict_t *pEntity, int teamonly ) // echo to server console g_engfuncs.pfnServerPrint( text ); - char *temp; + const char *temp; if( teamonly ) temp = "say_team"; else @@ -744,7 +744,6 @@ void PlayerPreThink( edict_t *pEntity ) { //ALERT( at_console, "PreThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); - entvars_t *pev = &pEntity->v; CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -762,7 +761,6 @@ void PlayerPostThink( edict_t *pEntity ) { //ALERT( at_console, "PostThink( %g, frametime %g )\n", gpGlobals->time, gpGlobals->frametime ); - entvars_t *pev = &pEntity->v; CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -950,7 +948,6 @@ animation right now. */ void PlayerCustomization( edict_t *pEntity, customization_t *pCust ) { - entvars_t *pev = &pEntity->v; CBasePlayer *pPlayer = (CBasePlayer *)GET_PRIVATE( pEntity ); if( !pPlayer ) @@ -990,7 +987,6 @@ A spectator has joined the game */ void SpectatorConnect( edict_t *pEntity ) { - entvars_t *pev = &pEntity->v; CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -1006,7 +1002,6 @@ A spectator has left the game */ void SpectatorDisconnect( edict_t *pEntity ) { - entvars_t *pev = &pEntity->v; CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -1022,7 +1017,6 @@ A spectator has sent a usercmd */ void SpectatorThink( edict_t *pEntity ) { - entvars_t *pev = &pEntity->v; CBaseSpectator *pPlayer = (CBaseSpectator *)GET_PRIVATE( pEntity ); if( pPlayer ) @@ -1235,11 +1229,11 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h } state->rendermode = ent->v.rendermode; - state->renderamt = ent->v.renderamt; + state->renderamt = (int)ent->v.renderamt; state->renderfx = ent->v.renderfx; - state->rendercolor.r = ent->v.rendercolor.x; - state->rendercolor.g = ent->v.rendercolor.y; - state->rendercolor.b = ent->v.rendercolor.z; + state->rendercolor.r = (byte)ent->v.rendercolor.x; + state->rendercolor.g = (byte)ent->v.rendercolor.y; + state->rendercolor.b = (byte)ent->v.rendercolor.z; state->aiment = 0; if( ent->v.aiment ) @@ -1286,7 +1280,7 @@ int AddToFullPack( struct entity_state_s *state, int e, edict_t *ent, edict_t *h //state->team = ent->v.team; state->usehull = ( ent->v.flags & FL_DUCKING ) ? 1 : 0; - state->health = ent->v.health; + state->health = (int)ent->v.health; } return 1; @@ -1834,7 +1828,7 @@ ConnectionlessPacket int ConnectionlessPacket( const struct netadr_s *net_from, const char *args, char *response_buffer, int *response_buffer_size ) { // Parse stuff from args - int max_buffer_size = *response_buffer_size; + //int max_buffer_size = *response_buffer_size; // Zero it out since we aren't going to respond. // If we wanted to response, we'd write data into response_buffer @@ -1888,10 +1882,10 @@ to be created during play ( e.g., grenades, ammo packs, projectiles, corpses, et */ void CreateInstancedBaselines( void ) { - int iret = 0; + /*int iret = 0; entity_state_t state; - memset( &state, 0, sizeof(state) ); + memset( &state, 0, sizeof(state) );*/ // Create any additional baselines here for things like grendates, etc. // iret = ENGINE_INSTANCE_BASELINE( pc->pev->classname, &state ); diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 3a59844f..d8830c20 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -460,11 +460,11 @@ Activity CBaseMonster::GetSmallFlinchActivity( void ) { Activity flinchActivity; BOOL fTriedDirection; - float flDot; + //float flDot; fTriedDirection = FALSE; UTIL_MakeVectors( pev->angles ); - flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); + //flDot = DotProduct( gpGlobals->v_forward, g_vecAttackDir * -1 ); switch( m_LastHitGroup ) { @@ -576,8 +576,8 @@ Killed */ void CBaseMonster::Killed( entvars_t *pevAttacker, int iGib ) { - unsigned int cCount = 0; - BOOL fDone = FALSE; + //unsigned int cCount = 0; + //BOOL fDone = FALSE; if( HasMemory( bits_MEMORY_KILLED ) ) { @@ -920,7 +920,7 @@ int CBaseMonster::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, f // enemy's last known position is somewhere down the vector that the attack came from. if( pevInflictor ) { - if( m_hEnemy == NULL || pevInflictor == m_hEnemy->pev || !HasConditions( bits_COND_SEE_ENEMY ) ) + if( m_hEnemy == 0 || pevInflictor == m_hEnemy->pev || !HasConditions( bits_COND_SEE_ENEMY ) ) { m_vecEnemyLKP = pevInflictor->origin; } @@ -1463,7 +1463,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, ( flDistance * tr.flFraction ) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ); } ApplyMultiDamage( pev, pevAttacker ); } @@ -1483,7 +1483,8 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi TraceResult tr; Vector vecRight = gpGlobals->v_right; Vector vecUp = gpGlobals->v_up; - float x, y, z; + float x = 0.0f, y = 0.0f; + float z; if( pevAttacker == NULL ) pevAttacker = pev; // the default attacker is ourselves @@ -1497,7 +1498,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi // get circular gaussian spread x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 ); y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 ); - z = x * x + y * y; + //z = x * x + y * y; Vector vecDir = vecDirShooting + x * vecSpread.x * vecRight + @@ -1548,7 +1549,7 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, ( flDistance * tr.flFraction ) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ) ); } ApplyMultiDamage( pev, pevAttacker ); diff --git a/dlls/controller.cpp b/dlls/controller.cpp index 3d56325f..bfa119d3 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -614,7 +614,7 @@ void CController::RunTask( Task_t *pTask ) Vector vecSrc = vecHand + pev->velocity * ( m_flShootTime - gpGlobals->time ); Vector vecDir; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( HasConditions( bits_COND_SEE_ENEMY ) ) { @@ -707,7 +707,7 @@ Schedule_t *CController::GetSchedule( void ) { case MONSTERSTATE_COMBAT: { - Vector vecTmp = Intersect( Vector( 0, 0, 0 ), Vector( 100, 4, 7 ), Vector( 2, 10, -3 ), 20.0 ); + // Vector vecTmp = Intersect( Vector( 0, 0, 0 ), Vector( 100, 4, 7 ), Vector( 2, 10, -3 ), 20.0 ); // dead enemy if( HasConditions( bits_COND_LIGHT_DAMAGE ) ) @@ -1095,7 +1095,6 @@ class CControllerHeadBall : public CBaseMonster void EXPORT BounceTouch( CBaseEntity *pOther ); void MovetoTarget( Vector vecTarget ); void Crawl( void ); - int m_iTrail; int m_flNextAttack; Vector m_vecIdeal; EHANDLE m_hOwner; @@ -1160,7 +1159,7 @@ void CControllerHeadBall::HuntThink( void ) MESSAGE_END(); // check world boundaries - if( gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == NULL || m_hOwner == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) + if( gpGlobals->time - pev->dmgtime > 5 || pev->renderamt < 64 || m_hEnemy == 0 || m_hOwner == 0 || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { SetTouch( NULL ); UTIL_Remove( this ); @@ -1340,7 +1339,7 @@ void CControllerZapBall::ExplodeTouch( CBaseEntity *pOther ) entvars_t *pevOwner; - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) { pevOwner = m_hOwner->pev; } diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index 7a4686e7..d749c785 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -425,10 +425,11 @@ void CCrossbow::FireBolt() UTIL_MakeVectors( anglesAim ); anglesAim.x = -anglesAim.x; + +#ifndef CLIENT_DLL Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; Vector vecDir = gpGlobals->v_forward; -#ifndef CLIENT_DLL CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate(); pBolt->pev->origin = vecSrc; pBolt->pev->angles = anglesAim; diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 80a18d65..00b16d57 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -183,7 +183,7 @@ int CCrowbar::Swing( int fFirst ) #endif PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, - 0.0, 0, 0.0 ); + 0, 0, 0 ); if( tr.flFraction >= 1.0 ) { @@ -294,7 +294,7 @@ int CCrowbar::Swing( int fFirst ) m_trHit = tr; } - m_pPlayer->m_iWeaponVolume = flVol * CROWBAR_WALLHIT_VOLUME; + m_pPlayer->m_iWeaponVolume = (int)( flVol * CROWBAR_WALLHIT_VOLUME ); #endif m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); diff --git a/dlls/decals.h b/dlls/decals.h index ce5a2b53..97f5f29f 100644 --- a/dlls/decals.h +++ b/dlls/decals.h @@ -66,7 +66,7 @@ enum decal_e typedef struct { - char *name; + const char *name; int index; } DLL_DECALLIST; diff --git a/dlls/doors.cpp b/dlls/doors.cpp index bdc82f06..dcb04e00 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -189,42 +189,42 @@ void CBaseDoor::KeyValue( KeyValueData *pkvd ) { if( FStrEq( pkvd->szKeyName, "skin" ) )//skin is used for content type { - pev->skin = atof( pkvd->szValue ); + pev->skin = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof( pkvd->szValue ); + m_bMoveSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) { - m_bStopSnd = atof( pkvd->szValue ); + m_bStopSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "healthvalue" ) ) { - m_bHealthValue = atof( pkvd->szValue ); + m_bHealthValue = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "locked_sound" ) ) { - m_bLockedSound = atof( pkvd->szValue ); + m_bLockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "locked_sentence" ) ) { - m_bLockedSentence = atof( pkvd->szValue ); + m_bLockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sound" ) ) { - m_bUnlockedSound = atof( pkvd->szValue ); + m_bUnlockedSound = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "unlocked_sentence" ) ) { - m_bUnlockedSentence = atof( pkvd->szValue ); + m_bUnlockedSentence = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "WaveHeight" ) ) @@ -328,7 +328,7 @@ void CBaseDoor::SetToggleState( int state ) void CBaseDoor::Precache( void ) { - char *pszSound; + const char *pszSound; // set the door's "in-motion" sound switch( m_bMoveSnd ) @@ -581,7 +581,7 @@ int CBaseDoor::DoorActivate() else { // door should open - if( m_hActivator != NULL && m_hActivator->IsPlayer() ) + if( m_hActivator != 0 && m_hActivator->IsPlayer() ) { // give health if player opened the door (medikit) //VARS( m_eoActivator )->health += m_bHealthValue; @@ -623,7 +623,7 @@ void CBaseDoor::DoorGoUp( void ) { float sign = 1.0; - if( m_hActivator != NULL ) + if( m_hActivator != 0 ) { pevActivator = m_hActivator->pev; @@ -1070,7 +1070,7 @@ void CMomentaryDoor::KeyValue( KeyValueData *pkvd ) if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof( pkvd->szValue ); + m_bMoveSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) diff --git a/dlls/effects.cpp b/dlls/effects.cpp index ecc04a19..2977a3ed 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -75,7 +75,7 @@ void CBubbling::Spawn( void ) pev->solid = SOLID_NOT; // Remove model & collisions pev->renderamt = 0; // The engine won't draw this model if this is set to 0 and blending is on pev->rendermode = kRenderTransTexture; - int speed = pev->speed > 0 ? pev->speed : -pev->speed; + int speed = fabs( pev->speed ); // HACKHACK!!! - Speed in rendercolor pev->rendercolor.x = speed >> 8; @@ -701,7 +701,7 @@ void CLightning::StrikeThink( void ) WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.y ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.z ); // r, g, b - WRITE_BYTE( pev->renderamt ); // brightness + WRITE_BYTE( (int)pev->renderamt ); // brightness WRITE_BYTE( m_speed ); // speed MESSAGE_END(); DoSparks( pStart->pev->origin, pEnd->pev->origin ); @@ -763,7 +763,7 @@ void CLightning::Zap( const Vector &vecSrc, const Vector &vecDest ) WRITE_BYTE( (int)pev->rendercolor.x ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.y ); // r, g, b WRITE_BYTE( (int)pev->rendercolor.z ); // r, g, b - WRITE_BYTE( pev->renderamt ); // brightness + WRITE_BYTE( (int)pev->renderamt ); // brightness WRITE_BYTE( m_speed ); // speed MESSAGE_END(); #else @@ -944,7 +944,7 @@ void CLaser::Spawn( void ) m_pSprite = NULL; if( m_pSprite ) - m_pSprite->SetTransparency( kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx ); + m_pSprite->SetTransparency( kRenderGlow, (int)pev->rendercolor.x, (int)pev->rendercolor.y, (int)pev->rendercolor.z, (int)pev->renderamt, (int)pev->renderfx ); if( pev->targetname && !( pev->spawnflags & SF_BEAM_STARTON ) ) TurnOff(); @@ -1619,7 +1619,7 @@ void CTestEffect::TestThink( void ) for( i = 0; i < m_iBeam; i++ ) { t = ( gpGlobals->time - m_flBeamTime[i] ) / ( 3 + m_flStartTime - m_flBeamTime[i] ); - m_pBeam[i]->SetBrightness( 255 * t ); + m_pBeam[i]->SetBrightness( (int)( 255 * t ) ); // m_pBeam[i]->SetScrollRate( 20 * t ); } pev->nextthink = gpGlobals->time + 0.1; @@ -1749,9 +1749,9 @@ Vector CBlood::BloodPosition( CBaseEntity *pActivator ) void CBlood::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if( pev->spawnflags & SF_BLOOD_STREAM ) - UTIL_BloodStream( BloodPosition( pActivator ), Direction(), ( Color() == BLOOD_COLOR_RED ) ? 70 : Color(), BloodAmount() ); + UTIL_BloodStream( BloodPosition( pActivator ), Direction(), ( Color() == BLOOD_COLOR_RED ) ? 70 : Color(), (int)BloodAmount() ); else - UTIL_BloodDrips( BloodPosition( pActivator ), Direction(), Color(), BloodAmount() ); + UTIL_BloodDrips( BloodPosition( pActivator ), Direction(), Color(), (int)BloodAmount() ); if( pev->spawnflags & SF_BLOOD_DECAL ) { @@ -1947,12 +1947,12 @@ void CFade::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType { if( pActivator->IsNetClient() ) { - UTIL_ScreenFade( pActivator, pev->rendercolor, Duration(), HoldTime(), pev->renderamt, fadeFlags ); + UTIL_ScreenFade( pActivator, pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags ); } } else { - UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), pev->renderamt, fadeFlags ); + UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, fadeFlags ); } SUB_UseTargets( this, USE_TOGGLE, 0 ); } diff --git a/dlls/effects.h b/dlls/effects.h index 031b8273..68f0ea29 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -238,7 +238,7 @@ public: inline int GetWidth( void ) { - return pev->scale; + return (int)pev->scale; } inline int GetNoise( void ) @@ -255,17 +255,17 @@ public: inline int GetBrightness( void ) { - return pev->renderamt; + return (int)pev->renderamt; } inline int GetFrame( void ) { - return pev->frame; + return (int)pev->frame; } inline int GetScrollRate( void ) { - return pev->animtime; + return (int)pev->animtime; } // Call after you change start/end positions diff --git a/dlls/egon.cpp b/dlls/egon.cpp index 433704ce..9a4de49b 100644 --- a/dlls/egon.cpp +++ b/dlls/egon.cpp @@ -270,7 +270,7 @@ void CEgon::Fire( const Vector &vecOrigSrc, const Vector &vecDir ) } } #endif - float timedist; + float timedist = 0.0f; switch( m_fireMode ) { @@ -380,13 +380,13 @@ void CEgon::UpdateEffect( const Vector &startPoint, const Vector &endPoint, floa } m_pBeam->SetStartPos( endPoint ); - m_pBeam->SetBrightness( 255 - ( timeBlend * 180 ) ); - m_pBeam->SetWidth( 40 - ( timeBlend * 20 ) ); + m_pBeam->SetBrightness( (int)( 255 - ( timeBlend * 180 )) ); + m_pBeam->SetWidth( (int)( 40 - ( timeBlend * 20 ) ) ); if( m_fireMode == FIRE_WIDE ) - m_pBeam->SetColor( 30 + ( 25 * timeBlend ), 30 + ( 30 * timeBlend ), 64 + 80 * fabs( sin( gpGlobals->time * 10 ) ) ); + m_pBeam->SetColor( (int)( 30 + ( 25 * timeBlend ) ), (int)( 30 + ( 30 * timeBlend ) ), (int)( 64 + 80 * fabs( sin( gpGlobals->time * 10 ) ) ) ); else - m_pBeam->SetColor( 60 + ( 25 * timeBlend ), 120 + ( 30 * timeBlend ), 64 + 80 * fabs( sin( gpGlobals->time *10 ) ) ); + m_pBeam->SetColor( (int)( 60 + ( 25 * timeBlend ) ), (int)( 120 + ( 30 * timeBlend ) ), (int)( 64 + 80 * fabs( sin( gpGlobals->time *10 ) ) ) ); UTIL_SetOrigin( m_pSprite->pev, endPoint ); m_pSprite->pev->frame += 8 * gpGlobals->frametime; diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index 1c5ec1b2..9bef0d48 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -14,10 +14,18 @@ ****/ #ifndef ENGINECALLBACK_H #define ENGINECALLBACK_H + +#ifdef _WIN32 +#ifndef __MINGW32__ #pragma once +#endif /* not __MINGW32__ */ +#endif #include "event_flags.h" +// Fix warning in MSVC8 +#undef SERVER_EXECUTE + // Must be provided by user of this code extern enginefuncs_t g_engfuncs; diff --git a/dlls/extdll.h b/dlls/extdll.h index 58349e32..ea176aab 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -25,11 +25,13 @@ #endif // Silence certain warnings +#ifdef _MSC_VER #pragma warning(disable : 4244) // int or float down-conversion #pragma warning(disable : 4305) // int or float data truncation #pragma warning(disable : 4201) // nameless struct/union #pragma warning(disable : 4514) // unreferenced inline function removed #pragma warning(disable : 4100) // unreferenced formal parameter +#endif // Prevent tons of unused windows definitions #ifdef _WIN32 @@ -42,8 +44,12 @@ #include "windows.h" #undef HSPRITE #else // _WIN32 +#ifndef FALSE #define FALSE 0 +#endif +#ifndef TRUE #define TRUE (!FALSE) +#endif typedef unsigned int ULONG; typedef unsigned char BYTE; typedef int BOOL; diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 38b05f7b..6abf1b44 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -104,7 +104,7 @@ void CBreakable::KeyValue( KeyValueData* pkvd ) else if( FStrEq( pkvd->szKeyName, "spawnobject" ) ) { int object = atoi( pkvd->szValue ); - if( object > 0 && object < ARRAYSIZE( pSpawnObjects ) ) + if( object > 0 && object < (int)ARRAYSIZE( pSpawnObjects ) ) m_iszSpawnObject = MAKE_STRING( pSpawnObjects[object] ); pkvd->fHandled = TRUE; } @@ -353,7 +353,7 @@ void CBreakable::DamageSound( void ) { int pitch; float fvol; - char *rgpsz[6]; + const char *rgpsz[6]; int i = 0; int material = m_Material; @@ -574,7 +574,6 @@ void CBreakable::Die( void ) { Vector vecSpot;// shard origin Vector vecVelocity;// shard velocity - CBaseEntity *pEntity = NULL; char cFlag = 0; int pitch; float fvol; @@ -794,7 +793,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; - static char *m_soundNames[3]; + static const char *m_soundNames[3]; int m_lastSound; // no need to save/restore, just keeps the same sound from playing twice in a row float m_maxSpeed; float m_soundTime; @@ -810,7 +809,7 @@ IMPLEMENT_SAVERESTORE( CPushable, CBreakable ) LINK_ENTITY_TO_CLASS( func_pushable, CPushable ) -char *CPushable::m_soundNames[3] = +const char *CPushable::m_soundNames[3] = { "debris/pushbox1.wav", "debris/pushbox2.wav", @@ -839,7 +838,7 @@ void CPushable::Spawn( void ) UTIL_SetOrigin( pev, pev->origin ); // Multiply by area of the box's cross-section (assume 1000 units^3 standard volume) - pev->skin = ( pev->skin * ( pev->maxs.x - pev->mins.x ) * ( pev->maxs.y - pev->mins.y ) ) * 0.0005; + pev->skin = (int)( ( pev->skin * ( pev->maxs.x - pev->mins.x ) * ( pev->maxs.y - pev->mins.y ) ) * 0.0005 ); m_soundTime = 0; } @@ -882,7 +881,7 @@ void CPushable::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "buoyancy" ) ) { - pev->skin = atof( pkvd->szValue ); + pev->skin = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index eab9e621..ab295e0c 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -190,7 +190,7 @@ void CFuncTank::Spawn( void ) if( m_fireRate <= 0 ) m_fireRate = 1; - if( m_spread > MAX_FIRING_SPREADS ) + if( m_spread > (int)MAX_FIRING_SPREADS ) m_spread = 0; pev->oldorigin = pev->origin; @@ -328,7 +328,7 @@ BOOL CFuncTank::OnControls( entvars_t *pevTest ) if( !( pev->spawnflags & SF_TANK_CANCONTROL ) ) return FALSE; - Vector offset = pevTest->origin - pev->origin; + //Vector offset = pevTest->origin - pev->origin; if( ( m_vecControllerUsePos - pevTest->origin ).Length() < 30 ) return TRUE; @@ -476,9 +476,9 @@ void CFuncTank::TrackTarget( void ) { TraceResult tr; edict_t *pPlayer = FIND_CLIENT_IN_PVS( edict() ); - BOOL updateTime = FALSE, lineOfSight; + BOOL updateTime = FALSE; Vector angles, direction, targetPosition, barrelEnd; - edict_t *pTarget; + edict_t *pTarget = NULL; // Get a position to aim for if( m_pController ) @@ -515,12 +515,8 @@ void CFuncTank::TrackTarget( void ) UTIL_TraceLine( barrelEnd, targetPosition, dont_ignore_monsters, edict(), &tr ); - lineOfSight = FALSE; - // No line of sight, don't track if( tr.flFraction == 1.0 || tr.pHit == pTarget ) { - lineOfSight = TRUE; - CBaseEntity *pInstance = CBaseEntity::Instance(pTarget); if( InRange( range ) && pInstance && pInstance->IsAlive() ) { @@ -644,7 +640,7 @@ void CFuncTank::Fire( const Vector &barrelEnd, const Vector &forward, entvars_t { CSprite *pSprite = CSprite::SpriteCreate( STRING( m_iszSpriteSmoke ), barrelEnd, TRUE ); pSprite->AnimateAndDie( RANDOM_FLOAT( 15.0, 20.0 ) ); - pSprite->SetTransparency( kRenderTransAlpha, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, 255, kRenderFxNone ); + pSprite->SetTransparency( kRenderTransAlpha, (int)pev->rendercolor.x, (int)pev->rendercolor.y, (int)pev->rendercolor.z, 255, kRenderFxNone ); pSprite->pev->velocity.z = RANDOM_FLOAT( 40, 80 ); pSprite->SetScale( m_spriteScale ); } @@ -714,7 +710,7 @@ void CFuncTankGun::Fire( const Vector &barrelEnd, const Vector &forward, entvars // FireBullets needs gpGlobals->v_up, etc. UTIL_MakeAimVectors( pev->angles ); - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); if( bulletCount > 0 ) { for( i = 0; i < bulletCount; i++ ) @@ -835,7 +831,7 @@ void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entva // TankTrace needs gpGlobals->v_up, etc. UTIL_MakeAimVectors( pev->angles ); - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); if( bulletCount ) { for( i = 0; i < bulletCount; i++ ) @@ -879,12 +875,12 @@ void CFuncTankRocket::Fire( const Vector &barrelEnd, const Vector &forward, entv if( m_fireLast != 0 ) { - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); if( bulletCount > 0 ) { for( i = 0; i < bulletCount; i++ ) { - CBaseEntity *pRocket = CBaseEntity::Create( "rpg_rocket", barrelEnd, pev->angles, edict() ); + CBaseEntity::Create( "rpg_rocket", barrelEnd, pev->angles, edict() ); } CFuncTank::Fire( barrelEnd, forward, pev ); } @@ -917,7 +913,7 @@ void CFuncTankMortar::Fire( const Vector &barrelEnd, const Vector &forward, entv { if( m_fireLast != 0 ) { - int bulletCount = ( gpGlobals->time - m_fireLast ) * m_fireRate; + int bulletCount = (int)( ( gpGlobals->time - m_fireLast ) * m_fireRate ); // Only create 1 explosion if( bulletCount > 0 ) { diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index 6c65b06f..7f60b401 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -538,7 +538,6 @@ void CGargantua::FlameControls( float angleX, float angleY ) void CGargantua::FlameUpdate( void ) { int i; - static float offset[2] = { 60, -60 }; TraceResult trace; Vector vecStart, angleGun; BOOL streaks = FALSE; @@ -759,7 +758,7 @@ void CGargantua::Spawn() //========================================================= void CGargantua::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/garg.mdl" ); PRECACHE_MODEL( GARG_EYE_SPRITE_NAME ); diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 10149202..93352b57 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -259,7 +259,7 @@ void CGauss::SecondaryAttack() m_pPlayer->m_flNextAmmoBurn = 1000; } - int pitch = ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100; + int pitch = (int)( ( gpGlobals->time - m_pPlayer->m_flStartCharge ) * ( 150 / GetFullChargeTime() ) + 100 ); if( pitch > 250 ) pitch = 250; @@ -359,11 +359,11 @@ void CGauss::StartFire( void ) void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) { m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; - + TraceResult tr, beam_tr; +#ifndef CLIENT_DLL Vector vecSrc = vecOrigSrc; Vector vecDest = vecSrc + vecDir * 8192; edict_t *pentIgnore; - TraceResult tr, beam_tr; float flMaxFrac = 1.0; int nTotal = 0; int fHasPunched = 0; @@ -371,8 +371,7 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) int nMaxHits = 10; pentIgnore = ENT( m_pPlayer->pev ); - -#ifdef CLIENT_DLL +#else if( m_fPrimaryFire == false ) g_irunninggausspred = true; #endif diff --git a/dlls/genericmonster.cpp b/dlls/genericmonster.cpp index c40bb802..23622120 100644 --- a/dlls/genericmonster.cpp +++ b/dlls/genericmonster.cpp @@ -88,7 +88,7 @@ void CGenericMonster::HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CGenericMonster::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= diff --git a/dlls/ggrenade.cpp b/dlls/ggrenade.cpp index 64d9f3cf..0ca516c4 100644 --- a/dlls/ggrenade.cpp +++ b/dlls/ggrenade.cpp @@ -49,7 +49,7 @@ void CGrenade::Explode( Vector vecSrc, Vector vecAim ) // UNDONE: temporary scorching for PreAlpha - find a less sleazy permenant solution. void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) { - float flRndSound;// sound randomizer + // float flRndSound;// sound randomizer pev->model = iStringNull;//invisible pev->solid = SOLID_NOT;// intangible @@ -102,7 +102,7 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) UTIL_DecalTrace( pTrace, DECAL_SCORCH2 ); } - flRndSound = RANDOM_FLOAT( 0, 1 ); + //flRndSound = RANDOM_FLOAT( 0, 1 ); switch( RANDOM_LONG( 0, 2 ) ) { @@ -144,8 +144,8 @@ void CGrenade::Smoke( void ) WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z ); WRITE_SHORT( g_sModelIndexSmoke ); - WRITE_BYTE( ( pev->dmg - 50 ) * 0.80 ); // scale * 10 - WRITE_BYTE( 12 ); // framerate + WRITE_BYTE( (int)( ( pev->dmg - 50 ) * 0.80 ) ); // scale * 10 + WRITE_BYTE( 12 ); // framerate MESSAGE_END(); } UTIL_Remove( this ); @@ -165,7 +165,7 @@ void CGrenade::DetonateUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_T void CGrenade::PreDetonate( void ) { - CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin, 400, 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, 400, 0.3 ); SetThink( &CGrenade::Detonate ); pev->nextthink = gpGlobals->time + 1; @@ -207,7 +207,7 @@ void CGrenade::DangerSoundThink( void ) return; } - CSoundEnt::InsertSound ( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, pev->velocity.Length(), 0.2 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin + pev->velocity * 0.5, (int)pev->velocity.Length(), 0.2 ); pev->nextthink = gpGlobals->time + 0.2; if( pev->waterlevel != 0 ) @@ -253,7 +253,7 @@ void CGrenade::BounceTouch( CBaseEntity *pOther ) // go ahead and emit the danger sound. // register a radius louder than the explosion, so we make sure everyone gets out of the way - CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, pev->dmg / 0.4, 0.3 ); + CSoundEnt::InsertSound( bits_SOUND_DANGER, pev->origin, (int)( pev->dmg / 0.4 ), 0.3 ); m_fRegisteredSound = TRUE; } diff --git a/dlls/gman.cpp b/dlls/gman.cpp index bdfb60d4..377755f6 100644 --- a/dlls/gman.cpp +++ b/dlls/gman.cpp @@ -109,7 +109,7 @@ void CGMan::HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CGMan::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= @@ -149,7 +149,7 @@ void CGMan::StartTask( Task_t *pTask ) switch( pTask->iTask ) { case TASK_WAIT: - if( m_hPlayer == NULL ) + if( m_hPlayer == 0 ) { m_hPlayer = UTIL_FindEntityByClassname( NULL, "player" ); } @@ -164,7 +164,7 @@ void CGMan::RunTask( Task_t *pTask ) { case TASK_WAIT: // look at who I'm talking to - if( m_flTalkTime > gpGlobals->time && m_hTalkTarget != NULL ) + if( m_flTalkTime > gpGlobals->time && m_hTalkTarget != 0 ) { float yaw = VecToYaw( m_hTalkTarget->pev->origin - pev->origin ) - pev->angles.y; @@ -177,7 +177,7 @@ void CGMan::RunTask( Task_t *pTask ) SetBoneController( 0, yaw ); } // look at player, but only if playing a "safe" idle animation - else if( m_hPlayer != NULL && pev->sequence == 0 ) + else if( m_hPlayer != 0 && pev->sequence == 0 ) { float yaw = VecToYaw( m_hPlayer->pev->origin - pev->origin ) - pev->angles.y; diff --git a/dlls/h_battery.cpp b/dlls/h_battery.cpp index fdb7c645..976a5733 100644 --- a/dlls/h_battery.cpp +++ b/dlls/h_battery.cpp @@ -91,7 +91,7 @@ void CRecharge::Spawn() UTIL_SetOrigin( pev, pev->origin ); // set size and link into world UTIL_SetSize( pev, pev->mins, pev->maxs ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - m_iJuice = gSkillData.suitchargerCapacity; + m_iJuice = (int)gSkillData.suitchargerCapacity; pev->frame = 0; } @@ -172,7 +172,7 @@ void CRecharge::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use void CRecharge::Recharge( void ) { - m_iJuice = gSkillData.suitchargerCapacity; + m_iJuice = (int)gSkillData.suitchargerCapacity; pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); } @@ -185,7 +185,7 @@ void CRecharge::Off( void ) m_iOn = 0; - if( ( !m_iJuice ) && ( ( m_iReactivate = g_pGameRules->FlHEVChargerRechargeTime() ) > 0 ) ) + if( ( !m_iJuice ) && ( ( m_iReactivate = (int)g_pGameRules->FlHEVChargerRechargeTime() ) > 0 ) ) { pev->nextthink = pev->ltime + m_iReactivate; SetThink( &CRecharge::Recharge ); diff --git a/dlls/h_cine.cpp b/dlls/h_cine.cpp index fc503171..bb07e02c 100644 --- a/dlls/h_cine.cpp +++ b/dlls/h_cine.cpp @@ -31,7 +31,7 @@ class CLegacyCineMonster : public CBaseMonster { public: - void CineSpawn( char *szModel ); + void CineSpawn( const char *szModel ); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT CineThink( void ); void Pain( void ); @@ -103,7 +103,7 @@ LINK_ENTITY_TO_CLASS( monster_cine3_barney, CCine3Barney ) // ********** Scientist SPAWN ********** // -void CLegacyCineMonster :: CineSpawn( char *szModel ) +void CLegacyCineMonster :: CineSpawn( const char *szModel ) { PRECACHE_MODEL(szModel); SET_MODEL(ENT(pev), szModel); diff --git a/dlls/h_cycler.cpp b/dlls/h_cycler.cpp index d685ac36..e920abfa 100644 --- a/dlls/h_cycler.cpp +++ b/dlls/h_cycler.cpp @@ -34,7 +34,7 @@ class CCycler : public CBaseMonster { public: - void GenericCyclerSpawn(char *szModel, Vector vecMin, Vector vecMax); + void GenericCyclerSpawn( const char *szModel, Vector vecMin, Vector vecMax ); virtual int ObjectCaps( void ) { return ( CBaseEntity::ObjectCaps() | FCAP_IMPULSE_USE ); } int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); void Spawn( void ); @@ -92,7 +92,7 @@ void CCyclerProbe::Spawn( void ) } // Cycler member functions -void CCycler::GenericCyclerSpawn( char *szModel, Vector vecMin, Vector vecMax ) +void CCycler::GenericCyclerSpawn( const char *szModel, Vector vecMin, Vector vecMax ) { if( !szModel || !*szModel ) { @@ -406,7 +406,7 @@ void CWreckage::Spawn( void ) } // pev->scale = 5.0; - m_flStartTime = gpGlobals->time; + m_flStartTime = (int)gpGlobals->time; } void CWreckage::Precache() diff --git a/dlls/hassassin.cpp b/dlls/hassassin.cpp index 5aac1e53..ff053595 100644 --- a/dlls/hassassin.cpp +++ b/dlls/hassassin.cpp @@ -185,7 +185,7 @@ void CHAssassin::SetYawSpeed( void ) //========================================================= void CHAssassin::Shoot( void ) { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { return; } @@ -597,7 +597,7 @@ IMPLEMENT_CUSTOM_SCHEDULES( CHAssassin, CBaseMonster ) //========================================================= BOOL CHAssassin::CheckMeleeAttack1( float flDot, float flDist ) { - if( m_flNextJump < gpGlobals->time && ( flDist <= 128 || HasMemory( bits_MEMORY_BADJUMP ) ) && m_hEnemy != NULL ) + if( m_flNextJump < gpGlobals->time && ( flDist <= 128 || HasMemory( bits_MEMORY_BADJUMP ) ) && m_hEnemy != 0 ) { TraceResult tr; @@ -687,7 +687,7 @@ void CHAssassin::RunAI( void ) // always visible if moving // always visible is not on hard - if( g_iSkillLevel != SKILL_HARD || m_hEnemy == NULL || pev->deadflag != DEAD_NO || m_Activity == ACT_RUN || m_Activity == ACT_WALK || !( pev->flags & FL_ONGROUND ) ) + if( g_iSkillLevel != SKILL_HARD || m_hEnemy == 0 || pev->deadflag != DEAD_NO || m_Activity == ACT_RUN || m_Activity == ACT_WALK || !( pev->flags & FL_ONGROUND ) ) m_iTargetRanderamt = 255; else m_iTargetRanderamt = 20; diff --git a/dlls/headcrab.cpp b/dlls/headcrab.cpp index d84a692e..60e03c10 100644 --- a/dlls/headcrab.cpp +++ b/dlls/headcrab.cpp @@ -226,7 +226,7 @@ void CHeadCrab::HandleAnimEvent( MonsterEvent_t *pEvent ) UTIL_MakeVectors( pev->angles ); Vector vecJumpDir; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { float gravity = g_psv_gravity->value; if( gravity <= 1 ) @@ -538,7 +538,7 @@ Schedule_t *CBabyCrab::GetScheduleOfType( int Type ) switch( Type ) { case SCHED_FAIL: // If you fail, try to jump! - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) return slHCRangeAttack1Fast; break; case SCHED_RANGE_ATTACK1: diff --git a/dlls/healthkit.cpp b/dlls/healthkit.cpp index e1b22467..99d53d35 100644 --- a/dlls/healthkit.cpp +++ b/dlls/healthkit.cpp @@ -159,7 +159,7 @@ void CWallHealth::Spawn() UTIL_SetOrigin( pev, pev->origin ); // set size and link into world UTIL_SetSize( pev, pev->mins, pev->maxs ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); - m_iJuice = gSkillData.healthchargerCapacity; + m_iJuice = (int)gSkillData.healthchargerCapacity; pev->frame = 0; } @@ -230,7 +230,7 @@ void CWallHealth::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE u void CWallHealth::Recharge( void ) { EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/medshot4.wav", 1.0, ATTN_NORM ); - m_iJuice = gSkillData.healthchargerCapacity; + m_iJuice = (int)gSkillData.healthchargerCapacity; pev->frame = 0; SetThink( &CBaseEntity::SUB_DoNothing ); } @@ -243,7 +243,7 @@ void CWallHealth::Off( void ) m_iOn = 0; - if( ( !m_iJuice ) && ( ( m_iReactivate = g_pGameRules->FlHealthChargerRechargeTime() ) > 0 ) ) + if( ( !m_iJuice ) && ( ( m_iReactivate = (int)g_pGameRules->FlHealthChargerRechargeTime() ) > 0 ) ) { pev->nextthink = pev->ltime + m_iReactivate; SetThink( &CWallHealth::Recharge ); diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 7b0eaa2c..4cb85c2c 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -217,7 +217,7 @@ const char *CHGrunt::pGruntSentences[] = "HG_TAUNT", // say rude things }; -enum +typedef enum { HGRUNT_SENT_NONE = -1, HGRUNT_SENT_GREN = 0, @@ -366,7 +366,7 @@ void CHGrunt::JustSpoke( void ) //========================================================= void CHGrunt::PrescheduleThink( void ) { - if( InSquad() && m_hEnemy != NULL ) + if( InSquad() && m_hEnemy != 0 ) { if( HasConditions( bits_COND_SEE_ENEMY ) ) { @@ -413,9 +413,9 @@ BOOL CHGrunt::FCanCheckAttacks( void ) //========================================================= BOOL CHGrunt::CheckMeleeAttack1( float flDot, float flDist ) { - CBaseMonster *pEnemy; + CBaseMonster *pEnemy = 0; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { pEnemy = m_hEnemy->MyMonsterPointer(); @@ -787,7 +787,7 @@ Vector CHGrunt::GetGunPosition() //========================================================= void CHGrunt::Shoot( void ) { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { return; } @@ -814,7 +814,7 @@ void CHGrunt::Shoot( void ) //========================================================= void CHGrunt::Shotgun( void ) { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { return; } @@ -1834,7 +1834,7 @@ IMPLEMENT_CUSTOM_SCHEDULES( CHGrunt, CSquadMonster ) void CHGrunt::SetActivity( Activity NewActivity ) { int iSequence = ACTIVITY_NOT_AVAILABLE; - void *pmodel = GET_MODEL_PTR( ENT( pev ) ); + //void *pmodel = GET_MODEL_PTR( ENT( pev ) ); switch( NewActivity ) { @@ -2032,10 +2032,10 @@ Schedule_t *CHGrunt::GetSchedule( void ) // before he starts pluggin away. if( FOkToSpeak() )// && RANDOM_LONG( 0, 1 ) ) { - if( ( m_hEnemy != NULL ) && m_hEnemy->IsPlayer() ) + if( ( m_hEnemy != 0 ) && m_hEnemy->IsPlayer() ) // player SENTENCEG_PlayRndSz( ENT( pev ), "HG_ALERT", HGRUNT_SENTENCE_VOLUME, GRUNT_ATTN, 0, m_voicePitch ); - else if( ( m_hEnemy != NULL ) && + else if( ( m_hEnemy != 0 ) && ( m_hEnemy->Classify() != CLASS_PLAYER_ALLY ) && ( m_hEnemy->Classify() != CLASS_HUMAN_PASSIVE ) && ( m_hEnemy->Classify() != CLASS_MACHINE ) ) @@ -2072,7 +2072,7 @@ Schedule_t *CHGrunt::GetSchedule( void ) // 10% chance of flinch. int iPercent = RANDOM_LONG( 0, 99 ); - if( iPercent <= 90 && m_hEnemy != NULL ) + if( iPercent <= 90 && m_hEnemy != 0 ) { // only try to take cover if we actually have an enemy! @@ -2308,7 +2308,7 @@ Schedule_t *CHGrunt::GetScheduleOfType( int Type ) } case SCHED_FAIL: { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // grunt has an enemy, so pick a different default fail schedule most likely to help recover. return &slGruntCombatFail[0]; @@ -2408,10 +2408,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display -- temporary, don't need to save - static char *m_szPoses[3]; + static const char *m_szPoses[3]; }; -char *CDeadHGrunt::m_szPoses[] = { "deadstomach", "deadside", "deadsitting" }; +const char *CDeadHGrunt::m_szPoses[] = { "deadstomach", "deadside", "deadsitting" }; void CDeadHGrunt::KeyValue( KeyValueData *pkvd ) { diff --git a/dlls/hornet.cpp b/dlls/hornet.cpp index 1e7025a0..d968b79b 100644 --- a/dlls/hornet.cpp +++ b/dlls/hornet.cpp @@ -258,14 +258,14 @@ void CHornet::TrackTarget( void ) } // UNDONE: The player pointer should come back after returning from another level - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { // enemy is dead. Look( 512 ); m_hEnemy = BestVisibleEnemy(); } - if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) + if( m_hEnemy != 0 && FVisible( m_hEnemy ) ) { m_vecEnemyLKP = m_hEnemy->BodyTarget( pev->origin ); } @@ -335,7 +335,7 @@ void CHornet::TrackTarget( void ) // if hornet is close to the enemy, jet in a straight line for a half second. // (only in the single player game) - if( m_hEnemy != NULL && !g_pGameRules->IsMultiplayer() ) + if( m_hEnemy != 0 && !g_pGameRules->IsMultiplayer() ) { if( flDelta >= 0.4 && ( pev->origin - m_vecEnemyLKP ).Length() <= 300 ) { diff --git a/dlls/houndeye.cpp b/dlls/houndeye.cpp index f35b0740..cedee258 100644 --- a/dlls/houndeye.cpp +++ b/dlls/houndeye.cpp @@ -137,7 +137,7 @@ int CHoundeye::Classify( void ) //========================================================= BOOL CHoundeye::FValidateHintType( short sHint ) { - int i; + size_t i; static short sHoundHints[] = { diff --git a/dlls/ichthyosaur.cpp b/dlls/ichthyosaur.cpp index cbc86d50..53f57a27 100644 --- a/dlls/ichthyosaur.cpp +++ b/dlls/ichthyosaur.cpp @@ -416,7 +416,7 @@ void CIchthyosaur::HandleAnimEvent( MonsterEvent_t *pEvent ) case ICHTHYOSAUR_AE_SHAKE_RIGHT: case ICHTHYOSAUR_AE_SHAKE_LEFT: { - if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) + if( m_hEnemy != 0 && FVisible( m_hEnemy ) ) { CBaseEntity *pHurt = m_hEnemy; @@ -622,7 +622,7 @@ void CIchthyosaur::RunTask( Task_t *pTask ) switch( pTask->iTask ) { case TASK_ICHTHYOSAUR_CIRCLE_ENEMY: - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskComplete(); } @@ -864,7 +864,7 @@ void CIchthyosaur::Stop( void ) void CIchthyosaur::Swim() { - int retValue = 0; + //int retValue = 0; Vector start = pev->origin; @@ -1072,7 +1072,7 @@ Vector CIchthyosaur::DoProbe( const Vector &Probe ) } } - if( bBumpedSomething && ( m_hEnemy == NULL || tr.pHit != m_hEnemy->edict() ) ) + if( bBumpedSomething && ( m_hEnemy == 0 || tr.pHit != m_hEnemy->edict() ) ) { Vector ProbeDir = Probe - pev->origin; diff --git a/dlls/islave.cpp b/dlls/islave.cpp index cfb1df1b..3b4343d3 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -51,7 +51,7 @@ public: void HandleAnimEvent( MonsterEvent_t *pEvent ); BOOL CheckRangeAttack1( float flDot, float flDist ); BOOL CheckRangeAttack2( float flDot, float flDist ); - void CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ); + void CallForHelp( const char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ); void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); int TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType ); @@ -155,7 +155,7 @@ int CISlave::IRelationship( CBaseEntity *pTarget ) return CBaseMonster::IRelationship( pTarget ); } -void CISlave::CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ) +void CISlave::CallForHelp( const char *szClassname, float flDist, EHANDLE hEnemy, Vector &vecLocation ) { // ALERT( at_aiconsole, "help " ); @@ -185,7 +185,7 @@ void CISlave::CallForHelp( char *szClassname, float flDist, EHANDLE hEnemy, Vect //========================================================= void CISlave::AlertSound( void ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { SENTENCEG_PlayRndSz( ENT( pev ), "SLV_ALERT", 0.85, ATTN_NORM, 0, m_voicePitch ); @@ -365,7 +365,7 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) WRITE_BYTE( 0 ); // decay * 0.1 MESSAGE_END(); } - if( m_hDead != NULL ) + if( m_hDead != 0 ) { WackBeam( -1, m_hDead ); WackBeam( 1, m_hDead ); @@ -385,7 +385,7 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) { ClearBeams(); - if( m_hDead != NULL ) + if( m_hDead != 0 ) { Vector vecDest = m_hDead->pev->origin + Vector( 0, 0, 38 ); TraceResult trace; @@ -394,7 +394,7 @@ void CISlave::HandleAnimEvent( MonsterEvent_t *pEvent ) if( !trace.fStartSolid ) { CBaseEntity *pNew = Create( "monster_alien_slave", m_hDead->pev->origin, m_hDead->pev->angles ); - CBaseMonster *pNewMonster = pNew->MyMonsterPointer( ); + //CBaseMonster *pNewMonster = pNew->MyMonsterPointer(); pNew->pev->spawnflags |= 1; WackBeam( -1, pNew ); WackBeam( 1, pNew ); @@ -484,7 +484,7 @@ BOOL CISlave::CheckRangeAttack2( float flDot, float flDist ) } } } - if( m_hDead != NULL ) + if( m_hDead != 0 ) return TRUE; else return FALSE; @@ -530,7 +530,7 @@ void CISlave::Spawn() //========================================================= void CISlave::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/islave.mdl" ); PRECACHE_MODEL( "sprites/lgtning.spr" ); @@ -756,8 +756,8 @@ void CISlave::BeamGlow() //========================================================= void CISlave::WackBeam( int side, CBaseEntity *pEntity ) { - Vector vecDest; - float flDist = 1.0; + //Vector vecDest; + //float flDist = 1.0; if( m_iBeams >= ISLAVE_MAX_BEAMS ) return; diff --git a/dlls/leech.cpp b/dlls/leech.cpp index ea524aaa..dccffcf4 100644 --- a/dlls/leech.cpp +++ b/dlls/leech.cpp @@ -271,7 +271,7 @@ void CLeech::AlertSound( void ) void CLeech::Precache( void ) { - int i; + size_t i; //PRECACHE_MODEL( "models/icky.mdl" ); PRECACHE_MODEL( "models/leech.mdl" ); diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 2a8b0683..e6b03125 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -99,7 +99,7 @@ void CLight::Spawn( void ) if( FBitSet( pev->spawnflags, SF_LIGHT_START_OFF ) ) LIGHT_STYLE( m_iStyle, "a" ); else if( m_iszPattern ) - LIGHT_STYLE( m_iStyle, (char *)STRING( m_iszPattern ) ); + LIGHT_STYLE( m_iStyle, STRING( m_iszPattern ) ); else LIGHT_STYLE( m_iStyle, "m" ); } @@ -115,7 +115,7 @@ void CLight::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useTyp if( FBitSet( pev->spawnflags, SF_LIGHT_START_OFF ) ) { if( m_iszPattern ) - LIGHT_STYLE( m_iStyle, (char *)STRING( m_iszPattern ) ); + LIGHT_STYLE( m_iStyle, STRING( m_iszPattern ) ); else LIGHT_STYLE( m_iStyle, "m" ); ClearBits( pev->spawnflags, SF_LIGHT_START_OFF ); @@ -155,15 +155,16 @@ void CEnvLight::KeyValue( KeyValueData* pkvd ) } else if( j == 4 ) { - r = r * ( v / 255.0 ); - g = g * ( v / 255.0 ); - b = b * ( v / 255.0 ); + v /= 255; + r *= v; + g *= v; + b *= v; } // simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling - r = pow( r / 114.0, 0.6 ) * 264; - g = pow( g / 114.0, 0.6 ) * 264; - b = pow( b / 114.0, 0.6 ) * 264; + r = (int)( pow( r / 114.0, 0.6 ) * 264.0 ); + g = (int)( pow( g / 114.0, 0.6 ) * 264.0 ); + b = (int)( pow( b / 114.0, 0.6 ) * 264.0 ); pkvd->fHandled = TRUE; sprintf( szColor, "%d", r ); diff --git a/dlls/maprules.cpp b/dlls/maprules.cpp index 3eea7486..2230acac 100644 --- a/dlls/maprules.cpp +++ b/dlls/maprules.cpp @@ -64,9 +64,9 @@ void CRuleEntity::Spawn( void ) void CRuleEntity::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "master")) + if( FStrEq(pkvd->szKeyName, "master" ) ) { - SetMaster( ALLOC_STRING(pkvd->szValue) ); + SetMaster( ALLOC_STRING( pkvd->szValue ) ); pkvd->fHandled = TRUE; } else @@ -75,9 +75,9 @@ void CRuleEntity::KeyValue( KeyValueData *pkvd ) BOOL CRuleEntity::CanFireForActivator( CBaseEntity *pActivator ) { - if ( m_iszMaster ) + if( m_iszMaster ) { - if ( UTIL_IsMasterTriggered( m_iszMaster, pActivator ) ) + if( UTIL_IsMasterTriggered( m_iszMaster, pActivator ) ) return TRUE; else return FALSE; @@ -135,7 +135,7 @@ public: void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void KeyValue( KeyValueData *pkvd ); - inline int Points( void ) { return pev->frags; } + inline int Points( void ) { return (int)pev->frags; } inline BOOL AllowNegativeScore( void ) { return pev->spawnflags & SF_SCORE_NEGATIVE; } inline BOOL AwardToTeam( void ) { return pev->spawnflags & SF_SCORE_TEAM; } @@ -643,8 +643,8 @@ public: inline void CountUp( void ) { pev->frags++; } inline void CountDown( void ) { pev->frags--; } inline void ResetCount( void ) { pev->frags = pev->dmg; } - inline int CountValue( void ) { return pev->frags; } - inline int LimitValue( void ) { return pev->health; } + inline int CountValue( void ) { return (int)pev->frags; } + inline int LimitValue( void ) { return (int)pev->health; } inline BOOL HitLimit( void ) { return CountValue() == LimitValue(); } diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index d034abd6..cfe4c561 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -133,7 +133,7 @@ int CBaseMonster::Restore( CRestore &restore ) m_Activity = ACT_RESET; // If we don't have an enemy, clear conditions like see enemy, etc. - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) m_afConditions = 0; return status; @@ -672,7 +672,7 @@ BOOL CBaseMonster::FRefreshRoute( void ) returnCode = BuildRoute( m_vecMoveGoal, bits_MF_TO_LOCATION, NULL ); break; case MOVEGOAL_TARGETENT: - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { returnCode = BuildRoute( m_hTargetEnt->pev->origin, bits_MF_TO_TARGETENT, m_hTargetEnt ); } @@ -954,7 +954,7 @@ BOOL CBaseMonster::CheckRangeAttack2( float flDot, float flDist ) BOOL CBaseMonster::CheckMeleeAttack1( float flDot, float flDist ) { // Decent fix to keep folks from kicking/punching hornets and snarks is to check the onground flag(sjb) - if( flDist <= 64 && flDot >= 0.7 && m_hEnemy != NULL && FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) + if( flDist <= 64 && flDot >= 0.7 && m_hEnemy != 0 && FBitSet( m_hEnemy->pev->flags, FL_ONGROUND ) ) { return TRUE; } @@ -1165,7 +1165,7 @@ void CBaseMonster::PushEnemy( CBaseEntity *pEnemy, Vector &vecLastKnownPos ) { if( m_hOldEnemy[i] == pEnemy ) return; - if( m_hOldEnemy[i] == NULL ) // someone died, reuse their slot + if( m_hOldEnemy[i] == 0 ) // someone died, reuse their slot break; } if( i >= MAX_OLD_ENEMIES ) @@ -1183,7 +1183,7 @@ BOOL CBaseMonster::PopEnemy() // UNDONE: blah, this is bad, we should use a stack but I'm too lazy to code one. for( int i = MAX_OLD_ENEMIES - 1; i >= 0; i-- ) { - if( m_hOldEnemy[i] != NULL ) + if( m_hOldEnemy[i] != 0 ) { if( m_hOldEnemy[i]->IsAlive()) // cheat and know when they die { @@ -1240,7 +1240,7 @@ void CBaseMonster::SetActivity( Activity NewActivity ) //========================================================= // SetSequenceByName //========================================================= -void CBaseMonster::SetSequenceByName( char *szSequence ) +void CBaseMonster::SetSequenceByName( const char *szSequence ) { int iSequence; @@ -2863,7 +2863,7 @@ void CBaseMonster::ReportAIState( void ) else ALERT( level, "No Schedule, " ); - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) ALERT( level, "\nEnemy is %s", STRING( m_hEnemy->pev->classname ) ); else ALERT( level, "No enemy" ); @@ -2950,7 +2950,7 @@ BOOL CBaseMonster::FCheckAITrigger( void ) switch( m_iTriggerCondition ) { case AITRIGGER_SEEPLAYER_ANGRY_AT_PLAYER: - if( m_hEnemy != NULL && m_hEnemy->IsPlayer() && HasConditions( bits_COND_SEE_ENEMY ) ) + if( m_hEnemy != 0 && m_hEnemy->IsPlayer() && HasConditions( bits_COND_SEE_ENEMY ) ) { fFireTarget = TRUE; } @@ -3321,7 +3321,7 @@ BOOL CBaseMonster::GetEnemy( void ) } // remember old enemies - if( m_hEnemy == NULL && PopEnemy() ) + if( m_hEnemy == 0 && PopEnemy() ) { if( m_pSchedule ) { @@ -3332,7 +3332,7 @@ BOOL CBaseMonster::GetEnemy( void ) } } - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { // monster has an enemy. return TRUE; @@ -3344,7 +3344,7 @@ BOOL CBaseMonster::GetEnemy( void ) //========================================================= // DropItem - dead monster drops named item //========================================================= -CBaseEntity *CBaseMonster::DropItem( char *pszItemName, const Vector &vecPos, const Vector &vecAng ) +CBaseEntity *CBaseMonster::DropItem( const char *pszItemName, const Vector &vecPos, const Vector &vecAng ) { if( !pszItemName ) { diff --git a/dlls/monsterstate.cpp b/dlls/monsterstate.cpp index f29664dc..cec29b79 100644 --- a/dlls/monsterstate.cpp +++ b/dlls/monsterstate.cpp @@ -42,7 +42,7 @@ void CBaseMonster::SetState( MONSTERSTATE State ) // Drop enemy pointers when going to idle case MONSTERSTATE_IDLE: - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { m_hEnemy = NULL;// not allowed to have an enemy anymore. ALERT( at_aiconsole, "Stripped\n" ); @@ -92,7 +92,7 @@ void CBaseMonster::RunAI( void ) } // do these calculations if monster has an enemy. - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { CheckEnemy( m_hEnemy ); } @@ -198,7 +198,7 @@ MONSTERSTATE CBaseMonster::GetIdealState( void ) COMBAT goes to ALERT upon death of enemy */ { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { m_IdealMonsterState = MONSTERSTATE_ALERT; // pev->effects = EF_BRIGHTFIELD; diff --git a/dlls/mpstubb.cpp b/dlls/mpstubb.cpp index 703a4dba..12b3a82f 100644 --- a/dlls/mpstubb.cpp +++ b/dlls/mpstubb.cpp @@ -230,7 +230,7 @@ CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) // currently think is the best visible enemy. No need to do // a distance check, just get mad at this one for now. iBestRelationship = IRelationship( pNextEnt ); - iNearest = ( pNextEnt->pev->origin - pev->origin ).Length(); + (int)iNearest = ( pNextEnt->pev->origin - pev->origin ).Length(); pReturn = pNextEnt; } else if( IRelationship( pNextEnt ) == iBestRelationship ) @@ -238,7 +238,7 @@ CBaseEntity *CBaseMonster::BestVisibleEnemy( void ) // this entity is disliked just as much as the entity that // we currently think is the best visible enemy, so we only // get mad at it if it is closer. - iDist = ( pNextEnt->pev->origin - pev->origin ).Length(); + (int)iDist = ( pNextEnt->pev->origin - pev->origin ).Length(); if( iDist <= iNearest ) { diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index ebef51de..9da8d0b4 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -256,7 +256,7 @@ void CHalfLifeMultiplay::Think( void ) if( pPlayer ) { - remain = flFragLimit - pPlayer->pev->frags; + remain = (int)( flFragLimit - pPlayer->pev->frags ); if( remain < bestfrags ) { bestfrags = remain; @@ -300,7 +300,7 @@ BOOL CHalfLifeMultiplay::IsDeathmatch( void ) //========================================================= BOOL CHalfLifeMultiplay::IsCoOp( void ) { - return gpGlobals->coop; + return gpGlobals->coop ? TRUE : FALSE; } //========================================================= @@ -467,7 +467,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl ) { MESSAGE_BEGIN( MSG_ONE, gmsgScoreInfo, NULL, pl->edict() ); WRITE_BYTE( i ); // client number - WRITE_SHORT( plr->pev->frags ); + WRITE_SHORT( (int)plr->pev->frags ); WRITE_SHORT( plr->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( GetTeamIndex( plr->m_szTeamName ) + 1 ); @@ -652,7 +652,7 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, // killed scores MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX(pVictim->edict()) ); - WRITE_SHORT( pVictim->pev->frags ); + WRITE_SHORT( (int)pVictim->pev->frags ); WRITE_SHORT( pVictim->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( GetTeamIndex( pVictim->m_szTeamName ) + 1 ); @@ -666,7 +666,7 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX( PK->edict() ) ); - WRITE_SHORT( PK->pev->frags ); + WRITE_SHORT( (int)PK->pev->frags ); WRITE_SHORT( PK->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( GetTeamIndex( PK->m_szTeamName ) + 1 ); @@ -689,14 +689,14 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, void CHalfLifeMultiplay::DeathNotice( CBasePlayer *pVictim, entvars_t *pKiller, entvars_t *pevInflictor ) { // Work out what killed the player, and send a message to all clients about it - CBaseEntity *Killer = CBaseEntity::Instance( pKiller ); + CBaseEntity::Instance( pKiller ); const char *killer_weapon_name = "world"; // by default, the player is killed by the world int killer_index = 0; // Hack to fix name change - char *tau = "tau_cannon"; - char *gluon = "gluon gun"; + const char *tau = "tau_cannon"; + const char *gluon = "gluon gun"; if( pKiller->flags & FL_CLIENT ) { diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index ba1c6192..479a2b34 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -587,7 +587,7 @@ void CNihilanth::ShootBalls( void ) while( m_flShootTime < m_flShootEnd && m_flShootTime < gpGlobals->time ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { Vector vecSrc, vecDir; CNihilanthHVR *pEntity; @@ -742,7 +742,7 @@ void CNihilanth::NextActivity() float flDist = ( m_posDesired - pev->origin ).Length(); float flDot = DotProduct( m_vecDesired, gpGlobals->v_forward ); - if( m_hRecharger != NULL ) + if( m_hRecharger != 0 ) { // at we at power up yet? if( flDist < 128.0 ) @@ -767,23 +767,23 @@ void CNihilanth::NextActivity() return; } - if( m_hEnemy != NULL && !m_hEnemy->IsAlive() ) + if( m_hEnemy != 0 && !m_hEnemy->IsAlive() ) { - m_hEnemy = NULL; + m_hEnemy = 0; } if( m_flLastSeen + 15 < gpGlobals->time ) { - m_hEnemy = NULL; + m_hEnemy = 0; } - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { Look( 4096 ); m_hEnemy = BestVisibleEnemy(); } - if( m_hEnemy != NULL && m_irritation != 0 ) + if( m_hEnemy != 0 && m_irritation != 0 ) { if( m_flLastSeen + 5 > gpGlobals->time && flDist < 256 && flDot > 0 ) { @@ -860,7 +860,7 @@ void CNihilanth::HuntThink( void ) } // look for current enemy - if( m_hEnemy != NULL && m_hRecharger == NULL ) + if( m_hEnemy != 0 && m_hRecharger == NULL ) { if( FVisible( m_hEnemy ) ) { @@ -928,7 +928,7 @@ void CNihilanth::Flight( void ) if( flDir < 0 ) flSpeed = -flSpeed; - float flDist = DotProduct( m_posDesired - vecEst, gpGlobals->v_forward ); + //float flDist = DotProduct( m_posDesired - vecEst, gpGlobals->v_forward ); // sideways drag m_velocity.x = m_velocity.x * ( 1.0 - fabs( gpGlobals->v_right.x ) * 0.05 ); @@ -959,7 +959,7 @@ BOOL CNihilanth::AbsorbSphere( void ) { for( int i = 0; i < N_SPHERES; i++ ) { - if( m_hSphere[i] != NULL ) + if( m_hSphere[i] != 0 ) { CNihilanthHVR *pSphere = (CNihilanthHVR *)( (CBaseEntity *)m_hSphere[i] ); pSphere->AbsorbInit(); @@ -978,7 +978,7 @@ BOOL CNihilanth::EmitSphere( void ) for( int i = 0; i < N_SPHERES; i++ ) { - if( m_hSphere[i] != NULL ) + if( m_hSphere[i] != 0 ) { m_iActiveSpheres++; } @@ -1007,10 +1007,10 @@ void CNihilanth::TargetSphere( USE_TYPE useType, float value ) for( i = 0; i < N_SPHERES; i++ ) { - if( m_hSphere[i] != NULL ) + if( m_hSphere[i] != 0 ) { pSphere = m_hSphere[i]->MyMonsterPointer(); - if( pSphere->m_hEnemy == NULL ) + if( pSphere->m_hEnemy == 0 ) break; } } @@ -1141,7 +1141,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) case 4: // get a sphere { - if( m_hRecharger != NULL ) + if( m_hRecharger != 0 ) { if( !EmitSphere() ) { @@ -1340,7 +1340,7 @@ void CNihilanthHVR::HoverThink( void ) { pev->nextthink = gpGlobals->time + 0.1; - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { CircleTarget( m_hTargetEnt->pev->origin + Vector( 0, 0, 16 * N_SCALE ) ); } @@ -1424,7 +1424,7 @@ void CNihilanthHVR::ZapThink( void ) pev->nextthink = gpGlobals->time + 0.05; // check world boundaries - if( m_hEnemy == NULL || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) + if( m_hEnemy == 0 || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { SetTouch( NULL ); UTIL_Remove( this ); @@ -1561,7 +1561,7 @@ void CNihilanthHVR::TeleportThink( void ) pev->nextthink = gpGlobals->time + 0.1; // check world boundaries - if( m_hEnemy == NULL || !m_hEnemy->IsAlive() || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) + if( m_hEnemy == 0 || !m_hEnemy->IsAlive() || pev->origin.x < -4096 || pev->origin.x > 4096 || pev->origin.y < -4096 || pev->origin.y > 4096 || pev->origin.z < -4096 || pev->origin.z > 4096 ) { STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); @@ -1573,10 +1573,10 @@ void CNihilanthHVR::TeleportThink( void ) STOP_SOUND( edict(), CHAN_WEAPON, "x/x_teleattack1.wav" ); UTIL_Remove( this ); - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) m_hTargetEnt->Use( m_hEnemy, m_hEnemy, USE_ON, 1.0 ); - if( m_hTouch != NULL && m_hEnemy != NULL ) + if( m_hTouch != 0 && m_hEnemy != NULL ) m_hTouch->Touch( m_hEnemy ); } else @@ -1630,10 +1630,10 @@ void CNihilanthHVR::TeleportTouch( CBaseEntity *pOther ) if( pOther == pEnemy ) { - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) m_hTargetEnt->Use( pEnemy, pEnemy, USE_ON, 1.0 ); - if( m_hTouch != NULL && pEnemy != NULL ) + if( m_hTouch != 0 && pEnemy != NULL ) m_hTouch->Touch( pEnemy ); } else @@ -1656,7 +1656,7 @@ void CNihilanthHVR::DissipateThink( void ) pev->renderamt -= 2; pev->scale += 0.1; - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { CircleTarget( m_hTargetEnt->pev->origin + Vector( 0, 0, 4096 ) ); } diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index a97b6a80..68a1c267 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -214,7 +214,7 @@ entvars_t *CGraph::LinkEntForLink( CLink *pLink, CNode *pNode ) //========================================================= int CGraph::HandleLinkEnt( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODEQUERY queryType ) { - edict_t *pentWorld; + //edict_t *pentWorld; CBaseEntity *pDoor; TraceResult tr; @@ -230,7 +230,7 @@ int CGraph::HandleLinkEnt( int iNode, entvars_t *pevLinkEnt, int afCapMask, NODE ALERT( at_aiconsole, "dead path ent!\n" ); return TRUE; } - pentWorld = NULL; + //pentWorld = NULL; // func_door if( FClassnameIs( pevLinkEnt, "func_door" ) || FClassnameIs( pevLinkEnt, "func_door_rotating" ) ) @@ -586,7 +586,7 @@ int CGraph::FindShortestPath( int *piPath, int iStart, int iDest, int iHull, int int iVisitNode; int iCurrentNode; int iNumPathNodes; - int iHullMask; + int iHullMask = 0; if( !m_fGraphPresent || !m_fGraphPointersSet ) { @@ -1665,10 +1665,10 @@ void CTestHull::BuildNodeGraph( void ) int iBadNode;// this is the node that caused graph generation to fail - int cMaxInitialLinks = 0; - int cMaxValidLinks = 0; + //int cMaxInitialLinks = 0; + //int cMaxValidLinks = 0; - int iPoolIndex = 0; + //int iPoolIndex = 0; int cPoolLinks;// number of links in the pool. Vector vecDirToCheckNode; @@ -2058,11 +2058,16 @@ void CTestHull::BuildNodeGraph( void ) fprintf( file, "\nAll Connections are Paired!\n" ); } +#ifdef _MSC_VER +#define SIZET_FMT "%Iu" +#else +#define SIZET_FMT "%zu" +#endif fprintf( file, "-------------------------------------------------------------------------------\n" ); fprintf( file, "\n\n-------------------------------------------------------------------------------\n" ); fprintf( file, "Total Number of Connections in Pool: %d\n", cPoolLinks ); fprintf( file, "-------------------------------------------------------------------------------\n" ); - fprintf( file, "Connection Pool: %d bytes\n", sizeof(CLink) * cPoolLinks ); + fprintf( file, "Connection Pool: " SIZET_FMT " bytes\n", sizeof(CLink) * cPoolLinks ); fprintf( file, "-------------------------------------------------------------------------------\n" ); ALERT( at_aiconsole, "%d Nodes, %d Connections\n", WorldGraph.m_cNodes, cPoolLinks ); diff --git a/dlls/nodes.h b/dlls/nodes.h index 27b890ed..2b582a6f 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -15,7 +15,8 @@ //========================================================= // nodes.h //========================================================= - +#ifndef NODES_H +#define NODES_H //========================================================= // DEFINE //========================================================= @@ -370,3 +371,4 @@ enum }; extern CGraph WorldGraph; +#endif // NODES_H diff --git a/dlls/observer.cpp b/dlls/observer.cpp index 0eda7490..f3fc54a0 100644 --- a/dlls/observer.cpp +++ b/dlls/observer.cpp @@ -35,7 +35,7 @@ void CBasePlayer::Observer_FindNextPlayer( bool bReverse ) else iStart = ENTINDEX( edict() ); int iCurrent = iStart; - m_hObserverTarget = NULL; + m_hObserverTarget = 0; int iDir = bReverse ? -1 : 1; do @@ -125,11 +125,11 @@ void CBasePlayer::Observer_CheckTarget() return; // try to find a traget if we have no current one - if( m_hObserverTarget == NULL ) + if( m_hObserverTarget == 0 ) { Observer_FindNextPlayer( false ); - if( m_hObserverTarget == NULL ) + if( m_hObserverTarget == 0 ) { // no target found at all @@ -166,7 +166,7 @@ void CBasePlayer::Observer_CheckTarget() void CBasePlayer::Observer_CheckProperties() { // try to find a traget if we have no current one - if( pev->iuser1 == OBS_IN_EYE && m_hObserverTarget != NULL ) + if( pev->iuser1 == OBS_IN_EYE && m_hObserverTarget != 0 ) { CBasePlayer* target = (CBasePlayer*)( UTIL_PlayerByIndex( ENTINDEX( m_hObserverTarget->edict() ) ) ); @@ -222,26 +222,26 @@ void CBasePlayer::Observer_SetMode( int iMode ) if( iMode < OBS_CHASE_LOCKED || iMode > OBS_MAP_CHASE ) iMode = OBS_IN_EYE; // now it is // verify observer target again - if( m_hObserverTarget != NULL ) + if( m_hObserverTarget != 0 ) { CBaseEntity *pEnt = m_hObserverTarget; if( ( pEnt == this ) || ( pEnt == NULL ) ) - m_hObserverTarget = NULL; + m_hObserverTarget = 0; else if( ( (CBasePlayer*)pEnt )->IsObserver() || ( pEnt->pev->effects & EF_NODRAW ) ) - m_hObserverTarget = NULL; + m_hObserverTarget = 0; } // set spectator mode pev->iuser1 = iMode; // if we are not roaming, we need a valid target to track - if( ( iMode != OBS_ROAMING ) && ( m_hObserverTarget == NULL ) ) + if( ( iMode != OBS_ROAMING ) && ( m_hObserverTarget == 0 ) ) { Observer_FindNextPlayer( false ); // if we didn't find a valid target switch to roaming - if( m_hObserverTarget == NULL ) + if( m_hObserverTarget == 0 ) { ClientPrint( pev, HUD_PRINTCENTER, "#Spec_NoTarget" ); pev->iuser1 = OBS_ROAMING; diff --git a/dlls/osprey.cpp b/dlls/osprey.cpp index 95088d2b..6a421645 100644 --- a/dlls/osprey.cpp +++ b/dlls/osprey.cpp @@ -261,7 +261,7 @@ BOOL COsprey::HasDead() { for( int i = 0; i < m_iUnits; i++ ) { - if( m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive() ) + if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() ) { return TRUE; } @@ -285,9 +285,9 @@ CBaseMonster *COsprey::MakeGrunt( Vector vecSrc ) for( int i = 0; i < m_iUnits; i++ ) { - if( m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive() ) + if( m_hGrunt[i] == 0 || !m_hGrunt[i]->IsAlive() ) { - if( m_hGrunt[i] != NULL && m_hGrunt[i]->pev->rendermode == kRenderNormal ) + if( m_hGrunt[i] != 0 && m_hGrunt[i]->pev->rendermode == kRenderNormal ) { m_hGrunt[i]->SUB_StartFadeOut(); } @@ -319,7 +319,7 @@ void COsprey::HoverThink( void ) int i; for( i = 0; i < 4; i++ ) { - if( m_hRepel[i] != NULL && m_hRepel[i]->pev->health > 0 && !( m_hRepel[i]->pev->flags & FL_ONGROUND ) ) + if( m_hRepel[i] != 0 && m_hRepel[i]->pev->health > 0 && !( m_hRepel[i]->pev->flags & FL_ONGROUND ) ) { break; } diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 93fb22fe..8fecf684 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -82,12 +82,12 @@ void CBasePlatTrain::KeyValue( KeyValueData *pkvd ) } else if( FStrEq( pkvd->szKeyName, "movesnd" ) ) { - m_bMoveSnd = atof( pkvd->szValue ); + m_bMoveSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "stopsnd" ) ) { - m_bStopSnd = atof( pkvd->szValue ); + m_bStopSnd = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } else if( FStrEq( pkvd->szKeyName, "volume" ) ) @@ -1437,7 +1437,7 @@ void CFuncTrackTrain::Spawn( void ) pev->speed = 0; pev->velocity = g_vecZero; pev->avelocity = g_vecZero; - pev->impulse = m_speed; + pev->impulse = (int)m_speed; m_dir = 1; @@ -2212,7 +2212,7 @@ void CGunTarget::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us { pev->takedamage = DAMAGE_AIM; m_hTargetEnt = GetNextTarget(); - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) return; pev->health = pev->max_health; Next(); diff --git a/dlls/player.cpp b/dlls/player.cpp index 7d7363b5..51995acf 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -459,7 +459,7 @@ int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl } // keep track of amount of damage last sustained - m_lastDamageAmount = flDamage; + m_lastDamageAmount = (int)flDamage; // Armor. if( pev->armorvalue && !( bitsDamageType & ( DMG_FALL | DMG_DROWN ) ) )// armor doesn't protect against fall or drown damage! @@ -787,7 +787,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) m_pLastItem = NULL; - if( m_pTank != NULL ) + if( m_pTank != 0 ) { m_pTank->Use( this, this, USE_OFF, 0 ); m_pTank = NULL; @@ -847,7 +847,7 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) g_pGameRules->PlayerKilled( this, pevAttacker, g_pevLastInflictor ); - if( m_pTank != NULL ) + if( m_pTank != 0 ) { m_pTank->Use( this, this, USE_OFF, 0 ); m_pTank = NULL; @@ -1172,7 +1172,7 @@ void CBasePlayer::WaterMove() // track drowning damage, give it back when // player finally takes a breath - m_idrowndmg += pev->dmg; + m_idrowndmg += (int)pev->dmg; } } else @@ -1393,7 +1393,7 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) if( m_pActiveItem ) m_pActiveItem->Holster(); - if( m_pTank != NULL ) + if( m_pTank != 0 ) { m_pTank->Use( this, this, USE_OFF, 0 ); m_pTank = NULL; @@ -1468,7 +1468,7 @@ void CBasePlayer::PlayerUse( void ) // Hit Use on a train? if( m_afButtonPressed & IN_USE ) { - if( m_pTank != NULL ) + if( m_pTank != 0 ) { // Stop controlling the tank // TODO: Send HUD Update @@ -1491,7 +1491,7 @@ void CBasePlayer::PlayerUse( void ) if( pTrain && !( pev->button & IN_JUMP ) && FBitSet( pev->flags, FL_ONGROUND ) && (pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE ) && pTrain->OnControls( pev ) ) { m_afPhysicsFlags |= PFLAG_ONTRAIN; - m_iTrain = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); + m_iTrain = TrainSpeed( (int)pTrain->pev->speed, pTrain->pev->impulse ); m_iTrain |= TRAIN_NEW; EMIT_SOUND( ENT( pev ), CHAN_ITEM, "plats/train_use1.wav", 0.8, ATTN_NORM ); return; @@ -1662,7 +1662,7 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) if( -score > pev->frags ) // Will this go negative? { - score = -pev->frags; // Sum will be 0 + score = (int)( -pev->frags ); // Sum will be 0 } } } @@ -1671,7 +1671,7 @@ void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( ENTINDEX( edict() ) ); - WRITE_SHORT( pev->frags ); + WRITE_SHORT( (int)pev->frags ); WRITE_SHORT( m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( g_pGameRules->GetTeamIndex( m_szTeamName ) + 1 ); @@ -1733,8 +1733,8 @@ void CBasePlayer::UpdateStatusBar() // allies and medics get to see the targets health if( g_pGameRules->PlayerRelationship( this, pEntity ) == GR_TEAMMATE ) { - newSBarState[SBAR_ID_TARGETHEALTH] = 100 * ( pEntity->pev->health / pEntity->pev->max_health ); - newSBarState[SBAR_ID_TARGETARMOR] = pEntity->pev->armorvalue; //No need to get it % based since 100 it's the max. + newSBarState[SBAR_ID_TARGETHEALTH] = (int)( 100 * ( pEntity->pev->health / pEntity->pev->max_health ) ); + newSBarState[SBAR_ID_TARGETARMOR] = (int)pEntity->pev->armorvalue; //No need to get it % based since 100 it's the max. } m_flStatusBarDisappearDelay = gpGlobals->time + 1.0; @@ -1899,7 +1899,7 @@ void CBasePlayer::PreThink( void ) if( vel ) { - m_iTrain = TrainSpeed( pTrain->pev->speed, pTrain->pev->impulse ); + m_iTrain = TrainSpeed( (int)pTrain->pev->speed, pTrain->pev->impulse ); m_iTrain |= TRAIN_ACTIVE|TRAIN_NEW; } } @@ -2010,7 +2010,7 @@ void CBasePlayer::CheckTimeBasedDamage() int i; BYTE bDuration = 0; - static float gtbdPrev = 0.0; + //static float gtbdPrev = 0.0; if( !( m_bitsDamageType & DMG_TIMEBASED ) ) return; @@ -2271,7 +2271,7 @@ void CBasePlayer::CheckSuitUpdate() // seconds, then we won't repeat playback of this word or sentence // for at least that number of seconds. -void CBasePlayer::SetSuitUpdate( char *name, int fgroup, int iNoRepeatTime ) +void CBasePlayer::SetSuitUpdate( const char *name, int fgroup, int iNoRepeatTime ) { int i; int isentence; @@ -2399,7 +2399,7 @@ void CBasePlayer::UpdatePlayerSound( void ) // is louder than his body/movement, use the weapon volume, else, use the body volume. if( FBitSet( pev->flags, FL_ONGROUND ) ) { - iBodyVolume = pev->velocity.Length(); + iBodyVolume = (int)pev->velocity.Length(); // clamp the noise that can be made by the body, in case a push trigger, // weapon recoil, or anything shoves the player abnormally fast. @@ -2432,7 +2432,7 @@ void CBasePlayer::UpdatePlayerSound( void ) } // decay weapon volume over time so bits_SOUND_COMBAT stays set for a while - m_iWeaponVolume -= 250 * gpGlobals->frametime; + m_iWeaponVolume -= (int)( 250 * gpGlobals->frametime ); if( m_iWeaponVolume < 0 ) { iVolume = 0; @@ -2450,7 +2450,7 @@ void CBasePlayer::UpdatePlayerSound( void ) } else if( iVolume > m_iTargetVolume ) { - iVolume -= 250 * gpGlobals->frametime; + iVolume -= (int)( 250 * gpGlobals->frametime ); if( iVolume < m_iTargetVolume ) { @@ -2479,7 +2479,7 @@ void CBasePlayer::UpdatePlayerSound( void ) } // keep track of virtual muzzle flash - m_iWeaponFlash -= 256 * gpGlobals->frametime; + m_iWeaponFlash -= (int)( 256 * gpGlobals->frametime ); if( m_iWeaponFlash < 0 ) m_iWeaponFlash = 0; @@ -2501,7 +2501,7 @@ void CBasePlayer::PostThink() goto pt_end; // Handle Tank controlling - if( m_pTank != NULL ) + if( m_pTank != 0 ) { // if they've moved too far from the gun, or selected a weapon, unuse the gun if( m_pTank->OnControls( pev ) && !pev->weaponmodel ) @@ -2565,7 +2565,7 @@ void CBasePlayer::PostThink() { if( m_flFallVelocity > 64 && !g_pGameRules->IsMultiplayer() ) { - CSoundEnt::InsertSound( bits_SOUND_PLAYER, pev->origin, m_flFallVelocity, 0.2 ); + CSoundEnt::InsertSound( bits_SOUND_PLAYER, pev->origin, (int)m_flFallVelocity, 0.2 ); // ALERT( at_console, "fall %f\n", m_flFallVelocity ); } m_flFallVelocity = 0; @@ -3195,7 +3195,7 @@ void CSprayCan::Think( void ) } else { - UTIL_PlayerDecalTrace( &tr, playernum, pev->frame, TRUE ); + UTIL_PlayerDecalTrace( &tr, playernum, (int)pev->frame, TRUE ); // Just painted last custom frame. if( pev->frame++ >= ( nFrames - 1 ) ) UTIL_Remove( this ); @@ -3682,7 +3682,7 @@ int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) // // Returns the unique ID for the ammo, or -1 if error // -int CBasePlayer::GiveAmmo( int iCount, char *szName, int iMax ) +int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax ) { if( !szName ) { @@ -3756,10 +3756,10 @@ Called every frame by the player PostThink */ void CBasePlayer::ItemPostFrame() { - static int fInSelect = FALSE; + //static int fInSelect = FALSE; // check if the player is using a tank - if( m_pTank != NULL ) + if( m_pTank != 0 ) return; #if defined( CLIENT_WEAPONS ) @@ -3912,12 +3912,12 @@ void CBasePlayer::UpdateClientData( void ) WRITE_BYTE( iHealth ); MESSAGE_END(); - m_iClientHealth = pev->health; + m_iClientHealth = (int)pev->health; } if( pev->armorvalue != m_iClientBattery ) { - m_iClientBattery = pev->armorvalue; + m_iClientBattery = (int)pev->armorvalue; ASSERT( gmsgBattery > 0 ); @@ -3945,8 +3945,8 @@ void CBasePlayer::UpdateClientData( void ) int visibleDamageBits = m_bitsDamageType & DMG_SHOWNHUD; MESSAGE_BEGIN( MSG_ONE, gmsgDamage, NULL, pev ); - WRITE_BYTE( pev->dmg_save ); - WRITE_BYTE( pev->dmg_take ); + WRITE_BYTE( (int)pev->dmg_save ); + WRITE_BYTE( (int)pev->dmg_take ); WRITE_LONG( visibleDamageBits ); WRITE_COORD( damageOrigin.x ); WRITE_COORD( damageOrigin.y ); @@ -4211,8 +4211,8 @@ Vector CBasePlayer::GetAutoaimVector( float flDelta ) { SET_CROSSHAIRANGLE( edict(), -m_vecAutoAim.x, m_vecAutoAim.y ); - m_lastx = m_vecAutoAim.x; - m_lasty = m_vecAutoAim.y; + m_lastx = (int)m_vecAutoAim.x; + m_lasty = (int)m_vecAutoAim.y; } } @@ -4556,10 +4556,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display -- temporary, don't need to save - static char *m_szPoses[4]; + static const char *m_szPoses[4]; }; -char *CDeadHEV::m_szPoses[] = +const char *CDeadHEV::m_szPoses[] = { "deadback", "deadsitting", @@ -4701,7 +4701,7 @@ void CRevertSaved::KeyValue( KeyValueData *pkvd ) void CRevertSaved::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), pev->renderamt, FFADE_OUT ); + UTIL_ScreenFadeAll( pev->rendercolor, Duration(), HoldTime(), (int)pev->renderamt, FFADE_OUT ); pev->nextthink = gpGlobals->time + MessageTime(); SetThink( &CRevertSaved::MessageThink ); } diff --git a/dlls/player.h b/dlls/player.h index cb2bddf8..b2dce868 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -273,7 +273,7 @@ public: void GiveNamedItem( const char *szName ); void EnableControl(BOOL fControl); - int GiveAmmo( int iAmount, char *szName, int iMax ); + int GiveAmmo( int iAmount, const char *szName, int iMax ); void SendAmmoUpdate(void); void WaterMove( void ); @@ -281,7 +281,7 @@ public: void PlayerUse( void ); void CheckSuitUpdate(); - void SetSuitUpdate(char *name, int fgroup, int iNoRepeat); + void SetSuitUpdate( const char *name, int fgroup, int iNoRepeat ); void UpdateGeigerCounter( void ); void CheckTimeBasedDamage( void ); diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 05d1fc8c..458ac532 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -92,7 +92,7 @@ void CSatchelCharge::Spawn( void ) void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) { - entvars_t *pevOther = pOther->pev; + //entvars_t *pevOther = pOther->pev; // don't hit the guy that launched this grenade if( pOther->edict() == pev->owner ) @@ -377,11 +377,11 @@ void CSatchel::Throw( void ) { if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { +#ifndef CLIENT_DLL Vector vecSrc = m_pPlayer->pev->origin; Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity; -#ifndef CLIENT_DLL CBaseEntity *pSatchel = Create( "monster_satchel", vecSrc, Vector( 0, 0, 0 ), m_pPlayer->edict() ); pSatchel->pev->velocity = vecThrow; pSatchel->pev->avelocity.y = 400; diff --git a/dlls/saverestore.h b/dlls/saverestore.h index a9ad2c54..4295871d 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -23,7 +23,7 @@ class CSaveRestoreBuffer public: CSaveRestoreBuffer( void ); CSaveRestoreBuffer( SAVERESTOREDATA *pdata ); - ~CSaveRestoreBuffer( void ); + virtual ~CSaveRestoreBuffer( void ); int EntityIndex( entvars_t *pevLookup ); int EntityIndex( edict_t *pentLookup ); @@ -41,6 +41,10 @@ protected: SAVERESTOREDATA *m_pdata; void BufferRewind( int size ); unsigned int HashString( const char *pszToken ); +private: + // effc++ rule 11 + void operator = ( CSaveRestoreBuffer& ); + CSaveRestoreBuffer( const CSaveRestoreBuffer& ); }; class CSave : public CSaveRestoreBuffer @@ -81,7 +85,7 @@ typedef struct class CRestore : public CSaveRestoreBuffer { public: - CRestore( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ) { m_global = 0; m_precache = TRUE; } + CRestore( SAVERESTOREDATA *pdata ) : CSaveRestoreBuffer( pdata ), m_global(0), m_precache( TRUE ) { } int ReadEntVars( const char *pname, entvars_t *pev ); // entvars_t int ReadFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); int ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount, int startField, int size, char *pName, void *pData ); @@ -160,6 +164,9 @@ private: globalentity_t *Find( string_t globalname ); globalentity_t *m_pList; int m_listCount; + // effc++ rule 11 + void operator = ( CGlobalState& ); + CGlobalState( const CGlobalState& ); }; extern CGlobalState gGlobalState; diff --git a/dlls/schedule.cpp b/dlls/schedule.cpp index c28a88fa..4a5cefca 100644 --- a/dlls/schedule.cpp +++ b/dlls/schedule.cpp @@ -238,7 +238,7 @@ void CBaseMonster::MaintainSchedule( void ) { if( (m_afConditions && !HasConditions( bits_COND_SCHEDULE_DONE ) ) || ( m_pSchedule && (m_pSchedule->iInterruptMask & bits_COND_SCHEDULE_DONE ) ) || - ( ( m_MonsterState == MONSTERSTATE_COMBAT ) && ( m_hEnemy == NULL ) ) ) + ( ( m_MonsterState == MONSTERSTATE_COMBAT ) && ( m_hEnemy == 0 ) ) ) { GetIdealState(); } @@ -407,7 +407,7 @@ void CBaseMonster::RunTask( Task_t *pTask ) { float distance; - if( m_hTargetEnt == NULL ) + if( m_hTargetEnt == 0 ) TaskFail(); else { @@ -675,7 +675,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY: { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); return; @@ -695,7 +695,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FIND_FAR_NODE_COVER_FROM_ENEMY: { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); return; @@ -715,7 +715,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FIND_NODE_COVER_FROM_ENEMY: { - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); return; @@ -737,7 +737,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) { entvars_t *pevCover; - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { // Find cover from self if no enemy available pevCover = pev; @@ -821,7 +821,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) SetTurnActivity(); break; case TASK_FACE_TARGET: - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { MakeIdealYaw( m_hTargetEnt->pev->origin ); SetTurnActivity(); @@ -904,7 +904,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) TaskComplete(); else { - if( m_hTargetEnt == NULL || !MoveToTarget( newActivity, 2 ) ) + if( m_hTargetEnt == 0 || !MoveToTarget( newActivity, 2 ) ) { TaskFail(); ALERT( at_aiconsole, "%s Failed to reach target!!!\n", STRING( pev->classname ) ); @@ -1043,7 +1043,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) case TASK_GET_PATH_TO_TARGET: { RouteClear(); - if( m_hTargetEnt != NULL && MoveToTarget( m_movementActivity, 1 ) ) + if( m_hTargetEnt != 0 && MoveToTarget( m_movementActivity, 1 ) ) { TaskComplete(); } @@ -1272,7 +1272,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_PLANT_ON_SCRIPT: { - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { pev->origin = m_hTargetEnt->pev->origin; // Plant on target } @@ -1282,7 +1282,7 @@ void CBaseMonster::StartTask( Task_t *pTask ) } case TASK_FACE_SCRIPT: { - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { pev->ideal_yaw = UTIL_AngleMod( m_hTargetEnt->pev->angles.y ); } diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index 4e60c58e..d7659c61 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -434,7 +434,7 @@ void CScientist::Scream( void ) Activity CScientist::GetStoppedActivity( void ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) return ACT_EXCITED; return CTalkMonster::GetStoppedActivity(); } @@ -510,7 +510,7 @@ void CScientist::RunTask( Task_t *pTask ) if( RANDOM_LONG( 0, 63 ) < 8 ) Scream(); - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { TaskFail(); } @@ -893,8 +893,8 @@ Schedule_t *CScientist::GetSchedule( void ) m_fearTime = gpGlobals->time; else if( DisregardEnemy( pEnemy ) ) // After 15 seconds of being hidden, return to alert { - m_hEnemy = NULL; - pEnemy = NULL; + m_hEnemy = 0; + pEnemy = 0; } } @@ -1021,12 +1021,12 @@ MONSTERSTATE CScientist::GetIdealState( void ) { // Strip enemy when going to alert m_IdealMonsterState = MONSTERSTATE_ALERT; - m_hEnemy = NULL; + m_hEnemy = 0; return m_IdealMonsterState; } // Follow if only scared a little - if( m_hTargetEnt != NULL ) + if( m_hTargetEnt != 0 ) { m_IdealMonsterState = MONSTERSTATE_ALERT; return m_IdealMonsterState; @@ -1050,7 +1050,7 @@ MONSTERSTATE CScientist::GetIdealState( void ) BOOL CScientist::CanHeal( void ) { - if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == NULL ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5 ) ) ) + if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == 0 ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5 ) ) ) return FALSE; return TRUE; @@ -1093,10 +1093,10 @@ public: void KeyValue( KeyValueData *pkvd ); int m_iPose;// which sequence to display - static char *m_szPoses[7]; + static const char *m_szPoses[7]; }; -char *CDeadScientist::m_szPoses[] = +const char *CDeadScientist::m_szPoses[] = { "lying_on_back", "lying_on_stomach", diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index f3cf37c5..da9708d1 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -1068,7 +1068,7 @@ BOOL CScriptedSentence::AcceptableSpeaker( CBaseMonster *pMonster ) { if( pev->spawnflags & SF_SENTENCE_FOLLOWERS ) { - if( pMonster->m_hTargetEnt == NULL || !FClassnameIs( pMonster->m_hTargetEnt->pev, "player" ) ) + if( pMonster->m_hTargetEnt == 0 || !FClassnameIs( pMonster->m_hTargetEnt->pev, "player" ) ) return FALSE; } BOOL override; @@ -1124,7 +1124,7 @@ BOOL CScriptedSentence::StartSentence( CBaseMonster *pTarget ) if( !pTarget ) { ALERT( at_aiconsole, "Not Playing sentence %s\n", STRING( m_iszSentence ) ); - return NULL; + return FALSE; } BOOL bConcurrent = FALSE; diff --git a/dlls/skill.cpp b/dlls/skill.cpp index 2a68e1a5..689bbadb 100644 --- a/dlls/skill.cpp +++ b/dlls/skill.cpp @@ -25,13 +25,12 @@ skilldata_t gSkillData; // take the name of a cvar, tack a digit for the skill level // on, and return the value.of that Cvar //========================================================= -float GetSkillCvar( char *pName ) +float GetSkillCvar( const char *pName ) { - int iCount; float flValue; char szBuffer[64]; - iCount = sprintf( szBuffer, "%s%d",pName, gSkillData.iSkillLevel ); + sprintf( szBuffer, "%s%d",pName, gSkillData.iSkillLevel ); flValue = CVAR_GET_FLOAT( szBuffer ); diff --git a/dlls/skill.h b/dlls/skill.h index 5e784bed..12b784e3 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -136,7 +136,7 @@ struct skilldata_t }; extern DLL_GLOBAL skilldata_t gSkillData; -float GetSkillCvar( char *pName ); +float GetSkillCvar( const char *pName ); extern DLL_GLOBAL int g_iSkillLevel; diff --git a/dlls/sound.cpp b/dlls/sound.cpp index b97eee12..f6110a8d 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -448,7 +448,7 @@ void CAmbientGeneric::InitModulationParms( void ) { int pitchinc; - m_dpv.volrun = pev->health * 10; // 0 - 100 + m_dpv.volrun = (int)( pev->health * 10 ); // 0 - 100 if( m_dpv.volrun > 100 ) m_dpv.volrun = 100; if( m_dpv.volrun < 0 ) @@ -553,7 +553,7 @@ void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, if( fraction < 0.0 ) fraction = 0.01; - m_dpv.pitch = fraction * 255; + m_dpv.pitch = (int)( fraction * 255 ); UTIL_EmitAmbientSound( ENT( pev ), pev->origin, szSoundFile, 0, 0, SND_CHANGE_PITCH, m_dpv.pitch ); return; @@ -1610,7 +1610,7 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in const char *pTextureName; float rgfl1[3]; float rgfl2[3]; - char *rgsz[4]; + const char *rgsz[4]; int cnt; float fattn = ATTN_NORM; @@ -1822,7 +1822,7 @@ IMPLEMENT_SAVERESTORE( CSpeaker, CBaseEntity ) // void CSpeaker::Spawn( void ) { - char *szSoundFile = (char*) STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); if( !m_preset && ( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) ) { @@ -1854,7 +1854,7 @@ void CSpeaker::Precache( void ) } void CSpeaker::SpeakerThink( void ) { - char* szSoundFile; + const char* szSoundFile = NULL; float flvolume = pev->health * 0.1; float flattenuation = 0.3; int flags = 0; @@ -1911,7 +1911,7 @@ void CSpeaker::SpeakerThink( void ) } } else - szSoundFile = (char*)STRING( pev->message ); + szSoundFile = STRING( pev->message ); if( szSoundFile[0] == '!' ) { diff --git a/dlls/squadmonster.cpp b/dlls/squadmonster.cpp index a89f39f9..3d476b50 100644 --- a/dlls/squadmonster.cpp +++ b/dlls/squadmonster.cpp @@ -192,7 +192,7 @@ BOOL CSquadMonster::SquadAdd( CSquadMonster *pAdd ) for( int i = 0; i < MAX_SQUAD_MEMBERS - 1; i++ ) { - if( m_hSquadMember[i] == NULL ) + if( m_hSquadMember[i] == 0 ) { m_hSquadMember[i] = pAdd; pAdd->m_hSquadLeader = this; @@ -258,7 +258,7 @@ void CSquadMonster::SquadMakeEnemy( CBaseEntity *pEnemy ) // reset members who aren't activly engaged in fighting if( pMember->m_hEnemy != pEnemy && !pMember->HasConditions( bits_COND_SEE_ENEMY ) ) { - if( pMember->m_hEnemy != NULL ) + if( pMember->m_hEnemy != 0 ) { // remember their current enemy pMember->PushEnemy( pMember->m_hEnemy, pMember->m_vecEnemyLKP ); @@ -459,7 +459,7 @@ BOOL CSquadMonster::NoFriendlyFire( void ) Vector v_left; //!!!BUGBUG - to fix this, the planes must be aligned to where the monster will be firing its gun, not the direction it is facing!!! - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { UTIL_MakeVectors( UTIL_VecToAngles( m_hEnemy->Center() - pev->origin ) ); } @@ -508,9 +508,7 @@ BOOL CSquadMonster::NoFriendlyFire( void ) //========================================================= MONSTERSTATE CSquadMonster::GetIdealState ( void ) { - int iConditions; - - iConditions = IScheduleFlags(); + IScheduleFlags(); // If no schedule conditions, the new ideal state is probably the reason we're in here. switch( m_MonsterState ) @@ -565,7 +563,7 @@ BOOL CSquadMonster::SquadEnemySplit( void ) for( int i = 0; i < MAX_SQUAD_MEMBERS; i++ ) { CSquadMonster *pMember = pSquadLeader->MySquadMember( i ); - if( pMember != NULL && pMember->m_hEnemy != NULL && pMember->m_hEnemy != pEnemy ) + if( pMember != NULL && pMember->m_hEnemy != 0 && pMember->m_hEnemy != pEnemy ) { return TRUE; } diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index ecd75ee5..707910c2 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -88,7 +88,7 @@ public: else return (CSquadMonster *)( (CBaseEntity *)m_hSquadMember[i] ); } - int InSquad( void ) { return m_hSquadLeader != NULL; } + int InSquad( void ) { return m_hSquadLeader != 0; } int IsLeader( void ) { return m_hSquadLeader == this; } int SquadJoin( int searchRadius ); int SquadRecruit( int searchRadius, int maxMembers ); diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index 30ddda62..830cfab8 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -94,7 +94,7 @@ int CSqueakGrenade::Classify( void ) if( m_iMyClass != 0 ) return m_iMyClass; // protect against recursion - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { m_iMyClass = CLASS_INSECT; // no one cares about it switch( m_hEnemy->Classify() ) @@ -180,13 +180,13 @@ void CSqueakGrenade::Killed( entvars_t *pevAttacker, int iGib ) UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 ); - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) RadiusDamage( pev, m_hOwner->pev, pev->dmg, CLASS_NONE, DMG_BLAST ); else RadiusDamage( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST ); // reset owner so death message happens - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) pev->owner = m_hOwner->edict(); CBaseMonster::Killed( pevAttacker, GIB_ALWAYS ); @@ -230,7 +230,7 @@ void CSqueakGrenade::HuntThink( void ) pev->velocity = pev->velocity * 0.9; pev->velocity.z += 8.0; } - else if( ( pev->movetype = MOVETYPE_FLY ) ) + else if( pev->movetype == MOVETYPE_FLY ) { pev->movetype = MOVETYPE_BOUNCE; } @@ -241,7 +241,7 @@ void CSqueakGrenade::HuntThink( void ) m_flNextHunt = gpGlobals->time + 2.0; - CBaseEntity *pOther = NULL; + //CBaseEntity *pOther = NULL; Vector vecDir; TraceResult tr; @@ -251,7 +251,7 @@ void CSqueakGrenade::HuntThink( void ) UTIL_MakeVectors( pev->angles ); - if( m_hEnemy == NULL || !m_hEnemy->IsAlive() ) + if( m_hEnemy == 0 || !m_hEnemy->IsAlive() ) { // find target, bounce a bit towards it. Look( 512 ); @@ -270,7 +270,7 @@ void CSqueakGrenade::HuntThink( void ) if( flpitch < 80 ) flpitch = 80; - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( FVisible( m_hEnemy ) ) { @@ -350,9 +350,9 @@ void CSqueakGrenade::SuperBounceTouch( CBaseEntity *pOther ) if( tr.pHit->v.modelindex != pev->modelindex ) { // ALERT( at_console, "hit enemy\n" ); - ClearMultiDamage( ); + ClearMultiDamage(); pOther->TraceAttack( pev, gSkillData.snarkDmgBite, gpGlobals->v_forward, &tr, DMG_SLASH ); - if( m_hOwner != NULL ) + if( m_hOwner != 0 ) ApplyMultiDamage( pev, m_hOwner->pev ); else ApplyMultiDamage( pev, pev ); diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index d832c2cc..35bf3856 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -51,7 +51,7 @@ TYPEDESCRIPTION CTalkMonster::m_SaveData[] = IMPLEMENT_SAVERESTORE( CTalkMonster, CBaseMonster ) // array of friend names -char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = +const char *CTalkMonster::m_szFriends[TLK_CFRIENDS] = { "monster_barney", "monster_scientist", @@ -391,7 +391,7 @@ void CTalkMonster::StartTask( Task_t *pTask ) case TASK_TLK_EYECONTACT: break; case TASK_TLK_IDEALYAW: - if( m_hTalkTarget != NULL ) + if( m_hTalkTarget != 0 ) { pev->yaw_speed = 60; float yaw = VecToYaw( m_hTalkTarget->pev->origin - pev->origin ) - pev->angles.y; @@ -536,7 +536,7 @@ void CTalkMonster::RunTask( Task_t *pTask ) } break; case TASK_TLK_EYECONTACT: - if( !IsMoving() && IsTalking() && m_hTalkTarget != NULL ) + if( !IsMoving() && IsTalking() && m_hTalkTarget != 0 ) { // ALERT( at_console, "waiting %f\n", m_flStopTalkTime - gpGlobals->time ); IdleHeadTurn( m_hTalkTarget->pev->origin ); @@ -561,7 +561,7 @@ void CTalkMonster::RunTask( Task_t *pTask ) } break; case TASK_WAIT_FOR_MOVEMENT: - if( IsTalking() && m_hTalkTarget != NULL ) + if( IsTalking() && m_hTalkTarget != 0 ) { // ALERT( at_console, "walking, talking\n" ); IdleHeadTurn( m_hTalkTarget->pev->origin ); @@ -582,7 +582,7 @@ void CTalkMonster::RunTask( Task_t *pTask ) IdleHeadTurn( pev->origin ); break; default: - if( IsTalking() && m_hTalkTarget != NULL ) + if( IsTalking() && m_hTalkTarget != 0 ) { IdleHeadTurn( m_hTalkTarget->pev->origin ); } @@ -603,7 +603,7 @@ void CTalkMonster::Killed( entvars_t *pevAttacker, int iGib ) LimitFollowers( CBaseEntity::Instance( pevAttacker ), 0 ); } - m_hTargetEnt = NULL; + m_hTargetEnt = 0; // Don't finish that sentence StopTalking(); SetUse( NULL ); @@ -613,7 +613,7 @@ void CTalkMonster::Killed( entvars_t *pevAttacker, int iGib ) CBaseEntity *CTalkMonster::EnumFriends( CBaseEntity *pPrevious, int listNumber, BOOL bTrace ) { CBaseEntity *pFriend = pPrevious; - char *pszFriend; + const char *pszFriend; TraceResult tr; Vector vecCheck; @@ -712,7 +712,7 @@ void CTalkMonster::LimitFollowers( CBaseEntity *pPlayer, int maxFollowers ) float CTalkMonster::TargetDistance( void ) { // If we lose the player, or he dies, return a really large distance - if( m_hTargetEnt == NULL || !m_hTargetEnt->IsAlive() ) + if( m_hTargetEnt == 0 || !m_hTargetEnt->IsAlive() ) return 1e6; return ( m_hTargetEnt->pev->origin - pev->origin ).Length(); @@ -764,7 +764,7 @@ CBaseEntity *CTalkMonster::FindNearestFriend( BOOL fPlayer ) Vector vecStart = pev->origin; Vector vecCheck; int i; - char *pszFriend; + const char *pszFriend; int cfriends; vecStart.z = pev->absmax.z; @@ -855,7 +855,7 @@ void CTalkMonster::Touch( CBaseEntity *pOther ) //========================================================= void CTalkMonster::IdleRespond( void ) { - int pitch = GetVoicePitch(); + //int pitch = GetVoicePitch(); // play response PlaySentence( m_szGrp[TLK_ANSWER], RANDOM_FLOAT( 2.8, 3.2 ), VOL_NORM, ATTN_IDLE ); @@ -890,7 +890,7 @@ int CTalkMonster::FOkToSpeak( void ) return FALSE; // don't talk if you're in combat - if( m_hEnemy != NULL && FVisible( m_hEnemy ) ) + if( m_hEnemy != 0 && FVisible( m_hEnemy ) ) return FALSE; return TRUE; @@ -977,7 +977,7 @@ void CTalkMonster::IdleHeadTurn( Vector &vecFriend ) int CTalkMonster::FIdleSpeak( void ) { // try to start a conversation, or make statement - int pitch; + //int pitch; const char *szIdleGroup; const char *szQuestionGroup; float duration; @@ -1001,7 +1001,7 @@ int CTalkMonster::FIdleSpeak( void ) duration = RANDOM_FLOAT( 2.8, 3.2 ); } - pitch = GetVoicePitch(); + //pitch = GetVoicePitch(); // player using this entity is alive and wounded? CBaseEntity *pTarget = m_hTargetEnt; @@ -1315,10 +1315,10 @@ void CTalkMonster::StopFollowing( BOOL clearSchedule ) if( m_movementGoal == MOVEGOAL_TARGETENT ) RouteClear(); // Stop him from walking toward the player - m_hTargetEnt = NULL; + m_hTargetEnt = 0; if( clearSchedule ) ClearSchedule(); - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) m_IdealMonsterState = MONSTERSTATE_COMBAT; } } @@ -1328,7 +1328,7 @@ void CTalkMonster::StartFollowing( CBaseEntity *pLeader ) if( m_pCine ) m_pCine->CancelScript(); - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) m_IdealMonsterState = MONSTERSTATE_ALERT; m_hTargetEnt = pLeader; diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 57c417e4..72222aae 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -138,7 +138,7 @@ public: // For following BOOL CanFollow( void ); - BOOL IsFollowing( void ) { return m_hTargetEnt != NULL && m_hTargetEnt->IsPlayer(); } + BOOL IsFollowing( void ) { return m_hTargetEnt != 0 && m_hTargetEnt->IsPlayer(); } void StopFollowing( BOOL clearSchedule ); void StartFollowing( CBaseEntity *pLeader ); virtual void DeclineFollowing( void ) {} @@ -154,7 +154,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; - static char *m_szFriends[TLK_CFRIENDS]; // array of friend names + static const char *m_szFriends[TLK_CFRIENDS]; // array of friend names static float g_talkWaitTime; int m_bitsSaid; // set bits for sentences we don't want repeated diff --git a/dlls/teamplay_gamerules.cpp b/dlls/teamplay_gamerules.cpp index 614bd7bb..87b695e7 100644 --- a/dlls/teamplay_gamerules.cpp +++ b/dlls/teamplay_gamerules.cpp @@ -116,7 +116,7 @@ void CHalfLifeTeamplay::Think( void ) return; } - remain = flFragLimit - team_scores[i]; + remain = (int)( flFragLimit - team_scores[i] ); if( remain < bestfrags ) { bestfrags = remain; @@ -157,7 +157,7 @@ BOOL CHalfLifeTeamplay::ClientCommand( CBasePlayer *pPlayer, const char *pcmd ) if( CMD_ARGC() < 2 ) return TRUE; - int slot = atoi( CMD_ARGV( 1 ) ); + //int slot = atoi( CMD_ARGV( 1 ) ); // select the item from the current menu return TRUE; @@ -241,7 +241,7 @@ void CHalfLifeTeamplay::InitHUD( CBasePlayer *pPlayer ) ChangePlayerTeam( pPlayer, pPlayer->m_szTeamName, FALSE, FALSE ); UTIL_SayText( text, pPlayer ); - int clientIndex = pPlayer->entindex(); + //int clientIndex = pPlayer->entindex(); RecountTeams(); // update this player with all the other players team info // loop through all active players and send their team info to the new client @@ -300,7 +300,7 @@ void CHalfLifeTeamplay::ChangePlayerTeam( CBasePlayer *pPlayer, const char *pTea MESSAGE_BEGIN( MSG_ALL, gmsgScoreInfo ); WRITE_BYTE( clientIndex ); - WRITE_SHORT( pPlayer->pev->frags ); + WRITE_SHORT( (int)pPlayer->pev->frags ); WRITE_SHORT( pPlayer->m_iDeaths ); WRITE_SHORT( 0 ); WRITE_SHORT( g_pGameRules->GetTeamIndex( pPlayer->m_szTeamName ) + 1 ); @@ -607,7 +607,7 @@ void CHalfLifeTeamplay::RecountTeams( bool bResendInfo ) if( tm >= 0 ) { - team_scores[tm] += plr->pev->frags; + team_scores[tm] += (int)plr->pev->frags; } if( bResendInfo ) //Someone's info changed, let's send the team info again. diff --git a/dlls/tentacle.cpp b/dlls/tentacle.cpp index 637b8946..44b8b45b 100644 --- a/dlls/tentacle.cpp +++ b/dlls/tentacle.cpp @@ -486,12 +486,12 @@ void CTentacle::Cycle( void ) m_flSoundYaw += 360; if( m_flSoundYaw > 180 ) m_flSoundYaw -= 360; - +#if 0 // ALERT( at_console, "sound %d %.0f\n", m_iSoundLevel, m_flSoundYaw ); if( m_flSoundTime < gpGlobals->time ) { // play "I hear new something" sound - char *sound; + const char *sound; switch( RANDOM_LONG( 0, 1 ) ) { @@ -505,6 +505,7 @@ void CTentacle::Cycle( void ) // UTIL_EmitAmbientSound( ENT( pev ), pev->origin + Vector( 0, 0, MyHeight() ), sound, 1.0, ATTN_NORM, 0, 100 ); } +#endif m_flSoundTime = gpGlobals->time + RANDOM_FLOAT( 5.0, 10.0 ); } @@ -591,7 +592,7 @@ void CTentacle::Cycle( void ) if( m_flNextSong < gpGlobals->time ) { // play "I hear new something" sound - char *sound; + const char *sound; switch( RANDOM_LONG( 0, 1 ) ) { @@ -791,7 +792,7 @@ void CTentacle::DieThink( void ) void CTentacle::HandleAnimEvent( MonsterEvent_t *pEvent ) { - char *sound; + const char *sound; switch( pEvent->event ) { diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 958f899f..2959d96d 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -1265,7 +1265,7 @@ void CTriggerVolume::Spawn( void ) pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; SET_MODEL( ENT(pev), STRING( pev->model ) ); // set size and link into world - pev->model = NULL; + pev->model = 0; pev->modelindex = 0; } @@ -1438,7 +1438,7 @@ void CChangeLevel::UseChangeLevel( CBaseEntity *pActivator, CBaseEntity *pCaller void CChangeLevel::ChangeLevelNow( CBaseEntity *pActivator ) { edict_t *pentLandmark; - LEVELLIST levels[16]; + //LEVELLIST levels[16]; ASSERT( !FStrEq( m_szMapName, "" ) ); @@ -2224,7 +2224,7 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP } // Nothing to look at! - if( m_hTarget == NULL ) + if( m_hTarget == 0 ) { return; } @@ -2280,10 +2280,10 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void CTriggerCamera::FollowTarget() { - if( m_hPlayer == NULL ) + if( m_hPlayer == 0 ) return; - if( m_hTarget == NULL || m_flReturnTime < gpGlobals->time ) + if( m_hTarget == 0 || m_flReturnTime < gpGlobals->time ) { if( m_hPlayer->IsAlive() ) { diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index e2ed0817..520206dd 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -162,7 +162,7 @@ void CTripmineGrenade::PowerupThink( void ) { TraceResult tr; - if( m_hOwner == NULL ) + if( m_hOwner == 0 ) { // find an owner edict_t *oldowner = pev->owner; @@ -217,7 +217,7 @@ void CTripmineGrenade::PowerupThink( void ) MakeBeam(); // play enabled sound - EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1.0, 75 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "weapons/mine_activate.wav", 0.5, ATTN_NORM, 1, 75 ); } pev->nextthink = gpGlobals->time + 0.1; } @@ -280,7 +280,7 @@ void CTripmineGrenade::BeamBreakThink( void ) } else { - if( m_hOwner == NULL ) + if( m_hOwner == 0 ) bBlowup = 1; else if( m_posOwner != m_hOwner->pev->origin ) bBlowup = 1; @@ -446,7 +446,7 @@ void CTripmine::PrimaryAttack( void ) { Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal ); - CBaseEntity *pEnt = CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 8, angles, m_pPlayer->edict() ); + CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 8, angles, m_pPlayer->edict() ); m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; diff --git a/dlls/turret.cpp b/dlls/turret.cpp index 2dce87fb..5b9e1b77 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -456,7 +456,7 @@ void CBaseTurret::ActiveThink( void ) pev->nextthink = gpGlobals->time + 0.1; StudioFrameAdvance(); - if( ( !m_iOn ) || ( m_hEnemy == NULL ) ) + if( ( !m_iOn ) || ( m_hEnemy == 0 ) ) { m_hEnemy = NULL; m_flLastSight = gpGlobals->time + m_flMaxWait; @@ -826,21 +826,21 @@ void CBaseTurret::SearchThink( void ) Ping(); // If we have a target and we're still healthy - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( !m_hEnemy->IsAlive() ) m_hEnemy = NULL;// Dead enemy forces a search for new one } // Acquire Target - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { Look( TURRET_RANGE ); m_hEnemy = BestVisibleEnemy(); } // If we've found a target, spin up the barrel and start to attack - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { m_flLastSight = 0; m_flSpinUpTime = 0; @@ -881,20 +881,20 @@ void CBaseTurret::AutoSearchThink( void ) pev->nextthink = gpGlobals->time + 0.3; // If we have a target and we're still healthy - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( !m_hEnemy->IsAlive() ) m_hEnemy = NULL;// Dead enemy forces a search for new one } // Acquire Target - if( m_hEnemy == NULL ) + if( m_hEnemy == 0 ) { Look( TURRET_RANGE ); m_hEnemy = BestVisibleEnemy(); } - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { SetThink( &CBaseTurret::Deploy ); EMIT_SOUND( ENT( pev ), CHAN_BODY, "turret/tu_alert.wav", TURRET_MACHINE_VOLUME, ATTN_NORM ); @@ -903,7 +903,7 @@ void CBaseTurret::AutoSearchThink( void ) void CBaseTurret::TurretDeath( void ) { - BOOL iActive = FALSE; + //BOOL iActive = FALSE; StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; @@ -1222,7 +1222,7 @@ void CSentry::SentryTouch( CBaseEntity *pOther ) void CSentry::SentryDeath( void ) { - BOOL iActive = FALSE; + //BOOL iActive = FALSE; StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; diff --git a/dlls/util.cpp b/dlls/util.cpp index 9c7d9803..d79c9f5a 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -118,7 +118,7 @@ float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ) U_Random(); U_Random(); - range = high - low; + range = (int)( high - low ); if( !range ) { return low; @@ -625,7 +625,7 @@ static unsigned short FixedUnsigned16( float value, float scale ) { int output; - output = value * scale; + output = (int)( value * scale ); if( output < 0 ) output = 0; if( output > 0xFFFF ) @@ -638,7 +638,7 @@ static short FixedSigned16( float value, float scale ) { int output; - output = value * scale; + output = (int)( value * scale ); if( output > 32767 ) output = 32767; @@ -937,10 +937,10 @@ TraceResult UTIL_GetGlobalTrace( ) { TraceResult tr; - tr.fAllSolid = gpGlobals->trace_allsolid; - tr.fStartSolid = gpGlobals->trace_startsolid; - tr.fInOpen = gpGlobals->trace_inopen; - tr.fInWater = gpGlobals->trace_inwater; + tr.fAllSolid = (int)gpGlobals->trace_allsolid; + tr.fStartSolid = (int)gpGlobals->trace_startsolid; + tr.fInOpen = (int)gpGlobals->trace_inopen; + tr.fInWater = (int)gpGlobals->trace_inwater; tr.flFraction = gpGlobals->trace_fraction; tr.flPlaneDist = gpGlobals->trace_plane_dist; tr.pHit = gpGlobals->trace_ent; @@ -1033,7 +1033,7 @@ float UTIL_SplineFraction( float value, float scale ) return 3 * valueSquared - 2 * valueSquared * value; } -char *UTIL_VarArgs( char *format, ... ) +char *UTIL_VarArgs( const char *format, ... ) { va_list argptr; static char string[1024]; @@ -1536,7 +1536,7 @@ void UTIL_PrecacheOther( const char *szClassname ) // UTIL_LogPrintf - Prints a logged message to console. // Preceded by LOG: ( timestamp ) < message > //========================================================= -void UTIL_LogPrintf( char *fmt, ... ) +void UTIL_LogPrintf( const char *fmt, ... ) { va_list argptr; static char string[1024]; @@ -1902,7 +1902,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) int i; TYPEDESCRIPTION *pField; - for( i = 0; i < ENTVARS_COUNT; i++ ) + for( i = 0; i < (int)ENTVARS_COUNT; i++ ) { pField = &gEntvarsDescription[i]; diff --git a/dlls/util.h b/dlls/util.h index f8ae0b6a..fc345ae4 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -87,8 +87,9 @@ typedef int EOFFSET; typedef int BOOL; // In case this ever changes +#ifndef M_PI #define M_PI 3.14159265358979323846 - +#endif // Keeps clutter down a bit, when declaring external entity/global method prototypes #define DECLARE_GLOBAL_METHOD(MethodName) extern void DLLEXPORT MethodName( void ) #define GLOBAL_METHOD(funcname) void DLLEXPORT funcname(void) @@ -304,7 +305,7 @@ extern float UTIL_Approach( float target, float value, float speed ); extern float UTIL_ApproachAngle( float target, float value, float speed ); extern float UTIL_AngleDistance( float next, float cur ); -extern char *UTIL_VarArgs( char *format, ... ); +extern char *UTIL_VarArgs( const char *format, ... ); extern void UTIL_Remove( CBaseEntity *pEntity ); extern BOOL UTIL_IsValidEntity( edict_t *pent ); extern BOOL UTIL_TeamsMatch( const char *pTeamName1, const char *pTeamName2 ); @@ -364,7 +365,7 @@ extern char *UTIL_dtos3( int d ); extern char *UTIL_dtos4( int d ); // Writes message to console with timestamp and FragLog header. -extern void UTIL_LogPrintf( char *fmt, ... ); +extern void UTIL_LogPrintf( const char *fmt, ... ); // Sorta like FInViewCone, but for nonmonsters. extern float UTIL_DotPoints ( const Vector &vecSrc, const Vector &vecCheck, const Vector &vecDir ); @@ -534,7 +535,7 @@ void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg); void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); #define PRECACHE_SOUND_ARRAY( a ) \ - { for (int i = 0; i < ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); } + { for (int i = 0; i < (int)ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); } #define EMIT_SOUND_ARRAY_DYN( chan, array ) \ EMIT_SOUND_DYN ( ENT(pev), chan , array [ RANDOM_LONG(0,ARRAYSIZE( array )-1) ], 1.0, ATTN_NORM, 0, RANDOM_LONG(95,105) ); diff --git a/dlls/vector.h b/dlls/vector.h index d3347983..265a9b00 100644 --- a/dlls/vector.h +++ b/dlls/vector.h @@ -22,8 +22,8 @@ class Vector2D { public: - inline Vector2D(void) { } - inline Vector2D(float X, float Y) { x = X; y = Y; } + inline Vector2D(void): x( 0.0f ), y( 0.0f ) { } + inline Vector2D(float X, float Y): x( 0.0f ), y( 0.0f ) { x = X; y = Y; } inline Vector2D operator+(const Vector2D& v) const { return Vector2D( x + v.x, y + v.y ); } inline Vector2D operator-(const Vector2D& v) const { return Vector2D( x - v.x, y - v.y ); } inline Vector2D operator*(float fl) const { return Vector2D( x * fl, y * fl ); } @@ -33,7 +33,7 @@ public: inline Vector2D Normalize ( void ) const { - Vector2D vec2; + //Vector2D vec2; float flLen = Length(); if( flLen == 0 ) @@ -60,12 +60,12 @@ class Vector // same data-layout as engine's vec3_t, { // which is a vec_t[3] public: // Construction/destruction - inline Vector( void ) { } - inline Vector( float X, float Y, float Z ) { x = X; y = Y; z = Z; } + inline Vector( void ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { } + inline Vector( float X, float Y, float Z ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { x = X; y = Y; z = Z; } //inline Vector( double X, double Y, double Z ) { x = (float)X; y = (float)Y; z = (float)Z; } //inline Vector( int X, int Y, int Z ) { x = (float)X; y = (float)Y; z = (float)Z; } - inline Vector( const Vector& v ) { x = v.x; y = v.y; z = v.z; } - inline Vector( float rgfl[3] ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } + inline Vector( const Vector& v ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { x = v.x; y = v.y; z = v.z; } + inline Vector( float rgfl[3] ): x( 0.0f ), y( 0.0f ), z( 0.0f ) { x = rgfl[0]; y = rgfl[1]; z = rgfl[2]; } // Operators inline Vector operator-( void ) const { return Vector( -x, -y, -z ); } diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index ee2a8547..0b6f7de6 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -935,7 +935,7 @@ BOOL CBasePlayerWeapon::CanDeploy( void ) return TRUE; } -BOOL CBasePlayerWeapon::DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal /* = 0 */, int body ) +BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal /* = 0 */, int body ) { if( !CanDeploy() ) return FALSE; @@ -1400,7 +1400,7 @@ BOOL CWeaponBox::PackAmmo( int iszName, int iCount ) //========================================================= // CWeaponBox - GiveAmmo //========================================================= -int CWeaponBox::GiveAmmo( int iCount, char *szName, int iMax, int *pIndex/* = NULL*/ ) +int CWeaponBox::GiveAmmo( int iCount, const char *szName, int iMax, int *pIndex/* = NULL*/ ) { int i; diff --git a/dlls/weapons.h b/dlls/weapons.h index 3e6fc5ce..8d60bad8 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -310,7 +310,7 @@ public: virtual BOOL CanDeploy( void ); virtual BOOL IsUseable( void ); - BOOL DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal = 0, int body = 0 ); + BOOL DefaultDeploy( const char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal = 0, int body = 0 ); int DefaultReload( int iClipSize, int iAnim, float fDelay, int body = 0 ); virtual void ItemPostFrame( void ); // called each frame by the player PostThink @@ -430,7 +430,7 @@ class CWeaponBox : public CBaseEntity void Touch( CBaseEntity *pOther ); void KeyValue( KeyValueData *pkvd ); BOOL IsEmpty( void ); - int GiveAmmo( int iCount, char *szName, int iMax, int *pIndex = NULL ); + int GiveAmmo( int iCount, const char *szName, int iMax, int *pIndex = NULL ); void SetObjectCollisionBox( void ); public: @@ -453,7 +453,7 @@ public: #ifdef CLIENT_DLL bool bIsMultiplayer ( void ); -void LoadVModel ( char *szViewModel, CBasePlayer *m_pPlayer ); +void LoadVModel ( const char *szViewModel, CBasePlayer *m_pPlayer ); #endif class CGlock : public CBasePlayerWeapon @@ -828,7 +828,9 @@ public: unsigned short m_usEgonStop; private: +#ifndef CLIENT_DLL float m_shootTime; +#endif EGON_FIREMODE m_fireMode; float m_shakeTime; BOOL m_deployed; diff --git a/dlls/world.cpp b/dlls/world.cpp index a065b5be..f352bd52 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -292,7 +292,7 @@ globalentity_t *CGlobalState::Find( string_t globalname ) //#ifdef _DEBUG void CGlobalState::DumpGlobals( void ) { - static char *estates[] = { "Off", "On", "Dead" }; + static const char *estates[] = { "Off", "On", "Dead" }; globalentity_t *pTest; ALERT( at_console, "-- Globals --\n" ); @@ -582,7 +582,7 @@ void CWorld::Precache( void ) // 63 testing LIGHT_STYLE( 63, "a" ); - for( int i = 0; i < ARRAYSIZE( gDecals ); i++ ) + for( int i = 0; i < (int)ARRAYSIZE( gDecals ); i++ ) gDecals[i].index = DECAL_INDEX( gDecals[i].name ); // init the WorldGraph. diff --git a/dlls/xen.cpp b/dlls/xen.cpp index 8e9c771c..4e9e1685 100644 --- a/dlls/xen.cpp +++ b/dlls/xen.cpp @@ -98,7 +98,7 @@ void CXenPLight::Spawn( void ) pev->frame = RANDOM_FLOAT( 0, 255 ); m_pGlow = CSprite::SpriteCreate( XEN_PLANT_GLOW_SPRITE, pev->origin + Vector(0,0,(pev->mins.z+pev->maxs.z)*0.5), FALSE ); - m_pGlow->SetTransparency( kRenderGlow, pev->rendercolor.x, pev->rendercolor.y, pev->rendercolor.z, pev->renderamt, pev->renderfx ); + m_pGlow->SetTransparency( kRenderGlow, (int)pev->rendercolor.x, (int)pev->rendercolor.y, (int)pev->rendercolor.z, (int)pev->renderamt, (int)pev->renderfx ); m_pGlow->SetAttachment( edict(), 1 ); } @@ -497,7 +497,7 @@ void CXenSporeLarge::Spawn( void ) UTIL_MakeVectorsPrivate( pev->angles, forward, right, NULL ); // Rotate the leg hulls into position - for( int i = 0; i < ARRAYSIZE( m_hullSizes ); i++ ) + for( int i = 0; i < (int)ARRAYSIZE( m_hullSizes ); i++ ) CXenHull::CreateHull( this, Vector( -12, -12, 0 ), Vector( 12, 12, 120 ), ( m_hullSizes[i].x * forward ) + ( m_hullSizes[i].y * right ) ); } @@ -536,7 +536,7 @@ void CXenSpore::Touch( CBaseEntity *pOther ) void CXenSpore::Think( void ) { - float flInterval = StudioFrameAdvance(); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; #if 0 DispatchAnimEvents( flInterval ); diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index b20293c1..2611f881 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -286,7 +286,7 @@ void CZombie::Spawn() //========================================================= void CZombie::Precache() { - int i; + size_t i; PRECACHE_MODEL( "models/zombie.mdl" ); diff --git a/engine/custom.h b/engine/custom.h index d48ee72d..8f644e00 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -16,6 +16,12 @@ #ifndef CUSTOM_H #define CUSTOM_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + #include "const.h" ///////////////// diff --git a/engine/edict.h b/engine/edict.h index b0469b86..e89b6926 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -16,6 +16,12 @@ #ifndef EDICT_H #define EDICT_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + #define MAX_ENT_LEAFS 48 #include "progdefs.h" @@ -39,4 +45,4 @@ struct edict_s // other fields from progs come immediately after }; -#endif//EDICT_H \ No newline at end of file +#endif//EDICT_H diff --git a/engine/eiface.h b/engine/eiface.h index 3419e5bd..30f8a82a 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -94,13 +94,13 @@ typedef unsigned int CRC32_t; // Engine hands this to DLLs for functionality callbacks typedef struct enginefuncs_s { - int (*pfnPrecacheModel)( char* s ); - int (*pfnPrecacheSound)( char* s ); + int (*pfnPrecacheModel)( const char *s ); + int (*pfnPrecacheSound)( const char *s ); void (*pfnSetModel)( edict_t *e, const char *m ); int (*pfnModelIndex)( const char *m ); int (*pfnModelFrames)( int modelIndex ); void (*pfnSetSize)( edict_t *e, const float *rgflMin, const float *rgflMax ); - void (*pfnChangeLevel)( char* s1, char* s2 ); + void (*pfnChangeLevel)( const char *s1, const char *s2 ); void (*pfnGetSpawnParms)( edict_t *ent ); void (*pfnSaveSpawnParms)( edict_t *ent ); float (*pfnVecToYaw)( const float *rgflVector ); @@ -132,12 +132,12 @@ typedef struct enginefuncs_s void (*pfnTraceModel)( const float *v1, const float *v2, int hullNumber, edict_t *pent, TraceResult *ptr ); const char *(*pfnTraceTexture)( edict_t *pTextureEntity, const float *v1, const float *v2 ); void (*pfnTraceSphere)( const float *v1, const float *v2, int fNoMonsters, float radius, edict_t *pentToSkip, TraceResult *ptr ); - void (*pfnGetAimVector)( edict_t* ent, float speed, float *rgflReturn ); - void (*pfnServerCommand)( char* str ); + void (*pfnGetAimVector)( edict_t *ent, float speed, float *rgflReturn ); + void (*pfnServerCommand)( const char *str ); void (*pfnServerExecute)( void ); - void (*pfnClientCommand)( edict_t* pEdict, char* szFmt, ... ); + void (*pfnClientCommand)( edict_t* pEdict, const char *szFmt, ... ); void (*pfnParticleEffect)( const float *org, const float *dir, float color, float count ); - void (*pfnLightStyle)( int style, char* val ); + void (*pfnLightStyle)( int style, const char *val ); int (*pfnDecalIndex)( const char *name ); int (*pfnPointContents)( const float *rgflVector ); void (*pfnMessageBegin)( int msg_dest, int msg_type, const float *pOrigin, edict_t *ed ); @@ -155,8 +155,8 @@ typedef struct enginefuncs_s const char* (*pfnCVarGetString)( const char *szVarName ); void (*pfnCVarSetFloat)( const char *szVarName, float flValue ); void (*pfnCVarSetString)( const char *szVarName, const char *szValue ); - void (*pfnAlertMessage)( ALERT_TYPE atype, char *szFmt, ... ); - void (*pfnEngineFprintf)( FILE *pfile, char *szFmt, ... ); + void (*pfnAlertMessage)( ALERT_TYPE atype, const char *szFmt, ... ); + void (*pfnEngineFprintf)( FILE *pfile, const char *szFmt, ... ); void* (*pfnPvAllocEntPrivateData)( edict_t *pEdict, int cb ); void* (*pfnPvEntPrivateData)( edict_t *pEdict ); void (*pfnFreeEntPrivateData)( edict_t *pEdict ); @@ -189,7 +189,7 @@ typedef struct enginefuncs_s void (*pfnSetView)( const edict_t *pClient, const edict_t *pViewent ); float (*pfnTime)( void ); void (*pfnCrosshairAngle)( const edict_t *pClient, float pitch, float yaw ); - byte* (*pfnLoadFileForMe)( char *filename, int *pLength ); + byte* (*pfnLoadFileForMe)( const char *filename, int *pLength ); void (*pfnFreeFile)( void *buffer ); void (*pfnEndSection)( const char *pszSectionName ); // trigger_endsection int (*pfnCompareFileTime)( char *filename1, char *filename2, int *iCompare ); @@ -201,12 +201,12 @@ typedef struct enginefuncs_s void (*pfnRunPlayerMove)( edict_t *fakeclient, const float *viewangles, float forwardmove, float sidemove, float upmove, unsigned short buttons, byte impulse, byte msec ); int (*pfnNumberOfEntities)( void ); char* (*pfnGetInfoKeyBuffer)( edict_t *e ); // passing in NULL gets the serverinfo - char* (*pfnInfoKeyValue)( char *infobuffer, char *key ); - void (*pfnSetKeyValue)( char *infobuffer, char *key, char *value ); - void (*pfnSetClientKeyValue)( int clientIndex, char *infobuffer, char *key, char *value ); - int (*pfnIsMapValid)( char *filename ); + char* (*pfnInfoKeyValue)( char *infobuffer, const char *key ); + void (*pfnSetKeyValue)( char *infobuffer, const char *key, const char *value ); + void (*pfnSetClientKeyValue)( int clientIndex, char *infobuffer, const char *key, const char *value ); + int (*pfnIsMapValid)( const char *filename ); void (*pfnStaticDecal)( const float *origin, int decalIndex, int entityIndex, int modelIndex ); - int (*pfnPrecacheGeneric)( char *s ); + int (*pfnPrecacheGeneric)( const char *s ); int (*pfnGetPlayerUserId)( edict_t *e ); // returns the server assigned userid for this player. useful for logging frags, etc. returns -1 if the edict couldn't be found in the list of clients void (*pfnBuildSoundMsg)( edict_t *entity, int channel, const char *sample, /*int*/float volume, float attenuation, int fFlags, int pitch, int msg_dest, int msg_type, const float *pOrigin, edict_t *ed ); int (*pfnIsDedicatedServer)( void ); // is this a dedicated server? @@ -228,7 +228,7 @@ typedef struct enginefuncs_s void (*pfnDeltaSetField) ( struct delta_s *pFields, const char *fieldname ); void (*pfnDeltaUnsetField)( struct delta_s *pFields, const char *fieldname ); - void (*pfnDeltaAddEncoder)( char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); + void (*pfnDeltaAddEncoder)( const char *name, void (*conditionalencode)( struct delta_s *pFields, const unsigned char *from, const unsigned char *to ) ); int (*pfnGetCurrentPlayer)( void ); int (*pfnCanSkipPlayer)( const edict_t *player ); int (*pfnDeltaFindField)( struct delta_s *pFields, const char *fieldname ); @@ -236,7 +236,7 @@ typedef struct enginefuncs_s void (*pfnDeltaUnsetFieldByIndex)( struct delta_s *pFields, int fieldNumber ); void (*pfnSetGroupMask)( int mask, int op ); int (*pfnCreateInstancedBaseline)( int classname, struct entity_state_s *baseline ); - void (*pfnCvar_DirectSet)( struct cvar_s *var, char *value ); + void (*pfnCvar_DirectSet)( struct cvar_s *var, const char *value ); // Forces the client and server to be running with the same version of the specified file // ( e.g., a player model ). @@ -245,7 +245,7 @@ typedef struct enginefuncs_s void (*pfnGetPlayerStats)( const edict_t *pClient, int *ping, int *packet_loss ); - void (*pfnAddServerCommand)( char *cmd_name, void (*function) (void) ); + void (*pfnAddServerCommand)( const char *cmd_name, void (*function) (void) ); // For voice communications, set which clients hear eachother. // NOTE: these functions take player entity indices (starting at 1). @@ -256,7 +256,7 @@ typedef struct enginefuncs_s void *(*pfnSequenceGet)( const char *fileName, const char *entryName ); void *(*pfnSequencePickSentence)( const char *groupName, int pickMethod, int *picked ); - int (*pfnGetFileSize)( char *filename ); + int (*pfnGetFileSize)( const char *filename ); unsigned int (*pfnGetApproxWavePlayLen)( const char *filepath ); int (*pfnIsCareerMatch)( void ); int (*pfnGetLocalizedStringLength)( const char *label ); @@ -274,9 +274,9 @@ typedef struct enginefuncs_s // Passed to pfnKeyValue typedef struct KeyValueData_s { - char *szClassName; // in: entity classname - char *szKeyName; // in: name of key - char *szValue; // in: value of key + const char *szClassName; // in: entity classname + const char *szKeyName; // in: name of key + const char *szValue; // in: value of key int fHandled; // out: DLL sets to true if key-value pair was understood } KeyValueData; @@ -374,13 +374,15 @@ typedef enum _fieldtypes typedef struct { FIELDTYPE fieldType; - char *fieldName; + const char *fieldName; int fieldOffset; short fieldSize; short flags; } TYPEDESCRIPTION; +#ifndef ARRAYSIZE #define ARRAYSIZE(p) (sizeof(p)/sizeof(p[0])) +#endif typedef struct { @@ -434,7 +436,7 @@ typedef struct void (*pfnPM_Move)( struct playermove_s *ppmove, qboolean server ); void (*pfnPM_Init)( struct playermove_s *ppmove ); - char (*pfnPM_FindTextureType)( char *name ); + char (*pfnPM_FindTextureType)( const char *name ); void (*pfnSetupVisibility)( struct edict_s *pViewEntity, struct edict_s *pClient, unsigned char **pvs, unsigned char **pas ); void (*pfnUpdateClientData) ( const struct edict_s *ent, int sendweapons, struct clientdata_s *cd ); int (*pfnAddToFullPack)( struct entity_state_s *state, int e, edict_t *ent, edict_t *host, int hostflags, int player, unsigned char *pSet ); diff --git a/engine/progdefs.h b/engine/progdefs.h index 74004a27..cdbcc006 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -16,6 +16,12 @@ #ifndef PROGDEFS_H #define PROGDEFS_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + typedef struct { float time; @@ -215,4 +221,4 @@ typedef struct entvars_s edict_t *euser4; } entvars_t; -#endif//PROGDEFS_H \ No newline at end of file +#endif//PROGDEFS_H diff --git a/pm_shared/pm_debug.c b/pm_shared/pm_debug.c index 3baccaef..3b0879c7 100644 --- a/pm_shared/pm_debug.c +++ b/pm_shared/pm_debug.c @@ -23,8 +23,10 @@ #include +#ifdef _MSC_VER #pragma warning(disable : 4244) #pragma warning(disable : 4305) +#endif extern playermove_t *pmove; diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index 4959d165..cc130598 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -15,6 +15,12 @@ #ifndef PM_DEBUG_H #define PM_DEBUG_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + void PM_ViewEntity( void ); void PM_DrawBBox( vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life ); void PM_ParticleLine( vec3_t start, vec3_t end, int pcolor, float life, float vert ); diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index cd17ce54..b4c652ba 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -16,6 +16,12 @@ #ifndef PM_DEFS_H #define PM_DEFS_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + #define MAX_PHYSENTS 600 // Must have room for all entities in the world. #define MAX_MOVEENTS 64 #define MAX_CLIP_PLANES 5 diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index 321527f2..d9dbc03d 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -15,5 +15,11 @@ #ifndef PM_INFO_H #define PM_INFO_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + #define MAX_PHYSINFO_STRING 256 #endif//PM_INFO_H diff --git a/pm_shared/pm_math.c b/pm_shared/pm_math.c index 3718dc63..5bbe0068 100644 --- a/pm_shared/pm_math.c +++ b/pm_shared/pm_math.c @@ -25,7 +25,9 @@ // fall over #define ROLL 2 +#ifdef _MSC_VER #pragma warning(disable : 4244) +#endif vec3_t vec3_origin = { 0,0,0 }; int nanmask = 255 << 23; diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 7a1fb966..c709ba14 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -36,7 +36,9 @@ extern float vJumpAngles[3]; static int pm_shared_initialized = 0; +#ifdef _MSC_VER #pragma warning( disable : 4305 ) +#endif playermove_t *pmove = NULL; @@ -90,7 +92,10 @@ playermove_t *pmove = NULL; #define PLAYER_DUCKING_MULTIPLIER 0.333 // double to float warning +#ifdef _MSC_VER #pragma warning(disable : 4244) +#endif + #define max(a, b) (((a) > (b)) ? (a) : (b)) #define min(a, b) (((a) < (b)) ? (a) : (b)) // up / down @@ -549,7 +554,7 @@ void PM_UpdateStepSound( void ) float fvol; vec3_t knee; vec3_t feet; - vec3_t center; + //vec3_t center; float height; float speed; float velrun; @@ -592,7 +597,7 @@ void PM_UpdateStepSound( void ) { fWalking = speed < velrun; - VectorCopy( pmove->origin, center ); + //VectorCopy( pmove->origin, center ); VectorCopy( pmove->origin, knee ); VectorCopy( pmove->origin, feet ); @@ -1062,7 +1067,7 @@ Only used by players. Moves along the ground when player is a MOVETYPE_WALK. */ void PM_WalkMove() { - int clip; + //int clip; int oldonground; int i; @@ -1072,7 +1077,7 @@ void PM_WalkMove() vec3_t wishdir; float wishspeed; - vec3_t dest, start; + vec3_t dest; //, start; vec3_t original, originalvel; vec3_t down, downvel; float downdist, updist; @@ -1135,7 +1140,7 @@ void PM_WalkMove() dest[2] = pmove->origin[2]; // first try moving directly to the next spot - VectorCopy( dest, start ); + //VectorCopy( dest, start ); trace = pmove->PM_PlayerTrace( pmove->origin, dest, PM_NORMAL, -1 ); // If we made it all the way, then copy trace end // as new player position. @@ -1158,7 +1163,8 @@ void PM_WalkMove() VectorCopy( pmove->velocity, originalvel ); // velocity. // Slide move - clip = PM_FlyMove(); + //clip = PM_FlyMove(); + PM_FlyMove(); // Copy the results out VectorCopy( pmove->origin, down ); @@ -1183,7 +1189,8 @@ void PM_WalkMove() } // slide move the rest of the way. - clip = PM_FlyMove(); + //clip = PM_FlyMove(); + PM_FlyMove(); // Now try going back down from the end point // press down the stepheight @@ -1994,8 +2001,8 @@ void PM_Duck( void ) int buttonsChanged = ( pmove->oldbuttons ^ pmove->cmd.buttons ); // These buttons have changed this frame int nButtonPressed = buttonsChanged & pmove->cmd.buttons; // The changed ones still down are "pressed" - int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; - int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; + //int duckchange = buttonsChanged & IN_DUCK ? 1 : 0; + //int duckpressed = nButtonPressed & IN_DUCK ? 1 : 0; if( pmove->cmd.buttons & IN_DUCK ) { @@ -2261,6 +2268,7 @@ void PM_AddGravity() pmove->basevelocity[2] = 0; PM_CheckVelocity(); } + /* ============ PM_PushEntity diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index 124d37ba..1d0e4f38 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -16,6 +16,12 @@ #ifndef PM_SHARED_H #define PM_SHARED_H +#ifdef _WIN32 +#ifndef __MINGW32__ +#pragma once +#endif /* not __MINGW32__ */ +#endif + void PM_Init( struct playermove_s *ppmove ); void PM_Move( struct playermove_s *ppmove, int server ); char PM_FindTextureType( char *name ); From d20c4ff32980ad5cfd999533165ed2f90a61075e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 02:36:56 +0500 Subject: [PATCH 023/199] Fix build. --- cl_dll/cl_util.h | 10 +++++++--- cl_dll/com_weapons.cpp | 2 +- cl_dll/hud_redraw.cpp | 2 +- cl_dll/text_message.cpp | 12 ++++++------ dlls/buttons.cpp | 2 +- dlls/combat.cpp | 2 +- dlls/weapons.cpp | 2 +- dlls/weapons.h | 2 +- engine/cdll_int.h | 2 +- 9 files changed, 20 insertions(+), 16 deletions(-) diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 54dcede0..22555caa 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -94,8 +94,12 @@ inline void DrawSetTextColor( float r, float g, float b ) inline int SPR_Height( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Height(x, f); } inline int SPR_Width( HSPRITE x, int f ) { return gEngfuncs.pfnSPR_Width(x, f); } -inline client_textmessage_t *TextMessageGet( const char *pName ) { return gEngfuncs.pfnTextMessageGet( pName ); } -inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b ) +inline client_textmessage_t *TextMessageGet( const char *pName ) +{ + return gEngfuncs.pfnTextMessageGet( pName ); +} + +inline int TextMessageDrawChar( int x, int y, int number, int r, int g, int b ) { return gEngfuncs.pfnDrawCharacter( x, y, number, r, g, b ); } @@ -115,7 +119,7 @@ inline void GetConsoleStringSize( const char *string, int *width, int *height ) gEngfuncs.pfnDrawConsoleStringLen( (char*)string, width, height ); } -int DrawUtfString( int xpos, int ypos, int iMaxX, char *szIt, int r, int g, int b ); +int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ); inline int ConsoleStringLen( const char *string ) { diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index e50de419..774df091 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -46,7 +46,7 @@ void COM_Log( const char *pszFile, const char *fmt, ... ) va_list argptr; char string[1024]; FILE *fp; - char *pfilename; + const char *pfilename; if( !pszFile ) { diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 5182b484..829fd4b2 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -281,7 +281,7 @@ int CHud::DrawHudNumberString( int xpos, int ypos, int iMinX, int iNumber, int r int CHud::DrawHudStringReverse( int xpos, int ypos, int iMinX, const char *szString, int r, int g, int b ) { // find the end of the string - for( char *szIt = szString; *szIt != 0; szIt++ ) + for( const char *szIt = szString; *szIt != 0; szIt++ ) xpos -= gHUD.m_scrinfo.charWidths[(unsigned char)*szIt]; if( xpos < iMinX ) xpos = iMinX; diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index 13b62577..58dae6f7 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -45,7 +45,7 @@ int CHudTextMessage::Init( void ) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) { char *dst = dst_buffer; - for( char *src = msg; *src != 0 && buffer_size > 0; buffer_size-- ) + for( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) { if( *src == '#' ) { @@ -163,22 +163,22 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf int msg_dest = READ_BYTE(); static char szBuf[6][128]; - char *msg_text = LookupString( READ_STRING(), &msg_dest ); + const char *msg_text = LookupString( READ_STRING(), &msg_dest ); msg_text = strcpy( szBuf[0], msg_text ); // keep reading strings and using C format strings for subsituting the strings into the localised text string const char *sstr1 = LookupString( READ_STRING() ); sstr1 = strcpy( szBuf[1], sstr1 ); - StripEndNewlineFromString( sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines + StripEndNewlineFromString( (char*)sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines const char *sstr2 = LookupString( READ_STRING() ); sstr2 = strcpy( szBuf[2], sstr2 ); - StripEndNewlineFromString( sstr2 ); + StripEndNewlineFromString( (char*)sstr2 ); const char *sstr3 = LookupString( READ_STRING() ); sstr3 = strcpy( szBuf[3], sstr3 ); - StripEndNewlineFromString( sstr3 ); + StripEndNewlineFromString( (char*)sstr3 ); const char *sstr4 = LookupString( READ_STRING() ); sstr4 = strcpy( szBuf[4], sstr4 ); - StripEndNewlineFromString( sstr4 ); + StripEndNewlineFromString( (char*)sstr4 ); char *psz = szBuf[5]; switch( msg_dest ) diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 76f4ad91..df7c51f3 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -525,7 +525,7 @@ void CBaseButton::Spawn() // Button sound table. // Also used by CBaseDoor to get 'touched' door lock/unlock sounds -char *ButtonSound( int sound ) +const char *ButtonSound( int sound ) { const char *pszSound; diff --git a/dlls/combat.cpp b/dlls/combat.cpp index d8830c20..35e4ffcf 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -1463,7 +1463,7 @@ void CBaseEntity::FireBullets( ULONG cShots, Vector vecSrc, Vector vecDirShootin } } // make bullet trails - UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ); + UTIL_BubbleTrail( vecSrc, tr.vecEndPos, (int)( ( flDistance * tr.flFraction ) / 64.0 ) ); } ApplyMultiDamage( pev, pevAttacker ); } diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 0b6f7de6..989c32a8 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -935,7 +935,7 @@ BOOL CBasePlayerWeapon::CanDeploy( void ) return TRUE; } -BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal /* = 0 */, int body ) +BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWeaponModel, int iAnim, const char *szAnimExt, int skiplocal /* = 0 */, int body ) { if( !CanDeploy() ) return FALSE; diff --git a/dlls/weapons.h b/dlls/weapons.h index 8d60bad8..7bb1b486 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -310,7 +310,7 @@ public: virtual BOOL CanDeploy( void ); virtual BOOL IsUseable( void ); - BOOL DefaultDeploy( const char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal = 0, int body = 0 ); + BOOL DefaultDeploy( const char *szViewModel, const char *szWeaponModel, int iAnim, const char *szAnimExt, int skiplocal = 0, int body = 0 ); int DefaultReload( int iClipSize, int iAnim, float fDelay, int body = 0 ); virtual void ItemPostFrame( void ); // called each frame by the player PostThink diff --git a/engine/cdll_int.h b/engine/cdll_int.h index a0dc59c2..056146b4 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -205,7 +205,7 @@ typedef struct cl_enginefuncs_s int (*CL_CreateVisibleEntity)( int type, struct cl_entity_s *ent ); const struct model_s* (*GetSpritePointer)( HSPRITE hSprite ); - void (*pfnPlaySoundByNameAtLocation)( char *szSound, float volume, float *origin ); + void (*pfnPlaySoundByNameAtLocation)( const char *szSound, float volume, float *origin ); unsigned short (*pfnPrecacheEvent)( int type, const char* psz ); void (*pfnPlaybackEvent)( int flags, const struct edict_s *pInvoker, unsigned short eventindex, float delay, float *origin, float *angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 ); From c28d86f748362565baa82a522404e1ae7476fac8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 02:42:30 +0500 Subject: [PATCH 024/199] Fix wrong check. --- dlls/cbase.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 0cc10bdb..cdf9a00f 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -511,7 +511,7 @@ int CBaseEntity::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl // (that is, no actual entity projectile was involved in the attack so use the shooter's origin). if( pevAttacker == pevInflictor ) { - vecTemp = pevInflictor->origin - VecBModelOrigin( pev ); + vecTemp = pevAttacker->origin - VecBModelOrigin( pev ); } else // an actual missile was involved. From 4ae58b4170bc0f05e27baea53262ccbfc22e7fd4 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 05:37:14 +0500 Subject: [PATCH 025/199] Fix weapon reload bug. Use macros instead of magic numbers. --- dlls/crossbow.cpp | 4 ++-- dlls/egon.cpp | 2 +- dlls/glock.cpp | 8 ++++---- dlls/python.cpp | 4 ++-- dlls/rpg.cpp | 9 ++------- dlls/shotgun.cpp | 2 +- 6 files changed, 12 insertions(+), 17 deletions(-) diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index d749c785..12d0ff8c 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -481,7 +481,7 @@ void CCrossbow::SecondaryAttack() void CCrossbow::Reload( void ) { - if( m_pPlayer->ammo_bolts <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CROSSBOW_MAX_CLIP ) return; if( m_pPlayer->pev->fov != 0 ) @@ -489,7 +489,7 @@ void CCrossbow::Reload( void ) SecondaryAttack(); } - if( DefaultReload( 5, CROSSBOW_RELOAD, 4.5 ) ) + if( DefaultReload( CROSSBOW_MAX_CLIP, CROSSBOW_RELOAD, 4.5 ) ) { EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xbow_reload1.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); } diff --git a/dlls/egon.cpp b/dlls/egon.cpp index 9a4de49b..b83c9086 100644 --- a/dlls/egon.cpp +++ b/dlls/egon.cpp @@ -143,7 +143,7 @@ float CEgon::GetDischargeInterval( void ) BOOL CEgon::HasAmmo( void ) { - if( m_pPlayer->ammo_uranium <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; return TRUE; diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 1f4517e7..4e679750 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -169,15 +169,15 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) void CGlock::Reload( void ) { - if( m_pPlayer->ammo_9mm <= 0 ) - return; + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == GLOCK_MAX_CLIP ) + return; int iResult; if( m_iClip == 0 ) - iResult = DefaultReload( 17, GLOCK_RELOAD, 1.5 ); + iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD, 1.5 ); else - iResult = DefaultReload( 17, GLOCK_RELOAD_NOT_EMPTY, 1.5 ); + iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD_NOT_EMPTY, 1.5 ); if( iResult ) { diff --git a/dlls/python.cpp b/dlls/python.cpp index 7bb71325..b7e48386 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -212,7 +212,7 @@ void CPython::PrimaryAttack() void CPython::Reload( void ) { - if( m_pPlayer->ammo_357 <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == PYTHON_MAX_CLIP ) return; if( m_pPlayer->pev->fov != 0 ) @@ -227,7 +227,7 @@ void CPython::Reload( void ) #else bUseScope = g_pGameRules->IsMultiplayer(); #endif - if( DefaultReload( 6, PYTHON_RELOAD, 2.0, bUseScope ) ) + if( DefaultReload( PYTHON_MAX_CLIP, PYTHON_RELOAD, 2.0, bUseScope ) ) { m_flSoundDelay = 1.5; } diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 95c9132a..fb2b39c8 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -278,13 +278,8 @@ void CRpg::Reload( void ) { int iResult = 0; - if( m_iClip == 1 ) - { - // don't bother with any of this if don't need to reload. - return; - } - - if( m_pPlayer->ammo_rockets <= 0 ) + // don't bother with any of this if don't need to reload. + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == RPG_MAX_CLIP ) return; // because the RPG waits to autoreload when no missiles are active while the LTD is on, the diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 595561e2..d6be007a 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -320,7 +320,7 @@ void CShotgun::WeaponIdle( void ) } else if( m_fInSpecialReload != 0 ) { - if( m_iClip != 8 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) + if( m_iClip != SHOTGUN_MAX_CLIP && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { Reload(); } From cabb03ad45de13063b0dc42255455d1eaab22eda Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 16:11:40 +0500 Subject: [PATCH 026/199] Merge https://github.com/ValveSoftware/halflife/pull/1598/commits/2257fa14e7b1cd1fffd0c9d058b7368799b8b2a3 --- dlls/hornet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/hornet.cpp b/dlls/hornet.cpp index d968b79b..758ba7e9 100644 --- a/dlls/hornet.cpp +++ b/dlls/hornet.cpp @@ -407,7 +407,7 @@ void CHornet::DartTouch( CBaseEntity *pOther ) void CHornet::DieTouch( CBaseEntity *pOther ) { - if( pOther && pOther->pev->takedamage ) + if( pOther && pOther->pev->takedamage && pev->owner ) { // do the damage switch( RANDOM_LONG( 0, 2 ) ) From 7113204d5133ed67975bd9220fe50b6ae8b1fda9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 16:42:54 +0500 Subject: [PATCH 027/199] Merge https://github.com/ValveSoftware/halflife/pull/1600/commits/8903b33ef34cbe7e33bfbaa15f5c418bf9d01a02 --- dlls/crowbar.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 00b16d57..051d2309 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -220,8 +220,14 @@ int CCrowbar::Swing( int fFirst ) CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); ClearMultiDamage(); - + // If building with the clientside weapon prediction system, + // UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making + // m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false. +#ifdef CLIENT_WEAPONS + if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) +#else if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) +#endif { // first swing does full damage pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); From 13a691bdd85c692da49eb66cc1ea04cedd012950 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 19:02:52 +0500 Subject: [PATCH 028/199] Fix GetHullBounds() Same as in https://github.com/FWGS/cs16-client/commit/8d4515be429bfbff90b702d968ea9d57690b9ef4 --- cl_dll/cdll_int.cpp | 12 ++++++------ dlls/client.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 13200a89..ffd342d2 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -76,18 +76,18 @@ int DLLEXPORT HUD_GetHullBounds( int hullnumber, float *mins, float *maxs ) switch( hullnumber ) { case 0: // Normal player - mins = Vector( -16, -16, -36 ); - maxs = Vector( 16, 16, 36 ); + Vector( -16, -16, -36 ).CopyToArray(mins); + Vector( 16, 16, 36 ).CopyToArray(maxs); iret = 1; break; case 1: // Crouched player - mins = Vector( -16, -16, -18 ); - maxs = Vector( 16, 16, 18 ); + Vector( -16, -16, -18 ).CopyToArray(mins); + Vector( 16, 16, 18 ).CopyToArray(maxs); iret = 1; break; case 2: // Point based hull - mins = Vector( 0, 0, 0 ); - maxs = Vector( 0, 0, 0 ); + Vector( 0, 0, 0 ).CopyToArray(mins); + Vector( 0, 0, 0 ).CopyToArray(maxs); iret = 1; break; } diff --git a/dlls/client.cpp b/dlls/client.cpp index 99f1913b..ea4eb590 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -1853,18 +1853,18 @@ int GetHullBounds( int hullnumber, float *mins, float *maxs ) switch( hullnumber ) { case 0: // Normal player - mins = VEC_HULL_MIN; - maxs = VEC_HULL_MAX; + VEC_HULL_MIN.CopyToArray(mins); + VEC_HULL_MAX.CopyToArray(maxs); iret = 1; break; case 1: // Crouched player - mins = VEC_DUCK_HULL_MIN; - maxs = VEC_DUCK_HULL_MAX; + VEC_DUCK_HULL_MIN.CopyToArray(mins); + VEC_DUCK_HULL_MAX.CopyToArray(maxs); iret = 1; break; case 2: // Point based hull - mins = Vector( 0, 0, 0 ); - maxs = Vector( 0, 0, 0 ); + Vector( 0, 0, 0 ).CopyToArray(mins); + Vector( 0, 0, 0 ).CopyToArray(maxs); iret = 1; break; } From 3dfbd2a41f550b39acc382bac1bf436504577143 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 19:31:49 +0500 Subject: [PATCH 029/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/14fa5e81d0c327d3e2b43d2804b6c9377ce96ec4 --- dlls/world.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/world.cpp b/dlls/world.cpp index f352bd52..1cc645c9 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -484,9 +484,12 @@ void CWorld::Precache( void ) ///!!!LATER - do we want a sound ent in deathmatch? (sjb) //pSoundEnt = CBaseEntity::Create( "soundent", g_vecZero, g_vecZero, edict() ); pSoundEnt = GetClassPtr( ( CSoundEnt *)NULL ); - pSoundEnt->Spawn(); - if( !pSoundEnt ) + if( pSoundEnt ) + { + pSoundEnt->Spawn(); + } + else { ALERT ( at_console, "**COULD NOT CREATE SOUNDENT**\n" ); } From ac6d7c4384d12ce7ff59162db892139fc91109c1 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 19:35:16 +0500 Subject: [PATCH 030/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/5cade5b7607da186349ad4c49fd778cff40ea3ee --- dlls/monsters.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index cfe4c561..5f112a62 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -334,12 +334,10 @@ void CBaseMonster::Look( int iDistance ) { if( pev->spawnflags & SF_MONSTER_WAIT_TILL_SEEN ) { - CBaseMonster *pClient; - - pClient = pSightEnt->MyMonsterPointer(); + CBaseMonster *pClient = pSightEnt->MyMonsterPointer(); // don't link this client in the list if the monster is wait till seen and the player isn't facing the monster - if( pSightEnt && !pClient->FInViewCone( this ) ) + if( pClient && !pClient->FInViewCone( this ) ) { // we're not in the player's view cone. continue; From d3ebe0ac46aedfd75a4ccafadfd70e3665361ac5 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 19:52:18 +0500 Subject: [PATCH 031/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/e7b5c6be5153ac402fc771d164808d2752105299 --- dlls/bigmomma.cpp | 2 +- dlls/crowbar.cpp | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index a038c776..6b594983 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -411,7 +411,7 @@ void CBigMomma::SetYawSpeed( void ) { int ys; - switch ( m_Activity ) + switch( m_Activity ) { case ACT_IDLE: ys = 100; diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 051d2309..b00a0ad3 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -219,32 +219,32 @@ int CCrowbar::Swing( int fFirst ) fDidHit = TRUE; CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - ClearMultiDamage(); - // If building with the clientside weapon prediction system, - // UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making - // m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false. -#ifdef CLIENT_WEAPONS - if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) -#else - if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) -#endif - { - // first swing does full damage - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); - } - else - { - // subsequent swings do half - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); - } - ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); - // play thwack, smack, or dong sound - float flVol = 1.0; - int fHitWorld = TRUE; + float flVol = 1.0; + int fHitWorld = TRUE; if( pEntity ) { + ClearMultiDamage(); + // If building with the clientside weapon prediction system, + // UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making + // m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false. +#ifdef CLIENT_WEAPONS + if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) +#else + if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) +#endif + { + // first swing does full damage + pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); + } + else + { + // subsequent swings do half + pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); + } + ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); + if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) { // play thwack or smack sound From 391c2aa2175d8e5511d80f68bac6d4b511739ca6 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 20:09:34 +0500 Subject: [PATCH 032/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/5a13e06f522b1aff363fd0b1d360c2ed725cc6e4 --- dlls/aflock.cpp | 6 +++--- dlls/client.cpp | 2 +- dlls/plats.cpp | 24 +++++++++++++----------- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/dlls/aflock.cpp b/dlls/aflock.cpp index 19998a9d..d50a8165 100644 --- a/dlls/aflock.cpp +++ b/dlls/aflock.cpp @@ -839,11 +839,11 @@ void CFlockingFlyer::SquadRemove( CFlockingFlyer *pRemove ) { CFlockingFlyer *pLeader = m_pSquadNext; - // copy the enemy LKP to the new leader - pLeader->m_vecEnemyLKP = m_vecEnemyLKP; - if( pLeader ) { + // copy the enemy LKP to the new leader + pLeader->m_vecEnemyLKP = m_vecEnemyLKP; + CFlockingFlyer *pList = pLeader; while( pList ) diff --git a/dlls/client.cpp b/dlls/client.cpp index ea4eb590..5d41d6ad 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -353,7 +353,7 @@ void Host_Say( edict_t *pEntity, int teamonly ) } // remove quotes if present - if( *p == '"' ) + if( p && *p == '"' ) { p++; p[strlen( p ) - 1] = 0; diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 8fecf684..203f5d9b 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -743,21 +743,21 @@ void CFuncTrain::Next( void ) pev->target = pTarg->pev->target; m_flWait = pTarg->GetDelay(); - if ( m_pevCurrentTarget && m_pevCurrentTarget->speed != 0 ) + if( m_pevCurrentTarget && m_pevCurrentTarget->speed != 0 ) { // don't copy speed from target if it is 0 (uninitialized) pev->speed = m_pevCurrentTarget->speed; - ALERT( at_aiconsole, "Train %s speed to %4.2f\n", STRING(pev->targetname), pev->speed ); + ALERT( at_aiconsole, "Train %s speed to %4.2f\n", STRING( pev->targetname ), pev->speed ); } m_pevCurrentTarget = pTarg->pev;// keep track of this since path corners change our target for us. pev->enemy = pTarg->edict();//hack - if(FBitSet(m_pevCurrentTarget->spawnflags, SF_CORNER_TELEPORT)) + if( FBitSet( m_pevCurrentTarget->spawnflags, SF_CORNER_TELEPORT ) ) { // Path corner has indicated a teleport to the next corner. - SetBits(pev->effects, EF_NOINTERP); - UTIL_SetOrigin(pev, pTarg->pev->origin - (pev->mins + pev->maxs)* 0.5); + SetBits( pev->effects, EF_NOINTERP ); + UTIL_SetOrigin( pev, pTarg->pev->origin - ( pev->mins + pev->maxs ) * 0.5 ); Wait(); // Get on with doing the next path corner. } else @@ -767,13 +767,15 @@ void CFuncTrain::Next( void ) // CHANGED this from CHAN_VOICE to CHAN_STATIC around OEM beta time because trains should // use CHAN_STATIC for their movement sounds to prevent sound field problems. // this is not a hack or temporary fix, this is how things should be. (sjb). - if ( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING(pev->noiseMovement) ); - if ( pev->noiseMovement ) - EMIT_SOUND (ENT(pev), CHAN_STATIC, (char*)STRING(pev->noiseMovement), m_volume, ATTN_NORM); - ClearBits(pev->effects, EF_NOINTERP); + if( pev->noiseMovement ) + { + STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + } + + ClearBits( pev->effects, EF_NOINTERP ); SetMoveDone( &CFuncTrain::Wait ); - LinearMove (pTarg->pev->origin - (pev->mins + pev->maxs)* 0.5, pev->speed); + LinearMove( pTarg->pev->origin - ( pev->mins + pev->maxs )* 0.5, pev->speed ); } } From 98a562c20e2add40c34973ed1be95f167120c10f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 2 Jul 2017 21:17:51 +0500 Subject: [PATCH 033/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/9d2ae368aae3207dc9f66aca8a3c1505d5c3014a --- dlls/scientist.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index d7659c61..7cf9cc4d 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -464,7 +464,10 @@ void CScientist::StartTask( Task_t *pTask ) { Talk( 2 ); m_hTalkTarget = m_hEnemy; - if( m_hEnemy->IsPlayer() ) + + //The enemy can be null here. - Solokiller + //Discovered while testing the barnacle grapple on headcrabs with scientists in view. + if( m_hEnemy && m_hEnemy->IsPlayer() ) PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM ); else PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM ); From 4800c0d54ca8a9c5de8e0aa2b2f448b7c8b164ff Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 3 Jul 2017 03:24:14 +0500 Subject: [PATCH 034/199] Deactivate satchels on disconnect. --- dlls/client.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 5d41d6ad..7354f68f 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -110,14 +110,12 @@ void ClientDisconnect( edict_t *pEntity ) WRITE_STRING( text ); MESSAGE_END(); - CSound *pSound; - pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEntity ) ); + CSound *pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( pEntity ) ); + + // since this client isn't around to think anymore, reset their sound. + if( pSound ) { - // since this client isn't around to think anymore, reset their sound. - if( pSound ) - { - pSound->Reset(); - } + pSound->Reset(); } // since the edict doesn't get deleted, fix it so it doesn't interfere. @@ -125,6 +123,12 @@ void ClientDisconnect( edict_t *pEntity ) pEntity->v.solid = SOLID_NOT;// nonsolid UTIL_SetOrigin( &pEntity->v, pEntity->v.origin ); + CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ); + if( pl->HasNamedPlayerItem( "weapon_satchel" ) ) + { + DeactivateSatchels( pl ); + } + g_pGameRules->ClientDisconnected( pEntity ); } From 780b4616fe420f3d9ab24d68bcc51ab172e4b1d0 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 02:41:23 +0500 Subject: [PATCH 035/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/c98747a35e324dca2d88c13036f1f74947caba96 --- dlls/rpg.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index fb2b39c8..021ad534 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -460,6 +460,8 @@ void CRpg::PrimaryAttack() m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5; + + ResetEmptySound(); } else { @@ -487,13 +489,13 @@ void CRpg::WeaponIdle( void ) { UpdateSpot(); - ResetEmptySound(); - if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { + ResetEmptySound(); + int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); if( flRand <= 0.75 || m_fSpotActive ) From 2cb20f7b7556306d08306e6615a93bf5d4f25a7a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 02:43:50 +0500 Subject: [PATCH 036/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/274bd297f9af9cc251447dafc97de26019f0ed20 --- dlls/python.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/python.cpp b/dlls/python.cpp index b7e48386..90606c50 100644 --- a/dlls/python.cpp +++ b/dlls/python.cpp @@ -169,7 +169,7 @@ void CPython::PrimaryAttack() Reload(); else { - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM ); + PlayEmptySound(); m_flNextPrimaryAttack = 0.15; } From c4820ad0df7bda569275452ad8f25c60d00301f9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:12:53 +0500 Subject: [PATCH 037/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/89efd616d6aed0304db5bf63bfecd311c1cedbdd --- dlls/subs.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/subs.cpp b/dlls/subs.cpp index 5ebe757b..4654363a 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -107,6 +107,13 @@ void CBaseEntity::UpdateOnRemove( void ) if( pev->globalname ) gGlobalState.EntitySetState( pev->globalname, GLOBAL_DEAD ); + + // tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality. + //Killtarget didn't do this before, so the counter broke. - Solokiller + if( CBaseEntity* pOwner = pev->owner ? Instance( pev->owner ) : 0 ) + { + pOwner->DeathNotice( this ); + } } // Convenient way to delay removing oneself From f22f1331afc052a70921e3bb0421c7c205a14bb2 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:25:39 +0500 Subject: [PATCH 038/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/2219190a09711ecbb441ec7160315eccac194dea --- dlls/controller.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/dlls/controller.cpp b/dlls/controller.cpp index bfa119d3..b042949e 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -47,6 +47,7 @@ public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); void SetYawSpeed( void ); int Classify( void ); void HandleAnimEvent( MonsterEvent_t *pEvent ); @@ -384,6 +385,23 @@ void CController::Precache() UTIL_PrecacheOther( "controller_head_ball" ); } +void CController::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pBall[0] ) + { + UTIL_Remove( m_pBall[0] ); + m_pBall[0] = nullptr; + } + + if( m_pBall[1] ) + { + UTIL_Remove( m_pBall[1] ); + m_pBall[1] = nullptr; + } +} + //========================================================= // AI Schedules Specific to this monster //========================================================= From 6379954153e2c0c0001139b7f7dce9835b17da15 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:32:53 +0500 Subject: [PATCH 039/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/e41b164fdffef1b89aa5286ae15c9617dfcf2188 https://github.com/SamVanheer/HLEnhanced/commit/2da0a12d353f2078f1e2f6d931deb9c0f04e5b43 --- dlls/gargantua.cpp | 14 ++++++++++++++ dlls/islave.cpp | 8 ++++++++ 2 files changed, 22 insertions(+) diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index 7f60b401..6aa6a738 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -200,6 +200,7 @@ class CGargantua : public CBaseMonster public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); void SetYawSpeed( void ); int Classify( void ); int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); @@ -802,6 +803,19 @@ void CGargantua::Precache() PRECACHE_SOUND( (char *)pBreatheSounds[i] ); } +void CGargantua::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pEyeGlow ) + { + UTIL_Remove( m_pEyeGlow ); + m_pEyeGlow = 0; + } + + FlameDestroy(); +} + void CGargantua::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) { ALERT( at_aiconsole, "CGargantua::TraceAttack\n" ); diff --git a/dlls/islave.cpp b/dlls/islave.cpp index 3b4343d3..51def5d3 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -44,6 +44,7 @@ class CISlave : public CSquadMonster public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); void SetYawSpeed( void ); int ISoundMask( void ); int Classify( void ); @@ -557,6 +558,13 @@ void CISlave::Precache() UTIL_PrecacheOther( "test_effect" ); } +void CISlave::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + ClearBeams(); +} + //========================================================= // TakeDamage - get provoked when injured //========================================================= From 95d81733fcc5cb152d9b71224fe4a60de52263bc Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:41:48 +0500 Subject: [PATCH 040/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/29947a0558967e43ead0c4558251c6f77924b3ea --- dlls/tripmine.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index 520206dd..60190604 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -43,6 +43,7 @@ class CTripmineGrenade : public CGrenade { void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); @@ -148,6 +149,13 @@ void CTripmineGrenade::Precache( void ) PRECACHE_SOUND( "weapons/mine_charge.wav" ); } +void CTripmineGrenade::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + KillBeam(); +} + void CTripmineGrenade::WarningThink( void ) { // play warning sound From 9c85e5eb77e81b642836bad53ddeaa72a6284c02 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:46:20 +0500 Subject: [PATCH 041/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/b3cf83bbf11e0f098382f27f63d0364043306a03 --- dlls/turret.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/dlls/turret.cpp b/dlls/turret.cpp index 5b9e1b77..ae95db14 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -56,6 +56,7 @@ class CBaseTurret : public CBaseMonster public: void Spawn( void ); virtual void Precache( void ); + void UpdateOnRemove(); void KeyValue( KeyValueData *pkvd ); void EXPORT TurretUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); @@ -279,6 +280,17 @@ void CBaseTurret::Precache() PRECACHE_SOUND( "turret/tu_alert.wav" ); } +void CBaseTurret::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pEyeGlow ) + { + UTIL_Remove( m_pEyeGlow ); + m_pEyeGlow = 0; + } +} + #define TURRET_GLOW_SPRITE "sprites/flare3.spr" void CTurret::Spawn() From 9bb5cb2f05391097453a27b51b671044189f320e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 03:56:48 +0500 Subject: [PATCH 042/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/46ea4af5f8dc168d048b2cada03308e9c4c3069d --- dlls/nihilanth.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 479a2b34..82b31e13 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -34,6 +34,7 @@ public: void Spawn( void ); void Precache( void ); + void UpdateOnRemove(); int Classify( void ) { return CLASS_ALIEN_MILITARY; }; int BloodColor( void ) { return BLOOD_COLOR_YELLOW; } void Killed( entvars_t *pevAttacker, int iGib ); @@ -345,6 +346,26 @@ void CNihilanth::Precache( void ) PRECACHE_SOUND( "debris/beamstart7.wav" ); } +void CNihilanth::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + + if( m_pBall ) + { + UTIL_Remove( m_pBall ); + m_pBall = 0; + } + + for( int i = 0; i < N_SPHERES, i++ ) + { + if( CBaseEntity* pSphere = (CBaseEntity *)m_hSphere[i] ) + { + UTIL_Remove( pSphere ); + m_hSphere[i] = 0; + } + } +} + void CNihilanth::PainSound( void ) { if( m_flNextPainSound > gpGlobals->time ) From 3ad3004dd900f5bfaecf2d57bead3e34d2fc5785 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 04:03:22 +0500 Subject: [PATCH 043/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/3e2f7e1e81af06d092f6350e58b26dfeb699ebc6 --- dlls/controller.cpp | 4 ++-- dlls/crowbar.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/dlls/controller.cpp b/dlls/controller.cpp index b042949e..e1d57517 100644 --- a/dlls/controller.cpp +++ b/dlls/controller.cpp @@ -392,13 +392,13 @@ void CController::UpdateOnRemove() if( m_pBall[0] ) { UTIL_Remove( m_pBall[0] ); - m_pBall[0] = nullptr; + m_pBall[0] = 0; } if( m_pBall[1] ) { UTIL_Remove( m_pBall[1] ); - m_pBall[1] = nullptr; + m_pBall[1] = 0; } } diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index b00a0ad3..65e21162 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -139,8 +139,10 @@ void CCrowbar::PrimaryAttack() { if( !Swing( 1 ) ) { +#ifndef CLIENT_DLL SetThink( &CCrowbar::SwingAgain ); pev->nextthink = gpGlobals->time + 0.1; +#endif } } @@ -301,11 +303,11 @@ int CCrowbar::Swing( int fFirst ) } m_pPlayer->m_iWeaponVolume = (int)( flVol * CROWBAR_WALLHIT_VOLUME ); -#endif - m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); SetThink( &CCrowbar::Smack ); pev->nextthink = UTIL_WeaponTimeBase() + 0.2; +#endif + m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); } return fDidHit; } From 740a5a2c31b799dd3f8bd4e5312451489e3cafbe Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 16:42:08 +0500 Subject: [PATCH 044/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/2baa8fe118db844968b2868d378d93b9f7f4f742 --- dlls/weapons.cpp | 7 +++++++ dlls/weapons.h | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 989c32a8..854425ad 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1557,6 +1557,13 @@ TYPEDESCRIPTION CEgon::m_SaveData[] = IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon ) +TYPEDESCRIPTION CHgun::m_SaveData[] = +{ + DEFINE_FIELD( CHgun, m_flRechargeTime, FIELD_FLOAT ), +}; + +IMPLEMENT_SAVERESTORE( CHgun, CBasePlayerWeapon ) + TYPEDESCRIPTION CSatchel::m_SaveData[] = { DEFINE_FIELD( CSatchel, m_chargeReady, FIELD_INTEGER ), diff --git a/dlls/weapons.h b/dlls/weapons.h index 7bb1b486..6f5de37a 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -841,6 +841,11 @@ private: class CHgun : public CBasePlayerWeapon { public: +#ifndef CLIENT_DLL + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; +#endif void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 4; } From 4024c29caf23984191d601bce7e17c5276b83632 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 16:45:48 +0500 Subject: [PATCH 045/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/7002f8fb477c03b44ec2251b1308f4e5432cb50e --- cl_dll/ammo.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 860cde42..3d214280 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -542,7 +542,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) } else { - if ( m_pWeapon ) + if( m_pWeapon ) SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); } @@ -574,6 +574,8 @@ int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) if( iId < 1 ) { SetCrosshair( 0, nullrc, 0, 0, 0 ); + // Clear out the weapon so we don't keep drawing the last active weapon's ammo. - Solokiller + m_pWeapon = 0; return 0; } From ca7464b158c5ad69c504168cd249dce4135d1a5d Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 16:51:43 +0500 Subject: [PATCH 046/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/60a45fb6cd027168e2c546d64f1176ed830070d8 --- dlls/weapons.cpp | 2 ++ dlls/weapons.h | 1 + 2 files changed, 3 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 854425ad..ff083ee7 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -598,6 +598,8 @@ BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) void CBasePlayerWeapon::ItemPostFrame( void ) { + WeaponTick(); + if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. diff --git a/dlls/weapons.h b/dlls/weapons.h index 6f5de37a..a7c40678 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -318,6 +318,7 @@ public: virtual void PrimaryAttack( void ) { return; } // do "+ATTACK" virtual void SecondaryAttack( void ) { return; } // do "+ATTACK2" virtual void Reload( void ) { return; } // do "+RELOAD" + virtual void WeaponTick() {} // Always called at beginning of ItemPostFrame. - Solokiller virtual void WeaponIdle( void ) { return; } // called when no buttons pressed virtual int UpdateClientData( CBasePlayer *pPlayer ); // sends hud info to client dll, if things have changed virtual void RetireWeapon( void ); From e5f6f7d9acbc35795cb20cbd7e09bd6e45afd6b9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 16:58:26 +0500 Subject: [PATCH 047/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/0cbbe099f3170170d41683c2a4288d1f06aad048 --- dlls/shotgun.cpp | 17 ++++++++++------- dlls/weapons.h | 1 + 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index d6be007a..12e73ede 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -169,7 +169,7 @@ void CShotgun::PrimaryAttack() // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - if( m_iClip != 0 ) + //if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.5; m_flNextPrimaryAttack = GetNextAttackDelay( 0.75 ); @@ -240,7 +240,7 @@ void CShotgun::SecondaryAttack( void ) // HEV suit - indicate out of ammo condition m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); - if( m_iClip != 0 ) + //if( m_iClip != 0 ) m_flPumpTime = gpGlobals->time + 0.95; m_flNextPrimaryAttack = GetNextAttackDelay( 1.5 ); @@ -299,18 +299,21 @@ void CShotgun::Reload( void ) } } -void CShotgun::WeaponIdle( void ) +void CShotgun::WeaponTick() { - ResetEmptySound(); - - m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); - if( m_flPumpTime && m_flPumpTime < gpGlobals->time ) { // play pumping sound EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/scock1.wav", 1, ATTN_NORM, 0, 95 + RANDOM_LONG( 0, 0x1f ) ); m_flPumpTime = 0; } +} + +void CShotgun::WeaponIdle( void ) +{ + ResetEmptySound(); + + m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) { diff --git a/dlls/weapons.h b/dlls/weapons.h index a7c40678..7d99e8a6 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -632,6 +632,7 @@ public: void SecondaryAttack( void ); BOOL Deploy( ); void Reload( void ); + void WeaponTick(); void WeaponIdle( void ); int m_fInReload; float m_flNextReload; From 689316912ac98dbd928caacaf73436130e391a28 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 17:06:23 +0500 Subject: [PATCH 048/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/19396936af13e417e7f9eaf48c48c49699da03fb --- cl_dll/ev_hldm.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 787e1be8..381c9179 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1430,6 +1430,12 @@ void EV_EgonFire( event_args_t *args ) } else { + // If there is any sound playing already, kill it. - Solokiller + // This is necessary because multiple sounds can play on the same channel at the same time. + // In some cases, more than 1 run sound plays when the egon stops firing, in which case only the earliest entry in the list is stopped. + // This ensures no more than 1 of those is ever active at the same time. + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EGON_SOUND_RUN ); + if( iFireMode == FIRE_WIDE ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, EGON_SOUND_RUN, 0.98, ATTN_NORM, 0, 125 ); else @@ -1438,7 +1444,7 @@ void EV_EgonFire( event_args_t *args ) //Only play the weapon anims if I shot it. if( EV_IsLocal( idx ) ) - gEngfuncs.pEventAPI->EV_WeaponAnimation ( g_fireAnims1[gEngfuncs.pfnRandomLong( 0, 3 )], 1 ); + 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. { From 55c3eb674c83cd511a34ea769885cbd6e43f09ad Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 17:39:50 +0500 Subject: [PATCH 049/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/35fd286ccaf7426a95baf30e682410510fe77083 --- dlls/monsters.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index 5f112a62..a9796a80 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -3357,6 +3357,9 @@ CBaseEntity *CBaseMonster::DropItem( const char *pszItemName, const Vector &vecP // do we want this behavior to be default?! (sjb) pItem->pev->velocity = pev->velocity; pItem->pev->avelocity = Vector( 0, RANDOM_FLOAT( 0, 100 ), 0 ); + + // Dropped items should never respawn (unless this rule changes in the future). - Solokiller + pItem->pev->spawnflags |= SF_NORESPAWN; return pItem; } else From 33ba064b88d9b0e818009049aef13f53bd16ae20 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 17:53:04 +0500 Subject: [PATCH 050/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/4dfa6b8710a0a30761b298a02bee21c65f056327 --- cl_dll/ev_hldm.cpp | 2 -- dlls/crowbar.cpp | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 381c9179..7d2464e8 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1159,8 +1159,6 @@ void EV_Crowbar( event_args_t *args ) if( EV_IsLocal( idx ) ) { - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 ); - switch( (g_iSwing++) % 3 ) { case 0: diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 65e21162..98808e14 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -183,9 +183,12 @@ int CCrowbar::Swing( int fFirst ) } } #endif - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, - 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, - 0, 0, 0 ); + if( fFirst ) + { + PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, + 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, + 0, 0, 0 ); + } if( tr.flFraction >= 1.0 ) { From 033bbbcd80bce28b4a5b25f5362e28d43b909474 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 18:04:09 +0500 Subject: [PATCH 051/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/3680342c619bf2efef9a8e2e99c72f4469a89bbd --- cl_dll/ammo.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index 3d214280..f439520e 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -536,7 +536,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) if( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) { - static wrect_t nullrc; + wrect_t nullrc = {}; gpActiveSel = NULL; SetCrosshair( 0, nullrc, 0, 0, 0 ); } @@ -556,7 +556,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) // int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) { - static wrect_t nullrc; + wrect_t nullrc = {}; int fOnTarget = FALSE; BEGIN_READ( pbuf, iSize ); From 6f44185a645266d2fb7ea8bc5136b6b57f650a61 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 18:31:35 +0500 Subject: [PATCH 052/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/0398781544bce0766545fbbb8ac8367e3db6c86b --- cl_dll/ev_hldm.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 7d2464e8..7bb3a797 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -521,16 +521,17 @@ void EV_FireGlock2( event_args_t *args ) VectorCopy( args->origin, origin ); VectorCopy( args->angles, angles ); VectorCopy( args->velocity, velocity ); + int empty = args->bparam1; AngleVectors( angles, forward, right, up ); - shell = gEngfuncs.pEventAPI->EV_FindModelIndex ("models/shell.mdl");// brass shell + shell = gEngfuncs.pEventAPI->EV_FindModelIndex( "models/shell.mdl" );// brass shell if( EV_IsLocal( idx ) ) { // Add muzzle flash to current weapon model EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( GLOCK_SHOOT, 2 ); + gEngfuncs.pEventAPI->EV_WeaponAnimation( empty ? GLOCK_SHOOT_EMPTY : GLOCK_SHOOT, 2 ); V_PunchAxis( 0, -2.0 ); } From e7b324da5ebd26b0eae9c080911fd40c6ca478fb Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 19:17:59 +0500 Subject: [PATCH 053/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/19c8e45d8f92d0e09171f9f1b5b3fd0f25d109b6 --- dlls/mp5.cpp | 6 ++++++ dlls/weapons.h | 1 + 2 files changed, 7 insertions(+) diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 7131f888..a13257a1 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -270,6 +270,12 @@ void CMP5::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again. } +BOOL CMP5::IsUseable() +{ + //Can be used if the player has AR grenades. - Solokiller + return CBasePlayerWeapon::IsUseable() || m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] > 0; +} + class CMP5AmmoClip : public CBasePlayerAmmo { void Spawn( void ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 7d99e8a6..86e9c7f6 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -563,6 +563,7 @@ public: BOOL Deploy( void ); void Reload( void ); void WeaponIdle( void ); + BOOL IsUseable(); float m_flNextAnimTime; int m_iShell; From 19bdc1d01b7287cd61b58fb7b7bdb6953caa50a8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 19:48:01 +0500 Subject: [PATCH 054/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/33413807d0ca23f3d9121e45f5584cb5be98751b --- dlls/gauss.cpp | 36 ++++++++++++++++++++++++++---------- dlls/weapons.h | 2 +- 2 files changed, 27 insertions(+), 11 deletions(-) diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 93352b57..0ebb876c 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -123,6 +123,12 @@ int CGauss::GetItemInfo( ItemInfo *p ) return 1; } +BOOL CGauss::IsUseable() +{ + // Currently charging, allow the player to fire it first. - Solokiller + return CBasePlayerWeapon::IsUseable() || m_InAttack != 0; +} + BOOL CGauss::Deploy() { m_pPlayer->m_flPlayAftershock = 0.0; @@ -224,6 +230,22 @@ void CGauss::SecondaryAttack() } else { + // Moved to before the ammo burn. + // Because we drained 1 when m_InAttack == 0, then 1 again now before checking if we're out of ammo, + // this resuled in the player having -1 ammo, which in turn caused CanDeploy to think it could be deployed. + // This will need to be fixed further down the line by preventing negative ammo unless explicitly required (infinite ammo?), + // But this check will prevent the problem for now. - Solokiller + // TODO: investigate further. + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + { + // out of ammo! force the gun to fire + StartFire(); + m_fInAttack = 0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; + return; + } + // during the charging process, eat one bit of ammo every once in a while if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flNextAmmoBurn && m_pPlayer->m_flNextAmmoBurn != 1000 ) { @@ -243,16 +265,6 @@ void CGauss::SecondaryAttack() } } - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - { - // out of ammo! force the gun to fire - StartFire(); - m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; - return; - } - if( UTIL_WeaponTimeBase() >= m_pPlayer->m_flAmmoStartCharge ) { // don't eat any more ammo after gun is fully charged. @@ -558,6 +570,10 @@ void CGauss::WeaponIdle( void ) StartFire(); m_fInAttack = 0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; + + // Need to set m_flNextPrimaryAttack so the weapon gets a chance to complete its secondary fire animation. - Solokiller + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; } else { diff --git a/dlls/weapons.h b/dlls/weapons.h index 86e9c7f6..736dadd4 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -741,7 +741,7 @@ public: int iItemSlot( void ) { return 4; } int GetItemInfo(ItemInfo *p); int AddToPlayer( CBasePlayer *pPlayer ); - + BOOL IsUseable(); BOOL Deploy( void ); void Holster( int skiplocal = 0 ); From 9ef79aee9ef6924dfdfe2ec1538dc0d26fe8a0f8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 21:44:06 +0500 Subject: [PATCH 055/199] Merge https://github.com/ValveSoftware/halflife/pull/1720/commits/6f020090bd75706174012bb080fce8f4b6a2d187 --- dlls/rpg.cpp | 8 ++++---- dlls/weapons.cpp | 2 +- dlls/weapons.h | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 021ad534..5fb8cc70 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -109,8 +109,8 @@ CRpgRocket *CRpgRocket::CreateRpgRocket( Vector vecOrigin, Vector vecAngles, CBa pRocket->pev->angles = vecAngles; pRocket->Spawn(); pRocket->SetTouch( &CRpgRocket::RocketTouch ); - pRocket->m_pLauncher = pLauncher;// remember what RPG fired me. - pRocket->m_pLauncher->m_cActiveRockets++;// register this missile as active for the launcher + pRocket->m_hLauncher = pLauncher;// remember what RPG fired me. + pLauncher->m_cActiveRockets++;// register this missile as active for the launcher pRocket->pev->owner = pOwner->edict(); return pRocket; @@ -150,10 +150,10 @@ void CRpgRocket::Spawn( void ) //========================================================= void CRpgRocket::RocketTouch( CBaseEntity *pOther ) { - if( m_pLauncher ) + if( CRpg* pLauncher = (CRpg*)( (CBaseEntity*)( m_hLauncher ) ) ) { // my launcher is still around, tell it I'm dead. - m_pLauncher->m_cActiveRockets--; + pLauncher->m_cActiveRockets--; } STOP_SOUND( edict(), CHAN_VOICE, "weapons/rocket1.wav" ); diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index ff083ee7..bc508c6a 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1518,7 +1518,7 @@ IMPLEMENT_SAVERESTORE( CRpg, CBasePlayerWeapon ) TYPEDESCRIPTION CRpgRocket::m_SaveData[] = { DEFINE_FIELD( CRpgRocket, m_flIgniteTime, FIELD_TIME ), - DEFINE_FIELD( CRpgRocket, m_pLauncher, FIELD_CLASSPTR ), + DEFINE_FIELD( CRpgRocket, m_hLauncher, FIELD_EHANDLE ), }; IMPLEMENT_SAVERESTORE( CRpgRocket, CGrenade ) diff --git a/dlls/weapons.h b/dlls/weapons.h index 736dadd4..3d8dd6ad 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -725,7 +725,7 @@ public: int m_iTrail; float m_flIgniteTime; - CRpg *m_pLauncher;// pointer back to the launcher that fired me. + EHANDLE m_hLauncher; // handle back to the launcher that fired me. }; class CGauss : public CBasePlayerWeapon From e98f45b2796670989b9ac219cbe99f4df9845e51 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 21:53:57 +0500 Subject: [PATCH 056/199] Merge https://github.com/ValveSoftware/halflife/pull/1599 --- dlls/weapons.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index bc508c6a..61b038c0 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -578,6 +578,13 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? + + // If the item is falling and its Think remains FallItem after the player picks it up, + // then after the item touches the ground its Touch will be set back to DefaultTouch, + // so the player will pick it up again, this time Kill-ing the item (since we already have it in the inventory), + // which will make the pointer bad and crash the game. + if( m_pfnThink == &CBasePlayerItem::FallThink ) + SetThink( NULL ); } BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) From cf5b2f9e14fdc87f3c58b8780834fffd9cec8fd7 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 5 Jul 2017 23:50:55 +0500 Subject: [PATCH 057/199] Merge https://github.com/ValveSoftware/halflife/pull/1601 --- cl_dll/cdll_int.cpp | 14 ++++++++++++++ dlls/client.cpp | 14 +++++++++++++- dlls/game.cpp | 2 ++ dlls/player.cpp | 13 +++++++++++++ dlls/player.h | 10 ++++++---- pm_shared/pm_shared.c | 13 ++++++++----- 6 files changed, 56 insertions(+), 10 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index ffd342d2..d71659e9 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -21,6 +21,7 @@ #include "hud.h" #include "cl_util.h" #include "netadr.h" +#include "parsemsg.h" extern "C" { @@ -32,10 +33,21 @@ extern "C" cl_enginefunc_t gEngfuncs; CHud gHUD; mobile_engfuncs_t *gMobileEngfuncs = NULL; + +extern "C" int g_bhopcap; void InitInput( void ); void EV_HookEvents( void ); void IN_Commands( void ); +int __MsgFunc_Bhopcap( const char *pszName, int iSize, void *pbuf ) +{ + BEGIN_READ( pbuf, iSize ); + + g_bhopcap = READ_BYTE(); + + return 1; +} + /* ========================== Initialize @@ -196,6 +208,8 @@ void DLLEXPORT HUD_Init( void ) { InitInput(); gHUD.Init(); + + gEngfuncs.pfnHookUserMsg( "Bhopcap", __MsgFunc_Bhopcap ); } /* diff --git a/dlls/client.cpp b/dlls/client.cpp index 7354f68f..1fead362 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -48,11 +48,15 @@ extern DLL_GLOBAL ULONG g_ulFrameCount; extern void CopyToBodyQue( entvars_t* pev ); extern int giPrecacheGrunt; extern int gmsgSayText; +extern int gmsgBhopcap; extern cvar_t allow_spectators; extern int g_teamplay; +extern cvar_t bhopcap; +extern "C" int g_bhopcap; + void LinkUserMessages( void ); /* @@ -799,8 +803,16 @@ void StartFrame( void ) gpGlobals->teamplay = teamplay.value; g_ulFrameCount++; -} + int oldBhopcap = g_bhopcap; + g_bhopcap = ( g_pGameRules->IsMultiplayer() && bhopcap.value != 0.0f ) ? 1 : 0; + if( g_bhopcap != oldBhopcap ) + { + MESSAGE_BEGIN( MSG_ALL, gmsgBhopcap, NULL ); + WRITE_BYTE( g_bhopcap ); + MESSAGE_END(); + } +} void ClientPrecache( void ) { diff --git a/dlls/game.cpp b/dlls/game.cpp index fb247903..7905075a 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -38,6 +38,7 @@ cvar_t teamlist = { "mp_teamlist","hgrunt;scientist", FCVAR_SERVER }; cvar_t teamoverride = { "mp_teamoverride","1" }; cvar_t defaultteam = { "mp_defaultteam","0" }; cvar_t allowmonsters = { "mp_allowmonsters","0", FCVAR_SERVER }; +cvar_t bhopcap = { "mp_bhopcap", "1", FCVAR_SERVER }; cvar_t allow_spectators = { "allow_spectators", "0", FCVAR_SERVER }; // 0 prevents players from being spectators @@ -473,6 +474,7 @@ void GameDLLInit( void ) CVAR_REGISTER( &teamoverride ); CVAR_REGISTER( &defaultteam ); CVAR_REGISTER( &allowmonsters ); + CVAR_REGISTER( &bhopcap ); CVAR_REGISTER( &mp_chattime ); diff --git a/dlls/player.cpp b/dlls/player.cpp index 51995acf..b838f35f 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -45,6 +45,8 @@ extern DLL_GLOBAL BOOL g_fDrawLines; int gEvilImpulse101; extern DLL_GLOBAL int g_iSkillLevel, gDisplayTitle; +extern "C" int g_bhopcap; + BOOL gInitHUD = TRUE; extern void CopyToBodyQue( entvars_t *pev); @@ -181,6 +183,7 @@ int gmsgSetFOV = 0; int gmsgShowMenu = 0; int gmsgGeigerRange = 0; int gmsgTeamNames = 0; +int gmsgBhopcap = 0; int gmsgStatusText = 0; int gmsgStatusValue = 0; @@ -227,6 +230,7 @@ void LinkUserMessages( void ) gmsgFade = REG_USER_MSG( "ScreenFade", sizeof(ScreenFade) ); gmsgAmmoX = REG_USER_MSG( "AmmoX", 2 ); gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 ); + gmsgBhopcap = REG_USER_MSG( "Bhopcap", 1 ); gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); @@ -4072,6 +4076,15 @@ void CBasePlayer::UpdateClientData( void ) UpdateStatusBar(); m_flNextSBarUpdateTime = gpGlobals->time + 0.2; } + + // Send the current bhopcap state. + if( !m_bSentBhopcap ) + { + m_bSentBhopcap = true; + MESSAGE_BEGIN( MSG_ONE, gmsgBhopcap, NULL, pev ); + WRITE_BYTE( g_bhopcap ); + MESSAGE_END(); + } } //========================================================= diff --git a/dlls/player.h b/dlls/player.h index b2dce868..8ff312ea 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -313,13 +313,15 @@ public: //Player ID void InitStatusBar( void ); void UpdateStatusBar( void ); - int m_izSBarState[ SBAR_END ]; + int m_izSBarState[SBAR_END]; float m_flNextSBarUpdateTime; float m_flStatusBarDisappearDelay; - char m_SbarString0[ SBAR_STRING_SIZE ]; - char m_SbarString1[ SBAR_STRING_SIZE ]; + char m_SbarString0[SBAR_STRING_SIZE]; + char m_SbarString1[SBAR_STRING_SIZE]; float m_flNextChatTime; + + bool m_bSentBhopcap; // If false, the player just joined and needs a bhopcap message. }; #define AUTOAIM_2DEGREES 0.0348994967025 @@ -327,7 +329,7 @@ public: #define AUTOAIM_8DEGREES 0.1391731009601 #define AUTOAIM_10DEGREES 0.1736481776669 -extern int gmsgHudText; +extern int gmsgHudText; extern BOOL gInitHUD; #endif // PLAYER_H diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index c709ba14..9aed8093 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -27,11 +27,13 @@ #include // atoi #include // isspace +int g_bhopcap = 1; + #ifdef CLIENT_DLL - // Spectator Mode - int iJumpSpectator; -extern float vJumpOrigin[3]; -extern float vJumpAngles[3]; +// Spectator Mode +int iJumpSpectator; +extern float vJumpOrigin[3]; +extern float vJumpAngles[3]; #endif static int pm_shared_initialized = 0; @@ -2556,7 +2558,8 @@ void PM_Jump( void ) // In the air now. pmove->onground = -1; - PM_PreventMegaBunnyJumping(); + if( g_bhopcap ) + PM_PreventMegaBunnyJumping(); if( tfc ) { From 85edea072b35d0dce99f60ad5fb11a1cd82e3e67 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:10:06 +0500 Subject: [PATCH 058/199] Merge https://github.com/ValveSoftware/halflife/pull/1590/commits/136de25b61689ee30ca0206e6737c7d06be77567 --- cl_dll/menu.cpp | 10 ++++++---- cl_dll/text_message.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/cl_dll/menu.cpp b/cl_dll/menu.cpp index 5f710a33..fc24b917 100644 --- a/cl_dll/menu.cpp +++ b/cl_dll/menu.cpp @@ -83,7 +83,7 @@ int CHudMenu::Draw( float flTime ) int nlc = 0; for( i = 0; i < MAX_MENU_STRING && g_szMenuString[i] != '\0'; i++ ) { - if ( g_szMenuString[i] == '\n' ) + if( g_szMenuString[i] == '\n' ) nlc++; } @@ -153,19 +153,21 @@ int CHudMenu::MsgFunc_ShowMenu( const char *pszName, int iSize, void *pbuf ) else { // append to the current menu string - strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen( g_szPrelocalisedMenuString ) ); + strncat( g_szPrelocalisedMenuString, READ_STRING(), MAX_MENU_STRING - strlen( g_szPrelocalisedMenuString ) - 1 ); } g_szPrelocalisedMenuString[MAX_MENU_STRING - 1] = 0; // ensure null termination (strncat/strncpy does not) if( !NeedMore ) { // we have the whole string, so we can localise it now - strcpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ) ); + strncpy( g_szMenuString, gHUD.m_TextMessage.BufferedLocaliseTextString( g_szPrelocalisedMenuString ), MAX_MENU_STRING ); + g_szMenuString[MAX_MENU_STRING - 1] = '\0'; // Swap in characters if( KB_ConvertString( g_szMenuString, &temp ) ) { - strcpy( g_szMenuString, temp ); + strncpy( g_szMenuString, temp, MAX_MENU_STRING ); + g_szMenuString[MAX_MENU_STRING - 1] = '\0'; free( temp ); } } diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index 58dae6f7..9452cebb 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -45,14 +45,15 @@ int CHudTextMessage::Init( void ) char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, int buffer_size ) { char *dst = dst_buffer; - for( char *src = (char*)msg; *src != 0 && buffer_size > 0; buffer_size-- ) + for( char *src = (char*)msg; *src != 0 && ( buffer_size - 1 ) > 0; buffer_size-- ) { if( *src == '#' ) { // cut msg name out of string static char word_buf[255]; char *wdst = word_buf, *word_start = src; - for( ++src; ( *src >= 'A' && *src <= 'z' ) || ( *src >= '0' && *src <= '9' ); wdst++, src++ ) + int wordbuf_size = (int)sizeof(word_buf); + for( ++src; ( ( *src >= 'A' && *src <= 'z' ) || ( *src >= '0' && *src <= '9' ) ) && ( wordbuf_size - 1 ) > 0; wdst++, src++, wordbuf_size-- ) { *wdst = *src; } @@ -69,21 +70,20 @@ char *CHudTextMessage::LocaliseTextString( const char *msg, char *dst_buffer, in } // copy string into message over the msg name - for( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0; wsrc++, dst++ ) + for( char *wsrc = (char*)clmsg->pMessage; *wsrc != 0 && ( buffer_size - 1 ) > 0; wsrc++, dst++, buffer_size-- ) { *dst = *wsrc; } - *dst = 0; + buffer_size++; } else { *dst = *src; dst++, src++; - *dst = 0; } } - dst_buffer[buffer_size - 1] = 0; // ensure null termination + *dst = 0; // ensure null termination return dst_buffer; } From 495c7717242f0315fced701c57dee242b48f66af Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:20:29 +0500 Subject: [PATCH 059/199] Update mp5.cpp. --- dlls/mp5.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index a13257a1..403efa04 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -238,7 +238,7 @@ void CMP5::SecondaryAttack( void ) void CMP5::Reload( void ) { - if( m_pPlayer->ammo_9mm <= 0 ) + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == MP5_MAX_CLIP ) return; DefaultReload( MP5_MAX_CLIP, MP5_RELOAD, 1.5 ); From b66f1cb39400e586d7a2ef8eca44c2f14c226e69 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:25:22 +0500 Subject: [PATCH 060/199] Update glock.cpp. --- dlls/glock.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 4e679750..3eb08d6c 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -109,7 +109,7 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) if( m_fFireOnEmpty ) { PlayEmptySound(); - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.2 ); } return; @@ -158,7 +158,7 @@ void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), fUseAutoAim ? m_usFireGlock1 : m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 ); - m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay( flCycleTime ); if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) // HEV suit - indicate out of ammo condition From 6e1059026faa90c5bfe5e3b3f4f58fde398d4524 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:41:13 +0500 Subject: [PATCH 061/199] Do not detonate hand grenade after weapon switch. --- dlls/handgrenade.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index 96119b6b..2a31fc84 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -103,6 +103,12 @@ void CHandGrenade::Holster( int skiplocal /* = 0 */ ) pev->nextthink = gpGlobals->time + 0.1; } + if( m_flStartThrow ) + { + m_flStartThrow = 0; + m_flReleaseThrow = 0; + } + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); } From b7d1bd3235790026cf0d3e66053ba155f2b0a07a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 00:44:14 +0500 Subject: [PATCH 062/199] Merge fix for blocked door sound from bubblemod. --- dlls/doors.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/doors.cpp b/dlls/doors.cpp index dcb04e00..231a3753 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -750,6 +750,11 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) // so let it just squash the object to death real fast if( m_flWait >= 0 ) { + // BMod Start - Door sound fix. + if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) + STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + // BMod End + if( m_toggle_state == TS_GOING_DOWN ) { DoorGoUp(); From bdd3e74ebd3fbf7f7d4d20cdf2e85c8f981309a3 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 02:30:10 +0500 Subject: [PATCH 063/199] Detonate satchels under blocked door. --- dlls/doors.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 231a3753..3a8613ab 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -22,6 +22,7 @@ #include "util.h" #include "cbase.h" #include "doors.h" +#include "weapons.h" extern void SetMovedir( entvars_t *ev ); @@ -746,6 +747,10 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) if( pev->dmg ) pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); + // Detonate satchels + if( !strcmp( "monster_satchel", STRING( pOther->pev->classname ) ) ) + ( (CSatchel*)pOther )->Use( this, this, USE_ON, 0 ); + // if a door has a negative wait, it would never come back if blocked, // so let it just squash the object to death real fast if( m_flWait >= 0 ) From c6b353e09287048fb42cd4811b5854ded5ce93bc Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 02:35:32 +0500 Subject: [PATCH 064/199] Fix build. --- dlls/gauss.cpp | 2 +- dlls/nihilanth.cpp | 2 +- dlls/subs.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 0ebb876c..d3e005c2 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -126,7 +126,7 @@ int CGauss::GetItemInfo( ItemInfo *p ) BOOL CGauss::IsUseable() { // Currently charging, allow the player to fire it first. - Solokiller - return CBasePlayerWeapon::IsUseable() || m_InAttack != 0; + return CBasePlayerWeapon::IsUseable() || m_fInAttack != 0; } BOOL CGauss::Deploy() diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 82b31e13..1f9b0f88 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -356,7 +356,7 @@ void CNihilanth::UpdateOnRemove() m_pBall = 0; } - for( int i = 0; i < N_SPHERES, i++ ) + for( int i = 0; i < N_SPHERES; i++ ) { if( CBaseEntity* pSphere = (CBaseEntity *)m_hSphere[i] ) { diff --git a/dlls/subs.cpp b/dlls/subs.cpp index 4654363a..2a299ce4 100644 --- a/dlls/subs.cpp +++ b/dlls/subs.cpp @@ -112,7 +112,7 @@ void CBaseEntity::UpdateOnRemove( void ) //Killtarget didn't do this before, so the counter broke. - Solokiller if( CBaseEntity* pOwner = pev->owner ? Instance( pev->owner ) : 0 ) { - pOwner->DeathNotice( this ); + pOwner->DeathNotice( pev ); } } From f575e78a9b7320db15025e94c1d1bb2cd1922a60 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 6 Jul 2017 03:47:59 +0500 Subject: [PATCH 065/199] Register allow_spectators cvar. --- dlls/game.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/game.cpp b/dlls/game.cpp index 7905075a..9b69cac9 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -455,6 +455,7 @@ void GameDLLInit( void ) g_footsteps = CVAR_GET_POINTER( "mp_footsteps" ); CVAR_REGISTER( &displaysoundlist ); + CVAR_REGISTER( &allow_spectators ); CVAR_REGISTER( &teamplay ); CVAR_REGISTER( &fraglimit ); From 4d1dc131b924dedbb03bf40eb4bb64bd1c624f1a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 8 Jul 2017 20:06:00 +0500 Subject: [PATCH 066/199] Fix mistakes with saverestore after merge. --- dlls/util.cpp | 2 +- engine/eiface.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/dlls/util.cpp b/dlls/util.cpp index d79c9f5a..f4b09cb1 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1890,7 +1890,7 @@ void CSave::WriteFunction( const char *pname, void **data, int count ) { const char *functionName; - functionName = NAME_FOR_FUNCTION( (unsigned int)(size_t)*data ); + functionName = NAME_FOR_FUNCTION( (size_t)*data ); if( functionName ) BufferField( pname, strlen( functionName ) + 1, functionName ); else diff --git a/engine/eiface.h b/engine/eiface.h index 30f8a82a..23cb17f8 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -172,8 +172,8 @@ typedef struct enginefuncs_s int (*pfnRegUserMsg)( const char *pszName, int iSize ); void (*pfnAnimationAutomove)( const edict_t* pEdict, float flTime ); void (*pfnGetBonePosition)( const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - unsigned int (*pfnFunctionFromName)( const char *pName ); - const char *(*pfnNameForFunction)( unsigned int function ); + size_t (*pfnFunctionFromName)( const char *pName ); + const char *(*pfnNameForFunction)( size_t function ); void (*pfnClientPrintf)( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients void (*pfnServerPrint)( const char *szMsg ); const char *(*pfnCmd_Args)( void ); // these 3 added From c16e1ecfef45f5a6b67ff470051c328cc7e760b6 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 8 Jul 2017 20:13:41 +0500 Subject: [PATCH 067/199] A little fix for nodes on 64bit arches. --- dlls/nodes.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/nodes.h b/dlls/nodes.h index 2b582a6f..f5ebcd84 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -104,7 +104,11 @@ typedef struct //========================================================= // CGraph //========================================================= +#if defined(__amd64__) || defined(__aarch64__) +#define GRAPH_VERSION (int)17// Was incremented for 64bit arches, because .nod-files have incombatibilities on different arches. +#else #define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. +#endif class CGraph { From 3bce17e3a04f8af10a927a07ceb8ab0f09152ec4 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sat, 8 Jul 2017 20:26:21 +0000 Subject: [PATCH 068/199] Fix saverestore on LP64 --- dlls/saverestore.h | 2 +- dlls/util.cpp | 6 +++--- engine/eiface.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dlls/saverestore.h b/dlls/saverestore.h index f76613e8..a9ad2c54 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -59,7 +59,7 @@ public: void WriteVector( const char *pname, const float *value, int count ); // Save a vector void WritePositionVector( const char *pname, const Vector &value ); // Offset for landmark if necessary void WritePositionVector( const char *pname, const float *value, int count ); // array of pos vectors - void WriteFunction( const char *pname, const int *value, int count ); // Save a function pointer + void WriteFunction( const char *pname, void **value, int count ); // Save a function pointer int WriteEntVars( const char *pname, entvars_t *pev ); // Save entvars_t (entvars_t) int WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCount ); diff --git a/dlls/util.cpp b/dlls/util.cpp index d1fceb0a..1c229edd 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1886,7 +1886,7 @@ void CSave::WritePositionVector( const char *pname, const float *value, int coun } } -void CSave::WriteFunction( const char *pname, const int *data, int count ) +void CSave::WriteFunction( const char *pname, void **data, int count ) { const char *functionName; @@ -1894,7 +1894,7 @@ void CSave::WriteFunction( const char *pname, const int *data, int count ) if( functionName ) BufferField( pname, strlen( functionName ) + 1, functionName ); else - ALERT( at_error, "Invalid function pointer in entity!" ); + ALERT( at_error, "Invalid function pointer in entity!\n" ); } void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) @@ -2042,7 +2042,7 @@ int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFi WriteInt( pTest->fieldName, (int *)(char *)pOutputData, pTest->fieldSize ); break; case FIELD_FUNCTION: - WriteFunction( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); + WriteFunction( pTest->fieldName, (void **)pOutputData, pTest->fieldSize ); break; default: ALERT( at_error, "Bad field type\n" ); diff --git a/engine/eiface.h b/engine/eiface.h index 903451f5..b3b9d415 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -171,8 +171,8 @@ typedef struct enginefuncs_s int (*pfnRegUserMsg)( const char *pszName, int iSize ); void (*pfnAnimationAutomove)( const edict_t* pEdict, float flTime ); void (*pfnGetBonePosition)( const edict_t* pEdict, int iBone, float *rgflOrigin, float *rgflAngles ); - unsigned long (*pfnFunctionFromName)( const char *pName ); - const char *(*pfnNameForFunction)( unsigned long function ); + void* (*pfnFunctionFromName)( const char *pName ); + const char *(*pfnNameForFunction)( void *function ); void (*pfnClientPrintf)( edict_t* pEdict, PRINT_TYPE ptype, const char *szMsg ); // JOHN: engine callbacks so game DLL can print messages to individual clients void (*pfnServerPrint)( const char *szMsg ); const char *(*pfnCmd_Args)( void ); // these 3 added From 9ebfc981773ec4c7a89ffe52d9c249e1fbef9634 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sat, 8 Jul 2017 21:28:31 +0000 Subject: [PATCH 069/199] Fix field sizes --- dlls/util.cpp | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/dlls/util.cpp b/dlls/util.cpp index 1c229edd..0298487b 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1584,6 +1584,33 @@ void UTIL_StripToken( const char *pKey, char *pDest ) // // -------------------------------------------------------------- static int gSizes[FIELD_TYPECOUNT] = +{ + sizeof(float), // FIELD_FLOAT + sizeof(int), // FIELD_STRING + sizeof(void*), // FIELD_ENTITY + sizeof(void*), // FIELD_CLASSPTR + sizeof(void*), // FIELD_EHANDLE + sizeof(void*), // FIELD_entvars_t + sizeof(void*), // FIELD_EDICT + sizeof(float) * 3, // FIELD_VECTOR + sizeof(float) * 3, // FIELD_POSITION_VECTOR + sizeof(void *), // FIELD_POINTER + sizeof(int), // FIELD_INTEGER +#ifdef GNUC + sizeof(void *) * 2, // FIELD_FUNCTION +#else + sizeof(void *), // FIELD_FUNCTION +#endif + sizeof(int), // FIELD_BOOLEAN + sizeof(short), // FIELD_SHORT + sizeof(char), // FIELD_CHARACTER + sizeof(float), // FIELD_TIME + sizeof(int), // FIELD_MODELNAME + sizeof(int), // FIELD_SOUNDNAME +}; + +// entities has different store size +static int gInputSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT sizeof(int), // FIELD_STRING @@ -1594,12 +1621,12 @@ static int gSizes[FIELD_TYPECOUNT] = sizeof(int), // FIELD_EDICT sizeof(float) * 3, // FIELD_VECTOR sizeof(float) * 3, // FIELD_POSITION_VECTOR - sizeof(int *), // FIELD_POINTER + sizeof(void *), // FIELD_POINTER sizeof(int), // FIELD_INTEGER #ifdef GNUC - sizeof(int *) * 2, // FIELD_FUNCTION + sizeof(void *) * 2, // FIELD_FUNCTION #else - sizeof(int *), // FIELD_FUNCTION + sizeof(void *), // FIELD_FUNCTION #endif sizeof(int), // FIELD_BOOLEAN sizeof(short), // FIELD_SHORT @@ -2137,7 +2164,7 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou for( j = 0; j < pTest->fieldSize; j++ ) { void *pOutputData = ( (char *)pBaseData + pTest->fieldOffset + ( j * gSizes[pTest->fieldType] ) ); - void *pInputData = (char *)pData + j * gSizes[pTest->fieldType]; + void *pInputData = (char *)pData + j * gInputSizes[pTest->fieldType]; switch( pTest->fieldType ) { From 4d7d6f2c378f0b79fe9dd4eeb931cdb6daadd48f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 10 Jul 2017 19:28:56 +0500 Subject: [PATCH 070/199] Turn off flashlight when player dead. --- dlls/player.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/player.cpp b/dlls/player.cpp index b838f35f..5029ce97 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -820,6 +820,9 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) else pev->weapons &= ~WEAPON_ALLWEAPONS; + // Turn off flashlight + ClearBits( pev->effects, EF_DIMLIGHT ); + for( i = 0; i < MAX_AMMO_SLOTS; i++ ) m_rgAmmo[i] = 0; From 2324270cc27d818923391f6d34319fb4cd258795 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 10 Jul 2017 22:18:45 +0500 Subject: [PATCH 071/199] Do not reduce armor value when godmode is active. --- dlls/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 5029ce97..852abca3 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -466,7 +466,7 @@ int CBasePlayer::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl m_lastDamageAmount = (int)flDamage; // Armor. - if( pev->armorvalue && !( bitsDamageType & ( DMG_FALL | DMG_DROWN ) ) )// armor doesn't protect against fall or drown damage! + if( !( pev->flags & FL_GODMODE ) && pev->armorvalue && !( bitsDamageType & ( DMG_FALL | DMG_DROWN ) ) )// armor doesn't protect against fall or drown damage! { float flNew = flDamage * flRatio; From 77d077c83dc3384ee6c6134a04657ea1259847f3 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 01:32:53 +0500 Subject: [PATCH 072/199] Partially merge https://github.com/SamVanheer/HLEnhanced/commit/3563a1846fc8905bb7357c103212a6e10b5f048b --- dlls/plats.cpp | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 203f5d9b..a60e6706 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -248,7 +248,7 @@ public: virtual int ObjectCaps( void ) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } void SpawnInsideTrigger( CFuncPlat *pPlatform ); void Touch( CBaseEntity *pOther ); - CFuncPlat *m_pPlatform; + EHANDLE m_pPlatform; }; /*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER @@ -340,24 +340,24 @@ static void PlatSpawnInsideTrigger( entvars_t *pevPlatform ) // void CPlatTrigger::SpawnInsideTrigger( CFuncPlat *pPlatform ) { - m_pPlatform = pPlatform; + m_hPlatform = pPlatform; // Create trigger entity, "point" it at the owning platform, give it a touch method pev->solid = SOLID_TRIGGER; pev->movetype = MOVETYPE_NONE; pev->origin = pPlatform->pev->origin; // Establish the trigger field's size - Vector vecTMin = m_pPlatform->pev->mins + Vector( 25, 25, 0 ); - Vector vecTMax = m_pPlatform->pev->maxs + Vector( 25, 25, 8 ); - vecTMin.z = vecTMax.z - ( m_pPlatform->m_vecPosition1.z - m_pPlatform->m_vecPosition2.z + 8 ); - if( m_pPlatform->pev->size.x <= 50 ) + Vector vecTMin = pPlatform->pev->mins + Vector( 25, 25, 0 ); + Vector vecTMax = pPlatform->pev->maxs + Vector( 25, 25, 8 ); + vecTMin.z = vecTMax.z - ( pPlatform->m_vecPosition1.z - pPlatform->m_vecPosition2.z + 8 ); + if( pPlatform->pev->size.x <= 50 ) { - vecTMin.x = ( m_pPlatform->pev->mins.x + m_pPlatform->pev->maxs.x ) / 2; + vecTMin.x = ( pPlatform->pev->mins.x + pPlatform->pev->maxs.x ) / 2; vecTMax.x = vecTMin.x + 1; } - if( m_pPlatform->pev->size.y <= 50 ) + if( pPlatform->pev->size.y <= 50 ) { - vecTMin.y = ( m_pPlatform->pev->mins.y + m_pPlatform->pev->maxs.y ) / 2; + vecTMin.y = ( pPlatform->pev->mins.y + pPlatform->pev->maxs.y ) / 2; vecTMax.y = vecTMin.y + 1; } UTIL_SetSize( pev, vecTMin, vecTMax ); @@ -373,15 +373,17 @@ void CPlatTrigger::Touch( CBaseEntity *pOther ) if( !FClassnameIs( pevToucher, "player" ) ) return; + CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform; + // Ignore touches by corpses if( !pOther->IsAlive() ) return; // Make linked platform go up/down. - if( m_pPlatform->m_toggle_state == TS_AT_BOTTOM ) - m_pPlatform->GoUp(); - else if( m_pPlatform->m_toggle_state == TS_AT_TOP ) - m_pPlatform->pev->nextthink = m_pPlatform->pev->ltime + 1;// delay going down + if( pPlatform->m_toggle_state == TS_AT_BOTTOM ) + pPlatform->GoUp(); + else if( pPlatform->m_toggle_state == TS_AT_TOP ) + pPlatform->pev->nextthink = pPlatform->pev->ltime + 1;// delay going down } // From 2df762e705d4726d5017b670138660bc8079053a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 01:40:26 +0500 Subject: [PATCH 073/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/f8db63a45bcc62d6110051109daca77031699df8 --- dlls/plats.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/dlls/plats.cpp b/dlls/plats.cpp index a60e6706..5d5d1f07 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -375,6 +375,13 @@ void CPlatTrigger::Touch( CBaseEntity *pOther ) CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform; + if( FNullEnt( pPlatform ) ) + { + // The target platform has been removed, remove myself as well. - Solokiller + UTIL_Remove( this ); + return; + } + // Ignore touches by corpses if( !pOther->IsAlive() ) return; @@ -429,7 +436,7 @@ void CFuncPlat::GoDown( void ) } // -// Platform has hit bottom. Stops and waits forever. +// Platform has hit bottom. Stops and waits forever. // void CFuncPlat::HitBottom( void ) { @@ -458,7 +465,7 @@ void CFuncPlat::GoUp( void ) } // -// Platform has hit top. Pauses, then starts back down again. +// Platform has hit top. Pauses, then starts back down again. // void CFuncPlat::HitTop( void ) { @@ -556,7 +563,7 @@ void CFuncPlatRot::GoDown( void ) } // -// Platform has hit bottom. Stops and waits forever. +// Platform has hit bottom. Stops and waits forever. // void CFuncPlatRot::HitBottom( void ) { @@ -575,7 +582,7 @@ void CFuncPlatRot::GoUp( void ) } // -// Platform has hit top. Pauses, then starts back down again. +// Platform has hit top. Pauses, then starts back down again. // void CFuncPlatRot::HitTop( void ) { @@ -857,8 +864,8 @@ void CFuncTrain::Precache( void ) case 1: PRECACHE_SOUND( "plats/train2.wav" ); PRECACHE_SOUND( "plats/train1.wav" ); - pev->noise = MAKE_STRING("plats/train2.wav" ); - pev->noise1 = MAKE_STRING("plats/train1.wav" ); + pev->noise = MAKE_STRING( "plats/train2.wav" ); + pev->noise1 = MAKE_STRING( "plats/train1.wav" ); break; case 2: PRECACHE_SOUND( "plats/platmove1.wav" ); From 8455d693609863c48108aeaff11d9b8e3f59fb49 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 01:58:22 +0500 Subject: [PATCH 074/199] Merge https://github.com/SamVanheer/HLEnhanced/commit/d6732ca0795e1be23bea808782eb4dfd13cbd1aa --- dlls/player.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 852abca3..9680aaf6 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3661,7 +3661,9 @@ int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) pev->viewmodel = 0; pev->weaponmodel = 0; } - else if( m_pLastItem == pItem ) + + // In some cases an item can be both the active and last item, like for instance dropping all weapons and only having an exhaustible weapon left. - Solokiller + if( m_pLastItem == pItem ) m_pLastItem = NULL; CBasePlayerItem *pPrev = m_rgpPlayerItems[pItem->iItemSlot()]; From 1c1d9ae18385f1a152c93f115289defbd64394ab Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 02:24:19 +0500 Subject: [PATCH 075/199] Remove unneeded strcpy usage. --- cl_dll/com_weapons.cpp | 2 +- cl_dll/com_weapons.h | 2 +- cl_dll/ev_hldm.cpp | 19 +++++++++---------- 3 files changed, 11 insertions(+), 12 deletions(-) diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index 774df091..5621149b 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -283,7 +283,7 @@ unsigned short stub_PrecacheEvent( int type, const char *s ) return 0; } -const char *stub_NameForFunction( unsigned int function ) +const char *stub_NameForFunction( void *function ) { return "func"; } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 8559e20b..0a538f0f 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -34,7 +34,7 @@ void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); int stub_PrecacheModel( const char* s ); int stub_PrecacheSound( const char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); -const char *stub_NameForFunction( unsigned int function ); +const char *stub_NameForFunction( void *function ); void stub_SetModel( struct edict_s *e, const char *m ); extern cvar_t *cl_lw; diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 7bb3a797..d94f9fea 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1695,7 +1695,7 @@ void EV_TrainPitchAdjust( event_args_t *args ) int pitch; int stop; - char sz[256]; + const char *pszSound; idx = args->entindex; @@ -1711,36 +1711,35 @@ void EV_TrainPitchAdjust( event_args_t *args ) switch( noise ) { case 1: - strcpy( sz, "plats/ttrain1.wav" ); + pszSound = "plats/ttrain1.wav"; break; case 2: - strcpy( sz, "plats/ttrain2.wav" ); + pszSound = "plats/ttrain2.wav"; break; case 3: - strcpy( sz, "plats/ttrain3.wav" ); + pszSound = "plats/ttrain3.wav"; break; case 4: - strcpy( sz, "plats/ttrain4.wav"); + pszSound = "plats/ttrain4.wav"; break; case 5: - strcpy( sz, "plats/ttrain6.wav"); + pszSound = "plats/ttrain6.wav"; break; case 6: - strcpy( sz, "plats/ttrain7.wav"); + pszSound = "plats/ttrain7.wav"; break; default: // no sound - strcpy( sz, "" ); return; } if( stop ) { - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, sz ); + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, pszSound ); } else { - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, sz, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch ); + gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, pszSound, m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, pitch ); } } From a383a57a09351365b5b3beb78d26ec0c035df4ef Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 11 Jul 2017 02:43:24 +0500 Subject: [PATCH 076/199] Fix build. --- dlls/plats.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 5d5d1f07..00b05bec 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -248,7 +248,7 @@ public: virtual int ObjectCaps( void ) { return (CBaseEntity::ObjectCaps() & ~FCAP_ACROSS_TRANSITION) | FCAP_DONT_SAVE; } void SpawnInsideTrigger( CFuncPlat *pPlatform ); void Touch( CBaseEntity *pOther ); - EHANDLE m_pPlatform; + EHANDLE m_hPlatform; }; /*QUAKED func_plat (0 .5 .8) ? PLAT_LOW_TRIGGER @@ -375,7 +375,7 @@ void CPlatTrigger::Touch( CBaseEntity *pOther ) CFuncPlat *pPlatform = (CFuncPlat*)(CBaseEntity*)m_hPlatform; - if( FNullEnt( pPlatform ) ) + if( !pPlatform ) { // The target platform has been removed, remove myself as well. - Solokiller UTIL_Remove( this ); From 4661b5c1a5245b27a5532745c11e44b5540e4172 Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 14 Jul 2017 13:11:58 +0000 Subject: [PATCH 077/199] Increase graph version --- dlls/nodes.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/nodes.h b/dlls/nodes.h index 27b890ed..cbf1e2a6 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -103,7 +103,11 @@ typedef struct //========================================================= // CGraph //========================================================= +#ifdef __amd64 +#define GRAPH_VERSION (int)16 * 10 +#else #define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. +#endif class CGraph { From a08bd614fe524d8c827ac34810a130b6f2dc90ba Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 14 Jul 2017 13:15:17 +0000 Subject: [PATCH 078/199] Fix client build --- cl_dll/com_weapons.cpp | 2 +- cl_dll/com_weapons.h | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cl_dll/com_weapons.cpp b/cl_dll/com_weapons.cpp index 4f539df9..d359a3f1 100644 --- a/cl_dll/com_weapons.cpp +++ b/cl_dll/com_weapons.cpp @@ -283,7 +283,7 @@ unsigned short stub_PrecacheEvent( int type, const char *s ) return 0; } -const char *stub_NameForFunction( unsigned long function ) +const char *stub_NameForFunction( void *function ) { return "func"; } diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index 7e1fdd77..4ce861f4 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // @@ -34,7 +34,7 @@ void HUD_SetMaxSpeed( const struct edict_s *ed, float speed ); int stub_PrecacheModel( char* s ); int stub_PrecacheSound( char* s ); unsigned short stub_PrecacheEvent( int type, const char *s ); -const char *stub_NameForFunction( unsigned long function ); +const char *stub_NameForFunction( void *function ); void stub_SetModel( struct edict_s *e, const char *m ); extern cvar_t *cl_lw; From 00833188dab87ef5746286479ba5aeb9d83b4a0c Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 14 Jul 2017 13:42:47 +0000 Subject: [PATCH 079/199] Use real MAKE_STRING when possible --- dlls/util.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/dlls/util.h b/dlls/util.h index e8aee878..5b00fe94 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -39,7 +39,14 @@ extern globalvars_t *gpGlobals; #if !defined __amd64__ || defined(CLIENT_DLL) #define MAKE_STRING(str) ((int)(size_t)str - (int)(size_t)STRING(0)) #else -#define MAKE_STRING ALLOC_STRING +static inline int MAKE_STRING(const char *szValue) +{ + long long ptrdiff = szValue - STRING(0); + if( ptrdiff > INT_MAX || ptrdiff < INT_MIN ) + return ALLOC_STRING(szValue); + else + return (int)ptrdiff; +} #endif inline edict_t *FIND_ENTITY_BY_CLASSNAME(edict_t *entStart, const char *pszName) From 1674a4b6d496b03da7efd689b739d721b83a9c8a Mon Sep 17 00:00:00 2001 From: mittorn Date: Fri, 14 Jul 2017 15:34:44 +0000 Subject: [PATCH 080/199] Use XASH_64BIT macro --- cl_dll/cl_dll.h | 4 ++++ dlls/extdll.h | 4 ++++ dlls/nodes.h | 2 +- dlls/util.h | 2 +- engine/studio.h | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index fda4b812..24d1874b 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -41,6 +41,10 @@ typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); #include "exportdef.h" #include +#if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) + #define XASH_64BIT +#endif + extern cl_enginefunc_t gEngfuncs; #include "../engine/mobility_int.h" extern mobile_engfuncs_t *gMobileEngfuncs; diff --git a/dlls/extdll.h b/dlls/extdll.h index cbc7ebb9..dda1cec5 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -57,6 +57,10 @@ typedef int BOOL; #include "stdlib.h" #include "math.h" +#if defined(__LP64__) || defined(__LLP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__) + #define XASH_64BIT +#endif + // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; typedef unsigned int string_t; // from engine's pr_comp.h; diff --git a/dlls/nodes.h b/dlls/nodes.h index cbf1e2a6..c959dd2e 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -103,7 +103,7 @@ typedef struct //========================================================= // CGraph //========================================================= -#ifdef __amd64 +#ifdef XASH_64BIT #define GRAPH_VERSION (int)16 * 10 #else #define GRAPH_VERSION (int)16// !!!increment this whever graph/node/link classes change, to obsolesce older disk files. diff --git a/dlls/util.h b/dlls/util.h index 5b00fe94..a61240fd 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -36,7 +36,7 @@ extern globalvars_t *gpGlobals; // Use this instead of ALLOC_STRING on constant strings #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) -#if !defined __amd64__ || defined(CLIENT_DLL) +#if !defined XASH_64BIT || defined(CLIENT_DLL) #define MAKE_STRING(str) ((int)(size_t)str - (int)(size_t)STRING(0)) #else static inline int MAKE_STRING(const char *szValue) diff --git a/engine/studio.h b/engine/studio.h index b5b709bb..5e5ec26c 100644 --- a/engine/studio.h +++ b/engine/studio.h @@ -215,7 +215,7 @@ typedef struct char label[32]; // textual name char name[64]; // file name cache_user_t cache; // cache index pointer -#ifndef __amd64 +#ifndef XASH_64BIT int data; // hack for group 0 #endif } mstudioseqgroup_t; From cbdf9b5d042bf695f85918ca8bee074ecec0d368 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 09:48:08 +0500 Subject: [PATCH 081/199] Fix knowledge bugs with satchels again. --- dlls/client.cpp | 6 ------ dlls/multiplay_gamerules.cpp | 6 ------ dlls/player.cpp | 1 + 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 1fead362..480a9506 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -127,12 +127,6 @@ void ClientDisconnect( edict_t *pEntity ) pEntity->v.solid = SOLID_NOT;// nonsolid UTIL_SetOrigin( &pEntity->v, pEntity->v.origin ); - CBasePlayer *pl = (CBasePlayer *)CBaseEntity::Instance( pEntity ); - if( pl->HasNamedPlayerItem( "weapon_satchel" ) ) - { - DeactivateSatchels( pl ); - } - g_pGameRules->ClientDisconnected( pEntity ); } diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 9da8d0b4..494ac4f6 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -675,12 +675,6 @@ void CHalfLifeMultiplay::PlayerKilled( CBasePlayer *pVictim, entvars_t *pKiller, // let the killer paint another decal as soon as he'd like. PK->m_flNextDecalTime = gpGlobals->time; } -#ifndef HLDEMO_BUILD - if( pVictim->HasNamedPlayerItem( "weapon_satchel" ) ) - { - DeactivateSatchels( pVictim ); - } -#endif } //========================================================= diff --git a/dlls/player.cpp b/dlls/player.cpp index 9680aaf6..1d198e84 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -826,6 +826,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) for( i = 0; i < MAX_AMMO_SLOTS; i++ ) m_rgAmmo[i] = 0; + DeactivateSatchels( this ); UpdateClientData(); // send Selected Weapon Message to our client From 004054586b0cc48863638a9505c3e139c3423148 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 10:01:32 +0500 Subject: [PATCH 082/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/52209adc339fa21ee1c9564e5d82ad97d9a09374 --- dlls/func_tank.cpp | 4 +++- dlls/player.cpp | 11 ----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index ab295e0c..cace610d 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -351,6 +351,7 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) ALERT( at_console, "using TANK!\n"); m_pController = pController; + m_pController->m_pTank = this; if( m_pController->m_pActiveItem ) { m_pController->m_pActiveItem->Holster(); @@ -380,6 +381,8 @@ void CFuncTank::StopControl() m_pController->m_iHideHUD &= ~HIDEHUD_WEAPONS; pev->nextthink = 0; + + m_pController->m_pTank = NULL; m_pController = NULL; if( IsActive() ) @@ -426,7 +429,6 @@ void CFuncTank::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE use } else if( !m_pController && useType != USE_OFF ) { - ( (CBasePlayer*)pActivator )->m_pTank = this; StartControl( (CBasePlayer*)pActivator ); } else diff --git a/dlls/player.cpp b/dlls/player.cpp index 1d198e84..10216734 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -792,10 +792,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) m_pLastItem = NULL; if( m_pTank != 0 ) - { m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; - } int i; CBasePlayerItem *pPendingItem; @@ -856,10 +853,7 @@ void CBasePlayer::Killed( entvars_t *pevAttacker, int iGib ) g_pGameRules->PlayerKilled( this, pevAttacker, g_pevLastInflictor ); if( m_pTank != 0 ) - { m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; - } // this client isn't going to be thinking for a while, so reset the sound until they respawn pSound = CSoundEnt::SoundPointerForIndex( CSoundEnt::ClientSoundIndex( edict() ) ); @@ -1402,10 +1396,7 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) m_pActiveItem->Holster(); if( m_pTank != 0 ) - { m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; - } // clear out the suit message cache so we don't keep chattering SetSuitUpdate( NULL, FALSE, 0 ); @@ -1481,7 +1472,6 @@ void CBasePlayer::PlayerUse( void ) // Stop controlling the tank // TODO: Send HUD Update m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; return; } else @@ -2520,7 +2510,6 @@ void CBasePlayer::PostThink() { // they've moved off the platform m_pTank->Use( this, this, USE_OFF, 0 ); - m_pTank = NULL; } } From 2b2fdac7d056587cc8105f47ea67cec457c913fa Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 10:04:33 +0500 Subject: [PATCH 083/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/336bc05c82c171f895656f913e9fbedfd8c8df54 --- dlls/rpg.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 5fb8cc70..c87d345f 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -265,6 +265,11 @@ void CRpgRocket::FollowThink( void ) pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; if( pev->waterlevel == 0 && pev->velocity.Length() < 1500 ) { + if( m_pLauncher ) + { + // my launcher is still around, tell it I'm dead. + m_pLauncher->m_cActiveRockets--; + } Detonate(); } } From 6f8cd70328a9ec1ef1dc74ec07aed72e098f8fc9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 10:11:39 +0500 Subject: [PATCH 084/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/7a627bf8e3e13929afd7b23ae8435ea8784b4654 --- dlls/satchel.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 458ac532..8ddc41a3 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -42,6 +42,9 @@ enum satchel_radio_e class CSatchelCharge : public CGrenade { + Vector m_lastBounceOrigin; // Used to fix a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set + void Spawn( void ); + void Precache( void ); void Spawn( void ); void Precache( void ); void BounceSound( void ); @@ -114,14 +117,19 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) } if( !( pev->flags & FL_ONGROUND ) && pev->velocity.Length2D() > 10 ) { + // Fix for a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set + if( pev->origin != m_lastBounceOrigin ) BounceSound(); } - StudioFrameAdvance(); + m_lastBounceOrigin = pev->origin; + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); } void CSatchelCharge::SatchelThink( void ) { - StudioFrameAdvance(); + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; if( !IsInWorld() ) @@ -149,7 +157,7 @@ void CSatchelCharge::SatchelThink( void ) void CSatchelCharge::Precache( void ) { - PRECACHE_MODEL( "models/grenade.mdl" ); + PRECACHE_MODEL( "models/w_satchel.mdl" ); PRECACHE_SOUND( "weapons/g_bounce1.wav" ); PRECACHE_SOUND( "weapons/g_bounce2.wav" ); PRECACHE_SOUND( "weapons/g_bounce3.wav" ); From 73a99df89420b7bf2939bdd0ddf53ad755ce8a3e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 10:15:17 +0500 Subject: [PATCH 085/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/c66ee97ade72db0f63d1357d7a0760702a1c92e8 --- dlls/cbase.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index cdf9a00f..6009bfd5 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -441,9 +441,16 @@ edict_t *EHANDLE::Get( void ) edict_t *EHANDLE::Set( edict_t *pent ) { - m_pent = pent; - if( pent ) - m_serialnumber = m_pent->serialnumber; + if( pent ) + { + m_pent = pent; + m_serialnumber = m_pent->serialnumber; + } + else + { + m_pent = NULL; + m_serialnumber = 0; + } return pent; } From 38b223651533fd0ab984147f906e2fe174683eb9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:01:53 +0500 Subject: [PATCH 086/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/ee1ec9d64f96ecce0ab144cd86b246f5e7b00555 --- dlls/player.cpp | 49 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 10216734..e94f5588 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -2583,11 +2583,10 @@ void CBasePlayer::PostThink() CheckPowerups( pev ); UpdatePlayerSound(); - +pt_end: // Track button info so we can detect 'pressed' and 'released' buttons next frame m_afButtonLast = pev->button; -pt_end: #if defined( CLIENT_WEAPONS ) // Decay timers on weapons // go through all of the weapons and make a list of the ones to pack @@ -4061,6 +4060,52 @@ void CBasePlayer::UpdateClientData( void ) m_rgpPlayerItems[i]->UpdateClientData( this ); } + if( m_pClientActiveItem != pPlayer->m_pActiveItem ) + { + if( pPlayer->m_pActiveItem == NULL ) + { + // If no weapon, we have to send update here + CBasePlayer *plr; + for( int i = 1; i <= gpGlobals->maxClients; i++ ) + { + plr = (CBasePlayer *)UTIL_PlayerByIndex( i ); + if( !plr || !plr->IsObserver() || plr->m_hObserverTarget != pPlayer ) + continue; + + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, plr->pev ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); + MESSAGE_END(); + } + + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pPlayer->pev ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); + WRITE_BYTE( 0 ); + MESSAGE_END(); + } + else if( this != pPlayer ) + { + // Special case for spectator + CBasePlayerWeapon *gun = (CBasePlayerWeapon *)pPlayer->m_pActiveItem->GetWeaponPtr(); + if( gun ) + { + int state; + if( pPlayer->m_fOnTarget ) + state = WEAPON_IS_ONTARGET; + else + state = 1; + + MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); + WRITE_BYTE( state ); + WRITE_BYTE( gun->m_iId ); + WRITE_BYTE( gun->m_iClip ); + MESSAGE_END(); + } + } + } + // Cache and client weapon change m_pClientActiveItem = m_pActiveItem; m_iClientFOV = m_iFOV; From f318cab1c23d0060c36786763bc6d8c955745616 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:06:26 +0500 Subject: [PATCH 087/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/d8daa2f16c30f31f2839fae03580dd213e4501c4 --- dlls/shotgun.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index 12e73ede..a08770b3 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -144,6 +144,9 @@ void CShotgun::PrimaryAttack() #endif m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; + // player "shoot" animation + m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); + Vector vecSrc = m_pPlayer->GetGunPosition(); Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); From 0570769d35c39a8c4d6a249ac7b46bd5fb0a5b8f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:17:26 +0500 Subject: [PATCH 088/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/fd29683101f725c5aa41d6fb62d5217db45e8582 --- dlls/func_tank.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index cace610d..4ee4e6d6 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -369,6 +369,9 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) void CFuncTank::StopControl() { + if( m_pLaser ) + m_pLaser->TurnOff(); + // TODO: bring back the controllers current weapon if( !m_pController ) return; From 075fd2903075aaa28b0d4930d7d1ba0d1b73f492 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:56:33 +0500 Subject: [PATCH 089/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/29c4d46ad02492a33ddd9bb4ace0c873855eebe7 --- dlls/items.cpp | 1 + dlls/weapons.cpp | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/dlls/items.cpp b/dlls/items.cpp index d9cc7871..b0b2aa38 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -166,6 +166,7 @@ void CItem::Materialize( void ) } SetTouch( &CItem::ItemTouch ); + SetThink( NULL ); } #define SF_SUIT_SHORTLOGON 0x0001 diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 61b038c0..22b4a456 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -485,7 +485,7 @@ void CBasePlayerItem::Materialize( void ) pev->solid = SOLID_TRIGGER; UTIL_SetOrigin( pev, pev->origin );// link into world. - SetTouch( &CBasePlayerItem::DefaultTouch); + SetTouch( &CBasePlayerItem::DefaultTouch ); SetThink( NULL ); } @@ -578,13 +578,6 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? - - // If the item is falling and its Think remains FallItem after the player picks it up, - // then after the item touches the ground its Touch will be set back to DefaultTouch, - // so the player will pick it up again, this time Kill-ing the item (since we already have it in the inventory), - // which will make the pointer bad and crash the game. - if( m_pfnThink == &CBasePlayerItem::FallThink ) - SetThink( NULL ); } BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) @@ -734,7 +727,7 @@ void CBasePlayerItem::AttachToPlayer( CBasePlayer *pPlayer ) pev->modelindex = 0;// server won't send down to clients if modelindex == 0 pev->model = iStringNull; pev->owner = pPlayer->edict(); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = 0;// Remove think - prevents futher attempts to materialize SetTouch( NULL ); SetThink( NULL ); } @@ -1054,6 +1047,7 @@ void CBasePlayerAmmo::Materialize( void ) } SetTouch( &CBasePlayerAmmo::DefaultTouch ); + SetThink( NULL ); } void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) From 5a2dccb978a7484db890c91f1ebd6fcfb9780194 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 12:58:28 +0500 Subject: [PATCH 090/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/09a90f4a0095d6702f43c66ff27e9f4444866f3c --- dlls/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index e94f5588..e9ad5645 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -799,13 +799,13 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) for( i = 0; i < MAX_ITEM_TYPES; i++ ) { m_pActiveItem = m_rgpPlayerItems[i]; + m_rgpPlayerItems[i] = NULL; while( m_pActiveItem ) { pPendingItem = m_pActiveItem->m_pNext; m_pActiveItem->Drop(); m_pActiveItem = pPendingItem; } - m_rgpPlayerItems[i] = NULL; } m_pActiveItem = NULL; From 7e5145aaff6dbb0d734acb66a97c9e7247e21402 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 13:03:38 +0500 Subject: [PATCH 091/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/b15a0f9d564d6f8e793617ebc88b41cd6940d90c --- dlls/crowbar.cpp | 12 ++++++++++++ dlls/glock.cpp | 12 ++++++++++++ dlls/weapons.h | 6 ++++-- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 98808e14..f9a91978 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -80,6 +80,18 @@ int CCrowbar::GetItemInfo( ItemInfo *p ) return 1; } +int CCrowbar::AddToPlayer( CBasePlayer *pPlayer ) +{ + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); + MESSAGE_END(); + return TRUE; + } + return FALSE; +} + BOOL CCrowbar::Deploy() { return DefaultDeploy( "models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar" ); diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 3eb08d6c..1150d8b9 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -86,6 +86,18 @@ int CGlock::GetItemInfo( ItemInfo *p ) return 1; } +int CGlock::AddToPlayer( CBasePlayer *pPlayer ) +{ + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); + MESSAGE_END(); + return TRUE; + } + return FALSE; +} + BOOL CGlock::Deploy() { // pev->body = 1; diff --git a/dlls/weapons.h b/dlls/weapons.h index 3d8dd6ad..f48767c8 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -463,7 +463,8 @@ public: void Spawn( void ); void Precache( void ); int iItemSlot( void ) { return 2; } - int GetItemInfo(ItemInfo *p); + int GetItemInfo( ItemInfo *p ); + int AddToPlayer( CBasePlayer *pPlayer ); void PrimaryAttack( void ); void SecondaryAttack( void ); @@ -496,7 +497,8 @@ public: int iItemSlot( void ) { return 1; } void EXPORT SwingAgain( void ); void EXPORT Smack( void ); - int GetItemInfo(ItemInfo *p); + int GetItemInfo( ItemInfo *p ); + int AddToPlayer( CBasePlayer *pPlayer ); void PrimaryAttack( void ); int Swing( int fFirst ); From 0af3a37151614429c13035c5dce0de3cf54f63c4 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 17 Jul 2017 13:45:39 +0500 Subject: [PATCH 092/199] Fix build. Remove unneeded changes. --- dlls/func_tank.cpp | 4 ++-- dlls/player.cpp | 4 ++-- dlls/rpg.cpp | 5 ----- dlls/satchel.cpp | 2 -- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 4ee4e6d6..54f4755a 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -369,8 +369,8 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) void CFuncTank::StopControl() { - if( m_pLaser ) - m_pLaser->TurnOff(); + //if( m_pLaser ) + //m_pLaser->TurnOff(); // TODO: bring back the controllers current weapon if( !m_pController ) diff --git a/dlls/player.cpp b/dlls/player.cpp index e9ad5645..d8ed7010 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -4060,7 +4060,7 @@ void CBasePlayer::UpdateClientData( void ) m_rgpPlayerItems[i]->UpdateClientData( this ); } - if( m_pClientActiveItem != pPlayer->m_pActiveItem ) + /*if( m_pClientActiveItem != pPlayer->m_pActiveItem ) { if( pPlayer->m_pActiveItem == NULL ) { @@ -4104,7 +4104,7 @@ void CBasePlayer::UpdateClientData( void ) MESSAGE_END(); } } - } + }*/ // Cache and client weapon change m_pClientActiveItem = m_pActiveItem; diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index c87d345f..5fb8cc70 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -265,11 +265,6 @@ void CRpgRocket::FollowThink( void ) pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; if( pev->waterlevel == 0 && pev->velocity.Length() < 1500 ) { - if( m_pLauncher ) - { - // my launcher is still around, tell it I'm dead. - m_pLauncher->m_cActiveRockets--; - } Detonate(); } } diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 8ddc41a3..015b3483 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -43,8 +43,6 @@ enum satchel_radio_e class CSatchelCharge : public CGrenade { Vector m_lastBounceOrigin; // Used to fix a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set - void Spawn( void ); - void Precache( void ); void Spawn( void ); void Precache( void ); void BounceSound( void ); From 8bae5a5450e7f0c1040fb7c2329a92723a9fc584 Mon Sep 17 00:00:00 2001 From: mittorn Date: Tue, 18 Jul 2017 12:59:46 +0000 Subject: [PATCH 093/199] Fix infinite loop on mingw --- cl_dll/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 94489844..ecbae657 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -91,7 +91,7 @@ SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w +DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../common \ From 5dab1c1f1db1556a6648f3c66e1066888257ae51 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 18 Jul 2017 22:54:03 +0500 Subject: [PATCH 094/199] Revert "Merge https://github.com/LevShisterov/BugfixedHL/commit/29c4d46ad02492a33ddd9bb4ace0c873855eebe7" This reverts commit 075fd2903075aaa28b0d4930d7d1ba0d1b73f492. --- dlls/items.cpp | 1 - dlls/weapons.cpp | 12 +++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/dlls/items.cpp b/dlls/items.cpp index b0b2aa38..d9cc7871 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -166,7 +166,6 @@ void CItem::Materialize( void ) } SetTouch( &CItem::ItemTouch ); - SetThink( NULL ); } #define SF_SUIT_SHORTLOGON 0x0001 diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 22b4a456..61b038c0 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -485,7 +485,7 @@ void CBasePlayerItem::Materialize( void ) pev->solid = SOLID_TRIGGER; UTIL_SetOrigin( pev, pev->origin );// link into world. - SetTouch( &CBasePlayerItem::DefaultTouch ); + SetTouch( &CBasePlayerItem::DefaultTouch); SetThink( NULL ); } @@ -578,6 +578,13 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? + + // If the item is falling and its Think remains FallItem after the player picks it up, + // then after the item touches the ground its Touch will be set back to DefaultTouch, + // so the player will pick it up again, this time Kill-ing the item (since we already have it in the inventory), + // which will make the pointer bad and crash the game. + if( m_pfnThink == &CBasePlayerItem::FallThink ) + SetThink( NULL ); } BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) @@ -727,7 +734,7 @@ void CBasePlayerItem::AttachToPlayer( CBasePlayer *pPlayer ) pev->modelindex = 0;// server won't send down to clients if modelindex == 0 pev->model = iStringNull; pev->owner = pPlayer->edict(); - pev->nextthink = 0;// Remove think - prevents futher attempts to materialize + pev->nextthink = gpGlobals->time + .1; SetTouch( NULL ); SetThink( NULL ); } @@ -1047,7 +1054,6 @@ void CBasePlayerAmmo::Materialize( void ) } SetTouch( &CBasePlayerAmmo::DefaultTouch ); - SetThink( NULL ); } void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) From 6d2a869ecdd0bc10b17733b78651c5528a099ec7 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 18 Jul 2017 22:56:45 +0500 Subject: [PATCH 095/199] Revert unneeded changes. --- dlls/satchel.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 015b3483..aeb9c5e6 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -117,17 +117,15 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) { // Fix for a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set if( pev->origin != m_lastBounceOrigin ) - BounceSound(); + BounceSound(); } m_lastBounceOrigin = pev->origin; - // There is no model animation so commented this out to prevent net traffic - // StudioFrameAdvance(); + StudioFrameAdvance(); } void CSatchelCharge::SatchelThink( void ) { - // There is no model animation so commented this out to prevent net traffic - // StudioFrameAdvance(); + StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; if( !IsInWorld() ) From c8ebe744c3311f1306f88fd88a467abd57029de5 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 02:00:03 +0500 Subject: [PATCH 096/199] Fix my mistakes. Apply fixes for rpg and tank laser again. --- dlls/func_tank.cpp | 11 +++++++++-- dlls/player.cpp | 46 ---------------------------------------------- dlls/rpg.cpp | 5 +++++ 3 files changed, 14 insertions(+), 48 deletions(-) diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 54f4755a..c4e3cb42 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -93,6 +93,7 @@ public: BOOL StartControl( CBasePlayer* pController ); void StopControl( void ); void ControllerPostFrame( void ); + virtual void StopFire( void ){} protected: CBasePlayer* m_pController; @@ -369,8 +370,7 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) void CFuncTank::StopControl() { - //if( m_pLaser ) - //m_pLaser->TurnOff(); + StopFire(); // TODO: bring back the controllers current weapon if( !m_pController ) @@ -755,6 +755,7 @@ public: virtual int Save( CSave &save ); virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; + virtual void StopFire( void ); private: CLaser *m_pLaser; @@ -859,6 +860,12 @@ void CFuncTankLaser::Fire( const Vector &barrelEnd, const Vector &forward, entva } } +void CFuncTankLaser::StopFire( void ) +{ + if( m_pLaser ) + m_pLaser->TurnOff(); +} + class CFuncTankRocket : public CFuncTank { public: diff --git a/dlls/player.cpp b/dlls/player.cpp index d8ed7010..04da24c4 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -4060,52 +4060,6 @@ void CBasePlayer::UpdateClientData( void ) m_rgpPlayerItems[i]->UpdateClientData( this ); } - /*if( m_pClientActiveItem != pPlayer->m_pActiveItem ) - { - if( pPlayer->m_pActiveItem == NULL ) - { - // If no weapon, we have to send update here - CBasePlayer *plr; - for( int i = 1; i <= gpGlobals->maxClients; i++ ) - { - plr = (CBasePlayer *)UTIL_PlayerByIndex( i ); - if( !plr || !plr->IsObserver() || plr->m_hObserverTarget != pPlayer ) - continue; - - MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, plr->pev ); - WRITE_BYTE( 0 ); - WRITE_BYTE( 0 ); - WRITE_BYTE( 0 ); - MESSAGE_END(); - } - - MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pPlayer->pev ); - WRITE_BYTE( 0 ); - WRITE_BYTE( 0 ); - WRITE_BYTE( 0 ); - MESSAGE_END(); - } - else if( this != pPlayer ) - { - // Special case for spectator - CBasePlayerWeapon *gun = (CBasePlayerWeapon *)pPlayer->m_pActiveItem->GetWeaponPtr(); - if( gun ) - { - int state; - if( pPlayer->m_fOnTarget ) - state = WEAPON_IS_ONTARGET; - else - state = 1; - - MESSAGE_BEGIN( MSG_ONE, gmsgCurWeapon, NULL, pev ); - WRITE_BYTE( state ); - WRITE_BYTE( gun->m_iId ); - WRITE_BYTE( gun->m_iClip ); - MESSAGE_END(); - } - } - }*/ - // Cache and client weapon change m_pClientActiveItem = m_pActiveItem; m_iClientFOV = m_iFOV; diff --git a/dlls/rpg.cpp b/dlls/rpg.cpp index 5fb8cc70..fe1fd8a9 100644 --- a/dlls/rpg.cpp +++ b/dlls/rpg.cpp @@ -265,6 +265,11 @@ void CRpgRocket::FollowThink( void ) pev->velocity = pev->velocity * 0.2 + vecTarget * flSpeed * 0.798; if( pev->waterlevel == 0 && pev->velocity.Length() < 1500 ) { + if( CRpg *pLauncher = (CRpg*)( (CBaseEntity*)( m_hLauncher ) ) ) + { + // my launcher is still around, tell it I'm dead. + pLauncher->m_cActiveRockets--; + } Detonate(); } } From c2a1b013c2d7c9a9c3cb4268de52aa67e3cc2368 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 02:47:31 +0500 Subject: [PATCH 097/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/001e6a09fa9e016995d76aa9092a7656efb63b9e --- dlls/weapons.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 61b038c0..8a7898bf 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -295,6 +295,7 @@ void W_Precache( void ) // common world objects UTIL_PrecacheOther( "item_suit" ); + UTIL_PrecacheOther( "item_healthkit" ); UTIL_PrecacheOther( "item_battery" ); UTIL_PrecacheOther( "item_antidote" ); UTIL_PrecacheOther( "item_security" ); @@ -316,6 +317,9 @@ void W_Precache( void ) UTIL_PrecacheOther( "ammo_9mmAR" ); UTIL_PrecacheOther( "ammo_ARgrenades" ); + // 9mm ammo box + UTIL_PrecacheOther( "ammo_9mmbox" ); + #if !defined( OEM_BUILD ) && !defined( HLDEMO_BUILD ) // python UTIL_PrecacheOtherWeapon( "weapon_357" ); From 9dff875d32bd076a34ce379f3e785fa7636bf228 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 02:51:17 +0500 Subject: [PATCH 098/199] Revert "Revert unneeded changes." This reverts commit 6d2a869ecdd0bc10b17733b78651c5528a099ec7. --- dlls/satchel.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index aeb9c5e6..015b3483 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -117,15 +117,17 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) { // Fix for a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set if( pev->origin != m_lastBounceOrigin ) - BounceSound(); + BounceSound(); } m_lastBounceOrigin = pev->origin; - StudioFrameAdvance(); + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); } void CSatchelCharge::SatchelThink( void ) { - StudioFrameAdvance(); + // There is no model animation so commented this out to prevent net traffic + // StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; if( !IsInWorld() ) From 426a0e7ab31ece52abe20436a64f4a5ce838bfe9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 02:52:11 +0500 Subject: [PATCH 099/199] Revert "Revert "Merge https://github.com/LevShisterov/BugfixedHL/commit/29c4d46ad02492a33ddd9bb4ace0c873855eebe7"" This reverts commit 5dab1c1f1db1556a6648f3c66e1066888257ae51. --- dlls/items.cpp | 1 + dlls/weapons.cpp | 12 +++--------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/dlls/items.cpp b/dlls/items.cpp index d9cc7871..b0b2aa38 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -166,6 +166,7 @@ void CItem::Materialize( void ) } SetTouch( &CItem::ItemTouch ); + SetThink( NULL ); } #define SF_SUIT_SHORTLOGON 0x0001 diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 8a7898bf..05db43da 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -489,7 +489,7 @@ void CBasePlayerItem::Materialize( void ) pev->solid = SOLID_TRIGGER; UTIL_SetOrigin( pev, pev->origin );// link into world. - SetTouch( &CBasePlayerItem::DefaultTouch); + SetTouch( &CBasePlayerItem::DefaultTouch ); SetThink( NULL ); } @@ -582,13 +582,6 @@ void CBasePlayerItem::DefaultTouch( CBaseEntity *pOther ) } SUB_UseTargets( pOther, USE_TOGGLE, 0 ); // UNDONE: when should this happen? - - // If the item is falling and its Think remains FallItem after the player picks it up, - // then after the item touches the ground its Touch will be set back to DefaultTouch, - // so the player will pick it up again, this time Kill-ing the item (since we already have it in the inventory), - // which will make the pointer bad and crash the game. - if( m_pfnThink == &CBasePlayerItem::FallThink ) - SetThink( NULL ); } BOOL CanAttack( float attack_time, float curtime, BOOL isPredicted ) @@ -738,7 +731,7 @@ void CBasePlayerItem::AttachToPlayer( CBasePlayer *pPlayer ) pev->modelindex = 0;// server won't send down to clients if modelindex == 0 pev->model = iStringNull; pev->owner = pPlayer->edict(); - pev->nextthink = gpGlobals->time + .1; + pev->nextthink = 0;// Remove think - prevents futher attempts to materialize SetTouch( NULL ); SetThink( NULL ); } @@ -1058,6 +1051,7 @@ void CBasePlayerAmmo::Materialize( void ) } SetTouch( &CBasePlayerAmmo::DefaultTouch ); + SetThink( NULL ); } void CBasePlayerAmmo::DefaultTouch( CBaseEntity *pOther ) From 51c682c15e7d6e2abdf403ef096b9cecbd545211 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 03:22:08 +0500 Subject: [PATCH 100/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/adb616153729102975800edbbdcc8ed8a50ed8ad --- dlls/game.cpp | 4 +++- dlls/game.h | 1 + dlls/gauss.cpp | 5 +++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/dlls/game.cpp b/dlls/game.cpp index 9b69cac9..b109f376 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -25,11 +25,12 @@ cvar_t timeleft = { "mp_timeleft","0" , FCVAR_SERVER | FCVAR_UNLOGGED }; // " // multiplayer server rules cvar_t teamplay = { "mp_teamplay","0", FCVAR_SERVER }; -cvar_t fraglimit = {"mp_fraglimit","0", FCVAR_SERVER }; +cvar_t fraglimit = { "mp_fraglimit","0", FCVAR_SERVER }; cvar_t timelimit = { "mp_timelimit","0", FCVAR_SERVER }; cvar_t friendlyfire = { "mp_friendlyfire","0", FCVAR_SERVER }; cvar_t falldamage = { "mp_falldamage","0", FCVAR_SERVER }; cvar_t weaponstay = { "mp_weaponstay","0", FCVAR_SERVER }; +cvar_t selfgauss = { "mp_selfgauss", "1", FCVAR_SERVER }; cvar_t forcerespawn = { "mp_forcerespawn","1", FCVAR_SERVER }; cvar_t flashlight = { "mp_flashlight","0", FCVAR_SERVER }; cvar_t aimcrosshair = { "mp_autocrosshair","1", FCVAR_SERVER }; @@ -467,6 +468,7 @@ void GameDLLInit( void ) CVAR_REGISTER( &friendlyfire ); CVAR_REGISTER( &falldamage ); CVAR_REGISTER( &weaponstay ); + CVAR_REGISTER( &selfgauss ); CVAR_REGISTER( &forcerespawn ); CVAR_REGISTER( &flashlight ); CVAR_REGISTER( &aimcrosshair ); diff --git a/dlls/game.h b/dlls/game.h index 925010f3..e29b2563 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -27,6 +27,7 @@ extern cvar_t timelimit; extern cvar_t friendlyfire; extern cvar_t falldamage; extern cvar_t weaponstay; +extern cvar_t selfgauss; extern cvar_t forcerespawn; extern cvar_t flashlight; extern cvar_t aimcrosshair; diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index d3e005c2..62af08e1 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -24,6 +24,7 @@ #include "soundent.h" #include "shake.h" #include "gamerules.h" +#include "game.h" #define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging #define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged @@ -512,6 +513,10 @@ void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) vecSrc = beam_tr.vecEndPos + vecDir; } + else if( !selfgauss.value ) + { + flDamage = 0; + } } else { From 946e962f3c8e1429ab39a0e5e851ff5d1e13a211 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 04:06:19 +0500 Subject: [PATCH 101/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/1c71f33cb0978cfdcfc5167d9c8860654778f762 --- cl_dll/flashlight.cpp | 2 ++ dlls/player.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index 8b8a8d0e..c3514c7d 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -49,6 +49,8 @@ void CHudFlashlight::Reset( void ) { m_fFade = 0; m_fOn = 0; + m_iBat = 100; + m_flBat = 1.0; } int CHudFlashlight::VidInit( void ) diff --git a/dlls/player.cpp b/dlls/player.cpp index 04da24c4..0d86caf8 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3868,6 +3868,12 @@ void CBasePlayer::UpdateClientData( void ) FireTargets( "game_playerspawn", this, this, USE_TOGGLE, 0 ); + // Send flashlight status + MESSAGE_BEGIN( MSG_ONE, gmsgFlashlight, NULL, pev ); + WRITE_BYTE( FlashlightIsOn() ? 1 : 0 ); + WRITE_BYTE( m_iFlashBattery ); + MESSAGE_END(); + InitStatusBar(); } From a2e4a7ec03d987c0645742fde30a591452689245 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 04:11:08 +0500 Subject: [PATCH 102/199] Fix crosshair. --- cl_dll/ammo.cpp | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index f439520e..edc21652 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -305,6 +305,9 @@ void CHudAmmo::Reset( void ) gHR.Reset(); //VidInit(); + wrect_t nullrc = {}; + SetCrosshair( 0, nullrc, 0, 0, 0 ); // reset crosshair + m_pWeapon = NULL; // reset last weapon } int CHudAmmo::VidInit( void ) @@ -606,22 +609,24 @@ int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) m_pWeapon = pWeapon; - if( gHUD.m_iFOV >= 90 ) + if( !( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) ) { - // normal crosshairs - if( fOnTarget && m_pWeapon->hAutoaim ) - SetCrosshair( m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255 ); + if( gHUD.m_iFOV >= 90 ) + { + // normal crosshairs + if( fOnTarget && m_pWeapon->hAutoaim ) + SetCrosshair( m_pWeapon->hAutoaim, m_pWeapon->rcAutoaim, 255, 255, 255 ); + else + SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); + } else - SetCrosshair( m_pWeapon->hCrosshair, m_pWeapon->rcCrosshair, 255, 255, 255 ); - } - else - { - // zoomed crosshairs - if( fOnTarget && m_pWeapon->hZoomedAutoaim ) - SetCrosshair( m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255 ); - else - SetCrosshair( m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255 ); - + { + // zoomed crosshairs + if( fOnTarget && m_pWeapon->hZoomedAutoaim ) + SetCrosshair( m_pWeapon->hZoomedAutoaim, m_pWeapon->rcZoomedAutoaim, 255, 255, 255 ); + else + SetCrosshair( m_pWeapon->hZoomedCrosshair, m_pWeapon->rcZoomedCrosshair, 255, 255, 255 ); + } } m_fFade = 200.0f; //!!! From d062757f5273e0ecdbf05f6a1ea599690ba8816a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 19 Jul 2017 23:25:47 +0500 Subject: [PATCH 103/199] Use MAKE_STRING for literals. Remove duplicated code. --- dlls/bmodels.cpp | 40 ++++------ dlls/buttons.cpp | 10 +-- dlls/doors.cpp | 192 +++++++++++++++++++++------------------------- dlls/maprules.cpp | 160 +++++++++++++++++++------------------- dlls/plats.cpp | 119 ++++++++++++++-------------- dlls/triggers.cpp | 2 +- 6 files changed, 244 insertions(+), 279 deletions(-) diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index 6e8526f9..c48abbf9 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -430,15 +430,13 @@ void CFuncRotating::Spawn() void CFuncRotating::Precache( void ) { - char* szSoundFile = (char*)STRING( pev->message ); + const char* szSoundFile = STRING( pev->message ); + BOOL NullSound = FALSE; // set up fan sounds if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) { // if a path is set for a wave, use it - PRECACHE_SOUND( szSoundFile ); - - pev->noiseRunning = ALLOC_STRING( szSoundFile ); } else { @@ -446,42 +444,32 @@ void CFuncRotating::Precache( void ) switch( m_sounds ) { case 1: - PRECACHE_SOUND( "fans/fan1.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan1.wav" ); + szSoundFile = "fans/fan1.wav"; break; case 2: - PRECACHE_SOUND( "fans/fan2.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan2.wav" ); + szSoundFile = "fans/fan2.wav"; break; case 3: - PRECACHE_SOUND( "fans/fan3.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan3.wav" ); + szSoundFile = "fans/fan3.wav"; break; case 4: - PRECACHE_SOUND( "fans/fan4.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan4.wav" ); + szSoundFile = "fans/fan4.wav"; break; case 5: - PRECACHE_SOUND( "fans/fan5.wav" ); - pev->noiseRunning = ALLOC_STRING( "fans/fan5.wav" ); + szSoundFile = "fans/fan5.wav"; break; case 0: default: - if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 0 ) - { - PRECACHE_SOUND( szSoundFile ); - - pev->noiseRunning = ALLOC_STRING( szSoundFile ); - break; - } - else - { - pev->noiseRunning = ALLOC_STRING( "common/null.wav" ); - break; - } + szSoundFile = "common/null.wav"; + NullSound = TRUE; + break; } } + if( !NullSound ) + PRECACHE_SOUND( szSoundFile ); + pev->noiseRunning = MAKE_STRING( szSoundFile ); + if( pev->avelocity != g_vecZero ) { // if fan was spinning, and we went through transition or save/restore, diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index df7c51f3..7ea9082a 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -292,14 +292,14 @@ void CBaseButton::Precache( void ) { pszSound = ButtonSound( (int)m_bLockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sLockedSound = ALLOC_STRING( pszSound ); + m_ls.sLockedSound = MAKE_STRING( pszSound ); } if( m_bUnlockedSound ) { pszSound = ButtonSound( (int)m_bUnlockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sUnlockedSound = ALLOC_STRING( pszSound ); + m_ls.sUnlockedSound = MAKE_STRING( pszSound ); } // get sentence group names, for doors which are directly 'touched' to open @@ -469,7 +469,7 @@ void CBaseButton::Spawn() //---------------------------------------------------- pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); - pev->noise = ALLOC_STRING( pszSound ); + pev->noise = MAKE_STRING( pszSound ); Precache(); @@ -876,7 +876,7 @@ void CRotButton::Spawn( void ) //---------------------------------------------------- pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); - pev->noise = ALLOC_STRING( pszSound ); + pev->noise = MAKE_STRING( pszSound ); // set the axis of rotation CBaseToggle::AxisDir( pev ); @@ -1012,7 +1012,7 @@ void CMomentaryRotButton::Spawn( void ) const char *pszSound = ButtonSound( m_sounds ); PRECACHE_SOUND( pszSound ); - pev->noise = ALLOC_STRING( pszSound ); + pev->noise = MAKE_STRING( pszSound ); m_lastUsed = 0; } diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 3a8613ab..ce901ee8 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -330,114 +330,104 @@ void CBaseDoor::SetToggleState( int state ) void CBaseDoor::Precache( void ) { const char *pszSound; + BOOL NullSound = FALSE; // set the door's "in-motion" sound switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doormove1.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" ); + pszSound = "doors/doormove1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doormove2.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" ); + pszSound = "doors/doormove2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doormove3.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" ); + pszSound = "doors/doormove3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doormove4.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" ); + pszSound = "doors/doormove4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doormove5.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" ); + pszSound = "doors/doormove5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doormove6.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" ); + pszSound = "doors/doormove6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doormove7.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" ); + pszSound = "doors/doormove7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doormove8.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" ); + pszSound = "doors/doormove8.wav"; break; case 9: - PRECACHE_SOUND( "doors/doormove9.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove9.wav" ); + pszSound = "doors/doormove9.wav"; break; case 10: - PRECACHE_SOUND( "doors/doormove10.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove10.wav" ); + pszSound = "doors/doormove10.wav"; break; + case 0: default: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseMoving = MAKE_STRING( pszSound ); + NullSound = FALSE; + // set the door's 'reached destination' stop sound switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doorstop1.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" ); + pszSound = "doors/doorstop1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doorstop2.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" ); + pszSound = "doors/doorstop2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doorstop3.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop3.wav" ); + pszSound = "doors/doorstop3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doorstop4.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" ); + pszSound = "doors/doorstop4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doorstop5.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" ); + pszSound = "doors/doorstop5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doorstop6.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav"); + pszSound = "doors/doorstop6.wav" break; case 7: - PRECACHE_SOUND( "doors/doorstop7.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" ); + pszSound = "doors/doorstop7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doorstop8.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" ); + pszSound = "doors/doorstop8.wav"; break; + case 0: default: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseArrived = MAKE_STRING( pszSound ); + // get door button sounds, for doors which are directly 'touched' to open if( m_bLockedSound ) { pszSound = ButtonSound( (int)m_bLockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sLockedSound = ALLOC_STRING( pszSound ); + m_ls.sLockedSound = MAKE_STRING( pszSound ); } if( m_bUnlockedSound ) { pszSound = ButtonSound( (int)m_bUnlockedSound ); PRECACHE_SOUND( pszSound ); - m_ls.sUnlockedSound = ALLOC_STRING( pszSound ); + m_ls.sUnlockedSound = MAKE_STRING( pszSound ); } // get sentence group names, for doors which are directly 'touched' to open @@ -445,39 +435,39 @@ void CBaseDoor::Precache( void ) { case 1: // access denied - m_ls.sLockedSentence = ALLOC_STRING( "NA" ); + m_ls.sLockedSentence = MAKE_STRING( "NA" ); break; case 2: // security lockout - m_ls.sLockedSentence = ALLOC_STRING( "ND" ); + m_ls.sLockedSentence = MAKE_STRING( "ND" ); break; case 3: // blast door - m_ls.sLockedSentence = ALLOC_STRING( "NF" ); + m_ls.sLockedSentence = MAKE_STRING( "NF" ); break; case 4: // fire door - m_ls.sLockedSentence = ALLOC_STRING( "NFIRE" ); + m_ls.sLockedSentence = MAKE_STRING( "NFIRE" ); break; case 5: // chemical door - m_ls.sLockedSentence = ALLOC_STRING( "NCHEM" ); + m_ls.sLockedSentence = MAKE_STRING( "NCHEM" ); break; case 6: // radiation door - m_ls.sLockedSentence = ALLOC_STRING( "NRAD" ); + m_ls.sLockedSentence = MAKE_STRING( "NRAD" ); break; case 7: // gen containment - m_ls.sLockedSentence = ALLOC_STRING( "NCON" ); + m_ls.sLockedSentence = MAKE_STRING( "NCON" ); break; case 8: // maintenance door - m_ls.sLockedSentence = ALLOC_STRING( "NH" ); + m_ls.sLockedSentence = MAKE_STRING( "NH" ); break; case 9: // broken door - m_ls.sLockedSentence = ALLOC_STRING( "NG" ); + m_ls.sLockedSentence = MAKE_STRING( "NG" ); break; default: m_ls.sLockedSentence = 0; @@ -488,35 +478,35 @@ void CBaseDoor::Precache( void ) { case 1: // access granted - m_ls.sUnlockedSentence = ALLOC_STRING( "EA" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EA" ); break; case 2: // security door - m_ls.sUnlockedSentence = ALLOC_STRING( "ED" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ED" ); break; case 3: // blast door - m_ls.sUnlockedSentence = ALLOC_STRING( "EF" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EF" ); break; case 4: // fire door - m_ls.sUnlockedSentence = ALLOC_STRING( "EFIRE" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EFIRE" ); break; case 5: // chemical door - m_ls.sUnlockedSentence = ALLOC_STRING( "ECHEM" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ECHEM" ); break; case 6: // radiation door - m_ls.sUnlockedSentence = ALLOC_STRING( "ERAD" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ERAD" ); break; case 7: // gen containment - m_ls.sUnlockedSentence = ALLOC_STRING( "ECON" ); + m_ls.sUnlockedSentence = MAKE_STRING( "ECON" ); break; case 8: // maintenance door - m_ls.sUnlockedSentence = ALLOC_STRING( "EH" ); + m_ls.sUnlockedSentence = MAKE_STRING( "EH" ); break; default: m_ls.sUnlockedSentence = 0; @@ -985,94 +975,88 @@ void CMomentaryDoor::Spawn( void ) Precache(); } - + void CMomentaryDoor::Precache( void ) { + const char *pszSound; + BOOL NullSound = FALSE; + // set the door's "in-motion" sound switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doormove1.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove1.wav" ); + pszSound = "doors/doormove1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doormove2.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove2.wav" ); + pszSound = "doors/doormove2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doormove3.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove3.wav" ); + pszSound = "doors/doormove3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doormove4.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove4.wav" ); + pszSound = "doors/doormove4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doormove5.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove5.wav" ); + pszSound = "doors/doormove5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doormove6.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove6.wav" ); + pszSound = "doors/doormove6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doormove7.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove7.wav" ); + pszSound = "doors/doormove7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doormove8.wav" ); - pev->noiseMoving = ALLOC_STRING( "doors/doormove8.wav" ); + pszSound = "doors/doormove8.wav"; break; + case 0: default: - pev->noiseMoving = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseMoving = MAKE_STRING( pszSound ); + NullSound = FALSE; + // set the door's 'reached destination' stop sound switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "doors/doorstop1.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop1.wav" ); + pszSound = "doors/doorstop1.wav"; break; case 2: - PRECACHE_SOUND( "doors/doorstop2.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop2.wav" ); + pszSound = "doors/doorstop2.wav"; break; case 3: - PRECACHE_SOUND( "doors/doorstop3.wav" ); - pev->noiseArrived = ALLOC_STRING("doors/doorstop3.wav"); + pszSound = "doors/doorstop3.wav"; break; case 4: - PRECACHE_SOUND( "doors/doorstop4.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop4.wav" ); + pszSound = "doors/doorstop4.wav"; break; case 5: - PRECACHE_SOUND( "doors/doorstop5.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop5.wav" ); + pszSound = "doors/doorstop5.wav"; break; case 6: - PRECACHE_SOUND( "doors/doorstop6.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop6.wav" ); + pszSound = "doors/doorstop6.wav"; break; case 7: - PRECACHE_SOUND( "doors/doorstop7.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop7.wav" ); + pszSound = "doors/doorstop7.wav"; break; case 8: - PRECACHE_SOUND( "doors/doorstop8.wav" ); - pev->noiseArrived = ALLOC_STRING( "doors/doorstop8.wav" ); + pszSound = "doors/doorstop8.wav"; break; + case 0: default: - pev->noiseArrived = ALLOC_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseArrived = MAKE_STRING( pszSound ); } void CMomentaryDoor::KeyValue( KeyValueData *pkvd ) diff --git a/dlls/maprules.cpp b/dlls/maprules.cpp index 2230acac..bfec93e2 100644 --- a/dlls/maprules.cpp +++ b/dlls/maprules.cpp @@ -153,9 +153,9 @@ void CGameScore::Spawn( void ) void CGameScore::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "points")) + if( FStrEq( pkvd->szKeyName, "points" ) ) { - SetPoints( atoi(pkvd->szValue) ); + SetPoints( atoi( pkvd->szValue ) ); pkvd->fHandled = TRUE; } else @@ -164,13 +164,13 @@ void CGameScore::KeyValue( KeyValueData *pkvd ) void CGameScore::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; // Only players can use this - if ( pActivator->IsPlayer() ) + if( pActivator->IsPlayer() ) { - if ( AwardToTeam() ) + if( AwardToTeam() ) { pActivator->AddPointsToTeam( Points(), AllowNegativeScore() ); } @@ -194,7 +194,7 @@ LINK_ENTITY_TO_CLASS( game_end, CGameEnd ) void CGameEnd::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; g_pGameRules->EndMultiplayerGame(); @@ -239,27 +239,27 @@ IMPLEMENT_SAVERESTORE( CGameText, CRulePointEntity ) void CGameText::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "channel")) + if( FStrEq( pkvd->szKeyName, "channel" ) ) { m_textParms.channel = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "x")) + else if( FStrEq( pkvd->szKeyName, "x" ) ) { m_textParms.x = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "y")) + else if( FStrEq(pkvd->szKeyName, "y" ) ) { m_textParms.y = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "effect")) + else if( FStrEq( pkvd->szKeyName, "effect" ) ) { m_textParms.effect = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "color")) + else if( FStrEq( pkvd->szKeyName, "color" ) ) { int color[4]; UTIL_StringToIntArray( color, 4, pkvd->szValue ); @@ -269,7 +269,7 @@ void CGameText::KeyValue( KeyValueData *pkvd ) m_textParms.a1 = color[3]; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "color2")) + else if( FStrEq( pkvd->szKeyName, "color2" ) ) { int color[4]; UTIL_StringToIntArray( color, 4, pkvd->szValue ); @@ -279,22 +279,22 @@ void CGameText::KeyValue( KeyValueData *pkvd ) m_textParms.a2 = color[3]; pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "fadein")) + else if( FStrEq( pkvd->szKeyName, "fadein" ) ) { m_textParms.fadeinTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "fadeout")) + else if( FStrEq( pkvd->szKeyName, "fadeout" ) ) { m_textParms.fadeoutTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "holdtime")) + else if( FStrEq( pkvd->szKeyName, "holdtime" ) ) { m_textParms.holdTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "fxtime")) + else if( FStrEq(pkvd->szKeyName, "fxtime" ) ) { m_textParms.fxTime = atof( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -305,16 +305,16 @@ void CGameText::KeyValue( KeyValueData *pkvd ) void CGameText::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( MessageToAll() ) + if( MessageToAll() ) { UTIL_HudMessageAll( m_textParms, MessageGet() ); } else { - if ( pActivator->IsNetClient() ) + if( pActivator->IsNetClient() ) { UTIL_HudMessage( pActivator, m_textParms, MessageGet() ); } @@ -356,12 +356,12 @@ LINK_ENTITY_TO_CLASS( game_team_master, CGameTeamMaster ) void CGameTeamMaster::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "teamindex")) + if( FStrEq( pkvd->szKeyName, "teamindex" ) ) { m_teamIndex = atoi( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "triggerstate")) + else if( FStrEq( pkvd->szKeyName, "triggerstate" ) ) { int type = atoi( pkvd->szValue ); switch( type ) @@ -384,12 +384,12 @@ void CGameTeamMaster::KeyValue( KeyValueData *pkvd ) void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( useType == USE_SET ) + if( useType == USE_SET ) { - if ( value < 0 ) + if( value < 0 ) { m_teamIndex = -1; } @@ -400,10 +400,10 @@ void CGameTeamMaster::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY return; } - if ( TeamMatch( pActivator ) ) + if( TeamMatch( pActivator ) ) { SUB_UseTargets( pActivator, triggerType, value ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) UTIL_Remove( this ); } } @@ -415,7 +415,7 @@ BOOL CGameTeamMaster::IsTriggered( CBaseEntity *pActivator ) const char *CGameTeamMaster::TeamID( void ) { - if ( m_teamIndex < 0 ) // Currently set to "no team" + if( m_teamIndex < 0 ) // Currently set to "no team" return ""; return g_pGameRules->GetIndexedTeamName( m_teamIndex ); // UNDONE: Fill this in with the team from the "teamlist" @@ -423,10 +423,10 @@ const char *CGameTeamMaster::TeamID( void ) BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) { - if ( m_teamIndex < 0 && AnyTeam() ) + if( m_teamIndex < 0 && AnyTeam() ) return TRUE; - if ( !pActivator ) + if( !pActivator ) return FALSE; return UTIL_TeamsMatch( pActivator->TeamID(), TeamID() ); @@ -443,7 +443,7 @@ BOOL CGameTeamMaster::TeamMatch( CBaseEntity *pActivator ) class CGameTeamSet : public CRulePointEntity { public: - void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); + void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); inline BOOL RemoveOnFire( void ) { return (pev->spawnflags & SF_TEAMSET_FIREONCE) ? TRUE : FALSE; } inline BOOL ShouldClearTeam( void ) { return (pev->spawnflags & SF_TEAMSET_CLEARTEAM) ? TRUE : FALSE; } @@ -454,10 +454,10 @@ LINK_ENTITY_TO_CLASS( game_team_set, CGameTeamSet ) void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( ShouldClearTeam() ) + if( ShouldClearTeam() ) { SUB_UseTargets( pActivator, USE_SET, -1 ); } @@ -466,7 +466,7 @@ void CGameTeamSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE SUB_UseTargets( pActivator, USE_SET, 0 ); } - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } @@ -506,22 +506,22 @@ IMPLEMENT_SAVERESTORE( CGamePlayerZone, CRuleBrushEntity ) void CGamePlayerZone::KeyValue( KeyValueData *pkvd ) { - if (FStrEq(pkvd->szKeyName, "intarget")) + if( FStrEq(pkvd->szKeyName, "intarget" ) ) { m_iszInTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "outtarget")) + else if( FStrEq( pkvd->szKeyName, "outtarget" ) ) { m_iszOutTarget = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "incount")) + else if( FStrEq( pkvd->szKeyName, "incount" ) ) { m_iszInCount = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } - else if (FStrEq(pkvd->szKeyName, "outcount")) + else if( FStrEq( pkvd->szKeyName, "outcount" ) ) { m_iszOutCount = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; @@ -535,12 +535,12 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY int playersInCount = 0; int playersOutCount = 0; - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; CBaseEntity *pPlayer = NULL; - for ( int i = 1; i <= gpGlobals->maxClients; i++ ) + for( int i = 1; i <= gpGlobals->maxClients; i++ ) { pPlayer = UTIL_PlayerByIndex( i ); if ( pPlayer ) @@ -549,40 +549,40 @@ void CGamePlayerZone::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY int hullNumber; hullNumber = human_hull; - if ( pPlayer->pev->flags & FL_DUCKING ) + if( pPlayer->pev->flags & FL_DUCKING ) { hullNumber = head_hull; } UTIL_TraceModel( pPlayer->pev->origin, pPlayer->pev->origin, hullNumber, edict(), &trace ); - if ( trace.fStartSolid ) + if( trace.fStartSolid ) { playersInCount++; - if ( m_iszInTarget ) + if( m_iszInTarget ) { - FireTargets( STRING(m_iszInTarget), pPlayer, pActivator, useType, value ); + FireTargets( STRING( m_iszInTarget ), pPlayer, pActivator, useType, value ); } } else { playersOutCount++; - if ( m_iszOutTarget ) + if( m_iszOutTarget ) { - FireTargets( STRING(m_iszOutTarget), pPlayer, pActivator, useType, value ); + FireTargets( STRING( m_iszOutTarget ), pPlayer, pActivator, useType, value ); } } } } - if ( m_iszInCount ) + if( m_iszInCount ) { - FireTargets( STRING(m_iszInCount), pActivator, this, USE_SET, playersInCount ); + FireTargets( STRING( m_iszInCount ), pActivator, this, USE_SET, playersInCount ); } - if ( m_iszOutCount ) + if( m_iszOutCount ) { - FireTargets( STRING(m_iszOutCount), pActivator, this, USE_SET, playersOutCount ); + FireTargets( STRING( m_iszOutCount ), pActivator, this, USE_SET, playersOutCount ); } } @@ -605,12 +605,12 @@ LINK_ENTITY_TO_CLASS( game_player_hurt, CGamePlayerHurt ) void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( pActivator->IsPlayer() ) + if( pActivator->IsPlayer() ) { - if ( pev->dmg < 0 ) + if( pev->dmg < 0 ) pActivator->TakeHealth( -pev->dmg, DMG_GENERIC ); else pActivator->TakeDamage( pev, pev, pev->dmg, DMG_GENERIC ); @@ -618,7 +618,7 @@ void CGamePlayerHurt::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY SUB_UseTargets( pActivator, useType, value ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } @@ -665,7 +665,7 @@ void CGameCounter::Spawn( void ) void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; switch( useType ) @@ -681,16 +681,16 @@ void CGameCounter::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE SetCountValue( (int)value ); break; } - - if ( HitLimit() ) + + if( HitLimit() ) { SUB_UseTargets( pActivator, USE_TOGGLE, 0 ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } - - if ( ResetOnFire() ) + + if( ResetOnFire() ) { ResetCount(); } @@ -716,12 +716,12 @@ LINK_ENTITY_TO_CLASS( game_counter_set, CGameCounterSet ) void CGameCounterSet::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; SUB_UseTargets( pActivator, USE_SET, pev->frags ); - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } @@ -756,19 +756,19 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) { CRulePointEntity::KeyValue( pkvd ); - if ( !pkvd->fHandled ) + if( !pkvd->fHandled ) { - for ( int i = 0; i < MAX_EQUIP; i++ ) + for( int i = 0; i < MAX_EQUIP; i++ ) { - if ( !m_weaponNames[i] ) + if( !m_weaponNames[i] ) { char tmp[128]; UTIL_StripToken( pkvd->szKeyName, tmp ); - m_weaponNames[i] = ALLOC_STRING(tmp); - m_weaponCount[i] = atoi(pkvd->szValue); - m_weaponCount[i] = max(1,m_weaponCount[i]); + m_weaponNames[i] = ALLOC_STRING( tmp ); + m_weaponCount[i] = atoi( pkvd->szValue ); + m_weaponCount[i] = max( 1, m_weaponCount[i] ); pkvd->fHandled = TRUE; break; } @@ -778,10 +778,10 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) void CGamePlayerEquip::Touch( CBaseEntity *pOther ) { - if ( !CanFireForActivator( pOther ) ) + if( !CanFireForActivator( pOther ) ) return; - if ( UseOnly() ) + if( UseOnly() ) return; EquipPlayer( pOther ); @@ -791,21 +791,21 @@ void CGamePlayerEquip::EquipPlayer( CBaseEntity *pEntity ) { CBasePlayer *pPlayer = NULL; - if ( pEntity->IsPlayer() ) + if( pEntity->IsPlayer() ) { pPlayer = (CBasePlayer *)pEntity; } - if ( !pPlayer ) + if( !pPlayer ) return; - for ( int i = 0; i < MAX_EQUIP; i++ ) + for( int i = 0; i < MAX_EQUIP; i++ ) { - if ( !m_weaponNames[i] ) + if( !m_weaponNames[i] ) break; - for ( int j = 0; j < m_weaponCount[i]; j++ ) + for( int j = 0; j < m_weaponCount[i]; j++ ) { - pPlayer->GiveNamedItem( STRING(m_weaponNames[i]) ); + pPlayer->GiveNamedItem( STRING( m_weaponNames[i] ) ); } } } @@ -844,9 +844,9 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) { CBaseEntity *pTeamEntity = NULL; - while ((pTeamEntity = UTIL_FindEntityByTargetname( pTeamEntity, pszTargetName )) != NULL) + while( ( pTeamEntity = UTIL_FindEntityByTargetname( pTeamEntity, pszTargetName ) ) != NULL ) { - if ( FClassnameIs( pTeamEntity->pev, "game_team_master" ) ) + if( FClassnameIs( pTeamEntity->pev, "game_team_master" ) ) return pTeamEntity->TeamID(); } @@ -855,10 +855,10 @@ const char *CGamePlayerTeam::TargetTeamName( const char *pszTargetName ) void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - if ( !CanFireForActivator( pActivator ) ) + if( !CanFireForActivator( pActivator ) ) return; - if ( pActivator->IsPlayer() ) + if( pActivator->IsPlayer() ) { const char *pszTargetTeam = TargetTeamName( STRING(pev->target) ); if ( pszTargetTeam ) @@ -868,7 +868,7 @@ void CGamePlayerTeam::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TY } } - if ( RemoveOnFire() ) + if( RemoveOnFire() ) { UTIL_Remove( this ); } diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 00b05bec..3034fd93 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -104,111 +104,100 @@ void CBasePlatTrain::KeyValue( KeyValueData *pkvd ) void CBasePlatTrain::Precache( void ) { + const char *pszSound; + BOOL NullSound = FALSE; + // set the plat's "in-motion" sound switch( m_bMoveSnd ) { - case 0: - pev->noiseMoving = MAKE_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "plats/bigmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/bigmove1.wav" ); + pszSound = "plats/bigmove1.wav"; break; case 2: - PRECACHE_SOUND( "plats/bigmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/bigmove2.wav" ); + pszSound = "plats/bigmove2.wav"; break; case 3: - PRECACHE_SOUND( "plats/elevmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/elevmove1.wav" ); + pszSound = "plats/elevmove1.wav"; break; case 4: - PRECACHE_SOUND( "plats/elevmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/elevmove2.wav" ); + pszSound = "plats/elevmove2.wav"; break; case 5: - PRECACHE_SOUND( "plats/elevmove3.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/elevmove3.wav" ); + pszSound = "plats/elevmove3.wav"; break; case 6: - PRECACHE_SOUND( "plats/freightmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/freightmove1.wav" ); + pszSound = "plats/freightmove1.wav"; break; case 7: - PRECACHE_SOUND( "plats/freightmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/freightmove2.wav" ); + pszSound = "plats/freightmove2.wav"; break; case 8: - PRECACHE_SOUND( "plats/heavymove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/heavymove1.wav" ); + pszSound = "plats/heavymove1.wav"; break; case 9: - PRECACHE_SOUND( "plats/rackmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/rackmove1.wav" ); + pszSound = "plats/rackmove1.wav"; break; case 10: - PRECACHE_SOUND( "plats/railmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/railmove1.wav" ); + pszSound = "plats/railmove1.wav"; break; case 11: - PRECACHE_SOUND( "plats/squeekmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/squeekmove1.wav" ); + pszSound = "plats/squeekmove1.wav"; break; case 12: - PRECACHE_SOUND( "plats/talkmove1.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/talkmove1.wav" ); + pszSound = "plats/talkmove1.wav"; break; case 13: - PRECACHE_SOUND( "plats/talkmove2.wav" ); - pev->noiseMoving = MAKE_STRING( "plats/talkmove2.wav" ); + pszSound = "plats/talkmove2.wav"; break; + case 0: default: - pev->noiseMoving = MAKE_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseMoving = MAKE_STRING( pszSound ); + NullSound = FALSE; + // set the plat's 'reached destination' stop sound switch( m_bStopSnd ) { - case 0: - pev->noiseArrived = MAKE_STRING( "common/null.wav" ); - break; case 1: - PRECACHE_SOUND( "plats/bigstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/bigstop1.wav" ); + pszSound = "plats/bigstop1.wav"; break; case 2: - PRECACHE_SOUND( "plats/bigstop2.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/bigstop2.wav" ); + pszSound = "plats/bigstop2.wav"; break; case 3: - PRECACHE_SOUND( "plats/freightstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/freightstop1.wav" ); + pszSound = "plats/freightstop1.wav"; break; case 4: - PRECACHE_SOUND( "plats/heavystop2.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/heavystop2.wav" ); + pszSound = "plats/heavystop2.wav"; break; case 5: - PRECACHE_SOUND( "plats/rackstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/rackstop1.wav" ); + pszSound = "plats/rackstop1.wav"; break; case 6: - PRECACHE_SOUND( "plats/railstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/railstop1.wav" ); + pszSound = "plats/railstop1.wav"; break; case 7: - PRECACHE_SOUND( "plats/squeekstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/squeekstop1.wav" ); + pszSound = "plats/squeekstop1.wav"; break; case 8: - PRECACHE_SOUND( "plats/talkstop1.wav" ); - pev->noiseArrived = MAKE_STRING( "plats/talkstop1.wav" ); + pszSound = "plats/talkstop1.wav"; break; + case 0: default: - pev->noiseArrived = MAKE_STRING( "common/null.wav" ); + pszSound = "common/null.wav"; + NullSound = TRUE; break; } + + if( !NullSound ) + PRECACHE_SOUND( pszSound ); + pev->noiseArrived = MAKE_STRING( pszSound ); } // @@ -1482,6 +1471,8 @@ void CFuncTrackTrain::Spawn( void ) void CFuncTrackTrain::Precache( void ) { + const char *pszSound; + if( m_flVolume == 0.0 ) m_flVolume = 1.0; @@ -1489,34 +1480,36 @@ void CFuncTrackTrain::Precache( void ) { default: // no sound - pev->noise = 0; + pszSound = NULL; break; case 1: - PRECACHE_SOUND( "plats/ttrain1.wav" ); - pev->noise = MAKE_STRING("plats/ttrain1.wav" ); + pszSound = "plats/ttrain1.wav"; break; case 2: - PRECACHE_SOUND( "plats/ttrain2.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain2.wav" ); + pszSound = "plats/ttrain2.wav"; break; case 3: - PRECACHE_SOUND( "plats/ttrain3.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain3.wav" ); + pszSound = "plats/ttrain3.wav"; break; case 4: - PRECACHE_SOUND( "plats/ttrain4.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain4.wav" ); + pszSound = "plats/ttrain4.wav"; break; case 5: - PRECACHE_SOUND( "plats/ttrain6.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain6.wav" ); + pszSound = "plats/ttrain6.wav"; break; case 6: - PRECACHE_SOUND( "plats/ttrain7.wav" ); - pev->noise = MAKE_STRING( "plats/ttrain7.wav" ); + pszSound = "plats/ttrain7.wav"; break; } + if( !pszSound ) + { + PRECACHE_SOUND( pszSound ); + pev->noise = MAKE_STRING( pszSound ); + } + else + pev->noise = 0; + PRECACHE_SOUND( "plats/ttrain_brake1.wav" ); PRECACHE_SOUND( "plats/ttrain_start1.wav" ); diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 2959d96d..57d8d031 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -1689,7 +1689,7 @@ void NextLevel( void ) // go back to start if no trigger_changelevel if( FNullEnt( pent ) ) { - gpGlobals->mapname = ALLOC_STRING( "start" ); + gpGlobals->mapname = MAKE_STRING( "start" ); pChange = GetClassPtr( (CChangeLevel *)NULL ); strcpy( pChange->m_szMapName, "start" ); } From 14e75025bb64f730fa42081fa594c397ca064b2d Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 10:33:39 +0500 Subject: [PATCH 104/199] Show long nicknames in scoreboard. Show fulli nicknames in scoreboard. --- cl_dll/scoreboard.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index b20e316c..3adbaab6 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -92,7 +92,7 @@ We have a minimum width of 1-320 - we could have the field widths scale with it? // X positions // relative to the side of the scoreboard -#define NAME_RANGE_MIN 20 +#define NAME_RANGE_MIN -100 #define NAME_RANGE_MAX 145 #define KILLS_RANGE_MIN 130 #define KILLS_RANGE_MAX 170 @@ -145,7 +145,7 @@ int CHudScoreboard::Draw( float fTime ) int xpos = NAME_RANGE_MIN + xpos_rel; FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; - FAR_RIGHT += 5; + FAR_RIGHT += 125; if( cl_scoreboard_bg && cl_scoreboard_bg->value ) gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); if( !gHUD.m_Teamplay ) @@ -340,7 +340,7 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, } FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; - FAR_RIGHT += 5; + FAR_RIGHT += 125; // draw the players, in order, and restricted to team if set while( 1 ) From 7a5c29cbc9f68bf1fbfe1a454ae351721155b640 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 10:51:34 +0500 Subject: [PATCH 105/199] Clear any effects on disconnect. --- dlls/client.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/client.cpp b/dlls/client.cpp index 480a9506..3e23821f 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -125,6 +125,7 @@ void ClientDisconnect( edict_t *pEntity ) // since the edict doesn't get deleted, fix it so it doesn't interfere. pEntity->v.takedamage = DAMAGE_NO;// don't attract autoaim pEntity->v.solid = SOLID_NOT;// nonsolid + pEntity->v.effects = 0;// clear any effects UTIL_SetOrigin( &pEntity->v, pEntity->v.origin ); g_pGameRules->ClientDisconnected( pEntity ); From ea8f2bed7715b48bdf012b1c6bcbcf8881e5400a Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 12:13:04 +0500 Subject: [PATCH 106/199] Implement cl_viewbob cvar for viewmodel bobbing. Same as in http://am.half-lifecreations.com/forums/index.php?topic=288.0 --- cl_dll/hud.cpp | 2 ++ cl_dll/view.cpp | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 0f3b45bc..05bda284 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -35,6 +35,7 @@ extern client_sprite_t *GetSpriteList( client_sprite_t *pList, const char *psz, extern cvar_t *sensitivity; cvar_t *cl_lw = NULL; +cvar_t *cl_viewbob = NULL; void ShutdownInput( void ); @@ -194,6 +195,7 @@ void CHud::Init( void ) m_pCvarStealMouse = CVAR_CREATE( "hud_capturemouse", "1", FCVAR_ARCHIVE ); m_pCvarDraw = CVAR_CREATE( "hud_draw", "1", FCVAR_ARCHIVE ); cl_lw = gEngfuncs.pfnGetCvarPointer( "cl_lw" ); + cl_viewbob = CVAR_CREATE( "cl_viewbob", "0", FCVAR_ARCHIVE ); m_pSpriteList = NULL; diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index dcd2b1af..efa4b104 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -78,6 +78,7 @@ extern cvar_t *cl_forwardspeed; extern cvar_t *chase_active; extern cvar_t *scr_ofsx, *scr_ofsy, *scr_ofsz; extern cvar_t *cl_vsmoothing; +extern cvar_t *cl_viewbob; extern Vector dead_viewangles; #define CAM_MODE_RELAX 1 @@ -527,7 +528,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) V_AddIdle( pparams ); // offsets - if ( pparams->health <= 0 ) + if( pparams->health <= 0 ) { VectorCopy( dead_viewangles, angles ); } @@ -598,6 +599,9 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) view->angles[ROLL] -= bob * 1; view->angles[PITCH] -= bob * 0.3; + if( cl_viewbob && cl_viewbob->value ) + VectorCopy( view->angles, view->curstate.angles ); + // pushing the view origin down off of the same X/Z plane as the ent's origin will give the // gun a very nice 'shifting' effect when the player looks up/down. If there is a problem // with view model distortion, this may be a cause. (SJB). From c9ac2c6dabf511a5b68526876d47a8579c2bf02c Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 12:22:02 +0500 Subject: [PATCH 107/199] Implement mp_satchelfix cvar. --- dlls/doors.cpp | 10 +++++++--- dlls/game.cpp | 2 ++ dlls/game.h | 1 + dlls/player.cpp | 4 +++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/dlls/doors.cpp b/dlls/doors.cpp index ce901ee8..61a04ed2 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -22,6 +22,7 @@ #include "util.h" #include "cbase.h" #include "doors.h" +#include "game.h" #include "weapons.h" extern void SetMovedir( entvars_t *ev ); @@ -737,9 +738,12 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) if( pev->dmg ) pOther->TakeDamage( pev, pev, pev->dmg, DMG_CRUSH ); - // Detonate satchels - if( !strcmp( "monster_satchel", STRING( pOther->pev->classname ) ) ) - ( (CSatchel*)pOther )->Use( this, this, USE_ON, 0 ); + if( satchelfix.value ) + { + // Detonate satchels + if( !strcmp( "monster_satchel", STRING( pOther->pev->classname ) ) ) + ( (CSatchel*)pOther )->Use( this, this, USE_ON, 0 ); + } // if a door has a negative wait, it would never come back if blocked, // so let it just squash the object to death real fast diff --git a/dlls/game.cpp b/dlls/game.cpp index b109f376..4354a63d 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -31,6 +31,7 @@ cvar_t friendlyfire = { "mp_friendlyfire","0", FCVAR_SERVER }; cvar_t falldamage = { "mp_falldamage","0", FCVAR_SERVER }; cvar_t weaponstay = { "mp_weaponstay","0", FCVAR_SERVER }; cvar_t selfgauss = { "mp_selfgauss", "1", FCVAR_SERVER }; +cvar_t satchelfix = { "mp_satchelfix", "0", FCVAR_SERVER }; cvar_t forcerespawn = { "mp_forcerespawn","1", FCVAR_SERVER }; cvar_t flashlight = { "mp_flashlight","0", FCVAR_SERVER }; cvar_t aimcrosshair = { "mp_autocrosshair","1", FCVAR_SERVER }; @@ -469,6 +470,7 @@ void GameDLLInit( void ) CVAR_REGISTER( &falldamage ); CVAR_REGISTER( &weaponstay ); CVAR_REGISTER( &selfgauss ); + CVAR_REGISTER( &satchelfix ); CVAR_REGISTER( &forcerespawn ); CVAR_REGISTER( &flashlight ); CVAR_REGISTER( &aimcrosshair ); diff --git a/dlls/game.h b/dlls/game.h index e29b2563..a6d0cd1c 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -28,6 +28,7 @@ extern cvar_t friendlyfire; extern cvar_t falldamage; extern cvar_t weaponstay; extern cvar_t selfgauss; +extern cvar_t satchelfix; extern cvar_t forcerespawn; extern cvar_t flashlight; extern cvar_t aimcrosshair; diff --git a/dlls/player.cpp b/dlls/player.cpp index 0d86caf8..1a7bc206 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -823,7 +823,9 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) for( i = 0; i < MAX_AMMO_SLOTS; i++ ) m_rgAmmo[i] = 0; - DeactivateSatchels( this ); + if( satchelfix.value ) + DeactivateSatchels( this ); + UpdateClientData(); // send Selected Weapon Message to our client From d1fbb99574d66c35de21a3b3b45a7c137b33f6e0 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 23:32:06 +0500 Subject: [PATCH 108/199] Fix some warnings yet. --- cl_dll/cl_util.h | 2 +- cl_dll/hud_spectator.cpp | 10 +++---- cl_dll/hud_spectator.h | 4 +-- dlls/client.cpp | 4 +-- dlls/doors.cpp | 2 +- dlls/multiplay_gamerules.cpp | 2 +- dlls/nihilanth.cpp | 20 +++++++------- engine/cdll_int.h | 52 ++++++++++++++++++------------------ 8 files changed, 48 insertions(+), 48 deletions(-) diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 22555caa..1996543d 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -144,7 +144,7 @@ inline void CenterPrint( const char *string ) #define GetPlayerInfo ( *gEngfuncs.pfnGetPlayerInfo ) // sound functions -inline void PlaySound( char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } +inline void PlaySound( const char *szSound, float vol ) { gEngfuncs.pfnPlaySoundByName( szSound, vol ); } inline void PlaySound( int iSound, float vol ) { gEngfuncs.pfnPlaySoundByIndex( iSound, vol ); } #define max(a, b) (((a) > (b)) ? (a) : (b)) diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index ff6eb8ff..5ffce74a 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -175,13 +175,13 @@ void UTIL_StringToVector( float * pVector, const char *pString ) } } -int UTIL_FindEntityInMap( char * name, float * origin, float * angle ) +int UTIL_FindEntityInMap( const char *name, float *origin, float *angle ) { int n, found = 0; char keyname[256]; char token[2048]; - cl_entity_t * pEnt = gEngfuncs.GetEntityByIndex( 0 ); // get world model + cl_entity_t *pEnt = gEngfuncs.GetEntityByIndex( 0 ); // get world model if( !pEnt ) return 0; @@ -189,7 +189,7 @@ int UTIL_FindEntityInMap( char * name, float * origin, float * angle ) if( !pEnt->model ) return 0; - char * data = pEnt->model->entities; + char *data = pEnt->model->entities; while( data ) { @@ -1374,12 +1374,12 @@ void CHudSpectator::DeathMessage( int victim ) AddOverviewEntityToList(m_hsprPlayerDead, pl, gEngfuncs.GetClientTime() + 2.0f ); } -bool CHudSpectator::AddOverviewEntityToList(HSPRITE sprite, cl_entity_t *ent, double killTime) +bool CHudSpectator::AddOverviewEntityToList( HSPRITE sprite, cl_entity_t *ent, double killTime ) { for( int i = 0; i < MAX_OVERVIEW_ENTITIES; i++ ) { // find empty entity slot - if( m_OverviewEntities[i].entity == NULL) + if( m_OverviewEntities[i].entity == NULL ) { m_OverviewEntities[i].entity = ent; m_OverviewEntities[i].hSprite = sprite; diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index f60353db..58026668 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -64,11 +64,11 @@ public: void CheckOverviewEntities(); void DrawOverview(); void DrawOverviewEntities(); - void GetMapPosition( float * returnvec ); + void GetMapPosition( float *returnvec ); void DrawOverviewLayer(); void LoadMapSprites(); bool ParseOverviewFile(); - bool IsActivePlayer( cl_entity_t * ent ); + bool IsActivePlayer( cl_entity_t *ent ); void SetModes( int iMainMode, int iInsetMode ); void HandleButtonsDown( int ButtonPressed ); void HandleButtonsUp( int ButtonPressed ); diff --git a/dlls/client.cpp b/dlls/client.cpp index 3e23821f..569b1a53 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -566,7 +566,7 @@ void ClientCommand( edict_t *pEntity ) // notify other clients of player switching to spectator mode UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n", - ( pev->netname && STRING(pev->netname)[0] != 0 ) ? STRING(pev->netname) : "unconnected" ) ); + ( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) ); } else ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" ); @@ -629,7 +629,7 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) return; // msg everyone if someone changes their name, and it isn't the first time (changing no name to current name) - if( pEntity->v.netname && STRING( pEntity->v.netname )[0] != 0 && !FStrEq( STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ) ) + if( pEntity->v.netname && ( STRING( pEntity->v.netname ) )[0] != 0 && !FStrEq( STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ) ) { char sName[256]; char *pName = g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ); diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 61a04ed2..90678df6 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -397,7 +397,7 @@ void CBaseDoor::Precache( void ) pszSound = "doors/doorstop5.wav"; break; case 6: - pszSound = "doors/doorstop6.wav" + pszSound = "doors/doorstop6.wav"; break; case 7: pszSound = "doors/doorstop7.wav"; diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 494ac4f6..a898158f 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -423,7 +423,7 @@ void CHalfLifeMultiplay::InitHUD( CBasePlayer *pl ) { // notify other clients of player joining the game UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has joined the game\n", - ( pl->pev->netname && STRING( pl->pev->netname )[0] != 0 ) ? STRING( pl->pev->netname ) : "unconnected" ) ); + ( pl->pev->netname && ( STRING( pl->pev->netname ) )[0] != 0 ) ? STRING( pl->pev->netname ) : "unconnected" ) ); // team match? if( g_teamplay ) diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 1f9b0f88..34375a58 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -642,14 +642,14 @@ void CNihilanth::MakeFriend( Vector vecStart ) for( i = 0; i < 3; i++ ) { - if( m_hFriend[i] != NULL && !m_hFriend[i]->IsAlive() ) + if( m_hFriend[i] != 0 && !m_hFriend[i]->IsAlive() ) { if( pev->rendermode == kRenderNormal ) // don't do it if they are already fading m_hFriend[i]->MyMonsterPointer()->FadeMonster(); m_hFriend[i] = NULL; } - if( m_hFriend[i] == NULL ) + if( m_hFriend[i] == 0 ) { if( RANDOM_LONG( 0, 1 ) == 0 ) { @@ -675,7 +675,7 @@ void CNihilanth::MakeFriend( Vector vecStart ) m_hFriend[i] = Create( "monster_alien_slave", node.m_vecOrigin, pev->angles ); } } - if( m_hFriend[i] != NULL ) + if( m_hFriend[i] != 0 ) { EMIT_SOUND( m_hFriend[i]->edict(), CHAN_WEAPON, "debris/beamstart7.wav", 1.0, ATTN_NORM ); } @@ -722,7 +722,7 @@ void CNihilanth::NextActivity() } } - if( ( pev->health < gSkillData.nihilanthHealth / 2 || m_iActiveSpheres < N_SPHERES / 2 ) && m_hRecharger == NULL && m_iLevel <= 9 ) + if( ( pev->health < gSkillData.nihilanthHealth / 2 || m_iActiveSpheres < N_SPHERES / 2 ) && m_hRecharger == 0 && m_iLevel <= 9 ) { char szName[64]; @@ -881,7 +881,7 @@ void CNihilanth::HuntThink( void ) } // look for current enemy - if( m_hEnemy != 0 && m_hRecharger == NULL ) + if( m_hEnemy != 0 && m_hRecharger == 0 ) { if( FVisible( m_hEnemy ) ) { @@ -1057,7 +1057,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) break; case 2: // zen - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { if( RANDOM_LONG( 0, 4 ) == 0 ) EMIT_SOUND( edict(), CHAN_VOICE, RANDOM_SOUND_ARRAY( pAttackSounds ), 1.0, 0.2 ); @@ -1098,7 +1098,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) break; case 3: // prayer - if (m_hEnemy != NULL) + if( m_hEnemy != 0 ) { char szText[32]; @@ -1178,7 +1178,7 @@ void CNihilanth::HandleAnimEvent( MonsterEvent_t *pEvent ) } break; case 6: - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { Vector vecSrc, vecAngles; GetAttachment( 2, vecSrc, vecAngles ); @@ -1208,7 +1208,7 @@ void CNihilanth::CommandUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ CBaseEntity *pTouch = UTIL_FindEntityByTargetname( NULL, m_szDeadTouch ); if( pTouch ) { - if( m_hEnemy != NULL ) + if( m_hEnemy != 0 ) { pTouch->Touch( m_hEnemy ); } @@ -1597,7 +1597,7 @@ void CNihilanthHVR::TeleportThink( void ) if( m_hTargetEnt != 0 ) m_hTargetEnt->Use( m_hEnemy, m_hEnemy, USE_ON, 1.0 ); - if( m_hTouch != 0 && m_hEnemy != NULL ) + if( m_hTouch != 0 && m_hEnemy != 0 ) m_hTouch->Touch( m_hEnemy ); } else diff --git a/engine/cdll_int.h b/engine/cdll_int.h index 056146b4..d45bb9d5 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -128,7 +128,7 @@ typedef struct cl_enginefuncs_s void (*pfnSPR_DrawAdditive)( int frame, int x, int y, const wrect_t *prc ); void (*pfnSPR_EnableScissor)( int x, int y, int width, int height ); void (*pfnSPR_DisableScissor)( void ); - client_sprite_t *(*pfnSPR_GetList)( char *psz, int *piCount ); + client_sprite_t *(*pfnSPR_GetList)( const char *psz, int *piCount ); // screen handlers void (*pfnFillRGBA)( int x, int y, int width, int height, int r, int g, int b, int a ); @@ -136,20 +136,20 @@ typedef struct cl_enginefuncs_s void (*pfnSetCrosshair)( HSPRITE hspr, wrect_t rc, int r, int g, int b ); // cvar handlers - struct cvar_s *(*pfnRegisterVariable)( char *szName, char *szValue, int flags ); - float (*pfnGetCvarFloat)( char *szName ); - char* (*pfnGetCvarString)( char *szName ); + struct cvar_s *(*pfnRegisterVariable)( const char *szName, const char *szValue, int flags ); + float (*pfnGetCvarFloat)( const char *szName ); + char* (*pfnGetCvarString)( const char *szName ); // command handlers - int (*pfnAddCommand)( char *cmd_name, void (*function)(void) ); - int (*pfnHookUserMsg)( char *szMsgName, pfnUserMsgHook pfn ); - int (*pfnServerCmd)( char *szCmdString ); - int (*pfnClientCmd)( char *szCmdString ); + int (*pfnAddCommand)( const char *cmd_name, void (*function)(void) ); + int (*pfnHookUserMsg)( const char *szMsgName, pfnUserMsgHook pfn ); + int (*pfnServerCmd)( const char *szCmdString ); + int (*pfnClientCmd)( const char *szCmdString ); void (*pfnGetPlayerInfo)( int ent_num, hud_player_info_t *pinfo ); // sound handlers - void (*pfnPlaySoundByName)( char *szSound, float volume ); + void (*pfnPlaySoundByName)( const char *szSound, float volume ); void (*pfnPlaySoundByIndex)( int iSound, float volume ); // vector helpers @@ -158,7 +158,7 @@ typedef struct cl_enginefuncs_s // text message system client_textmessage_t *(*pfnTextMessageGet)( const char *pName ); int (*pfnDrawCharacter)( int x, int y, int number, int r, int g, int b ); - int (*pfnDrawConsoleString)( int x, int y, char *string ); + int (*pfnDrawConsoleString)( int x, int y, const char *string ); void (*pfnDrawSetTextColor)( float r, float g, float b ); void (*pfnDrawConsoleStringLen)( const char *string, int *length, int *height ); @@ -171,19 +171,19 @@ typedef struct cl_enginefuncs_s void (*GetViewAngles)( float * ); void (*SetViewAngles)( float * ); int (*GetMaxClients)( void ); - void (*Cvar_SetValue)( char *cvar, float value ); + void (*Cvar_SetValue)( const char *cvar, float value ); int (*Cmd_Argc)( void ); char *(*Cmd_Argv)( int arg ); - void (*Con_Printf)( char *fmt, ... ); - void (*Con_DPrintf)( char *fmt, ... ); - void (*Con_NPrintf)( int pos, char *fmt, ... ); - void (*Con_NXPrintf)( struct con_nprint_s *info, char *fmt, ... ); + void (*Con_Printf)( const char *fmt, ... ); + void (*Con_DPrintf)( const char *fmt, ... ); + void (*Con_NPrintf)( int pos, const char *fmt, ... ); + void (*Con_NXPrintf)( struct con_nprint_s *info, const char *fmt, ... ); const char* (*PhysInfo_ValueForKey)( const char *key ); const char* (*ServerInfo_ValueForKey)( const char *key ); float (*GetClientMaxspeed)( void ); - int (*CheckParm)( char *parm, char **ppnext ); + int (*CheckParm)( const char *parm, const char **ppnext ); void (*Key_Event)( int key, int down ); void (*GetMousePosition)( int *mx, int *my ); @@ -212,7 +212,7 @@ typedef struct cl_enginefuncs_s void (*pfnWeaponAnim)( int iAnim, int body ); float (*pfnRandomFloat)( float flLow, float flHigh ); int (*pfnRandomLong)( int lLow, int lHigh ); - void (*pfnHookEvent)( char *name, void ( *pfnEvent )( struct event_args_s *args )); + void (*pfnHookEvent)( const char *name, void ( *pfnEvent )( struct event_args_s *args )); int (*Con_IsVisible) (); const char *(*pfnGetGameDirectory)( void ); struct cvar_s *(*pfnGetCvarPointer)( const char *szName ); @@ -223,8 +223,8 @@ typedef struct cl_enginefuncs_s void* (*VGui_GetPanel)( ); void (*VGui_ViewportPaintBackground)( int extents[4] ); - byte* (*COM_LoadFile)( char *path, int usehunk, int *pLength ); - char* (*COM_ParseFile)( char *data, char *token ); + byte* (*COM_LoadFile)( const char *path, int usehunk, int *pLength ); + char* (*COM_ParseFile)( const char *data, const char *token ); void (*COM_FreeFile)( void *buffer ); struct triangleapi_s *pTriAPI; @@ -252,7 +252,7 @@ typedef struct cl_enginefuncs_s // Gets a unique ID for the specified player. This is the same even if you see the player on a different server. // iPlayer is an entity index, so client 0 would use iPlayer=1. // Returns false if there is no player on the server in the specified slot. - qboolean (*GetPlayerUniqueID)(int iPlayer, char playerID[16]); + qboolean (*GetPlayerUniqueID)(int iPlayer, const char playerID[16]); // TrackerID access int (*GetTrackerIDForPlayer)(int playerSlot); @@ -260,7 +260,7 @@ typedef struct cl_enginefuncs_s // Same as pfnServerCmd, but the message goes in the unreliable stream so it can't clog the net stream // (but it might not get there). - int ( *pfnServerCmdUnreliable )( char *szCmdString ); + int ( *pfnServerCmdUnreliable )( const char *szCmdString ); void (*pfnGetMousePos)( struct tagPOINT *ppt ); void (*pfnSetMousePos)( int x, int y ); @@ -285,12 +285,12 @@ typedef struct cl_enginefuncs_s const char *(*LocalPlayerInfo_ValueForKey)( const char* key ); int (*pfnVGUI2DrawCharacter)( int x, int y, int ch, unsigned int font ); int (*pfnVGUI2DrawCharacterAdditive)( int x, int y, int ch, int r, int g, int b, unsigned int font ); - unsigned int (*pfnGetApproxWavePlayLen)( char *filename ); + unsigned int (*pfnGetApproxWavePlayLen)( const char *filename ); void* (*GetCareerGameUI)( void ); // g-cont. !!!! potential crash-point! - void (*Cvar_Set)( char *name, char *value ); + void (*Cvar_Set)( const char *name, const char *value ); int (*pfnIsPlayingCareerMatch)( void ); - void (*pfnPlaySoundVoiceByName)( char *szSound, float volume, int pitch ); - void (*pfnPrimeMusicStream)( char *filename, int looping ); + void (*pfnPlaySoundVoiceByName)( const char *szSound, float volume, int pitch ); + void (*pfnPrimeMusicStream)( const char *filename, int looping ); double (*pfnSys_FloatTime)( void ); // decay funcs @@ -298,7 +298,7 @@ typedef struct cl_enginefuncs_s void (*pfnConstructTutorMessageDecayBuffer)( int *buffer, int buflen ); void (*pfnResetTutorMessageDecayData)( void ); - void (*pfnPlaySoundByNameAtPitch)( char *szSound, float volume, int pitch ); + void (*pfnPlaySoundByNameAtPitch)( const char *szSound, float volume, int pitch ); void (*pfnFillRGBABlend)( int x, int y, int width, int height, int r, int g, int b, int a ); int (*pfnGetAppID)( void ); cmdalias_t *(*pfnGetAliases)( void ); From 58a5ca48be81a8d12995d4bd71f4ad9fee274ba7 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 20 Jul 2017 23:42:00 +0500 Subject: [PATCH 109/199] Add protection for vec3_t definition. --- common/mathlib.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/mathlib.h b/common/mathlib.h index fadb97fb..12fb972f 100644 --- a/common/mathlib.h +++ b/common/mathlib.h @@ -18,7 +18,12 @@ typedef float vec_t; typedef vec_t vec2_t[2]; + +#ifndef DID_VEC3_T_DEFINE +#define DID_VEC3_T_DEFINE typedef vec_t vec3_t[3]; +#endif + typedef vec_t vec4_t[4]; // x,y,z,w #ifndef M_PI From 3dc0939b40960f1a3e0c7ff9d68849e2dff0ccd7 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 21 Jul 2017 00:00:38 +0500 Subject: [PATCH 110/199] Prevent buffer overflow. --- cl_dll/text_message.cpp | 39 ++++++++++++++++++--------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index 9452cebb..b959fc87 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -162,42 +162,39 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf int msg_dest = READ_BYTE(); - static char szBuf[6][128]; - const char *msg_text = LookupString( READ_STRING(), &msg_dest ); - msg_text = strcpy( szBuf[0], msg_text ); +#define MSG_BUF_SIZE 128 + char szBuf[6][MSG_BUF_SIZE]; + + strncpy( szBuf[0], LookupString( READ_STRING(), &msg_dest ), MSG_BUF_SIZE - 1 ); + szBuf[0][MSG_BUF_SIZE - 1] = '\0'; + + for( int i = 1; i <= 4; i++ ) + { + // keep reading strings and using C format strings for subsituting the strings into the localised text string + strncpy( szBuf[i], LookupString( READ_STRING() ), MSG_BUF_SIZE - 1 ); + szBuf[i][MSG_BUF_SIZE - 1] = '\0'; + StripEndNewlineFromString( szBuf[i] ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines + } - // keep reading strings and using C format strings for subsituting the strings into the localised text string - const char *sstr1 = LookupString( READ_STRING() ); - sstr1 = strcpy( szBuf[1], sstr1 ); - StripEndNewlineFromString( (char*)sstr1 ); // these strings are meant for subsitution into the main strings, so cull the automatic end newlines - const char *sstr2 = LookupString( READ_STRING() ); - sstr2 = strcpy( szBuf[2], sstr2 ); - StripEndNewlineFromString( (char*)sstr2 ); - const char *sstr3 = LookupString( READ_STRING() ); - sstr3 = strcpy( szBuf[3], sstr3 ); - StripEndNewlineFromString( (char*)sstr3 ); - const char *sstr4 = LookupString( READ_STRING() ); - sstr4 = strcpy( szBuf[4], sstr4 ); - StripEndNewlineFromString( (char*)sstr4 ); char *psz = szBuf[5]; switch( msg_dest ) { case HUD_PRINTCENTER: - sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); + snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); CenterPrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTNOTIFY: psz[0] = 1; // mark this message to go into the notify buffer - sprintf( psz + 1, msg_text, sstr1, sstr2, sstr3, sstr4 ); + snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTTALK: - sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); - gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), 128 ); + snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), MSG_BUF_SIZE ); break; case HUD_PRINTCONSOLE: - sprintf( psz, msg_text, sstr1, sstr2, sstr3, sstr4 ); + snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; } From cf9ba716862eb50da691a4daff272a61f0a0b674 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Fri, 21 Jul 2017 00:52:09 +0500 Subject: [PATCH 111/199] Make UpdateOnRemove() virtual. --- cl_dll/hl/hl_baseentity.cpp | 1 + dlls/cbase.h | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index d24c0ef4..acd537e0 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -55,6 +55,7 @@ BOOL CBaseEntity::IsInWorld( void ) { return TRUE; } int CBaseEntity::ShouldToggle( USE_TYPE useType, BOOL currentState ) { return 0; } int CBaseEntity::DamageDecal( int bitsDamageType ) { return -1; } CBaseEntity *CBaseEntity::Create( const char *szName, const Vector &vecOrigin, const Vector &vecAngles, edict_t *pentOwner ) { return NULL; } +void CBaseEntity::UpdateOnRemove( void ) { } void CBaseEntity::SUB_Remove( void ) { } // CBaseDelay Stubs diff --git a/dlls/cbase.h b/dlls/cbase.h index 6c738bf5..b78de883 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -12,6 +12,8 @@ * without written permission from Valve LLC. * ****/ +#ifndef CBASE_H +#define CBASE_H /* Class Hierachy @@ -229,7 +231,7 @@ public: }; #endif - void UpdateOnRemove( void ); + virtual void UpdateOnRemove( void ); // common member functions void EXPORT SUB_Remove( void ); @@ -780,3 +782,4 @@ public: void Precache( void ); void KeyValue( KeyValueData *pkvd ); }; +#endif From 70c6e429076e746b1be4492b0c6f468ef7ea2174 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 23 Jul 2017 21:41:05 +0500 Subject: [PATCH 112/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/68c9b7cf6bdcacdf267c2e2dab2415dbbebdfcd2 --- cl_dll/hl/hl_baseentity.cpp | 2 +- dlls/handgrenade.cpp | 3 +- dlls/player.cpp | 20 +++++---- dlls/player.h | 2 +- dlls/satchel.cpp | 83 +++++++++++++++++-------------------- dlls/squeakgrenade.cpp | 3 +- dlls/tripmine.cpp | 3 +- dlls/weapons.cpp | 18 ++++++-- 8 files changed, 68 insertions(+), 66 deletions(-) diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index acd537e0..38978f6a 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -277,7 +277,7 @@ void CBasePlayer::ForceClientDllUpdate( void ) { } void CBasePlayer::ImpulseCommands() { } void CBasePlayer::CheatImpulseCommands( int iImpulse ) { } int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) { return FALSE; } -int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) { return FALSE; } +int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHoster ) { return FALSE; } void CBasePlayer::ItemPreFrame() { } void CBasePlayer::ItemPostFrame() { } int CBasePlayer::AmmoInventory( int iAmmoIndex ) { return -1; } diff --git a/dlls/handgrenade.cpp b/dlls/handgrenade.cpp index 2a31fc84..c2bbd7f9 100644 --- a/dlls/handgrenade.cpp +++ b/dlls/handgrenade.cpp @@ -99,8 +99,7 @@ void CHandGrenade::Holster( int skiplocal /* = 0 */ ) { // no more grenades! m_pPlayer->pev->weapons &= ~( 1 << WEAPON_HANDGRENADE ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); } if( m_flStartThrow ) diff --git a/dlls/player.cpp b/dlls/player.cpp index 1a7bc206..38038b36 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -666,8 +666,8 @@ void CBasePlayer::PackDeadPlayerItems( void ) int iWeaponRules; int iAmmoRules; int i; - CBasePlayerWeapon *rgpPackWeapons[20] = {0};// 20 hardcoded for now. How to determine exactly how many weapons we have? - int iPackAmmo[MAX_AMMO_SLOTS + 1]; + CBasePlayerWeapon *rgpPackWeapons[MAX_WEAPONS] = {}; + int iPackAmmo[MAX_AMMO_SLOTS]; int iPW = 0;// index into packweapons array int iPA = 0;// index into packammo array @@ -675,7 +675,7 @@ void CBasePlayer::PackDeadPlayerItems( void ) // get the game rules iWeaponRules = g_pGameRules->DeadPlayerWeapons( this ); - iAmmoRules = g_pGameRules->DeadPlayerAmmo( this ); + iAmmoRules = g_pGameRules->DeadPlayerAmmo( this ); if( iWeaponRules == GR_PLR_DROP_GUN_NO && iAmmoRules == GR_PLR_DROP_AMMO_NO ) { @@ -685,14 +685,14 @@ void CBasePlayer::PackDeadPlayerItems( void ) } // go through all of the weapons and make a list of the ones to pack - for( i = 0; i < MAX_ITEM_TYPES; i++ ) + for( i = 0; i < MAX_ITEM_TYPES && iPW < MAX_WEAPONS; i++ ) { if( m_rgpPlayerItems[i] ) { // there's a weapon here. Should I pack it? CBasePlayerItem *pPlayerItem = m_rgpPlayerItems[i]; - while( pPlayerItem ) + while( pPlayerItem && iPW < MAX_WEAPONS ) { switch( iWeaponRules ) { @@ -3640,14 +3640,16 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) return FALSE; } -int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem ) +int CBasePlayer::RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHolster ) { + pItem->pev->nextthink = 0;// crowbar may be trying to swing again, etc. + pItem->SetThink( NULL ); + if( m_pActiveItem == pItem ) { ResetAutoaim(); - pItem->Holster(); - pItem->pev->nextthink = 0;// crowbar may be trying to swing again, etc. - pItem->SetThink( NULL ); + if( bCallHolster ) + pItem->Holster(); m_pActiveItem = NULL; pev->viewmodel = 0; pev->weaponmodel = 0; diff --git a/dlls/player.h b/dlls/player.h index 8ff312ea..1c17556c 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -259,7 +259,7 @@ public: void AddPoints( int score, BOOL bAllowNegativeScore ); void AddPointsToTeam( int score, BOOL bAllowNegativeScore ); BOOL AddPlayerItem( CBasePlayerItem *pItem ); - BOOL RemovePlayerItem( CBasePlayerItem *pItem ); + BOOL RemovePlayerItem( CBasePlayerItem *pItem, bool bCallHoster ); void DropPlayerItem ( char *pszItemName ); BOOL HasPlayerItem( CBasePlayerItem *pCheckItem ); BOOL HasNamedPlayerItem( const char *pszItemName ); diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index 015b3483..dc8724bd 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -23,6 +23,13 @@ #include "player.h" #include "gamerules.h" +enum satchel_state +{ + SATCHEL_IDLE = 0, + SATCHEL_READY, + SATCHEL_RELOAD +}; + enum satchel_e { SATCHEL_IDLE1 = 0, @@ -194,7 +201,7 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) { pSatchel = (CSatchel *)pOriginal; - if( pSatchel->m_chargeReady != 0 ) + if( pSatchel->m_chargeReady != SATCHEL_IDLE ) { // player has some satchels deployed. Refuse to add more. return FALSE; @@ -211,7 +218,7 @@ int CSatchel::AddToPlayer( CBasePlayer *pPlayer ) int bResult = CBasePlayerItem::AddToPlayer( pPlayer ); pPlayer->pev->weapons |= ( 1 << m_iId ); - m_chargeReady = 0;// this satchel charge weapon now forgets that any satchels are deployed by it. + m_chargeReady = SATCHEL_IDLE;// this satchel charge weapon now forgets that any satchels are deployed by it. if( bResult ) { @@ -263,19 +270,7 @@ int CSatchel::GetItemInfo( ItemInfo *p ) //========================================================= BOOL CSatchel::IsUseable( void ) { - if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) - { - // player is carrying some satchels - return TRUE; - } - - if( m_chargeReady != 0 ) - { - // player isn't carrying any satchels, but has some out - return TRUE; - } - - return FALSE; + return CanDeploy(); } BOOL CSatchel::CanDeploy( void ) @@ -286,7 +281,7 @@ BOOL CSatchel::CanDeploy( void ) return TRUE; } - if( m_chargeReady != 0 ) + if( m_chargeReady ) { // player isn't carrying any satchels, but has some out return TRUE; @@ -322,11 +317,10 @@ void CSatchel::Holster( int skiplocal /* = 0 */ ) } EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); - if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && !m_chargeReady ) + if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && m_chargeReady != SATCHEL_READY ) { m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SATCHEL ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); } } @@ -334,38 +328,37 @@ void CSatchel::PrimaryAttack() { switch( m_chargeReady ) { - case 0: + case SATCHEL_IDLE: { - Throw(); + Throw(); } break; - case 1: + case SATCHEL_READY: { - SendWeaponAnim( SATCHEL_RADIO_FIRE ); + SendWeaponAnim( SATCHEL_RADIO_FIRE ); - edict_t *pPlayer = m_pPlayer->edict(); + edict_t *pPlayer = m_pPlayer->edict(); - CBaseEntity *pSatchel = NULL; + CBaseEntity *pSatchel = NULL; - while( ( pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 ) ) != NULL ) - { - if( FClassnameIs( pSatchel->pev, "monster_satchel" ) ) + while( ( pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 ) ) != NULL ) { - if( pSatchel->pev->owner == pPlayer ) + if( FClassnameIs( pSatchel->pev, "monster_satchel" ) ) { - pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); - m_chargeReady = 2; + if( pSatchel->pev->owner == pPlayer ) + { + pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); + } } } - } - m_chargeReady = 2; - m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; - break; + m_chargeReady = SATCHEL_RELOAD; + m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; + break; } - case 2: + case SATCHEL_RELOAD: // we're reloading, don't allow fire break; } @@ -373,7 +366,7 @@ void CSatchel::PrimaryAttack() void CSatchel::SecondaryAttack( void ) { - if( m_chargeReady != 2 ) + if( m_chargeReady != SATCHEL_RELOAD ) { Throw(); } @@ -403,8 +396,8 @@ void CSatchel::Throw( void ) // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - m_chargeReady = 1; - + m_chargeReady = SATCHEL_READY; + m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); @@ -419,17 +412,17 @@ void CSatchel::WeaponIdle( void ) switch( m_chargeReady ) { - case 0: + case SATCHEL_IDLE: SendWeaponAnim( SATCHEL_FIDGET1 ); // use tripmine animations strcpy( m_pPlayer->m_szAnimExtention, "trip" ); break; - case 1: + case SATCHEL_READY: SendWeaponAnim( SATCHEL_RADIO_FIDGET1 ); // use hivehand animations strcpy( m_pPlayer->m_szAnimExtention, "hive" ); break; - case 2: + case SATCHEL_RELOAD: if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { m_chargeReady = 0; @@ -450,7 +443,7 @@ void CSatchel::WeaponIdle( void ) m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_chargeReady = 0; + m_chargeReady = SATCHEL_IDLE; break; } m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again. diff --git a/dlls/squeakgrenade.cpp b/dlls/squeakgrenade.cpp index 830cfab8..bfe17ed1 100644 --- a/dlls/squeakgrenade.cpp +++ b/dlls/squeakgrenade.cpp @@ -475,8 +475,7 @@ void CSqueak::Holster( int skiplocal /* = 0 */ ) if( !m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { m_pPlayer->pev->weapons &= ~( 1 << WEAPON_SNARK ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); return; } diff --git a/dlls/tripmine.cpp b/dlls/tripmine.cpp index 60190604..94907bcd 100644 --- a/dlls/tripmine.cpp +++ b/dlls/tripmine.cpp @@ -418,8 +418,7 @@ void CTripmine::Holster( int skiplocal /* = 0 */ ) { // out of mines m_pPlayer->pev->weapons &= ~( 1 << WEAPON_TRIPMINE ); - SetThink( &CBasePlayerItem::DestroyItem ); - pev->nextthink = gpGlobals->time + 0.1; + DestroyItem(); } SendWeaponAnim( TRIPMINE_HOLSTER ); diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 05db43da..06bb1796 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -688,8 +688,8 @@ void CBasePlayerItem::DestroyItem( void ) { if( m_pPlayer ) { - // if attached to a player, remove. - m_pPlayer->RemovePlayerItem( this ); + // if attached to a player, remove. + m_pPlayer->RemovePlayerItem( this, false ); } Kill(); @@ -1140,7 +1140,17 @@ void CBasePlayerWeapon::RetireWeapon( void ) m_pPlayer->pev->weaponmodel = iStringNull; //m_pPlayer->pev->viewmodelindex = NULL; - g_pGameRules->GetNextBestWeapon( m_pPlayer, this ); + if( !g_pGameRules->GetNextBestWeapon( m_pPlayer, this ) ) + { + // Another weapon wasn't selected. Get rid of current one + if( m_pPlayer->m_pActiveItem == this ) + { + m_pPlayer->ResetAutoaim(); + m_pPlayer->m_pActiveItem->Holster(); + m_pPlayer->m_pLastItem = NULL; + m_pPlayer->m_pActiveItem = NULL; + } + } } //========================================================================= @@ -1340,7 +1350,7 @@ BOOL CWeaponBox::PackWeapon( CBasePlayerItem *pWeapon ) if( pWeapon->m_pPlayer ) { - if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon ) ) + if( !pWeapon->m_pPlayer->RemovePlayerItem( pWeapon, true ) ) { // failed to unhook the weapon from the player! return FALSE; From 49e740c6f132969f7881c21ad3bdecb6aad84568 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 24 Jul 2017 02:24:55 +0500 Subject: [PATCH 113/199] Remove unneeded casts. --- dlls/agrunt.cpp | 14 ++++++------- dlls/animation.cpp | 2 +- dlls/bmodels.cpp | 16 +++++++-------- dlls/buttons.cpp | 26 +++++++++++------------ dlls/cbase.cpp | 2 +- dlls/doors.cpp | 28 ++++++++++++------------- dlls/effects.cpp | 25 +++++++++++----------- dlls/func_break.cpp | 8 ++++---- dlls/func_tank.cpp | 10 ++++----- dlls/gargantua.cpp | 22 ++++++++++---------- dlls/genericmonster.cpp | 2 +- dlls/h_cycler.cpp | 10 ++++----- dlls/islave.cpp | 8 ++++---- dlls/leech.cpp | 4 ++-- dlls/multiplay_gamerules.cpp | 28 ++++++++++++------------- dlls/nodes.cpp | 8 ++++---- dlls/nodes.h | 6 +++--- dlls/plats.cpp | 40 ++++++++++++++++++------------------ dlls/prop.cpp | 6 +++--- dlls/scripted.cpp | 4 ++-- dlls/sound.cpp | 8 ++++---- dlls/stats.cpp | 4 ++-- dlls/triggers.cpp | 8 ++++---- dlls/util.cpp | 10 ++++----- dlls/util.h | 2 +- dlls/weapons.cpp | 8 ++++---- dlls/world.cpp | 4 ++-- dlls/xen.cpp | 6 +++--- dlls/zombie.cpp | 14 ++++++------- 29 files changed, 166 insertions(+), 167 deletions(-) diff --git a/dlls/agrunt.cpp b/dlls/agrunt.cpp index c6583fb7..cb47ac65 100644 --- a/dlls/agrunt.cpp +++ b/dlls/agrunt.cpp @@ -613,25 +613,25 @@ void CAGrunt::Precache() PRECACHE_MODEL( "models/agrunt.mdl" ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( (char *)pIdleSounds[i] ); + PRECACHE_SOUND( pIdleSounds[i] ); for( i = 0; i < ARRAYSIZE( pDieSounds ); i++ ) - PRECACHE_SOUND( (char *)pDieSounds[i] ); + PRECACHE_SOUND( pDieSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( (char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( (char *)pAlertSounds[i] ); + PRECACHE_SOUND( pAlertSounds[i] ); PRECACHE_SOUND( "hassault/hw_shoot1.wav" ); diff --git a/dlls/animation.cpp b/dlls/animation.cpp index 5454f0e8..f84ec380 100644 --- a/dlls/animation.cpp +++ b/dlls/animation.cpp @@ -208,7 +208,7 @@ void SequencePrecache( void *pmodel, const char *pSequenceName ) ALERT( at_error, "Bad sound event %d in sequence %s :: %s (sound is \"%s\")\n", pevent[i].event, pstudiohdr->name, pSequenceName, pevent[i].options ); } - PRECACHE_SOUND( (char *)( gpGlobals->pStringBase + ALLOC_STRING( pevent[i].options ) ) ); + PRECACHE_SOUND( gpGlobals->pStringBase + ALLOC_STRING( pevent[i].options ) ); } } } diff --git a/dlls/bmodels.cpp b/dlls/bmodels.cpp index c48abbf9..fe56b6ac 100644 --- a/dlls/bmodels.cpp +++ b/dlls/bmodels.cpp @@ -402,7 +402,7 @@ void CFuncRotating::Spawn() } UTIL_SetOrigin( pev, pev->origin ); - SET_MODEL( ENT(pev), STRING(pev->model) ); + SET_MODEL( ENT( pev ), STRING( pev->model ) ); SetUse( &CFuncRotating::RotatingUse ); // did level designer forget to assign speed? @@ -538,7 +538,7 @@ void CFuncRotating::RampPitchVol( int fUp ) pitch = PITCH_NORM - 1; // change the fan's vol and pitch - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), fvol, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, pitch ); } @@ -560,7 +560,7 @@ void CFuncRotating::SpinUp( void ) fabs( vecAVel.z ) >= fabs( pev->movedir.z * pev->speed ) ) { pev->avelocity = pev->movedir * pev->speed;// set speed in case we overshot - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), m_flVolume, m_flAttenuation, SND_CHANGE_PITCH | SND_CHANGE_VOL, FANPITCHMAX ); SetThink( &CFuncRotating::Rotate ); @@ -601,7 +601,7 @@ void CFuncRotating::SpinDown( void ) pev->avelocity = g_vecZero;// set speed in case we overshot // stop sound, we're done - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning /* Stop */ ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning /* Stop */ ), 0, 0, SND_STOP, (int)m_pitch ); SetThink( &CFuncRotating::Rotate ); @@ -630,7 +630,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, if( pev->avelocity != g_vecZero ) { SetThink( &CFuncRotating::SpinDown ); - //EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ), + //EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStop ), // m_flVolume, m_flAttenuation, 0, m_pitch ); pev->nextthink = pev->ltime + 0.1; @@ -638,7 +638,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, else// fan is not moving, so start it { SetThink( &CFuncRotating::SpinUp ); - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), 0.01, m_flAttenuation, 0, FANPITCHMIN ); pev->nextthink = pev->ltime + 0.1; @@ -651,7 +651,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, // play stopping sound here SetThink( &CFuncRotating::SpinDown ); - // EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, (char *)STRING( pev->noiseStop ), + // EMIT_SOUND_DYN( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStop ), // m_flVolume, m_flAttenuation, 0, m_pitch ); pev->nextthink = pev->ltime + 0.1; @@ -659,7 +659,7 @@ void CFuncRotating::RotatingUse( CBaseEntity *pActivator, CBaseEntity *pCaller, } else { - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char *)STRING( pev->noiseRunning ), + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noiseRunning ), m_flVolume, m_flAttenuation, 0, FANPITCHMAX ); pev->avelocity = pev->movedir * pev->speed; diff --git a/dlls/buttons.cpp b/dlls/buttons.cpp index 7ea9082a..90bc42e5 100644 --- a/dlls/buttons.cpp +++ b/dlls/buttons.cpp @@ -343,25 +343,25 @@ void CBaseButton::Precache( void ) m_ls.sUnlockedSentence = MAKE_STRING( "EA" ); break; case 2: // security door - m_ls.sUnlockedSentence = MAKE_STRING("ED"); + m_ls.sUnlockedSentence = MAKE_STRING( "ED" ); break; case 3: // blast door - m_ls.sUnlockedSentence = MAKE_STRING("EF"); + m_ls.sUnlockedSentence = MAKE_STRING( "EF" ); break; case 4: // fire door - m_ls.sUnlockedSentence = MAKE_STRING("EFIRE"); + m_ls.sUnlockedSentence = MAKE_STRING( "EFIRE" ); break; case 5: // chemical door - m_ls.sUnlockedSentence = MAKE_STRING("ECHEM"); + m_ls.sUnlockedSentence = MAKE_STRING( "ECHEM" ); break; case 6: // radiation door - m_ls.sUnlockedSentence = MAKE_STRING("ERAD"); + m_ls.sUnlockedSentence = MAKE_STRING( "ERAD" ); break; case 7: // gen containment - m_ls.sUnlockedSentence = MAKE_STRING("ECON"); + m_ls.sUnlockedSentence = MAKE_STRING( "ECON" ); break; case 8: // maintenance door - m_ls.sUnlockedSentence = MAKE_STRING("EH"); + m_ls.sUnlockedSentence = MAKE_STRING( "EH" ); break; default: m_ls.sUnlockedSentence = 0; @@ -426,7 +426,7 @@ int CBaseButton::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, fl if( code == BUTTON_RETURN ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); // Toggle buttons fire when they get back to their "home" position if( !( pev->spawnflags & SF_BUTTON_TOGGLE ) ) @@ -657,7 +657,7 @@ void CBaseButton::ButtonUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_ { if( !m_fStayPushed && FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); //SUB_UseTargets( m_eoActivator ); ButtonReturn(); @@ -716,7 +716,7 @@ void CBaseButton::ButtonTouch( CBaseEntity *pOther ) if( code == BUTTON_RETURN ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); ButtonReturn(); } @@ -729,7 +729,7 @@ void CBaseButton::ButtonTouch( CBaseEntity *pOther ) // void CBaseButton::ButtonActivate() { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); if( !UTIL_IsMasterTriggered( m_sMaster, m_hActivator ) ) { @@ -815,7 +815,7 @@ void CBaseButton::ButtonBackHome( void ) if( FBitSet( pev->spawnflags, SF_BUTTON_TOGGLE ) ) { - //EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + //EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); SUB_UseTargets( m_hActivator, USE_TOGGLE, 0 ); } @@ -1034,7 +1034,7 @@ void CMomentaryRotButton::KeyValue( KeyValueData *pkvd ) void CMomentaryRotButton::PlaySound( void ) { - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); } // BUGBUG: This design causes a latentcy. When the button is retriggered, the first impulse diff --git a/dlls/cbase.cpp b/dlls/cbase.cpp index 6009bfd5..8750bddf 100644 --- a/dlls/cbase.cpp +++ b/dlls/cbase.cpp @@ -605,7 +605,7 @@ int CBaseEntity::Restore( CRestore &restore ) mins = pev->mins; // Set model is about to destroy these maxs = pev->maxs; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); UTIL_SetSize( pev, mins, maxs ); // Reset them } diff --git a/dlls/doors.cpp b/dlls/doors.cpp index 90678df6..c12cc3a0 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -127,7 +127,7 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton if( fplaysound ) { // play 'door locked' sound - EMIT_SOUND( ENT( pev ), CHAN_ITEM, (char*)STRING( pls->sLockedSound ), fvol, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, STRING( pls->sLockedSound ), fvol, ATTN_NORM ); pls->flwaitSound = gpGlobals->time + flsoundwait; } @@ -164,7 +164,7 @@ void PlayLockSounds( entvars_t *pev, locksound_t *pls, int flocked, int fbutton // play 'door unlocked' sound if set if( fplaysound ) { - EMIT_SOUND( ENT( pev ), CHAN_ITEM, (char*)STRING( pls->sUnlockedSound ), fvol, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, STRING( pls->sUnlockedSound ), fvol, ATTN_NORM ); pls->flwaitSound = gpGlobals->time + flsoundwait; } @@ -606,7 +606,7 @@ void CBaseDoor::DoorGoUp( void ) // filter them out and leave a client stuck with looping door sounds! if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) if( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); m_toggle_state = TS_GOING_UP; @@ -646,8 +646,8 @@ void CBaseDoor::DoorHitTop( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); } ASSERT( m_toggle_state == TS_GOING_UP ); @@ -686,7 +686,7 @@ void CBaseDoor::DoorGoDown( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) if( m_toggle_state != TS_GOING_UP && m_toggle_state != TS_GOING_DOWN ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); #ifdef DOOR_ASSERT ASSERT( m_toggle_state == TS_AT_TOP ); #endif // DOOR_ASSERT @@ -706,8 +706,8 @@ void CBaseDoor::DoorHitBottom( void ) { if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) { - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); } ASSERT( m_toggle_state == TS_GOING_DOWN ); @@ -751,7 +751,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) { // BMod Start - Door sound fix. if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); // BMod End if( m_toggle_state == TS_GOING_DOWN ) @@ -767,7 +767,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) // Block all door pieces with the same targetname here. if( !FStringNull( pev->targetname ) ) { - for(;;) + for( ; ; ) { pentTarget = FIND_ENTITY_BY_TARGETNAME( pentTarget, STRING( pev->targetname ) ); @@ -799,7 +799,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) } } if( !FBitSet( pev->spawnflags, SF_DOOR_SILENT ) ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); if( pDoor->m_toggle_state == TS_GOING_DOWN ) pDoor->DoorGoUp(); @@ -1106,7 +1106,7 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP // This entity only thinks when it moves, so if it's thinking, it's in the process of moving // play the sound when it starts moving(not yet thinking) if( pev->nextthink < pev->ltime || pev->nextthink == 0 ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ), 1, ATTN_NORM ); // If we already moving to designated point, return else if( move == m_vecFinalDest ) return; @@ -1118,6 +1118,6 @@ void CMomentaryDoor::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP void CMomentaryDoor::MomentaryMoveDone( void ) { - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMoving ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseArrived ), 1, ATTN_NORM ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMoving ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseArrived ), 1, ATTN_NORM ); } diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 2977a3ed..c3216835 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -229,7 +229,7 @@ void CBeam::BeamInit( const char *pSpriteName, int width ) SetFrame( 0 ); SetScrollRate( 0 ); pev->model = MAKE_STRING( pSpriteName ); - SetTexture( PRECACHE_MODEL( (char *)pSpriteName ) ); + SetTexture( PRECACHE_MODEL( pSpriteName ) ); SetWidth( width ); pev->skin = 0; pev->sequence = 0; @@ -486,7 +486,7 @@ void CLightning::Spawn( void ) void CLightning::Precache( void ) { - m_spriteTexture = PRECACHE_MODEL( (char *)STRING( m_iszSpriteName ) ); + m_spriteTexture = PRECACHE_MODEL( STRING( m_iszSpriteName ) ); CBeam::Precache(); } @@ -954,9 +954,9 @@ void CLaser::Spawn( void ) void CLaser::Precache( void ) { - pev->modelindex = PRECACHE_MODEL( (char *)STRING( pev->model ) ); + pev->modelindex = PRECACHE_MODEL( STRING( pev->model ) ); if( m_iszSpriteName ) - PRECACHE_MODEL( (char *)STRING( m_iszSpriteName ) ); + PRECACHE_MODEL( STRING( m_iszSpriteName ) ); } void CLaser::KeyValue( KeyValueData *pkvd ) @@ -1100,7 +1100,7 @@ void CGlow::Spawn( void ) pev->effects = 0; pev->frame = 0; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_maxFrame = (float) MODEL_FRAMES( pev->modelindex ) - 1; @@ -1160,7 +1160,7 @@ void CSprite::Spawn( void ) void CSprite::Precache( void ) { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); // Reset attachment after save/restore if( pev->aiment ) @@ -1515,7 +1515,7 @@ void CEnvShooter::KeyValue( KeyValueData *pkvd ) void CEnvShooter::Precache( void ) { - m_iGibModelIndex = PRECACHE_MODEL( (char *)STRING( pev->model ) ); + m_iGibModelIndex = PRECACHE_MODEL( STRING( pev->model ) ); CBreakable::MaterialSoundPrecache( (Materials)m_iGibMaterial ); } @@ -2005,7 +2005,7 @@ void CMessage::Spawn( void ) void CMessage::Precache( void ) { if( pev->noise ) - PRECACHE_SOUND( (char *)STRING( pev->noise ) ); + PRECACHE_SOUND( STRING( pev->noise ) ); } void CMessage::KeyValue( KeyValueData *pkvd ) @@ -2040,16 +2040,15 @@ void CMessage::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useT if( pActivator && pActivator->IsPlayer() ) pPlayer = pActivator; else - { pPlayer = CBaseEntity::Instance( g_engfuncs.pfnPEntityOfEntIndex( 1 ) ); - } + if( pPlayer ) UTIL_ShowMessage( STRING( pev->message ), pPlayer ); } + if( pev->noise ) - { EMIT_SOUND( edict(), CHAN_BODY, STRING( pev->noise ), pev->scale, pev->speed ); - } + if( pev->spawnflags & SF_MESSAGE_ONCE ) UTIL_Remove( this ); @@ -2071,7 +2070,7 @@ public: void CEnvFunnel::Precache( void ) { - m_iSprite = PRECACHE_MODEL ( "sprites/flare6.spr" ); + m_iSprite = PRECACHE_MODEL( "sprites/flare6.spr" ); } LINK_ENTITY_TO_CLASS( env_funnel, CEnvFunnel ) diff --git a/dlls/func_break.cpp b/dlls/func_break.cpp index 6abf1b44..0cc3675f 100644 --- a/dlls/func_break.cpp +++ b/dlls/func_break.cpp @@ -259,7 +259,7 @@ void CBreakable::MaterialSoundPrecache( Materials precacheMaterial ) for( i = 0; i < soundCount; i++ ) { - PRECACHE_SOUND( (char *)pSoundList[i] ); + PRECACHE_SOUND( pSoundList[i] ); } } @@ -340,11 +340,11 @@ void CBreakable::Precache( void ) if( m_iszGibModel ) pGibName = STRING( m_iszGibModel ); - m_idShard = PRECACHE_MODEL( (char *)pGibName ); + m_idShard = PRECACHE_MODEL( pGibName ); // Precache the spawn item's data if( m_iszSpawnObject ) - UTIL_PrecacheOther( (char *)STRING( m_iszSpawnObject ) ); + UTIL_PrecacheOther( STRING( m_iszSpawnObject ) ); } // play shard sound when func_breakable takes damage. @@ -746,7 +746,7 @@ void CBreakable::Die( void ) SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = pev->ltime + 0.1; if( m_iszSpawnObject ) - CBaseEntity::Create( (char *)STRING( m_iszSpawnObject ), VecBModelOrigin( pev ), pev->angles, edict() ); + CBaseEntity::Create( STRING( m_iszSpawnObject ), VecBModelOrigin( pev ), pev->angles, edict() ); if( Explodable() ) { diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index c4e3cb42..6eebc675 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -200,13 +200,13 @@ void CFuncTank::Spawn( void ) void CFuncTank::Precache( void ) { if( m_iszSpriteSmoke ) - PRECACHE_MODEL( (char *)STRING( m_iszSpriteSmoke ) ); + PRECACHE_MODEL( STRING( m_iszSpriteSmoke ) ); if( m_iszSpriteFlash ) - PRECACHE_MODEL( (char *)STRING( m_iszSpriteFlash ) ); + PRECACHE_MODEL( STRING( m_iszSpriteFlash ) ); if( pev->noise ) - PRECACHE_SOUND( (char *)STRING( pev->noise ) ); + PRECACHE_SOUND( STRING( pev->noise ) ); } void CFuncTank::KeyValue( KeyValueData *pkvd ) @@ -688,13 +688,13 @@ void CFuncTank::StartRotSound( void ) if( !pev->noise || ( pev->spawnflags & SF_TANK_SOUNDON ) ) return; pev->spawnflags |= SF_TANK_SOUNDON; - EMIT_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noise ), 0.85, ATTN_NORM ); + EMIT_SOUND( edict(), CHAN_STATIC, STRING( pev->noise ), 0.85, ATTN_NORM ); } void CFuncTank::StopRotSound( void ) { if( pev->spawnflags & SF_TANK_SOUNDON ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noise ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noise ) ); pev->spawnflags &= ~SF_TANK_SOUNDON; } diff --git a/dlls/gargantua.cpp b/dlls/gargantua.cpp index 6aa6a738..f3155d7f 100644 --- a/dlls/gargantua.cpp +++ b/dlls/gargantua.cpp @@ -770,37 +770,37 @@ void CGargantua::Precache() PRECACHE_SOUND( GARG_STOMP_BUZZ_SOUND ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pBeamAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pBeamAttackSounds[i] ); + PRECACHE_SOUND( pBeamAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pRicSounds ); i++ ) - PRECACHE_SOUND( (char *)pRicSounds[i] ); + PRECACHE_SOUND( pRicSounds[i] ); for( i = 0; i < ARRAYSIZE( pFootSounds ); i++ ) - PRECACHE_SOUND( (char *)pFootSounds[i] ); + PRECACHE_SOUND( pFootSounds[i] ); for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( (char *)pIdleSounds[i] ); + PRECACHE_SOUND( pIdleSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND((char *)pAlertSounds[i]); + PRECACHE_SOUND( pAlertSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( (char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pStompSounds ); i++ ) - PRECACHE_SOUND( (char *)pStompSounds[i] ); + PRECACHE_SOUND( pStompSounds[i] ); for( i = 0; i < ARRAYSIZE( pBreatheSounds ); i++ ) - PRECACHE_SOUND( (char *)pBreatheSounds[i] ); + PRECACHE_SOUND( pBreatheSounds[i] ); } void CGargantua::UpdateOnRemove() diff --git a/dlls/genericmonster.cpp b/dlls/genericmonster.cpp index 23622120..3cc0acc6 100644 --- a/dlls/genericmonster.cpp +++ b/dlls/genericmonster.cpp @@ -131,7 +131,7 @@ void CGenericMonster::Spawn() //========================================================= void CGenericMonster::Precache() { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); } //========================================================= diff --git a/dlls/h_cycler.cpp b/dlls/h_cycler.cpp index e920abfa..5daad4a2 100644 --- a/dlls/h_cycler.cpp +++ b/dlls/h_cycler.cpp @@ -67,7 +67,7 @@ class CGenericCycler : public CCycler public: void Spawn( void ) { - GenericCyclerSpawn( (char *)STRING( pev->model ), Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) ); + GenericCyclerSpawn( STRING( pev->model ), Vector( -16, -16, 0 ), Vector( 16, 16, 72 ) ); } }; @@ -255,7 +255,7 @@ void CCyclerSprite::Spawn( void ) m_animate = 1; m_lastTime = gpGlobals->time; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_maxFrame = (float)MODEL_FRAMES( pev->modelindex ) - 1; @@ -314,7 +314,7 @@ void CWeaponCycler::Spawn() pev->solid = SOLID_SLIDEBOX; pev->movetype = MOVETYPE_NONE; - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); m_iszModel = pev->model; m_iModel = pev->modelindex; @@ -401,7 +401,7 @@ void CWreckage::Spawn( void ) if( pev->model ) { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); } // pev->scale = 5.0; @@ -412,7 +412,7 @@ void CWreckage::Spawn( void ) void CWreckage::Precache() { if( pev->model ) - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); } void CWreckage::Think( void ) diff --git a/dlls/islave.cpp b/dlls/islave.cpp index 51def5d3..b516c09b 100644 --- a/dlls/islave.cpp +++ b/dlls/islave.cpp @@ -544,16 +544,16 @@ void CISlave::Precache() PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND((char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); for( i = 0; i < ARRAYSIZE( pDeathSounds ); i++ ) - PRECACHE_SOUND( (char *)pDeathSounds[i] ); + PRECACHE_SOUND( pDeathSounds[i] ); UTIL_PrecacheOther( "test_effect" ); } diff --git a/dlls/leech.cpp b/dlls/leech.cpp index dccffcf4..1d64eae1 100644 --- a/dlls/leech.cpp +++ b/dlls/leech.cpp @@ -277,9 +277,9 @@ void CLeech::Precache( void ) PRECACHE_MODEL( "models/leech.mdl" ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( (char *)pAlertSounds[i] ); + PRECACHE_SOUND( pAlertSounds[i] ); } int CLeech::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index a898158f..5e06f909 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -92,7 +92,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() if( IS_DEDICATED_SERVER() ) { // dedicated server - /*char *servercfgfile = (char *)CVAR_GET_STRING( "servercfgfile" ); + /*const char *servercfgfile = CVAR_GET_STRING( "servercfgfile" ); if( servercfgfile && servercfgfile[0] ) { @@ -108,7 +108,7 @@ CHalfLifeMultiplay::CHalfLifeMultiplay() else { // listen server - char *lservercfgfile = (char *)CVAR_GET_STRING( "lservercfgfile" ); + const char *lservercfgfile = CVAR_GET_STRING( "lservercfgfile" ); if( lservercfgfile && lservercfgfile[0] ) { @@ -1214,7 +1214,7 @@ COM_Parse Parse a token out of a string ============== */ -char *COM_Parse( char *data ) +const char *COM_Parse( const char *data ) { int c; int len; @@ -1290,9 +1290,9 @@ COM_TokenWaiting Returns 1 if additional data is waiting to be processed on this line ============== */ -int COM_TokenWaiting( char *buffer ) +int COM_TokenWaiting( const char *buffer ) { - char *p; + const char *p; p = buffer; while( *p && *p!='\n') @@ -1313,12 +1313,12 @@ ReloadMapCycleFile Parses mapcycle.txt file into mapcycle_t structure ============== */ -int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) +int ReloadMapCycleFile( const char *filename, mapcycle_t *cycle ) { char szMap[32]; int length; - char *pFileList; - char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( filename, &length ); + const char *pFileList; + const char *aFileList = pFileList = (const char *)LOAD_FILE_FOR_ME( filename, &length ); int hasbuffer; mapcycle_item_s *item, *newlist = NULL, *next; @@ -1396,7 +1396,7 @@ int ReloadMapCycleFile( char *filename, mapcycle_t *cycle ) } } - FREE_FILE( aFileList ); + FREE_FILE( (void*)aFileList ); } // Fixup circular list pointer @@ -1532,7 +1532,7 @@ void CHalfLifeMultiplay::ChangeLevel( void ) BOOL do_cycle = TRUE; // find the map to change to - char *mapcfile = (char*)CVAR_GET_STRING( "mapcyclefile" ); + const char *mapcfile = CVAR_GET_STRING( "mapcyclefile" ); ASSERT( mapcfile != NULL ); szCommands[0] = '\0'; @@ -1650,8 +1650,8 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) { // read from the MOTD.txt file int length, char_count = 0; - char *pFileList; - char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( (char *)CVAR_GET_STRING( "motdfile" ), &length ); + const char *pFileList; + const char *aFileList = pFileList = (const char*)LOAD_FILE_FOR_ME( CVAR_GET_STRING( "motdfile" ), &length ); // send the server name MESSAGE_BEGIN( MSG_ONE, gmsgServerName, NULL, client ); @@ -1679,7 +1679,7 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) if( char_count < MAX_MOTD_LENGTH ) pFileList = aFileList + char_count; else - *pFileList = 0; + pFileList = 0; MESSAGE_BEGIN( MSG_ONE, gmsgMOTD, NULL, client ); WRITE_BYTE( *pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come @@ -1687,5 +1687,5 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) MESSAGE_END(); } - FREE_FILE( aFileList ); + FREE_FILE( (void*)aFileList ); } diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index 68a1c267..b94f894b 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -2108,7 +2108,7 @@ void CTestHull::BuildNodeGraph( void ) WorldGraph.ComputeStaticRoutingTables(); // save the node graph for this level - WorldGraph.FSaveGraph( (char *)STRING( gpGlobals->mapname ) ); + WorldGraph.FSaveGraph( STRING( gpGlobals->mapname ) ); ALERT( at_console, "Done.\n" ); } @@ -2363,7 +2363,7 @@ void CQueuePriority::Heap_SiftUp( void ) // will be loaded. If file cannot be loaded, the node tree // will be created and saved to disk. //========================================================= -int CGraph::FLoadGraph( char *szMapName ) +int CGraph::FLoadGraph( const char *szMapName ) { char szFilename[MAX_PATH]; int iVersion; @@ -2542,7 +2542,7 @@ NoMemory: // CGraph - FSaveGraph - It's not rocket science. // this WILL overwrite existing files. //========================================================= -int CGraph::FSaveGraph( char *szMapName ) +int CGraph::FSaveGraph( const char *szMapName ) { int iVersion = GRAPH_VERSION; char szFilename[MAX_PATH]; @@ -2674,7 +2674,7 @@ int CGraph::FSetGraphPointers( void ) // though. ( I now suspect that we are getting GMT back from // these functions and must compensate for local time ) (sjb) //========================================================= -int CGraph::CheckNODFile( char *szMapName ) +int CGraph::CheckNODFile( const char *szMapName ) { int retValue; diff --git a/dlls/nodes.h b/dlls/nodes.h index 29440025..49036a39 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -182,9 +182,9 @@ public: void InitGraph( void ); int AllocNodes ( void ); - int CheckNODFile(char *szMapName); - int FLoadGraph(char *szMapName); - int FSaveGraph(char *szMapName); + int CheckNODFile(const char *szMapName); + int FLoadGraph(const char *szMapName); + int FSaveGraph(const char *szMapName); int FSetGraphPointers(void); void CheckNode(Vector vecOrigin, int iNode); diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 3034fd93..1e6de4bf 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -416,7 +416,7 @@ void CFuncPlat::PlatUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE void CFuncPlat::GoDown( void ) { if( pev->noiseMovement ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_AT_TOP || m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_GOING_DOWN; @@ -430,10 +430,10 @@ void CFuncPlat::GoDown( void ) void CFuncPlat::HitBottom( void ) { if( pev->noiseMovement ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_AT_BOTTOM; @@ -445,7 +445,7 @@ void CFuncPlat::HitBottom( void ) void CFuncPlat::GoUp( void ) { if( pev->noiseMovement ) - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_AT_BOTTOM || m_toggle_state == TS_GOING_DOWN ); m_toggle_state = TS_GOING_UP; @@ -459,10 +459,10 @@ void CFuncPlat::GoUp( void ) void CFuncPlat::HitTop( void ) { if( pev->noiseMovement ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_WEAPON, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_WEAPON, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); ASSERT( m_toggle_state == TS_GOING_UP ); m_toggle_state = TS_AT_TOP; @@ -482,7 +482,7 @@ void CFuncPlat::Blocked( CBaseEntity *pOther ) pOther->TakeDamage( pev, pev, 1, DMG_CRUSH ); if( pev->noiseMovement ) - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ) ); // Send the platform back where it came from ASSERT( m_toggle_state == TS_GOING_UP || m_toggle_state == TS_GOING_DOWN ); @@ -670,7 +670,7 @@ void CFuncTrain::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE us pev->nextthink = 0; pev->velocity = g_vecZero; if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); } } @@ -691,9 +691,9 @@ void CFuncTrain::Wait( void ) // clear the sound channel. if( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); pev->nextthink = 0; return; } @@ -704,9 +704,9 @@ void CFuncTrain::Wait( void ) // -1 wait will wait forever! pev->nextthink = pev->ltime + m_flWait; if( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); SetThink( &CFuncTrain::Next ); } else @@ -728,10 +728,10 @@ void CFuncTrain::Next( void ) if( !pTarg ) { if( pev->noiseMovement ) - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); // Play stop sound if( pev->noiseStopMoving ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM ); return; } @@ -767,8 +767,8 @@ void CFuncTrain::Next( void ) // this is not a hack or temporary fix, this is how things should be. (sjb). if( pev->noiseMovement ) { - STOP_SOUND( edict(), CHAN_STATIC, (char*)STRING( pev->noiseMovement ) ); - EMIT_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); + STOP_SOUND( edict(), CHAN_STATIC, STRING( pev->noiseMovement ) ); + EMIT_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noiseMovement ), m_volume, ATTN_NORM ); } ClearBits( pev->effects, EF_NOINTERP ); @@ -1061,7 +1061,7 @@ void CFuncTrackTrain::StopSound( void ) PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_UPDATE, edict(), m_usAdjustPitch, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, us_encode, 0, 1, 0 ); /* - STOP_SOUND( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ) ); + STOP_SOUND( ENT( pev ), CHAN_STATIC, STRING( pev->noise ) ); */ EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "plats/ttrain_brake1.wav", m_flVolume, ATTN_NORM, 0, 100 ); } @@ -1085,14 +1085,14 @@ void CFuncTrackTrain::UpdateSound( void ) { // play startup sound for train EMIT_SOUND_DYN( ENT( pev ), CHAN_ITEM, "plats/ttrain_start1.wav", m_flVolume, ATTN_NORM, 0, 100 ); - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ), m_flVolume, ATTN_NORM, 0, (int)flpitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noise ), m_flVolume, ATTN_NORM, 0, (int)flpitch ); m_soundPlaying = 1; } else { /* // update pitch - EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, (char*)STRING( pev->noise ), m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, (int)flpitch ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_STATIC, STRING( pev->noise ), m_flVolume, ATTN_NORM, SND_CHANGE_PITCH, (int)flpitch ); */ // volume 0.0 - 1.0 - 6 bits // m_sounds 3 bits @@ -1322,7 +1322,7 @@ BOOL CFuncTrackTrain::OnControls( entvars_t *pevTest ) void CFuncTrackTrain::Find( void ) { - m_ppath = CPathTrack::Instance(FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); + m_ppath = CPathTrack::Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( pev->target ) ) ); if( !m_ppath ) return; diff --git a/dlls/prop.cpp b/dlls/prop.cpp index c6c4017e..7f7dba48 100644 --- a/dlls/prop.cpp +++ b/dlls/prop.cpp @@ -248,7 +248,7 @@ void CProp::MaterialSoundPrecache( Materials precacheMaterial ) for( i = 0; i < soundCount; i++ ) { - PRECACHE_SOUND( (char *)pSoundList[i] ); + PRECACHE_SOUND( pSoundList[i] ); } } @@ -327,8 +327,8 @@ void CProp::Precache( void ) if( m_iszGibModel ) pGibName = STRING( m_iszGibModel ); - m_idShard = PRECACHE_MODEL( (char *)pGibName ); - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + m_idShard = PRECACHE_MODEL( pGibName ); + PRECACHE_MODEL( STRING( pev->model ) ); } void CProp::DamageSound( void ) diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index da9708d1..678502f6 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -712,7 +712,7 @@ void CCineMonster::DelayStart( int state ) else { pTarget->m_iDelay--; - if (pTarget->m_iDelay <= 0) + if( pTarget->m_iDelay <= 0 ) pTarget->m_startTime = gpGlobals->time + 0.05; } } @@ -1177,7 +1177,7 @@ void CFurniture::Die( void ) //========================================================= void CFurniture::Spawn() { - PRECACHE_MODEL( (char *)STRING( pev->model ) ); + PRECACHE_MODEL( STRING( pev->model ) ); SET_MODEL( ENT( pev ), STRING( pev->model ) ); pev->movetype = MOVETYPE_NONE; diff --git a/dlls/sound.cpp b/dlls/sound.cpp index f6110a8d..85b9f71d 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -182,7 +182,7 @@ void CAmbientGeneric::Spawn( void ) m_flAttenuation = ATTN_STATIC; } - char* szSoundFile = (char*)STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); if( FStringNull( pev->message ) || strlen( szSoundFile ) < 1 ) { @@ -216,7 +216,7 @@ void CAmbientGeneric::Spawn( void ) void CAmbientGeneric::Precache( void ) { - char* szSoundFile = (char*)STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); if( !FStringNull( pev->message ) && strlen( szSoundFile ) > 1 ) { @@ -248,7 +248,7 @@ void CAmbientGeneric::Precache( void ) // with lfo if active. void CAmbientGeneric::RampThink( void ) { - char* szSoundFile = (char*) STRING(pev->message); + const char *szSoundFile = STRING( pev->message ); int pitch = m_dpv.pitch; int vol = m_dpv.vol; int flags = 0; @@ -533,7 +533,7 @@ void CAmbientGeneric::InitModulationParms( void ) // void CAmbientGeneric::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { - char* szSoundFile = (char*)STRING( pev->message ); + const char *szSoundFile = STRING( pev->message ); float fraction; if( useType != USE_TOGGLE ) diff --git a/dlls/stats.cpp b/dlls/stats.cpp index 9b21f792..1df298b2 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -48,7 +48,7 @@ float AmmoDamage( const char *pName ) return 0; } -void UpdateStatsFile( float dataTime, char *pMapname, float health, float ammo, int skillLevel ) +void UpdateStatsFile( float dataTime, const char *pMapname, float health, float ammo, int skillLevel ) { FILE *fp; @@ -136,7 +136,7 @@ void UpdateStats( CBasePlayer *pPlayer ) } else if( ( gStats.nextOutputTime != 0 && gStats.nextOutputTime < gStats.gameTime ) || forceWrite ) { - UpdateStatsFile( gStats.dataTime, (char *)STRING( gpGlobals->mapname ), health, ammo, (int)CVAR_GET_FLOAT( "skill" ) ); + UpdateStatsFile( gStats.dataTime, STRING( gpGlobals->mapname ), health, ammo, (int)CVAR_GET_FLOAT( "skill" ) ); gStats.lastAmmo = ammo; gStats.lastHealth = health; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 57d8d031..8171a195 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -527,7 +527,7 @@ void CBaseTrigger::InitTrigger() SetMovedir( pev ); pev->solid = SOLID_TRIGGER; pev->movetype = MOVETYPE_NONE; - SET_MODEL(ENT(pev), STRING( pev->model ) ); // set size and link into world + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // set size and link into world if( CVAR_GET_FLOAT( "showtriggers" ) == 0 ) SetBits( pev->effects, EF_NODRAW ); } @@ -1135,7 +1135,7 @@ void CBaseTrigger::ActivateMultiTrigger( CBaseEntity *pActivator ) } if( !FStringNull( pev->noise ) ) - EMIT_SOUND( ENT( pev ), CHAN_VOICE, (char*)STRING( pev->noise ), 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, STRING( pev->noise ), 1, ATTN_NORM ); // don't trigger again until reset // pev->takedamage = DAMAGE_NO; @@ -1264,7 +1264,7 @@ void CTriggerVolume::Spawn( void ) { pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - SET_MODEL( ENT(pev), STRING( pev->model ) ); // set size and link into world + SET_MODEL( ENT( pev ), STRING( pev->model ) ); // set size and link into world pev->model = 0; pev->modelindex = 0; } @@ -1338,7 +1338,7 @@ TYPEDESCRIPTION CChangeLevel::m_SaveData[] = DEFINE_FIELD( CChangeLevel, m_changeTargetDelay, FIELD_FLOAT ), }; -IMPLEMENT_SAVERESTORE(CChangeLevel,CBaseTrigger) +IMPLEMENT_SAVERESTORE( CChangeLevel, CBaseTrigger ) // // Cache user-entity-field values until spawn is called. diff --git a/dlls/util.cpp b/dlls/util.cpp index bca89948..68ba30cd 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1052,7 +1052,7 @@ Vector UTIL_GetAimVector( edict_t *pent, float flSpeed ) return tmp; } -int UTIL_IsMasterTriggered(string_t sMaster, CBaseEntity *pActivator) +int UTIL_IsMasterTriggered( string_t sMaster, CBaseEntity *pActivator ) { if( sMaster ) { @@ -1340,7 +1340,7 @@ void UTIL_StringToVector( float *pVector, const char *pString ) while( *pstr && *pstr != ' ' ) pstr++; - if( !(*pstr) ) + if( !( *pstr ) ) break; pstr++; pfront = pstr; @@ -1858,7 +1858,7 @@ void CSave::WriteString( const char *pname, const int *stringId, int count ) #if 0 if( count != 1 ) ALERT( at_error, "No string arrays!\n" ); - WriteString( pname, (char *)STRING( *stringId ) ); + WriteString( pname, STRING( *stringId ) ); #endif size = 0; for( i = 0; i < count; i++ ) @@ -2209,9 +2209,9 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou if( !FStringNull( string ) && m_precache ) { if( pTest->fieldType == FIELD_MODELNAME ) - PRECACHE_MODEL( (char *)STRING( string ) ); + PRECACHE_MODEL( STRING( string ) ); else if( pTest->fieldType == FIELD_SOUNDNAME ) - PRECACHE_SOUND( (char *)STRING( string ) ); + PRECACHE_SOUND( STRING( string ) ); } } break; diff --git a/dlls/util.h b/dlls/util.h index c13271b0..2ffe536e 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -542,7 +542,7 @@ void EMIT_GROUPID_SUIT(edict_t *entity, int isentenceg); void EMIT_GROUPNAME_SUIT(edict_t *entity, const char *groupname); #define PRECACHE_SOUND_ARRAY( a ) \ - { for (int i = 0; i < (int)ARRAYSIZE( a ); i++ ) PRECACHE_SOUND((char *) a [i]); } + { for (int i = 0; i < (int)ARRAYSIZE( a ); i++ ) PRECACHE_SOUND( a[i] ); } #define EMIT_SOUND_ARRAY_DYN( chan, array ) \ EMIT_SOUND_DYN ( ENT(pev), chan , array [ RANDOM_LONG(0,ARRAYSIZE( array )-1) ], 1.0, ATTN_NORM, 0, RANDOM_LONG(95,105) ); diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 06bb1796..a1205f27 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -367,7 +367,7 @@ void W_Precache( void ) g_sModelIndexBloodSpray = PRECACHE_MODEL( "sprites/bloodspray.spr" ); // initial blood g_sModelIndexBloodDrop = PRECACHE_MODEL( "sprites/blood.spr" ); // splattered blood - g_sModelIndexLaser = PRECACHE_MODEL( (char *)g_pModelNameLaser ); + g_sModelIndexLaser = PRECACHE_MODEL( g_pModelNameLaser ); g_sModelIndexLaserDot = PRECACHE_MODEL( "sprites/laserdot.spr" ); // used by explosions @@ -535,7 +535,7 @@ CBaseEntity* CBasePlayerItem::Respawn( void ) { // make a copy of this weapon that is invisible and inaccessible to players (no touch function). The weapon spawn/respawn code // will decide when to make the weapon visible and touchable. - CBaseEntity *pNewWeapon = CBaseEntity::Create( (char *)STRING( pev->classname ), g_pGameRules->VecWeaponRespawnSpot( this ), pev->angles, pev->owner ); + CBaseEntity *pNewWeapon = CBaseEntity::Create( STRING( pev->classname ), g_pGameRules->VecWeaponRespawnSpot( this ), pev->angles, pev->owner ); if( pNewWeapon ) { @@ -1297,7 +1297,7 @@ void CWeaponBox::Touch( CBaseEntity *pOther ) if( !FStringNull( m_rgiszAmmo[i] ) ) { // there's some ammo of this type. - pPlayer->GiveAmmo( m_rgAmmo[i], (char *)STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); + pPlayer->GiveAmmo( m_rgAmmo[i], STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); //ALERT( at_console, "Gave %d rounds of %s\n", m_rgAmmo[i], STRING( m_rgiszAmmo[i] ) ); @@ -1407,7 +1407,7 @@ BOOL CWeaponBox::PackAmmo( int iszName, int iCount ) if( iMaxCarry != -1 && iCount > 0 ) { //ALERT( at_console, "Packed %d rounds of %s\n", iCount, STRING( iszName ) ); - GiveAmmo( iCount, (char *)STRING( iszName ), iMaxCarry ); + GiveAmmo( iCount, STRING( iszName ), iMaxCarry ); return TRUE; } diff --git a/dlls/world.cpp b/dlls/world.cpp index 1cc645c9..3b9a1f1e 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -592,7 +592,7 @@ void CWorld::Precache( void ) WorldGraph.InitGraph(); // make sure the .NOD file is newer than the .BSP file. - if( !WorldGraph.CheckNODFile( ( char * )STRING( gpGlobals->mapname ) ) ) + if( !WorldGraph.CheckNODFile( STRING( gpGlobals->mapname ) ) ) { // NOD file is not present, or is older than the BSP file. WorldGraph.AllocNodes(); @@ -600,7 +600,7 @@ void CWorld::Precache( void ) else { // Load the node graph for this level - if( !WorldGraph.FLoadGraph ( (char *)STRING( gpGlobals->mapname ) ) ) + if( !WorldGraph.FLoadGraph( STRING( gpGlobals->mapname ) ) ) { // couldn't load, so alloc and prepare to build a graph. ALERT( at_console, "*Error opening .NOD file\n" ); diff --git a/dlls/xen.cpp b/dlls/xen.cpp index 4e9e1685..1d86beb3 100644 --- a/dlls/xen.cpp +++ b/dlls/xen.cpp @@ -444,9 +444,9 @@ CXenHull *CXenHull::CreateHull( CBaseEntity *source, const Vector &mins, const V CXenHull *pHull = GetClassPtr( (CXenHull *)NULL ); UTIL_SetOrigin( pHull->pev, source->pev->origin + offset ); - SET_MODEL( pHull->edict(), STRING(source->pev->model) ); + SET_MODEL( pHull->edict(), STRING( source->pev->model ) ); pHull->pev->solid = SOLID_BBOX; - pHull->pev->classname = MAKE_STRING("xen_hull"); + pHull->pev->classname = MAKE_STRING( "xen_hull" ); pHull->pev->movetype = MOVETYPE_NONE; pHull->pev->owner = source->edict(); UTIL_SetSize( pHull->pev, mins, maxs ); @@ -527,7 +527,7 @@ const char *CXenSpore::pModelNames[] = void CXenSpore::Precache( void ) { - PRECACHE_MODEL( (char *)pModelNames[pev->skin] ); + PRECACHE_MODEL( pModelNames[pev->skin] ); } void CXenSpore::Touch( CBaseEntity *pOther ) diff --git a/dlls/zombie.cpp b/dlls/zombie.cpp index 2611f881..96f032e6 100644 --- a/dlls/zombie.cpp +++ b/dlls/zombie.cpp @@ -266,7 +266,7 @@ void CZombie::Spawn() { Precache(); - SET_MODEL( ENT(pev), "models/zombie.mdl" ); + SET_MODEL( ENT( pev ), "models/zombie.mdl" ); UTIL_SetSize( pev, VEC_HUMAN_HULL_MIN, VEC_HUMAN_HULL_MAX ); pev->solid = SOLID_SLIDEBOX; @@ -291,22 +291,22 @@ void CZombie::Precache() PRECACHE_MODEL( "models/zombie.mdl" ); for( i = 0; i < ARRAYSIZE( pAttackHitSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackHitSounds[i] ); + PRECACHE_SOUND( pAttackHitSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackMissSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackMissSounds[i] ); + PRECACHE_SOUND( pAttackMissSounds[i] ); for( i = 0; i < ARRAYSIZE( pAttackSounds ); i++ ) - PRECACHE_SOUND( (char *)pAttackSounds[i] ); + PRECACHE_SOUND( pAttackSounds[i] ); for( i = 0; i < ARRAYSIZE( pIdleSounds ); i++ ) - PRECACHE_SOUND( (char *)pIdleSounds[i] ); + PRECACHE_SOUND( pIdleSounds[i] ); for( i = 0; i < ARRAYSIZE( pAlertSounds ); i++ ) - PRECACHE_SOUND( (char *)pAlertSounds[i] ); + PRECACHE_SOUND( pAlertSounds[i] ); for( i = 0; i < ARRAYSIZE( pPainSounds ); i++ ) - PRECACHE_SOUND( (char *)pPainSounds[i] ); + PRECACHE_SOUND( pPainSounds[i] ); } //========================================================= From 4150b464a047d87f398c8a9838a6a27fa3646418 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 24 Jul 2017 16:38:38 +0500 Subject: [PATCH 114/199] Improve spectator. --- dlls/client.cpp | 28 +++++++++++++++++++--------- dlls/observer.cpp | 23 +++++++++++++++++++++++ dlls/player.h | 1 + 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/dlls/client.cpp b/dlls/client.cpp index 569b1a53..32b6bebd 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -556,20 +556,30 @@ void ClientCommand( edict_t *pEntity ) } else if( FStrEq( pcmd, "spectate" ) ) // clients wants to become a spectator { - // always allow proxies to become a spectator - if( ( pev->flags & FL_PROXY ) || allow_spectators.value ) + CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + if( !pPlayer->IsObserver() ) { - CBasePlayer *pPlayer = GetClassPtr( (CBasePlayer *)pev ); + // always allow proxies to become a spectator + if( ( pev->flags & FL_PROXY ) || allow_spectators.value ) + { + edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); + pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); - edict_t *pentSpawnSpot = g_pGameRules->GetPlayerSpawnSpot( pPlayer ); - pPlayer->StartObserver( pev->origin, VARS( pentSpawnSpot )->angles ); - - // notify other clients of player switching to spectator mode - UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n", + // notify other clients of player switching to spectator mode + UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s switched to spectator mode\n", ( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) ); + } + else + ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" ); } else - ClientPrint( pev, HUD_PRINTCONSOLE, "Spectator mode is disabled.\n" ); + { + pPlayer->StopObserver(); + + // notify other clients of player left spectators + UTIL_ClientPrintAll( HUD_PRINTNOTIFY, UTIL_VarArgs( "%s has left spectator mode\n", + ( pev->netname && ( STRING( pev->netname ) )[0] != 0 ) ? STRING( pev->netname ) : "unconnected" ) ); + } } else if( FStrEq( pcmd, "specmode" ) ) // new spectator mode { diff --git a/dlls/observer.cpp b/dlls/observer.cpp index f3fc54a0..22fa3818 100644 --- a/dlls/observer.cpp +++ b/dlls/observer.cpp @@ -24,6 +24,10 @@ extern int gmsgCurWeapon; extern int gmsgSetFOV; +extern int gmsgTeamInfo; + +extern int g_teamplay; + // Find the next client in the game for this player to spectate void CBasePlayer::Observer_FindNextPlayer( bool bReverse ) { @@ -266,3 +270,22 @@ void CBasePlayer::Observer_SetMode( int iMode ) m_iObserverLastMode = iMode; } + +void CBasePlayer::StopObserver() +{ + // Turn off spectator + pev->iuser1 = pev->iuser2 = 0; + m_iHideHUD = 0; + + GetClassPtr( (CBasePlayer *)pev )->Spawn(); + pev->nextthink = -1; + + // Update Team Status + MESSAGE_BEGIN( MSG_ALL, gmsgTeamInfo ); + WRITE_BYTE( ENTINDEX( edict() ) ); // index number of primary entity + if( g_teamplay ) + WRITE_STRING( TeamID() ); + else + WRITE_STRING( "Players" ); + MESSAGE_END(); +} diff --git a/dlls/player.h b/dlls/player.h index 1c17556c..54e7fa85 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -255,6 +255,7 @@ public: void StartDeathCam( void ); void StartObserver( Vector vecPosition, Vector vecViewAngle ); + void StopObserver(); void AddPoints( int score, BOOL bAllowNegativeScore ); void AddPointsToTeam( int score, BOOL bAllowNegativeScore ); From aaf81c770994d179c43b39e4233299752dec7f44 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 24 Jul 2017 16:56:43 +0500 Subject: [PATCH 115/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/ef7cecf654ccf7716a5646ff9498928905a266dc --- pm_shared/pm_math.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pm_shared/pm_math.c b/pm_shared/pm_math.c index 5bbe0068..4bb4b93f 100644 --- a/pm_shared/pm_math.c +++ b/pm_shared/pm_math.c @@ -239,7 +239,7 @@ float AngleBetweenVectors( const vec3_t v1, const vec3_t v2 ) if( !l1 || !l2 ) return 0.0f; - angle = acos( DotProduct( v1, v2 ) ) / ( l1 * l2 ); + angle = acos( DotProduct( v1, v2 ) / ( l1 * l2 ) ); angle = ( angle * 180.0f ) / M_PI; return angle; From 96b1f4c58e8d8be9c1f743275b3ab562e50111ea Mon Sep 17 00:00:00 2001 From: mittorn Date: Sun, 30 Jul 2017 12:30:47 +0300 Subject: [PATCH 116/199] Fix wrong -std=c99 --- cl_dll/Android.mk | 1 - 1 file changed, 1 deletion(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index ecbae657..a79b6363 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -13,7 +13,6 @@ LOCAL_MODULE := client #else APP_PLATFORM := android-8 #endif -LOCAL_CONLYFLAGS += -std=c99 include $(XASH3D_CONFIG) From f14d7cc552dadde3756edddbf72a04251b620c9c Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 24 Jul 2017 23:07:59 +0500 Subject: [PATCH 117/199] A little fix. --- dlls/multiplay_gamerules.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 5e06f909..8d089696 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -1682,7 +1682,7 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) pFileList = 0; MESSAGE_BEGIN( MSG_ONE, gmsgMOTD, NULL, client ); - WRITE_BYTE( *pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come + WRITE_BYTE( pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come WRITE_STRING( chunk ); MESSAGE_END(); } From e3f953064dfe57f407d5129b432705d5d184af02 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 25 Jul 2017 13:24:06 +0500 Subject: [PATCH 118/199] Remove unneeded macros. --- dlls/enginecallback.h | 4 ---- engine/custom.h | 5 ----- engine/edict.h | 4 ---- engine/progdefs.h | 5 ----- pm_shared/pm_debug.h | 4 ---- pm_shared/pm_defs.h | 5 ----- pm_shared/pm_info.h | 4 ---- pm_shared/pm_shared.h | 4 ---- 8 files changed, 35 deletions(-) diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index 9bef0d48..a9e37c26 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -15,11 +15,7 @@ #ifndef ENGINECALLBACK_H #define ENGINECALLBACK_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #include "event_flags.h" diff --git a/engine/custom.h b/engine/custom.h index 8f644e00..30ee8d53 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -12,15 +12,10 @@ * without written permission from Valve LLC. * ****/ - #ifndef CUSTOM_H #define CUSTOM_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #include "const.h" diff --git a/engine/edict.h b/engine/edict.h index e89b6926..3994c705 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -16,11 +16,7 @@ #ifndef EDICT_H #define EDICT_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #define MAX_ENT_LEAFS 48 diff --git a/engine/progdefs.h b/engine/progdefs.h index cdbcc006..56d904b1 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -12,15 +12,10 @@ * without written permission from Valve LLC. * ****/ - #ifndef PROGDEFS_H #define PROGDEFS_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif typedef struct { diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index cc130598..417c3478 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -15,11 +15,7 @@ #ifndef PM_DEBUG_H #define PM_DEBUG_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif void PM_ViewEntity( void ); void PM_DrawBBox( vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life ); diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index b4c652ba..eddb17b6 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -12,15 +12,10 @@ * without written permission from Valve LLC. * ****/ - #ifndef PM_DEFS_H #define PM_DEFS_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #define MAX_PHYSENTS 600 // Must have room for all entities in the world. #define MAX_MOVEENTS 64 diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index d9dbc03d..d75b67fc 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -15,11 +15,7 @@ #ifndef PM_INFO_H #define PM_INFO_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif #define MAX_PHYSINFO_STRING 256 #endif//PM_INFO_H diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index 1d0e4f38..2fb947a2 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -16,11 +16,7 @@ #ifndef PM_SHARED_H #define PM_SHARED_H -#ifdef _WIN32 -#ifndef __MINGW32__ #pragma once -#endif /* not __MINGW32__ */ -#endif void PM_Init( struct playermove_s *ppmove ); void PM_Move( struct playermove_s *ppmove, int server ); From 65dc1997f7685b8cb6adc9ac1cb5594ca5f9c623 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Tue, 25 Jul 2017 23:52:50 +0500 Subject: [PATCH 119/199] Fix typo. --- dlls/plats.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/plats.cpp b/dlls/plats.cpp index 1e6de4bf..c1220f3c 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -1502,7 +1502,7 @@ void CFuncTrackTrain::Precache( void ) break; } - if( !pszSound ) + if( pszSound ) { PRECACHE_SOUND( pszSound ); pev->noise = MAKE_STRING( pszSound ); From 46ecb7e8eecc446472504f0112cb80fc0b64d4b4 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 9 Oct 2017 19:51:51 +0500 Subject: [PATCH 120/199] Fix shadowing variables. --- cl_dll/ev_hldm.cpp | 16 ++++++++-------- cl_dll/view.cpp | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index d94f9fea..80073b27 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -38,7 +38,7 @@ extern engine_studio_api_t IEngineStudio; -static int tracerCount[32]; +static int g_tracerCount[32]; extern "C" char PM_FindTextureType( char *name ); @@ -546,7 +546,7 @@ void EV_FireGlock2( event_args_t *args ) VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } //====================== // GLOCK END @@ -602,11 +602,11 @@ void EV_FireShotGunDouble( event_args_t *args ) if( gEngfuncs.GetMaxClients() > 1 ) { - EV_HLDM_FireBullets( idx, forward, right, up, 8, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.17365, 0.04362 ); + EV_HLDM_FireBullets( idx, forward, right, up, 8, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.17365, 0.04362 ); } else { - EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 ); + EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.08716 ); } } @@ -654,11 +654,11 @@ void EV_FireShotGunSingle( event_args_t *args ) if( gEngfuncs.GetMaxClients() > 1 ) { - EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.04362 ); + EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.04362 ); } else { - EV_HLDM_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &tracerCount[idx - 1], 0.08716, 0.08716 ); + EV_HLDM_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.08716 ); } } //====================== @@ -719,11 +719,11 @@ void EV_FireMP5( event_args_t *args ) if( gEngfuncs.GetMaxClients() > 1 ) { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } else { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } } diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index efa4b104..a4abe91c 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -91,7 +91,7 @@ float v_cameraFocusAngle = 35.0f; int v_cameraMode = CAM_MODE_FOCUS; qboolean v_resetCamera = 1; -vec3_t ev_punchangle; +vec3_t g_ev_punchangle; cvar_t *scr_ofsx; cvar_t *scr_ofsy; @@ -630,9 +630,9 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) VectorAdd( pparams->viewangles, pparams->punchangle, pparams->viewangles ); // Include client side punch, too - VectorAdd( pparams->viewangles, (float *)&ev_punchangle, pparams->viewangles ); + VectorAdd( pparams->viewangles, (float *)&g_ev_punchangle, pparams->viewangles ); - V_DropPunchAngle( pparams->frametime, (float *)&ev_punchangle ); + V_DropPunchAngle( pparams->frametime, (float *)&g_ev_punchangle ); // smooth out stair step ups #if 1 @@ -1579,7 +1579,7 @@ Client side punch effect */ void V_PunchAxis( int axis, float punch ) { - ev_punchangle[axis] = punch; + g_ev_punchangle[axis] = punch; } /* From e7989d438a4eea04317fc4dd7b79b34c9c18f3d8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 15 Oct 2017 00:12:26 +0500 Subject: [PATCH 121/199] Fix compatibility with MSVC 6. --- cl_dll/ammo.cpp | 6 +++--- dlls/player.cpp | 2 +- dlls/scientist.cpp | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index edc21652..4104acff 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -305,7 +305,7 @@ void CHudAmmo::Reset( void ) gHR.Reset(); //VidInit(); - wrect_t nullrc = {}; + wrect_t nullrc = {0,}; SetCrosshair( 0, nullrc, 0, 0, 0 ); // reset crosshair m_pWeapon = NULL; // reset last weapon } @@ -539,7 +539,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) if( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) { - wrect_t nullrc = {}; + wrect_t nullrc = {0,}; gpActiveSel = NULL; SetCrosshair( 0, nullrc, 0, 0, 0 ); } @@ -559,7 +559,7 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) // int CHudAmmo::MsgFunc_CurWeapon( const char *pszName, int iSize, void *pbuf ) { - wrect_t nullrc = {}; + wrect_t nullrc = {0,}; int fOnTarget = FALSE; BEGIN_READ( pbuf, iSize ); diff --git a/dlls/player.cpp b/dlls/player.cpp index 38038b36..e5a01bae 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -666,7 +666,7 @@ void CBasePlayer::PackDeadPlayerItems( void ) int iWeaponRules; int iAmmoRules; int i; - CBasePlayerWeapon *rgpPackWeapons[MAX_WEAPONS] = {}; + CBasePlayerWeapon *rgpPackWeapons[MAX_WEAPONS] = {0,}; int iPackAmmo[MAX_AMMO_SLOTS]; int iPW = 0;// index into packweapons array int iPA = 0;// index into packammo array diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index 7cf9cc4d..7e94b286 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -467,7 +467,7 @@ void CScientist::StartTask( Task_t *pTask ) //The enemy can be null here. - Solokiller //Discovered while testing the barnacle grapple on headcrabs with scientists in view. - if( m_hEnemy && m_hEnemy->IsPlayer() ) + if( m_hEnemy != 0 && m_hEnemy->IsPlayer() ) PlaySentence( "SC_PLFEAR", 5, VOL_NORM, ATTN_NORM ); else PlaySentence( "SC_FEAR", 5, VOL_NORM, ATTN_NORM ); From f78471ad1d562ba0a53a43981fba5a823ca3957f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 15 Oct 2017 00:57:55 +0500 Subject: [PATCH 122/199] min->Q_min, max->Q_max. --- cl_dll/hl/hl_weapons.cpp | 2 +- dlls/apache.cpp | 8 ++++---- dlls/client.cpp | 8 ++++---- dlls/combat.cpp | 2 +- dlls/effects.cpp | 12 ++++++------ dlls/extdll.h | 8 ++++---- dlls/hassassin.cpp | 4 ++-- dlls/items.cpp | 2 +- dlls/maprules.cpp | 2 +- dlls/monsters.cpp | 2 +- dlls/multiplay_gamerules.cpp | 8 ++++---- dlls/nihilanth.cpp | 4 ++-- dlls/nodes.cpp | 14 +++++++------- dlls/player.cpp | 16 ++++++++-------- dlls/sound.cpp | 2 +- dlls/talkmonster.cpp | 4 ++-- dlls/turret.cpp | 2 +- dlls/util.cpp | 4 ++-- dlls/weapons.cpp | 8 ++++---- 19 files changed, 56 insertions(+), 56 deletions(-) diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 8f8baea7..75161a9e 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -151,7 +151,7 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; - int j = min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); + int j = Q_min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); if( j == 0 ) return FALSE; diff --git a/dlls/apache.cpp b/dlls/apache.cpp index aeeea30e..b3cfcf87 100644 --- a/dlls/apache.cpp +++ b/dlls/apache.cpp @@ -804,13 +804,13 @@ BOOL CApache::FireGun() angles.x = angles.x + 360; if( angles.x > m_angGun.x ) - m_angGun.x = min( angles.x, m_angGun.x + 12 ); + m_angGun.x = Q_min( angles.x, m_angGun.x + 12 ); if( angles.x < m_angGun.x ) - m_angGun.x = max( angles.x, m_angGun.x - 12 ); + m_angGun.x = Q_max( angles.x, m_angGun.x - 12 ); if( angles.y > m_angGun.y ) - m_angGun.y = min( angles.y, m_angGun.y + 12 ); + m_angGun.y = Q_min( angles.y, m_angGun.y + 12 ); if( angles.y < m_angGun.y ) - m_angGun.y = max( angles.y, m_angGun.y - 12 ); + m_angGun.y = Q_max( angles.y, m_angGun.y - 12 ); m_angGun.y = SetBoneController( 0, m_angGun.y ); m_angGun.x = SetBoneController( 1, m_angGun.x ); diff --git a/dlls/client.cpp b/dlls/client.cpp index 32b6bebd..578534e3 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -1656,12 +1656,12 @@ int GetWeaponData( struct edict_s *player, struct weapon_data_s *info ) item->m_iId = II.iId; item->m_iClip = gun->m_iClip; - item->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle, -0.001 ); - item->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack, -0.001 ); - item->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack, -0.001 ); + item->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle, -0.001 ); + item->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack, -0.001 ); + item->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack, -0.001 ); item->m_fInReload = gun->m_fInReload; item->m_fInSpecialReload = gun->m_fInSpecialReload; - item->fuser1 = max( gun->pev->fuser1, -0.001 ); + item->fuser1 = Q_max( gun->pev->fuser1, -0.001 ); item->fuser2 = gun->m_flStartThrow; item->fuser3 = gun->m_flReleaseThrow; item->iuser1 = gun->m_chargeReady; diff --git a/dlls/combat.cpp b/dlls/combat.cpp index 35e4ffcf..9f221cc9 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -727,7 +727,7 @@ void CGib::BounceGibTouch( CBaseEntity *pOther ) float volume; float zvel = fabs( pev->velocity.z ); - volume = 0.8 * min( 1.0, ( (float)zvel ) / 450.0 ); + volume = 0.8 * Q_min( 1.0, ( (float)zvel ) / 450.0 ); CBreakable::MaterialSoundRandom( edict(), (Materials)m_material, volume ); } diff --git a/dlls/effects.cpp b/dlls/effects.cpp index c3216835..15df3bc3 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -280,12 +280,12 @@ void CBeam::RelinkBeam( void ) { const Vector &startPos = GetStartPos(), &endPos = GetEndPos(); - pev->mins.x = min( startPos.x, endPos.x ); - pev->mins.y = min( startPos.y, endPos.y ); - pev->mins.z = min( startPos.z, endPos.z ); - pev->maxs.x = max( startPos.x, endPos.x ); - pev->maxs.y = max( startPos.y, endPos.y ); - pev->maxs.z = max( startPos.z, endPos.z ); + pev->mins.x = Q_min( startPos.x, endPos.x ); + pev->mins.y = Q_min( startPos.y, endPos.y ); + pev->mins.z = Q_min( startPos.z, endPos.z ); + pev->maxs.x = Q_max( startPos.x, endPos.x ); + pev->maxs.y = Q_max( startPos.y, endPos.y ); + pev->maxs.z = Q_max( startPos.z, endPos.z ); pev->mins = pev->mins - pev->origin; pev->maxs = pev->maxs - pev->origin; diff --git a/dlls/extdll.h b/dlls/extdll.h index d9587bae..45c42309 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -88,11 +88,11 @@ typedef float vec_t; // needed before including progdefs.h // Shared header between the client DLL and the game DLLs #include "cdll_dll.h" -#ifndef min -#define min(a,b) (((a) < (b)) ? (a) : (b)) +#ifndef Q_min +#define Q_min(a,b) (((a) < (b)) ? (a) : (b)) #endif -#ifndef max -#define max(a,b) (((a) > (b)) ? (a) : (b)) +#ifndef Q_max +#define Q_max(a,b) (((a) > (b)) ? (a) : (b)) #endif #endif //EXTDLL_H diff --git a/dlls/hassassin.cpp b/dlls/hassassin.cpp index ff053595..f51ed4cb 100644 --- a/dlls/hassassin.cpp +++ b/dlls/hassassin.cpp @@ -699,12 +699,12 @@ void CHAssassin::RunAI( void ) EMIT_SOUND( ENT( pev ), CHAN_BODY, "debris/beamstart1.wav", 0.2, ATTN_NORM ); } - pev->renderamt = max( pev->renderamt - 50, m_iTargetRanderamt ); + pev->renderamt = Q_max( pev->renderamt - 50, m_iTargetRanderamt ); pev->rendermode = kRenderTransTexture; } else if( pev->renderamt < m_iTargetRanderamt ) { - pev->renderamt = min( pev->renderamt + 50, m_iTargetRanderamt ); + pev->renderamt = Q_min( pev->renderamt + 50, m_iTargetRanderamt ); if( pev->renderamt == 255 ) pev->rendermode = kRenderNormal; } diff --git a/dlls/items.cpp b/dlls/items.cpp index b0b2aa38..45edeb5e 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -227,7 +227,7 @@ class CItemBattery : public CItem char szcharge[64]; pPlayer->pev->armorvalue += gSkillData.batteryCapacity; - pPlayer->pev->armorvalue = min( pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY ); + pPlayer->pev->armorvalue = Q_min( pPlayer->pev->armorvalue, MAX_NORMAL_BATTERY ); EMIT_SOUND( pPlayer->edict(), CHAN_ITEM, "items/gunpickup2.wav", 1, ATTN_NORM ); diff --git a/dlls/maprules.cpp b/dlls/maprules.cpp index bfec93e2..519f7d2a 100644 --- a/dlls/maprules.cpp +++ b/dlls/maprules.cpp @@ -768,7 +768,7 @@ void CGamePlayerEquip::KeyValue( KeyValueData *pkvd ) m_weaponNames[i] = ALLOC_STRING( tmp ); m_weaponCount[i] = atoi( pkvd->szValue ); - m_weaponCount[i] = max( 1, m_weaponCount[i] ); + m_weaponCount[i] = Q_max( 1, m_weaponCount[i] ); pkvd->fHandled = TRUE; break; } diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index a9796a80..1e1d3de3 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -1959,7 +1959,7 @@ void CBaseMonster::MoveExecute( CBaseEntity *pTargetEnt, const Vector &vecDir, f while( flTotal > 0.001 ) { // don't walk more than 16 units or stairs stop working - flStep = min( 16.0, flTotal ); + flStep = Q_min( 16.0, flTotal ); UTIL_MoveToOrigin( ENT( pev ), m_Route[m_iRouteIndex].vecLocation, flStep, MOVE_NORMAL ); flTotal -= flStep; } diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 8d089696..7922d413 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -1368,15 +1368,15 @@ int ReloadMapCycleFile( const char *filename, mapcycle_t *cycle ) if( s && s[0] ) { item->minplayers = atoi( s ); - item->minplayers = max( item->minplayers, 0 ); - item->minplayers = min( item->minplayers, gpGlobals->maxClients ); + item->minplayers = Q_max( item->minplayers, 0 ); + item->minplayers = Q_min( item->minplayers, gpGlobals->maxClients ); } s = g_engfuncs.pfnInfoKeyValue( szBuffer, "maxplayers" ); if( s && s[0] ) { item->maxplayers = atoi( s ); - item->maxplayers = max( item->maxplayers, 0 ); - item->maxplayers = min( item->maxplayers, gpGlobals->maxClients ); + item->maxplayers = Q_max( item->maxplayers, 0 ); + item->maxplayers = Q_min( item->maxplayers, gpGlobals->maxClients ); } // Remove keys diff --git a/dlls/nihilanth.cpp b/dlls/nihilanth.cpp index 34375a58..1d072db4 100644 --- a/dlls/nihilanth.cpp +++ b/dlls/nihilanth.cpp @@ -478,7 +478,7 @@ void CNihilanth::DyingThink( void ) { if( m_pBall->pev->renderamt > 0 ) { - m_pBall->pev->renderamt = max( 0, m_pBall->pev->renderamt - 2 ); + m_pBall->pev->renderamt = Q_max( 0, m_pBall->pev->renderamt - 2 ); } else { @@ -895,7 +895,7 @@ void CNihilanth::HuntThink( void ) } else { - m_flAdj = min( m_flAdj + 10, 1000 ); + m_flAdj = Q_min( m_flAdj + 10, 1000 ); } } diff --git a/dlls/nodes.cpp b/dlls/nodes.cpp index b94f894b..04705638 100644 --- a/dlls/nodes.cpp +++ b/dlls/nodes.cpp @@ -793,12 +793,12 @@ void inline CalcBounds( int &Lower, int &Upper, int Goal, int Best ) int Temp = 2 * Goal - Best; if( Best > Goal ) { - Lower = max( 0, Temp ); + Lower = Q_max( 0, Temp ); Upper = Best; } else { - Upper = min( 255, Temp ); + Upper = Q_min( 255, Temp ); Lower = Best; } } @@ -962,7 +962,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = max( m_minY, halfY + 1 ); i <= m_maxY; i++ ) + for( i = Q_max( m_minY, halfY + 1 ); i <= m_maxY; i++ ) { for( j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++ ) { @@ -987,7 +987,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = min( m_maxZ, halfZ ); i >= m_minZ; i-- ) + for( i = Q_min( m_maxZ, halfZ ); i >= m_minZ; i-- ) { for( j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++ ) { @@ -1012,7 +1012,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = max( m_minX, halfX + 1 ); i <= m_maxX; i++ ) + for( i = Q_max( m_minX, halfX + 1 ); i <= m_maxX; i++ ) { for( j = m_RangeStart[0][i]; j <= m_RangeEnd[0][i]; j++ ) { @@ -1034,7 +1034,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = min( m_maxY, halfY ); i >= m_minY; i-- ) + for( i = Q_min( m_maxY, halfY ); i >= m_minY; i-- ) { for( j = m_RangeStart[1][i]; j <= m_RangeEnd[1][i]; j++ ) { @@ -1055,7 +1055,7 @@ int CGraph::FindNearestNode( const Vector &vecOrigin, int afNodeTypes ) } } - for( i = max( m_minZ, halfZ + 1 ); i <= m_maxZ; i++ ) + for( i = Q_max( m_minZ, halfZ + 1 ); i <= m_maxZ; i++ ) { for( j = m_RangeStart[2][i]; j <= m_RangeEnd[2][i]; j++ ) { diff --git a/dlls/player.cpp b/dlls/player.cpp index e5a01bae..757f03e4 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -2049,7 +2049,7 @@ void CBasePlayer::CheckTimeBasedDamage() // after the player has been drowning and finally takes a breath if( m_idrowndmg > m_idrownrestored ) { - int idif = min( m_idrowndmg - m_idrownrestored, 10 ); + int idif = Q_min( m_idrowndmg - m_idrownrestored, 10 ); TakeHealth( idif, DMG_GENERIC ); m_idrownrestored += idif; @@ -2606,23 +2606,23 @@ pt_end: if( gun && gun->UseDecrement() ) { - gun->m_flNextPrimaryAttack = max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); - gun->m_flNextSecondaryAttack = max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); + gun->m_flNextPrimaryAttack = Q_max( gun->m_flNextPrimaryAttack - gpGlobals->frametime, -1.0 ); + gun->m_flNextSecondaryAttack = Q_max( gun->m_flNextSecondaryAttack - gpGlobals->frametime, -0.001 ); if( gun->m_flTimeWeaponIdle != 1000 ) { - gun->m_flTimeWeaponIdle = max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); + gun->m_flTimeWeaponIdle = Q_max( gun->m_flTimeWeaponIdle - gpGlobals->frametime, -0.001 ); } if( gun->pev->fuser1 != 1000 ) { - gun->pev->fuser1 = max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); + gun->pev->fuser1 = Q_max( gun->pev->fuser1 - gpGlobals->frametime, -0.001 ); } // Only decrement if not flagged as NO_DECREMENT /*if( gun->m_flPumpTime != 1000 ) { - gun->m_flPumpTime = max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); + gun->m_flPumpTime = Q_max( gun->m_flPumpTime - gpGlobals->frametime, -0.001 ); }*/ } @@ -3705,7 +3705,7 @@ int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax ) if( i < 0 || i >= MAX_AMMO_SLOTS ) return -1; - int iAdd = min( iCount, iMax - m_rgAmmo[i] ); + int iAdd = Q_min( iCount, iMax - m_rgAmmo[i] ); if( iAdd < 1 ) return i; @@ -3826,7 +3826,7 @@ void CBasePlayer::SendAmmoUpdate( void ) // send "Ammo" update message MESSAGE_BEGIN( MSG_ONE, gmsgAmmoX, NULL, pev ); WRITE_BYTE( i ); - WRITE_BYTE( max( min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte + WRITE_BYTE( Q_max( Q_min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte MESSAGE_END(); } } diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 85b9f71d..31d0b7aa 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -1567,7 +1567,7 @@ void TEXTURETYPE_Init() continue; // null-terminate name and save in sentences array - j = min( j, CBTEXTURENAMEMAX - 1 + i ); + j = Q_min( j, CBTEXTURENAMEMAX - 1 + i ); buffer[j] = 0; strcpy( &( grgszTextureName[gcTextures++][0] ), &( buffer[i] ) ); } diff --git a/dlls/talkmonster.cpp b/dlls/talkmonster.cpp index 35bf3856..9180f037 100644 --- a/dlls/talkmonster.cpp +++ b/dlls/talkmonster.cpp @@ -403,11 +403,11 @@ void CTalkMonster::StartTask( Task_t *pTask ) if( yaw < 0 ) { - pev->ideal_yaw = min( yaw + 45, 0 ) + pev->angles.y; + pev->ideal_yaw = Q_min( yaw + 45, 0 ) + pev->angles.y; } else { - pev->ideal_yaw = max( yaw - 45, 0 ) + pev->angles.y; + pev->ideal_yaw = Q_max( yaw - 45, 0 ) + pev->angles.y; } } TaskComplete(); diff --git a/dlls/turret.cpp b/dlls/turret.cpp index ae95db14..093b2032 100644 --- a/dlls/turret.cpp +++ b/dlls/turret.cpp @@ -454,7 +454,7 @@ void CBaseTurret::EyeOff() { if( m_eyeBrightness > 0 ) { - m_eyeBrightness = max( 0, m_eyeBrightness - 30 ); + m_eyeBrightness = Q_max( 0, m_eyeBrightness - 30 ); m_pEyeGlow->SetBrightness( m_eyeBrightness ); } } diff --git a/dlls/util.cpp b/dlls/util.cpp index 68ba30cd..f382ac58 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1112,7 +1112,7 @@ void UTIL_BloodStream( const Vector &origin, const Vector &direction, int color, WRITE_COORD( direction.y ); WRITE_COORD( direction.z ); WRITE_BYTE( color ); - WRITE_BYTE( min( amount, 255 ) ); + WRITE_BYTE( Q_min( amount, 255 ) ); MESSAGE_END(); } @@ -1144,7 +1144,7 @@ void UTIL_BloodDrips( const Vector &origin, const Vector &direction, int color, WRITE_SHORT( g_sModelIndexBloodSpray ); // initial sprite model WRITE_SHORT( g_sModelIndexBloodDrop ); // droplet sprite models WRITE_BYTE( color ); // color index into host_basepal - WRITE_BYTE( min( max( 3, amount / 10 ), 16 ) ); // size + WRITE_BYTE( Q_min( Q_max( 3, amount / 10 ), 16 ) ); // size MESSAGE_END(); } diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index a1205f27..80a45284 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -607,7 +607,7 @@ void CBasePlayerWeapon::ItemPostFrame( void ) if( ( m_fInReload ) && ( m_pPlayer->m_flNextAttack <= UTIL_WeaponTimeBase() ) ) { // complete the reload. - int j = min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); + int j = Q_min( iMaxClip() - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]); // Add them to the clip m_iClip += j; @@ -850,7 +850,7 @@ BOOL CBasePlayerWeapon::AddPrimaryAmmo( int iCount, char *szName, int iMaxClip, else if( m_iClip == 0 ) { int i; - i = min( m_iClip + iCount, iMaxClip ) - m_iClip; + i = Q_min( m_iClip + iCount, iMaxClip ) - m_iClip; m_iClip += i; iIdAmmo = m_pPlayer->GiveAmmo( iCount - i, szName, iMaxCarry ); } @@ -964,7 +964,7 @@ BOOL CBasePlayerWeapon::DefaultReload( int iClipSize, int iAnim, float fDelay, i if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) return FALSE; - int j = min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); + int j = Q_min( iClipSize - m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ); if( j == 0 ) return FALSE; @@ -1428,7 +1428,7 @@ int CWeaponBox::GiveAmmo( int iCount, const char *szName, int iMax, int *pIndex/ if( pIndex ) *pIndex = i; - int iAdd = min( iCount, iMax - m_rgAmmo[i] ); + int iAdd = Q_min( iCount, iMax - m_rgAmmo[i] ); if( iCount == 0 || iAdd > 0 ) { m_rgAmmo[i] += iAdd; From 8e799fcf6d4fc6f3f685e07173d6e538968695ac Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 15 Oct 2017 14:22:14 +0500 Subject: [PATCH 123/199] Add crowbar idle animations under CROWBAR_IDLE_ANIM macro. --- cl_dll/ev_hldm.cpp | 6 ++++++ dlls/crowbar.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++- dlls/weapons.h | 3 +++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 80073b27..628b5bfa 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1138,7 +1138,13 @@ enum crowbar_e CROWBAR_ATTACK2MISS, CROWBAR_ATTACK2HIT, CROWBAR_ATTACK3MISS, +#ifndef CROWBAR_IDLE_ANIM CROWBAR_ATTACK3HIT +#else + CROWBAR_ATTACK3HIT, + CROWBAR_IDLE2, + CROWBAR_IDLE3 +#endif }; int g_iSwing; diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index f9a91978..4cc48d97 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -37,7 +37,13 @@ enum crowbar_e CROWBAR_ATTACK2MISS, CROWBAR_ATTACK2HIT, CROWBAR_ATTACK3MISS, +#ifndef CROWBAR_IDLE_ANIM CROWBAR_ATTACK3HIT +#else + CROWBAR_ATTACK3HIT, + CROWBAR_IDLE2, + CROWBAR_IDLE3 +#endif }; void CCrowbar::Spawn() @@ -208,7 +214,9 @@ int CCrowbar::Swing( int fFirst ) { // miss m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); - +#ifdef CROWBAR_IDLE_ANIM + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); +#endif // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); } @@ -324,5 +332,38 @@ int CCrowbar::Swing( int fFirst ) #endif m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); } +#ifdef CROWBAR_IDLE_ANIM + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); +#endif return fDidHit; } + +#ifdef CROWBAR_IDLE_ANIM +void CCrowbar::WeaponIdle( void ) +{ + if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) + { + int iAnim; + float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); + if( flRand > 0.9 ) + { + iAnim = CROWBAR_IDLE2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0; + } + else + { + if( flRand > 0.5 ) + { + iAnim = CROWBAR_IDLE; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 70.0 / 30.0; + } + else + { + iAnim = CROWBAR_IDLE3; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 160.0 / 30.0; + } + } + SendWeaponAnim( iAnim ); + } +} +#endif diff --git a/dlls/weapons.h b/dlls/weapons.h index f48767c8..6c03105b 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -504,6 +504,9 @@ public: int Swing( int fFirst ); BOOL Deploy( void ); void Holster( int skiplocal = 0 ); +#ifdef CROWBAR_IDLE_ANIM + void WeaponIdle(); +#endif int m_iSwing; TraceResult m_trHit; From aaedd794c36cfae4bbecabf5ce9c55116307e3ee Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 15 Oct 2017 17:50:05 +0500 Subject: [PATCH 124/199] Merge https://github.com/LevShisterov/BugfixedHL/commit/293b41b8cd20f19179926284e4100f00e8e62fd7 --- dlls/player.cpp | 5 +++++ dlls/player.h | 2 ++ 2 files changed, 7 insertions(+) diff --git a/dlls/player.cpp b/dlls/player.cpp index 757f03e4..d0a1f763 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -2586,6 +2586,11 @@ void CBasePlayer::PostThink() UpdatePlayerSound(); pt_end: + if( pev->deadflag == DEAD_NO ) + m_vecLastViewAngles = pev->angles; + else + pev->angles = m_vecLastViewAngles; + // Track button info so we can detect 'pressed' and 'released' buttons next frame m_afButtonLast = pev->button; diff --git a/dlls/player.h b/dlls/player.h index 54e7fa85..fecaf3c9 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -306,6 +306,8 @@ public: void TabulateAmmo( void ); + Vector m_vecLastViewAngles; + float m_flStartCharge; float m_flAmmoStartCharge; float m_flPlayAftershock; From 5aa11a38b3148dd220321a745cbdb3194947f0ba Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 1 Nov 2017 16:43:29 +0300 Subject: [PATCH 125/199] Give player exhaustible weapons when taking ammo for them from weaponbox --- dlls/weapons.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 80a45284..5e4f8f78 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1265,6 +1265,18 @@ void CWeaponBox::Kill( void ) UTIL_Remove( this ); } +static const char* IsAmmoForExhaustibleWeapon(const char* ammoName, int& weaponId) +{ + for (int i=0; im_rgpPlayerItems[j]; + while( pPlayerItem ) + { + if (pPlayerItem->m_iId == exhaustibleWeaponId) { + foundWeapon = true; + break; + } + pPlayerItem = pPlayerItem->m_pNext; + } + } + if (!foundWeapon) { + CBasePlayerWeapon* weapon = (CBasePlayerWeapon*)Create(weaponName, pev->origin, pev->angles); + if (weapon) { + weapon->pev->spawnflags |= SF_NORESPAWN; + weapon->m_iDefaultAmmo = 0; + if (pPlayer->AddPlayerItem(weapon)) { + weapon->AttachToPlayer(pPlayer); + } + } + } + } + // there's some ammo of this type. pPlayer->GiveAmmo( m_rgAmmo[i], STRING( m_rgiszAmmo[i] ), MaxAmmoCarry( m_rgiszAmmo[i] ) ); From 7d33351f77d7ac1f843c05a70bae8c9a8eabe8bf Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 18 Nov 2017 14:49:01 +0500 Subject: [PATCH 126/199] Add missing file to build lists. --- dlls/Android.mk | 1 + dlls/CMakeLists.txt | 1 + dlls/Makefile | 1 + 3 files changed, 3 insertions(+) diff --git a/dlls/Android.mk b/dlls/Android.mk index b160c424..1dc79616 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -96,6 +96,7 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ plane.cpp \ plats.cpp \ player.cpp \ + playermonster.cpp \ python.cpp \ rat.cpp \ roach.cpp \ diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index e0b6a8b3..4e56ab44 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -98,6 +98,7 @@ set (SVDLL_SOURCES plane.cpp plats.cpp player.cpp + playermonster.cpp python.cpp rat.cpp roach.cpp diff --git a/dlls/Makefile b/dlls/Makefile index 9c3a84f2..60aad1b3 100644 --- a/dlls/Makefile +++ b/dlls/Makefile @@ -135,6 +135,7 @@ OBJ = \ $(DLL_OBJDIR)/plane.o \ $(DLL_OBJDIR)/plats.o \ $(DLL_OBJDIR)/player.o \ + $(DLL_OBJDIR)/playermonster.o \^M $(DLL_OBJDIR)/python.o \ $(DLL_OBJDIR)/rat.o \ $(DLL_OBJDIR)/roach.o \ From ad3a2141eb53a42b15dd6a994971900873530c9a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 3 Dec 2017 18:52:38 +0300 Subject: [PATCH 127/199] Change __MSC_VER to _MSC_VER to make the client buildable with VS 6 --- engine/cdll_int.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/engine/cdll_int.h b/engine/cdll_int.h index d45bb9d5..20af4b55 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -93,7 +93,7 @@ typedef struct client_textmessage_s const char *pMessage; } client_textmessage_t; -#if __MSC_VER == 1200 +#if _MSC_VER == 1200 #define ulonglong_t __int64 #else #define ulonglong_t unsigned long long From 31b2a68d6d45bf4682043e9888b2f2b1f4f49df9 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Fri, 18 Nov 2016 01:05:05 +0300 Subject: [PATCH 128/199] goldsource mouse input --- CMakeLists.txt | 3 +- cl_dll/CMakeLists.txt | 42 +- cl_dll/input_goldsource.cpp | 1357 +++++++++++++++++++++++++++++++++++ cl_dll/inputw32.cpp | 901 ----------------------- 4 files changed, 1384 insertions(+), 919 deletions(-) create mode 100644 cl_dll/input_goldsource.cpp delete mode 100644 cl_dll/inputw32.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c2d6822..7719bac6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,6 +31,7 @@ option(USE_VGUI2 "Enable VGUI2. UNDONE" OFF) option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) option(BUILD_CLIENT "Build client dll" ON) option(BUILD_SERVER "Build server dll" ON) +option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) #----------------- # MAIN BUILD CODE \ @@ -59,4 +60,4 @@ endif() if(NOT BUILD_SERVER AND NOT BUILD_CLIENT) error("Nothing to build") -endif() \ No newline at end of file +endif() diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 7fffb29b..7bd04f77 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -26,24 +26,27 @@ project (CLDLL) set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") +if (GOLDSOURCE_SUPPORT) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lSDL2 -Wl,--no-undefined") +endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") -set (CLDLL_SOURCES - ../dlls/crossbow.cpp - ../dlls/crowbar.cpp - ../dlls/egon.cpp - ../dlls/gauss.cpp - ../dlls/handgrenade.cpp - ../dlls/hornetgun.cpp - ../dlls/mp5.cpp - ../dlls/python.cpp - ../dlls/rpg.cpp - ../dlls/satchel.cpp - ../dlls/shotgun.cpp - ../dlls/squeakgrenade.cpp - ../dlls/tripmine.cpp +set (CLDLL_SOURCES + ../dlls/crossbow.cpp + ../dlls/crowbar.cpp + ../dlls/egon.cpp + ../dlls/gauss.cpp + ../dlls/handgrenade.cpp + ../dlls/hornetgun.cpp + ../dlls/mp5.cpp + ../dlls/python.cpp + ../dlls/rpg.cpp + ../dlls/satchel.cpp + ../dlls/shotgun.cpp + ../dlls/squeakgrenade.cpp + ../dlls/tripmine.cpp ../dlls/glock.cpp - ev_hldm.cpp + ev_hldm.cpp hl/hl_baseentity.cpp hl/hl_events.cpp hl/hl_objects.cpp @@ -70,7 +73,6 @@ set (CLDLL_SOURCES hud_update.cpp in_camera.cpp input.cpp -#SRCS+=./inputw32.cpp menu.cpp message.cpp overview.cpp @@ -88,9 +90,15 @@ set (CLDLL_SOURCES tri.cpp util.cpp view.cpp - input_xash3d.cpp scoreboard.cpp MOTD.cpp) + +if (GOLDSOURCE_SUPPORT) + set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_goldsource.cpp) +else() + set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_xash3d.cpp) +endif() + include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) if(USE_VOICEMGR) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp new file mode 100644 index 00000000..70cd23c5 --- /dev/null +++ b/cl_dll/input_goldsource.cpp @@ -0,0 +1,1357 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +// in_win.c -- windows 95 mouse and joystick code +// 02/21/97 JCB Added extended DirectInput code to support external controllers. + +//#include "port.h" + +#include "hud.h" +#include "cl_util.h" +#include "camera.h" +#include "kbutton.h" +#include "cvardef.h" +#include "usercmd.h" +#include "const.h" +#include "camera.h" +#include "in_defs.h" +#include "keydefs.h" +#include "view.h" +//#include "Exports.h" + +#ifndef _WIN32 +#define USE_SDL2 +#endif + +#ifdef USE_SDL2 +#include +#include +#endif + +#ifdef _WIN32 +#include +#else +typedef unsigned int DWORD; +#endif + +#define MOUSE_BUTTON_COUNT 5 + +// use IN_SetVisibleMouse to set: +int iVisibleMouse = 0; + +extern cl_enginefunc_t gEngfuncs; + +extern int iMouseInUse; + +extern kbutton_t in_strafe; +extern kbutton_t in_mlook; +extern kbutton_t in_speed; +extern kbutton_t in_jlook; + +extern cvar_t *m_pitch; +extern cvar_t *m_yaw; +extern cvar_t *m_forward; +extern cvar_t *m_side; + +extern cvar_t *lookstrafe; +extern cvar_t *lookspring; +extern cvar_t *cl_pitchdown; +extern cvar_t *cl_pitchup; +extern cvar_t *cl_yawspeed; +extern cvar_t *cl_sidespeed; +extern cvar_t *cl_forwardspeed; +extern cvar_t *cl_pitchspeed; +extern cvar_t *cl_movespeedkey; + +#ifdef _WIN32 +static double s_flRawInputUpdateTime = 0.0f; +static bool m_bRawInput = false; +static bool m_bMouseThread = false; +bool isMouseRelative = false; +#endif + +#ifdef _WIN32 +#include "progdefs.h" +extern globalvars_t *gpGlobals; +#endif + +Vector dead_viewangles(0, 0, 0); + +void V_StopPitchDrift( void ) +{ + +} + +// mouse variables +cvar_t *m_filter; +cvar_t *sensitivity; + +// Custom mouse acceleration (0 disable, 1 to enable, 2 enable with separate yaw/pitch rescale) +static cvar_t *m_customaccel; +//Formula: mousesensitivity = ( rawmousedelta^m_customaccel_exponent ) * m_customaccel_scale + sensitivity +// If mode is 2, then x and y sensitivity are scaled by m_pitch and m_yaw respectively. +// Custom mouse acceleration value. +static cvar_t *m_customaccel_scale; +//Max mouse move scale factor, 0 for no limit +static cvar_t *m_customaccel_max; +//Mouse move is raised to this power before being scaled by scale factor +static cvar_t *m_customaccel_exponent; + +#ifdef _WIN32 +// if threaded mouse is enabled then the time to sleep between polls +static cvar_t *m_mousethread_sleep; +#endif + +int mouse_buttons; +int mouse_oldbuttonstate; +POINT current_pos; +int old_mouse_x, old_mouse_y, mx_accum, my_accum; +float mouse_x, mouse_y; + +static int restore_spi; +static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; +static int mouseactive = 0; +int mouseinitialized; +static int mouseparmsvalid; +static int mouseshowtoggle = 1; + +// joystick defines and variables +// where should defines be moved? +#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick +#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball +#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V +#define JOY_AXIS_X 0 +#define JOY_AXIS_Y 1 +#define JOY_AXIS_Z 2 +#define JOY_AXIS_R 3 +#define JOY_AXIS_U 4 +#define JOY_AXIS_V 5 + +enum _ControlList +{ + AxisNada = 0, + AxisForward, + AxisLook, + AxisSide, + AxisTurn +}; + + +DWORD dwAxisMap[ JOY_MAX_AXES ]; +DWORD dwControlMap[ JOY_MAX_AXES ]; +int pdwRawValue[ JOY_MAX_AXES ]; +DWORD joy_oldbuttonstate, joy_oldpovstate; + +int joy_id; +DWORD joy_numbuttons; + +#ifdef USE_SDL2 +SDL_GameController *s_pJoystick = NULL; +#endif + +// none of these cvars are saved over a session +// this means that advanced controller configuration needs to be executed +// each time. this avoids any problems with getting back to a default usage +// or when changing from one controller to another. this way at least something +// works. +cvar_t *in_joystick; +cvar_t *joy_name; +cvar_t *joy_advanced; +cvar_t *joy_advaxisx; +cvar_t *joy_advaxisy; +cvar_t *joy_advaxisz; +cvar_t *joy_advaxisr; +cvar_t *joy_advaxisu; +cvar_t *joy_advaxisv; +cvar_t *joy_forwardthreshold; +cvar_t *joy_sidethreshold; +cvar_t *joy_pitchthreshold; +cvar_t *joy_yawthreshold; +cvar_t *joy_forwardsensitivity; +cvar_t *joy_sidesensitivity; +cvar_t *joy_pitchsensitivity; +cvar_t *joy_yawsensitivity; +cvar_t *joy_wwhack1; +cvar_t *joy_wwhack2; + +int joy_avail, joy_advancedinit, joy_haspov; + +#ifdef _WIN32 +unsigned int s_hMouseThreadId = 0; +HANDLE s_hMouseThread = 0; +HANDLE s_hMouseQuitEvent = 0; +HANDLE s_hMouseThreadActiveLock = 0; +#endif + +/* +=========== +Force_CenterView_f +=========== +*/ +void Force_CenterView_f (void) +{ + vec3_t viewangles; + + if (!iMouseInUse) + { + gEngfuncs.GetViewAngles( (float *)viewangles ); + viewangles[PITCH] = 0; + gEngfuncs.SetViewAngles( (float *)viewangles ); + } +} + +#ifdef _WIN32 + +LONG mouseThreadActive = 0; +LONG mouseThreadCenterX = 0; +LONG mouseThreadCenterY = 0; +LONG mouseThreadDeltaX = 0; +LONG mouseThreadDeltaY = 0; +LONG mouseThreadSleep = 0; + +bool MouseThread_ActiveLock_Enter( void ) +{ + if(!m_bMouseThread) + return true; + + return WAIT_OBJECT_0 == WaitForSingleObject( s_hMouseThreadActiveLock, INFINITE); +} + +void MouseThread_ActiveLock_Exit( void ) +{ + if(!m_bMouseThread) + return; + + SetEvent( s_hMouseThreadActiveLock ); +} + +unsigned __stdcall MouseThread_Function( void * pArg ) +{ + while ( true ) + { + DWORD sleepVal = (DWORD)InterlockedExchangeAdd(&mouseThreadSleep, 0); + if(0 > sleepVal) sleepVal = 0; + else if(1000 < sleepVal) sleepVal = 1000; + if(WAIT_OBJECT_0 == WaitForSingleObject( s_hMouseQuitEvent, sleepVal)) + { + break; + } + + if( MouseThread_ActiveLock_Enter() ) + { + if ( InterlockedExchangeAdd(&mouseThreadActive, 0) ) + { + POINT mouse_pos; + POINT center_pos; + + center_pos.x = InterlockedExchangeAdd(&mouseThreadCenterX, 0); + center_pos.y = InterlockedExchangeAdd(&mouseThreadCenterY, 0); + GetCursorPos(&mouse_pos); + + mouse_pos.x -= center_pos.x; + mouse_pos.y -= center_pos.y; + + if(mouse_pos.x || mouse_pos.y) SetCursorPos( center_pos.x, center_pos.y ); + + InterlockedExchangeAdd(&mouseThreadDeltaX, mouse_pos.x); + InterlockedExchangeAdd(&mouseThreadDeltaY, mouse_pos.y); + } + + MouseThread_ActiveLock_Exit(); + } + } + + return 0; +} + +/// Updates mouseThreadActive using the global variables mouseactive, iVisibleMouse and m_bRawInput. Should be called after any of these is changed. +/// Has to be interlocked manually by programmer! Use MouseThread_ActiveLock_Enter and MouseThread_ActiveLock_Exit. +void UpdateMouseThreadActive(void) +{ + InterlockedExchange(&mouseThreadActive, mouseactive && !iVisibleMouse && !m_bRawInput); +} + +#endif + +void IN_SetMouseMode(bool enable) +{ + static bool currentMouseMode = false; + + if(enable == currentMouseMode) + return; + + if(enable) + { +#ifdef _WIN32 + if (mouseparmsvalid) + restore_spi = SystemParametersInfo (SPI_SETMOUSE, 0, newmouseparms, 0); + + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + if(m_bRawInput) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_TRUE); +#endif + isMouseRelative = true; + } +#else + SDL_SetRelativeMouseMode(SDL_TRUE); +#endif + + currentMouseMode = true; + } + else + { +#ifdef _WIN32 + if(isMouseRelative) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif + isMouseRelative = false; + } + + if (restore_spi) + SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); +#else + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif + + currentMouseMode = false; + } +} + +void IN_SetVisibleMouse(bool visible) +{ +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + iVisibleMouse = visible; + + IN_SetMouseMode(!visible); + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif +} + +void IN_ResetMouse( void ); + +/* +=========== +IN_ActivateMouse +=========== +*/ +extern "C" void DLLEXPORT IN_ActivateMouse (void) +{ + if (mouseinitialized) + { +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + IN_SetMouseMode(true); + + mouseactive = 1; + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif + + // now is a good time to reset mouse positon: + IN_ResetMouse(); + } +} + + +/* +=========== +IN_DeactivateMouse +=========== +*/ +extern "C" void DLLEXPORT IN_DeactivateMouse (void) +{ + if (mouseinitialized) + { +#ifdef _WIN32 + bool lockEntered = MouseThread_ActiveLock_Enter(); +#endif + + IN_SetMouseMode(false); + + mouseactive = 0; + +#ifdef _WIN32 + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); +#endif + } +} + +/* +=========== +IN_StartupMouse +=========== +*/ +void IN_StartupMouse (void) +{ + if ( gEngfuncs.CheckParm ("-nomouse", NULL ) ) + return; + + mouseinitialized = 1; +#ifdef _WIN32 + mouseparmsvalid = SystemParametersInfo (SPI_GETMOUSE, 0, originalmouseparms, 0); + + if (mouseparmsvalid) + { + if ( gEngfuncs.CheckParm ("-noforcemspd", NULL ) ) + newmouseparms[2] = originalmouseparms[2]; + + if ( gEngfuncs.CheckParm ("-noforcemaccel", NULL ) ) + { + newmouseparms[0] = originalmouseparms[0]; + newmouseparms[1] = originalmouseparms[1]; + } + + if ( gEngfuncs.CheckParm ("-noforcemparms", NULL ) ) + { + newmouseparms[0] = originalmouseparms[0]; + newmouseparms[1] = originalmouseparms[1]; + newmouseparms[2] = originalmouseparms[2]; + } + } +#endif + + mouse_buttons = MOUSE_BUTTON_COUNT; +} + +/* +=========== +IN_Shutdown +=========== +*/ +void IN_Shutdown (void) +{ + IN_DeactivateMouse (); + +#ifdef _WIN32 + if ( s_hMouseQuitEvent ) + { + SetEvent( s_hMouseQuitEvent ); + } + + if ( s_hMouseThread ) + { + if(WAIT_OBJECT_0 != WaitForSingleObject( s_hMouseThread, 5000 )) + { + TerminateThread( s_hMouseThread, 0 ); + } + CloseHandle( s_hMouseThread ); + s_hMouseThread = (HANDLE)0; + } + + if ( s_hMouseQuitEvent ) + { + CloseHandle( s_hMouseQuitEvent ); + s_hMouseQuitEvent = (HANDLE)0; + } + + if( s_hMouseThreadActiveLock ) + { + CloseHandle( s_hMouseThreadActiveLock ); + s_hMouseThreadActiveLock = (HANDLE)0; + } +#endif +} + +/* +=========== +IN_GetMousePos + +Ask for mouse position from engine +=========== +*/ +void IN_GetMousePos( int *mx, int *my ) +{ + gEngfuncs.GetMousePosition( mx, my ); +} + +/* +=========== +IN_ResetMouse + +FIXME: Call through to engine? +=========== +*/ +void IN_ResetMouse( void ) +{ + // no work to do in SDL +#ifdef _WIN32 + // reset only if mouse is active and not in visible mode: + if(mouseactive && !iVisibleMouse) + { + if ( !m_bRawInput && gEngfuncs.GetWindowCenterX && gEngfuncs.GetWindowCenterY ) + { + bool lockEntered = MouseThread_ActiveLock_Enter(); + + int centerX = gEngfuncs.GetWindowCenterX(); + int centerY = gEngfuncs.GetWindowCenterY(); + + SetCursorPos ( centerX, centerY ); + InterlockedExchange( &mouseThreadCenterX, centerX ); + InterlockedExchange( &mouseThreadCenterY, centerY ); + InterlockedExchange( &mouseThreadDeltaX, 0 ); + InterlockedExchange( &mouseThreadDeltaY, 0 ); + + if(lockEntered) MouseThread_ActiveLock_Exit(); + } + } +#endif +} + +/* +=========== +IN_MouseEvent +=========== +*/ +extern "C" void DLLEXPORT IN_MouseEvent (int mstate) +{ + int i; + + if ( iMouseInUse || iVisibleMouse ) + return; + + // perform button actions + for (i=0 ; ivalue; + + // Using special accleration values + if ( m_customaccel->value != 0 ) + { + float raw_mouse_movement_distance = sqrt( mx * mx + my * my ); + float acceleration_scale = m_customaccel_scale->value; + float accelerated_sensitivity_max = m_customaccel_max->value; + float accelerated_sensitivity_exponent = m_customaccel_exponent->value; + float accelerated_sensitivity = ( (float)pow( raw_mouse_movement_distance, accelerated_sensitivity_exponent ) * acceleration_scale + mouse_senstivity ); + + if ( accelerated_sensitivity_max > 0.0001f && + accelerated_sensitivity > accelerated_sensitivity_max ) + { + accelerated_sensitivity = accelerated_sensitivity_max; + } + + *x *= accelerated_sensitivity; + *y *= accelerated_sensitivity; + + // Further re-scale by yaw and pitch magnitude if user requests alternate mode 2 + // This means that they will need to up their value for m_customaccel_scale greatly (>40x) since m_pitch/yaw default + // to 0.022 + if ( m_customaccel->value == 2 ) + { + *x *= m_yaw->value; + *y *= m_pitch->value; + } + } + else + { + // Just apply the default + *x *= mouse_senstivity; + *y *= mouse_senstivity; + } +} + +void IN_GetMouseDelta( int *pOutX, int *pOutY) +{ + bool active = mouseactive && !iVisibleMouse; + int mx, my; + + if(active) + { + int deltaX, deltaY; +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( m_bMouseThread ) + { + // update mouseThreadSleep: + InterlockedExchange(&mouseThreadSleep, (LONG)m_mousethread_sleep->value); + + bool lockEntered = MouseThread_ActiveLock_Enter(); + + current_pos.x = InterlockedExchange( &mouseThreadDeltaX, 0 ); + current_pos.y = InterlockedExchange( &mouseThreadDeltaY, 0 ); + + if(lockEntered) MouseThread_ActiveLock_Exit(); + } + else + { + GetCursorPos (¤t_pos); + } + } + else +#endif + { +#ifdef USE_SDL2 + SDL_GetRelativeMouseState( &deltaX, &deltaY ); + current_pos.x = deltaX; + current_pos.y = deltaY; +#else + GetCursorPos (¤t_pos); + deltaX = current_pos.x - gEngfuncs.GetWindowCenterX(); + deltaY = current_pos.y - gEngfuncs.GetWindowCenterY(); +#endif + } + +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( m_bMouseThread ) + { + mx = current_pos.x; + my = current_pos.y; + } + else + { + mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum; + my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum; + } + } + else +#endif + { + mx = deltaX + mx_accum; + my = deltaY + my_accum; + } + + mx_accum = 0; + my_accum = 0; + + // reset mouse position if required, so there is room to move: +#ifdef _WIN32 + // do not reset if mousethread would do it: + if ( m_bRawInput || !m_bMouseThread ) +#else + if(true) +#endif + IN_ResetMouse(); + +#ifdef _WIN32 + // update m_bRawInput occasionally: + if ( gpGlobals && gpGlobals->time - s_flRawInputUpdateTime > 1.0f ) + { + s_flRawInputUpdateTime = gpGlobals->time; + + bool lockEntered = MouseThread_ActiveLock_Enter(); + + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + + if(m_bRawInput && !isMouseRelative) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_TRUE); +#endif + isMouseRelative = true; + } + else if(!m_bRawInput && isMouseRelative) + { +#ifdef USE_SDL2 + SDL_SetRelativeMouseMode(SDL_FALSE); +#endif + isMouseRelative = false; + } + + UpdateMouseThreadActive(); + if(lockEntered) MouseThread_ActiveLock_Exit(); + } +#endif + } + else + { + mx = my = 0; + } + + if(pOutX) *pOutX = mx; + if(pOutY) *pOutY = my; +} + +/* +=========== +IN_MouseMove +=========== +*/ +void IN_MouseMove ( float frametime, usercmd_t *cmd) +{ + int mx, my; + vec3_t viewangles; + + gEngfuncs.GetViewAngles( (float *)viewangles ); + + if ( in_mlook.state & 1) + { + V_StopPitchDrift (); + } + + //jjb - this disbles normal mouse control if the user is trying to + // move the camera, or if the mouse cursor is visible or if we're in intermission + if ( !iMouseInUse && !gHUD.m_iIntermission && !iVisibleMouse ) + { + IN_GetMouseDelta( &mx, &my ); + + if (m_filter && m_filter->value) + { + mouse_x = (mx + old_mouse_x) * 0.5; + mouse_y = (my + old_mouse_y) * 0.5; + } + else + { + mouse_x = mx; + mouse_y = my; + } + + old_mouse_x = mx; + old_mouse_y = my; + + // Apply custom mouse scaling/acceleration + IN_ScaleMouse( &mouse_x, &mouse_y ); + + // add mouse X/Y movement to cmd + if ( (in_strafe.state & 1) || (lookstrafe->value && (in_mlook.state & 1) )) + cmd->sidemove += m_side->value * mouse_x; + else + viewangles[YAW] -= m_yaw->value * mouse_x; + + if ( (in_mlook.state & 1) && !(in_strafe.state & 1)) + { + viewangles[PITCH] += m_pitch->value * mouse_y; + if (viewangles[PITCH] > cl_pitchdown->value) + viewangles[PITCH] = cl_pitchdown->value; + if (viewangles[PITCH] < -cl_pitchup->value) + viewangles[PITCH] = -cl_pitchup->value; + } + else + { + if ((in_strafe.state & 1) && gEngfuncs.IsNoClipping() ) + { + cmd->upmove -= m_forward->value * mouse_y; + } + else + { + cmd->forwardmove -= m_forward->value * mouse_y; + } + } + } + + gEngfuncs.SetViewAngles( (float *)viewangles ); + +/* +//#define TRACE_TEST +#if defined( TRACE_TEST ) + { + int mx, my; + void V_Move( int mx, int my ); + IN_GetMousePos( &mx, &my ); + V_Move( mx, my ); + } +#endif +*/ +} + +/* +=========== +IN_Accumulate +=========== +*/ +extern "C" void DLLEXPORT IN_Accumulate (void) +{ + //only accumulate mouse if we are not moving the camera with the mouse + if ( !iMouseInUse && !iVisibleMouse) + { + if (mouseactive) + { +#ifdef _WIN32 + if ( !m_bRawInput ) + { + if ( !m_bMouseThread ) + { + GetCursorPos (¤t_pos); + + mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); + my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); + } + } + else +#endif + { +#ifdef USE_SDL2 + int deltaX, deltaY; + SDL_GetRelativeMouseState( &deltaX, &deltaY ); + mx_accum += deltaX; + my_accum += deltaY; +#else + GetCursorPos (¤t_pos); + + mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); + my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); +#endif + } + + // force the mouse to the center, so there's room to move +#ifdef _WIN32 + // do not reset if mousethread would do it: + if ( m_bRawInput || !m_bMouseThread ) +#else + if(true) +#endif + IN_ResetMouse(); + + } + } + +} + +/* +=================== +IN_ClearStates +=================== +*/ +extern "C" void DLLEXPORT IN_ClearStates (void) +{ + if ( !mouseactive ) + return; + + mx_accum = 0; + my_accum = 0; + mouse_oldbuttonstate = 0; +} + +/* +=============== +IN_StartupJoystick +=============== +*/ +void IN_StartupJoystick (void) +{ + // abort startup if user requests no joystick + if ( gEngfuncs.CheckParm ("-nojoy", NULL ) ) + return; + + // assume no joystick + joy_avail = 0; +#ifdef USE_SDL2 + int nJoysticks = SDL_NumJoysticks(); + if ( nJoysticks > 0 ) + { + for ( int i = 0; i < nJoysticks; i++ ) + { + if ( SDL_IsGameController( i ) ) + { + s_pJoystick = SDL_GameControllerOpen( i ); + if ( s_pJoystick ) + { + //save the joystick's number of buttons and POV status + joy_numbuttons = SDL_CONTROLLER_BUTTON_MAX; + joy_haspov = 0; + + // old button and POV states default to no buttons pressed + joy_oldbuttonstate = joy_oldpovstate = 0; + + // mark the joystick as available and advanced initialization not completed + // this is needed as cvars are not available during initialization + gEngfuncs.Con_Printf ("joystick found\n\n", SDL_GameControllerName(s_pJoystick)); + joy_avail = 1; + joy_advancedinit = 0; + break; + } + } + } + } + else + { + gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); + } +#else + gEngfuncs.Con_DPrintf ("joystick not found -- implement joystick without SDL2\n\n"); +#endif +} + +int RawValuePointer (int axis) +{ +#ifdef USE_SDL2 + switch (axis) + { + default: + case JOY_AXIS_X: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); + case JOY_AXIS_Y: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); + case JOY_AXIS_Z: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); + case JOY_AXIS_R: + return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); + + } +#else + // TODO: implement joystick without SDL2 + return 0; +#endif +} + +/* +=========== +Joy_AdvancedUpdate_f +=========== +*/ +void Joy_AdvancedUpdate_f (void) +{ + + // called once by IN_ReadJoystick and by user whenever an update is needed + // cvars are now available + int i; + DWORD dwTemp; + + // initialize all the maps + for (i = 0; i < JOY_MAX_AXES; i++) + { + dwAxisMap[i] = AxisNada; + dwControlMap[i] = JOY_ABSOLUTE_AXIS; + pdwRawValue[i] = RawValuePointer(i); + } + + if( joy_advanced->value == 0.0) + { + // default joystick initialization + // 2 axes only with joystick control + dwAxisMap[JOY_AXIS_X] = AxisTurn; + // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS; + dwAxisMap[JOY_AXIS_Y] = AxisForward; + // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS; + } + else + { + if ( strcmp ( joy_name->string, "joystick") != 0 ) + { + // notify user of advanced controller + gEngfuncs.Con_Printf ("\n%s configured\n\n", joy_name->string); + } + + // advanced initialization here + // data supplied by user via joy_axisn cvars + dwTemp = (DWORD) joy_advaxisx->value; + dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisy->value; + dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisz->value; + dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisr->value; + dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisu->value; + dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; + dwTemp = (DWORD) joy_advaxisv->value; + dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; + dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; + } +} + + +/* +=========== +IN_Commands +=========== +*/ +void IN_Commands (void) +{ + int i, key_index; + + if (!joy_avail) + { + return; + } + + DWORD buttonstate, povstate; + + // loop through the joystick buttons + // key a joystick event or auxillary event for higher number buttons for each state change + buttonstate = 0; +#ifdef USE_SDL2 + for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) + { + if ( SDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + { + buttonstate |= 1<value) + { + return; + } + + // collect the joystick data, if possible + if (IN_ReadJoystick () != 1) + { + return; + } + + if (in_speed.state & 1) + speed = cl_movespeedkey->value; + else + speed = 1; + + aspeed = speed * frametime; + + // loop through the axes + for (i = 0; i < JOY_MAX_AXES; i++) + { + // get the floating point zero-centered, potentially-inverted data for the current axis + fAxisValue = (float)pdwRawValue[i]; + + if (joy_wwhack2->value != 0.0) + { + if (dwAxisMap[i] == AxisTurn) + { + // this is a special formula for the Logitech WingMan Warrior + // 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); + if (fTemp > 14000.0) + fTemp = 14000.0; + // restore direction information + fAxisValue = (fAxisValue > 0.0) ? fTemp : -fTemp; + } + } + + // convert range from -32768..32767 to -1..1 + fAxisValue /= 32768.0; + + switch (dwAxisMap[i]) + { + case AxisForward: + if ((joy_advanced->value == 0.0) && (in_jlook.state & 1)) + { + // user wants forward control to become look control + if (fabs(fAxisValue) > joy_pitchthreshold->value) + { + // if mouse invert is on, invert the joystick pitch value + // only absolute control support here (joy_advanced is 0) + if (m_pitch->value < 0.0) + { + viewangles[PITCH] -= (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + else + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + V_StopPitchDrift(); + } + else + { + // no pitch movement + // disable pitch return-to-center unless requested by user + // *** this code can be removed when the lookspring bug is fixed + // *** the bug always has the lookspring feature on + if(lookspring->value == 0.0) + { + V_StopPitchDrift(); + } + } + } + else + { + // user wants forward control to be forward control + if (fabs(fAxisValue) > joy_forwardthreshold->value) + { + cmd->forwardmove += (fAxisValue * joy_forwardsensitivity->value) * speed * cl_forwardspeed->value; + } + } + break; + + case AxisSide: + if (fabs(fAxisValue) > joy_sidethreshold->value) + { + cmd->sidemove += (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + } + break; + + case AxisTurn: + if ((in_strafe.state & 1) || (lookstrafe->value && (in_jlook.state & 1))) + { + // user wants turn control to become side control + if (fabs(fAxisValue) > joy_sidethreshold->value) + { + cmd->sidemove -= (fAxisValue * joy_sidesensitivity->value) * speed * cl_sidespeed->value; + } + } + else + { + // user wants turn control to be turn control + if (fabs(fAxisValue) > joy_yawthreshold->value) + { + if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + { + viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * aspeed * cl_yawspeed->value; + } + else + { + viewangles[YAW] += (fAxisValue * joy_yawsensitivity->value) * speed * 180.0; + } + + } + } + break; + + case AxisLook: + if (in_jlook.state & 1) + { + if (fabs(fAxisValue) > joy_pitchthreshold->value) + { + // pitch movement detected and pitch movement desired by user + if(dwControlMap[i] == JOY_ABSOLUTE_AXIS) + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * aspeed * cl_pitchspeed->value; + } + else + { + viewangles[PITCH] += (fAxisValue * joy_pitchsensitivity->value) * speed * 180.0; + } + V_StopPitchDrift(); + } + else + { + // no pitch movement + // disable pitch return-to-center unless requested by user + // *** this code can be removed when the lookspring bug is fixed + // *** the bug always has the lookspring feature on + if( lookspring->value == 0.0 ) + { + V_StopPitchDrift(); + } + } + } + break; + + default: + break; + } + } + + // bounds check pitch + if (viewangles[PITCH] > cl_pitchdown->value) + viewangles[PITCH] = cl_pitchdown->value; + if (viewangles[PITCH] < -cl_pitchup->value) + viewangles[PITCH] = -cl_pitchup->value; + + gEngfuncs.SetViewAngles( (float *)viewangles ); +} + +/* +=========== +IN_Move +=========== +*/ +void IN_Move ( float frametime, usercmd_t *cmd) +{ + if ( !iMouseInUse && mouseactive ) + { + IN_MouseMove ( frametime, cmd); + } + + IN_JoyMove ( frametime, cmd); +} + +/* +=========== +IN_Init +=========== +*/ +void IN_Init (void) +{ + m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); + sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. + + in_joystick = gEngfuncs.pfnRegisterVariable ( "joystick","0", FCVAR_ARCHIVE ); + joy_name = gEngfuncs.pfnRegisterVariable ( "joyname", "joystick", 0 ); + joy_advanced = gEngfuncs.pfnRegisterVariable ( "joyadvanced", "0", 0 ); + joy_advaxisx = gEngfuncs.pfnRegisterVariable ( "joyadvaxisx", "0", 0 ); + joy_advaxisy = gEngfuncs.pfnRegisterVariable ( "joyadvaxisy", "0", 0 ); + joy_advaxisz = gEngfuncs.pfnRegisterVariable ( "joyadvaxisz", "0", 0 ); + joy_advaxisr = gEngfuncs.pfnRegisterVariable ( "joyadvaxisr", "0", 0 ); + joy_advaxisu = gEngfuncs.pfnRegisterVariable ( "joyadvaxisu", "0", 0 ); + joy_advaxisv = gEngfuncs.pfnRegisterVariable ( "joyadvaxisv", "0", 0 ); + joy_forwardthreshold = gEngfuncs.pfnRegisterVariable ( "joyforwardthreshold", "0.15", 0 ); + joy_sidethreshold = gEngfuncs.pfnRegisterVariable ( "joysidethreshold", "0.15", 0 ); + joy_pitchthreshold = gEngfuncs.pfnRegisterVariable ( "joypitchthreshold", "0.15", 0 ); + joy_yawthreshold = gEngfuncs.pfnRegisterVariable ( "joyyawthreshold", "0.15", 0 ); + joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable ( "joyforwardsensitivity", "-1.0", 0 ); + joy_sidesensitivity = gEngfuncs.pfnRegisterVariable ( "joysidesensitivity", "-1.0", 0 ); + joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable ( "joypitchsensitivity", "1.0", 0 ); + joy_yawsensitivity = gEngfuncs.pfnRegisterVariable ( "joyyawsensitivity", "-1.0", 0 ); + joy_wwhack1 = gEngfuncs.pfnRegisterVariable ( "joywwhack1", "0.0", 0 ); + joy_wwhack2 = gEngfuncs.pfnRegisterVariable ( "joywwhack2", "0.0", 0 ); + + m_customaccel = gEngfuncs.pfnRegisterVariable ( "m_customaccel", "0", FCVAR_ARCHIVE ); + m_customaccel_scale = gEngfuncs.pfnRegisterVariable ( "m_customaccel_scale", "0.04", FCVAR_ARCHIVE ); + m_customaccel_max = gEngfuncs.pfnRegisterVariable ( "m_customaccel_max", "0", FCVAR_ARCHIVE ); + m_customaccel_exponent = gEngfuncs.pfnRegisterVariable ( "m_customaccel_exponent", "1", FCVAR_ARCHIVE ); + +#ifdef _WIN32 + m_bRawInput = CVAR_GET_FLOAT( "m_rawinput" ) != 0; + m_bMouseThread = gEngfuncs.CheckParm ("-mousethread", NULL ) != NULL; + m_mousethread_sleep = gEngfuncs.pfnRegisterVariable ( "m_mousethread_sleep", "1", FCVAR_ARCHIVE ); // default to less than 1000 Hz + + m_bMouseThread = m_bMouseThread && NULL != m_mousethread_sleep; + + if (m_bMouseThread) + { + // init mouseThreadSleep: +#if 0 // _beginthreadex is not defined on VS 6? + InterlockedExchange(&mouseThreadSleep, (LONG)m_mousethread_sleep->value); + + s_hMouseQuitEvent = CreateEvent( NULL, FALSE, FALSE, NULL ); + s_hMouseThreadActiveLock = CreateEvent( NULL, FALSE, TRUE, NULL ); + if ( s_hMouseQuitEvent && s_hMouseThreadActiveLock) + { + s_hMouseThread = (HANDLE)_beginthreadex( NULL, 0, MouseThread_Function, NULL, 0, &s_hMouseThreadId ); + } + + m_bMouseThread = NULL != s_hMouseThread; +#else + m_bMouseThread = 0; +#endif + + // at this early stage this won't print anything: + // gEngfuncs.Con_DPrintf ("Mouse thread %s.\n", m_bMouseThread ? "initalized" : "failed to initalize"); + } +#endif + + gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); + gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); + + IN_StartupMouse (); + IN_StartupJoystick (); +} diff --git a/cl_dll/inputw32.cpp b/cl_dll/inputw32.cpp deleted file mode 100644 index 5c8210fa..00000000 --- a/cl_dll/inputw32.cpp +++ /dev/null @@ -1,901 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -// in_win.c -- windows 95 mouse and joystick code -// 02/21/97 JCB Added extended DirectInput code to support external controllers. - -#include "hud.h" -#include "cl_util.h" -#include "camera.h" -#include "kbutton.h" -#include "cvardef.h" -#include "usercmd.h" -#include "const.h" -#include "camera.h" -#include "in_defs.h" -#include "../engine/keydefs.h" -//#include "view.h" -#include "windows.h" - -#define MOUSE_BUTTON_COUNT 5 - -// Set this to 1 to show mouse cursor. Experimental -int g_iVisibleMouse = 0; - -extern "C" -{ - void DLLEXPORT IN_ActivateMouse( void ); - void DLLEXPORT IN_DeactivateMouse( void ); - void DLLEXPORT IN_MouseEvent( int mstate ); - void DLLEXPORT IN_Accumulate( void ); - void DLLEXPORT IN_ClearStates( void ); -} - -extern cl_enginefunc_t gEngfuncs; - -extern int iMouseInUse; - -extern kbutton_t in_strafe; -extern kbutton_t in_mlook; -extern kbutton_t in_speed; -extern kbutton_t in_jlook; - -extern cvar_t *m_pitch; -extern cvar_t *m_yaw; -extern cvar_t *m_forward; -extern cvar_t *m_side; - -extern cvar_t *lookstrafe; -extern cvar_t *lookspring; -extern cvar_t *cl_pitchdown; -extern cvar_t *cl_pitchup; -extern cvar_t *cl_yawspeed; -extern cvar_t *cl_sidespeed; -extern cvar_t *cl_forwardspeed; -extern cvar_t *cl_pitchspeed; -extern cvar_t *cl_movespeedkey; - -// mouse variables -cvar_t *m_filter; -cvar_t *sensitivity; - -int mouse_buttons; -int mouse_oldbuttonstate; -POINT current_pos; -int mouse_x, mouse_y, old_mouse_x, old_mouse_y, mx_accum, my_accum; - -static int restore_spi; -static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; -static int mouseactive; -int mouseinitialized; -static int mouseparmsvalid; -static int mouseshowtoggle = 1; - -// joystick defines and variables -// where should defines be moved? -#define JOY_ABSOLUTE_AXIS 0x00000000 // control like a joystick -#define JOY_RELATIVE_AXIS 0x00000010 // control like a mouse, spinner, trackball -#define JOY_MAX_AXES 6 // X, Y, Z, R, U, V -#define JOY_AXIS_X 0 -#define JOY_AXIS_Y 1 -#define JOY_AXIS_Z 2 -#define JOY_AXIS_R 3 -#define JOY_AXIS_U 4 -#define JOY_AXIS_V 5 - -enum _ControlList -{ - AxisNada = 0, - AxisForward, - AxisLook, - AxisSide, - AxisTurn -}; - -DWORD dwAxisFlags[JOY_MAX_AXES] = -{ - JOY_RETURNX, - JOY_RETURNY, - JOY_RETURNZ, - JOY_RETURNR, - JOY_RETURNU, - JOY_RETURNV -}; - -DWORD dwAxisMap[JOY_MAX_AXES]; -DWORD dwControlMap[JOY_MAX_AXES]; -PDWORD pdwRawValue[JOY_MAX_AXES]; - -// none of these cvars are saved over a session -// this means that advanced controller configuration needs to be executed -// each time. this avoids any problems with getting back to a default usage -// or when changing from one controller to another. this way at least something -// works. -cvar_t *in_joystick; -cvar_t *joy_name; -cvar_t *joy_advanced; -cvar_t *joy_advaxisx; -cvar_t *joy_advaxisy; -cvar_t *joy_advaxisz; -cvar_t *joy_advaxisr; -cvar_t *joy_advaxisu; -cvar_t *joy_advaxisv; -cvar_t *joy_forwardthreshold; -cvar_t *joy_sidethreshold; -cvar_t *joy_pitchthreshold; -cvar_t *joy_yawthreshold; -cvar_t *joy_forwardsensitivity; -cvar_t *joy_sidesensitivity; -cvar_t *joy_pitchsensitivity; -cvar_t *joy_yawsensitivity; -cvar_t *joy_wwhack1; -cvar_t *joy_wwhack2; - -int joy_avail, joy_advancedinit, joy_haspov; -DWORD joy_oldbuttonstate, joy_oldpovstate; - -int joy_id; -DWORD joy_flags; -DWORD joy_numbuttons; - -static JOYINFOEX ji; - -/* -=========== -Force_CenterView_f -=========== -*/ -void Force_CenterView_f( void ) -{ - vec3_t viewangles; - - if( !iMouseInUse ) - { - gEngfuncs.GetViewAngles( (float *)viewangles ); - viewangles[PITCH] = 0; - gEngfuncs.SetViewAngles( (float *)viewangles ); - } -} - -/* -=========== -IN_ActivateMouse -=========== -*/ -void DLLEXPORT IN_ActivateMouse( void ) -{ - if( mouseinitialized ) - { - if( mouseparmsvalid ) - restore_spi = SystemParametersInfo( SPI_SETMOUSE, 0, newmouseparms, 0 ); - mouseactive = 1; - } -} - -/* -=========== -IN_DeactivateMouse -=========== -*/ -void DLLEXPORT IN_DeactivateMouse( void ) -{ - if( mouseinitialized ) - { - if( restore_spi ) - SystemParametersInfo( SPI_SETMOUSE, 0, originalmouseparms, 0 ); - mouseactive = 0; - } -} - -/* -=========== -IN_StartupMouse -=========== -*/ -void IN_StartupMouse( void ) -{ - if( gEngfuncs.CheckParm( "-nomouse", NULL ) ) - return; - - mouseinitialized = 1; - mouseparmsvalid = SystemParametersInfo( SPI_GETMOUSE, 0, originalmouseparms, 0 ); - - if( mouseparmsvalid ) - { - if( gEngfuncs.CheckParm( "-noforcemspd", NULL ) ) - newmouseparms[2] = originalmouseparms[2]; - - if( gEngfuncs.CheckParm( "-noforcemaccel", NULL ) ) - { - newmouseparms[0] = originalmouseparms[0]; - newmouseparms[1] = originalmouseparms[1]; - } - - if( gEngfuncs.CheckParm( "-noforcemparms", NULL ) ) - { - newmouseparms[0] = originalmouseparms[0]; - newmouseparms[1] = originalmouseparms[1]; - newmouseparms[2] = originalmouseparms[2]; - } - } - - mouse_buttons = MOUSE_BUTTON_COUNT; -} - -/* -=========== -IN_Shutdown -=========== -*/ -void IN_Shutdown( void ) -{ - IN_DeactivateMouse (); -} - -/* -=========== -IN_GetMousePos - -Ask for mouse position from engine -=========== -*/ -void IN_GetMousePos( int *mx, int *my ) -{ - gEngfuncs.GetMousePosition( mx, my ); -} - -/* -=========== -IN_ResetMouse - -FIXME: Call through to engine? -=========== -*/ -void IN_ResetMouse( void ) -{ - SetCursorPos ( gEngfuncs.GetWindowCenterX(), gEngfuncs.GetWindowCenterY() ); -} - -/* -=========== -IN_MouseEvent -=========== -*/ -void DLLEXPORT IN_MouseEvent( int mstate ) -{ - int i; - - if( iMouseInUse || g_iVisibleMouse ) - return; - - // perform button actions - for( i = 0; i < mouse_buttons; i++ ) - { - if( ( mstate & ( 1 << i ) ) && - !( mouse_oldbuttonstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_MOUSE1 + i, 1 ); - } - - if( !( mstate & ( 1 << i ) ) && - ( mouse_oldbuttonstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_MOUSE1 + i, 0 ); - } - } - - mouse_oldbuttonstate = mstate; -} - -/* -=========== -IN_MouseMove -=========== -*/ -void IN_MouseMove( float frametime, usercmd_t *cmd ) -{ - int mx, my; - vec3_t viewangles; - - gEngfuncs.GetViewAngles( (float *)viewangles ); - - //jjb - this disbles normal mouse control if the user is trying to - // move the camera, or if the mouse cursor is visible or if we're in intermission - if( !iMouseInUse && !g_iVisibleMouse && !gHUD.m_iIntermission ) - { - GetCursorPos( ¤t_pos ); - - mx = current_pos.x - gEngfuncs.GetWindowCenterX() + mx_accum; - my = current_pos.y - gEngfuncs.GetWindowCenterY() + my_accum; - - mx_accum = 0; - my_accum = 0; - - if( m_filter->value ) - { - mouse_x = ( mx + old_mouse_x ) * 0.5; - mouse_y = ( my + old_mouse_y ) * 0.5; - } - else - { - mouse_x = mx; - mouse_y = my; - } - - old_mouse_x = mx; - old_mouse_y = my; - - if( gHUD.GetSensitivity() != 0 ) - { - mouse_x *= gHUD.GetSensitivity(); - mouse_y *= gHUD.GetSensitivity(); - } - else - { - mouse_x *= sensitivity->value; - mouse_y *= sensitivity->value; - } - - // add mouse X/Y movement to cmd - if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_mlook.state & 1 ) ) ) - cmd->sidemove += m_side->value * mouse_x; - else - viewangles[YAW] -= m_yaw->value * mouse_x; - - if( ( in_mlook.state & 1 ) && !( in_strafe.state & 1 ) ) - { - viewangles[PITCH] += m_pitch->value * mouse_y; - if( viewangles[PITCH] > cl_pitchdown->value ) - viewangles[PITCH] = cl_pitchdown->value; - if( viewangles[PITCH] < -cl_pitchup->value ) - viewangles[PITCH] = -cl_pitchup->value; - } - else - { - if( ( in_strafe.state & 1 ) && gEngfuncs.IsNoClipping() ) - { - cmd->upmove -= m_forward->value * mouse_y; - } - else - { - cmd->forwardmove -= m_forward->value * mouse_y; - } - } - - // if the mouse has moved, force it to the center, so there's room to move - if( mx || my ) - { - IN_ResetMouse(); - } - } - - gEngfuncs.SetViewAngles( (float *)viewangles ); - -/* -//#define TRACE_TEST -#if defined( TRACE_TEST ) - { - int mx, my; - void V_Move( int mx, int my ); - IN_GetMousePos( &mx, &my ); - V_Move( mx, my ); - } -#endif -*/ -} - -/* -=========== -IN_Accumulate -=========== -*/ -void DLLEXPORT IN_Accumulate( void ) -{ - //only accumulate mouse if we are not moving the camera with the mouse - if( !iMouseInUse && !g_iVisibleMouse ) - { - if( mouseactive ) - { - GetCursorPos( ¤t_pos ); - - mx_accum += current_pos.x - gEngfuncs.GetWindowCenterX(); - my_accum += current_pos.y - gEngfuncs.GetWindowCenterY(); - - // force the mouse to the center, so there's room to move - IN_ResetMouse(); - } - } -} - -/* -=================== -IN_ClearStates -=================== -*/ -void DLLEXPORT IN_ClearStates( void ) -{ - if( !mouseactive ) - return; - - mx_accum = 0; - my_accum = 0; - mouse_oldbuttonstate = 0; -} - -/* -=============== -IN_StartupJoystick -=============== -*/ -void IN_StartupJoystick( void ) -{ - int numdevs; - JOYCAPS jc; - MMRESULT mmr; - - // assume no joystick - joy_avail = 0; - - // abort startup if user requests no joystick - if( gEngfuncs.CheckParm( "-nojoy", NULL ) ) - return; - - // verify joystick driver is present - if( ( numdevs = joyGetNumDevs() ) == 0 ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- driver not present\n\n" ); - return; - } - - // cycle through the joystick ids for the first valid one - for( joy_id = 0; joy_id < numdevs; joy_id++ ) - { - memset( &ji, 0, sizeof(ji) ); - ji.dwSize = sizeof(ji); - ji.dwFlags = JOY_RETURNCENTERED; - - if( ( mmr = joyGetPosEx( joy_id, &ji ) ) == JOYERR_NOERROR ) - break; - } - - // abort startup if we didn't find a valid joystick - if( mmr != JOYERR_NOERROR ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- no valid joysticks (%x)\n\n", mmr ); - return; - } - - // get the capabilities of the selected joystick - // abort startup if command fails - memset( &jc, 0, sizeof(jc) ); - if( ( mmr = joyGetDevCaps( joy_id, &jc, sizeof(jc) ) ) != JOYERR_NOERROR ) - { - gEngfuncs.Con_DPrintf( "joystick not found -- invalid joystick capabilities (%x)\n\n", mmr ); - return; - } - - // save the joystick's number of buttons and POV status - joy_numbuttons = jc.wNumButtons; - joy_haspov = jc.wCaps & JOYCAPS_HASPOV; - - // old button and POV states default to no buttons pressed - joy_oldbuttonstate = joy_oldpovstate = 0; - - // mark the joystick as available and advanced initialization not completed - // this is needed as cvars are not available during initialization - gEngfuncs.Con_Printf( "joystick found\n\n", mmr ); - joy_avail = 1; - joy_advancedinit = 0; -} - -/* -=========== -RawValuePointer -=========== -*/ -PDWORD RawValuePointer( int axis ) -{ - switch( axis ) - { - case JOY_AXIS_X: - return &ji.dwXpos; - case JOY_AXIS_Y: - return &ji.dwYpos; - case JOY_AXIS_Z: - return &ji.dwZpos; - case JOY_AXIS_R: - return &ji.dwRpos; - case JOY_AXIS_U: - return &ji.dwUpos; - case JOY_AXIS_V: - return &ji.dwVpos; - } - // FIX: need to do some kind of error - return &ji.dwXpos; -} - -/* -=========== -Joy_AdvancedUpdate_f -=========== -*/ -void Joy_AdvancedUpdate_f( void ) -{ - // called once by IN_ReadJoystick and by user whenever an update is needed - // cvars are now available - int i; - DWORD dwTemp; - - // initialize all the maps - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - dwAxisMap[i] = AxisNada; - dwControlMap[i] = JOY_ABSOLUTE_AXIS; - pdwRawValue[i] = RawValuePointer(i); - } - - if( joy_advanced->value == 0.0 ) - { - // default joystick initialization - // 2 axes only with joystick control - dwAxisMap[JOY_AXIS_X] = AxisTurn; - // dwControlMap[JOY_AXIS_X] = JOY_ABSOLUTE_AXIS; - dwAxisMap[JOY_AXIS_Y] = AxisForward; - // dwControlMap[JOY_AXIS_Y] = JOY_ABSOLUTE_AXIS; - } - else - { - if( strcmp( joy_name->string, "joystick" ) != 0 ) - { - // notify user of advanced controller - gEngfuncs.Con_Printf( "\n%s configured\n\n", joy_name->string ); - } - - // advanced initialization here - // data supplied by user via joy_axisn cvars - dwTemp = (DWORD)joy_advaxisx->value; - dwAxisMap[JOY_AXIS_X] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_X] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisy->value; - dwAxisMap[JOY_AXIS_Y] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Y] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisz->value; - dwAxisMap[JOY_AXIS_Z] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_Z] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisr->value; - dwAxisMap[JOY_AXIS_R] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_R] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisu->value; - dwAxisMap[JOY_AXIS_U] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_U] = dwTemp & JOY_RELATIVE_AXIS; - dwTemp = (DWORD)joy_advaxisv->value; - dwAxisMap[JOY_AXIS_V] = dwTemp & 0x0000000f; - dwControlMap[JOY_AXIS_V] = dwTemp & JOY_RELATIVE_AXIS; - } - - // compute the axes to collect from DirectInput - joy_flags = JOY_RETURNCENTERED | JOY_RETURNBUTTONS | JOY_RETURNPOV; - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - if( dwAxisMap[i] != AxisNada ) - { - joy_flags |= dwAxisFlags[i]; - } - } -} - -/* -=========== -IN_Commands -=========== -*/ -void IN_Commands( void ) -{ - int i, key_index; - DWORD buttonstate, povstate; - - if( !joy_avail ) - { - return; - } - - // loop through the joystick buttons - // key a joystick event or auxillary event for higher number buttons for each state change - buttonstate = ji.dwButtons; - for( i = 0; i < (int)joy_numbuttons; i++ ) - { - if( ( buttonstate & ( 1 << i ) ) && !( joy_oldbuttonstate & ( 1 << i ) ) ) - { - key_index = ( i < 4 ) ? K_JOY1 : K_AUX1; - gEngfuncs.Key_Event( key_index + i, 1 ); - } - - if( !( buttonstate & ( 1 << i ) ) && ( joy_oldbuttonstate & ( 1 << i ) ) ) - { - key_index = ( i < 4 ) ? K_JOY1 : K_AUX1; - gEngfuncs.Key_Event( key_index + i, 0 ); - } - } - joy_oldbuttonstate = buttonstate; - - if( joy_haspov ) - { - // convert POV information into 4 bits of state information - // this avoids any potential problems related to moving from one - // direction to another without going through the center position - povstate = 0; - if( ji.dwPOV != JOY_POVCENTERED ) - { - if( ji.dwPOV == JOY_POVFORWARD ) - povstate |= 0x01; - if( ji.dwPOV == JOY_POVRIGHT ) - povstate |= 0x02; - if( ji.dwPOV == JOY_POVBACKWARD ) - povstate |= 0x04; - if( ji.dwPOV == JOY_POVLEFT ) - povstate |= 0x08; - } - // determine which bits have changed and key an auxillary event for each change - for( i = 0; i < 4; i++ ) - { - if( ( povstate & ( 1 << i ) ) && !( joy_oldpovstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_AUX29 + i, 1 ); - } - - if( !( povstate & ( 1 << i ) ) && ( joy_oldpovstate & ( 1 << i ) ) ) - { - gEngfuncs.Key_Event( K_AUX29 + i, 0 ); - } - } - joy_oldpovstate = povstate; - } -} - -/* -=============== -IN_ReadJoystick -=============== -*/ -int IN_ReadJoystick( void ) -{ - memset( &ji, 0, sizeof(ji) ); - ji.dwSize = sizeof(ji); - ji.dwFlags = joy_flags; - - if( joyGetPosEx( joy_id, &ji ) == JOYERR_NOERROR ) - { - // this is a hack -- there is a bug in the Logitech WingMan Warrior DirectInput Driver - // rather than having 32768 be the zero point, they have the zero point at 32668 - // go figure -- anyway, now we get the full resolution out of the device - if( joy_wwhack1->value != 0.0 ) - { - ji.dwUpos += 100; - } - return 1; - } - else - { - // read error occurred - // turning off the joystick seems too harsh for 1 read error,\ - // but what should be done? - // Con_Printf( "IN_ReadJoystick: no response\n" ); - // joy_avail = 0; - return 0; - } -} - -/* -=========== -IN_JoyMove -=========== -*/ -void IN_JoyMove( float frametime, usercmd_t *cmd ) -{ - float speed, aspeed; - float fAxisValue, fTemp; - int i; - vec3_t viewangles; - - gEngfuncs.GetViewAngles( (float *)viewangles ); - - // complete initialization if first time in - // this is needed as cvars are not available at initialization time - if( joy_advancedinit != 1 ) - { - Joy_AdvancedUpdate_f(); - joy_advancedinit = 1; - } - - // verify joystick is available and that the user wants to use it - if( !joy_avail || !in_joystick->value ) - { - return; - } - - // collect the joystick data, if possible - if( IN_ReadJoystick () != 1 ) - { - return; - } - - if( in_speed.state & 1 ) - speed = cl_movespeedkey->value; - else - speed = 1; - - aspeed = speed * frametime; - - // loop through the axes - for( i = 0; i < JOY_MAX_AXES; i++ ) - { - // get the floating point zero-centered, potentially-inverted data for the current axis - fAxisValue = (float) *pdwRawValue[i]; - // move centerpoint to zero - fAxisValue -= 32768.0; - - if( joy_wwhack2->value != 0.0 ) - { - if( dwAxisMap[i] == AxisTurn ) - { - // this is a special formula for the Logitech WingMan Warrior - // 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 ); - if( fTemp > 14000.0 ) - fTemp = 14000.0; - // restore direction information - fAxisValue = ( fAxisValue > 0.0 ) ? fTemp : -fTemp; - } - } - - // convert range from -32768..32767 to -1..1 - fAxisValue /= 32768.0; - - switch( dwAxisMap[i] ) - { - case AxisForward: - if( ( joy_advanced->value == 0.0 ) && ( in_jlook.state & 1 ) ) - { - // user wants forward control to become look control - if( fabs( fAxisValue ) > joy_pitchthreshold->value ) - { - // if mouse invert is on, invert the joystick pitch value - // only absolute control support here (joy_advanced is 0) - if( m_pitch->value < 0.0 ) - { - viewangles[PITCH] -= ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - else - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - } - } - else - { - // user wants forward control to be forward control - if( fabs( fAxisValue ) > joy_forwardthreshold->value ) - { - cmd->forwardmove += ( fAxisValue * joy_forwardsensitivity->value ) * speed * cl_forwardspeed->value; - } - } - break; - case AxisSide: - if( fabs( fAxisValue ) > joy_sidethreshold->value ) - { - cmd->sidemove += ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; - } - break; - case AxisTurn: - if( ( in_strafe.state & 1 ) || ( lookstrafe->value && ( in_jlook.state & 1 ) ) ) - { - // user wants turn control to become side control - if( fabs( fAxisValue ) > joy_sidethreshold->value ) - { - cmd->sidemove -= ( fAxisValue * joy_sidesensitivity->value ) * speed * cl_sidespeed->value; - } - } - else - { - // user wants turn control to be turn control - if( fabs( fAxisValue ) > joy_yawthreshold->value ) - { - if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) - { - viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * aspeed * cl_yawspeed->value; - } - else - { - viewangles[YAW] += ( fAxisValue * joy_yawsensitivity->value ) * speed * 180.0; - } - } - } - break; - case AxisLook: - if( in_jlook.state & 1 ) - { - if( fabs( fAxisValue ) > joy_pitchthreshold->value ) - { - // pitch movement detected and pitch movement desired by user - if( dwControlMap[i] == JOY_ABSOLUTE_AXIS ) - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * aspeed * cl_pitchspeed->value; - } - else - { - viewangles[PITCH] += ( fAxisValue * joy_pitchsensitivity->value ) * speed * 180.0; - } - } - } - break; - default: - break; - } - } - - // bounds check pitch - if( viewangles[PITCH] > cl_pitchdown->value ) - viewangles[PITCH] = cl_pitchdown->value; - if( viewangles[PITCH] < -cl_pitchup->value ) - viewangles[PITCH] = -cl_pitchup->value; - - gEngfuncs.SetViewAngles( (float *)viewangles ); -} - -/* -=========== -IN_Move -=========== -*/ -void IN_Move( float frametime, usercmd_t *cmd ) -{ - if( !iMouseInUse && mouseactive ) - { - IN_MouseMove( frametime, cmd ); - } - - IN_JoyMove( frametime, cmd ); -} - -/* -=========== -IN_Init -=========== -*/ -void IN_Init( void ) -{ - m_filter = gEngfuncs.pfnRegisterVariable( "m_filter","0", FCVAR_ARCHIVE ); - sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. - - in_joystick = gEngfuncs.pfnRegisterVariable( "joystick","0", FCVAR_ARCHIVE ); - joy_name = gEngfuncs.pfnRegisterVariable( "joyname", "joystick", 0 ); - joy_advanced = gEngfuncs.pfnRegisterVariable( "joyadvanced", "0", 0 ); - joy_advaxisx = gEngfuncs.pfnRegisterVariable( "joyadvaxisx", "0", 0 ); - joy_advaxisy = gEngfuncs.pfnRegisterVariable( "joyadvaxisy", "0", 0 ); - joy_advaxisz = gEngfuncs.pfnRegisterVariable( "joyadvaxisz", "0", 0 ); - joy_advaxisr = gEngfuncs.pfnRegisterVariable( "joyadvaxisr", "0", 0 ); - joy_advaxisu = gEngfuncs.pfnRegisterVariable( "joyadvaxisu", "0", 0 ); - joy_advaxisv = gEngfuncs.pfnRegisterVariable( "joyadvaxisv", "0", 0 ); - joy_forwardthreshold = gEngfuncs.pfnRegisterVariable( "joyforwardthreshold", "0.15", 0 ); - joy_sidethreshold = gEngfuncs.pfnRegisterVariable( "joysidethreshold", "0.15", 0 ); - joy_pitchthreshold = gEngfuncs.pfnRegisterVariable( "joypitchthreshold", "0.15", 0 ); - joy_yawthreshold = gEngfuncs.pfnRegisterVariable( "joyyawthreshold", "0.15", 0 ); - joy_forwardsensitivity = gEngfuncs.pfnRegisterVariable( "joyforwardsensitivity", "-1.0", 0 ); - joy_sidesensitivity = gEngfuncs.pfnRegisterVariable( "joysidesensitivity", "-1.0", 0 ); - joy_pitchsensitivity = gEngfuncs.pfnRegisterVariable( "joypitchsensitivity", "1.0", 0 ); - joy_yawsensitivity = gEngfuncs.pfnRegisterVariable( "joyyawsensitivity", "-1.0", 0 ); - joy_wwhack1 = gEngfuncs.pfnRegisterVariable( "joywwhack1", "0.0", 0 ); - joy_wwhack2 = gEngfuncs.pfnRegisterVariable( "joywwhack2", "0.0", 0 ); - - gEngfuncs.pfnAddCommand ("force_centerview", Force_CenterView_f); - gEngfuncs.pfnAddCommand ("joyadvancedupdate", Joy_AdvancedUpdate_f); - - IN_StartupMouse (); - IN_StartupJoystick (); -} From 1d8d1b5d2e7d804e41c844642bb541cc17be4001 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 3 Dec 2017 23:52:35 +0300 Subject: [PATCH 129/199] Use mouse input backend depending on the current engine --- cl_dll/CMakeLists.txt | 11 ++--- cl_dll/cl_dll.h | 3 ++ cl_dll/hud.h | 4 +- cl_dll/input_goldsource.cpp | 43 +++++++++---------- cl_dll/input_mouse.cpp | 82 +++++++++++++++++++++++++++++++++++++ cl_dll/input_mouse.h | 77 ++++++++++++++++++++++++++++++++++ cl_dll/input_xash3d.cpp | 41 +++++++------------ 7 files changed, 204 insertions(+), 57 deletions(-) create mode 100644 cl_dll/input_mouse.cpp create mode 100644 cl_dll/input_mouse.h diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 7bd04f77..776f9bd9 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,7 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lSDL2 -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2 -Wl,--no-undefined") endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -73,6 +73,9 @@ set (CLDLL_SOURCES hud_update.cpp in_camera.cpp input.cpp + input_goldsource.cpp + input_mouse.cpp + input_xash3d.cpp menu.cpp message.cpp overview.cpp @@ -93,12 +96,6 @@ set (CLDLL_SOURCES scoreboard.cpp MOTD.cpp) -if (GOLDSOURCE_SUPPORT) - set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_goldsource.cpp) -else() - set (CLDLL_SOURCES "${CLDLL_SOURCES}" input_xash3d.cpp) -endif() - include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) if(USE_VOICEMGR) diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 24d1874b..0acd6860 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -25,6 +25,8 @@ // - Drawing the HUD graphics every frame // - Handling the custum HUD-update packets // +#ifndef CL_DLL_H +#define CL_DLL_H typedef unsigned char byte; typedef unsigned short word; typedef float vec_t; @@ -48,3 +50,4 @@ typedef int ( *pfnUserMsgHook )( const char *pszName, int iSize, void *pbuf ); extern cl_enginefunc_t gEngfuncs; #include "../engine/mobility_int.h" extern mobile_engfuncs_t *gMobileEngfuncs; +#endif diff --git a/cl_dll/hud.h b/cl_dll/hud.h index ab179bbb..1970753d 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -19,7 +19,8 @@ // // CHud handles the message, calculation, and drawing the HUD // - +#ifndef HUD_H +#define HUD_H #define RGB_YELLOWISH 0x00FFA000 //255,160,0 #define RGB_REDISH 0x00FF1010 //255,160,0 #define RGB_GREENISH 0x0000A000 //0,160,0 @@ -677,3 +678,4 @@ extern int g_iTeamNumber; extern int g_iUser1; extern int g_iUser2; extern int g_iUser3; +#endif diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 70cd23c5..5c2b0381 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -8,20 +8,20 @@ // in_win.c -- windows 95 mouse and joystick code // 02/21/97 JCB Added extended DirectInput code to support external controllers. -//#include "port.h" +#include "input_mouse.h" + +#ifdef SUPPORT_GOLDSOURCE_INPUT #include "hud.h" #include "cl_util.h" #include "camera.h" #include "kbutton.h" #include "cvardef.h" -#include "usercmd.h" #include "const.h" #include "camera.h" #include "in_defs.h" #include "keydefs.h" #include "view.h" -//#include "Exports.h" #ifndef _WIN32 #define USE_SDL2 @@ -79,7 +79,7 @@ bool isMouseRelative = false; extern globalvars_t *gpGlobals; #endif -Vector dead_viewangles(0, 0, 0); +extern Vector dead_viewangles; void V_StopPitchDrift( void ) { @@ -88,7 +88,7 @@ void V_StopPitchDrift( void ) // mouse variables cvar_t *m_filter; -cvar_t *sensitivity; +extern cvar_t *sensitivity; // Custom mouse acceleration (0 disable, 1 to enable, 2 enable with separate yaw/pitch rescale) static cvar_t *m_customaccel; @@ -106,16 +106,11 @@ static cvar_t *m_customaccel_exponent; static cvar_t *m_mousethread_sleep; #endif -int mouse_buttons; -int mouse_oldbuttonstate; -POINT current_pos; -int old_mouse_x, old_mouse_y, mx_accum, my_accum; float mouse_x, mouse_y; static int restore_spi; static int originalmouseparms[3], newmouseparms[3] = {0, 0, 1}; static int mouseactive = 0; -int mouseinitialized; static int mouseparmsvalid; static int mouseshowtoggle = 1; @@ -158,7 +153,7 @@ SDL_GameController *s_pJoystick = NULL; // each time. this avoids any problems with getting back to a default usage // or when changing from one controller to another. this way at least something // works. -cvar_t *in_joystick; +extern cvar_t *in_joystick; cvar_t *joy_name; cvar_t *joy_advanced; cvar_t *joy_advaxisx; @@ -348,7 +343,7 @@ void IN_ResetMouse( void ); IN_ActivateMouse =========== */ -extern "C" void DLLEXPORT IN_ActivateMouse (void) +void GoldSourceInput::IN_ActivateMouse (void) { if (mouseinitialized) { @@ -376,7 +371,7 @@ extern "C" void DLLEXPORT IN_ActivateMouse (void) IN_DeactivateMouse =========== */ -extern "C" void DLLEXPORT IN_DeactivateMouse (void) +void GoldSourceInput::IN_DeactivateMouse (void) { if (mouseinitialized) { @@ -400,7 +395,7 @@ extern "C" void DLLEXPORT IN_DeactivateMouse (void) IN_StartupMouse =========== */ -void IN_StartupMouse (void) +void GoldSourceInput::IN_StartupMouse (void) { if ( gEngfuncs.CheckParm ("-nomouse", NULL ) ) return; @@ -437,7 +432,7 @@ void IN_StartupMouse (void) IN_Shutdown =========== */ -void IN_Shutdown (void) +void GoldSourceInput::IN_Shutdown (void) { IN_DeactivateMouse (); @@ -521,7 +516,7 @@ void IN_ResetMouse( void ) IN_MouseEvent =========== */ -extern "C" void DLLEXPORT IN_MouseEvent (int mstate) +void GoldSourceInput::IN_MouseEvent (int mstate) { int i; @@ -596,7 +591,7 @@ void IN_ScaleMouse( float *x, float *y ) } } -void IN_GetMouseDelta( int *pOutX, int *pOutY) +void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) { bool active = mouseactive && !iVisibleMouse; int mx, my; @@ -715,7 +710,7 @@ void IN_GetMouseDelta( int *pOutX, int *pOutY) IN_MouseMove =========== */ -void IN_MouseMove ( float frametime, usercmd_t *cmd) +void GoldSourceInput::IN_MouseMove ( float frametime, usercmd_t *cmd) { int mx, my; vec3_t viewangles; @@ -797,7 +792,7 @@ void IN_MouseMove ( float frametime, usercmd_t *cmd) IN_Accumulate =========== */ -extern "C" void DLLEXPORT IN_Accumulate (void) +void GoldSourceInput::IN_Accumulate (void) { //only accumulate mouse if we are not moving the camera with the mouse if ( !iMouseInUse && !iVisibleMouse) @@ -850,7 +845,7 @@ extern "C" void DLLEXPORT IN_Accumulate (void) IN_ClearStates =================== */ -extern "C" void DLLEXPORT IN_ClearStates (void) +void GoldSourceInput::IN_ClearStates (void) { if ( !mouseactive ) return; @@ -999,7 +994,7 @@ void Joy_AdvancedUpdate_f (void) IN_Commands =========== */ -void IN_Commands (void) +void GoldSourceInput::IN_Commands (void) { int i, key_index; @@ -1274,7 +1269,7 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) IN_Move =========== */ -void IN_Move ( float frametime, usercmd_t *cmd) +void GoldSourceInput::IN_Move ( float frametime, usercmd_t *cmd) { if ( !iMouseInUse && mouseactive ) { @@ -1289,7 +1284,7 @@ void IN_Move ( float frametime, usercmd_t *cmd) IN_Init =========== */ -void IN_Init (void) +void GoldSourceInput::IN_Init (void) { m_filter = gEngfuncs.pfnRegisterVariable ( "m_filter","0", FCVAR_ARCHIVE ); sensitivity = gEngfuncs.pfnRegisterVariable ( "sensitivity","3", FCVAR_ARCHIVE ); // user mouse sensitivity setting. @@ -1355,3 +1350,5 @@ void IN_Init (void) IN_StartupMouse (); IN_StartupJoystick (); } + +#endif diff --git a/cl_dll/input_mouse.cpp b/cl_dll/input_mouse.cpp new file mode 100644 index 00000000..724824cd --- /dev/null +++ b/cl_dll/input_mouse.cpp @@ -0,0 +1,82 @@ +#include "input_mouse.h" +#include "exportdef.h" +#include "hud.h" + +// shared between backends +Vector dead_viewangles(0, 0, 0); +cvar_t *sensitivity; +cvar_t *in_joystick; + +FWGSInput fwgsInput; + +#ifdef SUPPORT_GOLDSOURCE_INPUT +GoldSourceInput goldSourceInput; +AbstractInput* currentInput = &goldSourceInput; +#else +AbstractInput* currentInput = &fwgsInput; +#endif +extern "C" void DLLEXPORT IN_ClientMoveEvent( float forwardmove, float sidemove ) +{ + currentInput->IN_ClientMoveEvent(forwardmove, sidemove); +} + +extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch ) +{ + currentInput->IN_ClientLookEvent(relyaw, relpitch); +} + +void IN_Move( float frametime, usercmd_t *cmd ) +{ + currentInput->IN_Move(frametime, cmd); +} + +extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) +{ + currentInput->IN_MouseEvent(mstate); +} + +extern "C" void DLLEXPORT IN_ClearStates( void ) +{ + currentInput->IN_ClearStates(); +} + +extern "C" void DLLEXPORT IN_ActivateMouse( void ) +{ + currentInput->IN_ActivateMouse(); +} + +extern "C" void DLLEXPORT IN_DeactivateMouse( void ) +{ + currentInput->IN_DeactivateMouse(); +} + +extern "C" void DLLEXPORT IN_Accumulate( void ) +{ + currentInput->IN_Accumulate(); +} + +void IN_Commands( void ) +{ + currentInput->IN_Commands(); +} + +void IN_Shutdown( void ) +{ + currentInput->IN_Shutdown(); +} + +void IN_Init( void ) +{ +#ifdef SUPPORT_GOLDSOURCE_INPUT + if (gMobileEngfuncs) { + gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); + currentInput = &fwgsInput; + } else { + gEngfuncs.Con_Printf( "GoldSource input is in use\n" ); + currentInput = &goldSourceInput; + } +#else + currentInput = &fwgsInput; +#endif + currentInput->IN_Init(); +} diff --git a/cl_dll/input_mouse.h b/cl_dll/input_mouse.h new file mode 100644 index 00000000..6ddf54db --- /dev/null +++ b/cl_dll/input_mouse.h @@ -0,0 +1,77 @@ +#ifndef INPUT_MOUSE_H +#define INPUT_MOUSE_H +#include "cl_dll.h" +#include "usercmd.h" +#include "in_defs.h" + +class AbstractInput +{ +public: + virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) = 0; + virtual void IN_ClientLookEvent( float relyaw, float relpitch ) = 0; + virtual void IN_Move( float frametime, usercmd_t *cmd ) = 0; + virtual void IN_MouseEvent( int mstate ) = 0; + virtual void IN_ClearStates( void ) = 0; + virtual void IN_ActivateMouse( void ) = 0; + virtual void IN_DeactivateMouse( void ) = 0; + virtual void IN_Accumulate( void ) = 0; + virtual void IN_Commands( void ) = 0; + virtual void IN_Shutdown( void ) = 0; + virtual void IN_Init( void ) = 0; +}; + +class FWGSInput : public AbstractInput +{ +public: + virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ); + virtual void IN_ClientLookEvent( float relyaw, float relpitch ); + virtual void IN_Move( float frametime, usercmd_t *cmd ); + virtual void IN_MouseEvent( int mstate ); + virtual void IN_ClearStates( void ); + virtual void IN_ActivateMouse( void ); + virtual void IN_DeactivateMouse( void ); + virtual void IN_Accumulate( void ); + virtual void IN_Commands( void ); + virtual void IN_Shutdown( void ); + virtual void IN_Init( void ); + +protected: + float ac_forwardmove; + float ac_sidemove; + int ac_movecount; + float rel_yaw; + float rel_pitch; +}; + +// No need for goldsource input support on the platforms that are not supported by GoldSource. +#if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86)) +#define SUPPORT_GOLDSOURCE_INPUT +class GoldSourceInput : public AbstractInput +{ +public: + virtual void IN_ClientMoveEvent( float forwardmove, float sidemove ) {} + virtual void IN_ClientLookEvent( float relyaw, float relpitch ) {} + virtual void IN_Move( float frametime, usercmd_t *cmd ); + virtual void IN_MouseEvent( int mstate ); + virtual void IN_ClearStates( void ); + virtual void IN_ActivateMouse( void ); + virtual void IN_DeactivateMouse( void ); + virtual void IN_Accumulate( void ); + virtual void IN_Commands( void ); + virtual void IN_Shutdown( void ); + virtual void IN_Init( void ); + +protected: + void IN_GetMouseDelta( int *pOutX, int *pOutY); + void IN_MouseMove ( float frametime, usercmd_t *cmd); + void IN_StartupMouse (void); + + int mouse_buttons; + int mouse_oldbuttonstate; + POINT current_pos; + int old_mouse_x, old_mouse_y, mx_accum, my_accum; + int mouseinitialized; +}; +#endif + +#endif diff --git a/cl_dll/input_xash3d.cpp b/cl_dll/input_xash3d.cpp index 63cdfbeb..2ff572ee 100644 --- a/cl_dll/input_xash3d.cpp +++ b/cl_dll/input_xash3d.cpp @@ -3,14 +3,9 @@ #include "cvardef.h" #include "kbutton.h" #include "keydefs.h" -cvar_t *sensitivity; -cvar_t *in_joystick; -#define PITCH 0 -#define YAW 1 -#define ROLL 2 - -extern "C" void DLLEXPORT IN_ClientMoveEvent( float forwardmove, float sidemove ); -extern "C" void DLLEXPORT IN_ClientLookEvent( float relyaw, float relpitch ); +#include "input_mouse.h" +extern cvar_t *sensitivity; +extern cvar_t *in_joystick; extern kbutton_t in_strafe; extern kbutton_t in_mlook; @@ -37,12 +32,6 @@ extern cvar_t *cl_movespeedkey; cvar_t *cl_laddermode; -float ac_forwardmove; -float ac_sidemove; -int ac_movecount; -float rel_yaw; -float rel_pitch; - #define F 1U<<0 // Forward #define B 1U<<1 // Back #define L 1U<<2 // Left @@ -55,7 +44,7 @@ float rel_pitch; #define IMPULSE_UP 4 int CL_IsDead( void ); -Vector dead_viewangles(0, 0, 0); +extern Vector dead_viewangles; void IN_ToggleButtons( float forwardmove, float sidemove ) { @@ -135,7 +124,7 @@ void IN_ToggleButtons( float forwardmove, float sidemove ) } } -void IN_ClientMoveEvent( float forwardmove, float sidemove ) +void FWGSInput::IN_ClientMoveEvent( float forwardmove, float sidemove ) { //gEngfuncs.Con_Printf("IN_MoveEvent\n"); @@ -144,14 +133,14 @@ void IN_ClientMoveEvent( float forwardmove, float sidemove ) ac_movecount++; } -void IN_ClientLookEvent( float relyaw, float relpitch ) +void FWGSInput::IN_ClientLookEvent( float relyaw, float relpitch ) { rel_yaw += relyaw; rel_pitch += relpitch; } // Rotate camera and add move values to usercmd -void IN_Move( float frametime, usercmd_t *cmd ) +void FWGSInput::IN_Move( float frametime, usercmd_t *cmd ) { Vector viewangles; bool fLadder = false; @@ -235,7 +224,7 @@ void IN_Move( float frametime, usercmd_t *cmd ) ac_movecount = 0; } -extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) +void FWGSInput::IN_MouseEvent( int mstate ) { static int mouse_oldbuttonstate; // perform button actions @@ -257,37 +246,37 @@ extern "C" void DLLEXPORT IN_MouseEvent( int mstate ) // Stubs -extern "C" void DLLEXPORT IN_ClearStates( void ) +void FWGSInput::IN_ClearStates( void ) { //gEngfuncs.Con_Printf( "IN_ClearStates\n" ); } -extern "C" void DLLEXPORT IN_ActivateMouse( void ) +void FWGSInput::IN_ActivateMouse( void ) { //gEngfuncs.Con_Printf( "IN_ActivateMouse\n" ); } -extern "C" void DLLEXPORT IN_DeactivateMouse( void ) +void FWGSInput::IN_DeactivateMouse( void ) { //gEngfuncs.Con_Printf( "IN_DeactivateMouse\n" ); } -extern "C" void DLLEXPORT IN_Accumulate( void ) +void FWGSInput::IN_Accumulate( void ) { //gEngfuncs.Con_Printf( "IN_Accumulate\n" ); } -void IN_Commands( void ) +void FWGSInput::IN_Commands( void ) { //gEngfuncs.Con_Printf( "IN_Commands\n" ); } -void IN_Shutdown( void ) +void FWGSInput::IN_Shutdown( void ) { } // Register cvars and reset data -void IN_Init( void ) +void FWGSInput::IN_Init( void ) { sensitivity = gEngfuncs.pfnRegisterVariable( "sensitivity", "3", FCVAR_ARCHIVE ); in_joystick = gEngfuncs.pfnRegisterVariable( "joystick", "0", FCVAR_ARCHIVE ); From 84e720eadcfa27434ee65335cb87c8e41a63a92f Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 4 Dec 2017 15:42:45 +0300 Subject: [PATCH 130/199] Add new input files and goldsource support flag to client makefiles --- cl_dll/Android.mk | 7 +++++++ cl_dll/Makefile | 11 ++++++++--- cl_dll/cl_dll.dsp | 14 +++++++++++++- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index a79b6363..29aee174 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -68,6 +68,8 @@ SRCS+=./hud_spectator.cpp SRCS+=./hud_update.cpp SRCS+=./in_camera.cpp SRCS+=./input.cpp +SRCS+=./input_goldsource.cpp +SRCS+=./input_mouse.cpp #SRCS+=./inputw32.cpp SRCS+=./menu.cpp SRCS+=./message.cpp @@ -100,6 +102,11 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../pm_shared LOCAL_CFLAGS += $(DEFINES) $(INCLUDES) +ifeq ($(GOLDSOURCE_SUPPORT),1) + DEFINES += -DGOLDSOURCE_SUPPORT + LOCAL_LDLIBS += -lSDL2 +endif + LOCAL_SRC_FILES := $(SRCS) $(SRCS_C) include $(BUILD_SHARED_LIBRARY) diff --git a/cl_dll/Makefile b/cl_dll/Makefile index 983b61c0..16427f8f 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -45,7 +45,8 @@ SRCS+=./hud_spectator.cpp SRCS+=./hud_update.cpp SRCS+=./in_camera.cpp SRCS+=./input.cpp -#SRCS+=./inputw32.cpp +SRCS+=./input_mouse.cpp +SRCS+=./input_goldsource.cpp SRCS+=./menu.cpp SRCS+=./message.cpp SRCS+=./overview.cpp @@ -72,9 +73,13 @@ CFLAGS = -m32 OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) LIBS=-lm +ifeq ($(GOLDSOURCE_SUPPORT),1) + DEFINES += -DGOLDSOURCE_SUPPORT + LIBS += -lSDL2 +endif ifeq ($(shell uname -s),Linux) - LIBS=$(LIBS) -ldl + LIBS += -ldl endif %.o : %.c @@ -83,7 +88,7 @@ endif %.o : %.cpp $(CXX) $(CFLAGS) $(INCLUDES) $(DEFINES) -fPIC -c $< -o $@ client.so : $(OBJS) - $(CXX) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS) + $(CXX) $(CFLAGS) $(OBJS) -o client.so -shared -Wl,--no-undefined -fPIC $(LIBS) clean: $(RM) $(OBJS) diff --git a/cl_dll/cl_dll.dsp b/cl_dll/cl_dll.dsp index 6864326b..e8ae7d15 100644 --- a/cl_dll/cl_dll.dsp +++ b/cl_dll/cl_dll.dsp @@ -300,7 +300,15 @@ SOURCE=.\input.cpp # End Source File # Begin Source File -SOURCE=.\inputw32.cpp +SOURCE=.\input_goldsource.cpp +# End Source File +# Begin Source File + +SOURCE=.\input_mouse.cpp +# End Source File +# Begin Source File + +SOURCE=.\input_xash3d.cpp # End Source File # Begin Source File @@ -513,6 +521,10 @@ SOURCE=.\in_defs.h # End Source File # Begin Source File +SOURCE=.\input_mouse.h +# End Source File +# Begin Source File + SOURCE=..\common\itrackeruser.h # End Source File # Begin Source File From d904505f6a991532fd2eedff4e98b683347f71cd Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 6 Dec 2017 19:19:27 +0300 Subject: [PATCH 131/199] Get vgui back for goldsource fullscreen support --- cl_dll/CMakeLists.txt | 9 ++++-- cl_dll/cdll_int.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 72 insertions(+), 3 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 776f9bd9..2ad46949 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,12 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2 -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lSDL2 -Wl,--no-undefined") + if (APPLE) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.dylib") + else() + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.so") + endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -96,7 +101,7 @@ set (CLDLL_SOURCES scoreboard.cpp MOTD.cpp) -include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) +include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/vgui/include) if(USE_VOICEMGR) #set(CLDLL_SOURCES diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index d71659e9..00496ea8 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -23,6 +23,13 @@ #include "netadr.h" #include "parsemsg.h" +#if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86)) +#define USE_VGUI_FOR_GOLDSOURCE_SUPPORT +#include "VGUI_Panel.h" +#include "VGUI_BorderLayout.h" +#include "VGUI_App.h" +#endif + extern "C" { #include "pm_shared.h" @@ -177,6 +184,46 @@ int *HUD_GetRect( void ) return extent; } +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT +class TeamFortressViewport : public vgui::Panel +{ +public: + TeamFortressViewport(int x,int y,int wide,int tall); + void Initialize( void ); + + virtual void paintBackground(); + void *operator new( size_t stAllocateBlock ); +}; + +static TeamFortressViewport* gViewPort = NULL; + +TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) +{ + gViewPort = this; + Initialize(); +} + +void TeamFortressViewport::Initialize() +{ + vgui::App::getInstance()->setCursorOveride( vgui::App::getInstance()->getScheme()->getCursor(vgui::Scheme::scu_none) ); +} + +void TeamFortressViewport::paintBackground() +{ + int wide, tall; + getParent()->getSize( wide, tall ); + setSize( wide, tall ); + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +} + +void *TeamFortressViewport::operator new( size_t stAllocateBlock ) +{ + void *mem = ::operator new( stAllocateBlock ); + memset( mem, 0, stAllocateBlock ); + return mem; +} +#endif + /* ========================== HUD_VidInit @@ -190,7 +237,21 @@ so the HUD can reinitialize itself. int DLLEXPORT HUD_VidInit( void ) { gHUD.VidInit(); +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); + root->setBgColor(128,128,0,0); + root->setLayout(new vgui::BorderLayout(0)); + if (gViewPort != NULL) + { + gViewPort->Initialize(); + } + else + { + gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); + gViewPort->setParent(root); + } +#endif return 1; } @@ -270,7 +331,10 @@ Called by engine every frame that client .dll is loaded */ void DLLEXPORT HUD_Frame( double time ) -{ gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +{ +#ifndef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +#endif } /* From 51bf51a840649165078226661ef790c0ed3971e4 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 6 Dec 2017 20:38:14 +0300 Subject: [PATCH 132/199] Provide vgui stub to avoid dependency of client of vgui lib --- cl_dll/CMakeLists.txt | 7 +- cl_dll/cdll_int.cpp | 37 ++-- utils/false_vgui/include/VGUI.h | 108 ++++++++++ utils/false_vgui/include/VGUI_App.h | 130 ++++++++++++ utils/false_vgui/include/VGUI_Bitmap.h | 37 ++++ utils/false_vgui/include/VGUI_Color.h | 44 +++++ utils/false_vgui/include/VGUI_Cursor.h | 57 ++++++ utils/false_vgui/include/VGUI_Dar.h | 194 ++++++++++++++++++ utils/false_vgui/include/VGUI_Image.h | 62 ++++++ utils/false_vgui/include/VGUI_KeyCode.h | 126 ++++++++++++ utils/false_vgui/include/VGUI_MouseCode.h | 24 +++ utils/false_vgui/include/VGUI_Panel.h | 229 ++++++++++++++++++++++ utils/false_vgui/include/VGUI_Scheme.h | 82 ++++++++ 13 files changed, 1114 insertions(+), 23 deletions(-) create mode 100644 utils/false_vgui/include/VGUI.h create mode 100644 utils/false_vgui/include/VGUI_App.h create mode 100644 utils/false_vgui/include/VGUI_Bitmap.h create mode 100644 utils/false_vgui/include/VGUI_Color.h create mode 100644 utils/false_vgui/include/VGUI_Cursor.h create mode 100644 utils/false_vgui/include/VGUI_Dar.h create mode 100644 utils/false_vgui/include/VGUI_Image.h create mode 100644 utils/false_vgui/include/VGUI_KeyCode.h create mode 100644 utils/false_vgui/include/VGUI_MouseCode.h create mode 100644 utils/false_vgui/include/VGUI_Panel.h create mode 100644 utils/false_vgui/include/VGUI_Scheme.h diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 2ad46949..e52a0d95 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -28,11 +28,6 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lSDL2 -Wl,--no-undefined") - if (APPLE) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.dylib") - else() - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -l:vgui.so") - endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -101,7 +96,7 @@ set (CLDLL_SOURCES scoreboard.cpp MOTD.cpp) -include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/vgui/include) +include_directories (. hl/ ../dlls ../dlls/wpn_shared ../common ../engine ../pm_shared ../game_shared ../public ../utils/false_vgui/include) if(USE_VOICEMGR) #set(CLDLL_SOURCES diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 00496ea8..1901d9d2 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -26,7 +26,6 @@ #if defined(GOLDSOURCE_SUPPORT) && (defined(_WIN32) || defined(__linux__) || defined(__APPLE__)) && (defined(__i386) || defined(_M_IX86)) #define USE_VGUI_FOR_GOLDSOURCE_SUPPORT #include "VGUI_Panel.h" -#include "VGUI_BorderLayout.h" #include "VGUI_App.h" #endif @@ -197,7 +196,7 @@ public: static TeamFortressViewport* gViewPort = NULL; -TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) +TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) : Panel(x, y, wide, tall) { gViewPort = this; Initialize(); @@ -205,14 +204,14 @@ TeamFortressViewport::TeamFortressViewport(int x, int y, int wide, int tall) void TeamFortressViewport::Initialize() { - vgui::App::getInstance()->setCursorOveride( vgui::App::getInstance()->getScheme()->getCursor(vgui::Scheme::scu_none) ); + //vgui::App::getInstance()->setCursorOveride( vgui::App::getInstance()->getScheme()->getCursor(vgui::Scheme::scu_none) ); } void TeamFortressViewport::paintBackground() { - int wide, tall; - getParent()->getSize( wide, tall ); - setSize( wide, tall ); +// int wide, tall; +// getParent()->getSize( wide, tall ); +// setSize( wide, tall ); gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); } @@ -239,17 +238,18 @@ int DLLEXPORT HUD_VidInit( void ) gHUD.VidInit(); #ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); - root->setBgColor(128,128,0,0); - root->setLayout(new vgui::BorderLayout(0)); + if (root) { + root->setBgColor(128,128,0,0); - if (gViewPort != NULL) - { - gViewPort->Initialize(); - } - else - { - gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); - gViewPort->setParent(root); + if (gViewPort != NULL) + { + gViewPort->Initialize(); + } + else + { + gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); + gViewPort->setParent(root); + } } #endif return 1; @@ -332,7 +332,10 @@ Called by engine every frame that client .dll is loaded void DLLEXPORT HUD_Frame( double time ) { -#ifndef USE_VGUI_FOR_GOLDSOURCE_SUPPORT +#ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT + if (!gViewPort) + gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); +#else gEngfuncs.VGui_ViewportPaintBackground(HUD_GetRect()); #endif } diff --git a/utils/false_vgui/include/VGUI.h b/utils/false_vgui/include/VGUI.h new file mode 100644 index 00000000..0dff607a --- /dev/null +++ b/utils/false_vgui/include/VGUI.h @@ -0,0 +1,108 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_H +#define VGUI_H + +//If you are going to add stuff to the vgui core... +// +//Keep it simple. +// +//Never put code in a header. +// +//The name of the class is the name of the the file +// +//Each class gets its own .cpp file for its definition and a .h for its header. Helper +//classes can be used but only within the .cpp and not referenceable from anywhere else. +// +//Don't add unneeded files. Keep the API clean. +// +//No platform specific code in vgui\lib-src\vgui dir. Code in vgui\lib-src\vgui should +//only include from vgui\include or standard C includes. ie, if I see windows.h included +//anywhere but vgui\lib-src\win32 I will hunt you down and kill you. Don't give me any crap +//that mfc is platform inspecific. +// +//Always use <> and not "" for includes +// +//Use minimum dependencies in headers. Don't include another header if you can get away +//with forward declaring (which is usually the case) +// +//No macros in headers. They are tools of satan. This also means no use of DEFINEs, use enum +// +//Minimize global functions +// +//No global variables. +// +//Panel is getting pretty plump, try and avoid adding junk to it if you can + +//TODO: Look and Feel support +// add Panel::setPaintProxy, if _paintProxy exists, it calls _paintProxy->paint +// instead of Panel::paint. Components should implement their painting in a seperate +// plugin class. Perhaps to encourage this, Panel::paint should just go away completely +// The other option is to have Panel have the interface Paintable +// class Paintable +// { +// public: +// virtual void paint()=0; +// }; +// Then a component can implement its paint in the class itself and then call +// setPaintProxy(this). If this is the case _paintProxy->paint should always be called +// and never Panel::paint from within paintTraverse +//TODO: Figure out the 'Valve' Look and Feel and implement that instead of a the Java one +//TODO: Determine ownership policy for Borders, Layouts, etc.. +//TODO: tooltips support +//TODO: ComboKey (hot key support) +//TODO: add Background.cpp, remove paintBackground from all components +// Panel implements setBackground, Panel::paintBackground calls _background->paintBackground +// similiar to the way Border works. +//TODO: Builtin components should never overide paintBackground, only paint +//TODO: All protected members should be converted to private +//TODO: All member variables should be moved to the top of the class prototype +//TODO: All private methods should be prepended with private +//TODO: Use of word internal in method names is not consistent and confusing +//TODO: Cleanup so bullshit publics are properly named, maybe even figure out +// a naming convention for them +//TODO: Breakup InputSignal into logical pieces +//TODO: Button is in a state of disarray, it should have ButtonModel support +//TODO: get rid of all the stupid strdup laziness, convert to vgui_strdup +//TODO: actually figure out policy on String and implement it consistently +//TODO: implement createLayoutInfo for other Layouts than need it +//TODO: BorderLayout should have option for a null LayoutInfo defaulting to center +//TODO: SurfaceBase should go away, put it in Surface +//TODO: ActionSignals and other Signals should just set a flag when they fire. +// then App can come along later and fire all the signals +//TODO: Change all method naming to starting with a capital letter. + +#ifdef _WIN32 +# define VGUIAPI __declspec( dllexport ) +#else +# define VGUIAPI __attribute__ ((visibility("default"))) +#include // size_t define +#endif + +#define null 0L + +typedef unsigned char uchar; +typedef unsigned short ushort; +typedef unsigned int uint; +typedef unsigned long ulong; + +namespace vgui +{ + +VGUIAPI void vgui_setMalloc(void *(*malloc)(size_t size) ); +VGUIAPI void vgui_setFree(void (*free)(void* memblock)); +VGUIAPI void vgui_strcpy(char* dst,int dstLen,const char* src); +VGUIAPI char* vgui_strdup(const char* src); +VGUIAPI int vgui_printf(const char* format,...); +VGUIAPI int vgui_dprintf(const char* format,...); +VGUIAPI int vgui_dprintf2(const char* format,...); + +} + +#endif + diff --git a/utils/false_vgui/include/VGUI_App.h b/utils/false_vgui/include/VGUI_App.h new file mode 100644 index 00000000..6e70f909 --- /dev/null +++ b/utils/false_vgui/include/VGUI_App.h @@ -0,0 +1,130 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_APP_H +#define VGUI_APP_H + +#include +#include +#include +#include +#include + +namespace vgui +{ + +class Panel; +class TickSignal; +class Scheme; +class TickSignal; +class SurfaceBase; + +class VGUIAPI App +{ +public: + App() {} + App(bool externalMain) {} +public: + static App* getInstance() {return 0;} + //TODO: the public and public bullshit are all messed up, need to organize + //TODO: actually all of the access needs to be properly thought out while you are at it +public: + virtual void start() {} + virtual void stop() {} + virtual void externalTick() {} + virtual bool wasMousePressed(MouseCode code,Panel* panel) {return false;} + virtual bool wasMouseDoublePressed(MouseCode code,Panel* panel) {return false;} + virtual bool isMouseDown(MouseCode code,Panel* panel) {return false;} + virtual bool wasMouseReleased(MouseCode code,Panel* panel) {return false;} + virtual bool wasKeyPressed(KeyCode code,Panel* panel) {return false;} + virtual bool isKeyDown(KeyCode code,Panel* panel) {return false;} + virtual bool wasKeyTyped(KeyCode code,Panel* panel) {return false;} + virtual bool wasKeyReleased(KeyCode code,Panel* panel) {return false;} + virtual void addTickSignal(TickSignal* s) {} + virtual void setCursorPos(int x,int y) {} + virtual void getCursorPos(int& x,int& y) {} + virtual void setMouseCapture(Panel* panel) {} + virtual void setMouseArena(int x0,int y0,int x1,int y1,bool enabled) {} + virtual void setMouseArena(Panel* panel) {} + virtual void requestFocus(Panel* panel) {} + virtual Panel* getFocus() {return 0;} + virtual void repaintAll() {} + virtual void setScheme(Scheme* scheme) {} + virtual Scheme* getScheme() {return 0;} + virtual void enableBuildMode() {} + virtual long getTimeMillis() {return 0;} + virtual char getKeyCodeChar(KeyCode code,bool shifted) {return '\0';} + virtual void getKeyCodeText(KeyCode code,char* buf,int buflen) {} + virtual int getClipboardTextCount() {return 0;} + virtual void setClipboardText(const char* text,int textLen) {} + virtual int getClipboardText(int offset,char* buf,int bufLen) {return 0;} + virtual void reset() {} + virtual void internalSetMouseArena(int x0,int y0,int x1,int y1,bool enabled) {} + virtual bool setRegistryString(const char* key,const char* value) {return false;} + virtual bool getRegistryString(const char* key,char* value,int valueLen) {return false;} + virtual bool setRegistryInteger(const char* key,int value) {return false;} + virtual bool getRegistryInteger(const char* key,int& value) {return false;} + virtual void setCursorOveride(Cursor* cursor) {} + virtual Cursor* getCursorOveride() {return 0;} + virtual void setMinimumTickMillisInterval(int interval) {} +public: //bullshit public stuff + virtual void main(int argc,char* argv[])=0; + virtual void run() {} + virtual void internalCursorMoved(int x,int y,SurfaceBase* surfaceBase) {} //expects input in surface space + virtual void internalMousePressed(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseDoublePressed(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseReleased(MouseCode code,SurfaceBase* surfaceBase) {} + virtual void internalMouseWheeled(int delta,SurfaceBase* surfaceBase) {} + virtual void internalKeyPressed(KeyCode code,SurfaceBase* surfaceBase) {} + virtual void internalKeyTyped(KeyCode code,SurfaceBase* surfaceBase) {} + virtual void internalKeyReleased(KeyCode code,SurfaceBase* surfaceBase) {} +private: + virtual void init() {} + virtual void updateMouseFocus(int x,int y,SurfaceBase* surfaceBase) {} + virtual void setMouseFocus(Panel* newMouseFocus) {} +protected: + virtual void surfaceBaseCreated(SurfaceBase* surfaceBase) {} + virtual void surfaceBaseDeleted(SurfaceBase* surfaceBase) {} + virtual void platTick() {} + virtual void internalTick() {} +protected: + static App* _instance; +protected: + bool _running; + bool _externalMain; + Dar _surfaceBaseDar; + Panel* _keyFocus; + Panel* _oldMouseFocus; + Panel* _mouseFocus; + Panel* _mouseCapture; + Panel* _wantedKeyFocus; + bool _mousePressed[MOUSE_LAST]; + bool _mouseDoublePressed[MOUSE_LAST]; + bool _mouseDown[MOUSE_LAST]; + bool _mouseReleased[MOUSE_LAST]; + bool _keyPressed[KEY_LAST]; + bool _keyTyped[KEY_LAST]; + bool _keyDown[KEY_LAST]; + bool _keyReleased[KEY_LAST]; + Dar _tickSignalDar; + Scheme* _scheme; + bool _buildMode; + bool _wantedBuildMode; + Panel* _mouseArenaPanel; + Cursor* _cursor[Cursor::dc_last]; + Cursor* _cursorOveride; +private: + long _nextTickMillis; + long _minimumTickMillisInterval; + friend class SurfaceBase; +}; +} + +#endif + + + diff --git a/utils/false_vgui/include/VGUI_Bitmap.h b/utils/false_vgui/include/VGUI_Bitmap.h new file mode 100644 index 00000000..a2cc7a45 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Bitmap.h @@ -0,0 +1,37 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_BITMAP_H +#define VGUI_BITMAP_H + +#include +#include + +namespace vgui +{ + +class Panel; + +class VGUIAPI Bitmap : public Image +{ +private: + int _id; + bool _uploaded; +public: + Bitmap() {} +protected: + virtual void setSize(int wide,int tall) {} + virtual void setRGBA(int x,int y,uchar r,uchar g,uchar b,uchar a) {} +public: + virtual void paint(Panel* panel) {} +protected: + uchar* _rgba; +}; + +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Color.h b/utils/false_vgui/include/VGUI_Color.h new file mode 100644 index 00000000..f3fec5c6 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Color.h @@ -0,0 +1,44 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_COLOR_H +#define VGUI_COLOR_H + +#include +#include + +//TODO: rename getColor(r,g,b,a) to getRGBA(r,g,b,a) +//TODO: rename setColor(r,g,b,a) to setRGBA(r,g,b,a) +//TODO: rename getColor(sc) to getSchemeColor(sc) +//TODO: rename setColor(sc) to setSchemeColor(sc) + +namespace vgui +{ + +class VGUIAPI Color +{ +private: + uchar _color[4]; + Scheme::SchemeColor _schemeColor; +public: + Color() {} + Color(int r,int g,int b,int a) {} + Color(Scheme::SchemeColor sc) {} +private: + virtual void init() {} +public: + virtual void setColor(int r,int g,int b,int a) {} + virtual void setColor(Scheme::SchemeColor sc) {} + virtual void getColor(int& r,int& g,int& b,int& a) {} + virtual void getColor(Scheme::SchemeColor& sc) {} + virtual int operator[](int index) {return 0;} +}; + +} + + +#endif diff --git a/utils/false_vgui/include/VGUI_Cursor.h b/utils/false_vgui/include/VGUI_Cursor.h new file mode 100644 index 00000000..8419e2dd --- /dev/null +++ b/utils/false_vgui/include/VGUI_Cursor.h @@ -0,0 +1,57 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_CURSOR_H +#define VGUI_CURSOR_H + +#include + +namespace vgui +{ + +class Bitmap; + +class VGUIAPI Cursor +{ +public: + enum DefaultCursor + { + dc_user, + dc_none, + dc_arrow, + dc_ibeam, + dc_hourglass, + dc_crosshair, + dc_up, + dc_sizenwse, + dc_sizenesw, + dc_sizewe, + dc_sizens, + dc_sizeall, + dc_no, + dc_hand, + dc_last + }; +private: + int _hotspot[2]; + Bitmap* _bitmap; + DefaultCursor _dc; +public: + Cursor(DefaultCursor dc) {} + Cursor(Bitmap* bitmap,int hotspotX,int hotspotY) {} +public: + virtual void getHotspot(int& x,int& y) {} +private: + virtual void privateInit(Bitmap* bitmap,int hotspotX,int hotspotY) {} +public: + virtual Bitmap* getBitmap() {return 0;} + virtual DefaultCursor getDefaultCursor() {return dc_none;} +}; + +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Dar.h b/utils/false_vgui/include/VGUI_Dar.h new file mode 100644 index 00000000..6f8eb513 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Dar.h @@ -0,0 +1,194 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_DAR_H +#define VGUI_DAR_H + +#include +#include +#include + + + +namespace vgui +{ + +//Simple lightweight dynamic array implementation +template class VGUIAPI Dar +{ +public: + Dar() + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(4); + } + Dar(int initialCapacity) + { + _count=0; + _capacity=0; + _data=null; + ensureCapacity(initialCapacity); + } +public: + void ensureCapacity(int wantedCapacity) + { + if(wantedCapacity<=_capacity){return;} + + //double capacity until it is >= wantedCapacity + //this could be done with math, but iterative is just so much more fun + int newCapacity=_capacity; + if(newCapacity==0){newCapacity=1;} + while(newCapacity_capacity)) + { + return; + } + _count=count; + } + int getCount() + { + return _count; + } + void addElement(ELEMTYPE elem) + { + ensureCapacity(_count+1); + _data[_count]=elem; + _count++; + } + bool hasElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + return true; + } + } + return false; + } + void putElement(ELEMTYPE elem) + { + if(hasElement(elem)) + { + return; + } + addElement(elem); + } + void insertElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>_count)) + { + return; + } + if((index==_count)||(_count==0)) + { + addElement(elem); + } + else + { + addElement(elem); //just to make sure it is big enough + for(int i=_count-1;i>index;i--) + { + _data[i]=_data[i-1]; + } + _data[index]=elem; + } + } + void setElementAt(ELEMTYPE elem,int index) + { + if((index<0)||(index>=_count)) + { + return; + } + _data[index]=elem; + } + void removeElementAt(int index) + { + if((index<0)||(index>=_count)) + { + return; + } + + //slide everything to the right of index, left one. + for(int i=index;i<(_count-1);i++) + { + _data[i]=_data[i+1]; + } + _count--; + } + void removeElement(ELEMTYPE elem) + { + for(int i=0;i<_count;i++) + { + if(_data[i]==elem) + { + removeElementAt(i); + break; + } + } + } + void removeAll() + { + _count=0; + } + ELEMTYPE operator[](int index) + { + if((index<0)||(index>=_count)) + { + return null; + } + return _data[index]; + } +protected: + int _count; + int _capacity; + ELEMTYPE* _data; +}; + +#ifdef _WIN32 +//forward referencing all the template types used so they get exported +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar*>; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +template class VGUIAPI Dar; +#endif + +} + + +#endif \ No newline at end of file diff --git a/utils/false_vgui/include/VGUI_Image.h b/utils/false_vgui/include/VGUI_Image.h new file mode 100644 index 00000000..ff83f047 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Image.h @@ -0,0 +1,62 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_IMAGE_H +#define VGUI_IMAGE_H + +#include +#include +#include + +//TODO:: needs concept of insets + +namespace vgui +{ + +class Panel; + +class VGUIAPI Image +{ +friend class Panel; +private: + int _pos[2]; + int _size[2]; + Panel* _panel; + Color _color; +public: + Image(); +public: + virtual void setPos(int x,int y) {} + virtual void getPos(int& x,int& y) {} + virtual void getSize(int& wide,int& tall) {} + virtual void setColor(Color color) {} + virtual void getColor(Color& color) {} +protected: + virtual void setSize(int wide,int tall) {} + virtual void drawSetColor(Scheme::SchemeColor sc) {} + virtual void drawSetColor(int r,int g,int b,int a) {} + virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} + virtual void drawSetTextFont(Scheme::SchemeFont sf) {} + virtual void drawSetTextFont(Font* font) {} + virtual void drawSetTextColor(Scheme::SchemeColor sc) {} + virtual void drawSetTextColor(int r,int g,int b,int a) {} + virtual void drawSetTextPos(int x,int y) {} + virtual void drawPrintText(const char* str,int strlen) {} + virtual void drawPrintText(int x,int y,const char* str,int strlen) {} + virtual void drawPrintChar(char ch) {} + virtual void drawPrintChar(int x,int y,char ch) {} + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} + virtual void drawSetTexture(int id) {} + virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} + virtual void paint(Panel* panel) {} +public: + virtual void doPaint(Panel* panel) {} +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_KeyCode.h b/utils/false_vgui/include/VGUI_KeyCode.h new file mode 100644 index 00000000..b6aea363 --- /dev/null +++ b/utils/false_vgui/include/VGUI_KeyCode.h @@ -0,0 +1,126 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_KEYCODE_H +#define VGUI_KEYCODE_H + +#include + +namespace vgui +{ +enum VGUIAPI KeyCode +{ + KEY_0=0, + KEY_1, + KEY_2, + KEY_3, + KEY_4, + KEY_5, + KEY_6, + KEY_7, + KEY_8, + KEY_9, + KEY_A, + KEY_B, + KEY_C, + KEY_D, + KEY_E, + KEY_F, + KEY_G, + KEY_H, + KEY_I, + KEY_J, + KEY_K, + KEY_L, + KEY_M, + KEY_N, + KEY_O, + KEY_P, + KEY_Q, + KEY_R, + KEY_S, + KEY_T, + KEY_U, + KEY_V, + KEY_W, + KEY_X, + KEY_Y, + KEY_Z, + KEY_PAD_0, + KEY_PAD_1, + KEY_PAD_2, + KEY_PAD_3, + KEY_PAD_4, + KEY_PAD_5, + KEY_PAD_6, + KEY_PAD_7, + KEY_PAD_8, + KEY_PAD_9, + KEY_PAD_DIVIDE, + KEY_PAD_MULTIPLY, + KEY_PAD_MINUS, + KEY_PAD_PLUS, + KEY_PAD_ENTER, + KEY_PAD_DECIMAL, + KEY_LBRACKET, + KEY_RBRACKET, + KEY_SEMICOLON, + KEY_APOSTROPHE, + KEY_BACKQUOTE, + KEY_COMMA, + KEY_PERIOD, + KEY_SLASH, + KEY_BACKSLASH, + KEY_MINUS, + KEY_EQUAL, + KEY_ENTER, + KEY_SPACE, + KEY_BACKSPACE, + KEY_TAB, + KEY_CAPSLOCK, + KEY_NUMLOCK, + KEY_ESCAPE, + KEY_SCROLLLOCK, + KEY_INSERT, + KEY_DELETE, + KEY_HOME, + KEY_END, + KEY_PAGEUP, + KEY_PAGEDOWN, + KEY_BREAK, + KEY_LSHIFT, + KEY_RSHIFT, + KEY_LALT, + KEY_RALT, + KEY_LCONTROL, + KEY_RCONTROL, + KEY_LWIN, + KEY_RWIN, + KEY_APP, + KEY_UP, + KEY_LEFT, + KEY_DOWN, + KEY_RIGHT, + KEY_F1, + KEY_F2, + KEY_F3, + KEY_F4, + KEY_F5, + KEY_F6, + KEY_F7, + KEY_F8, + KEY_F9, + KEY_F10, + KEY_F11, + KEY_F12, + KEY_LAST +}; +} + + +#endif + diff --git a/utils/false_vgui/include/VGUI_MouseCode.h b/utils/false_vgui/include/VGUI_MouseCode.h new file mode 100644 index 00000000..2de259db --- /dev/null +++ b/utils/false_vgui/include/VGUI_MouseCode.h @@ -0,0 +1,24 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_MOUSECODE_H +#define VGUI_MOUSECODE_H + +#include + +namespace vgui +{ +enum VGUIAPI MouseCode +{ + MOUSE_LEFT=0, + MOUSE_RIGHT, + MOUSE_MIDDLE, + MOUSE_LAST +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Panel.h b/utils/false_vgui/include/VGUI_Panel.h new file mode 100644 index 00000000..bec7ac25 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Panel.h @@ -0,0 +1,229 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_PANEL_H +#define VGUI_PANEL_H + + +/* + +TODO: + +Maybe have the border know who they are added to. +A border can only be added to 1 thing, and will be +removed from the other. That way they can actually +be memory managed. Also do Layout's this way too. + +TODO: + outlinedRect should have a thickness arg + +*/ + + +#include +#include +#include +#include +#include +#include +#include +//#include + +namespace vgui +{ + +enum KeyCode; +enum MouseCode; +class SurfaceBase; +class FocusChangeSignal; +class InputSignal; +class Cursor; +class Layout; +class FocusNavGroup; +class Border; +class Font; +class BuildGroup; +class App; +class LayoutInfo; +class RepaintSignal; + +class VGUIAPI Panel +{ +public: + Panel() {} + Panel(int x,int y,int wide,int tall) {setPos(x, y); setSize(wide, tall);} +private: + void init(int x,int y,int wide,int tall) {} +public: + virtual void setPos(int x,int y) {_pos[0] = x; _pos[1] = y;} + virtual void getPos(int& x,int& y) {x = _pos[0]; y = _pos[1];} + virtual void setSize(int wide,int tall) {_size[0] = wide, _size[1] = tall;} + virtual void getSize(int& wide,int& tall) {wide = _size[0], tall = _size[1];} + virtual void setBounds(int x,int y,int wide,int tall) {} + virtual void getBounds(int& x,int& y,int& wide,int& tall) {} + virtual int getWide() {return _size[0];} + virtual int getTall() {return _size[1];} + virtual Panel* getParent() {return _parent;} + virtual void setVisible(bool state) {_visible = state;} + virtual bool isVisible() {return _visible;} + virtual bool isVisibleUp() {return false;} + virtual void repaint() {} + virtual void repaintAll() {} + virtual void getAbsExtents(int& x0,int& y0,int& x1,int& y1) {} + virtual void getClipRect(int& x0,int& y0,int& x1,int& y1) {} + virtual void setParent(Panel* newParent) {_parent = newParent; newParent->addChild(this);} + virtual void addChild(Panel* child) {} + virtual void insertChildAt(Panel* child,int index) {} + virtual void removeChild(Panel* child) {} + virtual bool wasMousePressed(MouseCode code) {return false;} + virtual bool wasMouseDoublePressed(MouseCode code) {return false;} + virtual bool isMouseDown(MouseCode code) {return false;} + virtual bool wasMouseReleased(MouseCode code) {return false;} + virtual bool wasKeyPressed(KeyCode code) {return false;} + virtual bool isKeyDown(KeyCode code) {return false;} + virtual bool wasKeyTyped(KeyCode code) {return false;} + virtual bool wasKeyReleased(KeyCode code) {return false;} + virtual void addInputSignal(InputSignal* s) {} + virtual void removeInputSignal(InputSignal* s) {} + virtual void addRepaintSignal(RepaintSignal* s) {} + virtual void removeRepaintSignal(RepaintSignal* s) {} + virtual bool isWithin(int x,int y) {return false;} //in screen space + virtual Panel* isWithinTraverse(int x,int y) {return 0;} + virtual void localToScreen(int& x,int& y) {} + virtual void screenToLocal(int& x,int& y) {} + virtual void setCursor(Cursor* cursor) {} + virtual void setCursor(Scheme::SchemeCursor scu) {} + virtual Cursor* getCursor() {return 0;} + virtual void setMinimumSize(int wide,int tall) {} + virtual void getMinimumSize(int& wide,int& tall) {} + virtual void requestFocus() {} + virtual bool hasFocus() {return false;} + virtual int getChildCount() {return 0;} + virtual Panel* getChild(int index) {return 0;} + virtual void setLayout(Layout* layout) {} + virtual void invalidateLayout(bool layoutNow) {} + virtual void setFocusNavGroup(FocusNavGroup* focusNavGroup) {} + virtual void requestFocusPrev() {} + virtual void requestFocusNext() {} + virtual void addFocusChangeSignal(FocusChangeSignal* s) {} + virtual bool isAutoFocusNavEnabled() {return false;} + virtual void setAutoFocusNavEnabled(bool state) {} + virtual void setBorder(Border* border) {} + virtual void setPaintBorderEnabled(bool state) {} + virtual void setPaintBackgroundEnabled(bool state) {} + virtual void setPaintEnabled(bool state) {} + virtual void getInset(int& left,int& top,int& right,int& bottom) {} + virtual void getPaintSize(int& wide,int& tall) {} + virtual void setPreferredSize(int wide,int tall) {} + virtual void getPreferredSize(int& wide,int& tall) {} + virtual SurfaceBase* getSurfaceBase() {return 0;} + virtual bool isEnabled() {return _enabled = false;} + virtual void setEnabled(bool state) {_enabled = true;} + virtual void setBuildGroup(BuildGroup* buildGroup,const char* panelPersistanceName) {} + virtual bool isBuildGroupEnabled() {return false;} + virtual void removeAllChildren() {} + virtual void repaintParent() {} + virtual Panel* createPropertyPanel() {return 0;} + virtual void getPersistanceText(char* buf,int bufLen) {} + virtual void applyPersistanceText(const char* buf) {} + virtual void setFgColor(Scheme::SchemeColor sc) {} + virtual void setBgColor(Scheme::SchemeColor sc) {} + virtual void setFgColor(int r,int g,int b,int a) {} + virtual void setBgColor(int r,int g,int b,int a) {} + virtual void getFgColor(int& r,int& g,int& b,int& a) {} + virtual void getBgColor(int& r,int& g,int& b,int& a) {} + virtual void setBgColor(Color color) {} + virtual void setFgColor(Color color) {} + virtual void getBgColor(Color& color) {} + virtual void getFgColor(Color& color) {} + virtual void setAsMouseCapture(bool state) {} + virtual void setAsMouseArena(bool state) {} + virtual App* getApp() {return 0;} + virtual void getVirtualSize(int& wide,int& tall) {} + virtual void setLayoutInfo(LayoutInfo* layoutInfo) {} + virtual LayoutInfo* getLayoutInfo() {return 0;} + virtual bool isCursorNone() {return false;} +public: //bullshit public + virtual void solveTraverse() {} + virtual void paintTraverse() {} + virtual void setSurfaceBaseTraverse(SurfaceBase* surfaceBase) {} +protected: + virtual void performLayout() {} + virtual void internalPerformLayout() {} + virtual void drawSetColor(Scheme::SchemeColor sc) {} + virtual void drawSetColor(int r,int g,int b,int a) {} + virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} + virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} + virtual void drawSetTextFont(Scheme::SchemeFont sf) {} + virtual void drawSetTextFont(Font* font) {} + virtual void drawSetTextColor(Scheme::SchemeColor sc) {} + virtual void drawSetTextColor(int r,int g,int b,int a) {} + virtual void drawSetTextPos(int x,int y) {} + virtual void drawPrintText(const char* str,int strlen) {} + virtual void drawPrintText(int x,int y,const char* str,int strlen) {} + virtual void drawPrintChar(char ch) {} + virtual void drawPrintChar(int x,int y,char ch) {} + virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} + virtual void drawSetTexture(int id) {} + virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} + virtual void solve() {} + virtual void paintTraverse(bool repaint) {if(repaint) paintBackground();} + virtual void paintBackground() {} + virtual void paint() {} + virtual void paintBuildOverlay() {} + virtual void internalCursorMoved(int x,int y) {} + virtual void internalCursorEntered() {} + virtual void internalCursorExited() {} + virtual void internalMousePressed(MouseCode code) {} + virtual void internalMouseDoublePressed(MouseCode code) {} + virtual void internalMouseReleased(MouseCode code) {} + virtual void internalMouseWheeled(int delta) {} + virtual void internalKeyPressed(KeyCode code) {} + virtual void internalKeyTyped(KeyCode code) {} + virtual void internalKeyReleased(KeyCode code) {} + virtual void internalKeyFocusTicked() {} + virtual void internalFocusChanged(bool lost) {} + virtual void internalSetCursor() {} +protected: + int _pos[2]; + int _size[2]; + int _loc[2]; + int _minimumSize[2]; + int _preferredSize[2]; + Dar _childDar; + Panel* _parent; + SurfaceBase* _surfaceBase; + Dar _inputSignalDar; + Dar _repaintSignalDar; + int _clipRect[4]; + Cursor* _cursor; + Scheme::SchemeCursor _schemeCursor; + bool _visible; + Layout* _layout; + bool _needsLayout; + FocusNavGroup* _focusNavGroup; + Dar _focusChangeSignalDar; + bool _autoFocusNavEnabled; + Border* _border; +private: + bool _needsRepaint; + bool _enabled; + BuildGroup* _buildGroup; + Color _fgColor; + Color _bgColor; + LayoutInfo* _layoutInfo; + bool _paintBorderEnabled; + bool _paintBackgroundEnabled; + bool _paintEnabled; +friend class Panel; +friend class App; +friend class SurfaceBase; +friend class Image; +}; +} + +#endif diff --git a/utils/false_vgui/include/VGUI_Scheme.h b/utils/false_vgui/include/VGUI_Scheme.h new file mode 100644 index 00000000..e32d7976 --- /dev/null +++ b/utils/false_vgui/include/VGUI_Scheme.h @@ -0,0 +1,82 @@ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +// +// Purpose: +// +// $NoKeywords: $ +//============================================================================= + +#ifndef VGUI_SCHEME_H +#define VGUI_SCHEME_H + +#include + + +namespace vgui +{ + +class Font; +class Cursor; + +class VGUIAPI Scheme +{ +public: + enum SchemeColor + { + sc_user=0, + sc_black, + sc_white, + sc_primary1, + sc_primary2, + sc_primary3, + sc_secondary1, + sc_secondary2, + sc_secondary3, + sc_last + }; + enum SchemeFont + { + sf_user=0, + sf_primary1, + sf_primary2, + sf_primary3, + sf_secondary1, + sf_last + }; + enum SchemeCursor + { + scu_user=0, + scu_none, + scu_arrow, + scu_ibeam, + scu_hourglass, + scu_crosshair, + scu_up, + scu_sizenwse, + scu_sizenesw, + scu_sizewe, + scu_sizens, + scu_sizeall, + scu_no, + scu_hand, + scu_last + }; +public: + Scheme() {} +public: + virtual void setColor(SchemeColor sc,int r,int g,int b,int a) {} + virtual void getColor(SchemeColor sc,int& r,int& g,int& b,int& a) {} + virtual void setFont(SchemeFont sf,Font* font) {} + virtual Font* getFont(SchemeFont sf) {return 0;} + virtual void setCursor(SchemeCursor sc,Cursor* cursor) {} + virtual Cursor* getCursor(SchemeCursor sc) {return 0;} +protected: + int _color[sc_last][4]; + Font* _font[sf_last]; + Cursor* _cursor[scu_last]; + friend class Panel; + friend class Canvas; +}; + +} + +#endif From 33de8458d64353b2c4657a6c6648b4e1bc85cf86 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 6 Dec 2017 22:18:34 +0300 Subject: [PATCH 133/199] Some cleanup. Add false_vgui include path to makefiles --- cl_dll/Android.mk | 5 ++- cl_dll/CMakeLists.txt | 2 +- cl_dll/Makefile | 2 +- cl_dll/cdll_int.cpp | 3 ++ cl_dll/cl_dll.dsp | 4 +- utils/false_vgui/include/VGUI.h | 13 ------ utils/false_vgui/include/VGUI_Bitmap.h | 37 --------------- utils/false_vgui/include/VGUI_Image.h | 62 -------------------------- 8 files changed, 10 insertions(+), 118 deletions(-) delete mode 100644 utils/false_vgui/include/VGUI_Bitmap.h delete mode 100644 utils/false_vgui/include/VGUI_Image.h diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 29aee174..452eb48b 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -91,7 +91,7 @@ SRCS+=./view.cpp SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp -INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls +INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ @@ -99,7 +99,8 @@ LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../engine \ $(LOCAL_PATH)/../game_shared \ $(LOCAL_PATH)/../dlls \ - $(LOCAL_PATH)/../pm_shared + $(LOCAL_PATH)/../pm_shared \ + $(LOCAL_PATH)/../utils/false_vgui/include LOCAL_CFLAGS += $(DEFINES) $(INCLUDES) ifeq ($(GOLDSOURCE_SUPPORT),1) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index e52a0d95..e5a3aa0a 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,7 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -L${CMAKE_CURRENT_SOURCE_DIR}/.. -lSDL2 -Wl,--no-undefined") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2") endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") diff --git a/cl_dll/Makefile b/cl_dll/Makefile index 16427f8f..f624473e 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -67,7 +67,7 @@ SRCS+=./view.cpp SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp -INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls +INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include DEFINES = -Wno-write-strings -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL CFLAGS = -m32 OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 1901d9d2..7427ef80 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -239,6 +239,7 @@ int DLLEXPORT HUD_VidInit( void ) #ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); if (root) { + gEngfuncs.Con_Printf( "Root VGUI panel exists\n" ); root->setBgColor(128,128,0,0); if (gViewPort != NULL) @@ -250,6 +251,8 @@ int DLLEXPORT HUD_VidInit( void ) gViewPort = new TeamFortressViewport(0,0,root->getWide(),root->getTall()); gViewPort->setParent(root); } + } else { + gEngfuncs.Con_Printf( "Root VGUI panel does not exist\n" ); } #endif return 1; diff --git a/cl_dll/cl_dll.dsp b/cl_dll/cl_dll.dsp index e8ae7d15..17beb9ae 100644 --- a/cl_dll/cl_dll.dsp +++ b/cl_dll/cl_dll.dsp @@ -43,7 +43,7 @@ RSC=rc.exe # PROP Ignore_Export_Lib 1 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\utils\vgui\include" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /I "..\utils\false_vgui\include" /I "..\engine" /I "..\common" /I "..\pm_shared" /I "..\dlls" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /YX /FD /c # SUBTRACT CPP /Z # ADD BASE MTL /nologo /D "NDEBUG" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 @@ -80,7 +80,7 @@ SOURCE="$(InputPath)" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c -# ADD CPP /nologo /G5 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\vgui\include" /I "..\game_shared" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c +# ADD CPP /nologo /G5 /MTd /W3 /Gm /GR /GX /ZI /Od /I "..\dlls" /I "..\common" /I "..\pm_shared" /I "..\engine" /I "..\utils\false_vgui\include" /I "..\game_shared" /D "_DEBUG" /D "_MBCS" /D "WIN32" /D "_WINDOWS" /D "CLIENT_DLL" /D "CLIENT_WEAPONS" /FR /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 # ADD BASE RSC /l 0x409 /d "_DEBUG" diff --git a/utils/false_vgui/include/VGUI.h b/utils/false_vgui/include/VGUI.h index 0dff607a..c33e0589 100644 --- a/utils/false_vgui/include/VGUI.h +++ b/utils/false_vgui/include/VGUI.h @@ -91,18 +91,5 @@ typedef unsigned short ushort; typedef unsigned int uint; typedef unsigned long ulong; -namespace vgui -{ - -VGUIAPI void vgui_setMalloc(void *(*malloc)(size_t size) ); -VGUIAPI void vgui_setFree(void (*free)(void* memblock)); -VGUIAPI void vgui_strcpy(char* dst,int dstLen,const char* src); -VGUIAPI char* vgui_strdup(const char* src); -VGUIAPI int vgui_printf(const char* format,...); -VGUIAPI int vgui_dprintf(const char* format,...); -VGUIAPI int vgui_dprintf2(const char* format,...); - -} - #endif diff --git a/utils/false_vgui/include/VGUI_Bitmap.h b/utils/false_vgui/include/VGUI_Bitmap.h deleted file mode 100644 index a2cc7a45..00000000 --- a/utils/false_vgui/include/VGUI_Bitmap.h +++ /dev/null @@ -1,37 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef VGUI_BITMAP_H -#define VGUI_BITMAP_H - -#include -#include - -namespace vgui -{ - -class Panel; - -class VGUIAPI Bitmap : public Image -{ -private: - int _id; - bool _uploaded; -public: - Bitmap() {} -protected: - virtual void setSize(int wide,int tall) {} - virtual void setRGBA(int x,int y,uchar r,uchar g,uchar b,uchar a) {} -public: - virtual void paint(Panel* panel) {} -protected: - uchar* _rgba; -}; - -} - -#endif diff --git a/utils/false_vgui/include/VGUI_Image.h b/utils/false_vgui/include/VGUI_Image.h deleted file mode 100644 index ff83f047..00000000 --- a/utils/false_vgui/include/VGUI_Image.h +++ /dev/null @@ -1,62 +0,0 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ -// -// Purpose: -// -// $NoKeywords: $ -//============================================================================= - -#ifndef VGUI_IMAGE_H -#define VGUI_IMAGE_H - -#include -#include -#include - -//TODO:: needs concept of insets - -namespace vgui -{ - -class Panel; - -class VGUIAPI Image -{ -friend class Panel; -private: - int _pos[2]; - int _size[2]; - Panel* _panel; - Color _color; -public: - Image(); -public: - virtual void setPos(int x,int y) {} - virtual void getPos(int& x,int& y) {} - virtual void getSize(int& wide,int& tall) {} - virtual void setColor(Color color) {} - virtual void getColor(Color& color) {} -protected: - virtual void setSize(int wide,int tall) {} - virtual void drawSetColor(Scheme::SchemeColor sc) {} - virtual void drawSetColor(int r,int g,int b,int a) {} - virtual void drawFilledRect(int x0,int y0,int x1,int y1) {} - virtual void drawOutlinedRect(int x0,int y0,int x1,int y1) {} - virtual void drawSetTextFont(Scheme::SchemeFont sf) {} - virtual void drawSetTextFont(Font* font) {} - virtual void drawSetTextColor(Scheme::SchemeColor sc) {} - virtual void drawSetTextColor(int r,int g,int b,int a) {} - virtual void drawSetTextPos(int x,int y) {} - virtual void drawPrintText(const char* str,int strlen) {} - virtual void drawPrintText(int x,int y,const char* str,int strlen) {} - virtual void drawPrintChar(char ch) {} - virtual void drawPrintChar(int x,int y,char ch) {} - virtual void drawSetTextureRGBA(int id,const char* rgba,int wide,int tall) {} - virtual void drawSetTexture(int id) {} - virtual void drawTexturedRect(int x0,int y0,int x1,int y1) {} - virtual void paint(Panel* panel) {} -public: - virtual void doPaint(Panel* panel) {} -}; -} - -#endif From ca590f24208f7cf37889f833286822e33f4a1b5f Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 7 Dec 2017 00:31:27 +0300 Subject: [PATCH 134/199] Use old API to draw scoreboard and motd lines in goldsource --- cl_dll/cdll_int.cpp | 5 +++++ cl_dll/cl_util.h | 6 +++++- cl_dll/hud_redraw.cpp | 48 ++++++++++++++++++++++++------------------ cl_dll/input_mouse.cpp | 3 ++- 4 files changed, 39 insertions(+), 23 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index d71659e9..80b45e31 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -305,3 +305,8 @@ void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs ) return; gMobileEngfuncs = gpMobileEngfuncs; } + +bool isXashFWGS() +{ + return gMobileEngfuncs != NULL; +} diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 1996543d..23f12230 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -15,7 +15,8 @@ // // cl_util.h // - +#ifndef CL_UTIL_H +#define CL_UTIL_H #include "exportdef.h" #include "cvardef.h" @@ -179,3 +180,6 @@ inline void UnpackRGB( int &r, int &g, int &b, unsigned long ulRGB )\ } HSPRITE LoadSprite( const char *pszName ); + +bool isXashFWGS(); +#endif diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 829fd4b2..06b25a33 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -235,29 +235,35 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { - // xash3d: reset unicode state - gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); - - // draw the string until we hit the null character or a newline character - for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) + if (isXashFWGS()) { - int w = gHUD.m_scrinfo.charWidths['M']; - if( xpos + w > iMaxX ) - return xpos; - if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') ) - { - szIt++; - r = colors[*szIt - '0'][0]; - g = colors[*szIt - '0'][1]; - b = colors[*szIt - '0'][2]; - if( !*(++szIt) ) - return xpos; - } - int c = (unsigned int)(unsigned char)*szIt; - xpos += gEngfuncs.pfnVGUI2DrawCharacterAdditive( xpos, ypos, c, r, g, b, 0 ); - } + // xash3d: reset unicode state + gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); - return xpos; + // draw the string until we hit the null character or a newline character + for( ; *szIt != 0 && *szIt != '\n'; szIt++ ) + { + int w = gHUD.m_scrinfo.charWidths['M']; + if( xpos + w > iMaxX ) + return xpos; + if( ( *szIt == '^' ) && ( *( szIt + 1 ) >= '0') && ( *( szIt + 1 ) <= '7') ) + { + szIt++; + r = colors[*szIt - '0'][0]; + g = colors[*szIt - '0'][1]; + b = colors[*szIt - '0'][2]; + if( !*(++szIt) ) + return xpos; + } + int c = (unsigned int)(unsigned char)*szIt; + xpos += gEngfuncs.pfnVGUI2DrawCharacterAdditive( xpos, ypos, c, r, g, b, 0 ); + } + return xpos; + } + else + { + return gHUD.DrawHudString(xpos, ypos, iMaxX, szIt, r, g, b); + } } int CHud::DrawHudStringLen( const char *szIt ) diff --git a/cl_dll/input_mouse.cpp b/cl_dll/input_mouse.cpp index 724824cd..8d57091b 100644 --- a/cl_dll/input_mouse.cpp +++ b/cl_dll/input_mouse.cpp @@ -1,6 +1,7 @@ #include "input_mouse.h" #include "exportdef.h" #include "hud.h" +#include "cl_util.h" // shared between backends Vector dead_viewangles(0, 0, 0); @@ -68,7 +69,7 @@ void IN_Shutdown( void ) void IN_Init( void ) { #ifdef SUPPORT_GOLDSOURCE_INPUT - if (gMobileEngfuncs) { + if (isXashFWGS()) { gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); currentInput = &fwgsInput; } else { From 1759e8c956e1d4cbd42e9a6d17c1d4208b5b8f1a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 7 Dec 2017 01:25:59 +0300 Subject: [PATCH 135/199] Dynamic sdl2 loading from client --- cl_dll/CMakeLists.txt | 5 ++- cl_dll/input_goldsource.cpp | 73 ++++++++++++++++++++++++++++--------- cl_dll/input_mouse.h | 1 + 3 files changed, 60 insertions(+), 19 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index e5a3aa0a..e3ac075a 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -27,7 +27,10 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT -lSDL2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT") + if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ldl") + endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 5c2b0381..7c0e6183 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -28,8 +28,18 @@ #endif #ifdef USE_SDL2 +#include #include #include +int (*pfnSDL_SetRelativeMouseMode)(SDL_bool); +Uint32 (*pfnSDL_GetRelativeMouseState)(int* x, int* y); +int (*pfnSDL_NumJoysticks)(void); +SDL_bool (*pfnSDL_IsGameController)(int); +SDL_GameController* (*pfnSDL_GameControllerOpen)(int); +Sint16 (*pfnSDL_GameControllerGetAxis)(SDL_GameController*, SDL_GameControllerAxis); +Uint8 (*pfnSDL_GameControllerGetButton)(SDL_GameController*, SDL_GameControllerButton); +void (*pfnSDL_JoystickUpdate)(void); +const char* (*pfnSDL_GameControllerName)(SDL_GameController*); #endif #ifdef _WIN32 @@ -289,12 +299,12 @@ void IN_SetMouseMode(bool enable) if(m_bRawInput) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_TRUE); + pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } #else - SDL_SetRelativeMouseMode(SDL_TRUE); + pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif currentMouseMode = true; @@ -305,7 +315,7 @@ void IN_SetMouseMode(bool enable) if(isMouseRelative) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_FALSE); + pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; } @@ -313,7 +323,7 @@ void IN_SetMouseMode(bool enable) if (restore_spi) SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); #else - SDL_SetRelativeMouseMode(SDL_FALSE); + pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif currentMouseMode = false; @@ -464,6 +474,11 @@ void GoldSourceInput::IN_Shutdown (void) s_hMouseThreadActiveLock = (HANDLE)0; } #endif + +#ifdef USE_SDL2 + dlclose(sdl2Lib); + sdl2Lib = NULL; +#endif } /* @@ -623,7 +638,7 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) #endif { #ifdef USE_SDL2 - SDL_GetRelativeMouseState( &deltaX, &deltaY ); + pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); current_pos.x = deltaX; current_pos.y = deltaY; #else @@ -679,14 +694,14 @@ void GoldSourceInput::IN_GetMouseDelta( int *pOutX, int *pOutY) if(m_bRawInput && !isMouseRelative) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_TRUE); + pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } else if(!m_bRawInput && isMouseRelative) { #ifdef USE_SDL2 - SDL_SetRelativeMouseMode(SDL_FALSE); + pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; } @@ -815,7 +830,7 @@ void GoldSourceInput::IN_Accumulate (void) { #ifdef USE_SDL2 int deltaX, deltaY; - SDL_GetRelativeMouseState( &deltaX, &deltaY ); + pfnSDL_GetRelativeMouseState( &deltaX, &deltaY ); mx_accum += deltaX; my_accum += deltaY; #else @@ -869,14 +884,14 @@ void IN_StartupJoystick (void) // assume no joystick joy_avail = 0; #ifdef USE_SDL2 - int nJoysticks = SDL_NumJoysticks(); + int nJoysticks = pfnSDL_NumJoysticks(); if ( nJoysticks > 0 ) { for ( int i = 0; i < nJoysticks; i++ ) { - if ( SDL_IsGameController( i ) ) + if ( pfnSDL_IsGameController( i ) ) { - s_pJoystick = SDL_GameControllerOpen( i ); + s_pJoystick = pfnSDL_GameControllerOpen( i ); if ( s_pJoystick ) { //save the joystick's number of buttons and POV status @@ -888,7 +903,7 @@ void IN_StartupJoystick (void) // mark the joystick as available and advanced initialization not completed // this is needed as cvars are not available during initialization - gEngfuncs.Con_Printf ("joystick found\n\n", SDL_GameControllerName(s_pJoystick)); + gEngfuncs.Con_Printf ("joystick found\n\n", pfnSDL_GameControllerName(s_pJoystick)); joy_avail = 1; joy_advancedinit = 0; break; @@ -912,13 +927,13 @@ int RawValuePointer (int axis) { default: case JOY_AXIS_X: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); case JOY_AXIS_Y: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); case JOY_AXIS_Z: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); case JOY_AXIS_R: - return SDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); + return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); } #else @@ -1011,7 +1026,7 @@ void GoldSourceInput::IN_Commands (void) #ifdef USE_SDL2 for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { - if ( SDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + if ( pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) { buttonstate |= 1< Date: Thu, 7 Dec 2017 04:43:25 +0300 Subject: [PATCH 136/199] Provide safe wrappers around sdl function pointers. Use dylib extension on macOS --- cl_dll/input_goldsource.cpp | 137 ++++++++++++++++++++++++++++-------- 1 file changed, 108 insertions(+), 29 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 7c0e6183..e367a37e 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -40,6 +40,63 @@ Sint16 (*pfnSDL_GameControllerGetAxis)(SDL_GameController*, SDL_GameControllerAx Uint8 (*pfnSDL_GameControllerGetButton)(SDL_GameController*, SDL_GameControllerButton); void (*pfnSDL_JoystickUpdate)(void); const char* (*pfnSDL_GameControllerName)(SDL_GameController*); + +int safe_pfnSDL_SetRelativeMouseMode(SDL_bool mode) +{ + if (pfnSDL_SetRelativeMouseMode) + return pfnSDL_SetRelativeMouseMode(mode); + return -1; +} +Uint32 safe_pfnSDL_GetRelativeMouseState(int* x, int* y) +{ + if (pfnSDL_GetRelativeMouseState) + return pfnSDL_GetRelativeMouseState(x, y); + return 0; +} +int safe_pfnSDL_NumJoysticks() +{ + if (pfnSDL_NumJoysticks) + return pfnSDL_NumJoysticks(); + return -1; +} +SDL_bool safe_pfnSDL_IsGameController(int joystick_index) +{ + if (pfnSDL_IsGameController) + return pfnSDL_IsGameController(joystick_index); + return SDL_FALSE; +} +SDL_GameController* safe_pfnSDL_GameControllerOpen(int joystick_index) +{ + if (pfnSDL_GameControllerOpen) + return pfnSDL_GameControllerOpen(joystick_index); + return NULL; +} +Sint16 safe_pfnSDL_GameControllerGetAxis(SDL_GameController* gamecontroller, SDL_GameControllerAxis axis) +{ + if (pfnSDL_GameControllerGetAxis) + return pfnSDL_GameControllerGetAxis(gamecontroller, axis); + return 0; +} +Uint8 safe_pfnSDL_GameControllerGetButton(SDL_GameController* gamecontroller, SDL_GameControllerButton button) +{ + if (pfnSDL_GameControllerGetButton) + return pfnSDL_GameControllerGetButton(gamecontroller, button); + return 0; +} +void safe_pfnSDL_JoystickUpdate() +{ + if (pfnSDL_JoystickUpdate) + pfnSDL_JoystickUpdate(); +} +const char* safe_pfnSDL_GameControllerName(SDL_GameController* gamecontroller) +{ + if (pfnSDL_GameControllerName) + return pfnSDL_GameControllerName(gamecontroller); + return NULL; +} +static void** const sdlFunctionPointers[] = {(void**)&pfnSDL_SetRelativeMouseMode, (void**)&pfnSDL_GetRelativeMouseState, (void**)&pfnSDL_NumJoysticks, + (void**)&pfnSDL_IsGameController, (void**)&pfnSDL_GameControllerOpen, (void**)&pfnSDL_GameControllerGetAxis, + (void**)&pfnSDL_GameControllerGetButton, (void**)&pfnSDL_JoystickUpdate, (void**)&pfnSDL_GameControllerName}; #endif #ifdef _WIN32 @@ -299,12 +356,12 @@ void IN_SetMouseMode(bool enable) if(m_bRawInput) { #ifdef USE_SDL2 - pfnSDL_SetRelativeMouseMode(SDL_TRUE); + safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif isMouseRelative = true; } #else - pfnSDL_SetRelativeMouseMode(SDL_TRUE); + safe_pfnSDL_SetRelativeMouseMode(SDL_TRUE); #endif currentMouseMode = true; @@ -315,7 +372,7 @@ void IN_SetMouseMode(bool enable) if(isMouseRelative) { #ifdef USE_SDL2 - pfnSDL_SetRelativeMouseMode(SDL_FALSE); + safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif isMouseRelative = false; } @@ -323,7 +380,7 @@ void IN_SetMouseMode(bool enable) if (restore_spi) SystemParametersInfo (SPI_SETMOUSE, 0, originalmouseparms, 0); #else - pfnSDL_SetRelativeMouseMode(SDL_FALSE); + safe_pfnSDL_SetRelativeMouseMode(SDL_FALSE); #endif currentMouseMode = false; @@ -476,6 +533,9 @@ void GoldSourceInput::IN_Shutdown (void) #endif #ifdef USE_SDL2 + for (int j=0; j 0 ) { for ( int i = 0; i < nJoysticks; i++ ) { - if ( pfnSDL_IsGameController( i ) ) + if ( safe_pfnSDL_IsGameController( i ) ) { - s_pJoystick = pfnSDL_GameControllerOpen( i ); + s_pJoystick = safe_pfnSDL_GameControllerOpen( i ); if ( s_pJoystick ) { //save the joystick's number of buttons and POV status @@ -903,7 +963,7 @@ void IN_StartupJoystick (void) // mark the joystick as available and advanced initialization not completed // this is needed as cvars are not available during initialization - gEngfuncs.Con_Printf ("joystick found\n\n", pfnSDL_GameControllerName(s_pJoystick)); + gEngfuncs.Con_Printf ("joystick found\n\n", safe_pfnSDL_GameControllerName(s_pJoystick)); joy_avail = 1; joy_advancedinit = 0; break; @@ -927,13 +987,13 @@ int RawValuePointer (int axis) { default: case JOY_AXIS_X: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTX ); case JOY_AXIS_Y: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_LEFTY ); case JOY_AXIS_Z: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTX ); case JOY_AXIS_R: - return pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); + return safe_pfnSDL_GameControllerGetAxis( s_pJoystick, SDL_CONTROLLER_AXIS_RIGHTY ); } #else @@ -1026,7 +1086,7 @@ void GoldSourceInput::IN_Commands (void) #ifdef USE_SDL2 for ( i = 0; i < SDL_CONTROLLER_BUTTON_MAX; i++ ) { - if ( pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) + if ( safe_pfnSDL_GameControllerGetButton( s_pJoystick, (SDL_GameControllerButton)i ) ) { buttonstate |= 1< Date: Thu, 7 Dec 2017 21:25:26 +0300 Subject: [PATCH 137/199] sdl loading refactoring --- cl_dll/input_goldsource.cpp | 58 ++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 33 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index e367a37e..38dac71d 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -28,6 +28,7 @@ #endif #ifdef USE_SDL2 +#define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) ) #include #include #include @@ -94,9 +95,23 @@ const char* safe_pfnSDL_GameControllerName(SDL_GameController* gamecontroller) return pfnSDL_GameControllerName(gamecontroller); return NULL; } -static void** const sdlFunctionPointers[] = {(void**)&pfnSDL_SetRelativeMouseMode, (void**)&pfnSDL_GetRelativeMouseState, (void**)&pfnSDL_NumJoysticks, - (void**)&pfnSDL_IsGameController, (void**)&pfnSDL_GameControllerOpen, (void**)&pfnSDL_GameControllerGetAxis, - (void**)&pfnSDL_GameControllerGetButton, (void**)&pfnSDL_JoystickUpdate, (void**)&pfnSDL_GameControllerName}; + +struct SDLFunction +{ + void** ppfnFunc; + const char* name; +}; +static SDLFunction sdlFunctions[] = { + {(void**)&pfnSDL_SetRelativeMouseMode, "SDL_SetRelativeMouseMode"}, + {(void**)&pfnSDL_GetRelativeMouseState, "SDL_GetRelativeMouseState"}, + {(void**)&pfnSDL_NumJoysticks, "SDL_NumJoysticks"}, + {(void**)&pfnSDL_IsGameController, "SDL_IsGameController"}, + {(void**)&pfnSDL_GameControllerOpen, "SDL_GameControllerOpen"}, + {(void**)&pfnSDL_GameControllerGetAxis, "SDL_GameControllerGetAxis"}, + {(void**)&pfnSDL_GameControllerGetButton, "SDL_GameControllerGetButton"}, + {(void**)&pfnSDL_JoystickUpdate, "SDL_JoystickUpdate"}, + {(void**)&pfnSDL_GameControllerName, "SDL_GameControllerName"} +}; #endif #ifdef _WIN32 @@ -533,8 +548,8 @@ void GoldSourceInput::IN_Shutdown (void) #endif #ifdef USE_SDL2 - for (int j=0; j Date: Sat, 9 Dec 2017 00:16:29 +0300 Subject: [PATCH 138/199] Update README.md, update makefiles, add .bat scripts for msvc --- README.md | 92 +++++++++++++++++++++++++++++----- cl_dll/Android.mk | 4 +- cl_dll/Makefile | 1 - cl_dll/compile.bat | 84 +++++++++++++++++++++++++++++++ dlls/Makefile | 4 +- dlls/compile.bat | 121 +++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 291 insertions(+), 15 deletions(-) create mode 100644 cl_dll/compile.bat create mode 100644 dlls/compile.bat diff --git a/README.md b/README.md index bb1cc675..21db93fb 100644 --- a/README.md +++ b/README.md @@ -6,22 +6,41 @@ Half-Life SDK for Xash3D & GoldSource with some fixes. ### CMake as most universal way -``` -mkdir build && cd build -cmake ../ -``` + mkdir build && cd build + cmake ../ + make You may enable or disable some build options by -Dkey=value. All available build options are defined in CMakeLists.txt at root directory. +See below if you want to build the GoldSource compatible libraries. See below, if CMake is not suitable for you: ### Windows +#### Using msvc + +We use compilers provided with Microsoft Visual Studio 6. There're `compile.bat` scripts in both `cl_dll` and `dlls` directories. +Before running any of those files you must define `MSVCDir` variable which is the path to your msvc installation. + + set MSVCDir=C:\Program Files\Microsoft Visual Studio + compile.bat + +These scripts also can be ran via wine: + + MSVCDir="z:\home\$USER\.wine\drive_c\Program Files\Microsoft Visual Studio" wine cmd /c compile.bat + +The libraries built this way are always GoldSource compatible. + +There're dsp projects for MVS 6 in `cl_dll` and `dlls` directories, but we don't keep them up-to-date. You're free to adapt them for yourself and try to import into the newer MVS versions. + +#### Using mingw + TODO ### Linux -TODO + (cd dlls && make) + (cd cl_dll && make) ### OS X @@ -29,14 +48,65 @@ TODO ### FreeBSD -``` - cd dlls - gmake CXX=clang++ CC=clang - cd ../cl_dll - gmake CXX=clang++ CC=clang -``` + (cd dlls && gmake CXX=clang++ CC=clang) + (cd cl_dll && gmake CXX=clang++ CC=clang) ### Android Just typical `ndk-build`. +TODO: describe what it is. +### Building GoldSource-compatible libraries + +To enable building the goldsource compatible client library add GOLDSOURCE_SUPPORT flag when calling cmake: + + cmake .. -DGOLDSOURCE_SUPPORT=ON + +or when using make without cmake: + + make GOLDSOURCE_SUPPORT=1 + +Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d. + +Note for **Linux**: GoldSource requires libraries (both client and server) to be compiled with libstdc++ bundled with g++ of major version 4 (versions from 4.6 to 4.9 should work). +If your Linux distribution does not provide compatible g++ version you have several options. + +#### Method 1: Statically build with c++ library + +This one is the most simple but has a drawback. + + cmake ../ -DGOLDSOURCE_SUPPORT=ON -DCMAKE_C_FLAGS="-static-libstdc++ -static-libgcc" + +The drawback is that the compiled libraries will be larger in size. + +#### Method 2: Create and use chroot with older distro that includes g++ 4. + +Use the most suitable way for you to create an old distro 32-bit chroot. E.g. on Debian (and similar) you can use debootstrap. + + sudo debootstrap --arch=i386 jessie /var/chroot/jessie-debian-i386 # On Ubuntu type trusty instead of jessie + sudo chroot /var/chroot/jessie-debian-i386 + +Inside chroot install cmake, make, g++ and libsdl2-dev. Then exit the chroot. + +On the host system install schroot. Then create and adapt the following config in /etc/schroot/chroot.d/jessie.conf (you can choose a different name): + +``` +[jessie] +type=directory +description=Debian jessie i386 +directory=/var/chroot/debian-jessie-i386/ +users=yourusername +groups=yourusername +root-groups=root +preserve-environment=true +personality=linux32 +``` + +Insert your actual user name in place of `yourusername`. Then prepend any make or cmake call with `schroot -c jessie --`: + + schroot -c jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot -c jessie -- make + +#### Method 3: Install the needed g++ version yourself + +TODO: describe steps. diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 452eb48b..68917633 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -105,7 +105,9 @@ LOCAL_CFLAGS += $(DEFINES) $(INCLUDES) ifeq ($(GOLDSOURCE_SUPPORT),1) DEFINES += -DGOLDSOURCE_SUPPORT - LOCAL_LDLIBS += -lSDL2 + ifeq ($(shell uname -s),Linux) + LOCAL_LDLIBS += -ldl + endif endif LOCAL_SRC_FILES := $(SRCS) $(SRCS_C) diff --git a/cl_dll/Makefile b/cl_dll/Makefile index f624473e..0ff4dadf 100644 --- a/cl_dll/Makefile +++ b/cl_dll/Makefile @@ -75,7 +75,6 @@ OBJS = $(SRCS:.cpp=.o) $(SRCS_C:.c=.o) LIBS=-lm ifeq ($(GOLDSOURCE_SUPPORT),1) DEFINES += -DGOLDSOURCE_SUPPORT - LIBS += -lSDL2 endif ifeq ($(shell uname -s),Linux) diff --git a/cl_dll/compile.bat b/cl_dll/compile.bat new file mode 100644 index 00000000..9270d4bc --- /dev/null +++ b/cl_dll/compile.bat @@ -0,0 +1,84 @@ +@echo off +echo Setting environment for minimal Visual C++ 6 +set INCLUDE=%MSVCDir%\VC98\Include +set LIB=%MSVCDir%\VC98\Lib +set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH% + +echo -- Compiler is MSVC6 + +set XASH3DSRC=..\..\Xash3D_original +set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public -I../external -I../dlls -I../utils/false_vgui/include +set SOURCES=../dlls/crossbow.cpp^ + ../dlls/crowbar.cpp^ + ../dlls/egon.cpp^ + ../dlls/gauss.cpp^ + ../dlls/handgrenade.cpp^ + ../dlls/hornetgun.cpp^ + ../dlls/mp5.cpp^ + ../dlls/python.cpp^ + ../dlls/rpg.cpp^ + ../dlls/satchel.cpp^ + ../dlls/shotgun.cpp^ + ../dlls/squeakgrenade.cpp^ + ../dlls/tripmine.cpp^ + ../dlls/glock.cpp^ + ev_hldm.cpp^ + hl/hl_baseentity.cpp^ + hl/hl_events.cpp^ + hl/hl_objects.cpp^ + hl/hl_weapons.cpp^ + ammo.cpp^ + ammo_secondary.cpp^ + ammohistory.cpp^ + battery.cpp^ + cdll_int.cpp^ + com_weapons.cpp^ + death.cpp^ + demo.cpp^ + entity.cpp^ + ev_common.cpp^ + events.cpp^ + flashlight.cpp^ + GameStudioModelRenderer.cpp^ + geiger.cpp^ + health.cpp^ + hud.cpp^ + hud_msg.cpp^ + hud_redraw.cpp^ + hud_spectator.cpp^ + hud_update.cpp^ + in_camera.cpp^ + input.cpp^ + input_goldsource.cpp^ + input_mouse.cpp^ + input_xash3d.cpp^ + menu.cpp^ + message.cpp^ + overview.cpp^ + parsemsg.cpp^ + ../pm_shared/pm_debug.c^ + ../pm_shared/pm_math.c^ + ../pm_shared/pm_shared.c^ + saytext.cpp^ + status_icons.cpp^ + statusbar.cpp^ + studio_util.cpp^ + StudioModelRenderer.cpp^ + text_message.cpp^ + train.cpp^ + tri.cpp^ + util.cpp^ + view.cpp^ + scoreboard.cpp^ + MOTD.cpp +set DEFINES=/DCLIENT_DLL /DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR /DGOLDSOURCE_SUPPORT +set LIBS=user32.lib Winmm.lib +set OUTNAME=client.dll +set DEBUG=/debug + +cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG% + +echo -- Compile done. Cleaning... + +del *.obj *.exp *.lib *.ilk +echo -- Done. diff --git a/dlls/Makefile b/dlls/Makefile index 60aad1b3..3599b9c7 100644 --- a/dlls/Makefile +++ b/dlls/Makefile @@ -129,13 +129,13 @@ OBJ = \ $(DLL_OBJDIR)/multiplay_gamerules.o \ $(DLL_OBJDIR)/nihilanth.o \ $(DLL_OBJDIR)/nodes.o \ - $(DLL_OBJDIR)/observer.cpp \^M + $(DLL_OBJDIR)/observer.o \ $(DLL_OBJDIR)/osprey.o \ $(DLL_OBJDIR)/pathcorner.o \ $(DLL_OBJDIR)/plane.o \ $(DLL_OBJDIR)/plats.o \ $(DLL_OBJDIR)/player.o \ - $(DLL_OBJDIR)/playermonster.o \^M + $(DLL_OBJDIR)/playermonster.o \ $(DLL_OBJDIR)/python.o \ $(DLL_OBJDIR)/rat.o \ $(DLL_OBJDIR)/roach.o \ diff --git a/dlls/compile.bat b/dlls/compile.bat new file mode 100644 index 00000000..53c4511b --- /dev/null +++ b/dlls/compile.bat @@ -0,0 +1,121 @@ +@echo off +echo Setting environment for minimal Visual C++ 6 +set INCLUDE=%MSVCDir%\VC98\Include +set LIB=%MSVCDir%\VC98\Lib +set PATH=%MSVCDir%\VC98\Bin;%MSVCDir%\Common\MSDev98\Bin\;%PATH% + +echo -- Compiler is MSVC6 + +set XASH3DSRC=..\..\Xash3D_original +set INCLUDES=-I../common -I../engine -I../pm_shared -I../game_shared -I../public +set SOURCES=agrunt.cpp^ + airtank.cpp^ + aflock.cpp^ + animating.cpp^ + animation.cpp^ + apache.cpp^ + barnacle.cpp^ + barney.cpp^ + bigmomma.cpp^ + bloater.cpp^ + bmodels.cpp^ + bullsquid.cpp^ + buttons.cpp^ + cbase.cpp^ + client.cpp^ + combat.cpp^ + controller.cpp^ + crossbow.cpp^ + crowbar.cpp^ + defaultai.cpp^ + doors.cpp^ + effects.cpp^ + egon.cpp^ + explode.cpp^ + flyingmonster.cpp^ + func_break.cpp^ + func_tank.cpp^ + game.cpp^ + gamerules.cpp^ + gargantua.cpp^ + gauss.cpp^ + genericmonster.cpp^ + ggrenade.cpp^ + globals.cpp^ + glock.cpp^ + gman.cpp^ + h_ai.cpp^ + h_battery.cpp^ + h_cine.cpp^ + h_cycler.cpp^ + h_export.cpp^ + handgrenade.cpp^ + hassassin.cpp^ + headcrab.cpp^ + healthkit.cpp^ + hgrunt.cpp^ + hornet.cpp^ + hornetgun.cpp^ + houndeye.cpp^ + ichthyosaur.cpp^ + islave.cpp^ + items.cpp^ + leech.cpp^ + lights.cpp^ + maprules.cpp^ + monstermaker.cpp^ + monsters.cpp^ + monsterstate.cpp^ + mortar.cpp^ + mp5.cpp^ + multiplay_gamerules.cpp^ + nihilanth.cpp^ + nodes.cpp^ + observer.cpp^ + osprey.cpp^ + pathcorner.cpp^ + plane.cpp^ + plats.cpp^ + player.cpp^ + playermonster.cpp^ + python.cpp^ + rat.cpp^ + roach.cpp^ + rpg.cpp^ + satchel.cpp^ + schedule.cpp^ + scientist.cpp^ + scripted.cpp^ + shotgun.cpp^ + singleplay_gamerules.cpp^ + skill.cpp^ + sound.cpp^ + soundent.cpp^ + spectator.cpp^ + squadmonster.cpp^ + squeakgrenade.cpp^ + subs.cpp^ + talkmonster.cpp^ + teamplay_gamerules.cpp^ + tempmonster.cpp^ + tentacle.cpp^ + triggers.cpp^ + tripmine.cpp^ + turret.cpp^ + util.cpp^ + weapons.cpp^ + world.cpp^ + xen.cpp^ + zombie.cpp^ + ../pm_shared/pm_debug.c ../pm_shared/pm_math.c ../pm_shared/pm_shared.c +set DEFINES=/DCLIENT_WEAPONS /Dsnprintf=_snprintf /DNO_VOICEGAMEMGR +set LIBS=user32.lib +set OUTNAME=hl.dll +set DEBUG=/debug + +cl %DEFINES% %LIBS% %SOURCES% %INCLUDES% -o %OUTNAME% /link /dll /out:%OUTNAME% %DEBUG% /def:".\hl.def" + +echo -- Compile done. Cleaning... + +del *.obj *.exp *.lib *.ilk +echo -- Done. From 0d56674e28cf6d08eda6cca79ce208a16a1af6bd Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 9 Dec 2017 13:49:31 +0300 Subject: [PATCH 139/199] Add steam runtime chroot method --- README.md | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 21db93fb..f0d3b4a1 100644 --- a/README.md +++ b/README.md @@ -79,7 +79,21 @@ This one is the most simple but has a drawback. The drawback is that the compiled libraries will be larger in size. -#### Method 2: Create and use chroot with older distro that includes g++ 4. +#### Method 2: Build in Steam Runtime chroot + +This is the official way to build Steam compatible games for Linux. + +Clone https://github.com/ValveSoftware/steam-runtime and follow instructions https://github.com/ValveSoftware/steam-runtime#building-in-the-runtime + + sudo ./setup_chroot.sh --i386 + +Then use cmake and make as usual, but prepend the commands with `schroot --chroot steamrt_scout_i386 --`: + + mkdir build-in-steamrt && cd build-in-steamrt + schroot --chroot steamrt_scout_i386 -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot --chroot steamrt_scout_i386 -- make + +#### Method 3: Create your own chroot with older distro that includes g++ 4. Use the most suitable way for you to create an old distro 32-bit chroot. E.g. on Debian (and similar) you can use debootstrap. @@ -104,9 +118,10 @@ personality=linux32 Insert your actual user name in place of `yourusername`. Then prepend any make or cmake call with `schroot -c jessie --`: - schroot -c jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON - schroot -c jessie -- make + mkdir build-in-chroot && cd build-in-chroot + schroot --chroot jessie -- cmake ../ -DGOLDSOURCE_SUPPORT=ON + schroot --chroot jessie -- make -#### Method 3: Install the needed g++ version yourself +#### Method 4: Install the needed g++ version yourself TODO: describe steps. From 87d6ca3b687eb0f6b3745c1ec79d22aac9071783 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 9 Dec 2017 14:45:54 +0300 Subject: [PATCH 140/199] Add instructions for using chroot toolchain in QtCreator --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index f0d3b4a1..9261b1b3 100644 --- a/README.md +++ b/README.md @@ -125,3 +125,17 @@ Insert your actual user name in place of `yourusername`. Then prepend any make o #### Method 4: Install the needed g++ version yourself TODO: describe steps. + +#### Configuring Qt Creator to use toolchain from chroot + +Create a file with the following contents anywhere: + +```sh +#!/bin/sh +schroot --chroot steamrt_scout_i386 -- cmake "$@" +``` + +Make it executable. +In Qt Creator go to `Tools` -> `Options` -> `Build & Run` -> `CMake`. Add a new cmake tool and specify the path of previously created file. +Go to `Kits` tab, clone your default configuration and choose your CMake tool there. +Choose the new kit when opening CMakeLists.txt. From 5a60f08a59651aaaac73efa4af147f2a2d391a57 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 4 Dec 2017 01:02:25 +0300 Subject: [PATCH 141/199] Joystick support for non-sdl win32 (untested) --- cl_dll/input_goldsource.cpp | 161 ++++++++++++++++++++++++++++++++++-- 1 file changed, 153 insertions(+), 8 deletions(-) diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index 38dac71d..f530bdbc 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -217,10 +217,25 @@ enum _ControlList AxisTurn }; +#if !defined(USE_SDL2) && defined(_WIN32) +DWORD dwAxisFlags[JOY_MAX_AXES] = +{ + JOY_RETURNX, + JOY_RETURNY, + JOY_RETURNZ, + JOY_RETURNR, + JOY_RETURNU, + JOY_RETURNV +}; +#endif DWORD dwAxisMap[ JOY_MAX_AXES ]; DWORD dwControlMap[ JOY_MAX_AXES ]; +#if defined(USE_SDL2) int pdwRawValue[ JOY_MAX_AXES ]; +#elif defined(_WIN32) +PDWORD pdwRawValue[ JOY_MAX_AXES ]; +#endif DWORD joy_oldbuttonstate, joy_oldpovstate; int joy_id; @@ -228,6 +243,9 @@ DWORD joy_numbuttons; #ifdef USE_SDL2 SDL_GameController *s_pJoystick = NULL; +#elif defined(_WIN32) +DWORD joy_flags; +static JOYINFOEX ji; #endif // none of these cvars are saved over a session @@ -990,14 +1008,64 @@ void IN_StartupJoystick (void) { gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); } +#elif defined(_WIN32) + int numdevs; + JOYCAPS jc; + MMRESULT mmr; + // verify joystick driver is present + if ((numdevs = joyGetNumDevs ()) == 0) + { + gEngfuncs.Con_DPrintf ("joystick not found -- driver not present\n\n"); + return; + } + + // cycle through the joystick ids for the first valid one + for (joy_id=0 ; joy_idvalue != 0.0) + { + ji.dwUpos += 100; + } + return 1; + } + else + { + // read error occurred + // turning off the joystick seems too harsh for 1 read error,\ + // but what should be done? + // Con_Printf ("IN_ReadJoystick: no response\n"); + // joy_avail = 0; + return 0; + } +#else + return 0; +#endif } @@ -1213,7 +1353,12 @@ void IN_JoyMove ( float frametime, usercmd_t *cmd ) for (i = 0; i < JOY_MAX_AXES; i++) { // get the floating point zero-centered, potentially-inverted data for the current axis +#ifdef USE_SDL2 fAxisValue = (float)pdwRawValue[i]; +#elif defined(_WIN32) + fAxisValue = (float) *pdwRawValue[i]; + fAxisValue -= 32768.0; +#endif if (joy_wwhack2->value != 0.0) { From 18adf0979fe6fe8a9af2e5f46721f198b6274e5e Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 20:56:46 +0500 Subject: [PATCH 142/199] Redefine string_t. Fix wrong variables type. --- cl_dll/util_vector.h | 2 +- common/const.h | 2 +- dlls/bigmomma.cpp | 2 +- dlls/cbase.h | 2 +- dlls/effects.cpp | 6 +++--- dlls/effects.h | 2 +- dlls/extdll.h | 2 +- dlls/func_break.h | 4 ++-- dlls/func_tank.cpp | 6 +++--- dlls/lights.cpp | 2 +- dlls/mortar.cpp | 4 ++-- dlls/plats.cpp | 6 +++--- dlls/scripted.cpp | 6 +++--- dlls/scripted.h | 6 +++--- dlls/talkmonster.h | 4 ++-- dlls/triggers.cpp | 14 +++++++------- dlls/util.cpp | 14 +++++++------- dlls/util.h | 4 ++-- dlls/weapons.h | 2 +- 19 files changed, 45 insertions(+), 45 deletions(-) diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index ff5f9a91..8b596ac1 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -23,7 +23,7 @@ // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; // -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h //========================================================= diff --git a/common/const.h b/common/const.h index d29816e6..3d738675 100644 --- a/common/const.h +++ b/common/const.h @@ -733,7 +733,7 @@ enum }; typedef unsigned int func_t; -typedef unsigned int string_t; +typedef int string_t; typedef unsigned char byte; typedef unsigned short word; diff --git a/dlls/bigmomma.cpp b/dlls/bigmomma.cpp index 6b594983..434d6134 100644 --- a/dlls/bigmomma.cpp +++ b/dlls/bigmomma.cpp @@ -49,7 +49,7 @@ public: virtual int Restore( CRestore &restore ); static TYPEDESCRIPTION m_SaveData[]; - int m_preSequence; + string_t m_preSequence; }; LINK_ENTITY_TO_CLASS( info_bigmomma, CInfoBM ) diff --git a/dlls/cbase.h b/dlls/cbase.h index b78de883..10f7a85f 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -438,7 +438,7 @@ class CBaseDelay : public CBaseEntity { public: float m_flDelay; - int m_iszKillTarget; + string_t m_iszKillTarget; virtual void KeyValue( KeyValueData *pkvd ); virtual int Save( CSave &save ); diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 15df3bc3..5b8d650c 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -379,9 +379,10 @@ public: void BeamUpdateVars( void ); + string_t m_iszStartEntity; + string_t m_iszEndEntity; + string_t m_iszSpriteName; int m_active; - int m_iszStartEntity; - int m_iszEndEntity; float m_life; int m_boltWidth; int m_noiseAmplitude; @@ -389,7 +390,6 @@ public: int m_speed; float m_restrike; int m_spriteTexture; - int m_iszSpriteName; int m_frameStart; float m_radius; diff --git a/dlls/effects.h b/dlls/effects.h index 68f0ea29..f4b6b5b2 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -321,7 +321,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; CSprite *m_pSprite; - int m_iszSpriteName; + string_t m_iszSpriteName; Vector m_firePosition; }; #endif //EFFECTS_H diff --git a/dlls/extdll.h b/dlls/extdll.h index 45c42309..812ce40f 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -69,7 +69,7 @@ typedef int BOOL; // Header file containing definition of globalvars_t and entvars_t typedef unsigned int func_t; -typedef unsigned int string_t; // from engine's pr_comp.h; +typedef int string_t; // from engine's pr_comp.h; typedef float vec_t; // needed before including progdefs.h // Vector class diff --git a/dlls/func_break.h b/dlls/func_break.h index ab5dda41..b4ff1fc1 100644 --- a/dlls/func_break.h +++ b/dlls/func_break.h @@ -82,9 +82,9 @@ public: Materials m_Material; Explosions m_Explosion; + string_t m_iszGibModel; + string_t m_iszSpawnObject; int m_idShard; float m_angle; - int m_iszGibModel; - int m_iszSpawnObject; }; #endif // FUNC_BREAK_H diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 6eebc675..013948eb 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -97,6 +97,9 @@ public: protected: CBasePlayer* m_pController; + string_t m_iszSpriteSmoke; + string_t m_iszSpriteFlash; + string_t m_iszMaster; // Master entity (game_team_master or multisource) float m_flNextAttack; Vector m_vecControllerUsePos; @@ -120,14 +123,11 @@ protected: Vector m_barrelPos; // Length of the freakin barrel float m_spriteScale; // Scale of any sprites we shoot - int m_iszSpriteSmoke; - int m_iszSpriteFlash; TANKBULLET m_bulletType; // Bullet type int m_iBulletDamage; // 0 means use Bullet type's default damage Vector m_sightOrigin; // Last sight of target int m_spread; // firing spread - int m_iszMaster; // Master entity (game_team_master or multisource) }; TYPEDESCRIPTION CFuncTank::m_SaveData[] = diff --git a/dlls/lights.cpp b/dlls/lights.cpp index e6b03125..8a4f8de8 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -37,8 +37,8 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: + string_t m_iszPattern; int m_iStyle; - int m_iszPattern; }; LINK_ENTITY_TO_CLASS( light, CLight ) diff --git a/dlls/mortar.cpp b/dlls/mortar.cpp index 33a7d2da..7faf3e56 100644 --- a/dlls/mortar.cpp +++ b/dlls/mortar.cpp @@ -45,8 +45,8 @@ public: void EXPORT FieldUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); - int m_iszXController; - int m_iszYController; + string_t m_iszXController; + string_t m_iszYController; float m_flSpread; float m_flDelay; int m_iCount; diff --git a/dlls/plats.cpp b/dlls/plats.cpp index c1220f3c..b3e1c683 100644 --- a/dlls/plats.cpp +++ b/dlls/plats.cpp @@ -1619,9 +1619,9 @@ public: CFuncTrackTrain *m_train; - int m_trackTopName; - int m_trackBottomName; - int m_trainName; + string_t m_trackTopName; + string_t m_trackBottomName; + string_t m_trainName; TRAIN_CODE m_code; int m_targetState; int m_use; diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index 678502f6..92b9aa6a 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -907,15 +907,15 @@ public: BOOL StartSentence( CBaseMonster *pTarget ); private: - int m_iszSentence; // string index for idle animation - int m_iszEntity; // entity that is wanted for this sentence + string_t m_iszSentence; // string index for idle animation + string_t m_iszEntity; // entity that is wanted for this sentence + string_t m_iszListener; // name of entity to look at while talking float m_flRadius; // range to search float m_flDuration; // How long the sentence lasts float m_flRepeat; // repeat rate float m_flAttenuation; float m_flVolume; BOOL m_active; - int m_iszListener; // name of entity to look at while talking }; #define SF_SENTENCE_ONCE 0x0001 diff --git a/dlls/scripted.h b/dlls/scripted.h index 25348114..6cf8cfa1 100644 --- a/dlls/scripted.h +++ b/dlls/scripted.h @@ -77,9 +77,9 @@ public: void AllowInterrupt( BOOL fAllow ); int IgnoreConditions( void ); - int m_iszIdle; // string index for idle animation - int m_iszPlay; // string index for scripted animation - int m_iszEntity; // entity that is wanted for this script + string_t m_iszIdle; // string index for idle animation + string_t m_iszPlay; // string index for scripted animation + string_t m_iszEntity; // entity that is wanted for this script int m_fMoveTo; int m_iFinishSchedule; float m_flRadius; // range to search diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 72222aae..084861bc 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -162,8 +162,8 @@ public: int m_voicePitch; // pitch of voice for this head const char *m_szGrp[TLK_CGROUPS]; // sentence group names float m_useTime; // Don't allow +USE until this time - int m_iszUse; // Custom +USE sentence group (follow) - int m_iszUnUse; // Custom +USE sentence group (stop following) + string_t m_iszUse; // Custom +USE sentence group (follow) + string_t m_iszUnUse; // Custom +USE sentence group (stop following) float m_flLastSaidSmelled;// last time we talked about something that stinks float m_flStopTalkTime;// when in the future that I'll be done saying this sentence. diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 8171a195..7d7f255c 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -114,7 +114,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - int m_globalstate; + string_t m_globalstate; USE_TYPE triggerType; }; @@ -267,11 +267,11 @@ public: static TYPEDESCRIPTION m_SaveData[]; - int m_cTargets; // the total number of targets in this manager's fire list. + string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array + float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire + int m_cTargets; // the total number of targets in this manager's fire list. int m_index; // Current target float m_startTime;// Time we started firing - int m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array - float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire private: inline BOOL IsClone( void ) { return ( pev->spawnflags & SF_MULTIMAN_CLONE ) ? TRUE : FALSE; } inline BOOL ShouldClone( void ) @@ -1321,9 +1321,9 @@ public: static TYPEDESCRIPTION m_SaveData[]; + string_t m_changeTarget; char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map - int m_changeTarget; float m_changeTargetDelay; }; @@ -2054,7 +2054,7 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - int m_iszNewTarget; + string_t m_iszNewTarget; }; LINK_ENTITY_TO_CLASS( trigger_changetarget, CTriggerChangeTarget ) @@ -2117,7 +2117,7 @@ public: EHANDLE m_hPlayer; EHANDLE m_hTarget; CBaseEntity *m_pentPath; - int m_sPath; + string_t m_sPath; float m_flWait; float m_flReturnTime; float m_flStopTime; diff --git a/dlls/util.cpp b/dlls/util.cpp index f382ac58..94c8c68c 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -1586,7 +1586,7 @@ void UTIL_StripToken( const char *pKey, char *pDest ) static int gSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT - sizeof(int), // FIELD_STRING + sizeof(string_t), // FIELD_STRING sizeof(void*), // FIELD_ENTITY sizeof(void*), // FIELD_CLASSPTR sizeof(void*), // FIELD_EHANDLE @@ -1613,7 +1613,7 @@ static int gSizes[FIELD_TYPECOUNT] = static int gInputSizes[FIELD_TYPECOUNT] = { sizeof(float), // FIELD_FLOAT - sizeof(int), // FIELD_STRING + sizeof(string_t), // FIELD_STRING sizeof(int), // FIELD_ENTITY sizeof(int), // FIELD_CLASSPTR sizeof(int), // FIELD_EHANDLE @@ -1940,7 +1940,7 @@ void EntvarsKeyvalue( entvars_t *pev, KeyValueData *pkvd ) case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: - ( *(int *)( (char *)pev + pField->fieldOffset ) ) = ALLOC_STRING( pkvd->szValue ); + ( *(string_t *)( (char *)pev + pField->fieldOffset ) ) = ALLOC_STRING( pkvd->szValue ); break; case FIELD_TIME: case FIELD_FLOAT: @@ -2014,7 +2014,7 @@ int CSave::WriteFields( const char *pname, void *pBaseData, TYPEDESCRIPTION *pFi case FIELD_MODELNAME: case FIELD_SOUNDNAME: case FIELD_STRING: - WriteString( pTest->fieldName, (int *)pOutputData, pTest->fieldSize ); + WriteString( pTest->fieldName, (string_t *)pOutputData, pTest->fieldSize ); break; case FIELD_CLASSPTR: case FIELD_EVARS: @@ -2197,14 +2197,14 @@ int CRestore::ReadField( void *pBaseData, TYPEDESCRIPTION *pFields, int fieldCou } pInputData = pString; if( strlen( (char *)pInputData ) == 0 ) - *( (int *)pOutputData ) = 0; + *( (string_t *)pOutputData ) = 0; else { - int string; + string_t string; string = ALLOC_STRING( (char *)pInputData ); - *( (int *)pOutputData ) = string; + *( (string_t *)pOutputData ) = string; if( !FStringNull( string ) && m_precache ) { diff --git a/dlls/util.h b/dlls/util.h index 2ffe536e..ee7d116b 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -37,13 +37,13 @@ extern globalvars_t *gpGlobals; #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) #if !defined XASH_64BIT || defined(CLIENT_DLL) -#define MAKE_STRING(str) ((size_t)str - (size_t)STRING(0)) +#define MAKE_STRING(str) ((int)str - (int)STRING(0)) #else static inline int MAKE_STRING(const char *szValue) { long long ptrdiff = szValue - STRING(0); if( ptrdiff > INT_MAX || ptrdiff < INT_MIN ) - return ALLOC_STRING(szValue); + return ALLOC_STRING( szValue ); else return (int)ptrdiff; } diff --git a/dlls/weapons.h b/dlls/weapons.h index 6c03105b..0cfa2031 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -446,7 +446,7 @@ public: CBasePlayerItem *m_rgpPlayerItems[MAX_ITEM_TYPES];// one slot for each - int m_rgiszAmmo[MAX_AMMO_SLOTS];// ammo names + string_t m_rgiszAmmo[MAX_AMMO_SLOTS];// ammo names int m_rgAmmo[MAX_AMMO_SLOTS];// ammo quantities int m_cAmmoTypes;// how many ammo types packed into this box (if packed by a level designer) From 28020503292fb16cf30b6ccd639f5e6cb9cd4b46 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 21:05:13 +0500 Subject: [PATCH 143/199] Add missing break. --- dlls/hgrunt.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 4cb85c2c..62c947f1 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -959,6 +959,7 @@ void CHGrunt::HandleAnimEvent( MonsterEvent_t *pEvent ) } } + break; default: CSquadMonster::HandleAnimEvent( pEvent ); break; From 83c0505ffe12da025c207fcca1f9bd67b5291097 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 21:08:10 +0500 Subject: [PATCH 144/199] Add missing precache calls. --- dlls/effects.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 5b8d650c..2e127b2d 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -2181,6 +2181,8 @@ public: void CItemSoda::Precache( void ) { + PRECACHE_MODEL( "models/can.mdl" ); + PRECACHE_SOUND( "weapons/g_bounce.wav" ); } LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda ) From 41c9b072e5f871f6d4ce778a037cfa6ae38abcdb Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 10 Dec 2017 22:19:34 +0500 Subject: [PATCH 145/199] Add missing #include guards. --- cl_dll/ammohistory.h | 3 +++ cl_dll/health.h | 3 +++ cl_dll/hud_spectator.h | 4 ++-- cl_dll/parsemsg.h | 3 +++ dlls/gamerules.h | 4 +++- dlls/plane.h | 6 +++--- dlls/skill.h | 3 +++ dlls/spectator.h | 3 +++ dlls/squad.h | 4 +++- dlls/squadmonster.h | 3 +++ dlls/util.h | 3 +++ 11 files changed, 32 insertions(+), 7 deletions(-) diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index f1063ae1..032d3ee3 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -15,6 +15,8 @@ // // ammohistory.h // +#ifndef AMMOHISTORY_H +#define AMMOHISTORY_H // this is the max number of items in each bucket #define MAX_WEAPON_POSITIONS MAX_WEAPON_SLOTS @@ -137,3 +139,4 @@ public: }; extern HistoryResource gHR; +#endif // AMMOHISTORY_H diff --git a/cl_dll/health.h b/cl_dll/health.h index 132b9cb4..1007c17c 100644 --- a/cl_dll/health.h +++ b/cl_dll/health.h @@ -12,6 +12,8 @@ * without written permission from Valve LLC. * ****/ +#ifndef HEALTH_H +#define HEALTH_H #define DMG_IMAGE_LIFE 2 // seconds that image is up @@ -122,3 +124,4 @@ private: void CalcDamageDirection( vec3_t vecFrom ); void UpdateTiles( float fTime, long bits ); }; +#endif // HEALTH_H diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 58026668..9cfc5519 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -5,8 +5,8 @@ // $NoKeywords: $ //============================================================================= -#ifndef SPECTATOR_H -#define SPECTATOR_H +#ifndef HUD_SPECTATOR_H +#define HUD_SPECTATOR_H #pragma once #include "cl_entity.h" diff --git a/cl_dll/parsemsg.h b/cl_dll/parsemsg.h index 0e6bd2a3..6d552413 100644 --- a/cl_dll/parsemsg.h +++ b/cl_dll/parsemsg.h @@ -15,6 +15,8 @@ // // parsemsg.h // +#ifndef PARSEMSG_H +#define PARSEMSG_H #define ASSERT( x ) @@ -30,6 +32,7 @@ float READ_COORD( void ); float READ_ANGLE( void ); float READ_HIRESANGLE( void ); +#endif // PARSEMSG_H diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 6ad470d0..71036151 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -15,7 +15,8 @@ //========================================================= // GameRules //========================================================= - +#ifndef GAMERULES_H +#define GAMERULES_H //#include "weapons.h" //#include "items.h" class CBasePlayerItem; @@ -361,3 +362,4 @@ protected: }; extern DLL_GLOBAL CGameRules *g_pGameRules; +#endif // GAMERULES_H diff --git a/dlls/plane.h b/dlls/plane.h index 35a17611..912062f6 100644 --- a/dlls/plane.h +++ b/dlls/plane.h @@ -12,12 +12,12 @@ * without written permission from Valve LLC. * ****/ -#ifndef PLANE_H -#define PLANE_H - //========================================================= // Plane //========================================================= +#ifndef PLANE_H +#define PLANE_H + class CPlane { public: diff --git a/dlls/skill.h b/dlls/skill.h index 12b784e3..aa338362 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -15,6 +15,8 @@ //========================================================= // skill.h - skill level concerns //========================================================= +#ifndef SKILL_H +#define SKILL_H struct skilldata_t { @@ -143,3 +145,4 @@ extern DLL_GLOBAL int g_iSkillLevel; #define SKILL_EASY 1 #define SKILL_MEDIUM 2 #define SKILL_HARD 3 +#endif // SKILL_H diff --git a/dlls/spectator.h b/dlls/spectator.h index 90f8678f..00567fc6 100644 --- a/dlls/spectator.h +++ b/dlls/spectator.h @@ -13,6 +13,8 @@ * ****/ // Spectator.h +#ifndef SPECTATOR_H +#define SPECTATOR_H class CBaseSpectator : public CBaseEntity { @@ -25,3 +27,4 @@ public: private: void SpectatorImpulseCommand( void ); }; +#endif // SPECTATOR_H diff --git a/dlls/squad.h b/dlls/squad.h index bb2784bb..c29a7199 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -4,10 +4,11 @@ // // $NoKeywords: $ //============================================================================= - //========================================================= // squad.h //========================================================= +#ifndef SQUAD_H +#define SQUAD_H // these are special group roles that are assigned to members when the group is formed. // the reason these are explicitly assigned and tasks like throwing grenades to flush out @@ -19,3 +20,4 @@ #define bits_SQUAD_FLANK_RIGHT ( 1 << 1 ) #define bits_SQUAD_ADVANCE ( 1 << 2 ) #define bits_SQUAD_FLUSH_ATTACK ( 1 << 3 ) +#endif // SQUAD_H diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index 707910c2..132d4177 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -16,6 +16,8 @@ // CSquadMonster - all the extra data for monsters that // form squads. //========================================================= +#ifndef SQUADMONSTER_H +#define SQUADMONSTER_H #define SF_SQUADMONSTER_LEADER 32 @@ -116,3 +118,4 @@ public: MONSTERSTATE GetIdealState( void ); Schedule_t *GetScheduleOfType( int iType ); }; +#endif // SQUADMONSTER_H diff --git a/dlls/util.h b/dlls/util.h index ee7d116b..8f56cd76 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -12,6 +12,8 @@ * without written permission from Valve LLC. * ****/ +#ifndef UTIL_H +#define UTIL_H // // Misc utility code // @@ -575,3 +577,4 @@ int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); float UTIL_WeaponTimeBase( void ); +#endif // UTIL_H From f27d1028acf7ae1cf7494002e880d235177f2c52 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 11 Dec 2017 01:40:41 +0500 Subject: [PATCH 146/199] Do not reorganize variables in classes. Add missing #pragma once directives and more #include guards. --- cl_dll/GameStudioModelRenderer.h | 6 ++---- cl_dll/GameStudioModelRenderer_Sample.h | 6 ++---- cl_dll/StudioModelRenderer.h | 4 +--- cl_dll/ammo.h | 2 +- cl_dll/ammohistory.h | 1 + cl_dll/camera.h | 2 +- cl_dll/cl_dll.h | 1 + cl_dll/com_weapons.h | 4 +--- cl_dll/demo.h | 2 +- cl_dll/ev_hldm.h | 1 + cl_dll/eventscripts.h | 1 + cl_dll/health.h | 1 + cl_dll/hud.h | 1 + cl_dll/hud_iface.h | 2 +- cl_dll/hud_spectator.h | 2 +- cl_dll/in_defs.h | 2 +- cl_dll/input_mouse.h | 1 + cl_dll/kbutton.h | 3 +-- cl_dll/overview.h | 2 +- cl_dll/parsemsg.h | 1 + cl_dll/studio_util.h | 4 +--- cl_dll/util_vector.h | 4 ++++ common/beamdef.h | 4 ++-- common/bspfile.h | 2 +- common/cl_entity.h | 4 ++-- common/com_model.h | 4 ++-- common/con_nprint.h | 3 ++- common/const.h | 1 + common/cvardef.h | 1 + common/demo_api.h | 4 ++-- common/dlight.h | 4 ++-- common/entity_state.h | 3 ++- common/entity_types.h | 4 ++-- common/event_api.h | 4 ++-- common/event_args.h | 3 ++- common/event_flags.h | 4 ++-- common/gameinfo.h | 4 ++-- common/hltv.h | 4 ++-- common/ivoicetweak.h | 4 ++-- common/lightstyle.h | 4 ++-- common/mathlib.h | 5 ++++- common/net_api.h | 4 ++-- common/netadr.h | 4 ++-- common/particledef.h | 4 ++-- common/pmtrace.h | 4 ++-- common/qfont.h | 4 ++-- common/r_efx.h | 4 ++-- common/r_studioint.h | 5 ++--- common/ref_params.h | 4 ++-- common/render_api.h | 4 ++-- common/screenfade.h | 4 ++-- common/studio_event.h | 4 ++-- common/triangleapi.h | 2 +- common/usercmd.h | 4 ++-- common/wadfile.h | 4 ++-- common/weaponinfo.h | 4 ++-- common/wrect.h | 4 ++-- dlls/activity.h | 2 +- dlls/activitymap.h | 5 ++++- dlls/animation.h | 1 + dlls/basemonster.h | 2 +- dlls/cbase.h | 1 + dlls/cdll_dll.h | 2 +- dlls/client.h | 1 + dlls/decals.h | 1 + dlls/doors.h | 1 + dlls/effects.cpp | 4 ++-- dlls/effects.h | 1 + dlls/explode.h | 3 ++- dlls/exportdef.h | 1 + dlls/extdll.h | 1 + dlls/flyingmonster.h | 2 +- dlls/func_break.h | 5 +++-- dlls/func_tank.cpp | 6 +++--- dlls/game.h | 2 +- dlls/gamerules.h | 1 + dlls/hornet.h | 5 ++++- dlls/items.h | 1 + dlls/lights.cpp | 2 +- dlls/monsters.h | 1 + dlls/nodes.h | 1 + dlls/physcallback.h | 2 +- dlls/player.h | 1 + dlls/saverestore.h | 1 + dlls/schedule.h | 2 +- dlls/scripted.cpp | 2 +- dlls/scripted.h | 1 + dlls/scriptevent.h | 3 ++- dlls/skill.h | 3 ++- dlls/soundent.h | 4 ++++ dlls/spectator.h | 1 + dlls/squad.h | 1 + dlls/squadmonster.h | 1 + dlls/talkmonster.h | 1 + dlls/teamplay_gamerules.h | 4 ++++ dlls/trains.h | 1 + dlls/triggers.cpp | 6 +++--- dlls/util.h | 1 + dlls/vector.h | 1 + dlls/weapons.h | 1 + engine/cdll_exp.h | 3 ++- engine/cdll_int.h | 2 +- engine/custom.h | 3 +-- engine/customentity.h | 2 +- engine/edict.h | 4 +--- engine/eiface.h | 2 +- engine/keydefs.h | 4 ++-- engine/menu_int.h | 2 +- engine/physint.h | 4 ++-- engine/progdefs.h | 3 +-- engine/shake.h | 2 +- engine/sprite.h | 4 ++-- engine/studio.h | 2 +- pm_shared/pm_debug.h | 3 +-- pm_shared/pm_defs.h | 3 +-- pm_shared/pm_info.h | 3 +-- pm_shared/pm_materials.h | 1 + pm_shared/pm_movevars.h | 1 + pm_shared/pm_shared.h | 4 +--- 119 files changed, 183 insertions(+), 140 deletions(-) diff --git a/cl_dll/GameStudioModelRenderer.h b/cl_dll/GameStudioModelRenderer.h index 7d06f70f..881dd144 100644 --- a/cl_dll/GameStudioModelRenderer.h +++ b/cl_dll/GameStudioModelRenderer.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( GAMESTUDIOMODELRENDERER_H ) #define GAMESTUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== @@ -23,4 +21,4 @@ public: CGameStudioModelRenderer( void ); }; -#endif // GAMESTUDIOMODELRENDERER_H \ No newline at end of file +#endif // GAMESTUDIOMODELRENDERER_H diff --git a/cl_dll/GameStudioModelRenderer_Sample.h b/cl_dll/GameStudioModelRenderer_Sample.h index c924ba3e..9c09374b 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.h +++ b/cl_dll/GameStudioModelRenderer_Sample.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( GAMESTUDIOMODELRENDERER_H ) #define GAMESTUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== @@ -52,4 +50,4 @@ private: bool m_bLocal; }; -#endif // GAMESTUDIOMODELRENDERER_H \ No newline at end of file +#endif // GAMESTUDIOMODELRENDERER_H diff --git a/cl_dll/StudioModelRenderer.h b/cl_dll/StudioModelRenderer.h index 0a56b731..cbfd0d3b 100644 --- a/cl_dll/StudioModelRenderer.h +++ b/cl_dll/StudioModelRenderer.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined ( STUDIOMODELRENDERER_H ) #define STUDIOMODELRENDERER_H -#if defined( _WIN32 ) -#pragma once -#endif /* ==================== diff --git a/cl_dll/ammo.h b/cl_dll/ammo.h index 9134681c..57c08805 100644 --- a/cl_dll/ammo.h +++ b/cl_dll/ammo.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef __AMMO_H__ #define __AMMO_H__ diff --git a/cl_dll/ammohistory.h b/cl_dll/ammohistory.h index 032d3ee3..44edc916 100644 --- a/cl_dll/ammohistory.h +++ b/cl_dll/ammohistory.h @@ -15,6 +15,7 @@ // // ammohistory.h // +#pragma once #ifndef AMMOHISTORY_H #define AMMOHISTORY_H diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 448b22ca..69a00216 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -7,7 +7,7 @@ // Camera.h -- defines and such for a 3rd person camera // NOTE: must include quakedef.h first - +#pragma once #ifndef _CAMERA_H_ #define _CAMERA_H_ diff --git a/cl_dll/cl_dll.h b/cl_dll/cl_dll.h index 0acd6860..6e1c4e69 100644 --- a/cl_dll/cl_dll.h +++ b/cl_dll/cl_dll.h @@ -25,6 +25,7 @@ // - Drawing the HUD graphics every frame // - Handling the custum HUD-update packets // +#pragma once #ifndef CL_DLL_H #define CL_DLL_H typedef unsigned char byte; diff --git a/cl_dll/com_weapons.h b/cl_dll/com_weapons.h index d252c196..efe06ad6 100644 --- a/cl_dll/com_weapons.h +++ b/cl_dll/com_weapons.h @@ -7,11 +7,9 @@ // com_weapons.h // Shared weapons common function prototypes +#pragma once #if !defined( COM_WEAPONSH ) #define COM_WEAPONSH -#ifdef _WIN32 -#pragma once -#endif #include "hud_iface.h" diff --git a/cl_dll/demo.h b/cl_dll/demo.h index a0a1b30e..b7dbaff0 100644 --- a/cl_dll/demo.h +++ b/cl_dll/demo.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( DEMOH ) #define DEMOH -#pragma once // Types of demo messages we can write/parse enum diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index bff43b1e..88b221df 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -5,6 +5,7 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined ( EV_HLDMH ) #define EV_HLDMH diff --git a/cl_dll/eventscripts.h b/cl_dll/eventscripts.h index bb835474..c11ee338 100644 --- a/cl_dll/eventscripts.h +++ b/cl_dll/eventscripts.h @@ -6,6 +6,7 @@ //============================================================================= // eventscripts.h +#pragma once #if !defined ( EVENTSCRIPTSH ) #define EVENTSCRIPTSH diff --git a/cl_dll/health.h b/cl_dll/health.h index 1007c17c..62d7e0bc 100644 --- a/cl_dll/health.h +++ b/cl_dll/health.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef HEALTH_H #define HEALTH_H diff --git a/cl_dll/hud.h b/cl_dll/hud.h index 1970753d..decfa917 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -19,6 +19,7 @@ // // CHud handles the message, calculation, and drawing the HUD // +#pragma once #ifndef HUD_H #define HUD_H #define RGB_YELLOWISH 0x00FFA000 //255,160,0 diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index a7a05e7e..7993bd9d 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( HUD_IFACEH ) #define HUD_IFACEH -#pragma once #include "exportdef.h" diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 9cfc5519..7a9ec9d3 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #ifndef HUD_SPECTATOR_H #define HUD_SPECTATOR_H -#pragma once #include "cl_entity.h" diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index 037c7cc6..d5c352fa 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( IN_DEFSH ) #define IN_DEFSH -#pragma once // up / down #define PITCH 0 diff --git a/cl_dll/input_mouse.h b/cl_dll/input_mouse.h index 6ddf54db..cf0102c8 100644 --- a/cl_dll/input_mouse.h +++ b/cl_dll/input_mouse.h @@ -1,3 +1,4 @@ +#pragma once #ifndef INPUT_MOUSE_H #define INPUT_MOUSE_H #include "cl_dll.h" diff --git a/cl_dll/kbutton.h b/cl_dll/kbutton.h index 29accdf5..54f1ea93 100644 --- a/cl_dll/kbutton.h +++ b/cl_dll/kbutton.h @@ -4,10 +4,9 @@ // // $NoKeywords: $ //============================================================================= - +#pragma once #if !defined( KBUTTONH ) #define KBUTTONH -#pragma once typedef struct kbutton_s { diff --git a/cl_dll/overview.h b/cl_dll/overview.h index 6748760b..59535fb4 100644 --- a/cl_dll/overview.h +++ b/cl_dll/overview.h @@ -5,9 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #ifndef OVERVIEW_H #define OVERVIEW_H -#pragma once //----------------------------------------------------------------------------- // Purpose: Handles the drawing of the top-down map and all the things on it diff --git a/cl_dll/parsemsg.h b/cl_dll/parsemsg.h index 6d552413..05efefc3 100644 --- a/cl_dll/parsemsg.h +++ b/cl_dll/parsemsg.h @@ -15,6 +15,7 @@ // // parsemsg.h // +#pragma once #ifndef PARSEMSG_H #define PARSEMSG_H diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index 963dcda7..7af94672 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -5,11 +5,9 @@ // $NoKeywords: $ //============================================================================= +#pragma once #if !defined( STUDIO_UTIL_H ) #define STUDIO_UTIL_H -#if defined( WIN32 ) -#pragma once -#endif #ifndef M_PI #define M_PI 3.14159265358979323846 // matches value in gcc v2 math.h diff --git a/cl_dll/util_vector.h b/cl_dll/util_vector.h index 8b596ac1..477d97be 100644 --- a/cl_dll/util_vector.h +++ b/cl_dll/util_vector.h @@ -15,6 +15,9 @@ // Vector.h // A subset of the extdll.h in the project HL Entity DLL // +#pragma once +#ifndef UTIL_VECTOR_H +#define UTIL_VECTOR_H // Misc C-runtime library headers #include "stdio.h" @@ -124,3 +127,4 @@ inline float DotProduct( const Vector& a, const Vector& b) { return( a.x * b.x + inline Vector CrossProduct(const Vector& a, const Vector& b) { return Vector( a.y * b.z - a.z * b.y, a.z * b.x - a.x * b.z, a.x * b.y - a.y * b.x ); } #define vec3_t Vector +#endif // UTIL_VECTOR_H diff --git a/common/beamdef.h b/common/beamdef.h index 3b8c553a..f254428c 100644 --- a/common/beamdef.h +++ b/common/beamdef.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef BEAMDEF_H #define BEAMDEF_H @@ -57,4 +57,4 @@ struct beam_s struct particle_s *particles; }; -#endif//BEAMDEF_H \ No newline at end of file +#endif//BEAMDEF_H diff --git a/common/bspfile.h b/common/bspfile.h index 809e2fd0..079e1b21 100644 --- a/common/bspfile.h +++ b/common/bspfile.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef BSPFILE_H #define BSPFILE_H diff --git a/common/cl_entity.h b/common/cl_entity.h index 02f84e35..c003ce30 100644 --- a/common/cl_entity.h +++ b/common/cl_entity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef CL_ENTITY_H #define CL_ENTITY_H @@ -102,4 +102,4 @@ struct cl_entity_s colorVec cvFloorColor; }; -#endif//CL_ENTITY_H \ No newline at end of file +#endif//CL_ENTITY_H diff --git a/common/com_model.h b/common/com_model.h index 709f23d9..abc8e8e6 100644 --- a/common/com_model.h +++ b/common/com_model.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef COM_MODEL_H #define COM_MODEL_H @@ -410,4 +410,4 @@ typedef struct mspriteframedesc_t frames[1]; } msprite_t; -#endif//COM_MODEL_H \ No newline at end of file +#endif//COM_MODEL_H diff --git a/common/con_nprint.h b/common/con_nprint.h index 5d87c760..615a1850 100644 --- a/common/con_nprint.h +++ b/common/con_nprint.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CON_NPRINT_H #define CON_NPRINT_H @@ -22,4 +23,4 @@ typedef struct con_nprint_s float color[3]; // RGB colors ( 0.0 -> 1.0 scale ) } con_nprint_t; -#endif//CON_NPRINT_H \ No newline at end of file +#endif//CON_NPRINT_H diff --git a/common/const.h b/common/const.h index 3d738675..fa0f33e6 100644 --- a/common/const.h +++ b/common/const.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CONST_H #define CONST_H // diff --git a/common/cvardef.h b/common/cvardef.h index e8a24581..f461c329 100644 --- a/common/cvardef.h +++ b/common/cvardef.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CVARDEF_H #define CVARDEF_H diff --git a/common/demo_api.h b/common/demo_api.h index fa89bbef..1a678b60 100644 --- a/common/demo_api.h +++ b/common/demo_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef DEMO_API_H #define DEMO_API_H @@ -24,4 +24,4 @@ typedef struct demo_api_s void (*WriteBuffer)( int size, unsigned char *buffer ); } demo_api_t; -#endif//DEMO_API_H \ No newline at end of file +#endif//DEMO_API_H diff --git a/common/dlight.h b/common/dlight.h index b139d582..ecb01445 100644 --- a/common/dlight.h +++ b/common/dlight.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef DLIGHT_H #define DLIGHT_H @@ -28,4 +28,4 @@ typedef struct dlight_s qboolean dark; // subtracts light instead of adding } dlight_t; -#endif//DLIGHT_H \ No newline at end of file +#endif//DLIGHT_H diff --git a/common/entity_state.h b/common/entity_state.h index ef5448f1..2ffd70dc 100644 --- a/common/entity_state.h +++ b/common/entity_state.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ENTITY_STATE_H #define ENTITY_STATE_H @@ -183,4 +184,4 @@ typedef struct local_state_s weapon_data_t weapondata[64]; } local_state_t; -#endif//ENTITY_STATE_H \ No newline at end of file +#endif//ENTITY_STATE_H diff --git a/common/entity_types.h b/common/entity_types.h index 25a8fce9..f5754fea 100644 --- a/common/entity_types.h +++ b/common/entity_types.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef ENTITY_TYPES_H #define ENTITY_TYPES_H @@ -22,4 +22,4 @@ #define ET_BEAM 3 #define ET_FRAGMENTED 4 // BMODEL or SPRITE that was split across BSP nodes -#endif//ENTITY_TYPES_H \ No newline at end of file +#endif//ENTITY_TYPES_H diff --git a/common/event_api.h b/common/event_api.h index a7ff71b2..86c5fbe9 100644 --- a/common/event_api.h +++ b/common/event_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EVENT_API_H #define EVENT_API_H @@ -51,4 +51,4 @@ typedef struct event_api_s struct msurface_s *( *EV_TraceSurface )( int ground, float *vstart, float *vend ); } event_api_t; -#endif//EVENT_API_H \ No newline at end of file +#endif//EVENT_API_H diff --git a/common/event_args.h b/common/event_args.h index d85906cc..4cf63741 100644 --- a/common/event_args.h +++ b/common/event_args.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EVENT_ARGS_H #define EVENT_ARGS_H @@ -44,4 +45,4 @@ typedef struct event_args_s int bparam2; } event_args_t; -#endif//EVENT_ARGS_H \ No newline at end of file +#endif//EVENT_ARGS_H diff --git a/common/event_flags.h b/common/event_flags.h index 3c1d8fb3..a2d5f3b7 100644 --- a/common/event_flags.h +++ b/common/event_flags.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EVENT_FLAGS_H #define EVENT_FLAGS_H @@ -42,4 +42,4 @@ // Only issue event client side ( from shared code ) #define FEV_CLIENT (1<<6) -#endif//EVENT_FLAGS_H \ No newline at end of file +#endif//EVENT_FLAGS_H diff --git a/common/gameinfo.h b/common/gameinfo.h index 511b3718..ab5f649c 100644 --- a/common/gameinfo.h +++ b/common/gameinfo.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef GAMEINFO_H #define GAMEINFO_H @@ -46,4 +46,4 @@ typedef struct int gamemode; } GAMEINFO; -#endif//GAMEINFO_H \ No newline at end of file +#endif//GAMEINFO_H diff --git a/common/hltv.h b/common/hltv.h index 79251910..e64dd30b 100644 --- a/common/hltv.h +++ b/common/hltv.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef HLTV_H #define HLTV_H @@ -56,4 +56,4 @@ #define MAX_DIRECTOR_CMD_PARAMETERS 4 #define MAX_DIRECTOR_CMD_STRING 128 -#endif//HLTV_H \ No newline at end of file +#endif//HLTV_H diff --git a/common/ivoicetweak.h b/common/ivoicetweak.h index 541a63fa..96879beb 100644 --- a/common/ivoicetweak.h +++ b/common/ivoicetweak.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef IVOICETWEAK_H #define IVOICETWEAK_H @@ -37,4 +37,4 @@ typedef struct IVoiceTweak_s int (*GetSpeakingVolume)( void ); } IVoiceTweak; -#endif//IVOICETWEAK_H \ No newline at end of file +#endif//IVOICETWEAK_H diff --git a/common/lightstyle.h b/common/lightstyle.h index 8b42edac..a12702f4 100644 --- a/common/lightstyle.h +++ b/common/lightstyle.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef LIGHTSTYLE_H #define LIGHTSTYLE_H @@ -26,4 +26,4 @@ typedef struct float time; // local time is gurantee what new style begins from the start, not mid or end of the sequence } lightstyle_t; -#endif//LIGHTSTYLE_H \ No newline at end of file +#endif//LIGHTSTYLE_H diff --git a/common/mathlib.h b/common/mathlib.h index 12fb972f..6bcf76eb 100644 --- a/common/mathlib.h +++ b/common/mathlib.h @@ -13,7 +13,9 @@ * ****/ // mathlib.h - +#pragma once +#ifndef MATHLIB_H +#define MATHLIB_H #include typedef float vec_t; @@ -98,3 +100,4 @@ float anglemod(float a); ) \ : \ BoxOnPlaneSide( (emins), (emaxs), (p))) +#endif // MATHLIB_H diff --git a/common/net_api.h b/common/net_api.h index 00831394..da18fc30 100644 --- a/common/net_api.h +++ b/common/net_api.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef NET_API_H #define NET_API_H @@ -94,4 +94,4 @@ typedef struct net_api_s void (*SetValueForKey)( char *s, const char *key, const char *value, int maxsize ); } net_api_t; -#endif//NET_APIH \ No newline at end of file +#endif // NET_APIH diff --git a/common/netadr.h b/common/netadr.h index dfeea8b0..0d70a22b 100644 --- a/common/netadr.h +++ b/common/netadr.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef NETADR_H #define NETADR_H @@ -34,4 +34,4 @@ typedef struct netadr_s unsigned short port; } netadr_t; -#endif//NETADR_H \ No newline at end of file +#endif//NETADR_H diff --git a/common/particledef.h b/common/particledef.h index 3f2ead66..15c95feb 100644 --- a/common/particledef.h +++ b/common/particledef.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PARTICLEDEF_H #define PARTICLEDEF_H @@ -51,4 +51,4 @@ typedef struct particle_s unsigned char context; } particle_t; -#endif//PARTICLEDEF_H \ No newline at end of file +#endif//PARTICLEDEF_H diff --git a/common/pmtrace.h b/common/pmtrace.h index 6394de56..d5dd1453 100644 --- a/common/pmtrace.h +++ b/common/pmtrace.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PM_TRACE_H #define PM_TRACE_H @@ -38,4 +38,4 @@ struct pmtrace_s int hitgroup; }; -#endif//PM_TRACE_H \ No newline at end of file +#endif//PM_TRACE_H diff --git a/common/qfont.h b/common/qfont.h index 06408572..beb36ff9 100644 --- a/common/qfont.h +++ b/common/qfont.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef QFONT_H #define QFONT_H @@ -35,4 +35,4 @@ typedef struct qfont_s byte data[4]; } qfont_t; -#endif//QFONT_H \ No newline at end of file +#endif//QFONT_H diff --git a/common/r_efx.h b/common/r_efx.h index fc27bef7..1a55aa0b 100644 --- a/common/r_efx.h +++ b/common/r_efx.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef R_EFX_H #define R_EFX_H @@ -192,4 +192,4 @@ struct efx_api_s void (*R_FireCustomDecal)( int textureIndex, int entity, int modelIndex, float *position, int flags, float scale ); }; -#endif//R_EFX_H \ No newline at end of file +#endif//R_EFX_H diff --git a/common/r_studioint.h b/common/r_studioint.h index 00384a16..b17e826f 100644 --- a/common/r_studioint.h +++ b/common/r_studioint.h @@ -12,8 +12,7 @@ * without written permission from Valve LLC. * ****/ - - +#pragma once #ifndef R_STUDIOINT_H #define R_STUDIOINT_H @@ -151,4 +150,4 @@ typedef struct sv_blending_interface_s const edict_t *pEdict ); } sv_blending_interface_t; -#endif//R_STUDIOINT_H \ No newline at end of file +#endif//R_STUDIOINT_H diff --git a/common/ref_params.h b/common/ref_params.h index 0458c4f4..61527eca 100644 --- a/common/ref_params.h +++ b/common/ref_params.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef REF_PARAMS_H #define REF_PARAMS_H @@ -87,4 +87,4 @@ typedef struct ref_overview_s float flZoom; } ref_overview_t; -#endif//REF_PARAMS_H \ No newline at end of file +#endif//REF_PARAMS_H diff --git a/common/render_api.h b/common/render_api.h index 7a9fcffe..03973f27 100644 --- a/common/render_api.h +++ b/common/render_api.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef RENDER_API_H #define RENDER_API_H @@ -258,4 +258,4 @@ typedef struct render_interface_s void (*Mod_ProcessUserData)( struct model_s *mod, qboolean create, const byte *buffer ); } render_interface_t; -#endif//RENDER_API_H \ No newline at end of file +#endif//RENDER_API_H diff --git a/common/screenfade.h b/common/screenfade.h index 730f729e..1611f914 100644 --- a/common/screenfade.h +++ b/common/screenfade.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SCREENFADE_H #define SCREENFADE_H @@ -26,4 +26,4 @@ typedef struct screenfade_s int fadeFlags; // Fading flags } screenfade_t; -#endif//SCREENFADE_H \ No newline at end of file +#endif//SCREENFADE_H diff --git a/common/studio_event.h b/common/studio_event.h index 29ea1f90..cf21e82a 100644 --- a/common/studio_event.h +++ b/common/studio_event.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef STUDIO_EVENT_H #define STUDIO_EVENT_H @@ -24,4 +24,4 @@ typedef struct mstudioevent_s char options[64]; } mstudioevent_t; -#endif//STUDIO_EVENT_H \ No newline at end of file +#endif//STUDIO_EVENT_H diff --git a/common/triangleapi.h b/common/triangleapi.h index f2e9a309..49dc919f 100644 --- a/common/triangleapi.h +++ b/common/triangleapi.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef TRIANGLEAPI_H #define TRIANGLEAPI_H diff --git a/common/usercmd.h b/common/usercmd.h index 96e3c91b..538c60a6 100644 --- a/common/usercmd.h +++ b/common/usercmd.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef USERCMD_H #define USERCMD_H @@ -36,4 +36,4 @@ typedef struct usercmd_s vec3_t impact_position; } usercmd_t; -#endif//USERCMD_H \ No newline at end of file +#endif//USERCMD_H diff --git a/common/wadfile.h b/common/wadfile.h index 38a08032..84ffbb2d 100644 --- a/common/wadfile.h +++ b/common/wadfile.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef WADFILE_H #define WADFILE_H @@ -76,4 +76,4 @@ typedef struct mip_s unsigned int offsets[4]; // four mip maps stored } mip_t; -#endif//WADFILE_H \ No newline at end of file +#endif//WADFILE_H diff --git a/common/weaponinfo.h b/common/weaponinfo.h index ae78c645..b94857b6 100644 --- a/common/weaponinfo.h +++ b/common/weaponinfo.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef WEAPONINFO_H #define WEAPONINFO_H @@ -47,4 +47,4 @@ typedef struct weapon_data_s float fuser4; } weapon_data_t; -#endif//WEAPONINFO_H \ No newline at end of file +#endif//WEAPONINFO_H diff --git a/common/wrect.h b/common/wrect.h index 8dd2ba2f..51e84d88 100644 --- a/common/wrect.h +++ b/common/wrect.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef WRECT_H #define WRECT_H @@ -21,4 +21,4 @@ typedef struct wrect_s int left, right, top, bottom; } wrect_t; -#endif//WRECT_H \ No newline at end of file +#endif//WRECT_H diff --git a/dlls/activity.h b/dlls/activity.h index 5382d70d..90d85a08 100644 --- a/dlls/activity.h +++ b/dlls/activity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef ACTIVITY_H #define ACTIVITY_H diff --git a/dlls/activitymap.h b/dlls/activitymap.h index 5f77c55a..b5f789f9 100644 --- a/dlls/activitymap.h +++ b/dlls/activitymap.h @@ -12,7 +12,9 @@ * without written permission from Valve LLC. * ****/ - +#pragma once +#ifndef ACTIVITYMAP_H +#define ACTIVITYMAP_H #define _A( a ) { a, #a } activity_map_t activity_map[] = @@ -95,3 +97,4 @@ _A( ACT_FLINCH_LEFTLEG ), _A( ACT_FLINCH_RIGHTLEG ), { 0, NULL } }; +#endif // ACTIVITYMAP_H diff --git a/dlls/animation.h b/dlls/animation.h index 384c1e98..6def910c 100644 --- a/dlls/animation.h +++ b/dlls/animation.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ANIMATION_H #define ANIMATION_H diff --git a/dlls/basemonster.h b/dlls/basemonster.h index 0d22104f..2234aaf9 100644 --- a/dlls/basemonster.h +++ b/dlls/basemonster.h @@ -12,7 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ - +#pragma once #ifndef BASEMONSTER_H #define BASEMONSTER_H diff --git a/dlls/cbase.h b/dlls/cbase.h index 10f7a85f..4cf40abd 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CBASE_H #define CBASE_H /* diff --git a/dlls/cdll_dll.h b/dlls/cdll_dll.h index c960a6ac..0aafafbd 100644 --- a/dlls/cdll_dll.h +++ b/dlls/cdll_dll.h @@ -16,7 +16,7 @@ // cdll_dll.h // this file is included by both the game-dll and the client-dll, - +#pragma once #ifndef CDLL_DLL_H #define CDLL_DLL_H diff --git a/dlls/client.h b/dlls/client.h index 6728151b..6feaac1a 100644 --- a/dlls/client.h +++ b/dlls/client.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CLIENT_H #define CLIENT_H diff --git a/dlls/decals.h b/dlls/decals.h index 97f5f29f..5de54421 100644 --- a/dlls/decals.h +++ b/dlls/decals.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef DECALS_H #define DECALS_H diff --git a/dlls/doors.h b/dlls/doors.h index 7e89b497..fe2b5a85 100644 --- a/dlls/doors.h +++ b/dlls/doors.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef DOORS_H #define DOORS_H diff --git a/dlls/effects.cpp b/dlls/effects.cpp index 2e127b2d..bd9959f9 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -379,10 +379,9 @@ public: void BeamUpdateVars( void ); + int m_active; string_t m_iszStartEntity; string_t m_iszEndEntity; - string_t m_iszSpriteName; - int m_active; float m_life; int m_boltWidth; int m_noiseAmplitude; @@ -390,6 +389,7 @@ public: int m_speed; float m_restrike; int m_spriteTexture; + string_t m_iszSpriteName; int m_frameStart; float m_radius; diff --git a/dlls/effects.h b/dlls/effects.h index f4b6b5b2..5dd55209 100644 --- a/dlls/effects.h +++ b/dlls/effects.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EFFECTS_H #define EFFECTS_H diff --git a/dlls/explode.h b/dlls/explode.h index e1c6cce0..001d93ca 100644 --- a/dlls/explode.h +++ b/dlls/explode.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EXPLODE_H #define EXPLODE_H @@ -26,4 +27,4 @@ extern DLL_GLOBAL short g_sModelIndexFireball; extern DLL_GLOBAL short g_sModelIndexSmoke; extern void ExplosionCreate( const Vector ¢er, const Vector &angles, edict_t *pOwner, int magnitude, BOOL doDamage ); -#endif //EXPLODE_H +#endif // EXPLODE_H diff --git a/dlls/exportdef.h b/dlls/exportdef.h index 995613ff..363d8d12 100644 --- a/dlls/exportdef.h +++ b/dlls/exportdef.h @@ -1,3 +1,4 @@ +#pragma once #ifndef EXPORTDEF_H #define EXPORTDEF_H #if defined _WIN32 || defined __CYGWIN__ diff --git a/dlls/extdll.h b/dlls/extdll.h index 812ce40f..d6ea4888 100644 --- a/dlls/extdll.h +++ b/dlls/extdll.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef EXTDLL_H #define EXTDLL_H diff --git a/dlls/flyingmonster.h b/dlls/flyingmonster.h index 4dd87fb4..31ff4e33 100644 --- a/dlls/flyingmonster.h +++ b/dlls/flyingmonster.h @@ -13,7 +13,7 @@ * ****/ // Base class for flying monsters. This overrides the movement test & execution code from CBaseMonster - +#pragma once #ifndef FLYINGMONSTER_H #define FLYINGMONSTER_H diff --git a/dlls/func_break.h b/dlls/func_break.h index b4ff1fc1..89c9f54e 100644 --- a/dlls/func_break.h +++ b/dlls/func_break.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef FUNC_BREAK_H #define FUNC_BREAK_H @@ -82,9 +83,9 @@ public: Materials m_Material; Explosions m_Explosion; - string_t m_iszGibModel; - string_t m_iszSpawnObject; int m_idShard; float m_angle; + string_t m_iszGibModel; + string_t m_iszSpawnObject; }; #endif // FUNC_BREAK_H diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index 013948eb..a3dba841 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -97,9 +97,6 @@ public: protected: CBasePlayer* m_pController; - string_t m_iszSpriteSmoke; - string_t m_iszSpriteFlash; - string_t m_iszMaster; // Master entity (game_team_master or multisource) float m_flNextAttack; Vector m_vecControllerUsePos; @@ -123,11 +120,14 @@ protected: Vector m_barrelPos; // Length of the freakin barrel float m_spriteScale; // Scale of any sprites we shoot + string_t m_iszSpriteSmoke; + string_t m_iszSpriteFlash; TANKBULLET m_bulletType; // Bullet type int m_iBulletDamage; // 0 means use Bullet type's default damage Vector m_sightOrigin; // Last sight of target int m_spread; // firing spread + string_t m_iszMaster; // Master entity (game_team_master or multisource) }; TYPEDESCRIPTION CFuncTank::m_SaveData[] = diff --git a/dlls/game.h b/dlls/game.h index a6d0cd1c..0dc5ba87 100644 --- a/dlls/game.h +++ b/dlls/game.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef GAME_H #define GAME_H diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 71036151..04c6eea5 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -15,6 +15,7 @@ //========================================================= // GameRules //========================================================= +#pragma once #ifndef GAMERULES_H #define GAMERULES_H //#include "weapons.h" diff --git a/dlls/hornet.h b/dlls/hornet.h index dc78fc40..f0f0d366 100644 --- a/dlls/hornet.h +++ b/dlls/hornet.h @@ -15,7 +15,9 @@ //========================================================= // Hornets //========================================================= - +#pragma once +#ifndef HORNET_H +#define HORNET_H //========================================================= // Hornet Defines //========================================================= @@ -55,3 +57,4 @@ public: int m_iHornetType; float m_flFlySpeed; }; +#endif // HORNET_H diff --git a/dlls/items.h b/dlls/items.h index 2c31f801..060678c8 100644 --- a/dlls/items.h +++ b/dlls/items.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef ITEMS_H #define ITEMS_H diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 8a4f8de8..1c39266b 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -37,8 +37,8 @@ public: static TYPEDESCRIPTION m_SaveData[]; private: - string_t m_iszPattern; int m_iStyle; + string_t m_iszPattern; }; LINK_ENTITY_TO_CLASS( light, CLight ) diff --git a/dlls/monsters.h b/dlls/monsters.h index 6f2df294..4aeca3a9 100644 --- a/dlls/monsters.h +++ b/dlls/monsters.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef MONSTERS_H #include "skill.h" #define MONSTERS_H diff --git a/dlls/nodes.h b/dlls/nodes.h index 49036a39..52b715e5 100644 --- a/dlls/nodes.h +++ b/dlls/nodes.h @@ -15,6 +15,7 @@ //========================================================= // nodes.h //========================================================= +#pragma once #ifndef NODES_H #define NODES_H //========================================================= diff --git a/dlls/physcallback.h b/dlls/physcallback.h index 1db276e0..fd68936c 100644 --- a/dlls/physcallback.h +++ b/dlls/physcallback.h @@ -12,9 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PHYSCALLBACK_H #define PHYSCALLBACK_H -#pragma once #include "physint.h" diff --git a/dlls/player.h b/dlls/player.h index fecaf3c9..6fc06dbb 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PLAYER_H #define PLAYER_H diff --git a/dlls/saverestore.h b/dlls/saverestore.h index 4295871d..81f9f131 100644 --- a/dlls/saverestore.h +++ b/dlls/saverestore.h @@ -13,6 +13,7 @@ * ****/ // Implementation in UTIL.CPP +#pragma once #ifndef SAVERESTORE_H #define SAVERESTORE_H diff --git a/dlls/schedule.h b/dlls/schedule.h index 0c4fb1ce..6414ff15 100644 --- a/dlls/schedule.h +++ b/dlls/schedule.h @@ -15,7 +15,7 @@ //========================================================= // Scheduling //========================================================= - +#pragma once #ifndef SCHEDULE_H #define SCHEDULE_H diff --git a/dlls/scripted.cpp b/dlls/scripted.cpp index 92b9aa6a..41638b39 100644 --- a/dlls/scripted.cpp +++ b/dlls/scripted.cpp @@ -909,13 +909,13 @@ public: private: string_t m_iszSentence; // string index for idle animation string_t m_iszEntity; // entity that is wanted for this sentence - string_t m_iszListener; // name of entity to look at while talking float m_flRadius; // range to search float m_flDuration; // How long the sentence lasts float m_flRepeat; // repeat rate float m_flAttenuation; float m_flVolume; BOOL m_active; + string_t m_iszListener; // name of entity to look at while talking }; #define SF_SENTENCE_ONCE 0x0001 diff --git a/dlls/scripted.h b/dlls/scripted.h index 6cf8cfa1..59b696f7 100644 --- a/dlls/scripted.h +++ b/dlls/scripted.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef SCRIPTED_H #define SCRIPTED_H diff --git a/dlls/scriptevent.h b/dlls/scriptevent.h index 714ac99c..18436a26 100644 --- a/dlls/scriptevent.h +++ b/dlls/scriptevent.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef SCRIPTEVENT_H #define SCRIPTEVENT_H @@ -26,4 +27,4 @@ #define SCRIPT_EVENT_SOUND_VOICE 1008 // Play named wave file (on CHAN_VOICE) #define SCRIPT_EVENT_SENTENCE_RND1 1009 // Play sentence group 25% of the time #define SCRIPT_EVENT_NOT_DEAD 1010 // Bring back to life (for life/death sequences) -#endif //SCRIPTEVENT_H +#endif // SCRIPTEVENT_H diff --git a/dlls/skill.h b/dlls/skill.h index aa338362..5244c923 100644 --- a/dlls/skill.h +++ b/dlls/skill.h @@ -15,6 +15,7 @@ //========================================================= // skill.h - skill level concerns //========================================================= +#pragma once #ifndef SKILL_H #define SKILL_H @@ -23,7 +24,7 @@ struct skilldata_t int iSkillLevel; // game skill level // Monster Health & Damage - float agruntHealth; + float agruntHealth; float agruntDmgPunch; float apacheHealth; diff --git a/dlls/soundent.h b/dlls/soundent.h index 6c39a6c0..88def506 100644 --- a/dlls/soundent.h +++ b/dlls/soundent.h @@ -17,6 +17,9 @@ // spawns, and handles the world's active and free sound // lists. //========================================================= +#pragma once +#ifndef SOUNDENT_H +#define SOUNDENT_H #define MAX_WORLD_SOUNDS 64 // maximum number of sounds handled by the world at one time. @@ -91,3 +94,4 @@ public: private: CSound m_SoundPool[ MAX_WORLD_SOUNDS ]; }; +#endif // SOUNDENT_H diff --git a/dlls/spectator.h b/dlls/spectator.h index 00567fc6..c4e895c0 100644 --- a/dlls/spectator.h +++ b/dlls/spectator.h @@ -13,6 +13,7 @@ * ****/ // Spectator.h +#pragma once #ifndef SPECTATOR_H #define SPECTATOR_H diff --git a/dlls/squad.h b/dlls/squad.h index c29a7199..f8f20aa0 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -7,6 +7,7 @@ //========================================================= // squad.h //========================================================= +#pragma once #ifndef SQUAD_H #define SQUAD_H diff --git a/dlls/squadmonster.h b/dlls/squadmonster.h index 132d4177..e2c8a5b9 100644 --- a/dlls/squadmonster.h +++ b/dlls/squadmonster.h @@ -16,6 +16,7 @@ // CSquadMonster - all the extra data for monsters that // form squads. //========================================================= +#pragma once #ifndef SQUADMONSTER_H #define SQUADMONSTER_H diff --git a/dlls/talkmonster.h b/dlls/talkmonster.h index 084861bc..36ac21a6 100644 --- a/dlls/talkmonster.h +++ b/dlls/talkmonster.h @@ -12,6 +12,7 @@ * use or distribution of this code by or to any unlicensed person is illegal. * ****/ +#pragma once #ifndef TALKMONSTER_H #define TALKMONSTER_H diff --git a/dlls/teamplay_gamerules.h b/dlls/teamplay_gamerules.h index 06823ca6..12ed038f 100644 --- a/dlls/teamplay_gamerules.h +++ b/dlls/teamplay_gamerules.h @@ -15,6 +15,9 @@ // // teamplay_gamerules.h // +#pragma once +#ifndef TEAMPLAY_GAMERULES_H +#define TEAMPLAY_GAMERULES_H #define MAX_TEAMNAME_LENGTH 16 #define MAX_TEAMS 32 @@ -55,3 +58,4 @@ private: BOOL m_teamLimit; // This means the server set only some teams as valid char m_szTeamList[TEAMPLAY_TEAMLISTLENGTH]; }; +#endif // TEAMPLAY_GAMERULES_H diff --git a/dlls/trains.h b/dlls/trains.h index e8003b3e..f740e2ea 100644 --- a/dlls/trains.h +++ b/dlls/trains.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef TRAINS_H #define TRAINS_H diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 7d7f255c..6d8fef04 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -267,11 +267,11 @@ public: static TYPEDESCRIPTION m_SaveData[]; - string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array - float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire int m_cTargets; // the total number of targets in this manager's fire list. int m_index; // Current target float m_startTime;// Time we started firing + string_t m_iTargetName[MAX_MULTI_TARGETS];// list if indexes into global string array + float m_flTargetDelay[MAX_MULTI_TARGETS];// delay (in seconds) from time of manager fire to target fire private: inline BOOL IsClone( void ) { return ( pev->spawnflags & SF_MULTIMAN_CLONE ) ? TRUE : FALSE; } inline BOOL ShouldClone( void ) @@ -1321,9 +1321,9 @@ public: static TYPEDESCRIPTION m_SaveData[]; - string_t m_changeTarget; char m_szMapName[cchMapNameMost]; // trigger_changelevel only: next map char m_szLandmarkName[cchMapNameMost]; // trigger_changelevel only: landmark on next map + string_t m_changeTarget; float m_changeTargetDelay; }; diff --git a/dlls/util.h b/dlls/util.h index 8f56cd76..7f9dea70 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef UTIL_H #define UTIL_H // diff --git a/dlls/vector.h b/dlls/vector.h index 265a9b00..48c707b4 100644 --- a/dlls/vector.h +++ b/dlls/vector.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef VECTOR_H #define VECTOR_H diff --git a/dlls/weapons.h b/dlls/weapons.h index 0cfa2031..312f5531 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef WEAPONS_H #define WEAPONS_H diff --git a/engine/cdll_exp.h b/engine/cdll_exp.h index bf43654c..e4c1f5d8 100644 --- a/engine/cdll_exp.h +++ b/engine/cdll_exp.h @@ -12,6 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ +#pragma once #ifndef CDLL_EXP_H #define CDLL_EXP_H @@ -66,4 +67,4 @@ typedef struct cldll_func_s void (*pfnClipMoveToEntity)( struct physent_s *pe, const vec3_t start, vec3_t mins, vec3_t maxs, const vec3_t end, struct pmtrace_s *tr ); } cldll_func_t; -#endif//CDLL_EXP_H \ No newline at end of file +#endif//CDLL_EXP_H diff --git a/engine/cdll_int.h b/engine/cdll_int.h index 20af4b55..abfc43bd 100644 --- a/engine/cdll_int.h +++ b/engine/cdll_int.h @@ -18,7 +18,7 @@ // 4-23-98 // JOHN: client dll interface declarations // - +#pragma once #ifndef CDLL_INT_H #define CDLL_INT_H diff --git a/engine/custom.h b/engine/custom.h index 30ee8d53..02aa2089 100644 --- a/engine/custom.h +++ b/engine/custom.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef CUSTOM_H #define CUSTOM_H -#pragma once - #include "const.h" ///////////////// diff --git a/engine/customentity.h b/engine/customentity.h index 63e672f8..f524ae79 100644 --- a/engine/customentity.h +++ b/engine/customentity.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef CUSTOMENTITY_H #define CUSTOMENTITY_H diff --git a/engine/edict.h b/engine/edict.h index 3994c705..8584a0d9 100644 --- a/engine/edict.h +++ b/engine/edict.h @@ -12,12 +12,10 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EDICT_H #define EDICT_H -#pragma once - #define MAX_ENT_LEAFS 48 #include "progdefs.h" diff --git a/engine/eiface.h b/engine/eiface.h index 6fa51c12..f6cf2f51 100644 --- a/engine/eiface.h +++ b/engine/eiface.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef EIFACE_H #define EIFACE_H diff --git a/engine/keydefs.h b/engine/keydefs.h index ea22139f..5593d75a 100644 --- a/engine/keydefs.h +++ b/engine/keydefs.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef KEYDEFS_H #define KEYDEFS_H @@ -130,4 +130,4 @@ #define K_MOUSE4 244 #define K_MOUSE5 245 -#endif//KEYDEFS_H \ No newline at end of file +#endif//KEYDEFS_H diff --git a/engine/menu_int.h b/engine/menu_int.h index 69c10ce4..d907bd87 100644 --- a/engine/menu_int.h +++ b/engine/menu_int.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef MENU_INT_H #define MENU_INT_H diff --git a/engine/physint.h b/engine/physint.h index af923a00..2b4ac8f7 100644 --- a/engine/physint.h +++ b/engine/physint.h @@ -12,7 +12,7 @@ but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. */ - +#pragma once #ifndef PHYSINT_H #define PHYSINT_H @@ -111,4 +111,4 @@ typedef struct physics_interface_s int (*pfnRestoreDecal)( struct decallist_s *entry, edict_t *pEdict, qboolean adjacent ); } physics_interface_t; -#endif//PHYSINT_H \ No newline at end of file +#endif//PHYSINT_H diff --git a/engine/progdefs.h b/engine/progdefs.h index 56d904b1..31cfb3cb 100644 --- a/engine/progdefs.h +++ b/engine/progdefs.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PROGDEFS_H #define PROGDEFS_H -#pragma once - typedef struct { float time; diff --git a/engine/shake.h b/engine/shake.h index b2e88a33..a3e49324 100644 --- a/engine/shake.h +++ b/engine/shake.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SHAKE_H #define SHAKE_H diff --git a/engine/sprite.h b/engine/sprite.h index afc81a4e..4368c1ac 100644 --- a/engine/sprite.h +++ b/engine/sprite.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef SPRITE_H #define SPRITE_H @@ -99,4 +99,4 @@ typedef struct frametype_t type; } dframetype_t; -#endif//SPRITE_H \ No newline at end of file +#endif//SPRITE_H diff --git a/engine/studio.h b/engine/studio.h index 00e7ad27..88254c96 100644 --- a/engine/studio.h +++ b/engine/studio.h @@ -12,7 +12,7 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef STUDIO_H #define STUDIO_H diff --git a/pm_shared/pm_debug.h b/pm_shared/pm_debug.h index 417c3478..6c91d62e 100644 --- a/pm_shared/pm_debug.h +++ b/pm_shared/pm_debug.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_DEBUG_H #define PM_DEBUG_H -#pragma once - void PM_ViewEntity( void ); void PM_DrawBBox( vec3_t mins, vec3_t maxs, vec3_t origin, int pcolor, float life ); void PM_ParticleLine( vec3_t start, vec3_t end, int pcolor, float life, float vert ); diff --git a/pm_shared/pm_defs.h b/pm_shared/pm_defs.h index eddb17b6..82480806 100644 --- a/pm_shared/pm_defs.h +++ b/pm_shared/pm_defs.h @@ -12,11 +12,10 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_DEFS_H #define PM_DEFS_H -#pragma once - #define MAX_PHYSENTS 600 // Must have room for all entities in the world. #define MAX_MOVEENTS 64 #define MAX_CLIP_PLANES 5 diff --git a/pm_shared/pm_info.h b/pm_shared/pm_info.h index d75b67fc..9a971d53 100644 --- a/pm_shared/pm_info.h +++ b/pm_shared/pm_info.h @@ -12,10 +12,9 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_INFO_H #define PM_INFO_H -#pragma once - #define MAX_PHYSINFO_STRING 256 #endif//PM_INFO_H diff --git a/pm_shared/pm_materials.h b/pm_shared/pm_materials.h index e625b4fc..9bc71b72 100644 --- a/pm_shared/pm_materials.h +++ b/pm_shared/pm_materials.h @@ -12,6 +12,7 @@ * without written permission from Valve LLC. * ****/ +#pragma once #ifndef PM_MATERIALS_H #define PM_MATERIALS_H diff --git a/pm_shared/pm_movevars.h b/pm_shared/pm_movevars.h index 35fa5b4f..61eb06fd 100644 --- a/pm_shared/pm_movevars.h +++ b/pm_shared/pm_movevars.h @@ -6,6 +6,7 @@ //============================================================================= // pm_movevars.h +#pragma once #if !defined( PM_MOVEVARSH ) #define PM_MOVEVARSH diff --git a/pm_shared/pm_shared.h b/pm_shared/pm_shared.h index 2fb947a2..c315353b 100644 --- a/pm_shared/pm_shared.h +++ b/pm_shared/pm_shared.h @@ -12,12 +12,10 @@ * without written permission from Valve LLC. * ****/ - +#pragma once #ifndef PM_SHARED_H #define PM_SHARED_H -#pragma once - void PM_Init( struct playermove_s *ppmove ); void PM_Move( struct playermove_s *ppmove, int server ); char PM_FindTextureType( char *name ); From bf429f0709d5045a8cf2880b3b035fb0ab0b41e7 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 16 Dec 2017 04:56:23 +0300 Subject: [PATCH 147/199] Fix item soda precache --- dlls/effects.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/effects.cpp b/dlls/effects.cpp index bd9959f9..bd12f8aa 100644 --- a/dlls/effects.cpp +++ b/dlls/effects.cpp @@ -2182,7 +2182,7 @@ public: void CItemSoda::Precache( void ) { PRECACHE_MODEL( "models/can.mdl" ); - PRECACHE_SOUND( "weapons/g_bounce.wav" ); + PRECACHE_SOUND( "weapons/g_bounce3.wav" ); } LINK_ENTITY_TO_CLASS( item_sodacan, CItemSoda ) From 1285d4834781aead0d99c65784ebb671be5e59e1 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 17 Dec 2017 02:35:36 +0500 Subject: [PATCH 148/199] Update .travis.yml. --- .travis.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 9e165b81..00f3f479 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,10 +5,20 @@ compiler: os: - linux - osx -sudo: true +addons: + apt: + packages: + - gcc-multilib + - g++-multilib before_script: - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-multilib g++-multilib; fi + - curl http://libsdl.org/release/SDL2-devel-2.0.7-mingw.tar.gz | tar xzf - + - mv SDL2-2.0.7/i686-w64-mingw32/include/SDL2 cl_dll/ script: - mkdir -p build && cd build - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=0 && make -j3 && rm -rf * - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * \ No newline at end of file + - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -march=nocona -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 + - mkdir -p gamelibs/cl_dlls + - mkdir -p gamelibs/dlls + - cp cl_dll/libclient.* gamelibs/cl_dlls + - cp dlls/libserver.* gamelibs/dlls + - tar -J -cf gamelibs.txz gamelibs + - curl --upload-file gamelibs.txz https://transfer.sh/gamelibs.txz From e0f475e80e05b00984fb52088f1230d84c724736 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 17 Dec 2017 22:46:44 +0500 Subject: [PATCH 149/199] Use branch name and OS name as tarball name. --- .travis.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.travis.yml b/.travis.yml index 00f3f479..da740958 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,9 +16,9 @@ before_script: script: - mkdir -p build && cd build - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -march=nocona -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 - - mkdir -p gamelibs/cl_dlls - - mkdir -p gamelibs/dlls - - cp cl_dll/libclient.* gamelibs/cl_dlls - - cp dlls/libserver.* gamelibs/dlls - - tar -J -cf gamelibs.txz gamelibs - - curl --upload-file gamelibs.txz https://transfer.sh/gamelibs.txz + - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls + - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls + - cp cl_dll/libclient.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls + - cp dlls/libserver.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls + - tar -J -cf $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC + - curl --upload-file $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz https://transfer.sh/$TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz From a2f0ecf7419e58b7bd3a15257ecf954786e18128 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 18 Dec 2017 02:44:42 +0500 Subject: [PATCH 150/199] Fix linking with libdl on some environments. --- cl_dll/CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index e3ac075a..aa1e94f8 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -28,9 +28,6 @@ set (CLDLL_LIBRARY client) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT") - if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ldl") - endif() endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") @@ -109,6 +106,9 @@ if(USE_VOICEMGR) endif() add_library (${CLDLL_LIBRARY} SHARED ${CLDLL_SOURCES}) +if (GOLDSOURCE_SUPPORT) + target_link_libraries( ${CLDLL_LIBRARY} ${CMAKE_DL_LIBS} ) +endif() set_target_properties (${CLDLL_SHARED} PROPERTIES POSITION_INDEPENDENT_CODE 1) From b5650d56108f60d3b7e290edef835610a7d0dc65 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 18 Dec 2017 04:32:25 +0500 Subject: [PATCH 151/199] Do not use cpu-dependent optimization. --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index da740958..dff12df2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -15,7 +15,7 @@ before_script: - mv SDL2-2.0.7/i686-w64-mingw32/include/SDL2 cl_dll/ script: - mkdir -p build && cd build - - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -march=nocona -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 + - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls - cp cl_dll/libclient.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls From c128c69ceb2a96730ffe487bef234c4e59f3cac3 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 19 Dec 2017 00:27:56 +0300 Subject: [PATCH 152/199] Add install() for CMake. --- CMakeLists.txt | 4 ++++ cl_dll/CMakeLists.txt | 13 ++++++++++++- dlls/CMakeLists.txt | 13 ++++++++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7719bac6..0d754eb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,10 @@ option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) option(BUILD_CLIENT "Build client dll" ON) option(BUILD_SERVER "Build server dll" ON) option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) +set(GAMEDIR "valve" CACHE STRING "Gamedir path") +set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll") +set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll") +set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows") #----------------- # MAIN BUILD CODE \ diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index aa1e94f8..2d247950 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -110,6 +110,17 @@ if (GOLDSOURCE_SUPPORT) target_link_libraries( ${CLDLL_LIBRARY} ${CMAKE_DL_LIBS} ) endif() -set_target_properties (${CLDLL_SHARED} PROPERTIES +set_target_properties (${CLDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) +if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set_target_properties(${CLDLL_LIBRARY} PROPERTIES + OUTPUT_NAME "client" + PREFIX "") +endif() + +install( TARGETS ${CLDLL_LIBRARY} + DESTINATION "${GAMEDIR}/${CLIENT_INSTALL_DIR}/" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE ) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 4e56ab44..480b61d1 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -145,6 +145,17 @@ endif() add_library (${SVDLL_LIBRARY} SHARED ${SVDLL_SOURCES}) -set_target_properties (${SVDLL_SHARED} PROPERTIES +set_target_properties (${SVDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) +if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set_target_properties(${SVDLL_LIBRARY} PROPERTIES + OUTPUT_NAME ${SERVER_LIBRARY_NAME} + PREFIX "") +endif() + +install( TARGETS ${SVDLL_LIBRARY} + DESTINATION "${GAMEDIR}/${SERVER_INSTALL_DIR}/" + PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) From 7981bad606f0a251b3904405539b667c06c676f5 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Tue, 19 Dec 2017 00:28:34 +0300 Subject: [PATCH 153/199] Fix weapon selection being broken at the start of demo(or manual fullupdate call) --- dlls/player.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dlls/player.cpp b/dlls/player.cpp index d0a1f763..52f5f546 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3327,6 +3327,10 @@ void CBasePlayer::ForceClientDllUpdate( void ) m_fWeapon = FALSE; // Force weapon send m_fKnownItem = FALSE; // Force weaponinit messages. m_fInitHUD = TRUE; // Force HUD gmsgResetHUD message + m_bSentBhopcap = true; // a1ba: Update bhopcap state + memset( m_rgAmmoLast, 0, sizeof( m_rgAmmoLast )); // a1ba: Force update AmmoX + + // Now force all the necessary messages // to be sent. From 113135f7b9dd9d0dcd54f2e6724f016148faa1d8 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 18 Dec 2017 23:58:30 +0300 Subject: [PATCH 154/199] Ignore dlls, pdb, some cmake generated files and orig files produced by some diff programs --- .gitignore | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 26362f60..a0bc5604 100644 --- a/.gitignore +++ b/.gitignore @@ -6,4 +6,14 @@ *.a *.framework *.exe -build/ \ No newline at end of file +*.dll +*.pdb +build/ +CMakeLists.txt.user +cmake_install.cmake +*.orig +*.cbp +*.dsw +*.vsxproj +*.vsproj +*.sln From 6be68c49f334b63055ffe09da94cd5295ae4bc15 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 20 Dec 2017 04:35:54 +0300 Subject: [PATCH 155/199] Remove redundant files of original xash3d hlsdk --- backup.bat | 31 ------------------------- backup.lst | 36 ----------------------------- debug.bat | 42 --------------------------------- make_sdk.bat | 62 ------------------------------------------------- release.bat | 42 --------------------------------- xash.dsw | 65 ---------------------------------------------------- xash_sdk.dsw | 65 ---------------------------------------------------- xash_sdk.lst | 22 ------------------ 8 files changed, 365 deletions(-) delete mode 100644 backup.bat delete mode 100644 backup.lst delete mode 100644 debug.bat delete mode 100644 make_sdk.bat delete mode 100644 release.bat delete mode 100644 xash.dsw delete mode 100644 xash_sdk.dsw delete mode 100644 xash_sdk.lst diff --git a/backup.bat b/backup.bat deleted file mode 100644 index 7e780aa8..00000000 --- a/backup.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -color 4F -echo XashXT Group 2006 (C) -echo Prepare source for backup -echo. - -if exist backup.log del /f /q backup.log -if not exist D:\!backup/ mkdir D:\!backup\ -echo Prepare OK! -echo Please wait: backup in progress -C:\Progra~1\WinRar\rar a -agMMMYYYY-DD D:\!backup\.rar -dh -m5 @backup.lst >>backup.log -if errorlevel 1 goto error -if errorlevel 0 goto ok -:ok -cls -echo Source was sucessfully backuped -echo and stored in folder "backup" -echo Press any key for exit. :-) -if exist backup.log del /f /q backup.log -exit -:error -echo ****************************** -echo ***********Error!************* -echo ****************************** -echo **See backup.log for details** -echo ****************************** -echo ****************************** -echo. -echo press any key for exit :-( -pause>nul -exit diff --git a/backup.lst b/backup.lst deleted file mode 100644 index 628de079..00000000 --- a/backup.lst +++ /dev/null @@ -1,36 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2007 © -// list with backup directories -//======================================================================= - -// global stuff -xash.dsw -debug.bat -backup.lst -backup.bat -release.bat -change.log -make_sdk.bat -xash_sdk.lst - -cl_dll\ -cl_dll\hl\ -common\ -dlls\ -game_shared\ -game_launch\ -engine\ -engine\client\ -engine\client\vgui\ -engine\server\ -engine\common\ -engine\common\imagelib\ -engine\common\soundlib\ -pm_shared\ -mainui\ -mainui\legacy -utils\ -utils\makefont\ -utils\vgui\ -utils\vgui\include\ -utils\vgui\lib\win32_vc6\ \ No newline at end of file diff --git a/debug.bat b/debug.bat deleted file mode 100644 index eb702325..00000000 --- a/debug.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off - -set MSDEV=BuildConsole -set CONFIG=/ShowTime /ShowAgent /nologo /cfg= -set MSDEV=msdev -set CONFIG=/make -set build_type=debug -set BUILD_ERROR= -call vcvars32 - -%MSDEV% engine/engine.dsp %CONFIG%"engine - Win32 Debug" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -%MSDEV% mainui/mainui.dsp %CONFIG%"mainui - Win32 Debug" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -if "%BUILD_ERROR%"=="" goto build_ok - -echo ********************* -echo ********************* -echo *** Build Errors! *** -echo ********************* -echo ********************* -echo press any key to exit -echo ********************* -pause>nul -goto done - - -@rem -@rem Successful build -@rem -:build_ok - -rem //delete log files -if exist engine\engine.plg del /f /q engine\engine.plg -if exist mainui\mainui.plg del /f /q mainui\mainui.plg - -echo -echo Build succeeded! -echo -:done \ No newline at end of file diff --git a/make_sdk.bat b/make_sdk.bat deleted file mode 100644 index 96602839..00000000 --- a/make_sdk.bat +++ /dev/null @@ -1,62 +0,0 @@ -@echo off -color 5A -echo XashXT Group 2010 (C) -echo Create Xash3D SDK -echo. - -if not exist D:\Xash3D\src_main\xash_sdk/ mkdir D:\Xash3D\src_main\xash_sdk\ -if not exist D:\Xash3D\src_main\xash_sdk\engine/ mkdir D:\Xash3D\src_main\xash_sdk\engine\ -if not exist D:\Xash3D\src_main\xash_sdk\common/ mkdir D:\Xash3D\src_main\xash_sdk\common\ -if not exist D:\Xash3D\src_main\xash_sdk\mainui/ mkdir D:\Xash3D\src_main\xash_sdk\mainui\ -if not exist D:\Xash3D\src_main\xash_sdk\mainui\legacy/ mkdir D:\Xash3D\src_main\xash_sdk\mainui\legacy -if not exist D:\Xash3D\src_main\xash_sdk\utils/ mkdir D:\Xash3D\src_main\xash_sdk\utils\ -if not exist D:\Xash3D\src_main\xash_sdk\utils\makefont/ mkdir D:\Xash3D\src_main\xash_sdk\utils\makefont -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui\include/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui\include -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui\lib/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui\lib -if not exist D:\Xash3D\src_main\xash_sdk\utils\vgui\lib\win32_vc6/ mkdir D:\Xash3D\src_main\xash_sdk\utils\vgui\lib\win32_vc6 -if not exist D:\Xash3D\src_main\xash_sdk\game_launch/ mkdir D:\Xash3D\src_main\xash_sdk\game_launch\ -if not exist D:\Xash3D\src_main\xash_sdk\cl_dll/ mkdir D:\Xash3D\src_main\xash_sdk\cl_dll\ -if not exist D:\Xash3D\src_main\xash_sdkcl_dll\hl/ mkdir D:\Xash3D\src_main\xash_sdk\cl_dll\hl\ -if not exist D:\Xash3D\src_main\xash_sdk\dlls/ mkdir D:\Xash3D\src_main\xash_sdk\dlls\ -if not exist D:\Xash3D\src_main\xash_sdk\dlls\wpn_shared/ mkdir D:\Xash3D\src_main\xash_sdk\dlls\wpn_shared\ -if not exist D:\Xash3D\src_main\xash_sdk\game_shared/ mkdir D:\Xash3D\src_main\xash_sdk\game_shared\ -if not exist D:\Xash3D\src_main\xash_sdk\pm_shared/ mkdir D:\Xash3D\src_main\xash_sdk\pm_shared\ -@copy /Y engine\*.h xash_sdk\engine\*.h -@copy /Y game_launch\*.* xash_sdk\game_launch\*.* -@copy /Y mainui\*.* xash_sdk\mainui\*.* -@copy /Y mainui\legacy\*.* xash_sdk\mainui\legacy\*.* -@copy /Y common\*.* xash_sdk\common\*.* -@copy /Y cl_dll\*.* xash_sdk\cl_dll\*.* -@copy /Y cl_dll\hl\*.* xash_sdk\cl_dll\hl\*.* -@copy /Y dlls\*.* xash_sdk\dlls\*.* -@copy /Y dlls\wpn_shared\*.* xash_sdk\dlls\wpn_shared\*.* -@copy /Y utils\makefont\*.* xash_sdk\utils\makefont\*.* -@copy /Y utils\vgui\include\*.* xash_sdk\utils\vgui\include\*.* -@copy /Y utils\vgui\lib\win32_vc6\*.* xash_sdk\utils\vgui\lib\win32_vc6\*.* -@copy /Y game_shared\*.* xash_sdk\game_shared\*.* -@copy /Y pm_shared\*.* xash_sdk\pm_shared\*.* -@copy /Y xash_sdk.dsw xash_sdk\xash_sdk.dsw -echo Prepare OK! -echo Please wait: creating SDK in progress -C:\Progra~1\WinRar\rar a xash_sdk -dh -k -r -s -df -m5 @xash_sdk.lst >>makesdk.log -if errorlevel 1 goto error -if errorlevel 0 goto ok -:ok -cls -echo SDK was sucessfully created -echo and stored in RAR-chive "xash_sdk" -echo Press any key for exit. :-) -if exist makesdk.log del /f /q makesdk.log -exit -:error -echo ****************************** -echo ***********Error!************* -echo ****************************** -echo *See makesdk.log for details** -echo ****************************** -echo ****************************** -echo. -echo press any key for exit :-( -pause>nul -exit \ No newline at end of file diff --git a/release.bat b/release.bat deleted file mode 100644 index dae2d16c..00000000 --- a/release.bat +++ /dev/null @@ -1,42 +0,0 @@ -@echo off - -set MSDEV=BuildConsole -set CONFIG=/ShowTime /ShowAgent /nologo /cfg= -set MSDEV=msdev -set CONFIG=/make -set build_type=release -set BUILD_ERROR= -call vcvars32 - -%MSDEV% engine/engine.dsp %CONFIG%"engine - Win32 Release" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -%MSDEV% mainui/mainui.dsp %CONFIG%"mainui - Win32 Release" %build_target% -if errorlevel 1 set BUILD_ERROR=1 - -if "%BUILD_ERROR%"=="" goto build_ok - -echo ********************* -echo ********************* -echo *** Build Errors! *** -echo ********************* -echo ********************* -echo press any key to exit -echo ********************* -pause>nul -goto done - - -@rem -@rem Successful build -@rem -:build_ok - -rem //delete log files -if exist engine\engine.plg del /f /q engine\engine.plg -if exist mainui\mainui.plg del /f /q mainui\mainui.plg - -echo -echo Build succeeded! -echo -:done \ No newline at end of file diff --git a/xash.dsw b/xash.dsw deleted file mode 100644 index 3be1a44d..00000000 --- a/xash.dsw +++ /dev/null @@ -1,65 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "hl"=".\dlls\hl.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "client"=".\cl_dll\cl_dll.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mainui"=".\mainui\mainui.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "engine"=".\engine\engine.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/xash_sdk.dsw b/xash_sdk.dsw deleted file mode 100644 index ad911ba0..00000000 --- a/xash_sdk.dsw +++ /dev/null @@ -1,65 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "hl"=".\dlls\hl.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "client"=".\cl_dll\cl_dll.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "mainui"=".\mainui\mainui.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "game"=".\game_launch\game.dsp" - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/xash_sdk.lst b/xash_sdk.lst deleted file mode 100644 index a211c3b4..00000000 --- a/xash_sdk.lst +++ /dev/null @@ -1,22 +0,0 @@ -//======================================================================= -// Copyright XashXT Group 2011 © -// list with SDK directories -//======================================================================= - -// global stuff -xash_sdk\xash_sdk.dsw -xash_sdk\cl_dll\ -xash_sdk\cl_dll\hl\ -xash_sdk\common\ -xash_sdk\dlls\ -xash_sdk\game_shared\ -xash_sdk\game_launch\ -xash_sdk\engine\ -xash_sdk\pm_shared\ -xash_sdk\mainui\ -xash_dsk\mainui\legacy -xash_sdk\utils\ -xash_sdk\makefont\ -xash_sdk\utils\vgui\ -xash_sdk\utils\vgui\include\ -xash_sdk\utils\vgui\lib\win32_vc6\ \ No newline at end of file From df737ff88d5552e7d6fc0ac67ea60520d9f8f4e6 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 21 Dec 2017 17:12:05 +0500 Subject: [PATCH 156/199] Update .travis.yml --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index dff12df2..fb18612f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -18,7 +18,7 @@ script: - cmake ../ -DCMAKE_C_FLAGS="-O2 -pipe -DNDEBUG -fvisibility=hidden -fomit-frame-pointer" -DCMAKE_CXX_FLAGS="-fno-exceptions -fno-rtti" -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined -Wl,--strip-all" -DGOLDSOURCE_SUPPORT=1 -DUSE_VOICEMGR=0 && make -j3 - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls - mkdir -p $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls - - cp cl_dll/libclient.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls - - cp dlls/libserver.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls + - cp cl_dll/client.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/cl_dlls + - cp dlls/hl.* $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC/dlls - tar -J -cf $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC - curl --upload-file $TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz https://transfer.sh/$TRAVIS_BRANCH-$TRAVIS_OS_NAME-$CC.txz From b66ceab4e586d762408b8e81f88455ec66e00401 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 23 Dec 2017 14:02:59 +0500 Subject: [PATCH 157/199] Fix scoreboard position. --- cl_dll/scoreboard.cpp | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 3adbaab6..908d00f3 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -92,17 +92,17 @@ We have a minimum width of 1-320 - we could have the field widths scale with it? // X positions // relative to the side of the scoreboard -#define NAME_RANGE_MIN -100 -#define NAME_RANGE_MAX 145 -#define KILLS_RANGE_MIN 130 -#define KILLS_RANGE_MAX 170 -#define DIVIDER_POS 180 -#define DEATHS_RANGE_MIN 185 -#define DEATHS_RANGE_MAX 210 -#define PING_RANGE_MIN 245 -#define PING_RANGE_MAX 295 -#define PL_RANGE_MIN 315 -#define PL_RANGE_MAX 375 +#define NAME_RANGE_MIN -65 +#define NAME_RANGE_MAX 180 +#define KILLS_RANGE_MIN 165 +#define KILLS_RANGE_MAX 205 +#define DIVIDER_POS 215 +#define DEATHS_RANGE_MIN 220 +#define DEATHS_RANGE_MAX 245 +#define PING_RANGE_MIN 280 +#define PING_RANGE_MAX 330 +#define PL_RANGE_MIN 350 +#define PL_RANGE_MAX 410 int SCOREBOARD_WIDTH = 320; From 7eeccf6ecf642c76ab2668526ebbea4b9b2421e4 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Mon, 25 Dec 2017 01:25:40 +0500 Subject: [PATCH 158/199] Fix build. --- cl_dll/ev_hldm.cpp | 4 ++-- dlls/player.cpp | 6 +++--- dlls/poke646/firetrail.cpp | 4 ++-- dlls/poke646/robocop.cpp | 2 +- dlls/poke646/xenspit.cpp | 4 ++-- dlls/poke646/xensquasher.cpp | 2 +- dlls/weapons.cpp | 7 ------- dlls/weapons.h | 39 ------------------------------------ 8 files changed, 11 insertions(+), 57 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index d6b92974..862c7f87 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -1879,7 +1879,7 @@ void EV_FireBradnailer( event_args_t *args ) VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_NAIL, 2, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_NAIL, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } //====================== @@ -1937,7 +1937,7 @@ void EV_FireNailgun( event_args_t *args ) VectorCopy( forward, vecAiming ); - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_NAIL, 1, &tracerCount[idx - 1], args->fparam1, args->fparam2 ); + EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_NAIL, 1, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); } //====================== diff --git a/dlls/player.cpp b/dlls/player.cpp index 572f65db..8034a887 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -4637,12 +4637,12 @@ BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) void CBasePlayer::IncrementExertLevel( int amount ) { - m_iExertLevel += min( amount, PLAYER_EXERT_LEVEL_MAX - m_iExertLevel ); + m_iExertLevel += Q_min( amount, PLAYER_EXERT_LEVEL_MAX - m_iExertLevel ); } void CBasePlayer::DecrementExertLevel( int amount ) { - m_iExertLevel -= min( amount, m_iExertLevel ); + m_iExertLevel -= Q_min( amount, m_iExertLevel ); } void CBasePlayer::SetExertLevel( int level ) @@ -4667,7 +4667,7 @@ void CBasePlayer::UpdateExertLevel( void ) if( temp < 1 ) temp = 1; - m_iExertLevel -= min( m_iExertLevel, temp ); + m_iExertLevel -= Q_min( m_iExertLevel, temp ); m_flExertRate = PLAYER_EXERT_RATE; m_flExertUpdateStart = gpGlobals->time; diff --git a/dlls/poke646/firetrail.cpp b/dlls/poke646/firetrail.cpp index e274df11..587f7bcc 100644 --- a/dlls/poke646/firetrail.cpp +++ b/dlls/poke646/firetrail.cpp @@ -60,7 +60,7 @@ void CFireTrail::Think(void) pSprite->AnimateAndDie(RANDOM_FLOAT(15.0f, 20.0f)); pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 192, kRenderFxNoDissipation ); pSprite->SetScale(pev->speed); - pSprite->pev->frame = pSprite->Frames() - ((max(0, pev->speed - (0.1 * pSprite->pev->framerate)) * pSprite->Frames()) / pev->maxspeed); + pSprite->pev->frame = pSprite->Frames() - ((Q_max(0, pev->speed - (0.1 * pSprite->pev->framerate)) * pSprite->Frames()) / pev->maxspeed); pev->speed -= 0.1; if (pev->speed > 0) @@ -80,4 +80,4 @@ void CFireTrail::Touch(CBaseEntity *pOther) if ((pev->velocity.x*pev->velocity.x + pev->velocity.y*pev->velocity.y) < 10.0) pev->speed = 0; -} \ No newline at end of file +} diff --git a/dlls/poke646/robocop.cpp b/dlls/poke646/robocop.cpp index d73528a4..6d78933c 100644 --- a/dlls/poke646/robocop.cpp +++ b/dlls/poke646/robocop.cpp @@ -1366,7 +1366,7 @@ void CRoboCop::BeamUpdate(void) if (m_pBeamSpot) { - m_pBeamSpot->pev->renderamt = UTIL_Approach(min(m_beamBrightness + 25, 255), m_pBeamSpot->pev->renderamt, 60); + m_pBeamSpot->pev->renderamt = UTIL_Approach(Q_min(m_beamBrightness + 25, 255), m_pBeamSpot->pev->renderamt, 60); if (m_pBeamSpot->pev->renderamt == 0) m_pBeamSpot->pev->effects |= EF_NODRAW; else diff --git a/dlls/poke646/xenspit.cpp b/dlls/poke646/xenspit.cpp index b38d433d..160796e4 100644 --- a/dlls/poke646/xenspit.cpp +++ b/dlls/poke646/xenspit.cpp @@ -262,7 +262,7 @@ void CXenLargeSpit::Touch(CBaseEntity *pOther) { // ALERT(at_console, " CXenLargeSpit::Touch START\n"); - float damage = max(pev->dmg, pev->dmg * m_iChildCount); + float damage = Q_max(pev->dmg, pev->dmg * m_iChildCount); RadiusDamage(pev->origin, pev, pev, damage, 110, CLASS_NONE, DMG_POISON | DMG_ALWAYSGIB); @@ -335,7 +335,7 @@ void CXenLargeSpit::CycleThink(void) float cs, sn, dist; cs = cos(pSpit->m_flCycle * 2 * M_PI); sn = sin(pSpit->m_flCycle * 2 * M_PI); - dist = max(2, 2 * m_iChildCount); + dist = Q_max(2, 2 * m_iChildCount); // ALERT(at_console, "cs: %.2f. sn: %.2f\n", cs, sn); diff --git a/dlls/poke646/xensquasher.cpp b/dlls/poke646/xensquasher.cpp index 0654a704..3d87a37c 100644 --- a/dlls/poke646/xensquasher.cpp +++ b/dlls/poke646/xensquasher.cpp @@ -406,7 +406,7 @@ void CXenSquasher::Fire(Vector vecOrigSrc, Vector vecDir, float flDamage) pLargeSpit->pev->velocity = gpGlobals->v_forward * 800; pLargeSpit->pev->scale = 0.2f; - int iNumProjectiles = max(1, flDamage * XENSPIT_MAX_PROJECTILES / 200); + int iNumProjectiles = Q_max(1, flDamage * XENSPIT_MAX_PROJECTILES / 200); float cycle = 0; float cycleGap = 1.0f / (float)iNumProjectiles; diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index d7b32446..68d9aaf3 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -1604,13 +1604,6 @@ TYPEDESCRIPTION CEgon::m_SaveData[] = IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon ) -TYPEDESCRIPTION CHgun::m_SaveData[] = -{ - DEFINE_FIELD( CHgun, m_flRechargeTime, FIELD_FLOAT ), -}; - -IMPLEMENT_SAVERESTORE( CHgun, CBasePlayerWeapon ) - TYPEDESCRIPTION CSatchel::m_SaveData[] = { DEFINE_FIELD( CSatchel, m_chargeReady, FIELD_INTEGER ), diff --git a/dlls/weapons.h b/dlls/weapons.h index 97a36e53..93c1ac25 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -821,45 +821,6 @@ private: unsigned short m_usEgonFire; }; -class CHgun : public CBasePlayerWeapon -{ -public: -#ifndef CLIENT_DLL - int Save( CSave &save ); - int Restore( CRestore &restore ); - static TYPEDESCRIPTION m_SaveData[]; -#endif - void Spawn( void ); - void Precache( void ); - int iItemSlot( void ) { return 4; } - int GetItemInfo(ItemInfo *p); - int AddToPlayer( CBasePlayer *pPlayer ); - - void PrimaryAttack( void ); - void SecondaryAttack( void ); - BOOL Deploy( void ); - BOOL IsUseable( void ); - void Holster( int skiplocal = 0 ); - void Reload( void ); - void WeaponIdle( void ); - float m_flNextAnimTime; - - float m_flRechargeTime; - - int m_iFirePhase;// don't save me. - - virtual BOOL UseDecrement( void ) - { -#if defined( CLIENT_WEAPONS ) - return TRUE; -#else - return FALSE; -#endif - } -private: - unsigned short m_usHornetFire; -}; - class CHandGrenade : public CBasePlayerWeapon { public: From 3dda2ec590a305bea7023f98bb0c6da30c02c7d6 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 28 Dec 2017 02:02:23 +0300 Subject: [PATCH 159/199] Fix compiling on MSVC2017 --- cl_dll/CMakeLists.txt | 19 +++++++++++++++---- dlls/CMakeLists.txt | 11 +++++++++-- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 2d247950..824acc52 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -25,11 +25,22 @@ project (CLDLL) set (CLDLL_LIBRARY client) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") -if (GOLDSOURCE_SUPPORT) - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT") + +add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) + +if(NOT WIN32) + add_compile_options(-fno-exceptions) # GCC/Clang flag + add_compile_options(-Wno-write-strings) # GCC/Clang flag + add_definitions(-D_LINUX -DLINUX) # It seems enough for all non-Win32 systems + add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) +else() + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) endif() -set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") + +if (GOLDSOURCE_SUPPORT) + add_definitions(-DGOLDSOURCE_SUPPORT) +endif() + set (CLDLL_SOURCES ../dlls/crossbow.cpp diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 480b61d1..1564b90e 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -25,8 +25,15 @@ project (SVDLL) set (SVDLL_LIBRARY server) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -fno-exceptions -w") -set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") +add_definitions(-DCLIENT_WEAPONS) + +if(NOT WIN32) + add_compile_options(-fno-exceptions) # GCC/Clang flag + add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems + add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) +else() + add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) +endif() set (SVDLL_SOURCES agrunt.cpp From 9a02d7116fc0d6dd89ab0f6f2e54e18eb6ecac8e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 28 Dec 2017 02:05:47 +0300 Subject: [PATCH 160/199] It's better to use MSVC here instead of WIN32, so it wouldn't break MinGW builds --- cl_dll/CMakeLists.txt | 2 +- dlls/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 824acc52..05990913 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -28,7 +28,7 @@ set (CLDLL_LIBRARY client) add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) -if(NOT WIN32) +if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-write-strings) # GCC/Clang flag add_definitions(-D_LINUX -DLINUX) # It seems enough for all non-Win32 systems diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 1564b90e..bf65b00f 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -27,7 +27,7 @@ set (SVDLL_LIBRARY server) add_definitions(-DCLIENT_WEAPONS) -if(NOT WIN32) +if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) From c5aa3aa40e461042425a171b121df2e043d8d3d4 Mon Sep 17 00:00:00 2001 From: mittorn Date: Sat, 30 Dec 2017 22:22:14 +0700 Subject: [PATCH 161/199] Fix amd64 build --- dlls/util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/util.h b/dlls/util.h index 7f9dea70..41e86a84 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -40,7 +40,7 @@ extern globalvars_t *gpGlobals; #define STRING(offset) (const char *)(gpGlobals->pStringBase + (int)offset) #if !defined XASH_64BIT || defined(CLIENT_DLL) -#define MAKE_STRING(str) ((int)str - (int)STRING(0)) +#define MAKE_STRING(str) ((int)(long int)str - (int)(long int)STRING(0)) #else static inline int MAKE_STRING(const char *szValue) { From 8abffc937138ad9e84132259b81683f25f127286 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 13 Jan 2018 09:01:38 +0500 Subject: [PATCH 162/199] Fix typo. --- dlls/util.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/util.cpp b/dlls/util.cpp index 94c8c68c..c7feab31 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -989,7 +989,7 @@ float UTIL_Approach( float target, float value, float speed ) float UTIL_ApproachAngle( float target, float value, float speed ) { target = UTIL_AngleMod( target ); - value = UTIL_AngleMod( target ); + value = UTIL_AngleMod( value ); float delta = target - value; From 31c1e121b5826245e1ec074f83d4e3636cef7891 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sat, 13 Jan 2018 18:03:24 +0300 Subject: [PATCH 163/199] Fix some warnings. Disable warning about invalid offsetof as it produces billion warnings in save-restore code --- dlls/CMakeLists.txt | 4 ++-- dlls/playermonster.cpp | 4 ++-- utils/false_vgui/include/VGUI_Panel.h | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index bf65b00f..bfd7d80b 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # Copyright (c) 2015 Pavlo Lavrenenko # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -28,7 +28,7 @@ set (SVDLL_LIBRARY server) add_definitions(-DCLIENT_WEAPONS) if(NOT MSVC) - add_compile_options(-fno-exceptions) # GCC/Clang flag + add_compile_options(-fno-exceptions -Wno-invalid-offsetof) # GCC/Clang flag add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) else() diff --git a/dlls/playermonster.cpp b/dlls/playermonster.cpp index cd3484ab..a6e38389 100644 --- a/dlls/playermonster.cpp +++ b/dlls/playermonster.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // @@ -82,7 +82,7 @@ void CPlayerMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CPlayerMonster::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= diff --git a/utils/false_vgui/include/VGUI_Panel.h b/utils/false_vgui/include/VGUI_Panel.h index bec7ac25..351b2375 100644 --- a/utils/false_vgui/include/VGUI_Panel.h +++ b/utils/false_vgui/include/VGUI_Panel.h @@ -219,7 +219,6 @@ private: bool _paintBorderEnabled; bool _paintBackgroundEnabled; bool _paintEnabled; -friend class Panel; friend class App; friend class SurfaceBase; friend class Image; From c13546377453d78c120d41d2b91326d3267e0a94 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Mon, 15 Jan 2018 02:43:57 +0300 Subject: [PATCH 164/199] add_compile_options for older cmake versions --- CMakeLists.txt | 10 ++++++++++ dlls/CMakeLists.txt | 5 +++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0d754eb5..e025342a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,16 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8) endif() endif() +# add_compile_options for older cmake versions +if(${CMAKE_VERSION} VERSION_LESS "3.0.2") +macro(add_compile_options) + set(list_var "${ARGV}") + foreach(arg IN LISTS list_var) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") + endforeach() +endmacro() +endif() + if(BUILD_CLIENT) add_subdirectory(cl_dll) endif() diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index bfd7d80b..bf7d3370 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -1,4 +1,4 @@ -# +# # Copyright (c) 2015 Pavlo Lavrenenko # # Permission is hereby granted, free of charge, to any person obtaining a copy @@ -28,7 +28,8 @@ set (SVDLL_LIBRARY server) add_definitions(-DCLIENT_WEAPONS) if(NOT MSVC) - add_compile_options(-fno-exceptions -Wno-invalid-offsetof) # GCC/Clang flag + add_compile_options(-fno-exceptions) # GCC/Clang flag + add_compile_options(-Wno-invalid-offsetof) # GCC/Clang flag add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) else() From 8dc9245fe3eba4db5b8d44bc094b95b2273b462b Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Thu, 18 Jan 2018 22:36:32 +0300 Subject: [PATCH 165/199] Copyright symbol to utf-8 --- cl_dll/GameStudioModelRenderer.cpp | 2 +- cl_dll/GameStudioModelRenderer.h | 2 +- cl_dll/GameStudioModelRenderer_Sample.cpp | 2 +- cl_dll/GameStudioModelRenderer_Sample.h | 2 +- cl_dll/StudioModelRenderer.cpp | 2 +- cl_dll/StudioModelRenderer.h | 2 +- cl_dll/camera.h | 2 +- cl_dll/demo.h | 2 +- cl_dll/entity.cpp | 2 +- cl_dll/ev_hldm.h | 2 +- cl_dll/events.cpp | 2 +- cl_dll/eventscripts.h | 2 +- cl_dll/hud_iface.h | 2 +- cl_dll/hud_servers.cpp | 2 +- cl_dll/hud_servers.h | 2 +- cl_dll/hud_servers_priv.h | 2 +- cl_dll/hud_spectator.cpp | 2 +- cl_dll/hud_spectator.h | 2 +- cl_dll/in_camera.cpp | 2 +- cl_dll/in_defs.h | 2 +- cl_dll/input.cpp | 2 +- cl_dll/kbutton.h | 2 +- cl_dll/overview.cpp | 2 +- cl_dll/overview.h | 2 +- cl_dll/studio_util.cpp | 2 +- cl_dll/studio_util.h | 2 +- cl_dll/tri.cpp | 2 +- cl_dll/view.cpp | 2 +- cl_dll/view.h | 2 +- dlls/squad.h | 2 +- dlls/stats.cpp | 2 +- pm_shared/pm_movevars.h | 2 +- 32 files changed, 32 insertions(+), 32 deletions(-) diff --git a/cl_dll/GameStudioModelRenderer.cpp b/cl_dll/GameStudioModelRenderer.cpp index c7211752..f2953e96 100644 --- a/cl_dll/GameStudioModelRenderer.cpp +++ b/cl_dll/GameStudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer.h b/cl_dll/GameStudioModelRenderer.h index 881dd144..8b911db8 100644 --- a/cl_dll/GameStudioModelRenderer.h +++ b/cl_dll/GameStudioModelRenderer.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer_Sample.cpp b/cl_dll/GameStudioModelRenderer_Sample.cpp index d697d927..5f1d2b69 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.cpp +++ b/cl_dll/GameStudioModelRenderer_Sample.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer_Sample.h b/cl_dll/GameStudioModelRenderer_Sample.h index 9c09374b..a9136880 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.h +++ b/cl_dll/GameStudioModelRenderer_Sample.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/StudioModelRenderer.cpp b/cl_dll/StudioModelRenderer.cpp index b7c3c1c6..ffcf305b 100644 --- a/cl_dll/StudioModelRenderer.cpp +++ b/cl_dll/StudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/StudioModelRenderer.h b/cl_dll/StudioModelRenderer.h index cbfd0d3b..0f91122d 100644 --- a/cl_dll/StudioModelRenderer.h +++ b/cl_dll/StudioModelRenderer.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 69a00216..99235ed6 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/demo.h b/cl_dll/demo.h index b7dbaff0..def3616a 100644 --- a/cl_dll/demo.h +++ b/cl_dll/demo.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 303a9d25..344d1783 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index 88b221df..ffb1190a 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/events.cpp b/cl_dll/events.cpp index a51dd72f..a6d21a69 100644 --- a/cl_dll/events.cpp +++ b/cl_dll/events.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/eventscripts.h b/cl_dll/eventscripts.h index c11ee338..c4d831e0 100644 --- a/cl_dll/eventscripts.h +++ b/cl_dll/eventscripts.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index 7993bd9d..ae73fc70 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers.cpp b/cl_dll/hud_servers.cpp index 67973c75..9f940025 100644 --- a/cl_dll/hud_servers.cpp +++ b/cl_dll/hud_servers.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers.h b/cl_dll/hud_servers.h index 33fb72a5..59c60f4c 100644 --- a/cl_dll/hud_servers.h +++ b/cl_dll/hud_servers.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers_priv.h b/cl_dll/hud_servers_priv.h index d26b3655..c5c9b18e 100644 --- a/cl_dll/hud_servers_priv.h +++ b/cl_dll/hud_servers_priv.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index 5ffce74a..8f470c0a 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 7a9ec9d3..2993c3f2 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/in_camera.cpp b/cl_dll/in_camera.cpp index 92051afe..cf5489c0 100644 --- a/cl_dll/in_camera.cpp +++ b/cl_dll/in_camera.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index d5c352fa..5b6d7a41 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/input.cpp b/cl_dll/input.cpp index fd1ef7da..10014082 100644 --- a/cl_dll/input.cpp +++ b/cl_dll/input.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/kbutton.h b/cl_dll/kbutton.h index 54f1ea93..55fbeee6 100644 --- a/cl_dll/kbutton.h +++ b/cl_dll/kbutton.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/overview.cpp b/cl_dll/overview.cpp index 881812f7..ddfb3cd5 100644 --- a/cl_dll/overview.cpp +++ b/cl_dll/overview.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/overview.h b/cl_dll/overview.h index 59535fb4..88a7a047 100644 --- a/cl_dll/overview.h +++ b/cl_dll/overview.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/studio_util.cpp b/cl_dll/studio_util.cpp index a5eb39f1..d3a031d4 100644 --- a/cl_dll/studio_util.cpp +++ b/cl_dll/studio_util.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index 7af94672..90c84fb4 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index 517ef982..6bb4edbe 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index a4abe91c..bda8616d 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/view.h b/cl_dll/view.h index c0aa0e8f..7d8624c9 100644 --- a/cl_dll/view.h +++ b/cl_dll/view.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/dlls/squad.h b/dlls/squad.h index f8f20aa0..607540cf 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/dlls/stats.cpp b/dlls/stats.cpp index 1df298b2..48804a16 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/pm_shared/pm_movevars.h b/pm_shared/pm_movevars.h index 61eb06fd..19b46b1d 100644 --- a/pm_shared/pm_movevars.h +++ b/pm_shared/pm_movevars.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // From 48733fd1a1a5e10b1029b8099d118ee2d4ce63ec Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Fri, 19 Jan 2018 20:00:32 +0300 Subject: [PATCH 166/199] All copyright symbols to (c) --- cl_dll/GameStudioModelRenderer.cpp | 2 +- cl_dll/GameStudioModelRenderer.h | 2 +- cl_dll/GameStudioModelRenderer_Sample.cpp | 2 +- cl_dll/GameStudioModelRenderer_Sample.h | 2 +- cl_dll/StudioModelRenderer.cpp | 2 +- cl_dll/StudioModelRenderer.h | 2 +- cl_dll/camera.h | 2 +- cl_dll/demo.h | 2 +- cl_dll/entity.cpp | 2 +- cl_dll/ev_hldm.h | 2 +- cl_dll/events.cpp | 2 +- cl_dll/eventscripts.h | 2 +- cl_dll/hud_iface.h | 2 +- cl_dll/hud_servers.cpp | 2 +- cl_dll/hud_servers.h | 2 +- cl_dll/hud_servers_priv.h | 2 +- cl_dll/hud_spectator.cpp | 2 +- cl_dll/hud_spectator.h | 2 +- cl_dll/in_camera.cpp | 2 +- cl_dll/in_defs.h | 2 +- cl_dll/input.cpp | 2 +- cl_dll/input_goldsource.cpp | 2 +- cl_dll/kbutton.h | 2 +- cl_dll/overview.cpp | 2 +- cl_dll/overview.h | 2 +- cl_dll/studio_util.cpp | 2 +- cl_dll/studio_util.h | 2 +- cl_dll/tri.cpp | 2 +- cl_dll/view.cpp | 2 +- cl_dll/view.h | 2 +- dlls/playermonster.cpp | 2 +- dlls/squad.h | 2 +- dlls/stats.cpp | 2 +- pm_shared/pm_movevars.h | 2 +- 34 files changed, 34 insertions(+), 34 deletions(-) diff --git a/cl_dll/GameStudioModelRenderer.cpp b/cl_dll/GameStudioModelRenderer.cpp index f2953e96..570b3375 100644 --- a/cl_dll/GameStudioModelRenderer.cpp +++ b/cl_dll/GameStudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer.h b/cl_dll/GameStudioModelRenderer.h index 8b911db8..0e424576 100644 --- a/cl_dll/GameStudioModelRenderer.h +++ b/cl_dll/GameStudioModelRenderer.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer_Sample.cpp b/cl_dll/GameStudioModelRenderer_Sample.cpp index 5f1d2b69..ee8e8f9c 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.cpp +++ b/cl_dll/GameStudioModelRenderer_Sample.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/GameStudioModelRenderer_Sample.h b/cl_dll/GameStudioModelRenderer_Sample.h index a9136880..7a4d062d 100644 --- a/cl_dll/GameStudioModelRenderer_Sample.h +++ b/cl_dll/GameStudioModelRenderer_Sample.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/StudioModelRenderer.cpp b/cl_dll/StudioModelRenderer.cpp index ffcf305b..a9859244 100644 --- a/cl_dll/StudioModelRenderer.cpp +++ b/cl_dll/StudioModelRenderer.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/StudioModelRenderer.h b/cl_dll/StudioModelRenderer.h index 0f91122d..69d28a1e 100644 --- a/cl_dll/StudioModelRenderer.h +++ b/cl_dll/StudioModelRenderer.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/camera.h b/cl_dll/camera.h index 99235ed6..1ecb9563 100644 --- a/cl_dll/camera.h +++ b/cl_dll/camera.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/demo.h b/cl_dll/demo.h index def3616a..3aaa3f21 100644 --- a/cl_dll/demo.h +++ b/cl_dll/demo.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 344d1783..40649fa7 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index ffb1190a..8a836762 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/events.cpp b/cl_dll/events.cpp index a6d21a69..f286d261 100644 --- a/cl_dll/events.cpp +++ b/cl_dll/events.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/eventscripts.h b/cl_dll/eventscripts.h index c4d831e0..c61bf300 100644 --- a/cl_dll/eventscripts.h +++ b/cl_dll/eventscripts.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_iface.h b/cl_dll/hud_iface.h index ae73fc70..73464c83 100644 --- a/cl_dll/hud_iface.h +++ b/cl_dll/hud_iface.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers.cpp b/cl_dll/hud_servers.cpp index 9f940025..fa6d5585 100644 --- a/cl_dll/hud_servers.cpp +++ b/cl_dll/hud_servers.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers.h b/cl_dll/hud_servers.h index 59c60f4c..5e886560 100644 --- a/cl_dll/hud_servers.h +++ b/cl_dll/hud_servers.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_servers_priv.h b/cl_dll/hud_servers_priv.h index c5c9b18e..72590c2f 100644 --- a/cl_dll/hud_servers_priv.h +++ b/cl_dll/hud_servers_priv.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_spectator.cpp b/cl_dll/hud_spectator.cpp index 8f470c0a..edb743ba 100644 --- a/cl_dll/hud_spectator.cpp +++ b/cl_dll/hud_spectator.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/hud_spectator.h b/cl_dll/hud_spectator.h index 2993c3f2..9b3391e2 100644 --- a/cl_dll/hud_spectator.h +++ b/cl_dll/hud_spectator.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/in_camera.cpp b/cl_dll/in_camera.cpp index cf5489c0..12ad41f4 100644 --- a/cl_dll/in_camera.cpp +++ b/cl_dll/in_camera.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/in_defs.h b/cl_dll/in_defs.h index 5b6d7a41..b4c51730 100644 --- a/cl_dll/in_defs.h +++ b/cl_dll/in_defs.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/input.cpp b/cl_dll/input.cpp index 10014082..0abd542b 100644 --- a/cl_dll/input.cpp +++ b/cl_dll/input.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index f530bdbc..bd997784 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/kbutton.h b/cl_dll/kbutton.h index 55fbeee6..4c7c7ae8 100644 --- a/cl_dll/kbutton.h +++ b/cl_dll/kbutton.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/overview.cpp b/cl_dll/overview.cpp index ddfb3cd5..81f028e2 100644 --- a/cl_dll/overview.cpp +++ b/cl_dll/overview.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/overview.h b/cl_dll/overview.h index 88a7a047..c1675e98 100644 --- a/cl_dll/overview.h +++ b/cl_dll/overview.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/studio_util.cpp b/cl_dll/studio_util.cpp index d3a031d4..6e488dcb 100644 --- a/cl_dll/studio_util.cpp +++ b/cl_dll/studio_util.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/studio_util.h b/cl_dll/studio_util.h index 90c84fb4..83de704c 100644 --- a/cl_dll/studio_util.h +++ b/cl_dll/studio_util.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index 6bb4edbe..ab8f3730 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index bda8616d..daecc3af 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/cl_dll/view.h b/cl_dll/view.h index 7d8624c9..6ca818d5 100644 --- a/cl_dll/view.h +++ b/cl_dll/view.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // diff --git a/dlls/playermonster.cpp b/dlls/playermonster.cpp index a6e38389..092e7dca 100644 --- a/dlls/playermonster.cpp +++ b/dlls/playermonster.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/dlls/squad.h b/dlls/squad.h index 607540cf..2c79ee90 100644 --- a/dlls/squad.h +++ b/dlls/squad.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/dlls/stats.cpp b/dlls/stats.cpp index 48804a16..e37832c8 100644 --- a/dlls/stats.cpp +++ b/dlls/stats.cpp @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: New version of the slider bar // diff --git a/pm_shared/pm_movevars.h b/pm_shared/pm_movevars.h index 19b46b1d..53d8ee9c 100644 --- a/pm_shared/pm_movevars.h +++ b/pm_shared/pm_movevars.h @@ -1,4 +1,4 @@ -//========= Copyright © 1996-2002, Valve LLC, All rights reserved. ============ +//========= Copyright (c) 1996-2002, Valve LLC, All rights reserved. ============ // // Purpose: // From 53626b99652070e7e54767cb827afb3d96169aeb Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 20 Jan 2018 17:03:53 +0300 Subject: [PATCH 167/199] Add custom makefont from #46 --- utils/makefont/makefont.cpp | 845 ++++++++++++++++++++++++++++++++++++ utils/makefont/makefont.dsp | 138 ++++++ utils/makefont/winebuild.sh | 3 + 3 files changed, 986 insertions(+) create mode 100644 utils/makefont/makefont.cpp create mode 100644 utils/makefont/makefont.dsp create mode 100755 utils/makefont/winebuild.sh diff --git a/utils/makefont/makefont.cpp b/utils/makefont/makefont.cpp new file mode 100644 index 00000000..eb2eb3ff --- /dev/null +++ b/utils/makefont/makefont.cpp @@ -0,0 +1,845 @@ +/*** +* +* Copyright (c) 1996-2002, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#define _NOENUMQBOOL + +#include + +extern "C" +{ + #include "cmdlib.h" + #include "wadlib.h" +} +#include "qfont.h" + +#define DEFAULT_FONT "Arial" + +#define FONT_TAG 6 // Font's are the 6th tag after the TYP_LUMPY base ( 64 )...i.e., type == 70 + +BOOL bItalic = FALSE; +BOOL bBold = FALSE; +BOOL bUnderline = FALSE; + +char fontname[ 256 ]; +int pointsize[3] = { 9, 11, 15 }; + +/* +================= +zeromalloc + +Allocates and zeroes memory +================= +*/ +void *zeromalloc( size_t size ) +{ + unsigned char *pbuffer; + pbuffer = ( unsigned char * )malloc( size ); + if ( !pbuffer ) + { + printf( "Failed on allocation of %i bytes", size ); + exit( -1 ); + } + + memset( pbuffer, 0, size ); + return ( void * )pbuffer; +} + +/* +================= +Draw_SetupConsolePalette + +Set's the palette to full brightness ( 192 ) and +set's up palette entry 0 -- black +================= +*/ +void Draw_SetupConsolePalette( unsigned char *pal ) +{ + unsigned char *pPalette; + int i; + + pPalette = pal; + + *(short *)pPalette = 3 * 256; + pPalette += sizeof( short ); + + for ( i = 0; i < 256; i++ ) + { + pPalette[3 * i + 0 ] = i; + pPalette[3 * i + 1 ] = i; + pPalette[3 * i + 2 ] = i; + } + + // Set palette zero correctly + pPalette[ 0 ] = 0; + pPalette[ 1 ] = 0; + pPalette[ 2 ] = 0; +} + +//DJXX added for debugging +BOOL WriteDIB(LPTSTR szFile, HANDLE hDIB) +{ + BITMAPFILEHEADER hdr; + LPBITMAPINFOHEADER lpbi; + + if (!hDIB) + return FALSE; + + FILE *file; + file = SafeOpenWrite(szFile); + + + lpbi = (LPBITMAPINFOHEADER)hDIB; + + int nColors = 1 << lpbi->biBitCount; + + // Fill in the fields of the file header + hdr.bfType = ((WORD)('M' << 8) | 'B'); // is always "BM" + hdr.bfSize = GlobalSize(hDIB) + sizeof(hdr); + printf("WriteDIB. Error code = %i\n",GetLastError()); + hdr.bfReserved1 = 0; + hdr.bfReserved2 = 0; + hdr.bfOffBits = (DWORD)(sizeof(hdr)+lpbi->biSize + + nColors * sizeof(RGBQUAD)); + + // Write the file header + SafeWrite(file, &hdr, sizeof(hdr)); + + // Write the DIB header and the bits + SafeWrite(file, lpbi, GlobalSize(hDIB)); + fclose(file); + return TRUE; +} + + +/* +================= +CreateProportionalConsoleFont + +Renders TT font into memory dc and creates appropriate qfont_t structure +================= +*/ +//DJXX: New version, draws chararacters closely to each other without spaces + +// YWB: Sigh, VC 6.0's global optimizer causes weird stack fixups in release builds. Disable the globabl optimizer for this function. +#pragma optimize( "g", off ) +qfont_t *CreateProportionalConsoleFont(char *pszFont, int nPointSize, BOOL bItalic, BOOL bUnderline, BOOL bBold, int *outsize) +{ + HDC hdc; + HDC hmemDC; + HBITMAP hbm, oldbm; + RECT rc; + HFONT fnt, oldfnt; + TEXTMETRIC tm; + int startchar = 32; + int c; + int i, j; + int x, y; + int nScans; + unsigned char *bits; + BITMAPINFO tempbmi; + BITMAPINFO *pbmi; + BITMAPINFOHEADER *pbmheader; + unsigned char *pqdata; + unsigned char *pCur; + int x1, y1; + unsigned char *pPalette; + qfont_t *pqf = NULL; + int fullsize; + int w = 16; + //int h = (128 - 32) / 16; + int h = (256 - 32) / 16; + int charheight = nPointSize + 5; + int charwidth = 16;//now used only for calculating width of wad texture + int fontcharwidth; + int edge = 1; + RECT rcChar; + boolean lShadow = true;//draw shadow instead of outline + + // Create the font + fnt = CreateFont(-nPointSize, 0, 0, 0, bBold ? FW_HEAVY : FW_MEDIUM, bItalic, bUnderline, 0, /*ANSI_CHARSET*/DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH | FF_DONTCARE, pszFont); + + bits = NULL; + + fullsize = sizeof(qfont_t)-4 + (/*128*/256 * w * charwidth) + sizeof(short)+768 + 64; + + // Store off final size + *outsize = fullsize; + + pqf = (qfont_t *)zeromalloc(fullsize); + pqdata = (unsigned char *)pqf + sizeof(qfont_t)-4; + + pPalette = pqdata + (/*128*/256 * w * charwidth); + + // Configure palette + Draw_SetupConsolePalette(pPalette); + + hdc = GetDC(NULL); + hmemDC = CreateCompatibleDC(hdc); + + oldfnt = (HFONT)SelectObject(hmemDC, fnt); + + if (GetTextMetrics(hmemDC, &tm)) + { + fontcharwidth = tm.tmMaxCharWidth; + if (fontcharwidth % 2)//hack: on odd values of fontcharwidth, bitmaps pixel check gives false triggering + fontcharwidth++; + } + else { + fontcharwidth = charwidth; + } + + if (lShadow) + charheight += edge;//adding 1 pixel to bottom for shadowing + + rc.top = 0; + rc.left = 0; + rc.right = fontcharwidth * w; + rc.bottom = charheight * h; + + hbm = CreateBitmap(fontcharwidth * w, charheight * h, 1, 1, NULL); + oldbm = (HBITMAP)SelectObject(hmemDC, hbm); + + SetTextColor(hmemDC, 0x00ffffff); + SetBkMode(hmemDC, TRANSPARENT); + + // Paint black background + FillRect(hmemDC, &rc, (HBRUSH)GetStockObject(BLACK_BRUSH)); + + // Draw character set into memory DC + for (j = 0; j < h; j++) + { + for (i = 0; i < w; i++) + { + x = i * fontcharwidth; + y = j * charheight; + + c = (unsigned char)(startchar + j * w + i); + + // Only draw printable characters, of course + //if ( isprint( c ) && c <= 127 ) + { + // Draw it. + rcChar.left = x + 1; + rcChar.top = y + 1; + rcChar.right = x + fontcharwidth - 1; + rcChar.bottom = y + charheight - 1; + + DrawText(hmemDC, (char *)&c, 1, &rcChar, DT_NOPREFIX | DT_LEFT); + } + } + } + + // Now turn the qfont into raw format + memset(&tempbmi, 0, sizeof(BITMAPINFO)); + + pbmheader = (BITMAPINFOHEADER *)&tempbmi; + + pbmheader->biSize = sizeof(BITMAPINFOHEADER); + pbmheader->biWidth = w * fontcharwidth; + pbmheader->biHeight = -h * charheight; + pbmheader->biPlanes = 1; + pbmheader->biBitCount = 1; + pbmheader->biCompression = BI_RGB; + + // Find out how big the bitmap is + nScans = GetDIBits(hmemDC, hbm, 0, h * charheight, NULL, &tempbmi, DIB_RGB_COLORS); + + // Allocate space for all bits + pbmi = (BITMAPINFO *)zeromalloc(sizeof (BITMAPINFOHEADER)+2 * sizeof(RGBQUAD)+pbmheader->biSizeImage); + + memcpy(pbmi, &tempbmi, sizeof(BITMAPINFO)); + + bits = (unsigned char *)pbmi + sizeof(BITMAPINFOHEADER)+2 * sizeof(RGBQUAD); + + // Now read in bits + nScans = GetDIBits(hmemDC, hbm, 0, h * charheight, bits, pbmi, DIB_RGB_COLORS); + + if (nScans > 0) + { +#if 0 //for debugging + char sz[128];//DJXX write dib to file + sprintf(sz, "font_%s_%i.bmp", pszFont, nPointSize); + WriteDIB(sz, pbmi); +#endif + // Now convert to proper raw format + // + // Now get results from dib + pqf->height = /*128*/256; // Always set to 128 + pqf->width = charwidth; + pqf->rowheight = charheight; + pqf->rowcount = h; + pCur = pqdata; + + // Set everything to index 255 ( 0xff ) == transparent + memset(pCur, 0xFF, w * charwidth * pqf->height); + + int k = 0, dest_x = 0, dest_y = 0; + + for (j = 0; j < h; j++) + for (i = 0; i < w; i++) + { + int rightmost, leftmost, realcharwidth; + + x = i * fontcharwidth; + y = j * charheight; + + //c = (char)( startchar + j * w + i ); here was memory bug + c = (unsigned char)(startchar + j * w + i); + + rightmost = 0; + leftmost = fontcharwidth; + + //Calculate real width of the character + for (y1 = 0; y1 < charheight; y1++) + for (x1 = 0; x1 < fontcharwidth; x1++) + { + int src_offset; + + src_offset = (y + y1) * w * fontcharwidth + x + x1; + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7)))//on odd values of fontcharwidth this check gives false triggering + { + if (x1 > rightmost) + rightmost = x1; + + if (x1 < leftmost) + leftmost = x1; + } + } + if (leftmost > rightmost)//empty characters + { + leftmost = 0; + rightmost = 7; + } else { + rightmost += edge; + if (!lShadow) + leftmost -= edge; + } + + realcharwidth = rightmost - leftmost + 1; + pqf->fontinfo[c].charwidth = realcharwidth; + + if (dest_x + realcharwidth >= w * charwidth)//if it not fits on current line then carry it to the next line + { + dest_x = 0; + k++; + } + + dest_y = k * charheight; + pqf->fontinfo[c].startoffset = dest_y * w * charwidth + dest_x; + + if (lShadow) + { + int shift = edge; + //Draw shadow by shifting character to 1 pixel right and down + for (y1 = 0; y1 < charheight; y1++) + for (x1 = 0; x1 < realcharwidth; x1++) + { + int src_offset, dest_offset; + + src_offset = (y + y1) * w * fontcharwidth + x + x1 + leftmost; + dest_offset = (dest_y + shift + y1) * w * charwidth + (dest_x + shift + x1); + + // Dest + pCur = pqdata + dest_offset; + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7))) + { + // Near Black + //pCur[0] = 32; + pCur[0] = 0;//full black so shadow remains black even it's coloured text + } + } + } + else + { + // Put black pixels below and to the right of each pixel(outline) + for (y1 = edge; y1 < charheight - edge; y1++) + for (x1 = 0; x1 < realcharwidth; x1++) + { + int src_offset, dest_offset; + + int xx0, yy0; + + dest_offset = (dest_y + y1) * w * charwidth + (dest_x + x1); + + // Dest + pCur = pqdata + dest_offset; + + for (xx0 = -edge; xx0 <= edge; xx0++) + for (yy0 = -edge; yy0 <= edge; yy0++) + { + src_offset = (y + y1 + yy0) * w * fontcharwidth + x + x1 + xx0 + leftmost;//adding shift + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7))) + { + // Near Black + pCur[0] = 32; + } + } + } + } + + // Now copy in the actual font pixels + for (y1 = 0; y1 < charheight; y1++) + for (x1 = 0; x1 < realcharwidth; x1++) + { + int src_offset, dest_offset; + + src_offset = (y + y1) * w * fontcharwidth + x + x1 + leftmost; + dest_offset = (dest_y + y1) * w * charwidth + (dest_x + x1); + + // Dest + pCur = pqdata + dest_offset; + + if (bits[src_offset >> 3] & (1 << (7 - src_offset & 7))) + { + pCur[0] = 192; + } + } + dest_x += realcharwidth; + } + } + // Free memory bits + free(pbmi); + SelectObject(hmemDC, oldfnt); + DeleteObject(fnt); + + SelectObject(hmemDC, oldbm); + + DeleteObject(hbm); + + DeleteDC(hmemDC); + ReleaseDC(NULL, hdc); + + return pqf; +} +#pragma optimize( "g", on ) + + +/* +================= +CreateConsoleFont + +Renders TT font into memory dc and creates appropriate qfont_t structure +================= +*/ +//DJXX: original version, just added drawing of locale characters and fixed memory bug. +// YWB: Sigh, VC 6.0's global optimizer causes weird stack fixups in release builds. Disable the globabl optimizer for this function. +#pragma optimize( "g", off ) +qfont_t *CreateConsoleFont( char *pszFont, int nPointSize, BOOL bItalic, BOOL bUnderline, BOOL bBold, int *outsize ) +{ + HDC hdc; + HDC hmemDC; + HBITMAP hbm, oldbm; + RECT rc; + HFONT fnt, oldfnt; + int startchar = 32; + int c; + int i, j; + int x, y; + int nScans; + unsigned char *bits; + BITMAPINFO tempbmi; + BITMAPINFO *pbmi; + BITMAPINFOHEADER *pbmheader; + unsigned char *pqdata; + unsigned char *pCur; + int x1, y1; + unsigned char *pPalette; + qfont_t *pqf = NULL; + int fullsize; + int w = 16; + //int h = (128-32)/16; + int h = (256 - 32) / 16; + int charheight = nPointSize + 5; + int charwidth = 16; + RECT rcChar; + + // Create the font + fnt = CreateFont( -nPointSize, 0, 0, 0, bBold ? FW_HEAVY : FW_MEDIUM, bItalic, bUnderline, 0, /*ANSI_CHARSET*/DEFAULT_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, VARIABLE_PITCH | FF_DONTCARE, pszFont ); + + bits = NULL; + + fullsize = sizeof( qfont_t ) - 4 + ( /*128*/256 * w * charwidth ) + sizeof(short) + 768 + 64; + + // Store off final size + *outsize = fullsize; + + pqf = ( qfont_t * )zeromalloc( fullsize ); + pqdata = (unsigned char *)pqf + sizeof( qfont_t ) - 4; + + pPalette = pqdata + ( /*128*/256 * w * charwidth); + + // Configure palette + Draw_SetupConsolePalette( pPalette ); + + hdc = GetDC( NULL ); + hmemDC = CreateCompatibleDC( hdc ); + + rc.top = 0; + rc.left = 0; + rc.right = charwidth * w; + rc.bottom = charheight * h; + + hbm = CreateBitmap( charwidth * w, charheight * h, 1, 1, NULL ); + oldbm = (HBITMAP)SelectObject( hmemDC, hbm ); + oldfnt = (HFONT)SelectObject( hmemDC, fnt ); + + SetTextColor( hmemDC, 0x00ffffff ); + SetBkMode( hmemDC, TRANSPARENT ); + + // Paint black background + FillRect( hmemDC, &rc, (HBRUSH)GetStockObject( BLACK_BRUSH ) ); + + // Draw character set into memory DC + for ( j = 0; j < h; j++ ) + { + for ( i = 0; i < w; i++ ) + { + x = i * charwidth; + y = j * charheight; + + c = (unsigned char)( startchar + j * w + i ); + + // Only draw printable characters, of course + //if ( isprint( c ) && c <= 127 ) + { + // Draw it. + rcChar.left = x + 1; + rcChar.top = y + 1; + rcChar.right = x + charwidth - 1; + rcChar.bottom = y + charheight - 1; + + DrawText( hmemDC, (char *)&c, 1, &rcChar, DT_NOPREFIX | DT_LEFT ); + } + } + } + + // Now turn the qfont into raw format + memset( &tempbmi, 0, sizeof( BITMAPINFO ) ); + pbmheader = ( BITMAPINFOHEADER * )&tempbmi; + + pbmheader->biSize = sizeof( BITMAPINFOHEADER ); + pbmheader->biWidth = w * charwidth; + pbmheader->biHeight = -h * charheight; + pbmheader->biPlanes = 1; + pbmheader->biBitCount = 1; + pbmheader->biCompression = BI_RGB; + + // Find out how big the bitmap is + nScans = GetDIBits( hmemDC, hbm, 0, h * charheight, NULL, &tempbmi, DIB_RGB_COLORS ); + + // Allocate space for all bits + pbmi = ( BITMAPINFO * )zeromalloc( sizeof ( BITMAPINFOHEADER ) + 2 * sizeof( RGBQUAD ) + pbmheader->biSizeImage ); + + memcpy( pbmi, &tempbmi, sizeof( BITMAPINFO ) ); + + bits = ( unsigned char * )pbmi + sizeof( BITMAPINFOHEADER ) + 2 * sizeof( RGBQUAD ); + + // Now read in bits + nScans = GetDIBits( hmemDC, hbm, 0, h * charheight, bits, pbmi, DIB_RGB_COLORS ); + + if ( nScans > 0 ) + { +#if 0 //for debugging + char sz[128];//DJXX write dib to file + sprintf(sz, "font_%s_%i.bmp", pszFont, nPointSize); + WriteDIB(sz, pbmi); +#endif + + // Now convert to proper raw format + // + // Now get results from dib + pqf->height = /*128*/256; // Always set to 128 + pqf->width = charwidth; + pqf->rowheight = charheight; + pqf->rowcount = h; + pCur = pqdata; + + // Set everything to index 255 ( 0xff ) == transparent + memset( pCur, 0xFF, w * charwidth * pqf->height ); + + for ( j = 0; j < h; j++ ) + { + for ( i = 0; i < w; i++ ) + { + int edge = 1; + int bestwidth; + x = i * charwidth; + y = j * charheight; + + + //c = (char)( startchar + j * w + i ); here was memory bug + c = (unsigned char)(startchar + j * w + i); + + pqf->fontinfo[ c ].charwidth = charwidth; + pqf->fontinfo[ c ].startoffset = y * w * charwidth + x; + + bestwidth = 0; + + // In this first pass, place the black drop shadow so characters draw ok in the engine against + // most backgrounds. + // YWB: FIXME, apply a box filter and enable blending? +#if 0//DJXX: we already did that for a whole image by memset + // Make it all transparent for starters + for ( y1 = 0; y1 < charheight; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + offset = ( y + y1 ) * w * charwidth + x + x1 ; + // Dest + pCur = pqdata + offset; + // Assume transparent + pCur[0] = 255; + } + } +#endif + // Put black pixels below and to the right of each pixel + for ( y1 = edge; y1 < charheight - edge; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + int srcoffset; + + int xx0, yy0; + + offset = ( y + y1 ) * w * charwidth + x + x1 ; + + // Dest + pCur = pqdata + offset; + + for ( xx0 = -edge; xx0 <= edge; xx0++ ) + { + for ( yy0 = -edge; yy0 <= edge; yy0++ ) + { + srcoffset = ( y + y1 + yy0 ) * w * charwidth + x + x1 + xx0; + + if ( bits[ srcoffset >> 3 ] & ( 1 << ( 7 - srcoffset & 7 ) ) ) + { + // Near Black + pCur[0] = 32; + } + } + } + } + } + + // Now copy in the actual font pixels + for ( y1 = 0; y1 < charheight; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + + offset = ( y + y1 ) * w * charwidth + x + x1; + + // Dest + pCur = pqdata + offset; + + if ( bits[ offset >> 3 ] & ( 1 << ( 7 - offset & 7 ) ) ) + { + if ( x1 > bestwidth ) + { + bestwidth = x1; + } + + // Full color + // FIXME: Enable true palette support in engine? + pCur[0] = 192; + } + } + } + + // bestwidth += 1; + /* + // Now blend it + for ( y1 = 0; y1 < charheight; y1++ ) + { + for ( x1 = 0; x1 < charwidth; x1++ ) + { + int offset; + + offset = ( y + y1 ) * w * charwidth + x + x1; + + // Dest + pCur = pqdata + offset; + + if ( bits[ offset >> 3 ] & ( 1 << ( 7 - offset & 7 ) ) ) + { + if ( x1 > bestwidth ) + { + bestwidth = x1; + } + + // Full color + // FIXME: Enable true palette support in engine? + pCur[0] = 192; + } + } + } + */ + + // Space character width + if ( c == 32 ) + { + bestwidth = 8; + } + else + { + // Small characters needs can be padded a bit so they don't run into each other + if ( bestwidth <= 14 ) + { + bestwidth += 2; + } + } + + // Store off width + pqf->fontinfo[ c ].charwidth = bestwidth; + } + } + } + + // Free memory bits + free ( pbmi ); + + SelectObject( hmemDC, oldfnt ); + DeleteObject( fnt ); + + SelectObject( hmemDC, oldbm ); + + DeleteObject( hbm ); + + DeleteDC( hmemDC ); + ReleaseDC( NULL, hdc ); + + return pqf; +} + +#pragma optimize( "g", on ) + +/* +================= +main + +================= +*/ +int main(int argc, char* argv[]) +{ + int i; + DWORD start, end; + char destfile[1024]; + char sz[ 32 ]; + int outsize[ 3 ]; + + qfont_t *fonts[ 3 ]; + + strcpy( fontname, DEFAULT_FONT ); + + printf("makefont.exe Version 2.0 by valve and DJXX (%s)\n", __DATE__ ); + + printf ("----- Creating Console Font ----\n"); + + for (i=1 ; i= argc ) + { + Error( "Makefont: Insufficient point sizes specified\n" ); + } + pointsize[0] = atoi( argv[i+1] ); + pointsize[1] = atoi( argv[i+2] ); + pointsize[2] = atoi( argv[i+3] ); + i += 3; + } + else if (!strcmp(argv[i],"-italic")) + { + bItalic = TRUE; + printf ( "italic set\n"); + } + else if (!strcmp(argv[i],"-bold")) + { + bBold = TRUE; + printf ( "bold set\n"); + } + else if (!strcmp(argv[i],"-underline")) + { + bUnderline = TRUE; + printf ( "underline set\n"); + } + else if ( argv[i][0] == '-' ) + { + Error ("Unknown option \"%s\"", argv[i]); + } + else + break; + } + + if ( i != argc - 1 ) + { + Error ("usage: makefont [-font \"fontname\"] [-italic] [-underline] [-bold] [-pointsizes sm med lg] outfile"); + } + + printf( "Creating %i, %i, and %i point %s fonts\n", pointsize[0], pointsize[1], pointsize[2], fontname ); + + start = timeGetTime(); + + // Create the fonts + for ( i = 0 ; i < 3; i++ ) + { + fonts[ i ] = CreateProportionalConsoleFont( fontname, pointsize[i], bItalic, bUnderline, bBold, &outsize[ i ] ); + //fonts[i] = CreateConsoleFont(fontname, pointsize[i], bItalic, bUnderline, bBold, &outsize[i]); + } + + // Create wad file + strcpy (destfile, argv[argc - 1]); + StripExtension (destfile); + DefaultExtension (destfile, ".wad"); + + NewWad( destfile, false ); + + // Add fonts as lumps + for ( i = 0; i < 3; i++ ) + { + sprintf( sz, "font%i", i ); + AddLump( sz, fonts[ i ], outsize[ i ], TYP_LUMPY + FONT_TAG, false ); + } + + // Store results as a WAD3 + // NOTE: ( should be named fonts.wad in the valve\ subdirectory ) + WriteWad( 3 ); + + // Clean up memory + for ( i = 0 ; i < 3; i++ ) + { + free( fonts[ i ] ); + } + + end = timeGetTime (); + + printf ( "%5.5f seconds elapsed\n", (float)( end - start )/1000.0 ); + + // Display for a second since it might not be running from command prompt + Sleep( 1000 ); + return 0; +} diff --git a/utils/makefont/makefont.dsp b/utils/makefont/makefont.dsp new file mode 100644 index 00000000..aece6e0c --- /dev/null +++ b/utils/makefont/makefont.dsp @@ -0,0 +1,138 @@ +# Microsoft Developer Studio Project File - Name="makefont" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=makefont - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "makefont.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "makefont.mak" CFG="makefont - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "makefont - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "makefont - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "makefont - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /c +# ADD CPP /nologo /W3 /GX /Zi /O2 /I "../../common" /I "../common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX"qfont.h" /FD /c +# ADD BASE RSC /l 0x409 /d "NDEBUG" +# ADD RSC /l 0x409 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 +# Begin Special Build Tool +TargetPath=.\Release\makefont.exe +SOURCE="$(InputPath)" +PostBuild_Desc=Copyint to valve\ +PostBuild_Cmds=xcopy $(TargetPath) ..\..\..\valve /r /i +# End Special Build Tool + +!ELSEIF "$(CFG)" == "makefont - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /Yu"stdafx.h" /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../../common" /I "../common" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX"qfont.h" /FD /GZ /c +# ADD BASE RSC /l 0x409 /d "_DEBUG" +# ADD RSC /l 0x409 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# Begin Special Build Tool +TargetPath=.\Debug\makefont.exe +SOURCE="$(InputPath)" +PostBuild_Desc=Copyint to valve\ +PostBuild_Cmds=xcopy $(TargetPath) ..\..\..\valve /r /i +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "makefont - Win32 Release" +# Name "makefont - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=..\common\cmdlib.c +# End Source File +# Begin Source File + +SOURCE=.\makefont.cpp +# End Source File +# Begin Source File + +SOURCE=..\common\wadlib.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=..\common\cmdlib.h +# End Source File +# Begin Source File + +SOURCE=.\StdAfx.h +# End Source File +# Begin Source File + +SOURCE=..\common\wadlib.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# Begin Source File + +SOURCE=.\ReadMe.txt +# End Source File +# End Target +# End Project diff --git a/utils/makefont/winebuild.sh b/utils/makefont/winebuild.sh new file mode 100755 index 00000000..ec259577 --- /dev/null +++ b/utils/makefont/winebuild.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +winegcc -g -m32 makefont.cpp ../common/wadlib.c ../common/cmdlib.c -I../common/ -I../../common/ -mwindows -mno-cygwin -lwinmm -fno-stack-protector From 588065ab162693a30569d07089b46d7d17ca66d9 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 15 Feb 2018 17:27:02 +0500 Subject: [PATCH 168/199] Do not show long nicknames on low resolution. --- cl_dll/scoreboard.cpp | 65 ++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 908d00f3..0f26c6f2 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -92,17 +92,18 @@ We have a minimum width of 1-320 - we could have the field widths scale with it? // X positions // relative to the side of the scoreboard -#define NAME_RANGE_MIN -65 -#define NAME_RANGE_MAX 180 -#define KILLS_RANGE_MIN 165 -#define KILLS_RANGE_MAX 205 -#define DIVIDER_POS 215 -#define DEATHS_RANGE_MIN 220 -#define DEATHS_RANGE_MAX 245 -#define PING_RANGE_MIN 280 -#define PING_RANGE_MAX 330 -#define PL_RANGE_MIN 350 -#define PL_RANGE_MAX 410 +#define NAME_RANGE_MIN 20 +#define NAME_RANGE_MAX 145 +#define NAME_RANGE_MODIFIER 120 +#define KILLS_RANGE_MIN 130 +#define KILLS_RANGE_MAX 170 +#define DIVIDER_POS 180 +#define DEATHS_RANGE_MIN 185 +#define DEATHS_RANGE_MAX 210 +#define PING_RANGE_MIN 245 +#define PING_RANGE_MAX 295 +#define PL_RANGE_MIN 315 +#define PL_RANGE_MAX 375 int SCOREBOARD_WIDTH = 320; @@ -128,11 +129,11 @@ int CHudScoreboard::Draw( float fTime ) if( cl_showpacketloss && cl_showpacketloss->value && ( ScreenWidth >= 400 ) ) { can_show_packetloss = 1; - SCOREBOARD_WIDTH = 400; + SCOREBOARD_WIDTH = ( ScreenWidth >= 520 ) ? ( 400 - NAME_RANGE_MODIFIER ) : 400; } else { - SCOREBOARD_WIDTH = 320; + SCOREBOARD_WIDTH = ( ScreenWidth >= 440 ) ? ( 320 - NAME_RANGE_MODIFIER ) : 320; } // just sort the list on the fly @@ -145,7 +146,14 @@ int CHudScoreboard::Draw( float fTime ) int xpos = NAME_RANGE_MIN + xpos_rel; FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; - FAR_RIGHT += 125; + FAR_RIGHT += 5; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + xpos -= NAME_RANGE_MODIFIER; + FAR_RIGHT += NAME_RANGE_MODIFIER; + } + if( cl_scoreboard_bg && cl_scoreboard_bg->value ) gHUD.DrawDarkRectangle( xpos - 5, ypos - 5, FAR_RIGHT, ROW_RANGE_MAX ); if( !gHUD.m_Teamplay ) @@ -165,7 +173,7 @@ int CHudScoreboard::Draw( float fTime ) list_slot += 1.2; ypos = ROW_RANGE_MIN + ( list_slot * ROW_GAP ); - xpos = NAME_RANGE_MIN + xpos_rel; + // xpos = NAME_RANGE_MIN + xpos_rel; FillRGBA( xpos - 4, ypos, FAR_RIGHT -2, 1, 255, 140, 0, 255 ); // draw the seperator line list_slot += 0.8; @@ -266,12 +274,18 @@ int CHudScoreboard::Draw( float fTime ) break; xpos = NAME_RANGE_MIN + xpos_rel; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + xpos -= NAME_RANGE_MODIFIER; + } + int r = 255, g = 225, b = 55; // draw the stuff kinda yellowish if( team_info->ownteam ) // if it is their team, draw the background different color { // overlay the background in blue, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); } // draw their name (left to right) @@ -340,7 +354,12 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, } FAR_RIGHT = can_show_packetloss ? PL_RANGE_MAX : PING_RANGE_MAX; - FAR_RIGHT += 125; + FAR_RIGHT += 5; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + FAR_RIGHT += NAME_RANGE_MODIFIER; + } // draw the players, in order, and restricted to team if set while( 1 ) @@ -380,6 +399,12 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, break; int xpos = NAME_RANGE_MIN + xpos_rel; + + if( ( ScreenWidth >= 440 && !can_show_packetloss ) || ( ScreenWidth >= 520 && can_show_packetloss ) ) + { + xpos -= NAME_RANGE_MODIFIER; + } + int r = 255, g = 255, b = 255; float *colors = GetClientColor( best_player ); r *= colors[0], g *= colors[1], b *= colors[2]; @@ -388,18 +413,18 @@ int CHudScoreboard::DrawPlayers( int xpos_rel, float list_slot, int nameoffset, if( pl_info->thisplayer ) { // green is the suicide color? i wish this could do grey... - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 80, 155, 0, 70 ); } else { // Highlight the killers name - overlay the background in red, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 255, 0, 0, ( (float)15 * (float)( m_fLastKillTime - gHUD.m_flTime ) ) ); } } else if( pl_info->thisplayer ) // if it is their name, draw it a different color { // overlay the background in blue, then draw the score text over it - FillRGBA( NAME_RANGE_MIN + xpos_rel - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); + FillRGBA( xpos - 5, ypos, FAR_RIGHT, ROW_GAP, 0, 0, 255, 70 ); } // draw their name (left to right) From f13adcfb8b7dc11d365389bc01ee3290f1d4ff26 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 15 Feb 2018 17:52:07 +0500 Subject: [PATCH 169/199] Fix infinite slide in multiplayer. --- pm_shared/pm_shared.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index 9aed8093..abe7b317 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -3312,8 +3312,8 @@ void PM_Move( struct playermove_s *ppmove, int server ) pmove->flags &= ~FL_ONGROUND; } - // In single player, reset friction after each movement to FrictionModifier Triggers work still. - if( !pmove->multiplayer && ( pmove->movetype == MOVETYPE_WALK ) ) + // Reset friction after each movement to FrictionModifier Triggers work still. + if( pmove->movetype == MOVETYPE_WALK ) { pmove->friction = 1.0f; } From 556e2647fe0ba801c75bf810e41ef58c5eb90c34 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 15 Feb 2018 18:15:02 +0500 Subject: [PATCH 170/199] Do not show train controls after player death. --- dlls/player.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 52f5f546..99d4c7f6 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -782,6 +782,9 @@ void CBasePlayer::PackDeadPlayerItems( void ) void CBasePlayer::RemoveAllItems( BOOL removeSuit ) { + int i; + CBasePlayerItem *pPendingItem; + if( m_pActiveItem ) { ResetAutoaim(); @@ -794,8 +797,8 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) if( m_pTank != 0 ) m_pTank->Use( this, this, USE_OFF, 0 ); - int i; - CBasePlayerItem *pPendingItem; + m_iTrain = TRAIN_NEW; // turn off train + for( i = 0; i < MAX_ITEM_TYPES; i++ ) { m_pActiveItem = m_rgpPlayerItems[i]; From ccbc147c90bd530ef04af79a794fc6affb4c535e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 3 Mar 2018 23:58:19 +0300 Subject: [PATCH 171/199] Fix Battery message spam when armorvalue goes fractional --- dlls/player.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/player.cpp b/dlls/player.cpp index 99d4c7f6..bbd668ba 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -3935,7 +3935,7 @@ void CBasePlayer::UpdateClientData( void ) m_iClientHealth = (int)pev->health; } - if( pev->armorvalue != m_iClientBattery ) + if( (int)pev->armorvalue != m_iClientBattery ) { m_iClientBattery = (int)pev->armorvalue; From 4538ba1c19e0a3dd4898c3410ae751c821347b2e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:12:44 +0300 Subject: [PATCH 172/199] Force XP toolchain in newer Visual Studio --- CMakeLists.txt | 6 ++++++ cmake/VSForceXPToolchain.cmake | 29 +++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+) create mode 100644 cmake/VSForceXPToolchain.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e025342a..3403cfbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,12 @@ # cmake_minimum_required(VERSION 2.6.0) + +# Install custom module path +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") + +include(VSForceXPToolchain) # Force XP toolchain for Visual Studio + project (HLSDK-XASH3D) #-------------- diff --git a/cmake/VSForceXPToolchain.cmake b/cmake/VSForceXPToolchain.cmake new file mode 100644 index 00000000..e78fb0a2 --- /dev/null +++ b/cmake/VSForceXPToolchain.cmake @@ -0,0 +1,29 @@ +if(WIN32) + # Windows XP compatible platform toolset. Must be set before project(), + # otherwise change of CMAKE_*_TOOLSET will take no effect. + # We get VS version from the generator name because neither MSVC* nor other + # variables that describe the compiler aren't available before project(). + if ("${CMAKE_GENERATOR}" MATCHES "Visual Studio ([0-9]+)") + if(${CMAKE_MATCH_1} LESS 11) + # Nothing. Older VS does support XP by default. + elseif(${CMAKE_MATCH_1} EQUAL 11) + # Visual Studio 11 2012 + set(CMAKE_GENERATOR_TOOLSET "v110_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAK_VS_PLATFORM_TOOLSET "v110_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + elseif (${CMAKE_MATCH_1} EQUAL 12) + # Visual Studio 12 2013 + set(CMAKE_GENERATOR_TOOLSET "v120_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAKE_VS_PLATFORM_TOOLSET "v120_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + elseif (${CMAKE_MATCH_1} EQUAL 14) + # Visual Studio 14 2015 + set(CMAKE_GENERATOR_TOOLSET "v140_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAKE_VS_PLATFORM_TOOLSET "v140_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + elseif (${CMAKE_MATCH_1} EQUAL 15) + # Visual Studio 15 2017 + set(CMAKE_GENERATOR_TOOLSET "v141_xp" CACHE STRING "CMAKE_GENERATOR_TOOLSET" FORCE) + set(CMAKE_VS_PLATFORM_TOOLSET "v141_xp" CACHE STRING "CMAKE_VS_PLATFORM_TOOLSET" FORCE) + else() + message(WARNING "WARNING: You maybe building without Windows XP compability. See which toolchain version Visual Studio provides, and say cmake to use it: cmake -G \"Visual Studio XX\" -T \"vXXX_xp\"") + endif() + endif() +endif() From 81d31cdbd19c7fb744c8fb981321bfcdedb1006b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:13:52 +0300 Subject: [PATCH 173/199] Add appveyor --- appveyor.yml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 appveyor.yml diff --git a/appveyor.yml b/appveyor.yml new file mode 100644 index 00000000..eb39ee2d --- /dev/null +++ b/appveyor.yml @@ -0,0 +1,28 @@ +version: 1.0.{build} + +branches: + only: + - master + +environment: + matrix: + - os: Visual Studio 2013 + GENERATOR_NAME: "Visual Studio 12 2013" + - os: Visual Studio 2015 + GENERATOR_NAME: "Visual Studio 14 2015" +# TODO: Uncomment when AppVeyor will provide XP toolchain for VS2017 +# - os: Visual Studio 2017 +# GENERATOR_NAME: "Visual Studio 15 2017" + +clone_folder: c:\projects\xash\hlsdk-xash3d + +build: + project: INSTALL.vcxproj + verbosity: normal + +configuration: + - Debug + +before_build: + - git submodule update --init --recursive + - cmake -G "%GENERATOR_NAME%" From d52b03a9c465436dc78b012eca1677eeec8bad61 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:18:05 +0300 Subject: [PATCH 174/199] Add AppVeyor build status --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9261b1b3..a57d94b5 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Half-Life SDK for Xash3D [![Build Status](https://travis-ci.org/FWGS/hlsdk-xash3d.svg)](https://travis-ci.org/FWGS/hlsdk-xash3d) +# Half-Life SDK for Xash3D [![Build Status](https://travis-ci.org/FWGS/hlsdk-xash3d.svg)](https://travis-ci.org/FWGS/hlsdk-xash3d) [![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/FWGS/hlsdk-xash3d?svg=true)](https://ci.appveyor.com/project/a1batross/hlsdk-xash3d) Half-Life SDK for Xash3D & GoldSource with some fixes. @@ -31,7 +31,7 @@ These scripts also can be ran via wine: The libraries built this way are always GoldSource compatible. -There're dsp projects for MVS 6 in `cl_dll` and `dlls` directories, but we don't keep them up-to-date. You're free to adapt them for yourself and try to import into the newer MVS versions. +There're dsp projects for Visual Studio 6 in `cl_dll` and `dlls` directories, but we don't keep them up-to-date. You're free to adapt them for yourself and try to import into the newer Visual Studio versions. #### Using mingw @@ -44,7 +44,7 @@ TODO ### OS X -TODO +Nothing here. ### FreeBSD From 6818ff091df1f4aae12ec784b5467bc4016e4f35 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:21:05 +0300 Subject: [PATCH 175/199] Remove cast pointer to size_t in cbase.h, it's useless here --- dlls/cbase.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dlls/cbase.h b/dlls/cbase.h index 4cf40abd..e200d7b0 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -283,7 +283,7 @@ public: #ifdef _DEBUG void FunctionCheck( void *pFunction, char *name ) { - if( pFunction && !NAME_FOR_FUNCTION( (size_t)( pFunction ) ) ) + if( pFunction && !NAME_FOR_FUNCTION( pFunction ) ) ALERT( at_error, "No EXPORT: %s:%s (%08lx)\n", STRING( pev->classname ), name, (size_t)pFunction ); } From 6161c6d4d834f1eac22b1e16aad86ab5ecf6971b Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sun, 4 Mar 2018 00:24:54 +0300 Subject: [PATCH 176/199] Replace snprintf by _snprintf, for MSVC --- cl_dll/text_message.cpp | 8 ++++---- dlls/client.cpp | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/cl_dll/text_message.cpp b/cl_dll/text_message.cpp index b959fc87..512623dd 100644 --- a/cl_dll/text_message.cpp +++ b/cl_dll/text_message.cpp @@ -181,20 +181,20 @@ int CHudTextMessage::MsgFunc_TextMsg( const char *pszName, int iSize, void *pbuf switch( msg_dest ) { case HUD_PRINTCENTER: - snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); CenterPrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTNOTIFY: psz[0] = 1; // mark this message to go into the notify buffer - snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + _snprintf( psz + 1, MSG_BUF_SIZE - 1, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; case HUD_PRINTTALK: - snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); gHUD.m_SayText.SayTextPrint( ConvertCRtoNL( psz ), MSG_BUF_SIZE ); break; case HUD_PRINTCONSOLE: - snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); + _snprintf( psz, MSG_BUF_SIZE, szBuf[0], szBuf[1], szBuf[2], szBuf[3], szBuf[4] ); ConsolePrint( ConvertCRtoNL( psz ) ); break; } diff --git a/dlls/client.cpp b/dlls/client.cpp index 578534e3..1e7dab72 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -108,7 +108,7 @@ void ClientDisconnect( edict_t *pEntity ) char text[256] = ""; if( pEntity->v.netname ) - snprintf( text, sizeof(text), "- %s has left the game\n", STRING( pEntity->v.netname ) ); + _snprintf( text, sizeof(text), "- %s has left the game\n", STRING( pEntity->v.netname ) ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); @@ -660,7 +660,7 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) if( gpGlobals->maxClients > 1 ) { char text[256]; - snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); + _snprintf( text, 256, "* %s changed name to %s\n", STRING( pEntity->v.netname ), g_engfuncs.pfnInfoKeyValue( infobuffer, "name" ) ); MESSAGE_BEGIN( MSG_ALL, gmsgSayText, NULL ); WRITE_BYTE( ENTINDEX( pEntity ) ); WRITE_STRING( text ); From 4af903015604bbbbaf9b861fbd2e2b565520bcd1 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Thu, 22 Mar 2018 15:23:34 +0300 Subject: [PATCH 177/199] Append 64 postfix on 64 bit --- CMakeLists.txt | 3 ++- cl_dll/CMakeLists.txt | 7 ++++++- dlls/CMakeLists.txt | 7 ++++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3403cfbd..705025bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,7 @@ project (HLSDK-XASH3D) #-------------- # USER DEFINES \ ################\ +option(64BIT "Allow 64 Bit builds" OFF) option(USE_VGUI "Enable VGUI1. UNDONE" OFF) option(USE_VGUI2 "Enable VGUI2. UNDONE" OFF) option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) @@ -50,7 +51,7 @@ set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows" set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") # Build 32-bit Xash on 64-bit, because Xash3D not support this -if(CMAKE_SIZEOF_VOID_P EQUAL 8) +if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) error("UNDONE: set 32 build flags") else() diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 05990913..b848aa6c 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -125,8 +125,13 @@ set_target_properties (${CLDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(CLDLL_NAME "client") + if(64BIT) + set(CLDLL_NAME "client64") + endif() + set_target_properties(${CLDLL_LIBRARY} PROPERTIES - OUTPUT_NAME "client" + OUTPUT_NAME ${CLDLL_NAME} PREFIX "") endif() diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index bf7d3370..55370eeb 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -157,8 +157,13 @@ set_target_properties (${SVDLL_LIBRARY} PROPERTIES POSITION_INDEPENDENT_CODE 1) if(APPLE OR WIN32 OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux") + set(SVDLL_NAME "${SERVER_LIBRARY_NAME}") + if(64BIT) + set(SVDLL_NAME "${SERVER_LIBRARY_NAME}64") + endif() + set_target_properties(${SVDLL_LIBRARY} PROPERTIES - OUTPUT_NAME ${SERVER_LIBRARY_NAME} + OUTPUT_NAME ${SVDLL_NAME} PREFIX "") endif() From bc379e92343ae52d44c152baaf176e32f8ed9765 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 23 Mar 2018 23:08:38 +0300 Subject: [PATCH 178/199] Add 64/32 bit message and a dumb check when 32 bit isn't properly enabled --- CMakeLists.txt | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 705025bf..bd7fe664 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,6 +39,7 @@ option(USE_VOICEMGR "Enable VOICE MANAGER." OFF) option(BUILD_CLIENT "Build client dll" ON) option(BUILD_SERVER "Build server dll" ON) option(GOLDSOURCE_SUPPORT "Build goldsource compatible client library" OFF) +option(64BIT "Disable auto -m32 appending to compiler flags" OFF) set(GAMEDIR "valve" CACHE STRING "Gamedir path") set(SERVER_INSTALL_DIR "dlls" CACHE STRING "Where put server dll") set(CLIENT_INSTALL_DIR "cl_dlls" CACHE STRING "Where put client dll") @@ -50,25 +51,35 @@ set(SERVER_LIBRARY_NAME "hl" CACHE STRING "Library name for Linux/MacOS/Windows" set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") -# Build 32-bit Xash on 64-bit, because Xash3D not support this if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) - error("UNDONE: set 32 build flags") + error("UNDONE: set 32 build flags") else() - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") endif() + set(CMAKE_SIZEOF_VOID_P 4) +endif() + +if(64BIT AND CMAKE_SIZEOF_VOID_P EQUAL 4) + message(FATAL_ERROR "You enabled XASH_64BIT, but compiler can't create 64 bit code!") +endif() + +if(64BIT) + message(STATUS "Building for 64 Bit") +else() + message(STATUS "Building for 32 Bit") endif() # add_compile_options for older cmake versions if(${CMAKE_VERSION} VERSION_LESS "3.0.2") -macro(add_compile_options) - set(list_var "${ARGV}") - foreach(arg IN LISTS list_var) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") - endforeach() -endmacro() + macro(add_compile_options) + set(list_var "${ARGV}") + foreach(arg IN LISTS list_var) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${arg}") + endforeach() + endmacro() endif() if(BUILD_CLIENT) From 3401f54148e4001b4aa893e92695b17d93b0b53e Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Fri, 23 Mar 2018 23:46:05 +0300 Subject: [PATCH 179/199] Fix Android buil --- cl_dll/Android.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 68917633..df6130ed 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -92,7 +92,7 @@ SRCS+=./input_xash3d.cpp SRCS+=./scoreboard.cpp SRCS+=./MOTD.cpp INCLUDES = -I../common -I. -I../game_shared -I../pm_shared -I../engine -I../dlls -I../utils/false_vgui/include -DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w +DEFINES = -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w -D_snprintf=snprintf LOCAL_C_INCLUDES := $(LOCAL_PATH)/. \ $(LOCAL_PATH)/../common \ From 5103cec6c12d09980f14c51f447b8ecf32b26a83 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 31 Mar 2018 03:03:53 +0500 Subject: [PATCH 180/199] Fix weapons id. --- dlls/weapons.h | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/dlls/weapons.h b/dlls/weapons.h index 93c1ac25..f0497044 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -63,16 +63,13 @@ public: #define ITEM_BATTERY 4 #define WEAPON_NONE 0 -#define WEAPON_HEATERPIPE 2 -#define WEAPON_BRADNAILER 3 -#define WEAPON_NAILGUN 4 -#define WEAPON_SHOTGUN 5 -#define WEAPON_CMLWBR 6 -#define WEAPON_XS 7 -#define WEAPON_PIPEBOMB 8 -#define WEAPON_PAR21 9 -#define WEAPON_CROWBAR 10 -#define WEAPON_SATCHEL 11 +#define WEAPON_CROWBAR 1 +#define WEAPON_GLOCK 2 +#define WEAPON_MP5 4 +#define WEAPON_CROSSBOW 6 +#define WEAPON_SHOTGUN 7 +#define WEAPON_GAUSS 9 +#define WEAPON_SATCHEL 14 #define WEAPON_ALLWEAPONS (~(1< Date: Sat, 31 Mar 2018 03:08:08 +0500 Subject: [PATCH 181/199] Do not use client weapons. --- cl_dll/CMakeLists.txt | 22 +--------------------- cl_dll/hl/hl_weapons.cpp | 38 -------------------------------------- dlls/CMakeLists.txt | 2 +- 3 files changed, 2 insertions(+), 60 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 57cc2dee..60a86f4c 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -25,33 +25,13 @@ project (CLDLL) set (CLDLL_LIBRARY client) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_WEAPONS -DCLIENT_DLL -w") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -DLINUX -D_LINUX -Dstricmp=strcasecmp -D_strnicmp=strncasecmp -Dstrnicmp=strncasecmp -DCLIENT_DLL -w") if (GOLDSOURCE_SUPPORT) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DGOLDSOURCE_SUPPORT") endif() set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") set (CLDLL_SOURCES - ../dlls/crossbow.cpp - ../dlls/crowbar.cpp -# ../dlls/egon.cpp -# ../dlls/gauss.cpp -# ../dlls/handgrenade.cpp -# ../dlls/hornetgun.cpp -# ../dlls/mp5.cpp -# ../dlls/python.cpp - ../dlls/rpg.cpp - ../dlls/satchel.cpp - ../dlls/shotgun.cpp - ../dlls/squeakgrenade.cpp - ../dlls/tripmine.cpp -# ../dlls/glock.cpp - ../dlls/poke646/bradnailer.cpp - ../dlls/poke646/cmlwbr.cpp - ../dlls/poke646/heaterpipe.cpp - ../dlls/poke646/nailgun.cpp - ../dlls/poke646/weapon_pipebomb.cpp - ../dlls/poke646/xensquasher.cpp ev_hldm.cpp hl/hl_baseentity.cpp hl/hl_events.cpp diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 59e74638..f9c09096 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -53,13 +53,6 @@ int g_irunninggausspred = 0; vec3_t previousorigin; // HLDM Weapon placeholder entities. -CHeaterPipe g_HeaterPipe; -CCmlwbr g_Cmlwbr; -CShotgun g_Shotgun; -CPipeBomb g_PipeBomb; -CBradnailer g_Bradnailer; -CNailgun g_Nailgun; -CXenSquasher g_Xs; /* ====================== AlertMessage @@ -594,13 +587,6 @@ void HUD_InitClientWeapons( void ) HUD_PrepEntity( &player, NULL ); // Allocate slot(s) for each weapon that we are going to be predicting - HUD_PrepEntity( &g_HeaterPipe, &player ); - HUD_PrepEntity( &g_Shotgun, &player ); - HUD_PrepEntity( &g_Cmlwbr, &player ); - HUD_PrepEntity( &g_PipeBomb, &player ); - HUD_PrepEntity( &g_Bradnailer, &player ); - HUD_PrepEntity( &g_Nailgun, &player ); - HUD_PrepEntity( &g_Xs, &player ); } /* @@ -662,30 +648,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm // Fill in data based on selected weapon // FIXME, make this a method in each weapon? where you pass in an entity_state_t *? - switch( from->client.m_iId ) - { - case WEAPON_HEATERPIPE: - pWeapon = &g_HeaterPipe; - break; - case WEAPON_SHOTGUN: - pWeapon = &g_Shotgun; - break; - case WEAPON_CMLWBR: - pWeapon = &g_Cmlwbr; - break; - case WEAPON_PIPEBOMB: - pWeapon = &g_PipeBomb; - break; - case WEAPON_BRADNAILER: - pWeapon = &g_Bradnailer; - break; - case WEAPON_NAILGUN: - pWeapon = &g_Nailgun; - break; - case WEAPON_XS: - pWeapon = &g_Xs; - break; - } // Store pointer to our destination entity_state_t so we can get our origin, etc. from it // for setting up events on the client diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 3dec6998..3ae6568c 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -25,7 +25,7 @@ project (SVDLL) set (SVDLL_LIBRARY server) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -fno-exceptions -w") +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_LINUX -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf -fno-exceptions -w") set(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") set (SVDLL_SOURCES From fc743d866e11c706aba3d250a36ce8767dbf9198 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sat, 31 Mar 2018 03:14:51 +0500 Subject: [PATCH 182/199] Remove useless events. --- cl_dll/ev_hldm.cpp | 1362 --------------------------------------- cl_dll/hl/hl_events.cpp | 42 -- 2 files changed, 1404 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 862c7f87..1c16656f 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -53,31 +53,10 @@ extern "C" void EV_FireGlock1( struct event_args_s *args ); void EV_FireGlock2( struct event_args_s *args ); void EV_FireShotGunSingle( struct event_args_s *args ); -void EV_FireShotGunDouble( struct event_args_s *args ); -void EV_FireMP5( struct event_args_s *args ); -void EV_FireMP52( struct event_args_s *args ); -void EV_FirePython( struct event_args_s *args ); -void EV_FireGauss( struct event_args_s *args ); -void EV_SpinGauss( struct event_args_s *args ); -void EV_Crowbar( struct event_args_s *args ); -void EV_FireCrossbow( struct event_args_s *args ); -void EV_FireCrossbow2( struct event_args_s *args ); -void EV_FireRpg( struct event_args_s *args ); -void EV_EgonFire( struct event_args_s *args ); -void EV_EgonStop( struct event_args_s *args ); -void EV_HornetGunFire( struct event_args_s *args ); -void EV_TripmineFire( struct event_args_s *args ); -void EV_SnarkFire( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); -void EV_HeaterPipe(struct event_args_s *args); -void EV_FireBradnailer(struct event_args_s *args); -void EV_FireNailgun(struct event_args_s *args); -void EV_FireCmlwbr(struct event_args_s *args); void EV_SpinXS(struct event_args_s *args); -void EV_FireXS(struct event_args_s *args); -void EV_Reload(struct event_args_s *args); } #define VECTOR_CONE_1DEGREES Vector( 0.00873, 0.00873, 0.00873 ) @@ -617,10 +596,6 @@ void EV_FireGlock2( event_args_t *args ) //====================== // SHOTGUN START //====================== -void EV_FireShotGunDouble( event_args_t *args ) -{ -} - void EV_FireShotGunSingle( event_args_t *args ) { int idx; @@ -676,1031 +651,6 @@ void EV_FireShotGunSingle( event_args_t *args ) // SHOTGUN END //====================== -//====================== -// MP5 START -//====================== -void EV_FireMP5( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - vec3_t ShellVelocity; - vec3_t ShellOrigin; - int shell; - vec3_t vecSrc, vecAiming; - vec3_t up, right, forward; - //float flSpread = 0.01; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - AngleVectors( angles, forward, right, up ); - - shell = gEngfuncs.pEventAPI->EV_FindModelIndex("models/shell.mdl");// brass shell - - if( EV_IsLocal( idx ) ) - { - // Add muzzle flash to current weapon model - EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_FIRE1 + gEngfuncs.pfnRandomLong( 0, 2 ), 2 ); - - V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) ); - } - - EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 20, -12, 4 ); - - EV_EjectBrass ( ShellOrigin, ShellVelocity, angles[YAW], shell, TE_BOUNCE_SHELL ); - - switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/hks1.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/hks2.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - } - - EV_GetGunPosition( args, vecSrc, origin ); - VectorCopy( forward, vecAiming ); - - if( gEngfuncs.GetMaxClients() > 1 ) - { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); - } - else - { - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_MP5, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); - } -} - -// We only predict the animation and sound -// The grenade is still launched from the server. -void EV_FireMP52( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( MP5_LAUNCH, 2 ); - V_PunchAxis( 0, -10 ); - } - - switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/glauncher.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/glauncher2.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - break; - } -} -//====================== -// MP5 END -//====================== - -//====================== -// PHYTON START -// ( .357 ) -//====================== -void EV_FirePython( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - vec3_t vecSrc, vecAiming; - vec3_t up, right, forward; - //float flSpread = 0.01; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - AngleVectors( angles, forward, right, up ); - - if( EV_IsLocal( idx ) ) - { - // Python uses different body in multiplayer versus single player - int multiplayer = gEngfuncs.GetMaxClients() == 1 ? 0 : 1; - - // Add muzzle flash to current weapon model - EV_MuzzleFlash(); - gEngfuncs.pEventAPI->EV_WeaponAnimation( PYTHON_FIRE1, multiplayer ? 1 : 0 ); - - V_PunchAxis( 0, -10.0 ); - } - - switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/357_shot1.wav", gEngfuncs.pfnRandomFloat( 0.8, 0.9 ), ATTN_NORM, 0, PITCH_NORM ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/357_shot2.wav", gEngfuncs.pfnRandomFloat( 0.8, 0.9 ), ATTN_NORM, 0, PITCH_NORM ); - break; - } - - EV_GetGunPosition( args, vecSrc, origin ); - - VectorCopy( forward, vecAiming ); - - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_357, 0, 0, args->fparam1, args->fparam2 ); -} -//====================== -// PHYTON END -// ( .357 ) -//====================== - -//====================== -// GAUSS START -//====================== -#define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch - -void EV_SpinGauss( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - int iSoundState = 0; - - int pitch; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - pitch = args->iparam1; - - iSoundState = args->bparam1 ? SND_CHANGE_PITCH : 0; - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "ambience/pulsemachine.wav", 1.0, ATTN_NORM, iSoundState, pitch ); -} - -/* -============================== -EV_StopPreviousGauss - -============================== -*/ -void EV_StopPreviousGauss( int idx ) -{ - // Make sure we don't have a gauss spin event in the queue for this guy - gEngfuncs.pEventAPI->EV_KillEvents( idx, "events/gaussspin.sc" ); - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_WEAPON, "ambience/pulsemachine.wav" ); -} - -extern float g_flApplyVel; - -void EV_FireGauss( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - float flDamage = args->fparam1; - //int primaryfire = args->bparam1; - - int m_fPrimaryFire = args->bparam1; - //int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; - vec3_t vecSrc; - vec3_t vecDest; - //edict_t *pentIgnore; - pmtrace_t tr, beam_tr; - float flMaxFrac = 1.0; - //int nTotal = 0; - int fHasPunched = 0; - int fFirstBeam = 1; - int nMaxHits = 10; - physent_t *pEntity; - int m_iBeam, m_iGlow, m_iBalls; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - if( args->bparam2 ) - { - EV_StopPreviousGauss( idx ); - return; - } - - //Con_Printf( "Firing gauss with %f\n", flDamage ); - EV_GetGunPosition( args, vecSrc, origin ); - - m_iBeam = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/smoke.spr" ); - m_iBalls = m_iGlow = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/hotglow.spr" ); - - AngleVectors( angles, forward, right, up ); - - VectorMA( vecSrc, 8192, forward, vecDest ); - - if( EV_IsLocal( idx ) ) - { - V_PunchAxis( 0, -2.0 ); - gEngfuncs.pEventAPI->EV_WeaponAnimation( GAUSS_FIRE2, 2 ); - - if( m_fPrimaryFire == false ) - g_flApplyVel = flDamage; - } - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/gauss2.wav", 0.5 + flDamage * ( 1.0 / 400.0 ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); - - while( flDamage > 10 && nMaxHits > 0 ) - { - nMaxHits--; - - gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - 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_PopPMStates(); - - if( tr.allsolid ) - break; - - if( fFirstBeam ) - { - if( EV_IsLocal( idx ) ) - { - // Add muzzle flash to current weapon model - EV_MuzzleFlash(); - } - fFirstBeam = 0; - - gEngfuncs.pEfxAPI->R_BeamEntPoint( - idx | 0x1000, - tr.endpos, - m_iBeam, - 0.1, - m_fPrimaryFire ? 1.0 : 2.5, - 0.0, - m_fPrimaryFire ? 128.0 : flDamage, - 0, - 0, - 0, - m_fPrimaryFire ? 255 : 255, - m_fPrimaryFire ? 128 : 255, - m_fPrimaryFire ? 0 : 255 - ); - } - else - { - gEngfuncs.pEfxAPI->R_BeamPoints( vecSrc, - tr.endpos, - m_iBeam, - 0.1, - m_fPrimaryFire ? 1.0 : 2.5, - 0.0, - m_fPrimaryFire ? 128.0 : flDamage, - 0, - 0, - 0, - m_fPrimaryFire ? 255 : 255, - m_fPrimaryFire ? 128 : 255, - m_fPrimaryFire ? 0 : 255 - ); - } - - pEntity = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent ); - if( pEntity == NULL ) - break; - - if( pEntity->solid == SOLID_BSP ) - { - float n; - - //pentIgnore = NULL; - - n = -DotProduct( tr.plane.normal, forward ); - - if( n < 0.5 ) // 60 degrees - { - // ALERT( at_console, "reflect %f\n", n ); - // reflect - vec3_t r; - - VectorMA( forward, 2.0 * n, tr.plane.normal, r ); - - flMaxFrac = flMaxFrac - tr.fraction; - - VectorCopy( r, forward ); - - VectorMA( tr.endpos, 8.0, forward, vecSrc ); - VectorMA( vecSrc, 8192.0, forward, vecDest ); - - gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage * n / 255.0, flDamage * n * 0.5 * 0.1, FTENT_FADEOUT ); - - vec3_t fwd; - VectorAdd( tr.endpos, tr.plane.normal, fwd ); - - gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 100, - 255, 100 ); - - // lose energy - if( n == 0 ) - { - n = 0.1; - } - - flDamage = flDamage * ( 1 - n ); - } - else - { - // tunnel - EV_HLDM_DecalGunshot( &tr, BULLET_MONSTER_12MM ); - - gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 1.0, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0, 6.0, FTENT_FADEOUT ); - - // limit it to one hole punch - if( fHasPunched ) - { - break; - } - fHasPunched = 1; - - // try punching through wall if secondary attack (primary is incapable of breaking through) - if( !m_fPrimaryFire ) - { - vec3_t start; - - VectorMA( tr.endpos, 8.0, forward, start ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); - - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( start, vecDest, PM_STUDIO_BOX, -1, &beam_tr ); - - if( !beam_tr.allsolid ) - { - vec3_t delta; - - // trace backwards to find exit point - gEngfuncs.pEventAPI->EV_PlayerTrace( beam_tr.endpos, tr.endpos, PM_STUDIO_BOX, -1, &beam_tr ); - - VectorSubtract( beam_tr.endpos, tr.endpos, delta ); - - n = Length( delta ); - - if( n < flDamage ) - { - if( n == 0 ) - n = 1; - flDamage -= n; - - // absorption balls - { - vec3_t fwd; - VectorSubtract( tr.endpos, forward, fwd ); - gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 3, 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 100, - 255, 100 ); - } - - //////////////////////////////////// WHAT TO DO HERE - // CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); - - EV_HLDM_DecalGunshot( &beam_tr, BULLET_MONSTER_12MM ); - - gEngfuncs.pEfxAPI->R_TempSprite( beam_tr.endpos, vec3_origin, 0.1, m_iGlow, kRenderGlow, kRenderFxNoDissipation, flDamage / 255.0, 6.0, FTENT_FADEOUT ); - - // balls - { - vec3_t fwd; - VectorSubtract( beam_tr.endpos, forward, fwd ); - gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, beam_tr.endpos, fwd, m_iBalls, (int)( flDamage * 0.3 ), 0.1, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 200, - 255, 40 ); - } - - VectorAdd( beam_tr.endpos, forward, vecSrc ); - } - } - else - { - flDamage = 0; - } - - gEngfuncs.pEventAPI->EV_PopPMStates(); - } - else - { - if( m_fPrimaryFire ) - { - // slug doesn't punch through ever with primary - // fire, so leave a little glowy bit and make some balls - gEngfuncs.pEfxAPI->R_TempSprite( tr.endpos, vec3_origin, 0.2, m_iGlow, kRenderGlow, kRenderFxNoDissipation, 200.0 / 255.0, 0.3, FTENT_FADEOUT ); - { - vec3_t fwd; - VectorAdd( tr.endpos, tr.plane.normal, fwd ); - gEngfuncs.pEfxAPI->R_Sprite_Trail( TE_SPRITETRAIL, tr.endpos, fwd, m_iBalls, 8, 0.6, gEngfuncs.pfnRandomFloat( 10, 20 ) / 100.0, 100, - 255, 200 ); - } - } - - flDamage = 0; - } - } - } - else - { - VectorAdd( tr.endpos, forward, vecSrc ); - } - } -} -//====================== -// GAUSS END -//====================== - -//====================== -// CROWBAR START -//====================== -enum crowbar_e -{ - CROWBAR_IDLE = 0, - CROWBAR_DRAW, - CROWBAR_HOLSTER, - CROWBAR_ATTACK1HIT, - CROWBAR_ATTACK1MISS, - CROWBAR_ATTACK2MISS, - CROWBAR_ATTACK2HIT, - CROWBAR_ATTACK3MISS, -#ifndef CROWBAR_IDLE_ANIM - CROWBAR_ATTACK3HIT -#else - CROWBAR_ATTACK3HIT, - CROWBAR_IDLE2, - CROWBAR_IDLE3 -#endif -}; - -int g_iSwing; - -//Only predict the miss sounds, hit sounds are still played -//server side, so players don't get the wrong idea. -void EV_Crowbar( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - //Play Swing sound - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/cbar_miss1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - - if( EV_IsLocal( idx ) ) - { - switch( (g_iSwing++) % 3 ) - { - case 0: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK1MISS, 1 ); - break; - case 1: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK2MISS, 1 ); - break; - case 2: - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROWBAR_ATTACK3MISS, 1 ); - break; - } - } -} -//====================== -// CROWBAR END -//====================== - -//====================== -// CROSSBOW START -//====================== -enum crossbow_e -{ - CROSSBOW_IDLE1 = 0, // full - CROSSBOW_IDLE2, // empty - CROSSBOW_FIDGET1, // full - CROSSBOW_FIDGET2, // empty - CROSSBOW_FIRE1, // full - CROSSBOW_FIRE2, // reload - CROSSBOW_FIRE3, // empty - CROSSBOW_RELOAD, // from empty - CROSSBOW_DRAW1, // full - CROSSBOW_DRAW2, // empty - CROSSBOW_HOLSTER1, // full - CROSSBOW_HOLSTER2 // empty -}; - -//===================== -// EV_BoltCallback -// This function is used to correct the origin and angles -// of the bolt, so it looks like it's stuck on the wall. -//===================== -void EV_BoltCallback( struct tempent_s *ent, float frametime, float currenttime ) -{ - ent->entity.origin = ent->entity.baseline.vuser1; - ent->entity.angles = ent->entity.baseline.vuser2; -} - -void EV_FireCrossbow2( event_args_t *args ) -{ - vec3_t vecSrc, vecEnd; - vec3_t up, right, forward; - pmtrace_t tr; - - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - - VectorCopy( args->velocity, velocity ); - - AngleVectors( angles, forward, right, up ); - - EV_GetGunPosition( args, vecSrc, origin ); - - VectorMA( vecSrc, 8192, forward, vecEnd ); - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); - - if( EV_IsLocal( idx ) ) - { - if( args->iparam1 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 1 ); - else if( args->iparam2 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 1 ); - } - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // 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 ); - - //We hit something - if( tr.fraction < 1.0 ) - { - physent_t *pe = gEngfuncs.pEventAPI->EV_GetPhysent( tr.ent ); - - //Not the world, let's assume we hit something organic ( dog, cat, uncle joe, etc ). - if( pe->solid != SOLID_BSP ) - { - switch( gEngfuncs.pfnRandomLong( 0, 1 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, tr.endpos, CHAN_BODY, "weapons/xbow_hitbod1.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, tr.endpos, CHAN_BODY, "weapons/xbow_hitbod2.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - break; - } - } - //Stick to world but don't stick to glass, it might break and leave the bolt floating. It can still stick to other non-transparent breakables though. - else if( pe->rendermode == kRenderNormal ) - { - gEngfuncs.pEventAPI->EV_PlaySound( 0, tr.endpos, CHAN_BODY, "weapons/xbow_hit1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, PITCH_NORM ); - - //Not underwater, do some sparks... - if( gEngfuncs.PM_PointContents( tr.endpos, NULL ) != CONTENTS_WATER ) - gEngfuncs.pEfxAPI->R_SparkShower( tr.endpos ); - - vec3_t vBoltAngles; - int iModelIndex = gEngfuncs.pEventAPI->EV_FindModelIndex( "models/crossbow_bolt.mdl" ); - - VectorAngles( forward, vBoltAngles ); - - TEMPENTITY *bolt = gEngfuncs.pEfxAPI->R_TempModel( tr.endpos - forward * 10, Vector( 0, 0, 0 ), vBoltAngles , 5, iModelIndex, TE_BOUNCE_NULL ); - - if( bolt ) - { - bolt->flags |= ( FTENT_CLIENTCUSTOM ); //So it calls the callback function. - bolt->entity.baseline.vuser1 = tr.endpos - forward * 10; // Pull out a little bit - bolt->entity.baseline.vuser2 = vBoltAngles; //Look forward! - bolt->callback = EV_BoltCallback; //So we can set the angles and origin back. (Stick the bolt to the wall) - } - } - } - - gEngfuncs.pEventAPI->EV_PopPMStates(); -} - -//TODO: Fully predict the fliying bolt. -void EV_FireCrossbow( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xbow_fire1.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/xbow_reload1.wav", gEngfuncs.pfnRandomFloat( 0.95, 1.0 ), ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); - - //Only play the weapon anims if I shot it. - if( EV_IsLocal( idx ) ) - { - if( args->iparam1 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE1, 1 ); - else if ( args->iparam2 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( CROSSBOW_FIRE3, 1 ); - - V_PunchAxis( 0, -2.0 ); - } -} -//====================== -// CROSSBOW END -//====================== - -//====================== -// RPG START -//====================== -enum rpg_e -{ - RPG_IDLE = 0, - RPG_FIDGET, - RPG_RELOAD, // to reload - RPG_FIRE2, // to empty - RPG_HOLSTER1, // loaded - RPG_DRAW1, // loaded - RPG_HOLSTER2, // unloaded - RPG_DRAW_UL, // unloaded - RPG_IDLE_UL, // unloaded idle - RPG_FIDGET_UL // unloaded fidget -}; - -void EV_FireRpg( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/rocketfire1.wav", 0.9, ATTN_NORM, 0, PITCH_NORM ); - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_ITEM, "weapons/glauncher.wav", 0.7, ATTN_NORM, 0, PITCH_NORM ); - - //Only play the weapon anims if I shot it. - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( RPG_FIRE2, 1 ); - - V_PunchAxis( 0, -5.0 ); - } -} -//====================== -// RPG END -//====================== - -//====================== -// EGON END -//====================== -enum egon_e -{ - EGON_IDLE1 = 0, - EGON_FIDGET1, - EGON_ALTFIREON, - EGON_ALTFIRECYCLE, - EGON_ALTFIREOFF, - EGON_FIRE1, - EGON_FIRE2, - EGON_FIRE3, - EGON_FIRE4, - EGON_DRAW, - EGON_HOLSTER -}; - -int g_fireAnims1[] = { EGON_FIRE1, EGON_FIRE2, EGON_FIRE3, EGON_FIRE4 }; -int g_fireAnims2[] = { EGON_ALTFIRECYCLE }; - -enum EGON_FIRESTATE -{ - FIRE_OFF, - FIRE_CHARGE -}; - -enum EGON_FIREMODE -{ - FIRE_NARROW, - FIRE_WIDE -}; - -#define EGON_PRIMARY_VOLUME 450 -#define EGON_BEAM_SPRITE "sprites/xbeam1.spr" -#define EGON_FLARE_SPRITE "sprites/XSpark1.spr" -#define EGON_SOUND_OFF "weapons/egon_off1.wav" -#define EGON_SOUND_RUN "weapons/egon_run3.wav" -#define EGON_SOUND_STARTUP "weapons/egon_windup2.wav" - -#define ARRAYSIZE(p) ( sizeof(p) /sizeof(p[0]) ) - -BEAM *pBeam; -BEAM *pBeam2; - -void EV_EgonFire( event_args_t *args ) -{ - int idx, /*iFireState,*/ iFireMode; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - //iFireState = args->iparam1; - iFireMode = args->iparam2; - int iStartup = args->bparam1; - - if( iStartup ) - { - if( iFireMode == FIRE_WIDE ) - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, EGON_SOUND_STARTUP, 0.98, ATTN_NORM, 0, 125 ); - else - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, EGON_SOUND_STARTUP, 0.9, ATTN_NORM, 0, 100 ); - } - else - { - // If there is any sound playing already, kill it. - Solokiller - // This is necessary because multiple sounds can play on the same channel at the same time. - // In some cases, more than 1 run sound plays when the egon stops firing, in which case only the earliest entry in the list is stopped. - // This ensures no more than 1 of those is ever active at the same time. - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EGON_SOUND_RUN ); - - if( iFireMode == FIRE_WIDE ) - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, EGON_SOUND_RUN, 0.98, ATTN_NORM, 0, 125 ); - else - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_STATIC, EGON_SOUND_RUN, 0.9, ATTN_NORM, 0, 100 ); - } - - //Only play the weapon anims if I shot it. - 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. - { - vec3_t vecSrc, vecEnd, angles, forward, right, up; - pmtrace_t tr; - - cl_entity_t *pl = gEngfuncs.GetEntityByIndex( idx ); - - if( pl ) - { - VectorCopy( gHUD.m_vecAngles, angles ); - - AngleVectors( angles, forward, right, up ); - - EV_GetGunPosition( args, vecSrc, pl->origin ); - - VectorMA( vecSrc, 2048, forward, vecEnd ); - - gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // 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_PopPMStates(); - - int iBeamModelIndex = gEngfuncs.pEventAPI->EV_FindModelIndex( EGON_BEAM_SPRITE ); - - float r = 50.0f; - float g = 50.0f; - float b = 125.0f; - - if( IEngineStudio.IsHardware() ) - { - r /= 100.0f; - g /= 100.0f; - } - - pBeam = gEngfuncs.pEfxAPI->R_BeamEntPoint( idx | 0x1000, tr.endpos, iBeamModelIndex, 99999, 3.5, 0.2, 0.7, 55, 0, 0, r, g, b ); - - if( pBeam ) - 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 ); - } - } -} - -void EV_EgonStop( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_STATIC, EGON_SOUND_RUN ); - - if( args->iparam1 ) - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, EGON_SOUND_OFF, 0.98, ATTN_NORM, 0, 100 ); - - if( EV_IsLocal( idx ) ) - { - if( pBeam ) - { - pBeam->die = 0.0; - pBeam = NULL; - } - - if( pBeam2 ) - { - pBeam2->die = 0.0; - pBeam2 = NULL; - } - } -} -//====================== -// EGON END -//====================== - -//====================== -// HORNET START -//====================== -enum hgun_e -{ - HGUN_IDLE1 = 0, - HGUN_FIDGETSWAY, - HGUN_FIDGETSHAKE, - HGUN_DOWN, - HGUN_UP, - HGUN_SHOOT -}; - -void EV_HornetGunFire( event_args_t *args ) -{ - int idx; //, iFireMode; - vec3_t origin, angles, vecSrc, forward, right, up; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - //iFireMode = args->iparam1; - - //Only play the weapon anims if I shot it. - if( EV_IsLocal( idx ) ) - { - V_PunchAxis( 0, gEngfuncs.pfnRandomLong( 0, 2 ) ); - gEngfuncs.pEventAPI->EV_WeaponAnimation( HGUN_SHOOT, 1 ); - } - - switch( gEngfuncs.pfnRandomLong( 0, 2 ) ) - { - case 0: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire1.wav", 1, ATTN_NORM, 0, 100 ); - break; - case 1: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire2.wav", 1, ATTN_NORM, 0, 100 ); - break; - case 2: - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "agrunt/ag_fire3.wav", 1, ATTN_NORM, 0, 100 ); - break; - } -} -//====================== -// HORNET END -//====================== - -//====================== -// TRIPMINE START -//====================== -enum tripmine_e -{ - TRIPMINE_IDLE1 = 0, - TRIPMINE_IDLE2, - TRIPMINE_ARM1, - TRIPMINE_ARM2, - TRIPMINE_FIDGET, - TRIPMINE_HOLSTER, - TRIPMINE_DRAW, - TRIPMINE_WORLD, - TRIPMINE_GROUND -}; - -//We only check if it's possible to put a trip mine -//and if it is, then we play the animation. Server still places it. -void EV_TripmineFire( event_args_t *args ) -{ - int idx; - vec3_t vecSrc, angles, view_ofs, forward; - pmtrace_t tr; - - idx = args->entindex; - VectorCopy( args->origin, vecSrc ); - VectorCopy( args->angles, angles ); - - AngleVectors( angles, forward, NULL, NULL ); - - if( !EV_IsLocal ( idx ) ) - return; - - // Grab predicted result for local player - gEngfuncs.pEventAPI->EV_LocalPlayerViewheight( view_ofs ); - - vecSrc = vecSrc + view_ofs; - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers ( idx - 1 ); - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc, vecSrc + forward * 128, PM_NORMAL, -1, &tr ); - - //Hit something solid - if( tr.fraction < 1.0 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation ( TRIPMINE_DRAW, 0 ); - - gEngfuncs.pEventAPI->EV_PopPMStates(); -} -//====================== -// TRIPMINE END -//====================== - -//====================== -// SQUEAK START -//====================== -enum squeak_e -{ - SQUEAK_IDLE1 = 0, - SQUEAK_FIDGETFIT, - SQUEAK_FIDGETNIP, - SQUEAK_DOWN, - SQUEAK_UP, - SQUEAK_THROW -}; - -#define VEC_HULL_MIN Vector( -16, -16, -36 ) -#define VEC_DUCK_HULL_MIN Vector( -16, -16, -18 ) - -void EV_SnarkFire( event_args_t *args ) -{ - int idx; - vec3_t vecSrc, angles, view_ofs, forward; - pmtrace_t tr; - - idx = args->entindex; - VectorCopy( args->origin, vecSrc ); - VectorCopy( args->angles, angles ); - - AngleVectors( angles, forward, NULL, NULL ); - - if( !EV_IsLocal ( idx ) ) - return; - - if( args->ducking ) - vecSrc = vecSrc - ( VEC_HULL_MIN - VEC_DUCK_HULL_MIN ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // Now add in all of the players. - gEngfuncs.pEventAPI->EV_SetSolidPlayers( idx - 1 ); - gEngfuncs.pEventAPI->EV_SetTraceHull( 2 ); - gEngfuncs.pEventAPI->EV_PlayerTrace( vecSrc + forward * 20, vecSrc + forward * 64, PM_NORMAL, -1, &tr ); - - //Find space to drop the thing. - if( tr.allsolid == 0 && tr.startsolid == 0 && tr.fraction > 0.25 ) - gEngfuncs.pEventAPI->EV_WeaponAnimation( SQUEAK_THROW, 0 ); - - gEngfuncs.pEventAPI->EV_PopPMStates(); -} -//====================== -// SQUEAK END -//====================== - void EV_TrainPitchAdjust( event_args_t *args ) { int idx; @@ -1765,227 +715,6 @@ int EV_TFC_IsAllyTeam( int iTeam1, int iTeam2 ) return 0; } -//====================== -// HEATERPIPE START -//====================== -enum heaterpipe_e -{ - HEATERPIPE_IDLE = 0, - HEATERPIPE_DRAW, - HEATERPIPE_HOLSTER, - HEATERPIPE_ATTACK1HIT, - HEATERPIPE_ATTACK1MISS, - HEATERPIPE_ATTACK2MISS, - HEATERPIPE_ATTACK2HIT, - HEATERPIPE_ATTACK3MISS, - HEATERPIPE_ATTACK3HIT, - HEATERPIPE_IDLE2, - HEATERPIPE_IDLE3, -}; - -//Only predict the miss sounds, hit sounds are still played -//server side, so players don't get the wrong idea. -void EV_HeaterPipe( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - //Play Swing sound - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/pipe_miss.wav", 1, ATTN_NORM, 0, PITCH_NORM ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( HEATERPIPE_ATTACK1MISS, 1 ); - - switch( ( g_iSwing++ ) % 3 ) - { - case 0: - gEngfuncs.pEventAPI->EV_WeaponAnimation( HEATERPIPE_ATTACK1MISS, 1 ); - break; - case 1: - gEngfuncs.pEventAPI->EV_WeaponAnimation( HEATERPIPE_ATTACK2MISS, 1 ); - break; - case 2: - gEngfuncs.pEventAPI->EV_WeaponAnimation( HEATERPIPE_ATTACK3MISS, 1 ); - break; - } - } -} -//====================== -// HEATERPIPE END -//====================== - -//====================== -// BRADNAILER START -//====================== -enum bradnailer_e -{ - BRADNAILER_IDLE1 = 0, - BRADNAILER_IDLE2, - BRADNAILER_IDLE3, - BRADNAILER_SHOOT, - BRADNAILER_SHOOT_EMPTY, - BRADNAILER_RELOAD, - BRADNAILER_RELOAD_NOT_EMPTY, - BRADNAILER_DRAW, - BRADNAILER_HOLSTER, - BRADNAILER_ADD_SILENCER, - BRADNAILER_UPRIGHT_TO_TILT, - BRADNAILER_TILT_TO_UPRIGHT, - BRADNAILER_FASTSHOOT, -}; - -void EV_FireBradnailer( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - int fastshoot = args->bparam1; - - vec3_t vecSrc, vecAiming; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - AngleVectors( angles, forward, right, up ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( fastshoot ? BRADNAILER_FASTSHOOT : BRADNAILER_SHOOT, 2 ); - - V_PunchAxis( 0, -2.0 ); - } - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/bradnailer.wav", gEngfuncs.pfnRandomFloat( 0.92, 1.0 ), ATTN_NORM, 0, 98 + gEngfuncs.pfnRandomLong( 0, 3 ) ); - - EV_GetGunPosition( args, vecSrc, origin ); - - // Adjust tracer source. - if( fastshoot ) - { - vecSrc = vecSrc + forward * 4 + up * -4; - } - else - { - vecSrc = vecSrc + forward * 12 + right * 8 + up * -4; - } - - VectorCopy( forward, vecAiming ); - - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_NAIL, 2, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); -} - -//====================== -// BRADNAILER END -//====================== - -//====================== -// NAILGUN START -//====================== -enum nailgun_e -{ - NAILGUN_LONGIDLE = 0, - NAILGUN_IDLE1, - NAILGUN_LAUNCH, - NAILGUN_RELOAD, - NAILGUN_DEPLOY, - NAILGUN_FIRE1, - NAILGUN_FIRE2, - NAILGUN_FIRE3, - NAILGUN_DEPLOY_EMPTY, - NAILGUN_LONGIDLE_EMPTY, - NAILGUN_IDLE1_EMPTY, -}; - -void EV_FireNailgun( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - - vec3_t vecSrc, vecAiming; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - AngleVectors( angles, forward, right, up ); - - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( NAILGUN_FIRE1 + gEngfuncs.pfnRandomLong( 0, 2 ), 2 ); - - V_PunchAxis( 0, gEngfuncs.pfnRandomFloat( -2, 2 ) ); - } - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/nailgun.wav", 1, ATTN_NORM, 0, 94 + gEngfuncs.pfnRandomLong( 0, 0xf ) ); - - EV_GetGunPosition( args, vecSrc, origin ); - - // Adjust tracer source. - vecSrc = vecSrc + forward * 8 + right * 16 + up * -16; - - VectorCopy( forward, vecAiming ); - - EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_NAIL, 1, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); -} - -//====================== -// NAILGUN END -//====================== - -//====================== -// CMLWBR START -//====================== -enum cmlwbr_e -{ - CMLWBR_IDLE1 = 0, // drawn - CMLWBR_IDLE2, // undrawn - CMLWBR_FIDGET1, // drawn - CMLWBR_FIDGET2, // undrawn - CMLWBR_FIRE1, - CMLWBR_RELOAD, // drawn - CMLWBR_DRAWBACK, - CMLWBR_UNDRAW, - CMLWBR_DRAW1, // drawn - CMLWBR_DRAW2, // undrawn - CMLWBR_HOLSTER1, // drawn - CMLWBR_HOLSTER2, // undrawn -}; - -//TODO: Fully predict the fliying bolt. -void EV_FireCmlwbr( event_args_t *args ) -{ - int idx; - vec3_t origin; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/cmlwbr_fire.wav", 1, ATTN_NORM, 0, 93 + gEngfuncs.pfnRandomLong( 0, 0xF ) ); - - //Only play the weapon anims if I shot it. - if( EV_IsLocal( idx ) ) - { - gEngfuncs.pEventAPI->EV_WeaponAnimation( CMLWBR_FIRE1, 1 ); - - V_PunchAxis( 0, -2.0 ); - } -} -//====================== -// CMLWBR END -//====================== - //====================== // XENSQUASHER START //====================== @@ -2024,94 +753,3 @@ void EV_SpinXS( event_args_t *args ) gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xs_windup.wav", 1.0, ATTN_NORM, iSoundState, pitch ); } - -/* -============================== -EV_StopPreviousXS -============================== -*/ -void EV_StopPreviousXS( int idx ) -{ - // Make sure we don't have a gauss spin event in the queue for this guy - gEngfuncs.pEventAPI->EV_KillEvents( idx, "events/xsspin.sc" ); - gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_WEAPON, "weapons/xs_windup.wav" ); -} - -void EV_FireXS( event_args_t *args ) -{ - int idx; - vec3_t origin; - vec3_t angles; - vec3_t velocity; - float flDamage = args->fparam1; - int primaryfire = args->bparam1; - - int m_fPrimaryFire = args->bparam1; - int m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; - vec3_t vecSrc; - vec3_t vecDest; - pmtrace_t tr, beam_tr; - float flMaxFrac = 1.0; - int nTotal = 0; - int fHasPunched = 0; - int fFirstBeam = 1; - int nMaxHits = 10; - int m_iBeam, m_iGlow, m_iBalls; - vec3_t up, right, forward; - - idx = args->entindex; - VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); - - if( args->bparam2 ) - { - EV_StopPreviousXS( idx ); - return; - } - - //Con_Printf( "Firing gauss with %f\n", flDamage ); - EV_GetGunPosition( args, vecSrc, origin ); - - m_iBeam = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/smoke.spr" ); - m_iBalls = m_iGlow = gEngfuncs.pEventAPI->EV_FindModelIndex( "sprites/hotglow.spr" ); - - AngleVectors( angles, forward, right, up ); - - VectorMA( vecSrc, 8192, forward, vecDest ); - - if( EV_IsLocal( idx ) ) - { - V_PunchAxis( 0, -2.0 ); - gEngfuncs.pEventAPI->EV_WeaponAnimation( XS_FIRE2, 2 ); - - if( m_fPrimaryFire == false ) - g_flApplyVel = flDamage; - } - - gEngfuncs.pEventAPI->EV_PlaySound( idx, origin, CHAN_WEAPON, "weapons/xs_shot.wav", 0.5 + flDamage * ( 1.0 / 400.0 ), ATTN_NORM, 0, 85 + gEngfuncs.pfnRandomLong( 0, 0x1f ) ); -} -//====================== -// XENSQUASHER END -//====================== - -//====================== -// RELOAD START -//====================== -void EV_Reload( event_args_t *args ) -{ - int idx; - - idx = args->entindex; - - if( EV_IsLocal( idx ) ) - { - int anim = args->iparam1; - int body = args->iparam2; - gEngfuncs.pEventAPI->EV_WeaponAnimation( anim, body ); - } -} - -//====================== -// RELOAD END -//====================== diff --git a/cl_dll/hl/hl_events.cpp b/cl_dll/hl/hl_events.cpp index 9412453e..4668fa4d 100644 --- a/cl_dll/hl/hl_events.cpp +++ b/cl_dll/hl/hl_events.cpp @@ -23,31 +23,10 @@ extern "C" void EV_FireGlock1( struct event_args_s *args ); void EV_FireGlock2( struct event_args_s *args ); void EV_FireShotGunSingle( struct event_args_s *args ); -void EV_FireShotGunDouble( struct event_args_s *args ); -void EV_FireMP5( struct event_args_s *args ); -void EV_FireMP52( struct event_args_s *args ); -void EV_FirePython( struct event_args_s *args ); -void EV_FireGauss( struct event_args_s *args ); -void EV_SpinGauss( struct event_args_s *args ); -void EV_Crowbar( struct event_args_s *args ); -void EV_FireCrossbow( struct event_args_s *args ); -void EV_FireCrossbow2( struct event_args_s *args ); -void EV_FireRpg( struct event_args_s *args ); -void EV_EgonFire( struct event_args_s *args ); -void EV_EgonStop( struct event_args_s *args ); -void EV_HornetGunFire( struct event_args_s *args ); -void EV_TripmineFire( struct event_args_s *args ); -void EV_SnarkFire( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); -void EV_HeaterPipe( struct event_args_s *args ); -void EV_FireBradnailer( struct event_args_s *args ); -void EV_FireNailgun( struct event_args_s *args ); -void EV_FireCmlwbr( struct event_args_s *args ); void EV_SpinXS( struct event_args_s *args ); -void EV_FireXS( struct event_args_s *args ); -void EV_Reload( struct event_args_s *args ); } /* @@ -68,28 +47,7 @@ void Game_HookEvents( void ) gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 ); gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 ); gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle ); - gEngfuncs.pfnHookEvent( "events/shotgun2.sc", EV_FireShotGunDouble ); - gEngfuncs.pfnHookEvent( "events/mp5.sc", EV_FireMP5 ); - gEngfuncs.pfnHookEvent( "events/mp52.sc", EV_FireMP52 ); - gEngfuncs.pfnHookEvent( "events/python.sc", EV_FirePython ); - gEngfuncs.pfnHookEvent( "events/gauss.sc", EV_FireGauss ); - gEngfuncs.pfnHookEvent( "events/gaussspin.sc", EV_SpinGauss ); gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust ); - gEngfuncs.pfnHookEvent( "events/crowbar.sc", EV_Crowbar ); - gEngfuncs.pfnHookEvent( "events/crossbow1.sc", EV_FireCrossbow ); - gEngfuncs.pfnHookEvent( "events/crossbow2.sc", EV_FireCrossbow2 ); - gEngfuncs.pfnHookEvent( "events/rpg.sc", EV_FireRpg ); - gEngfuncs.pfnHookEvent( "events/egon_fire.sc", EV_EgonFire ); - gEngfuncs.pfnHookEvent( "events/egon_stop.sc", EV_EgonStop ); - gEngfuncs.pfnHookEvent( "events/firehornet.sc", EV_HornetGunFire ); - gEngfuncs.pfnHookEvent( "events/tripfire.sc", EV_TripmineFire ); - gEngfuncs.pfnHookEvent( "events/snarkfire.sc", EV_SnarkFire ); - gEngfuncs.pfnHookEvent( "events/heaterpipe.sc", EV_HeaterPipe ); - gEngfuncs.pfnHookEvent( "events/bradnailer.sc", EV_FireBradnailer ); - gEngfuncs.pfnHookEvent( "events/nailgun.sc", EV_FireNailgun ); - gEngfuncs.pfnHookEvent( "events/cmlwbr.sc", EV_FireCmlwbr ); gEngfuncs.pfnHookEvent( "events/xsspin.sc", EV_SpinXS ); - gEngfuncs.pfnHookEvent( "events/xs.sc", EV_FireXS ); - gEngfuncs.pfnHookEvent( "events/reload.sc", EV_Reload ); } From 9d7ab6acf46a8b71ef119d9c252767865522d21d Mon Sep 17 00:00:00 2001 From: Andrey Akhmichin Date: Sat, 31 Mar 2018 17:09:13 +0500 Subject: [PATCH 183/199] Some fixes for FoV, HUD, egon flare and new compilers. (#52) * Fix warnings. * Merge some fixes from https://github.com/Fograin/hl-subs-mod. --- cl_dll/ev_hldm.cpp | 41 ++++++++++++++++++++++++++++++++++++- cl_dll/health.cpp | 3 ++- cl_dll/hl/hl_objects.cpp | 25 +++++++++++++++++++++- cl_dll/hl/hl_weapons.cpp | 2 ++ cl_dll/hud.cpp | 3 ++- cl_dll/hud.h | 2 +- cl_dll/hud_msg.cpp | 16 ++++++++++++++- cl_dll/input_goldsource.cpp | 2 +- cl_dll/scoreboard.cpp | 2 +- dlls/monsters.cpp | 3 ++- dlls/player.cpp | 18 +++++++++++++--- 11 files changed, 105 insertions(+), 12 deletions(-) diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 628b5bfa..08127aa1 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -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 ) 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 ) 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 ) 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; + } } } //====================== diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index d4979c35..eebf0eb0 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -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 ); diff --git a/cl_dll/hl/hl_objects.cpp b/cl_dll/hl/hl_objects.cpp index b51ee693..55822dcb 100644 --- a/cl_dll/hl/hl_objects.cpp +++ b/cl_dll/hl/hl_objects.cpp @@ -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 ) 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 */ void Game_AddObjects( void ) { - if( pBeam && pBeam2 ) + if( pBeam || pBeam2 || pFlare ) // Vit_amiN: egon flare added UpdateBeams(); } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index 75161a9e..b2c1d7b3 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -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 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; diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 05bda284..195dfa5a 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -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 ) 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; diff --git a/cl_dll/hud.h b/cl_dll/hud.h index decfa917..f3e1ed85 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -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 ); diff --git a/cl_dll/hud_msg.cpp b/cl_dll/hud_msg.cpp index 47f8bc92..b435a85c 100644 --- a/cl_dll/hud_msg.cpp +++ b/cl_dll/hud_msg.cpp @@ -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 ) // 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 ) //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 ) 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; diff --git a/cl_dll/input_goldsource.cpp b/cl_dll/input_goldsource.cpp index bd997784..c45841cb 100644 --- a/cl_dll/input_goldsource.cpp +++ b/cl_dll/input_goldsource.cpp @@ -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 diff --git a/cl_dll/scoreboard.cpp b/cl_dll/scoreboard.cpp index 0f26c6f2..5d52787c 100644 --- a/cl_dll/scoreboard.cpp +++ b/cl_dll/scoreboard.cpp @@ -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; diff --git a/dlls/monsters.cpp b/dlls/monsters.cpp index 1e1d3de3..953d1a69 100644 --- a/dlls/monsters.cpp +++ b/dlls/monsters.cpp @@ -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? diff --git a/dlls/player.cpp b/dlls/player.cpp index bbd668ba..b1d28e67 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -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 ) 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 ) 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 ) { 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 ) 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(); } From f6ffc92d5d17c0d52ddceacff08193bd320b60a0 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 1 Apr 2018 20:38:56 +0300 Subject: [PATCH 184/199] Always update gHUD.m_iFOV on SetFOV message. Fix #53 --- cl_dll/hl/hl_weapons.cpp | 2 -- cl_dll/hud.cpp | 5 ----- cl_dll/hud_msg.cpp | 2 -- 3 files changed, 9 deletions(-) diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index b2c1d7b3..75161a9e 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -34,7 +34,6 @@ 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]; @@ -882,7 +881,6 @@ 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; diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 195dfa5a..3ef72889 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -413,7 +413,6 @@ 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,10 +513,6 @@ int CHud::MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ) int newfov = READ_BYTE(); int def_fov = CVAR_GET_FLOAT( "default_fov" ); - //Weapon prediction already takes care of changing the fog. ( g_lastFOV ). - if( g_hasPredictedFOV ) - return 1; - g_lastFOV = newfov; if( newfov == 0 ) diff --git a/cl_dll/hud_msg.cpp b/cl_dll/hud_msg.cpp index b435a85c..7cc2fbad 100644 --- a/cl_dll/hud_msg.cpp +++ b/cl_dll/hud_msg.cpp @@ -28,7 +28,6 @@ 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 @@ -55,7 +54,6 @@ int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ) // Vit_amiN: reset the FOV m_iFOV = 0; // default_fov g_lastFOV = 0.0f; - g_hasPredictedFOV = false; return 1; } From 0c515e34649dc7ce9e5be5fabfd71c61b0db04f0 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 2 Apr 2018 23:54:10 +0300 Subject: [PATCH 185/199] Update mobility interface --- engine/mobility_int.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/engine/mobility_int.h b/engine/mobility_int.h index 88f63315..d8b6120a 100644 --- a/engine/mobility_int.h +++ b/engine/mobility_int.h @@ -34,7 +34,7 @@ extern "C" { #define TOUCH_FL_DEF_HIDE (1U << 6) #define TOUCH_FL_DRAW_ADDITIVE (1U << 7) #define TOUCH_FL_STROKE (1U << 8) -#define TOUCH_FL_PRECISION (1U << 9) +#define TOUCH_FL_PRECISION (1U << 9) typedef struct mobile_engfuncs_s { @@ -65,13 +65,21 @@ typedef struct mobile_engfuncs_s void (*pfnTouchSetClientOnly)( unsigned char state ); // Clean defaults list - void (*pfnTouchResetDefaultButtons)(); + void (*pfnTouchResetDefaultButtons)( void ); + // Draw scaled font for client + int (*pfnDrawScaledCharacter)( int x, int y, int number, int r, int g, int b, float scale ); + + void (*pfnSys_Warn)( const char *format, ... ); + + // Get native object for current platform. + // Pass NULL to arguments to receive an array of available objects or NULL if nothing + void *(*pfnGetNativeObject)( const char *obj ); + + void (*pfnSetCustomClientID)( const char *id ); // To be continued... } mobile_engfuncs_t; -extern mobile_engfuncs_t *gMobileEngfuncs; - // function exported from client // returns 0 on no error otherwise error typedef int (*pfnMobilityInterface)( mobile_engfuncs_t *gMobileEngfuncs ); From cec6d7a1bc6383a81cdbb7622e6e4a1ec9ec1b07 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 2 Apr 2018 23:56:01 +0300 Subject: [PATCH 186/199] Add HUD_MessageBox. Rename isXashFWGS to IsXashFWGS --- cl_dll/cdll_int.cpp | 17 ++++++++++++++++- cl_dll/cl_util.h | 3 ++- cl_dll/hud_redraw.cpp | 2 +- cl_dll/input_mouse.cpp | 2 +- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index fec09792..dc9199ba 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -376,7 +376,22 @@ void DLLEXPORT HUD_MobilityInterface( mobile_engfuncs_t *gpMobileEngfuncs ) gMobileEngfuncs = gpMobileEngfuncs; } -bool isXashFWGS() +bool HUD_MessageBox( const char *msg ) +{ + gEngfuncs.Con_Printf( msg ); // just in case + + if( IsXashFWGS() ) + { + gMobileEngfuncs->pfnSys_Warn( msg ); + return true; + } + + // TODO: Load SDL2 and call ShowSimpleMessageBox + + return false; +} + +bool IsXashFWGS() { return gMobileEngfuncs != NULL; } diff --git a/cl_dll/cl_util.h b/cl_dll/cl_util.h index 23f12230..0cb65f32 100644 --- a/cl_dll/cl_util.h +++ b/cl_dll/cl_util.h @@ -181,5 +181,6 @@ inline void UnpackRGB( int &r, int &g, int &b, unsigned long ulRGB )\ HSPRITE LoadSprite( const char *pszName ); -bool isXashFWGS(); +bool HUD_MessageBox( const char *msg ); +bool IsXashFWGS(); #endif diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 06b25a33..4a46a519 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -235,7 +235,7 @@ int CHud::DrawHudString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int DrawUtfString( int xpos, int ypos, int iMaxX, const char *szIt, int r, int g, int b ) { - if (isXashFWGS()) + if (IsXashFWGS()) { // xash3d: reset unicode state gEngfuncs.pfnVGUI2DrawCharacterAdditive( 0, 0, 0, 0, 0, 0, 0 ); diff --git a/cl_dll/input_mouse.cpp b/cl_dll/input_mouse.cpp index 8d57091b..3233d797 100644 --- a/cl_dll/input_mouse.cpp +++ b/cl_dll/input_mouse.cpp @@ -69,7 +69,7 @@ void IN_Shutdown( void ) void IN_Init( void ) { #ifdef SUPPORT_GOLDSOURCE_INPUT - if (isXashFWGS()) { + if (IsXashFWGS()) { gEngfuncs.Con_Printf( "FWGS Xash3D input is in use\n" ); currentInput = &fwgsInput; } else { From 6e5062b39e2118ccb967015265ce81df57dd1e08 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Mon, 2 Apr 2018 23:56:26 +0300 Subject: [PATCH 187/199] Check for bad game data(missing or invalid hud.txt) --- cl_dll/hud.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 3ef72889..62c32b41 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -381,6 +381,18 @@ void CHud::VidInit( void ) // assumption: number_1, number_2, etc, are all listed and loaded sequentially m_HUD_number_0 = GetSpriteIndex( "number_0" ); + if( m_HUD_number_0 == -1 ) + { + const char *msg = "There is something wrong with your game data! Please, reinstall\n"; + + if( HUD_MessageBox( msg ) ) + { + gEngfuncs.pfnClientCmd( "quit\n" ); + } + + return; + } + m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top; m_Ammo.VidInit(); From 71f55bb119c7ec4d0c5dd6dc0c29dee5aa9bcda7 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Tue, 3 Apr 2018 21:39:07 +0300 Subject: [PATCH 188/199] Add mingw support to CMakeLists.txt. Add crosscompiling instructions to README.md --- CMakeLists.txt | 5 +++++ README.md | 8 ++++++++ cl_dll/CMakeLists.txt | 5 ++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd7fe664..64c48928 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,11 @@ else() message(STATUS "Building for 32 Bit") endif() +if (MINGW) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++ -static-libgcc") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--add-stdcall-alias") +endif() + # add_compile_options for older cmake versions if(${CMAKE_VERSION} VERSION_LESS "3.0.2") macro(add_compile_options) diff --git a/README.md b/README.md index a57d94b5..be0a5fa8 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,12 @@ Half-Life SDK for Xash3D & GoldSource with some fixes. cmake ../ make +Crosscompiling using mingw: + + mkdir build-mingw && cd build-mingw + TOOLCHAIN_PREFIX=i686-w64-mingw32 # check up the actual mingw prefix of your mingw installation + cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER="$TOOLCHAIN_PREFIX-gcc" -DCMAKE_CXX_COMPILER="$TOOLCHAIN_PREFIX-g++" + You may enable or disable some build options by -Dkey=value. All available build options are defined in CMakeLists.txt at root directory. See below if you want to build the GoldSource compatible libraries. @@ -68,6 +74,8 @@ or when using make without cmake: Unlike original client by Valve the resulting client library will not depend on vgui or SDL2 just like the one that's used in FWGS Xash3d. +Note for **Windows**: it's not possible to create GoldSource compatible libraries using mingw, only msvc builds will work. + Note for **Linux**: GoldSource requires libraries (both client and server) to be compiled with libstdc++ bundled with g++ of major version 4 (versions from 4.6 to 4.9 should work). If your Linux distribution does not provide compatible g++ version you have several options. diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index b848aa6c..323d156f 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -32,7 +32,10 @@ if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-write-strings) # GCC/Clang flag add_definitions(-D_LINUX -DLINUX) # It seems enough for all non-Win32 systems - add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) + add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp) + if(NOT MINGW) + add_definitions(-D_snprintf=snprintf -D_vsnprintf=vsnprintf) + endif() else() add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) endif() From d112f720ad305db4266fc39ed89add34d575ec92 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Tue, 3 Apr 2018 23:17:56 +0300 Subject: [PATCH 189/199] Test building with mingw on travis --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 9e165b81..fecd6f5b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,7 +8,9 @@ os: sudo: true before_script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-multilib g++-multilib; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" && "CC" == "gcc" ]]; then sudo apt-get install mingw-w64-i686-dev binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686; fi script: - mkdir -p build && cd build - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=0 && make -j3 && rm -rf * - - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * \ No newline at end of file + - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * + - if [[ "$TRAVIS_OS_NAME" == "linux" && "CC" == "gcc" ]]; then cd ..; mkdir build-mingw; cd build-mingw; cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++; make -j3; fi From ec6afbe86d311a4679c282611efd53b0aea53d5a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Wed, 4 Apr 2018 17:30:53 +0300 Subject: [PATCH 190/199] Fix addressing variables in travis --- .travis.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fecd6f5b..01d2ba27 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,9 +8,9 @@ os: sudo: true before_script: - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo apt-get install gcc-multilib g++-multilib; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" && "CC" == "gcc" ]]; then sudo apt-get install mingw-w64-i686-dev binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CC" == "gcc" ]]; then sudo apt-get install mingw-w64-i686-dev binutils-mingw-w64-i686 gcc-mingw-w64-i686 g++-mingw-w64-i686; fi script: - mkdir -p build && cd build - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=0 && make -j3 && rm -rf * - cmake ../ -DCMAKE_EXE_LINKER_FLAGS="-Wl,--no-undefined" -DUSE_VOICEMGR=1 && make -j3 && rm -rf * - - if [[ "$TRAVIS_OS_NAME" == "linux" && "CC" == "gcc" ]]; then cd ..; mkdir build-mingw; cd build-mingw; cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++; make -j3; fi + - if [[ "$TRAVIS_OS_NAME" == "linux" && "$CC" == "gcc" ]]; then cd ..; mkdir build-mingw; cd build-mingw; cmake ../ -DCMAKE_SYSTEM_NAME=Windows -DCMAKE_C_COMPILER=i686-w64-mingw32-gcc -DCMAKE_CXX_COMPILER=i686-w64-mingw32-g++ && make -j3; fi From d17387c61ffe0a81b2ae6c6737bc7f08d7040ab3 Mon Sep 17 00:00:00 2001 From: Alibek Omarov Date: Sat, 7 Apr 2018 04:21:16 +0300 Subject: [PATCH 191/199] Some fixes for PM_InitTextureTypes() from ReGameDLL_CS --- pm_shared/pm_shared.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pm_shared/pm_shared.c b/pm_shared/pm_shared.c index abe7b317..ace56595 100644 --- a/pm_shared/pm_shared.c +++ b/pm_shared/pm_shared.c @@ -168,24 +168,23 @@ void PM_InitTextureTypes() char buffer[512]; int i, j; byte *pMemFile; - int fileSize, filePos; + int fileSize, filePos = 0; static qboolean bTextureTypeInit = false; if( bTextureTypeInit ) return; - memset(&( grgszTextureName[0][0] ), 0, CTEXTURESMAX * CBTEXTURENAMEMAX ); - memset( grgchTextureType, 0, CTEXTURESMAX ); + memset(&( grgszTextureName[0][0] ), 0, sizeof( grgszTextureName ) ); + memset( grgchTextureType, 0, sizeof( grgchTextureType ) ); gcTextures = 0; - fileSize = pmove->COM_FileSize( "sound/materials.txt" ); - pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, NULL ); + pMemFile = pmove->COM_LoadFile( "sound/materials.txt", 5, &fileSize ); if( !pMemFile ) return; - memset( buffer, 0, 512 ); - filePos = 0; + memset( buffer, 0, sizeof( buffer ) ); + // for each line in the file... while( pmove->memfgets( pMemFile, fileSize, &filePos, buffer, 511 ) != NULL && (gcTextures < CTEXTURESMAX ) ) { From 3d7e2b0d933a5d27aed69f77e90f19e7c946728f Mon Sep 17 00:00:00 2001 From: Night Owl Date: Sun, 8 Apr 2018 03:25:13 +0500 Subject: [PATCH 192/199] Do not show flashlight sprite in spectator mode. --- cl_dll/flashlight.cpp | 3 +++ dlls/player.cpp | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/cl_dll/flashlight.cpp b/cl_dll/flashlight.cpp index c3514c7d..ee3d6d22 100644 --- a/cl_dll/flashlight.cpp +++ b/cl_dll/flashlight.cpp @@ -108,6 +108,9 @@ int CHudFlashlight::Draw( float flTime ) int r, g, b, x, y, a; wrect_t rc; + if( gEngfuncs.IsSpectateOnly() ) + return 1; + if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) return 1; diff --git a/dlls/player.cpp b/dlls/player.cpp index b1d28e67..926bf1e1 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -1421,7 +1421,7 @@ void CBasePlayer::StartObserver( Vector vecPosition, Vector vecViewAngle ) MESSAGE_END(); // Setup flags - m_iHideHUD = ( HIDEHUD_HEALTH | HIDEHUD_WEAPONS ); + m_iHideHUD = ( HIDEHUD_HEALTH | HIDEHUD_FLASHLIGHT | HIDEHUD_WEAPONS ); m_afPhysicsFlags |= PFLAG_OBSERVER; pev->effects = EF_NODRAW; pev->view_ofs = g_vecZero; From 75bc5105e786fef7ad865fee5226fbf88906541a Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 8 Apr 2018 19:59:11 +0300 Subject: [PATCH 193/199] Remove old TEXTURETYPE code --- dlls/sound.cpp | 84 ++------------------------------------------------ dlls/world.cpp | 3 -- 2 files changed, 3 insertions(+), 84 deletions(-) diff --git a/dlls/sound.cpp b/dlls/sound.cpp index 31d0b7aa..30c44326 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -1454,14 +1454,6 @@ void EMIT_GROUPNAME_SUIT( edict_t *entity, const char *groupname ) // texture name to a material type. Play footstep sound based // on material type. -int fTextureTypeInit = FALSE; - -#define CTEXTURESMAX 512 // max number of textures loaded - -int gcTextures = 0; -char grgszTextureName[CTEXTURESMAX][CBTEXTURENAMEMAX]; // texture names -char grgchTextureType[CTEXTURESMAX]; // parallel array of texture types - // open materials.txt, get size, alloc space, // save in array. Only works first time called, // ignored on subsequent calls. @@ -1513,87 +1505,17 @@ static char *memfgets( byte *pMemFile, int fileSize, int &filePos, char *pBuffer return NULL; } -void TEXTURETYPE_Init() -{ - char buffer[512]; - int i, j; - byte *pMemFile; - int fileSize, filePos = 0; - - if( fTextureTypeInit ) - return; - - memset( &( grgszTextureName[0][0] ), 0, CTEXTURESMAX * CBTEXTURENAMEMAX ); - memset( grgchTextureType, 0, CTEXTURESMAX ); - - gcTextures = 0; - - pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/materials.txt", &fileSize ); - if( !pMemFile ) - return; - - memset( buffer, 0, 512 ); - // for each line in the file... - while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL && ( gcTextures < CTEXTURESMAX) ) - { - // skip whitespace - i = 0; - while( buffer[i] && isspace( buffer[i] ) ) - i++; - - if( !buffer[i] ) - continue; - - // skip comment lines - if( buffer[i] == '/' || !isalpha( buffer[i] ) ) - continue; - - // get texture type - grgchTextureType[gcTextures] = toupper( buffer[i++] ); - - // skip whitespace - while( buffer[i] && isspace( buffer[i] ) ) - i++; - - if( !buffer[i] ) - continue; - - // get sentence name - j = i; - while( buffer[j] && !isspace( buffer[j] ) ) - j++; - - if( !buffer[j] ) - continue; - - // null-terminate name and save in sentences array - j = Q_min( j, CBTEXTURENAMEMAX - 1 + i ); - buffer[j] = 0; - strcpy( &( grgszTextureName[gcTextures++][0] ), &( buffer[i] ) ); - } - - g_engfuncs.pfnFreeFile( pMemFile ); - - fTextureTypeInit = TRUE; -} - // given texture name, find texture type // if not found, return type 'concrete' // NOTE: this routine should ONLY be called if the // current texture under the player changes! +extern "C" char PM_FindTextureType( char *name ); + char TEXTURETYPE_Find( char *name ) { - // CONSIDER: pre-sort texture names and perform faster binary search here - - for( int i = 0; i < gcTextures; i++ ) - { - if( !strnicmp( name, &( grgszTextureName[i][0] ), CBTEXTURENAMEMAX - 1 ) ) - return grgchTextureType[i]; - } - - return CHAR_TEX_CONCRETE; + return PM_FindTextureType(name); } // play a strike sound based on the texture that was hit by the attack traceline. VecSrc/VecEnd are the diff --git a/dlls/world.cpp b/dlls/world.cpp index 3b9a1f1e..ae5a41bc 100644 --- a/dlls/world.cpp +++ b/dlls/world.cpp @@ -500,9 +500,6 @@ void CWorld::Precache( void ) // ok to call this multiple times, calls after first are ignored. SENTENCEG_Init(); - // init texture type array from materials.txt - TEXTURETYPE_Init(); - // the area based ambient sounds MUST be the first precache_sounds // player precaches W_Precache(); // get weapon precaches From b63c1753a142e98598a86deac9e64276997261c8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 11 Apr 2018 04:48:42 +0500 Subject: [PATCH 194/199] Do not break motd(Revert old changes). --- dlls/multiplay_gamerules.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 7922d413..de91ac6e 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -1650,8 +1650,8 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) { // read from the MOTD.txt file int length, char_count = 0; - const char *pFileList; - const char *aFileList = pFileList = (const char*)LOAD_FILE_FOR_ME( CVAR_GET_STRING( "motdfile" ), &length ); + char *pFileList; + char *aFileList = pFileList = (char*)LOAD_FILE_FOR_ME( CVAR_GET_STRING( "motdfile" ), &length ); // send the server name MESSAGE_BEGIN( MSG_ONE, gmsgServerName, NULL, client ); @@ -1679,10 +1679,10 @@ void CHalfLifeMultiplay::SendMOTDToClient( edict_t *client ) if( char_count < MAX_MOTD_LENGTH ) pFileList = aFileList + char_count; else - pFileList = 0; + *pFileList = 0; MESSAGE_BEGIN( MSG_ONE, gmsgMOTD, NULL, client ); - WRITE_BYTE( pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come + WRITE_BYTE( *pFileList ? FALSE : TRUE ); // FALSE means there is still more message to come WRITE_STRING( chunk ); MESSAGE_END(); } From 352e52eb0d7eeb3b65191543297d594706456a52 Mon Sep 17 00:00:00 2001 From: Roman Chistokhodov Date: Sun, 8 Jul 2018 15:49:23 +0300 Subject: [PATCH 195/199] Fix #62 ligthting issue. --- dlls/lights.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dlls/lights.cpp b/dlls/lights.cpp index 1c39266b..13e6d3a9 100644 --- a/dlls/lights.cpp +++ b/dlls/lights.cpp @@ -155,10 +155,10 @@ void CEnvLight::KeyValue( KeyValueData* pkvd ) } else if( j == 4 ) { - v /= 255; - r *= v; - g *= v; - b *= v; + float vf = v / 255.0f; + r *= vf; + g *= vf; + b *= vf; } // simulate qrad direct, ambient,and gamma adjustments, as well as engine scaling From 65cb1f54f467b225949fab42b75a10a4bd202466 Mon Sep 17 00:00:00 2001 From: Jonathan Poncelet Date: Tue, 7 Aug 2018 08:24:04 +0100 Subject: [PATCH 196/199] Made library functions hidden by default on Mac/Linux This resolves an issue where the server library was calling client library functions in error. --- cl_dll/CMakeLists.txt | 1 + dlls/CMakeLists.txt | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/cl_dll/CMakeLists.txt b/cl_dll/CMakeLists.txt index 323d156f..1143eefe 100644 --- a/cl_dll/CMakeLists.txt +++ b/cl_dll/CMakeLists.txt @@ -31,6 +31,7 @@ add_definitions(-DCLIENT_WEAPONS -DCLIENT_DLL) if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-write-strings) # GCC/Clang flag + add_compile_options(-fvisibility=hidden) # GCC/Clang flag add_definitions(-D_LINUX -DLINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp) if(NOT MINGW) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 55370eeb..ccaa0279 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -30,13 +30,14 @@ add_definitions(-DCLIENT_WEAPONS) if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-invalid-offsetof) # GCC/Clang flag + add_compile_options(-fvisibility=hidden) # GCC/Clang flag add_definitions(-D_LINUX) # It seems enough for all non-Win32 systems add_definitions(-Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf -D_vsnprintf=vsnprintf ) else() add_definitions(-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE) endif() -set (SVDLL_SOURCES +set (SVDLL_SOURCES agrunt.cpp airtank.cpp aflock.cpp @@ -140,7 +141,7 @@ set (SVDLL_SOURCES ../pm_shared/pm_math.c ../pm_shared/pm_shared.c ) - + include_directories (. wpn_shared ../common ../engine ../pm_shared ../game_shared ../public) if(USE_VOICEMGR) From b423cac3de4336e47c7379d04652275c5a0bd7c8 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Wed, 12 Sep 2018 05:05:55 +0500 Subject: [PATCH 197/199] Use CMAKE_C_FLAGS value for C++ compilers. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 64c48928..918449e3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,8 +55,8 @@ if(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT 64BIT) if(MSVC) error("UNDONE: set 32 build flags") else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m32") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -m32") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m32") endif() set(CMAKE_SIZEOF_VOID_P 4) From 3915b19d2d0bb22ff2e85a499d8de13b3bbb5a32 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 25 Oct 2018 06:49:41 +0500 Subject: [PATCH 198/199] Rewrite HUD, weapons and monsters code. Fix nailguns spread. Fix xen squasher's projectile. Lock multiplayer. Read soundtrack names from sound/soundtrack.txt. --- cl_dll/Android.mk | 20 -- cl_dll/ammo.cpp | 148 +++------ cl_dll/ammo_secondary.cpp | 2 +- cl_dll/ammohistory.cpp | 10 +- cl_dll/cdll_int.cpp | 13 - cl_dll/entity.cpp | 3 + cl_dll/ev_hldm.cpp | 98 +++--- cl_dll/ev_hldm.h | 2 - cl_dll/health.cpp | 49 +-- cl_dll/hl/hl_baseentity.cpp | 4 - cl_dll/hl/hl_events.cpp | 11 +- cl_dll/hl/hl_objects.cpp | 46 --- cl_dll/hl/hl_weapons.cpp | 48 --- cl_dll/hud.cpp | 53 ++- cl_dll/hud.h | 21 +- cl_dll/hud_msg.cpp | 6 - cl_dll/hud_redraw.cpp | 30 +- cl_dll/poke646/scope.cpp | 56 +--- cl_dll/tri.cpp | 12 +- cl_dll/view.cpp | 2 + dlls/Android.mk | 12 +- dlls/CMakeLists.txt | 16 +- dlls/barney.cpp | 2 +- dlls/cbase.h | 22 -- dlls/client.cpp | 9 +- dlls/combat.cpp | 2 - dlls/crossbow.cpp | 325 +++++++++++++++++- dlls/crossbow.h | 47 --- dlls/crowbar.cpp | 118 +++---- dlls/doors.cpp | 2 +- dlls/enginecallback.h | 1 + dlls/func_tank.cpp | 5 +- dlls/game.cpp | 2 + dlls/gamerules.h | 2 +- dlls/gauss.cpp | 397 ++++++++-------------- dlls/ggrenade.cpp | 58 ++-- dlls/glock.cpp | 189 +++++++---- dlls/hgrunt.cpp | 63 ++++ dlls/items.cpp | 9 +- dlls/mortar.cpp | 6 +- dlls/mp5.cpp | 242 ++++---------- dlls/multiplay_gamerules.cpp | 3 +- dlls/player.cpp | 328 +++--------------- dlls/player.h | 45 +-- dlls/playermonster.cpp | 2 +- dlls/poke646/bradnailer.cpp | 326 ------------------ dlls/poke646/cmlwbr.cpp | 456 ------------------------- dlls/poke646/firetrail.cpp | 52 ++- dlls/poke646/genericmodel.cpp | 64 +--- dlls/poke646/heaterpipe.cpp | 313 ------------------ dlls/poke646/mp3.cpp | 98 ++++++ dlls/poke646/mp3.h | 7 + dlls/poke646/nail.cpp | 87 ++--- dlls/poke646/nail.h | 20 +- dlls/poke646/nailgun.cpp | 290 ---------------- dlls/poke646/pipebomb.cpp | 227 ------------- dlls/poke646/robocop.cpp | 415 ++++++++++------------- dlls/poke646/weapon_pipebomb.cpp | 310 ----------------- dlls/poke646/xenspit.cpp | 351 -------------------- dlls/poke646/xenspit.h | 71 ---- dlls/poke646/xensquasher.cpp | 11 +- dlls/poke646/xsbeam.cpp | 213 ++++++++++++ dlls/poke646/{pipebomb.h => xsbeam.h} | 45 ++- dlls/satchel.cpp | 212 +++++++----- dlls/schedule.h | 38 +-- dlls/scientist.cpp | 7 +- dlls/shotgun.cpp | 31 +- dlls/sound.cpp | 58 +++- dlls/triggers.cpp | 55 ++-- dlls/util.cpp | 14 + dlls/util.h | 12 + dlls/weapons.cpp | 92 ++---- dlls/weapons.h | 458 ++++---------------------- dlls/world.cpp | 16 +- 74 files changed, 2053 insertions(+), 4837 deletions(-) delete mode 100644 dlls/crossbow.h delete mode 100644 dlls/poke646/bradnailer.cpp delete mode 100644 dlls/poke646/cmlwbr.cpp delete mode 100644 dlls/poke646/heaterpipe.cpp create mode 100644 dlls/poke646/mp3.cpp create mode 100644 dlls/poke646/mp3.h delete mode 100644 dlls/poke646/nailgun.cpp delete mode 100644 dlls/poke646/pipebomb.cpp delete mode 100644 dlls/poke646/weapon_pipebomb.cpp delete mode 100644 dlls/poke646/xenspit.cpp delete mode 100644 dlls/poke646/xenspit.h create mode 100644 dlls/poke646/xsbeam.cpp rename dlls/poke646/{pipebomb.h => xsbeam.h} (50%) diff --git a/cl_dll/Android.mk b/cl_dll/Android.mk index 25e00012..4d73cd8a 100755 --- a/cl_dll/Android.mk +++ b/cl_dll/Android.mk @@ -24,31 +24,11 @@ LOCAL_CFLAGS += -DCLIENT_DLL=1 SRCS= SRCS_C= -SRCS+=../dlls/crossbow.cpp -SRCS+=../dlls/crowbar.cpp -#SRCS+=../dlls/egon.cpp SRCS+=./ev_hldm.cpp -#SRCS+=../dlls/gauss.cpp -#SRCS+=../dlls/handgrenade.cpp SRCS+=./hl/hl_baseentity.cpp SRCS+=./hl/hl_events.cpp SRCS+=./hl/hl_objects.cpp SRCS+=./hl/hl_weapons.cpp -#SRCS+=../dlls/hornetgun.cpp -#SRCS+=../dlls/mp5.cpp -#SRCS+=../dlls/python.cpp -SRCS+=../dlls/rpg.cpp -SRCS+=../dlls/satchel.cpp -SRCS+=../dlls/shotgun.cpp -SRCS+=../dlls/squeakgrenade.cpp -SRCS+=../dlls/tripmine.cpp -#SRCS+=../dlls/glock.cpp -SRCS+=../dlls/poke646/bradnailer.cpp -SRCS+=../dlls/poke646/cmlwbr.cpp -SRCS+=../dlls/poke646/heaterpipe.cpp -SRCS+=../dlls/poke646/nailgun.cpp -SRCS+=../dlls/poke646/weapon_pipebomb.cpp -SRCS+=../dlls/poke646/xensquasher.cpp #SRCS+=../game_shared/voice_banmgr.cpp #SRCS+=../game_shared/voice_status.cpp SRCS+=./ammo.cpp diff --git a/cl_dll/ammo.cpp b/cl_dll/ammo.cpp index a4ce3ec2..0eb1cc92 100644 --- a/cl_dll/ammo.cpp +++ b/cl_dll/ammo.cpp @@ -315,6 +315,7 @@ int CHudAmmo::VidInit( void ) // Load sprites for buckets (top row of weapon menu) m_HUD_bucket0 = gHUD.GetSpriteIndex( "bucket1" ); m_HUD_selection = gHUD.GetSpriteIndex( "selection" ); + m_HUD_stripe = gHUD.GetSpriteIndex( "stripe" ); ghsprBuckets = gHUD.GetSprite( m_HUD_bucket0 ); giBucketWidth = gHUD.GetSpriteRect( m_HUD_bucket0 ).right - gHUD.GetSpriteRect( m_HUD_bucket0 ).left; @@ -425,12 +426,6 @@ void WeaponsResource::SelectSlot( int iSlot, int fAdvance, int iDirection ) if( gHUD.m_fPlayerDead || gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) return; - if ( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) - return; - - if( ! ( gHUD.m_iWeaponBits & ~( 1 << ( WEAPON_SUIT ) ) ) ) - return; - WEAPON *p = NULL; bool fastSwitch = CVAR_GET_FLOAT( "hud_fastswitch" ) != 0; @@ -487,7 +482,7 @@ int CHudAmmo::MsgFunc_AmmoX( const char *pszName, int iSize, void *pbuf ) BEGIN_READ( pbuf, iSize ); int iIndex = READ_BYTE(); - int iCount = READ_BYTE(); + int iCount = READ_SHORT(); gWR.SetAmmo( iIndex, abs( iCount ) ); @@ -498,7 +493,7 @@ int CHudAmmo::MsgFunc_AmmoPickup( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); int iIndex = READ_BYTE(); - int iCount = READ_BYTE(); + int iCount = READ_SHORT(); // Add ammo to the history gHR.AddToHistory( HISTSLOT_AMMO, iIndex, abs( iCount ) ); @@ -537,6 +532,9 @@ int CHudAmmo::MsgFunc_HideWeapon( const char *pszName, int iSize, void *pbuf ) if( gEngfuncs.IsSpectateOnly() ) return 1; + if( !( gHUD.m_iHideHUDDisplay & HIDEHUD_WEAPONS ) ) + gHUD.m_flScaleColorTime = gHUD.m_flTime + 2.0; + if( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) { wrect_t nullrc = {0,}; @@ -833,9 +831,6 @@ int CHudAmmo::Draw( float flTime ) int a, x, y, r, g, b; int AmmoWidth; - if( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) ) - return 1; - if( ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) ) return 1; @@ -861,7 +856,7 @@ int CHudAmmo::Draw( float flTime ) AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; - a = (int) min( gHUD.m_flAlpha, max( MIN_ALPHA, m_fFade) ); + a = (int)max( MIN_ALPHA, m_fFade); if( m_fFade > 0 ) m_fFade -= ( gHUD.m_flTimeDelta * 20 ); @@ -871,7 +866,7 @@ 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 = ScreenHeight - gHUD.m_iFontHeight - 10; // Does weapon have any ammo at all? if( m_pWeapon->iAmmoType > 0 ) @@ -881,40 +876,37 @@ int CHudAmmo::Draw( float flTime ) if( pw->iClip >= 0 ) { // room for the number and the '|' and the current ammo - x = ScreenWidth - ( 8 * AmmoWidth ) - iIconWidth; + int StripeWidth = gHUD.GetSpriteRect( m_HUD_stripe ).right - gHUD.GetSpriteRect( m_HUD_stripe ).left; + + x = ScreenWidth - ( 6 * AmmoWidth ) - iIconWidth - StripeWidth - 62; x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, pw->iClip, r, g, b ); - - /*wrect_t rc; - rc.top = 0; - rc.left = 0; - rc.right = AmmoWidth; - rc.bottom = 100;*/ - - int iBarWidth = AmmoWidth / 10; - - x += AmmoWidth / 2; + x += 16; UnpackRGB( r,g,b, RGB_YELLOWISH ); - // draw the | bar - FillRGBA( x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a ); - - x += iBarWidth + AmmoWidth / 2; - // GL Seems to need this ScaleColors( r, g, b, a ); - x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmoType ), r, g, b ); + + // draw the | bar + SPR_Set( gHUD.GetSprite( m_HUD_stripe ), r, g, b ); + SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_stripe ) ); + + // GL Seems to need this + x = gHUD.DrawHudNumber( x + StripeWidth + 16, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmoType ), r, g, b ); + x += 10; } else { // SPR_Draw a bullets only line - x = ScreenWidth - 4 * AmmoWidth - iIconWidth; + x = ScreenWidth - 4 * AmmoWidth - iIconWidth - 10; x = gHUD.DrawHudNumber( x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo( pw->iAmmoType ), r, g, b ); + x += 10; } // Draw the ammo Icon + // int iOffset = ( m_pWeapon->rcAmmo.bottom - m_pWeapon->rcAmmo.top ) / 8; SPR_Set( m_pWeapon->hAmmo, r, g, b ); - SPR_DrawAdditive( 0, x + iIconWidth / 4, y, &m_pWeapon->rcAmmo ); + SPR_DrawAdditive( 0, x, y + 1, &m_pWeapon->rcAmmo ); } // Does weapon have seconday ammo? @@ -931,7 +923,8 @@ int CHudAmmo::Draw( float flTime ) // Draw the ammo Icon SPR_Set( m_pWeapon->hAmmo2, r, g, b ); - SPR_DrawAdditive( 0, x + iIconWidth / 4, y, &m_pWeapon->rcAmmo2 ); + int iOffset = ( m_pWeapon->rcAmmo2.bottom - m_pWeapon->rcAmmo2.top ) / 8; + SPR_DrawAdditive( 0, x, y - iOffset, &m_pWeapon->rcAmmo2 ); } } return 1; @@ -949,7 +942,7 @@ int DrawBar( int x, int y, int width, int height, float f ) if( f > 1 ) f = 1; - if( f ) + if( f > 0 ) { int w = f * width; @@ -961,18 +954,19 @@ int DrawBar( int x, int y, int width, int height, float f ) r = 255 - g; b = 0; - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 255 ) ); + //ScaleColors( r, g, b, min( gHUD.m_flAlpha, 255 ) ); - FillRGBA( x, y, w, height, r, g, b, min( gHUD.m_flAlpha, 255 ) ); + FillRGBA( x, y, w, height, 255 - g, g, 0, 255 ); x += w; width -= w; } else { - UnpackRGB( r, g, b, RGB_YELLOWISH ); + r=g=b=f; +// UnpackRGB( r, g, b, RGB_YELLOWISH ); } - FillRGBA( x, y, width, height, r, g, b, min( gHUD.m_flAlpha, 128 ) ); + FillRGBA( x, y, width, height, r, g, b, 64 ); return( x + width ); } @@ -1010,87 +1004,53 @@ int CHudAmmo::DrawWList( float flTime ) { int r, g, b, x, y, a, i; - if( !gpActiveSel ) - return 0; - - int iActiveSlot; - - if( gpActiveSel == (WEAPON *)1 ) - iActiveSlot = -1; // current slot has no weapons - else - iActiveSlot = gpActiveSel->iSlot; - x = 10; //!!! y = 10; //!!! - // Ensure that there are available choices in the active slot - if( iActiveSlot > 0 ) - { - if( !gWR.GetFirstPos( iActiveSlot ) ) - { - gpActiveSel = (WEAPON *)1; - iActiveSlot = -1; - } - } - // Draw top line for( i = 0; i < MAX_WEAPON_SLOTS; i++ ) { - int iHeight; - UnpackRGB( r, g, b, RGB_YELLOWISH ); - if( iActiveSlot == i ) - a = min( gHUD.m_flAlpha, 255 ); - else - a = min( gHUD.m_flAlpha, 192 ); - - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 128 ) ); // 255 + ScaleColors( r, g, b, 100 ); // 255 SPR_Set( gHUD.GetSprite( m_HUD_bucket0 + i ), r, g, b ); - - // make active slot wide enough to accomodate gun pictures - if( i == iActiveSlot ) - { - WEAPON *p = gWR.GetFirstPos( iActiveSlot ); - if( p ) - iHeight = p->rcActive.bottom - p->rcActive.top; - else - iHeight = giBucketWidth; - } - else - iHeight = giBucketHeight; - SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_bucket0 + i ) ); - y += iHeight + 5; + y += giBucketHeight + 4; } - a = min(gHUD.m_flAlpha, 128); //!!! + if( !gpActiveSel ) + return 0; + + if( gpActiveSel != (WEAPON *)1 ) + { + if( gpActiveSel->iSlot > 0 && !gWR.GetFirstPos( gpActiveSel->iSlot ) ) + { + gpActiveSel = (WEAPON *)1; + } + } y = 10; // Draw all of the buckets for( i = 0; i < MAX_WEAPON_SLOTS; i++ ) { - x = giBucketWidth + 15; + x = giBucketWidth + 14; - WEAPON *p = gWR.GetFirstPos( i ); - int iHeight = giBucketHeight; - if( p ) - iHeight = p->rcActive.bottom - p->rcActive.top; + WEAPON *p; // = gWR.GetFirstPos( i ); for( int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++ ) { p = gWR.GetWeaponSlot( i, iPos ); if( !p || !p->iId ) - continue; + continue; - UnpackRGB( r, g, b, RGB_YELLOWISH ); + UnpackRGB( r, g, b, RGB_WHITEISH ); // if active, then we must have ammo. if( gpActiveSel == p ) { - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 192 ) ); + ScaleColors( r, g, b, 192 ); SPR_Set( p->hActive, r, g, b ); SPR_DrawAdditive( 0, x, y, &p->rcActive ); @@ -1099,21 +1059,21 @@ int CHudAmmo::DrawWList( float flTime ) { // Draw Weapon if Red if no ammo if( gWR.HasAmmo( p ) ) - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 192 ) ); + ScaleColors( r, g, b, 192 ); else - ScaleColors( r, g, b, min( gHUD.m_flAlpha, 64 ) ); + ScaleColors( r, g, b, 96 ); SPR_Set( p->hInactive, r, g, b ); SPR_DrawAdditive( 0, x, y, &p->rcInactive ); } // Draw Ammo Bar - DrawAmmoBar( p, x + giABWidth/2, y, giABWidth, giABHeight ); + DrawAmmoBar( p, x + 1, y + 1, giABWidth, giABHeight ); - x += p->rcActive.right - p->rcActive.left + 5; + x += p->rcActive.right - p->rcActive.left + 4; } - y += iHeight + 5; + y += giBucketHeight + 4; } return 1; diff --git a/cl_dll/ammo_secondary.cpp b/cl_dll/ammo_secondary.cpp index 474c6869..954ff211 100644 --- a/cl_dll/ammo_secondary.cpp +++ b/cl_dll/ammo_secondary.cpp @@ -61,7 +61,7 @@ int CHudAmmoSecondary::Draw( float flTime ) // draw secondary ammo icons above normal ammo readout int a, x, y, r, g, b, AmmoWidth; UnpackRGB( r, g, b, RGB_YELLOWISH ); - a = (int) max( min( gHUD.m_flAlpha, MIN_ALPHA ), m_fFade ); + a = (int) max( MIN_ALPHA, m_fFade ); if( m_fFade > 0 ) m_fFade -= ( gHUD.m_flTimeDelta * 20 ); // slowly lower alpha to fade out icons ScaleColors( r, g, b, a ); diff --git a/cl_dll/ammohistory.cpp b/cl_dll/ammohistory.cpp index aea573d5..4b1e6745 100644 --- a/cl_dll/ammohistory.cpp +++ b/cl_dll/ammohistory.cpp @@ -139,8 +139,10 @@ int HistoryResource::DrawAmmoHistory( float flTime ) SPR_DrawAdditive( 0, xpos, ypos, &rcPic ); } - // Draw the number - gHUD.DrawHudNumberString( xpos - 10, ypos, xpos - 100, rgAmmoHistory[i].iCount, r, g, b ); + // 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 ); } else if( rgAmmoHistory[i].type == HISTSLOT_WEAP ) { @@ -156,7 +158,7 @@ int HistoryResource::DrawAmmoHistory( float flTime ) UnpackRGB( r, g, b, RGB_REDISH ); // if the weapon doesn't have ammo, display it as red float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80; - ScaleColors( r, g, b, min( gHUD.m_flAlpha, min( scale, 255 ) ) ); + ScaleColors( r, g, b, min( scale, 255 ) ); int ypos = ScreenHeight - ( AMMO_PICKUP_PICK_HEIGHT + ( AMMO_PICKUP_GAP * i ) ); int xpos = ScreenWidth - ( weap->rcInactive.right - weap->rcInactive.left ); @@ -174,7 +176,7 @@ int HistoryResource::DrawAmmoHistory( float flTime ) UnpackRGB( r, g, b, RGB_YELLOWISH ); float scale = ( rgAmmoHistory[i].DisplayTime - flTime ) * 80; - ScaleColors( r, g, b, min( gHUD.m_flAlpha, min( scale, 255 ) ) ); + ScaleColors( r, g, b, min( scale, 255 ) ); int ypos = ScreenHeight - ( AMMO_PICKUP_PICK_HEIGHT + ( AMMO_PICKUP_GAP * i ) ); int xpos = ScreenWidth - ( rect.right - rect.left ) - 10; diff --git a/cl_dll/cdll_int.cpp b/cl_dll/cdll_int.cpp index 543356b2..9a3bbd49 100644 --- a/cl_dll/cdll_int.cpp +++ b/cl_dll/cdll_int.cpp @@ -45,11 +45,6 @@ void InitInput( void ); void EV_HookEvents( void ); void IN_Commands( void ); -extern cvar_t *cl_upspeed; -extern cvar_t *cl_forwardspeed; -extern cvar_t *cl_backspeed; -extern cvar_t *cl_sidespeed; - int __MsgFunc_Bhopcap( const char *pszName, int iSize, void *pbuf ) { BEGIN_READ( pbuf, iSize ); @@ -242,14 +237,6 @@ int DLLEXPORT HUD_VidInit( void ) { gHUD.VidInit(); - // - // Fixup player speed. - // - cl_upspeed->value = - cl_forwardspeed->value = - cl_backspeed->value = - cl_sidespeed->value = 200; - #ifdef USE_VGUI_FOR_GOLDSOURCE_SUPPORT vgui::Panel* root=(vgui::Panel*)gEngfuncs.VGui_GetPanel(); if (root) { diff --git a/cl_dll/entity.cpp b/cl_dll/entity.cpp index 303a9d25..792c2f97 100644 --- a/cl_dll/entity.cpp +++ b/cl_dll/entity.cpp @@ -22,6 +22,7 @@ void Game_AddObjects( void ); +bool bDrawScope; extern vec3_t v_origin; int g_iAlive = 1; @@ -95,6 +96,7 @@ void DLLEXPORT HUD_TxferLocalOverrides( struct entity_state_s *state, const stru // Fire prevention state->iuser4 = client->iuser4; + bDrawScope = client->iuser4; } /* @@ -213,6 +215,7 @@ void DLLEXPORT HUD_TxferPredictionData( struct entity_state_s *ps, const struct // Fire prevention pcd->iuser4 = ppcd->iuser4; + bDrawScope = ppcd->iuser4; pcd->fuser2 = ppcd->fuser2; pcd->fuser3 = ppcd->fuser3; diff --git a/cl_dll/ev_hldm.cpp b/cl_dll/ev_hldm.cpp index 1c16656f..a6cac4fd 100644 --- a/cl_dll/ev_hldm.cpp +++ b/cl_dll/ev_hldm.cpp @@ -50,8 +50,8 @@ extern cvar_t *cl_lw; extern "C" { // HLDM -void EV_FireGlock1( struct event_args_s *args ); -void EV_FireGlock2( struct event_args_s *args ); +//void EV_FireGlock1( struct event_args_s *args ); +//void EV_FireGlock2( struct event_args_s *args ); void EV_FireShotGunSingle( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); @@ -210,16 +210,8 @@ float EV_HLDM_PlayTextureSound( int idx, pmtrace_t *ptr, float *vecSrc, float *v return 0.0; // crowbar already makes this sound fvol = 1.0; fvolbar = 0.2; - if( iBulletType == BULLET_PLAYER_NAIL ) - { - rgsz[0] = "weapons/brad_hit1.wav"; - rgsz[1] = "weapons/brad_hit2.wav"; - } - else - { - rgsz[0] = "weapons/bullet_hit1.wav"; - rgsz[1] = "weapons/bullet_hit2.wav"; - } + rgsz[0] = "weapons/bullet_hit1.wav"; + rgsz[1] = "weapons/bullet_hit2.wav"; fattn = 1.0; cnt = 2; break; @@ -311,12 +303,12 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName ) TEMPENTITY* pSmoke = gEngfuncs.pEfxAPI->R_TempSprite( position, // position velocity, // velocity - gEngfuncs.pfnRandomFloat( 30, 35 ) / 100, // scale + gEngfuncs.pfnRandomFloat( 0.3f, 0.5f ), // scale modelindex, // model index kRenderNormal, // rendermode kRenderFxNoDissipation, // renderfx - gEngfuncs.pfnRandomFloat( 0.25, 0.5 ), // alpha - 0.01, // life + 0.5, // alpha + 0.3, // life FTENT_SPRCYCLE | FTENT_FADEOUT ); // flags if( pSmoke ) @@ -325,7 +317,7 @@ void EV_HLDM_GunshotDecalTrace( pmtrace_t *pTrace, char *decalName ) VectorAngles( velocity, angles ); pSmoke->flags |= FTENT_CLIENTCUSTOM; - pSmoke->entity.curstate.framerate = 4; + pSmoke->entity.curstate.framerate = 30; pSmoke->entity.baseline.vuser1 = angles; pSmoke->callback = EV_WallPuffCallback; } @@ -349,7 +341,6 @@ void EV_HLDM_DecalGunshot( pmtrace_t *pTrace, int iBulletType ) case BULLET_MONSTER_MP5: case BULLET_PLAYER_BUCKSHOT: case BULLET_PLAYER_357: - //case BULLET_PLAYER_NAIL: default: // smoke and decal EV_HLDM_GunshotDecalTrace( pTrace, EV_HLDM_DamageDecal( pe ) ); @@ -389,7 +380,6 @@ int EV_HLDM_CheckTracer( int idx, float *vecSrc, float *end, float *forward, flo switch( iBulletType ) { case BULLET_PLAYER_MP5: - case BULLET_PLAYER_NAIL: case BULLET_MONSTER_MP5: case BULLET_MONSTER_9MM: case BULLET_MONSTER_12MM: @@ -421,28 +411,16 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int vec3_t vecDir, vecEnd; float x, y, z; - //We randomize for the Shotgun. - if( iBulletType == BULLET_PLAYER_BUCKSHOT ) - { - do{ - x = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); - y = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); - z = x * x + y * y; - }while( z > 1 ); + do{ + x = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); + y = gEngfuncs.pfnRandomFloat( -0.5, 0.5 ) + gEngfuncs.pfnRandomFloat( -0.5, 0.5 ); + z = x * x + y * y; + }while( z > 1 ); - for( i = 0 ; i < 3; i++ ) - { - vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[i] + y * flSpreadY * up [i]; - vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; - } - }//But other guns already have their spread randomized in the synched spread. - else + for( i = 0 ; i < 3; i++ ) { - for( i = 0 ; i < 3; i++ ) - { - vecDir[i] = vecDirShooting[i] + flSpreadX * right[i] + flSpreadY * up [i]; - vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; - } + vecDir[i] = vecDirShooting[i] + x * flSpreadX * right[i] + y * flSpreadY * up [i]; + vecEnd[i] = vecSrc[i] + flDistance * vecDir[i]; } gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); @@ -482,13 +460,6 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); EV_HLDM_DecalGunshot( &tr, iBulletType ); break; - case BULLET_PLAYER_NAIL: - if( !tracer ) - { - EV_HLDM_PlayTextureSound( idx, &tr, vecSrc, vecEnd, iBulletType ); - // EV_HLDM_DecalGunshot( &tr, iBulletType ); - } - break; } } @@ -499,7 +470,7 @@ void EV_HLDM_FireBullets( int idx, float *forward, float *right, float *up, int //====================== // GLOCK START //====================== -void EV_FireGlock1( event_args_t *args ) +/*void EV_FireGlock1( event_args_t *args ) { int idx; vec3_t origin; @@ -588,7 +559,7 @@ void EV_FireGlock2( event_args_t *args ) VectorCopy( forward, vecAiming ); EV_HLDM_FireBullets( idx, forward, right, up, 1, vecSrc, vecAiming, 8192, BULLET_PLAYER_9MM, 0, &g_tracerCount[idx - 1], args->fparam1, args->fparam2 ); -} +}*/ //====================== // GLOCK END //====================== @@ -626,7 +597,7 @@ void EV_FireShotGunSingle( event_args_t *args ) EV_MuzzleFlash(); gEngfuncs.pEventAPI->EV_WeaponAnimation( SHOTGUN_FIRE, 2 ); - V_PunchAxis( 0, -5.0 ); + V_PunchAxis( 0, -15.0 ); } EV_GetDefaultShellInfo( args, origin, velocity, ShellVelocity, ShellOrigin, forward, right, up, 32, -12, 6 ); @@ -638,19 +609,14 @@ void EV_FireShotGunSingle( event_args_t *args ) EV_GetGunPosition( args, vecSrc, origin ); VectorCopy( forward, vecAiming ); - if( gEngfuncs.GetMaxClients() > 1 ) - { - EV_HLDM_FireBullets( idx, forward, right, up, 4, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.04362 ); - } - else - { - EV_HLDM_FireBullets( idx, forward, right, up, 6, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.08716 ); - } + EV_HLDM_FireBullets( idx, forward, right, up, 12, vecSrc, vecAiming, 2048, BULLET_PLAYER_BUCKSHOT, 0, &g_tracerCount[idx - 1], 0.08716, 0.08716 ); } //====================== // SHOTGUN END //====================== +#define SND_CHANGE_PITCH (1 << 7) // duplicated in protocol.h change sound pitch + void EV_TrainPitchAdjust( event_args_t *args ) { int idx; @@ -732,6 +698,15 @@ enum xensquasher_e XS_RELOAD, }; +void EV_StopPreviousXS( int idx ) +{ + // Make sure we don't have a gauss spin event in the queue for this guy + gEngfuncs.pEventAPI->EV_KillEvents( idx, "events/xsspin.sc" ); + gEngfuncs.pEventAPI->EV_StopSound( idx, CHAN_WEAPON, "weapons/xs_windup.wav" ); + if( EV_IsLocal( idx ) ) + gEngfuncs.pEventAPI->EV_WeaponAnimation( XS_FIRE2, 2 ); +} + void EV_SpinXS( event_args_t *args ) { int idx; @@ -743,9 +718,16 @@ void EV_SpinXS( event_args_t *args ) int pitch; idx = args->entindex; + + if( args->bparam2 ) + { + EV_StopPreviousXS( idx ); + return; + } + VectorCopy( args->origin, origin ); - VectorCopy( args->angles, angles ); - VectorCopy( args->velocity, velocity ); + // VectorCopy( args->angles, angles ); + // VectorCopy( args->velocity, velocity ); pitch = args->iparam1; diff --git a/cl_dll/ev_hldm.h b/cl_dll/ev_hldm.h index 85ca53b5..0403c686 100644 --- a/cl_dll/ev_hldm.h +++ b/cl_dll/ev_hldm.h @@ -18,8 +18,6 @@ typedef enum BULLET_PLAYER_357, // python BULLET_PLAYER_BUCKSHOT, // shotgun BULLET_PLAYER_CROWBAR, // crowbar swipe - BULLET_PLAYER_NAIL, // nails - BULLET_PLAYER_XS, // xen squasher BULLET_MONSTER_9MM, BULLET_MONSTER_MP5, BULLET_MONSTER_12MM diff --git a/cl_dll/health.cpp b/cl_dll/health.cpp index 0ee4309f..12f788c2 100644 --- a/cl_dll/health.cpp +++ b/cl_dll/health.cpp @@ -61,7 +61,7 @@ int CHudHealth::Init( void ) { HOOK_MESSAGE( Health ); HOOK_MESSAGE( Damage ); - m_iHealth = 50; + m_iHealth = 100; m_fFade = 0; m_iFlags = 0; m_bitsDamage = 0; @@ -156,25 +156,33 @@ int CHudHealth::MsgFunc_Damage( const char *pszName, int iSize, void *pbuf ) // Green <-> Yellow <-> Red ramp void CHudHealth::GetPainColor( int &r, int &g, int &b ) { +#if 0 int iHealth = m_iHealth; if( iHealth > 25 ) iHealth -= 25; else if( iHealth < 0 ) iHealth = 0; -#if 0 + g = iHealth * 255 / 100; r = 255 - g; b = 0; #else - if( m_iHealth > 25 ) + if( m_iHealth <= 0 ) + { + UnpackRGB( r, g, b, RGB_REDISH ); + } + else if( m_iHealth > 15 ) { UnpackRGB( r, g, b, RGB_YELLOWISH ); } else { UnpackRGB( r, g, b, RGB_YELLOWISH ); - g = b = 255 * fabs( sin( gEngfuncs.GetClientTime() * M_PI * 2.0f ) ); + float f = ( sin( ( 16 - gHUD.m_flTime ) * m_iHealth ) + 1.0 ) * 0.5; + r = (int)( r * f * 58.0f ); + g = (int)( g * f ); + b = (int)( b * f ); } #endif } @@ -197,44 +205,37 @@ int CHudHealth::Draw( float flTime ) m_fFade -= ( gHUD.m_flTimeDelta * 20 ); if( m_fFade <= 0 ) { - a = MIN_ALPHA; m_fFade = 0; } // Fade the health number back to dim - a = min( gHUD.m_flAlpha, MIN_ALPHA ) + ( m_fFade / FADE_TIME ) * 128; + a = MIN_ALPHA + ( m_fFade / FADE_TIME ) * 128; } else - a = min( gHUD.m_flAlpha, MIN_ALPHA ); + a = MIN_ALPHA; // If health is getting low, make it bright red if( m_iHealth <= 15 ) - a = 255; + a = 192; GetPainColor( r, g, b ); ScaleColors( r, g, b, a ); - // Only draw health if we have the suit. - if( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) ) - { - HealthWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left; + wrect_t cross = gHUD.GetSpriteRect( m_HUD_cross ); - wrect_t cross = gHUD.GetSpriteRect( m_HUD_cross ); + int CrossWidth = cross.right - cross.left; + int CrossHeight = cross.bottom - cross.top; - int CrossWidth = cross.right - cross.left; - int CrossHeight = cross.bottom - cross.top; + x = 10; + y = ScreenHeight - CrossHeight - 10; - y = ScreenHeight - gHUD.m_iFontHeight / 2 - CrossHeight; - x = CrossWidth; + SPR_Set( gHUD.GetSprite( m_HUD_cross ), r, g, b ); + SPR_DrawAdditive( 0, 10, y, &cross ); - SPR_Set( gHUD.GetSprite( m_HUD_cross ), r, g, b ); - SPR_DrawAdditive( 0, x, y, &cross ); + x = CrossWidth + 20; + y = ScreenHeight - gHUD.m_iFontHeight - 10; - y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2; - x = CrossWidth * 2.0f + HealthWidth; - - x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b ); - } + gHUD.DrawHudNumber( x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b ); DrawDamage( flTime ); return DrawPain( flTime ); diff --git a/cl_dll/hl/hl_baseentity.cpp b/cl_dll/hl/hl_baseentity.cpp index 158957c8..38978f6a 100644 --- a/cl_dll/hl/hl_baseentity.cpp +++ b/cl_dll/hl/hl_baseentity.cpp @@ -302,10 +302,6 @@ const char *CBasePlayer::TeamID( void ) { return ""; } int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax ) { return 0; } void CBasePlayer::AddPoints( int score, BOOL bAllowNegativeScore ) { } void CBasePlayer::AddPointsToTeam( int score, BOOL bAllowNegativeScore ) { } -void CBasePlayer::IncrementExertLevel( int amount ) { } -void CBasePlayer::DecrementExertLevel( int amount ) { } -void CBasePlayer::ShowPlayerHUD( BOOL bInstant ) {} -void CBasePlayer::HidePlayerHUD( BOOL bInstant ) {} void ClearMultiDamage( void ) { } void ApplyMultiDamage( entvars_t *pevInflictor, entvars_t *pevAttacker ) { } diff --git a/cl_dll/hl/hl_events.cpp b/cl_dll/hl/hl_events.cpp index 4668fa4d..49c66b40 100644 --- a/cl_dll/hl/hl_events.cpp +++ b/cl_dll/hl/hl_events.cpp @@ -20,8 +20,8 @@ extern "C" { // HLDM -void EV_FireGlock1( struct event_args_s *args ); -void EV_FireGlock2( struct event_args_s *args ); +//void EV_FireGlock1( struct event_args_s *args ); +//void EV_FireGlock2( struct event_args_s *args ); void EV_FireShotGunSingle( struct event_args_s *args ); void EV_TrainPitchAdjust( struct event_args_s *args ); @@ -44,10 +44,9 @@ That was what we were going to do, but we ran out of time...oh well. */ void Game_HookEvents( void ) { - gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 ); - gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 ); + // gEngfuncs.pfnHookEvent( "events/glock1.sc", EV_FireGlock1 ); + // gEngfuncs.pfnHookEvent( "events/glock2.sc", EV_FireGlock2 ); gEngfuncs.pfnHookEvent( "events/shotgun1.sc", EV_FireShotGunSingle ); - gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust ); - gEngfuncs.pfnHookEvent( "events/xsspin.sc", EV_SpinXS ); + gEngfuncs.pfnHookEvent( "events/train.sc", EV_TrainPitchAdjust ); } diff --git a/cl_dll/hl/hl_objects.cpp b/cl_dll/hl/hl_objects.cpp index b51ee693..dfeb4e1f 100644 --- a/cl_dll/hl/hl_objects.cpp +++ b/cl_dll/hl/hl_objects.cpp @@ -27,54 +27,10 @@ #include "entity_types.h" #include "r_efx.h" -extern BEAM *pBeam; -extern BEAM *pBeam2; void HUD_GetLastOrg( float *org ); void UpdateBeams( void ) { - vec3_t forward, vecSrc, vecEnd, origin, angles, right, up; - vec3_t view_ofs; - pmtrace_t tr; - cl_entity_t *pthisplayer = gEngfuncs.GetLocalPlayer(); - int idx = pthisplayer->index; - - // Get our exact viewangles from engine - gEngfuncs.GetViewAngles( (float *)angles ); - - // Determine our last predicted origin - HUD_GetLastOrg( (float *)&origin ); - - AngleVectors( angles, forward, right, up ); - - VectorCopy( origin, vecSrc ); - - VectorMA( vecSrc, 2048, forward, vecEnd ); - - gEngfuncs.pEventAPI->EV_SetUpPlayerPrediction( false, true ); - - // Store off the old count - gEngfuncs.pEventAPI->EV_PushPMStates(); - - // 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_PopPMStates(); - - if( pBeam ) - { - pBeam->target = tr.endpos; - pBeam->die = gEngfuncs.GetClientTime() + 0.1; // We keep it alive just a little bit forward in the future, just in case. - } - - if( pBeam2 ) - { - 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. - } } /* @@ -86,6 +42,4 @@ Add game specific, client-side objects here */ void Game_AddObjects( void ) { - if( pBeam && pBeam2 ) - UpdateBeams(); } diff --git a/cl_dll/hl/hl_weapons.cpp b/cl_dll/hl/hl_weapons.cpp index f9c09096..e467886e 100644 --- a/cl_dll/hl/hl_weapons.cpp +++ b/cl_dll/hl/hl_weapons.cpp @@ -692,11 +692,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm pCurrent->m_flNextSecondaryAttack = pfrom->m_flNextSecondaryAttack; pCurrent->m_flTimeWeaponIdle = pfrom->m_flTimeWeaponIdle; pCurrent->pev->fuser1 = pfrom->fuser1; - pCurrent->m_flStartThrow = pfrom->fuser2; - pCurrent->m_flReleaseThrow = pfrom->fuser3; - pCurrent->m_chargeReady = pfrom->iuser1; - pCurrent->m_fInAttack = pfrom->iuser2; - pCurrent->m_fireState = pfrom->iuser3; pCurrent->m_iSecondaryAmmoType = (int)from->client.vuser3[2]; pCurrent->m_iPrimaryAmmoType = (int)from->client.vuser4[0]; @@ -735,30 +730,12 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm player.m_flNextAmmoBurn = from->client.fuser2; player.m_flAmmoStartCharge = from->client.fuser3; - //Stores all our ammo info, so the client side weapons can use them. - player.ammo_9mm = (int)from->client.vuser1[0]; - player.ammo_357 = (int)from->client.vuser1[1]; - player.ammo_argrens = (int)from->client.vuser1[2]; - player.ammo_bolts = (int)from->client.ammo_nails; //is an int anyways... - player.ammo_buckshot = (int)from->client.ammo_shells; - player.ammo_uranium = (int)from->client.ammo_cells; - player.ammo_hornets = (int)from->client.vuser2[0]; - player.ammo_rockets = (int)from->client.ammo_rockets; - // Point to current weapon object if( from->client.m_iId ) { player.m_pActiveItem = g_pWpns[from->client.m_iId]; } - if( player.m_pActiveItem->m_iId == WEAPON_BRADNAILER || player.m_pActiveItem->m_iId == WEAPON_NAILGUN ) - { - player.ammo_nails = (int)from->client.vuser2[1]; - } - else if( player.m_pActiveItem->m_iId == WEAPON_XS ) - { - player.ammo_xencandy = (int)from->client.vuser2[1]; - } // Don't go firing anything if we have died. // Or if we don't have a weapon model deployed @@ -811,26 +788,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm to->client.fuser3 = player.m_flAmmoStartCharge; to->client.maxspeed = player.pev->maxspeed; - //HL Weapons - to->client.vuser1[0] = player.ammo_9mm; - to->client.vuser1[1] = player.ammo_357; - to->client.vuser1[2] = player.ammo_argrens; - - to->client.ammo_nails = player.ammo_bolts; - to->client.ammo_shells = player.ammo_buckshot; - to->client.ammo_cells = player.ammo_uranium; - to->client.vuser2[0] = player.ammo_hornets; - to->client.ammo_rockets = player.ammo_rockets; - - if( player.m_pActiveItem->m_iId == WEAPON_BRADNAILER || player.m_pActiveItem->m_iId == WEAPON_NAILGUN ) - { - from->client.vuser2[1] = player.ammo_nails; - } - else if( player.m_pActiveItem->m_iId == WEAPON_XS ) - { - from->client.vuser2[1] = player.ammo_xencandy; - } - // Make sure that weapon animation matches what the game .dll is telling us // over the wire ( fixes some animation glitches ) if( g_runfuncs && ( HUD_GetWeaponAnim() != to->client.weaponanim ) ) @@ -861,11 +818,6 @@ void HUD_WeaponsPostThink( local_state_s *from, local_state_s *to, usercmd_t *cm pto->m_flNextSecondaryAttack = pCurrent->m_flNextSecondaryAttack; pto->m_flTimeWeaponIdle = pCurrent->m_flTimeWeaponIdle; pto->fuser1 = pCurrent->pev->fuser1; - pto->fuser2 = pCurrent->m_flStartThrow; - pto->fuser3 = pCurrent->m_flReleaseThrow; - pto->iuser1 = pCurrent->m_chargeReady; - pto->iuser2 = pCurrent->m_fInAttack; - pto->iuser3 = pCurrent->m_fireState; // Decrement weapon counters, server does this at same time ( during post think, after doing everything else ) pto->m_flNextReload -= cmd->msec / 1000.0; diff --git a/cl_dll/hud.cpp b/cl_dll/hud.cpp index 06168fae..770fce2a 100644 --- a/cl_dll/hud.cpp +++ b/cl_dll/hud.cpp @@ -78,9 +78,26 @@ int __MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) return gHUD.MsgFunc_GameMode( pszName, iSize, pbuf ); } -int __MsgFunc_StartUp( const char *pszName, int iSize, void *pbuf ) +int __MsgFunc_PlayMP3( const char *pszName, int iSize, void *pbuf ) { - return gHUD.MsgFunc_StartUp( pszName, iSize, pbuf ); + const char *pszSound; + char cmd[64], path[64]; + int loop; + + BEGIN_READ( pbuf, iSize ); + pszSound = READ_STRING(); + loop = READ_BYTE(); + + sprintf( path, "sound/%s", pszSound ); + if( !isXashFWGS() && gEngfuncs.pfnGetCvarPointer( "gl_overbright" ) ) + { + sprintf( cmd, "mp3 play %s\n", path ); + gEngfuncs.pfnClientCmd( cmd ); + } + else + gEngfuncs.pfnPrimeMusicStream( path, loop ); + + return 1; } // TFFree Command Menu @@ -166,7 +183,7 @@ void CHud::Init( void ) HOOK_MESSAGE( ViewMode ); HOOK_MESSAGE( SetFOV ); HOOK_MESSAGE( Concuss ); - HOOK_MESSAGE( StartUp ); + HOOK_MESSAGE( PlayMP3 ); // TFFree CommandMenu HOOK_COMMAND( "+commandmenu", OpenCommandMenu ); @@ -195,8 +212,6 @@ void CHud::Init( void ) m_iLogo = 0; m_iFOV = 0; - m_flAlpha = 0; - m_flTargetAlpha = 0; CVAR_CREATE( "zoom_sensitivity_ratio", "1.2", 0 ); default_fov = CVAR_CREATE( "default_fov", "90", 0 ); @@ -237,7 +252,6 @@ void CHud::Init( void ) m_AmmoSecondary.Init(); m_TextMessage.Init(); m_StatusIcons.Init(); - m_Scope.Init(); m_MOTD.Init(); m_Scoreboard.Init(); @@ -407,7 +421,6 @@ void CHud::VidInit( void ) m_AmmoSecondary.VidInit(); m_TextMessage.VidInit(); m_StatusIcons.VidInit(); - m_Scope.VidInit(); m_Scoreboard.VidInit(); m_MOTD.VidInit(); } @@ -590,29 +603,3 @@ float CHud::GetSensitivity( void ) return m_flMouseSensitivity; } -int CHud::MsgFunc_StartUp( const char *pszName, int iSize, void *pbuf ) -{ - BEGIN_READ( pbuf, iSize ); - - // Target alpha - float alpha = READ_BYTE(); - - if( alpha < 0 ) - alpha = 0; - else if( alpha > 255 ) - alpha = 255; - - m_flTargetAlpha = alpha; - - // Start alpha - alpha = READ_BYTE(); - - if( alpha < 0 ) - alpha = 0; - else if( alpha > 255 ) - alpha = 255; - - m_flAlpha = alpha; - - return 1; -} diff --git a/cl_dll/hud.h b/cl_dll/hud.h index c9a94cda..b6fd0c0d 100644 --- a/cl_dll/hud.h +++ b/cl_dll/hud.h @@ -22,8 +22,9 @@ #pragma once #ifndef HUD_H #define HUD_H -#define RGB_YELLOWISH 0x00FFFFFF //255,255,255 -#define RGB_REDISH 0x00FF1010 //255,160,0 +#define RGB_YELLOWISH 0x00C1CFCB //193,207,203 +#define RGB_WHITEISH 0x00FAFAFA //250,250,250 +#define RGB_REDISH 0x00FA0000 //250,0,0 #define RGB_GREENISH 0x0000A000 //0,160,0 #include "wrect.h" @@ -132,6 +133,7 @@ private: WEAPON *m_pWeapon; int m_HUD_bucket0; int m_HUD_selection; + int m_HUD_stripe; }; // @@ -561,15 +563,9 @@ private: // //----------------------------------------------------- // -class CHudScope : public CHudBase +class CHudScope { public: - int Init( void ); - int VidInit( void ); - int Draw( float flTime ); - void Reset( void ); - int MsgFunc_Scope( const char *pszName, int iSize, void *pbuf ); - int DrawScope( void ); private: @@ -595,6 +591,7 @@ public: HSPRITE m_hsprCursor; float m_flTime; // the current client time float m_fOldTime; // the time at which the HUD was last redrawn + float m_flScaleColorTime; double m_flTimeDelta; // the difference between flTime and fOldTime Vector m_vecOrigin; Vector m_vecAngles; @@ -673,7 +670,6 @@ public: void _cdecl MsgFunc_ViewMode( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_SetFOV( const char *pszName, int iSize, void *pbuf ); int _cdecl MsgFunc_Concuss( const char *pszName, int iSize, void *pbuf ); - int _cdecl MsgFunc_StartUp( const char *pszName, int iSize, void *pbuf ); // Screen information SCREENINFO m_scrinfo; @@ -690,11 +686,6 @@ public: void AddHudElem( CHudBase *p ); float GetSensitivity(); - - float m_flAlpha; - -private: - float m_flTargetAlpha; }; extern CHud gHUD; diff --git a/cl_dll/hud_msg.cpp b/cl_dll/hud_msg.cpp index 47f8bc92..676934ce 100644 --- a/cl_dll/hud_msg.cpp +++ b/cl_dll/hud_msg.cpp @@ -23,9 +23,6 @@ #define MAX_CLIENTS 32 -extern BEAM *pBeam; -extern BEAM *pBeam2; - /// USER-DEFINED SERVER MESSAGE HANDLERS int CHud::MsgFunc_ResetHUD( const char *pszName, int iSize, void *pbuf ) @@ -69,9 +66,6 @@ void CHud::MsgFunc_InitHUD( const char *pszName, int iSize, void *pbuf ) pList->p->InitHUDData(); pList = pList->pNext; } - - //Probably not a good place to put this. - pBeam = pBeam2 = NULL; } int CHud::MsgFunc_GameMode( const char *pszName, int iSize, void *pbuf ) diff --git a/cl_dll/hud_redraw.cpp b/cl_dll/hud_redraw.cpp index 9ae50cda..20c60ebf 100644 --- a/cl_dll/hud_redraw.cpp +++ b/cl_dll/hud_redraw.cpp @@ -79,7 +79,6 @@ void CHud::Think( void ) } } -void HUD_DrawOrthoTriangles( void ); // Redraw // step through the local data, placing the appropriate graphics & text as appropriate @@ -113,8 +112,6 @@ int CHud::Redraw( float flTime, int intermission ) // if no redrawing is necessary // return 0; - HUD_DrawOrthoTriangles(); - if( m_pCvarDraw->value ) { HUDLIST *pList = m_pHudList; @@ -180,23 +177,26 @@ int CHud::Redraw( float flTime, int intermission ) } */ - // - // Slowly increase HUD alpha value. - // - if( m_flAlpha != m_flTargetAlpha ) - { - if( m_flAlpha < m_flTargetAlpha ) - m_flAlpha = min( m_flAlpha + 2, m_flTargetAlpha ); - else if( m_flAlpha > m_flTargetAlpha ) - m_flAlpha = max( m_flAlpha - 8, m_flTargetAlpha ); - } - return 1; } void ScaleColors( int &r, int &g, int &b, int a ) { - float x = (float)a / 255; + float f = 1.0; + if( gHUD.m_flScaleColorTime != 0.0f ) + { + float flTimeDiff = gHUD.m_flScaleColorTime - gHUD.m_flTime; + if( flTimeDiff > 0.0f && flTimeDiff >= 1.0f ) + { + flTimeDiff = 1.0f; + } + else if( flTimeDiff <= 0.0f ) + { + flTimeDiff = 0.0f; + } + f = 1.0f - flTimeDiff; + } + float x = f * (float)a / 255; r = (int)( r * x ); g = (int)( g * x ); b = (int)( b * x ); diff --git a/cl_dll/poke646/scope.cpp b/cl_dll/poke646/scope.cpp index 9f9cea6c..7ce5b209 100644 --- a/cl_dll/poke646/scope.cpp +++ b/cl_dll/poke646/scope.cpp @@ -26,63 +26,15 @@ #include "pm_shared.h" #include "pm_defs.h" #include "pmtrace.h" - +extern bool bDrawScope; extern vec3_t v_origin; // last view origin extern vec3_t v_angles; // last view angle extern vec3_t v_cl_angles; // last client/mouse angle extern vec3_t v_sim_org; // last sim origin -DECLARE_MESSAGE(m_Scope, Scope) - -int CHudScope::Init(void) +int CHudScope::DrawScope() { - HOOK_MESSAGE(Scope); - - m_iFlags = 0; - - gHUD.AddHudElem(this); - return 1; -} - -void CHudScope::Reset(void) -{ - -} - -int CHudScope::VidInit(void) -{ - m_hSprite = SPR_Load("sprites/scopeborder.spr"); - - return 1; -} - -int CHudScope::MsgFunc_Scope(const char *pszName, int iSize, void *pbuf) -{ - // TODO: update local health data - BEGIN_READ(pbuf, iSize); - int fOn = READ_BYTE(); - - if (fOn) - { - m_iFlags |= HUD_ACTIVE; - } - else - { - m_iFlags &= ~HUD_ACTIVE; - } - - return 1; -} - - -int CHudScope::Draw(float flTime) -{ - return 1; -} - -int CHudScope::DrawScope(void) -{ - if (!(m_iFlags & HUD_ACTIVE)) + if( !bDrawScope ) return 1; if (!m_hSprite) @@ -341,4 +293,4 @@ int CHudScope::DrawScope(void) // gEngfuncs.Con_Printf("CMLWBR trace distance: %.3f\n", meters); return 1; -} \ No newline at end of file +} diff --git a/cl_dll/tri.cpp b/cl_dll/tri.cpp index fabbe4b5..6cc48609 100644 --- a/cl_dll/tri.cpp +++ b/cl_dll/tri.cpp @@ -112,19 +112,9 @@ Render any triangles with transparent rendermode needs here */ void DLLEXPORT HUD_DrawTransparentTriangles( void ) { + gHUD.m_Scope.DrawScope(); #if defined( TEST_IT ) // Draw_Triangles(); #endif } -/* -================= -HUD_DrawOrthoTriangles -Orthogonal Triangles -- (relative to resolution, -smackdab on the screen) add them here -================= -*/ -void HUD_DrawOrthoTriangles( void ) -{ - gHUD.m_Scope.DrawScope(); -} diff --git a/cl_dll/view.cpp b/cl_dll/view.cpp index 2237dc49..de00c424 100644 --- a/cl_dll/view.cpp +++ b/cl_dll/view.cpp @@ -26,6 +26,7 @@ #include "shake.h" #include "hltv.h" +extern bool bDrawScope; // Spectator Mode extern "C" { @@ -762,6 +763,7 @@ void V_CalcNormalRefdef( struct ref_params_s *pparams ) // Store off overridden viewangles v_angles = pparams->viewangles; + bDrawScope = 0; } } diff --git a/dlls/Android.mk b/dlls/Android.mk index fb15abea..93a6da78 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -56,9 +56,11 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ func_tank.cpp \ game.cpp \ gamerules.cpp \ + gauss.cpp \ gargantua.cpp \ genericmonster.cpp \ ggrenade.cpp \ + glock.cpp \ globals.cpp \ gman.cpp \ h_ai.cpp \ @@ -123,18 +125,12 @@ LOCAL_SRC_FILES := agrunt.cpp airtank.cpp \ ../pm_shared/pm_debug.c \ ../pm_shared/pm_math.c \ ../pm_shared/pm_shared.c \ - poke646/bradnailer.cpp \ - poke646/cmlwbr.cpp \ poke646/firetrail.cpp \ poke646/genericmodel.cpp \ - poke646/heaterpipe.cpp \ + poke646/mp3.cpp \ poke646/nail.cpp \ - poke646/nailgun.cpp \ - poke646/pipebomb.cpp \ poke646/robocop.cpp \ - poke646/weapon_pipebomb.cpp \ - poke646/xenspit.cpp \ - poke646/xensquasher.cpp + poke646/xsbeam..cpp # ../game_shared/voice_gamemgr.cpp LOCAL_LDLIBS := -llog diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 3ae6568c..17f7e0e1 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -59,11 +59,11 @@ set (SVDLL_SOURCES game.cpp gamerules.cpp gargantua.cpp -# gauss.cpp + gauss.cpp genericmonster.cpp ggrenade.cpp globals.cpp -# glock.cpp + glock.cpp gman.cpp h_ai.cpp h_battery.cpp @@ -88,7 +88,7 @@ set (SVDLL_SOURCES monsters.cpp monsterstate.cpp mortar.cpp -# mp5.cpp + mp5.cpp multiplay_gamerules.cpp nihilanth.cpp nodes.cpp @@ -131,18 +131,12 @@ set (SVDLL_SOURCES ../pm_shared/pm_debug.c ../pm_shared/pm_math.c ../pm_shared/pm_shared.c - poke646/bradnailer.cpp - poke646/cmlwbr.cpp poke646/firetrail.cpp poke646/genericmodel.cpp - poke646/heaterpipe.cpp + poke646/mp3.cpp poke646/nail.cpp - poke646/nailgun.cpp - poke646/pipebomb.cpp poke646/robocop.cpp - poke646/weapon_pipebomb.cpp - poke646/xenspit.cpp - poke646/xensquasher.cpp + poke646/xsbeam.cpp ) include_directories (. wpn_shared poke646 ../common ../engine ../pm_shared ../game_shared ../public) diff --git a/dlls/barney.cpp b/dlls/barney.cpp index 3fc5aef0..329528bf 100644 --- a/dlls/barney.cpp +++ b/dlls/barney.cpp @@ -616,7 +616,7 @@ void CBarney::Killed( entvars_t *pevAttacker, int iGib ) GetAttachment( 0, vecGunPos, vecGunAngles ); - DropItem( "weapon_9mmhandgun", vecGunPos, vecGunAngles ); + DropItem( "weapon_bradnailer", vecGunPos, vecGunAngles ); } SetUse( NULL ); diff --git a/dlls/cbase.h b/dlls/cbase.h index e9d5c31a..a0980264 100644 --- a/dlls/cbase.h +++ b/dlls/cbase.h @@ -333,28 +333,6 @@ public: virtual BOOL FVisible( CBaseEntity *pEntity ); virtual BOOL FVisible( const Vector &vecOrigin ); - - //We use this variables to store each ammo count. - int ammo_9mm; - int ammo_357; - int ammo_bolts; - int ammo_buckshot; - int ammo_rockets; - int ammo_uranium; - int ammo_hornets; - int ammo_argrens; - int ammo_nails; - int ammo_xencandy; - - //Special stuff for grenades and satchels. - float m_flStartThrow; - float m_flReleaseThrow; - int m_chargeReady; - int m_fInAttack; - - enum EGON_FIRESTATE { FIRE_OFF, FIRE_CHARGE }; - int m_fireState; - int m_thrownByPlayer; }; // Ugly technique to override base member functions diff --git a/dlls/client.cpp b/dlls/client.cpp index d5986a71..7ef14a14 100644 --- a/dlls/client.cpp +++ b/dlls/client.cpp @@ -204,6 +204,7 @@ void ClientPutInServer( edict_t *pEntity ) pPlayer->pev->iuser1 = 0; pPlayer->pev->iuser2 = 0; + pPlayer->pev->iuser4 = 0; } #ifndef NO_VOICEGAMEMGR @@ -667,6 +668,8 @@ void ClientUserInfoChanged( edict_t *pEntity, char *infobuffer ) MESSAGE_END(); } + SET_CLIENT_MAX_SPEED( pEntity, PLAYER_MAX_SPEED ); + // team match? if( g_teamplay ) { @@ -929,8 +932,6 @@ void ClientPrecache( void ) if( giPrecacheGrunt ) UTIL_PrecacheOther( "monster_human_grunt" ); - - PRECACHE_SOUND("player/breathe2.wav"); } /* @@ -945,7 +946,7 @@ const char *GetGameDescription() if( g_pGameRules ) // this function may be called before the world has spawned, and the game rules initialized return g_pGameRules->GetGameDescription(); else - return "Half-Life"; + return "Poke646"; } /* @@ -1745,11 +1746,13 @@ void UpdateClientData( const struct edict_s *ent, int sendweapons, struct client // don't use spec vars from chased player cd->iuser1 = pevOrg->iuser1; cd->iuser2 = pevOrg->iuser2; + cd->iuser4 = pevOrg->iuser4; } else { cd->iuser1 = pev->iuser1; cd->iuser2 = pev->iuser2; + cd->iuser4 = pev->iuser4; } #if defined( CLIENT_WEAPONS ) if( sendweapons ) diff --git a/dlls/combat.cpp b/dlls/combat.cpp index b2ceabf4..0a271ee1 100644 --- a/dlls/combat.cpp +++ b/dlls/combat.cpp @@ -1524,11 +1524,9 @@ Vector CBaseEntity::FireBulletsPlayer( ULONG cShots, Vector vecSrc, Vector vecDi { default: case BULLET_PLAYER_9MM: - case BULLET_PLAYER_NAIL1: pEntity->TraceAttack( pevAttacker, gSkillData.plrDmg9MM, vecDir, &tr, DMG_NEVERGIB ); break; case BULLET_PLAYER_MP5: - case BULLET_PLAYER_NAIL2: pEntity->TraceAttack( pevAttacker, gSkillData.plrDmgMP5, vecDir, &tr, DMG_NEVERGIB ); break; case BULLET_PLAYER_BUCKSHOT: diff --git a/dlls/crossbow.cpp b/dlls/crossbow.cpp index 77ac9d41..77f8473b 100644 --- a/dlls/crossbow.cpp +++ b/dlls/crossbow.cpp @@ -22,9 +22,34 @@ #include "nodes.h" #include "player.h" #include "gamerules.h" -#include "crossbow.h" +#include "shake.h" #ifndef CLIENT_DLL +#define BOLT_AIR_VELOCITY 2000 +#define BOLT_WATER_VELOCITY 1000 + +extern BOOL gPhysicsInterfaceInitialized; + +// UNDONE: Save/restore this? Don't forget to set classname and LINK_ENTITY_TO_CLASS() +// +// OVERLOADS SOME ENTVARS: +// +// speed - the ideal magnitude of my velocity +class CCrossbowBolt : public CBaseEntity +{ + void Spawn( void ); + void Precache( void ); + int Classify( void ); + void EXPORT BubbleThink( void ); + void EXPORT BoltTouch( CBaseEntity *pOther ); + void EXPORT ExplodeThink( void ); + + int m_iTrail; + +public: + static CCrossbowBolt *BoltCreate( void ); +}; + LINK_ENTITY_TO_CLASS( crossbow_bolt, CCrossbowBolt ) CCrossbowBolt *CCrossbowBolt::BoltCreate( void ) @@ -48,7 +73,7 @@ void CCrossbowBolt::Spawn() SET_MODEL( ENT( pev ), "models/crossbow_bolt.mdl" ); UTIL_SetOrigin( pev, pev->origin ); - UTIL_SetSize( pev, Vector( 0, 0, 0 ), Vector( 0, 0, 0 ) ); + UTIL_SetSize( pev, g_vecZero, g_vecZero ); SetTouch( &CCrossbowBolt::BoltTouch ); SetThink( &CCrossbowBolt::BubbleThink ); @@ -97,7 +122,7 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) ApplyMultiDamage( pev, pevOwner ); - pev->velocity = Vector( 0, 0, 0 ); + pev->velocity = g_vecZero; // play body "thwack" sound switch( RANDOM_LONG( 0, 1 ) ) { @@ -129,7 +154,7 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) pev->angles = UTIL_VecToAngles( vecDir ); pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_FLY; - pev->velocity = Vector( 0, 0, 0 ); + pev->velocity = g_vecZero; pev->avelocity.z = 0; pev->angles.z = RANDOM_LONG( 0, 360 ); pev->nextthink = gpGlobals->time + 10.0; @@ -140,7 +165,7 @@ void CCrossbowBolt::BoltTouch( CBaseEntity *pOther ) UTIL_SetOrigin( pev, pev->origin - vecDir * 12 ); pev->angles = UTIL_VecToAngles( vecDir ); pev->solid = SOLID_NOT; - pev->velocity = Vector( 0, 0, 0 ); + pev->velocity = g_vecZero; pev->avelocity.z = 0; pev->angles.z = RANDOM_LONG( 0, 360 ); pev->nextthink = gpGlobals->time + 10.0; @@ -215,4 +240,294 @@ void CCrossbowBolt::ExplodeThink( void ) UTIL_Remove( this ); } #endif + +enum crossbow_e +{ + CROSSBOW_IDLE1 = 0, // full + CROSSBOW_IDLE2, // empty + CROSSBOW_FIDGET1, // full + CROSSBOW_FIDGET2, // empty + CROSSBOW_FIRE1, // full + CROSSBOW_RELOAD, // reload + CROSSBOW_DRAWBACK, // empty + CROSSBOW_UNDRAW, // from empty + CROSSBOW_DRAW1, // full + CROSSBOW_DRAW2, // empty + CROSSBOW_HOLSTER1, // full + CROSSBOW_HOLSTER2 // empty +}; + +LINK_ENTITY_TO_CLASS( weapon_cmlwbr, CCrossbow ) + +void CCrossbow::Spawn() +{ + Precache(); + m_iId = WEAPON_CROSSBOW; + SET_MODEL( ENT( pev ), "models/w_crossbow.mdl" ); + + m_iDefaultAmmo = CROSSBOW_DEFAULT_GIVE; + + FallInit();// get ready to fall down. +} + +int CCrossbow::AddToPlayer( CBasePlayer *pPlayer ) +{ + if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev ); + WRITE_BYTE( m_iId ); + MESSAGE_END(); + return TRUE; + } + return FALSE; +} + +void CCrossbow::Precache( void ) +{ + PRECACHE_MODEL( "models/w_crossbow.mdl" ); + PRECACHE_MODEL( "models/v_cmlwbr.mdl" ); + PRECACHE_MODEL( "models/p_crossbow.mdl" ); + + PRECACHE_SOUND( "weapons/cmlwbr_fire.wav" ); + PRECACHE_SOUND( "weapons/cmlwbr_reload.wav" ); + PRECACHE_SOUND( "weapons/cmlwbr_drawback.wav" ); + PRECACHE_SOUND( "weapons/cmlwbr_undraw.wav" ); + PRECACHE_SOUND( "weapons/cmlwbr_zoom.wav" ); + + UTIL_PrecacheOther( "crossbow_bolt" ); +} + +int CCrossbow::GetItemInfo( ItemInfo *p ) +{ + p->pszName = STRING( pev->classname ); + p->pszAmmo1 = "bolts"; + p->iMaxAmmo1 = BOLT_MAX_CARRY; + p->pszAmmo2 = NULL; + p->iMaxAmmo2 = -1; + p->iMaxClip = CROSSBOW_MAX_CLIP; + p->iSlot = 2; + p->iPosition = 1; + p->iId = WEAPON_CROSSBOW; + p->iFlags = 0; + p->iWeight = CROSSBOW_WEIGHT; + return 1; +} + +BOOL CCrossbow::Deploy() +{ + return DefaultDeploy( "models/v_cmlwbr.mdl", "models/p_crossbow.mdl", m_iClip ? CROSSBOW_DRAW1 : CROSSBOW_DRAW2 , "bow" ); +} + +void CCrossbow::Holster( int skiplocal /* = 0 */ ) +{ + m_fInReload = FALSE;// cancel any reload in progress. + + if( m_fInZoom ) + { + ZoomOut(); + } + + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; + SendWeaponAnim( m_iClip ? CROSSBOW_HOLSTER1 : CROSSBOW_HOLSTER2 ); +} + +void CCrossbow::PrimaryAttack( void ) +{ + if( m_pPlayer->pev->waterlevel == 3 ) + { + PlayEmptySound(); + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2f; + return; + } + + FireBolt(); +} + +void CCrossbow::FireBolt() +{ + TraceResult tr; + + if( m_iClip == 0 || !m_fInAttack ) + { + PlayEmptySound(); + return; + } + + m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; + + m_iClip--; + + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_fire.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); + SendWeaponAnim( CROSSBOW_FIRE1 ); + + // player "shoot" animation + m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); + + Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; + UTIL_MakeVectors( anglesAim ); + + anglesAim.x = -anglesAim.x; + +#ifndef CLIENT_DLL + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; + Vector vecDir = gpGlobals->v_forward; + + CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate(); + pBolt->pev->origin = vecSrc; + pBolt->pev->angles = anglesAim; + pBolt->pev->owner = m_pPlayer->edict(); + + if( m_pPlayer->pev->waterlevel == 3 ) + { + pBolt->pev->velocity = vecDir * BOLT_WATER_VELOCITY; + pBolt->pev->speed = BOLT_WATER_VELOCITY; + } + else + { + pBolt->pev->velocity = vecDir * BOLT_AIR_VELOCITY; + pBolt->pev->speed = BOLT_AIR_VELOCITY; + } + pBolt->pev->avelocity.z = 10; +#endif + + if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + // HEV suit - indicate out of ammo condition + m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); + + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.75f; + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.2f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1f; + + m_pPlayer->pev->punchangle.x -= 2.0f; +} + +void CCrossbow::ZoomOut() +{ + m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov + m_fInZoom = 0; + m_pPlayer->pev->iuser4 = m_fInZoom; + m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_cmlwbr.mdl" ); + UTIL_ScreenFade( m_pPlayer, g_vecZero, 0.2, 0.1, 255, FFADE_IN ); +} + +void CCrossbow::SecondaryAttack() +{ + if( m_fInZoom == 2 ) + { + ZoomOut(); + m_flNextPrimaryAttack = m_flNextSecondaryAttack = m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.7; + } + else + { + m_pPlayer->m_iFOV = m_pPlayer->pev->fov = 20 * ( 2 - m_fInZoom ); + ++m_fInZoom; + m_pPlayer->pev->iuser4 = m_fInZoom; + m_pPlayer->pev->viewmodel = 0; + UTIL_ScreenFade( m_pPlayer, g_vecZero, 0.1, 0.1, 255, FFADE_IN ); + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + } + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_zoom.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); +} + +void CCrossbow::ToggleDrawn() +{ + SetThink( NULL ); + m_fInAttack = ( m_fInAttack == 0 ); + if( m_fInSpecialReload ) + { + m_fInSpecialReload = 0; + Reload(); + } +} + +void CCrossbow::Reload( void ) +{ + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CROSSBOW_MAX_CLIP ) + return; + + if( m_fInZoom != 0 ) + { + ZoomOut(); + } + + if( m_fInAttack ) + { + if(!m_fInSpecialReload ) + { + SetThink( &CCrossbow::ToggleDrawn ); + pev->nextthink = gpGlobals->time + 1.4f; + SendWeaponAnim( CROSSBOW_UNDRAW ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_undraw.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); + m_fInSpecialReload = 1; + } + return; + } + + if( DefaultReload( CROSSBOW_MAX_CLIP, CROSSBOW_RELOAD, 4.5f ) ) + { + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_reload.wav", RANDOM_FLOAT( 0.95, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); + } + m_flNextPrimaryAttack = m_flNextSecondaryAttack = m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 4.5f; +} + +void CCrossbow::WeaponIdle( void ) +{ + m_pPlayer->GetAutoaimVector( AUTOAIM_2DEGREES ); // get the autoaim vector but ignore it; used for autoaim crosshair in DM + + ResetEmptySound(); + + if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) + { + int iAnim; + if( m_fInAttack || !m_iClip ) + { + float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 ); + if( flRand <= 0.75 || m_fInZoom ) + { + iAnim = m_fInAttack ? CROSSBOW_IDLE1 : CROSSBOW_IDLE2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.1f; + } + else + { + iAnim = m_fInAttack ? CROSSBOW_FIDGET1 : CROSSBOW_FIDGET2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.8f; + } + } + else + { + iAnim = CROSSBOW_DRAWBACK; + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cmlwbr_drawback.wav", RANDOM_FLOAT( 0.9, 1.0 ), ATTN_NORM, 0, 93 + RANDOM_LONG( 0, 0xF ) ); + m_flNextSecondaryAttack = m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.3f; + SetThink( &CCrossbow::ToggleDrawn ); + pev->nextthink = gpGlobals->time + 1.2f; + } + SendWeaponAnim( iAnim ); + } +} + +class CCrossbowAmmo : public CBasePlayerAmmo +{ + void Spawn( void ) + { + Precache(); + SET_MODEL( ENT( pev ), "models/w_crossbow_clip.mdl" ); + CBasePlayerAmmo::Spawn(); + } + void Precache( void ) + { + PRECACHE_MODEL( "models/w_crossbow_clip.mdl" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); + } + BOOL AddAmmo( CBaseEntity *pOther ) + { + if( pOther->GiveAmmo( AMMO_CROSSBOWCLIP_GIVE, "bolts", BOLT_MAX_CARRY ) != -1 ) + { + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); + return TRUE; + } + return FALSE; + } +}; + +LINK_ENTITY_TO_CLASS( ammo_bolts, CCrossbowAmmo ) #endif diff --git a/dlls/crossbow.h b/dlls/crossbow.h deleted file mode 100644 index 662bbd67..00000000 --- a/dlls/crossbow.h +++ /dev/null @@ -1,47 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ -#ifndef CROSSBOW_H -#define CROSSBOW_H - -#ifdef _WIN32 -#pragma once -#endif - -#define BOLT_AIR_VELOCITY 2000 -#define BOLT_WATER_VELOCITY 1000 - -extern BOOL gPhysicsInterfaceInitialized; - -// UNDONE: Save/restore this? Don't forget to set classname and LINK_ENTITY_TO_CLASS() -// -// OVERLOADS SOME ENTVARS: -// -// speed - the ideal magnitude of my velocity -class CCrossbowBolt : public CBaseEntity -{ - void Spawn(void); - void Precache(void); - int Classify(void); - void EXPORT BubbleThink(void); - void EXPORT BoltTouch(CBaseEntity *pOther); - void EXPORT ExplodeThink(void); - - int m_iTrail; - -public: - static CCrossbowBolt *BoltCreate(void); -}; - -#endif // CROSSBOW_H diff --git a/dlls/crowbar.cpp b/dlls/crowbar.cpp index 4cc48d97..b5c08cee 100644 --- a/dlls/crowbar.cpp +++ b/dlls/crowbar.cpp @@ -25,7 +25,7 @@ #define CROWBAR_BODYHIT_VOLUME 128 #define CROWBAR_WALLHIT_VOLUME 512 -LINK_ENTITY_TO_CLASS( weapon_crowbar, CCrowbar ) +LINK_ENTITY_TO_CLASS( weapon_heaterpipe, CCrowbar ) enum crowbar_e { @@ -50,7 +50,7 @@ void CCrowbar::Spawn() { Precache(); m_iId = WEAPON_CROWBAR; - SET_MODEL( ENT( pev ), "models/w_crowbar.mdl" ); + SET_MODEL( ENT( pev ), "models/w_heaterpipe.mdl" ); m_iClip = -1; FallInit();// get ready to fall down. @@ -58,17 +58,16 @@ void CCrowbar::Spawn() void CCrowbar::Precache( void ) { - PRECACHE_MODEL( "models/v_crowbar.mdl" ); - PRECACHE_MODEL( "models/w_crowbar.mdl" ); - PRECACHE_MODEL( "models/p_crowbar.mdl" ); - PRECACHE_SOUND( "weapons/cbar_hit1.wav" ); - PRECACHE_SOUND( "weapons/cbar_hit2.wav" ); + PRECACHE_MODEL( "models/v_heaterpipe.mdl" ); + PRECACHE_MODEL( "models/w_heaterpipe.mdl" ); + PRECACHE_MODEL( "models/p_heaterpipe.mdl" ); + PRECACHE_SOUND( "weapons/pipe_hit1.wav" ); + PRECACHE_SOUND( "weapons/pipe_hit2.wav" ); PRECACHE_SOUND( "weapons/cbar_hitbod1.wav" ); PRECACHE_SOUND( "weapons/cbar_hitbod2.wav" ); PRECACHE_SOUND( "weapons/cbar_hitbod3.wav" ); - PRECACHE_SOUND( "weapons/cbar_miss1.wav" ); - - m_usCrowbar = PRECACHE_EVENT( 1, "events/crowbar.sc" ); + PRECACHE_SOUND( "weapons/pipe_miss.wav" ); + PRECACHE_SOUND( "player/pl_breathe.wav" ); } int CCrowbar::GetItemInfo( ItemInfo *p ) @@ -81,7 +80,7 @@ int CCrowbar::GetItemInfo( ItemInfo *p ) p->iMaxClip = WEAPON_NOCLIP; p->iSlot = 0; p->iPosition = 0; - p->iId = WEAPON_CROWBAR; + p->iId = m_iId = WEAPON_CROWBAR; p->iWeight = CROWBAR_WEIGHT; return 1; } @@ -100,7 +99,7 @@ int CCrowbar::AddToPlayer( CBasePlayer *pPlayer ) BOOL CCrowbar::Deploy() { - return DefaultDeploy( "models/v_crowbar.mdl", "models/p_crowbar.mdl", CROWBAR_DRAW, "crowbar" ); + return DefaultDeploy( "models/v_heaterpipe.mdl", "models/p_heaterpipe.mdl", CROWBAR_DRAW, "crowbar" ); } void CCrowbar::Holster( int skiplocal /* = 0 */ ) @@ -155,13 +154,14 @@ void FindHullIntersection( const Vector &vecSrc, TraceResult &tr, float *mins, f void CCrowbar::PrimaryAttack() { - if( !Swing( 1 ) ) + if( m_flNextPrimaryAttack + 1 <= UTIL_WeaponTimeBase() ) { -#ifndef CLIENT_DLL - SetThink( &CCrowbar::SwingAgain ); - pev->nextthink = gpGlobals->time + 0.1; -#endif + m_iSwing = Q_max( 0, m_iSwing - static_cast( ( UTIL_WeaponTimeBase() - m_flNextPrimaryAttack ) * 5.0f ) ); } + + Swing(); + + ++m_iSwing; } void CCrowbar::Smack() @@ -169,16 +169,10 @@ void CCrowbar::Smack() DecalGunshot( &m_trHit, BULLET_PLAYER_CROWBAR ); } -void CCrowbar::SwingAgain( void ) +void CCrowbar::Swing() { - Swing( 0 ); -} - -int CCrowbar::Swing( int fFirst ) -{ - int fDidHit = FALSE; - TraceResult tr; + float flVol; UTIL_MakeVectors( m_pPlayer->pev->v_angle ); Vector vecSrc = m_pPlayer->GetGunPosition(); @@ -201,29 +195,39 @@ int CCrowbar::Swing( int fFirst ) } } #endif - if( fFirst ) + if( m_iSwing > 4 && m_flNextBreathSoundTime <= UTIL_WeaponTimeBase() ) { - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usCrowbar, - 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, - 0, 0, 0 ); + flVol = Q_min( 1.0f, static_cast( m_iSwing - 3 ) * 0.2 ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_BODY, "player/pl_breathe.wav", flVol, ATTN_NORM ); + m_flNextBreathSoundTime = UTIL_WeaponTimeBase() + 1.2f; } if( tr.flFraction >= 1.0 ) { - if( fFirst ) + // miss + switch( ( m_iSwing++ ) % 3 ) { - // miss - m_flNextPrimaryAttack = GetNextAttackDelay( 0.5 ); -#ifdef CROWBAR_IDLE_ANIM - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); -#endif - // player "shoot" animation - m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); + case 0: + SendWeaponAnim( CROWBAR_ATTACK1MISS ); + break; + case 1: + SendWeaponAnim( CROWBAR_ATTACK2MISS ); + break; + case 2: + SendWeaponAnim( CROWBAR_ATTACK3MISS ); + break; } + m_flNextPrimaryAttack = ( static_cast( m_iSwing ) * 0.03f ) + UTIL_WeaponTimeBase() + 0.5f; + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/pipe_miss.wav", 1, ATTN_NORM, 0, 94 + RANDOM_LONG( 0, 0xF ) ); +#ifdef CROWBAR_IDLE_ANIM + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); +#endif + // player "shoot" animation + m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); } else { - switch( ( ( m_iSwing++ ) % 2 ) + 1 ) + switch( ( m_iSwing++ ) % 3 ) { case 0: SendWeaponAnim( CROWBAR_ATTACK1HIT ); @@ -241,33 +245,21 @@ int CCrowbar::Swing( int fFirst ) #ifndef CLIENT_DLL // hit - fDidHit = TRUE; CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); // play thwack, smack, or dong sound - float flVol = 1.0; - int fHitWorld = TRUE; + flVol = 1.0; + int fHitWorld = TRUE; + + m_flNextPrimaryAttack = ( static_cast( m_iSwing ) * 0.03f ) + UTIL_WeaponTimeBase() + 0.3f; if( pEntity ) { ClearMultiDamage(); - // If building with the clientside weapon prediction system, - // UTIL_WeaponTimeBase() is always 0 and m_flNextPrimaryAttack is >= -1.0f, thus making - // m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() always evaluate to false. -#ifdef CLIENT_WEAPONS - if( ( m_flNextPrimaryAttack + 1 == UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) -#else - if( ( m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase() ) || g_pGameRules->IsMultiplayer() ) -#endif - { - // first swing does full damage - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB ); - } - else - { - // subsequent swings do half - pEntity->TraceAttack( m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB ); - } + + float flDmg = Q_max( 1.0f, gSkillData.plrDmgCrowbar - ( static_cast( m_iSwing ) * 0.5f ) ); + pEntity->TraceAttack( m_pPlayer->pev, flDmg, gpGlobals->v_forward, &tr, DMG_CLUB ); + ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); if( pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE ) @@ -287,7 +279,7 @@ int CCrowbar::Swing( int fFirst ) } m_pPlayer->m_iWeaponVolume = CROWBAR_BODYHIT_VOLUME; if( !pEntity->IsAlive() ) - return TRUE; + return; else flVol = 0.1; @@ -314,10 +306,10 @@ int CCrowbar::Swing( int fFirst ) switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pipe_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); break; case 1: - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/cbar_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/pipe_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); break; } @@ -328,14 +320,12 @@ int CCrowbar::Swing( int fFirst ) m_pPlayer->m_iWeaponVolume = (int)( flVol * CROWBAR_WALLHIT_VOLUME ); SetThink( &CCrowbar::Smack ); - pev->nextthink = UTIL_WeaponTimeBase() + 0.2; + pev->nextthink = UTIL_WeaponTimeBase() + 0.1f; #endif - m_flNextPrimaryAttack = GetNextAttackDelay( 0.25 ); } #ifdef CROWBAR_IDLE_ANIM m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); #endif - return fDidHit; } #ifdef CROWBAR_IDLE_ANIM diff --git a/dlls/doors.cpp b/dlls/doors.cpp index c12cc3a0..c4c390e9 100644 --- a/dlls/doors.cpp +++ b/dlls/doors.cpp @@ -742,7 +742,7 @@ void CBaseDoor::Blocked( CBaseEntity *pOther ) { // Detonate satchels if( !strcmp( "monster_satchel", STRING( pOther->pev->classname ) ) ) - ( (CSatchel*)pOther )->Use( this, this, USE_ON, 0 ); + ( (CPipebomb*)pOther )->Use( this, this, USE_ON, 0 ); } // if a door has a negative wait, it would never come back if blocked, diff --git a/dlls/enginecallback.h b/dlls/enginecallback.h index a9e37c26..a7e6a584 100644 --- a/dlls/enginecallback.h +++ b/dlls/enginecallback.h @@ -160,5 +160,6 @@ inline void *GET_PRIVATE( edict_t *pent ) #define ENGINE_FORCE_UNMODIFIED ( *g_engfuncs.pfnForceUnmodified ) #define PLAYER_CNX_STATS ( *g_engfuncs.pfnGetPlayerStats ) +#define SET_CLIENT_MAX_SPEED ( *g_engfuncs.pfnSetClientMaxspeed ) #endif //ENGINECALLBACK_H diff --git a/dlls/func_tank.cpp b/dlls/func_tank.cpp index a3dba841..cbc7f5b1 100644 --- a/dlls/func_tank.cpp +++ b/dlls/func_tank.cpp @@ -128,6 +128,7 @@ protected: Vector m_sightOrigin; // Last sight of target int m_spread; // firing spread string_t m_iszMaster; // Master entity (game_team_master or multisource) + int m_iControllerHUDFlags; }; TYPEDESCRIPTION CFuncTank::m_SaveData[] = @@ -158,6 +159,7 @@ TYPEDESCRIPTION CFuncTank::m_SaveData[] = DEFINE_FIELD( CFuncTank, m_flNextAttack, FIELD_TIME ), DEFINE_FIELD( CFuncTank, m_iBulletDamage, FIELD_INTEGER ), DEFINE_FIELD( CFuncTank, m_iszMaster, FIELD_STRING ), + DEFINE_FIELD( CFuncTank, m_iControllerHUDFlags, FIELD_INTEGER ), }; IMPLEMENT_SAVERESTORE( CFuncTank, CBaseEntity ) @@ -360,6 +362,7 @@ BOOL CFuncTank::StartControl( CBasePlayer *pController ) m_pController->pev->viewmodel = 0; } + m_iControllerHUDFlags = m_pController->m_iHideHUD; m_pController->m_iHideHUD |= HIDEHUD_WEAPONS; m_vecControllerUsePos = m_pController->pev->origin; @@ -381,7 +384,7 @@ void CFuncTank::StopControl() ALERT( at_console, "stopped using TANK\n"); - m_pController->m_iHideHUD &= ~HIDEHUD_WEAPONS; + m_pController->m_iHideHUD = m_iControllerHUDFlags; pev->nextthink = 0; diff --git a/dlls/game.cpp b/dlls/game.cpp index 34491987..5ab739f4 100644 --- a/dlls/game.cpp +++ b/dlls/game.cpp @@ -893,5 +893,7 @@ void GameDLLInit( void ) // END REGISTER CVARS FOR SKILL LEVEL STUFF SERVER_COMMAND( "exec skill.cfg\n" ); + + SOUNDTRACKLIST_Init(); } diff --git a/dlls/gamerules.h b/dlls/gamerules.h index 04c6eea5..e34414cd 100644 --- a/dlls/gamerules.h +++ b/dlls/gamerules.h @@ -76,7 +76,7 @@ public: virtual BOOL IsDeathmatch( void ) = 0;//is this a deathmatch game? virtual BOOL IsTeamplay( void ) { return FALSE; };// is this deathmatch game being played with team rules? virtual BOOL IsCoOp( void ) = 0;// is this a coop game? - virtual const char *GetGameDescription( void ) { return "Half-Life"; } // this is the game name that gets seen in the server browser + virtual const char *GetGameDescription( void ) { return "Poke646"; } // this is the game name that gets seen in the server browser // Client connection/disconnection virtual BOOL ClientConnected( edict_t *pEntity, const char *pszName, const char *pszAddress, char szRejectReason[128] ) = 0;// a client just connected to the server (player hasn't spawned yet) diff --git a/dlls/gauss.cpp b/dlls/gauss.cpp index 62af08e1..34a514b6 100644 --- a/dlls/gauss.cpp +++ b/dlls/gauss.cpp @@ -25,26 +25,28 @@ #include "shake.h" #include "gamerules.h" #include "game.h" +#include "xsbeam.h" -#define GAUSS_PRIMARY_CHARGE_VOLUME 256// how loud gauss is while charging -#define GAUSS_PRIMARY_FIRE_VOLUME 450// how loud gauss is when discharged +#define XS_PRIMARY_CHARGE_VOLUME 256// how loud xen squasher is while charging +#define XS_PRIMARY_FIRE_VOLUME 450// how loud xen squasher is when discharged -enum gauss_e +enum xs_e { - GAUSS_IDLE = 0, - GAUSS_IDLE2, - GAUSS_FIDGET, - GAUSS_SPINUP, - GAUSS_SPIN, - GAUSS_FIRE, - GAUSS_FIRE2, - GAUSS_HOLSTER, - GAUSS_DRAW + XS_IDLE = 0, + XS_IDLE2, + XS_FIDGET, + XS_SPINUP, + XS_SPIN, + XS_FIRE, + XS_FIRE2, + XS_HOLSTER, + XS_DRAW, + XS_RELOAD }; -LINK_ENTITY_TO_CLASS( weapon_gauss, CGauss ) +LINK_ENTITY_TO_CLASS( weapon_xs, CXS ) -float CGauss::GetFullChargeTime( void ) +float CXS::GetFullChargeTime( void ) { #ifdef CLIENT_DLL if( bIsMultiplayer() ) @@ -58,44 +60,42 @@ float CGauss::GetFullChargeTime( void ) return 4; } -#ifdef CLIENT_DLL -extern int g_irunninggausspred; -#endif -void CGauss::Spawn() +void CXS::Spawn() { Precache(); - m_iId = WEAPON_GAUSS; - SET_MODEL( ENT( pev ), "models/w_gauss.mdl" ); + m_iId = WEAPON_XS; + SET_MODEL( ENT( pev ), "models/w_xs.mdl" ); - m_iDefaultAmmo = GAUSS_DEFAULT_GIVE; + m_iDefaultAmmo = XS_DEFAULT_GIVE; FallInit();// get ready to fall down. + pev->sequence = 0; + pev->animtime = gpGlobals->time; + pev->framerate = 1; } -void CGauss::Precache( void ) +void CXS::Precache( void ) { - PRECACHE_MODEL( "models/w_gauss.mdl" ); - PRECACHE_MODEL( "models/v_gauss.mdl" ); + PRECACHE_MODEL( "models/w_xs.mdl" ); + PRECACHE_MODEL( "models/v_xs.mdl" ); PRECACHE_MODEL( "models/p_gauss.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); - PRECACHE_SOUND( "weapons/gauss2.wav" ); - PRECACHE_SOUND( "weapons/electro4.wav" ); - PRECACHE_SOUND( "weapons/electro5.wav" ); - PRECACHE_SOUND( "weapons/electro6.wav" ); - PRECACHE_SOUND( "ambience/pulsemachine.wav" ); + PRECACHE_SOUND( "weapons/xs_shot.wav" ); + PRECACHE_SOUND( "weapons/xs_moan1.wav" ); + PRECACHE_SOUND( "weapons/xs_moan2.wav" ); + PRECACHE_SOUND( "weapons/xs_moan3.wav" ); + PRECACHE_SOUND( "weapons/xs_windup.wav" ); + PRECACHE_SOUND( "weapons/xs_reload.wav" ); - m_iGlow = PRECACHE_MODEL( "sprites/hotglow.spr" ); - m_iBalls = PRECACHE_MODEL( "sprites/hotglow.spr" ); - m_iBeam = PRECACHE_MODEL( "sprites/smoke.spr" ); + m_usXSSpin = PRECACHE_EVENT( 1, "events/xsspin.sc" ); - m_usGaussFire = PRECACHE_EVENT( 1, "events/gauss.sc" ); - m_usGaussSpin = PRECACHE_EVENT( 1, "events/gaussspin.sc" ); + UTIL_PrecacheOther( "xs_beam" ); } -int CGauss::AddToPlayer( CBasePlayer *pPlayer ) +int CXS::AddToPlayer( CBasePlayer *pPlayer ) { if( CBasePlayerWeapon::AddToPlayer( pPlayer ) ) { @@ -107,46 +107,44 @@ int CGauss::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -int CGauss::GetItemInfo( ItemInfo *p ) +int CXS::GetItemInfo( ItemInfo *p ) { p->pszName = STRING( pev->classname ); p->pszAmmo1 = "uranium"; p->iMaxAmmo1 = URANIUM_MAX_CARRY; p->pszAmmo2 = NULL; p->iMaxAmmo2 = -1; - p->iMaxClip = WEAPON_NOCLIP; + p->iMaxClip = XS_MAX_CLIP; p->iSlot = 3; - p->iPosition = 1; - p->iId = m_iId = WEAPON_GAUSS; + p->iPosition = 0; + p->iId = m_iId = WEAPON_XS; p->iFlags = 0; - p->iWeight = GAUSS_WEIGHT; + p->iWeight = XS_WEIGHT; return 1; } -BOOL CGauss::IsUseable() +BOOL CXS::IsUseable() { // Currently charging, allow the player to fire it first. - Solokiller return CBasePlayerWeapon::IsUseable() || m_fInAttack != 0; } -BOOL CGauss::Deploy() +BOOL CXS::Deploy() { - m_pPlayer->m_flPlayAftershock = 0.0; - return DefaultDeploy( "models/v_gauss.mdl", "models/p_gauss.mdl", GAUSS_DRAW, "gauss" ); + return DefaultDeploy( "models/v_xs.mdl", "models/p_gauss.mdl", XS_DRAW, "gauss" ); } -void CGauss::Holster( int skiplocal /* = 0 */ ) +void CXS::Holster( int skiplocal /* = 0 */ ) { - PLAYBACK_EVENT_FULL( FEV_RELIABLE | FEV_GLOBAL, m_pPlayer->edict(), m_usGaussFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - SendWeaponAnim( GAUSS_HOLSTER ); + SendWeaponAnim( XS_HOLSTER ); m_fInAttack = 0; + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM ); } -void CGauss::PrimaryAttack() +void CXS::PrimaryAttack() { // don't fire underwater if( m_pPlayer->pev->waterlevel == 3 ) @@ -156,33 +154,33 @@ void CGauss::PrimaryAttack() return; } - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] < 2 ) + if( m_iClip <= 0 ) { PlayEmptySound(); m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; return; } - m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; + m_pPlayer->m_iWeaponVolume = XS_PRIMARY_FIRE_VOLUME; m_fPrimaryFire = TRUE; - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= 2; + --m_iClip; StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.2; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.2; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.4; } -void CGauss::SecondaryAttack() +void CXS::SecondaryAttack() { // don't fire underwater if( m_pPlayer->pev->waterlevel == 3 ) { if( m_fInAttack != 0 ) { - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); - SendWeaponAnim( GAUSS_IDLE ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_moan1.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); + SendWeaponAnim( XS_IDLE ); m_fInAttack = 0; } else @@ -196,7 +194,7 @@ void CGauss::SecondaryAttack() if( m_fInAttack == 0 ) { - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + if( m_iClip <= 0 ) { EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/357_cock1.wav", 0.8, ATTN_NORM ); m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; @@ -205,19 +203,19 @@ void CGauss::SecondaryAttack() m_fPrimaryFire = FALSE; - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;// take one ammo just to start the spin + --m_iClip;// take one ammo just to start the spin m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase(); // spin up - m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; + m_pPlayer->m_iWeaponVolume = XS_PRIMARY_CHARGE_VOLUME; - SendWeaponAnim( GAUSS_SPINUP ); + SendWeaponAnim( XS_SPINUP ); m_fInAttack = 1; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; m_pPlayer->m_flStartCharge = gpGlobals->time; m_pPlayer->m_flAmmoStartCharge = UTIL_WeaponTimeBase() + GetFullChargeTime(); - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0 ); + PLAYBACK_EVENT_FULL( 0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 110, 0, 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; } @@ -225,7 +223,7 @@ void CGauss::SecondaryAttack() { if( m_flTimeWeaponIdle < UTIL_WeaponTimeBase() ) { - SendWeaponAnim( GAUSS_SPIN ); + SendWeaponAnim( XS_SPIN ); m_fInAttack = 2; } } @@ -237,12 +235,12 @@ void CGauss::SecondaryAttack() // This will need to be fixed further down the line by preventing negative ammo unless explicitly required (infinite ammo?), // But this check will prevent the problem for now. - Solokiller // TODO: investigate further. - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + if( m_iClip <= 0 ) { // out of ammo! force the gun to fire StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.2; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1; return; } @@ -256,12 +254,12 @@ void CGauss::SecondaryAttack() if( g_pGameRules->IsMultiplayer() ) #endif { - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; + --m_iClip; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.1; } else { - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; + --m_iClip; m_pPlayer->m_flNextAmmoBurn = UTIL_WeaponTimeBase() + 0.3; } } @@ -281,27 +279,27 @@ void CGauss::SecondaryAttack() if( m_iSoundState == 0 ) ALERT( at_console, "sound state %d\n", m_iSoundState ); - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); + PLAYBACK_EVENT_FULL( 0, m_pPlayer->edict(), m_usXSSpin, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, pitch, 0, ( m_iSoundState == SND_CHANGE_PITCH ) ? 1 : 0, 0 ); m_iSoundState = SND_CHANGE_PITCH; // hack for going through level transitions - m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_CHARGE_VOLUME; + m_pPlayer->m_iWeaponVolume = XS_PRIMARY_CHARGE_VOLUME; // m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.1; if( m_pPlayer->m_flStartCharge < gpGlobals->time - 10 ) { // Player charged up too long. Zap him. - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); - EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/electro6.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG( 0, 0x3f ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_moan1.wav", 1.0, ATTN_NORM, 0, 80 + RANDOM_LONG( 0, 0x3f ) ); + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_ITEM, "weapons/xs_moan3.wav", 1.0, ATTN_NORM, 0, 75 + RANDOM_LONG( 0, 0x3f ) ); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.2; m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; #ifndef CLIENT_DLL - m_pPlayer->TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), 50, DMG_SHOCK ); - UTIL_ScreenFade( m_pPlayer, Vector( 255, 128, 0 ), 2, 0.5, 128, FFADE_IN ); + m_pPlayer->TakeDamage( VARS( eoNullEntity ), VARS( eoNullEntity ), 50, DMG_POISON ); + UTIL_ScreenFade( m_pPlayer, Vector( 192, 224, 0 ), 2, 0.5, 128, FFADE_IN ); #endif - SendWeaponAnim( GAUSS_IDLE ); + SendWeaponAnim( XS_IDLE ); // Player may have been killed and this weapon dropped, don't execute any more code after this! return; @@ -315,13 +313,13 @@ void CGauss::SecondaryAttack() // of weaponidle() and make its own function then to try to // merge this into Fire(), which has some identical variable names //========================================================= -void CGauss::StartFire( void ) +void CXS::StartFire( void ) { float flDamage; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); Vector vecAiming = gpGlobals->v_forward; - Vector vecSrc = m_pPlayer->GetGunPosition(); // + gpGlobals->v_up * -8 + gpGlobals->v_right * 8; + Vector vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 20 + gpGlobals->v_up * -6 + gpGlobals->v_right * 3; if( gpGlobals->time - m_pPlayer->m_flStartCharge > GetFullChargeTime() ) { @@ -355,7 +353,7 @@ void CGauss::StartFire( void ) if( !g_pGameRules->IsMultiplayer() ) { - // in deathmatch, gauss can pop you up into the air. Not in single play. + // in deathmatch, xen squasher can pop you up into the air. Not in single play. m_pPlayer->pev->velocity.z = flZVel; } #endif @@ -369,181 +367,41 @@ void CGauss::StartFire( void ) Fire( vecSrc, vecAiming, flDamage ); } -void CGauss::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) +void CXS::Fire( Vector vecOrigSrc, Vector vecDir, float flDamage ) { - m_pPlayer->m_iWeaponVolume = GAUSS_PRIMARY_FIRE_VOLUME; - TraceResult tr, beam_tr; -#ifndef CLIENT_DLL - Vector vecSrc = vecOrigSrc; - Vector vecDest = vecSrc + vecDir * 8192; - edict_t *pentIgnore; - float flMaxFrac = 1.0; - int nTotal = 0; - int fHasPunched = 0; - int fFirstBeam = 1; - int nMaxHits = 10; + m_pPlayer->m_iWeaponVolume = XS_PRIMARY_FIRE_VOLUME; - pentIgnore = ENT( m_pPlayer->pev ); -#else - if( m_fPrimaryFire == false ) - g_irunninggausspred = true; -#endif - // The main firing event is sent unreliably so it won't be delayed. - PLAYBACK_EVENT_FULL( FEV_NOTHOST, m_pPlayer->edict(), m_usGaussFire, 0.0, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, flDamage, 0.0, 0, 0, m_fPrimaryFire ? 1 : 0, 0 ); + CXSBeam *pXSBeam = CXSBeam::CXSBeamCreate( flDamage ); + + pXSBeam->pev->origin = vecOrigSrc; + pXSBeam->m_vecOldOrigin = vecOrigSrc; + pXSBeam->pev->angles = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; + pXSBeam->pev->velocity = vecDir * 1250.0f; + pXSBeam->pev->owner = m_pPlayer->edict(); + pXSBeam->Init(); + + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_shot.wav", flDamage * 0.0025 + 0.5, ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 16 ) ); // This reliable event is used to stop the spinning sound // It's delayed by a fraction of second to make sure it is delayed by 1 frame on the client // It's sent reliably anyway, which could lead to other delays + PLAYBACK_EVENT_FULL( FEV_RELIABLE, m_pPlayer->edict(), m_usXSSpin, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); - PLAYBACK_EVENT_FULL( FEV_NOTHOST | FEV_RELIABLE, m_pPlayer->edict(), m_usGaussFire, 0.01, (float *)&m_pPlayer->pev->origin, (float *)&m_pPlayer->pev->angles, 0.0, 0.0, 0, 0, 0, 1 ); - - /*ALERT( at_console, "%f %f %f\n%f %f %f\n", - vecSrc.x, vecSrc.y, vecSrc.z, - vecDest.x, vecDest.y, vecDest.z );*/ - - //ALERT( at_console, "%f %f\n", tr.flFraction, flMaxFrac ); - -#ifndef CLIENT_DLL - while( flDamage > 10 && nMaxHits > 0 ) - { - nMaxHits--; - - // ALERT( at_console, "." ); - UTIL_TraceLine( vecSrc, vecDest, dont_ignore_monsters, pentIgnore, &tr ); - - if( tr.fAllSolid ) - break; - - CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit ); - - if( pEntity == NULL ) - break; - - if( fFirstBeam ) - { - m_pPlayer->pev->effects |= EF_MUZZLEFLASH; - fFirstBeam = 0; - - nTotal += 26; - } - - if( pEntity->pev->takedamage ) - { - ClearMultiDamage(); - pEntity->TraceAttack( m_pPlayer->pev, flDamage, vecDir, &tr, DMG_BULLET ); - ApplyMultiDamage( m_pPlayer->pev, m_pPlayer->pev ); - } - - if( pEntity->ReflectGauss() ) - { - float n; - - pentIgnore = NULL; - - n = -DotProduct( tr.vecPlaneNormal, vecDir ); - - if( n < 0.5 ) // 60 degrees - { - // ALERT( at_console, "reflect %f\n", n ); - // reflect - Vector r; - - r = 2.0 * tr.vecPlaneNormal * n + vecDir; - flMaxFrac = flMaxFrac - tr.flFraction; - vecDir = r; - vecSrc = tr.vecEndPos + vecDir * 8; - vecDest = vecSrc + vecDir * 8192; - - // explode a bit - m_pPlayer->RadiusDamage( tr.vecEndPos, pev, m_pPlayer->pev, flDamage * n, CLASS_NONE, DMG_BLAST ); - - nTotal += 34; - - // lose energy - if( n == 0 ) n = 0.1; - flDamage = flDamage * ( 1 - n ); - } - else - { - nTotal += 13; - - // limit it to one hole punch - if( fHasPunched ) - break; - fHasPunched = 1; - - // try punching through wall if secondary attack (primary is incapable of breaking through) - if( !m_fPrimaryFire ) - { - UTIL_TraceLine( tr.vecEndPos + vecDir * 8, vecDest, dont_ignore_monsters, pentIgnore, &beam_tr ); - if( !beam_tr.fAllSolid ) - { - // trace backwards to find exit point - UTIL_TraceLine( beam_tr.vecEndPos, tr.vecEndPos, dont_ignore_monsters, pentIgnore, &beam_tr ); - - n = ( beam_tr.vecEndPos - tr.vecEndPos ).Length(); - - if( n < flDamage ) - { - if( n == 0 ) - n = 1; - flDamage -= n; - - // ALERT( at_console, "punch %f\n", n ); - nTotal += 21; - - // exit blast damage - //m_pPlayer->RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, CLASS_NONE, DMG_BLAST ); - float damage_radius; - - if( g_pGameRules->IsMultiplayer() ) - { - damage_radius = flDamage * 1.75; // Old code == 2.5 - } - else - { - damage_radius = flDamage * 2.5; - } - - ::RadiusDamage( beam_tr.vecEndPos + vecDir * 8, pev, m_pPlayer->pev, flDamage, damage_radius, CLASS_NONE, DMG_BLAST ); - - CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); - - nTotal += 53; - - vecSrc = beam_tr.vecEndPos + vecDir; - } - else if( !selfgauss.value ) - { - flDamage = 0; - } - } - else - { - //ALERT( at_console, "blocked %f\n", n ); - flDamage = 0; - } - } - else - { - //ALERT( at_console, "blocked solid\n" ); - - flDamage = 0; - } - - } - } - else - { - vecSrc = tr.vecEndPos + vecDir; - pentIgnore = ENT( pEntity->pev ); - } - } -#endif - // ALERT( at_console, "%d bytes\n", nTotal ); + pev->effects |= EF_MUZZLEFLASH; } -void CGauss::WeaponIdle( void ) +void CXS::Reload() +{ + if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == XS_MAX_CLIP ) + return; + + if( !m_fInAttack && DefaultReload( XS_MAX_CLIP, XS_RELOAD, 3.5 ) ) + { + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_reload.wav", 0.8, ATTN_NORM, 0, ATTN_NORM ); + } +} + +void CXS::WeaponIdle( void ) { ResetEmptySound(); @@ -553,13 +411,13 @@ void CGauss::WeaponIdle( void ) switch( RANDOM_LONG( 0, 3 ) ) { case 0: - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro4.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_moan1.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro5.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_moan2.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/electro6.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); + EMIT_SOUND( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/xs_moan3.wav", RANDOM_FLOAT( 0.7, 0.8 ), ATTN_NORM ); break; case 3: break; // no sound @@ -574,10 +432,10 @@ void CGauss::WeaponIdle( void ) { StartFire(); m_fInAttack = 0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.2; // Need to set m_flNextPrimaryAttack so the weapon gets a chance to complete its secondary fire animation. - Solokiller - if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) + if( m_iClip <= 0 ) m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.5; } else @@ -586,37 +444,60 @@ void CGauss::WeaponIdle( void ) float flRand = RANDOM_FLOAT( 0, 1 ); if( flRand <= 0.5 ) { - iAnim = GAUSS_IDLE; + iAnim = XS_IDLE; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } else if( flRand <= 0.75 ) { - iAnim = GAUSS_IDLE2; + iAnim = XS_IDLE2; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } else { - iAnim = GAUSS_FIDGET; + iAnim = XS_FIDGET; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3; } -#ifndef CLIENT_DLL SendWeaponAnim( iAnim ); -#endif } } -class CGaussAmmo : public CBasePlayerAmmo +class CXSAmmo : public CBasePlayerAmmo { + void EXPORT FallThink() + { + pev->nextthink = gpGlobals->time + 0.1; + + if( pev->flags & FL_ONGROUND ) + { + // clatter if we have an owner (i.e., dropped by someone) + // don't clatter if the gun is waiting to respawn (if it's waiting, it is invisible!) + if( !FNullEnt( pev->owner ) ) + { + EMIT_SOUND_DYN( ENT( pev ), CHAN_VOICE, "items/weapondrop1.wav", 1, ATTN_NORM, 0, 100 ); + } + + // lie flat + pev->angles.x = 0; + pev->angles.z = 0; + + UTIL_SetOrigin( pev, pev->origin );// link into world. + SetThink( NULL ); + } + } void Spawn( void ) { Precache(); - SET_MODEL( ENT( pev ), "models/w_gaussammo.mdl" ); + SET_MODEL( ENT( pev ), "models/w_xencandy.mdl" ); CBasePlayerAmmo::Spawn(); + + SetThink( &CXSAmmo::FallThink ); + pev->nextthink = gpGlobals->time + 0.1; } void Precache( void ) { - PRECACHE_MODEL( "models/w_gaussammo.mdl" ); + PRECACHE_MODEL( "models/w_xencandy.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); + PRECACHE_SOUND( "items/weapondrop1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) { @@ -629,5 +510,5 @@ class CGaussAmmo : public CBasePlayerAmmo } }; -LINK_ENTITY_TO_CLASS( ammo_gaussclip, CGaussAmmo ) +LINK_ENTITY_TO_CLASS( ammo_xencandy, CXSAmmo ) #endif diff --git a/dlls/ggrenade.cpp b/dlls/ggrenade.cpp index 539401ad..4f9a37e0 100644 --- a/dlls/ggrenade.cpp +++ b/dlls/ggrenade.cpp @@ -56,34 +56,7 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) pev->takedamage = DAMAGE_NO; - if( FClassnameIs( pev, "monster_pipebomb" ) ) - { - int trailCount = RANDOM_LONG( 1, 4 ); - for( int i = 0; i < trailCount; i++ ) - Create( "fire_trail", pev->origin, pTrace->vecPlaneNormal, NULL ); - - // blast circles - MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); - WRITE_BYTE( TE_BEAMCYLINDER ); - WRITE_COORD( pev->origin.x ); - WRITE_COORD( pev->origin.y ); - WRITE_COORD( pev->origin.z + 16 ); - WRITE_COORD( pev->origin.x ); - WRITE_COORD( pev->origin.y ); - WRITE_COORD( pev->origin.z + 16 + 384 ); // reach damage radius over .3 seconds - WRITE_SHORT( g_sModelIndexShockwave ); - WRITE_BYTE( 0 ); // startframe - WRITE_BYTE( 0 ); // framerate - WRITE_BYTE( 3 ); // life - WRITE_BYTE( 16 ); // width - WRITE_BYTE( 0 ); // noise - WRITE_BYTE( 255 ); // r - WRITE_BYTE( 255 ); // g - WRITE_BYTE( 255 ); // b - WRITE_BYTE( 255 ); //brightness - WRITE_BYTE( 0 ); // speed - MESSAGE_END(); - } + Vector vecOldOrigin = pev->origin; // Pull out of the wall a bit if( pTrace->flFraction != 1.0 ) @@ -111,6 +84,35 @@ void CGrenade::Explode( TraceResult *pTrace, int bitsDamageType ) WRITE_BYTE( TE_EXPLFLAG_NONE ); MESSAGE_END(); + if( FClassnameIs( pev, "monster_satchel" ) && iContents != CONTENTS_WATER ) + { + // blast circles + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_BEAMCYLINDER ); + WRITE_COORD( vecOldOrigin.x ); + WRITE_COORD( vecOldOrigin.y ); + WRITE_COORD( vecOldOrigin.z + 16 ); + WRITE_COORD( vecOldOrigin.x ); + WRITE_COORD( vecOldOrigin.y ); + WRITE_COORD( vecOldOrigin.z + 700 ); // reach damage radius over .3 seconds + WRITE_SHORT( static_cast( this )->m_iTrail ); + WRITE_BYTE( 0 ); // startframe + WRITE_BYTE( 10 ); // framerate + WRITE_BYTE( 2 ); // life + WRITE_BYTE( 16 ); // width + WRITE_BYTE( 0 ); // noise + WRITE_BYTE( 255 ); // r + WRITE_BYTE( 255 ); // g + WRITE_BYTE( 255 ); // b + WRITE_BYTE( 128 ); //brightness + WRITE_BYTE( 0 ); // speed + MESSAGE_END(); + + int trailCount = RANDOM_LONG( 2, 4 ); + for( int i = 0; i < trailCount; i++ ) + Create( "fire_trail", pev->origin, pTrace->vecPlaneNormal, NULL ); + } + CSoundEnt::InsertSound( bits_SOUND_COMBAT, pev->origin, NORMAL_EXPLOSION_VOLUME, 3.0 ); entvars_t *pevOwner; if( pev->owner ) diff --git a/dlls/glock.cpp b/dlls/glock.cpp index 1150d8b9..c70d8e40 100644 --- a/dlls/glock.cpp +++ b/dlls/glock.cpp @@ -20,6 +20,7 @@ #include "weapons.h" #include "nodes.h" #include "player.h" +#include "nail.h" enum glock_e { @@ -32,19 +33,22 @@ enum glock_e GLOCK_RELOAD_NOT_EMPTY, GLOCK_DRAW, GLOCK_HOLSTER, - GLOCK_ADD_SILENCER + GLOCK_ADD_SILENCER, + GLOCK_UPRIGHT_TO_TILT, + GLOCK_TILT_TO_UPRIGHT, + GLOCK_FASTSHOOT }; -LINK_ENTITY_TO_CLASS( weapon_glock, CGlock ) -LINK_ENTITY_TO_CLASS( weapon_9mmhandgun, CGlock ) +LINK_ENTITY_TO_CLASS( weapon_bradnailer, CGlock ) void CGlock::Spawn() { - pev->classname = MAKE_STRING( "weapon_9mmhandgun" ); // hack to allow for old names + // pev->classname = MAKE_STRING( "weapon_9mmhandgun" ); // hack to allow for old names Precache(); m_iId = WEAPON_GLOCK; - SET_MODEL( ENT( pev ), "models/w_9mmhandgun.mdl" ); + SET_MODEL( ENT( pev ), "models/w_bradnailer.mdl" ); + m_fInAttack = 0; m_iDefaultAmmo = GLOCK_DEFAULT_GIVE; FallInit();// get ready to fall down. @@ -52,21 +56,14 @@ void CGlock::Spawn() void CGlock::Precache( void ) { - PRECACHE_MODEL( "models/v_9mmhandgun.mdl" ); - PRECACHE_MODEL( "models/w_9mmhandgun.mdl" ); - PRECACHE_MODEL( "models/p_9mmhandgun.mdl" ); - - m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shell - + PRECACHE_MODEL( "models/v_bradnailer.mdl" ); + PRECACHE_MODEL( "models/w_bradnailer.mdl" ); + PRECACHE_MODEL( "models/p_bradnailer.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); PRECACHE_SOUND( "items/9mmclip2.wav" ); + PRECACHE_SOUND( "weapons/bradnailer.wav" ); - PRECACHE_SOUND( "weapons/pl_gun1.wav" );//silenced handgun - PRECACHE_SOUND( "weapons/pl_gun2.wav" );//silenced handgun - PRECACHE_SOUND( "weapons/pl_gun3.wav" );//handgun - - m_usFireGlock1 = PRECACHE_EVENT( 1, "events/glock1.sc" ); - m_usFireGlock2 = PRECACHE_EVENT( 1, "events/glock2.sc" ); + // UTIL_PrecacheOther( "nailgun_nail" ); } int CGlock::GetItemInfo( ItemInfo *p ) @@ -101,82 +98,125 @@ int CGlock::AddToPlayer( CBasePlayer *pPlayer ) BOOL CGlock::Deploy() { // pev->body = 1; - return DefaultDeploy( "models/v_9mmhandgun.mdl", "models/p_9mmhandgun.mdl", GLOCK_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 ); + return DefaultDeploy( "models/v_bradnailer.mdl", "models/p_bradnailer.mdl", GLOCK_DRAW, "onehanded", /*UseDecrement() ? 1 : 0*/ 0 ); } void CGlock::SecondaryAttack( void ) { - GlockFire( 0.1, 0.2, FALSE ); + GlockFire( 0.2, FALSE ); } void CGlock::PrimaryAttack( void ) { - GlockFire( 0.01, 0.3, TRUE ); + GlockFire( 0.3, TRUE ); } -void CGlock::GlockFire( float flSpread, float flCycleTime, BOOL fUseAutoAim ) +void CGlock::GlockFire( float flCycleTime, BOOL fUseAutoAim ) { + // don't fire underwater + if( m_pPlayer->pev->waterlevel == 3 ) + { + PlayEmptySound(); + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; + return; + } + if( m_iClip <= 0 ) { if( m_fFireOnEmpty ) { PlayEmptySound(); - m_flNextPrimaryAttack = GetNextAttackDelay( 0.2 ); + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.15; } - return; } + if( fUseAutoAim ) + { + if( m_fInAttack ) + { + SendWeaponAnim( GLOCK_TILT_TO_UPRIGHT ); + m_fInAttack = 0; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + return; + } + + SendWeaponAnim( GLOCK_SHOOT ); + } + else + { + if( !m_fInAttack ) + { + SendWeaponAnim( GLOCK_UPRIGHT_TO_TILT ); + m_fInAttack = 1; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.3f; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; + return; + } + + SendWeaponAnim( GLOCK_FASTSHOOT ); + } m_iClip--; - m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; + m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; + + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/bradnailer.wav", 1.0, ATTN_NORM, 0, 98 + RANDOM_LONG( 0, 3 ) ); + + // m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - // silenced - if( pev->body == 1 ) - { - m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH; - } - else - { - // non-silenced - m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; - } + Vector vecAngles = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; + UTIL_MakeVectors( vecAngles ); - Vector vecSrc = m_pPlayer->GetGunPosition(); - Vector vecAiming; + vecAngles.x = -vecAngles.x; + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 3; + float flSpread; if( fUseAutoAim ) { - vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); + vecSrc = vecSrc + gpGlobals->v_up + gpGlobals->v_right * 2; + flSpread = 0.008732f; } else { - vecAiming = gpGlobals->v_forward; + flSpread = 0.06976f; } - Vector vecDir; - vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, Vector( flSpread, flSpread, flSpread ), 8192, BULLET_PLAYER_9MM, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed ); + float x, y; + do{ + x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + } + while( x * x + y * y > 1.0f ); - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), fUseAutoAim ? m_usFireGlock1 : m_usFireGlock2, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, ( m_iClip == 0 ) ? 1 : 0, 0 ); + Vector vecSpread = x * flSpread * gpGlobals->v_up + y * flSpread * gpGlobals->v_right + gpGlobals->v_forward; + Vector vecDest = vecSrc + vecSpread * 2048.0f; + + UTIL_MakeTracer( vecSrc, vecDest ); + + CNailGunNail *pNail = CNailGunNail::NailCreate( TRUE ); + pNail->pev->origin = vecSrc; + pNail->pev->angles = vecAngles; + pNail->pev->owner = m_pPlayer->edict(); + pNail->pev->velocity = vecSpread * 1600.0f; + pNail->pev->speed = 1600.0f; + pNail->pev->avelocity.z = 10; m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay( flCycleTime ); - if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); + if( m_fInAttack ) + { + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.0f; + } + else + { + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + } - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); + m_pPlayer->pev->punchangle.x -= 2.0f; } void CGlock::Reload( void ) @@ -184,30 +224,44 @@ void CGlock::Reload( void ) if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == GLOCK_MAX_CLIP ) return; - int iResult; + if( m_fInAttack ) + { + if( !m_fInSpecialReload ) + { + SendWeaponAnim( GLOCK_TILT_TO_UPRIGHT ); - if( m_iClip == 0 ) - iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD, 1.5 ); - else - iResult = DefaultReload( GLOCK_MAX_CLIP, GLOCK_RELOAD_NOT_EMPTY, 1.5 ); - - if( iResult ) + SetThink( &CGlock::ReloadWait ); + pev->nextthink = gpGlobals->time + 0.4; + m_fInSpecialReload = 1; + } + } + else if( DefaultReload( GLOCK_MAX_CLIP, m_iClip ? GLOCK_RELOAD : GLOCK_RELOAD_NOT_EMPTY, 2.3 ) ) { m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); } } +void CGlock::ReloadWait() +{ + m_fInAttack = m_fInSpecialReload = 0; + SetThink( NULL ); + Reload(); +} + void CGlock::WeaponIdle( void ) { ResetEmptySound(); - m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES ); - if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; - // only idle if the slid isn't back - if( m_iClip != 0 ) + if( m_fInAttack ) + { + m_fInAttack = 0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.4f; + SendWeaponAnim( GLOCK_TILT_TO_UPRIGHT ); + } + else { int iAnim; float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 ); @@ -236,13 +290,13 @@ class CGlockAmmo : public CBasePlayerAmmo void Spawn( void ) { Precache(); - SET_MODEL( ENT( pev ), "models/w_9mmclip.mdl" ); + SET_MODEL( ENT( pev ), "models/w_nailclip.mdl" ); CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL( "models/w_9mmclip.mdl" ); + PRECACHE_MODEL( "models/w_nailclip.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); } @@ -257,5 +311,4 @@ class CGlockAmmo : public CBasePlayerAmmo } }; -LINK_ENTITY_TO_CLASS( ammo_glockclip, CGlockAmmo ) -LINK_ENTITY_TO_CLASS( ammo_9mmclip, CGlockAmmo ) +LINK_ENTITY_TO_CLASS( ammo_nailclip, CGlockAmmo ) diff --git a/dlls/hgrunt.cpp b/dlls/hgrunt.cpp index 97899a5f..5a33f010 100644 --- a/dlls/hgrunt.cpp +++ b/dlls/hgrunt.cpp @@ -934,6 +934,33 @@ void CHGrunt::Spawn() m_HackedGunPos = Vector( 0, 0, 55 ); + if( pev->body ) + { + switch( pev->body ) + { + case 1: + SetBodygroup( HEAD_GROUP, HEAD_GRUNT ); + break; + case 2: + SetBodygroup( HEAD_GROUP, HEAD_COMMANDER ); + break; + case 3: + SetBodygroup( HEAD_GROUP, HEAD_SHOTGUN ); + break; + case 4: + SetBodygroup( HEAD_GROUP, HEAD_M203 ); + break; + default: + break; + } + } + else + { + SetBodygroup( HEAD_GROUP, RANDOM_LONG( HEAD_COMMANDER, HEAD_M203) ); + } + + pev->skin = 0; + if( pev->weapons == 0 ) { // initialize to original values @@ -942,6 +969,9 @@ void CHGrunt::Spawn() // pev->weapons = HGRUNT_9MMAR | HGRUNT_GRENADELAUNCHER; } + if( FBitSet( pev->weapons, HGRUNT_GRENADELAUNCHER ) ) + ClearBits( pev->weapons, HGRUNT_GRENADELAUNCHER ); + if( FBitSet( pev->weapons, HGRUNT_SHOTGUN ) ) { SetBodygroup( GUN_GROUP, GUN_SHOTGUN ); @@ -2375,5 +2405,38 @@ void CDeadHGrunt::Spawn( void ) // Corpses have less health pev->health = 8; + // map old bodies onto new bodies + switch( pev->body ) + { + case 0: + // Grunt with Gun + pev->body = 0; + pev->skin = 0; + SetBodygroup( HEAD_GROUP, HEAD_COMMANDER ); + SetBodygroup( GUN_GROUP, GUN_MP5 ); + break; + case 1: + // Commander with Gun + pev->body = 0; + pev->skin = 0; + SetBodygroup( HEAD_GROUP, HEAD_GRUNT ); + SetBodygroup( GUN_GROUP, GUN_MP5 ); + break; + case 2: + // Grunt no Gun + pev->body = 0; + pev->skin = 0; + SetBodygroup( HEAD_GROUP, HEAD_COMMANDER ); + SetBodygroup( GUN_GROUP, GUN_NONE ); + break; + case 3: + // Commander no Gun + pev->body = 0; + pev->skin = 0; + SetBodygroup( HEAD_GROUP, HEAD_GRUNT ); + SetBodygroup( GUN_GROUP, GUN_NONE ); + break; + } + MonsterInitDead(); } diff --git a/dlls/items.cpp b/dlls/items.cpp index f969b291..45edeb5e 100644 --- a/dlls/items.cpp +++ b/dlls/items.cpp @@ -30,7 +30,6 @@ #include "gamerules.h" extern int gmsgItemPickup; -extern int gmsgStartUp; class CWorldItem : public CBaseEntity { @@ -189,10 +188,10 @@ class CItemSuit : public CItem if( pPlayer->pev->weapons & ( 1<ShowPlayerHUD(); + if( pev->spawnflags & SF_SUIT_SHORTLOGON ) + EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_A0" ); // short version of suit logon, + else + EMIT_SOUND_SUIT( pPlayer->edict(), "!HEV_AAx" ); // long version of suit logon pPlayer->pev->weapons |= ( 1 << WEAPON_SUIT ); return TRUE; diff --git a/dlls/mortar.cpp b/dlls/mortar.cpp index 7faf3e56..e8c7bef3 100644 --- a/dlls/mortar.cpp +++ b/dlls/mortar.cpp @@ -197,6 +197,7 @@ public: void EXPORT MortarExplode( void ); int m_spriteTexture; + int m_blastwave; }; LINK_ENTITY_TO_CLASS( monster_mortar, CMortar ) @@ -217,6 +218,7 @@ void CMortar::Spawn() void CMortar::Precache() { m_spriteTexture = PRECACHE_MODEL( "sprites/lgtning.spr" ); + m_blastwave = PRECACHE_MODEL( "sprites/xbeam3.spr" ); } void CMortar::MortarExplode( void ) @@ -245,7 +247,7 @@ void CMortar::MortarExplode( void ) MESSAGE_END(); #endif -#if 0 +#if 1 // blast circle MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); WRITE_BYTE( TE_BEAMTORUS ); @@ -255,7 +257,7 @@ void CMortar::MortarExplode( void ) WRITE_COORD( pev->origin.x ); WRITE_COORD( pev->origin.y ); WRITE_COORD( pev->origin.z + 32 + pev->dmg * 2 / .2 ); // reach damage radius over .3 seconds - WRITE_SHORT( m_spriteTexture ); + WRITE_SHORT( m_blastwave ); WRITE_BYTE( 0 ); // startframe WRITE_BYTE( 0 ); // framerate WRITE_BYTE( 2 ); // life diff --git a/dlls/mp5.cpp b/dlls/mp5.cpp index 403efa04..4226a825 100644 --- a/dlls/mp5.cpp +++ b/dlls/mp5.cpp @@ -22,6 +22,7 @@ #include "player.h" #include "soundent.h" #include "gamerules.h" +#include "nail.h" enum mp5_e { @@ -32,24 +33,20 @@ enum mp5_e MP5_DEPLOY, MP5_FIRE1, MP5_FIRE2, - MP5_FIRE3 + MP5_FIRE3, + MP5_DEPLOY_EMPTY, + MP5_LONGIDLE_EMPTY, + MP5_IDLE1_EMPTY }; -LINK_ENTITY_TO_CLASS( weapon_mp5, CMP5 ) -LINK_ENTITY_TO_CLASS( weapon_9mmAR, CMP5 ) +LINK_ENTITY_TO_CLASS( weapon_nailgun, CMP5 ) //========================================================= //========================================================= -int CMP5::SecondaryAmmoIndex( void ) -{ - return m_iSecondaryAmmoType; -} - void CMP5::Spawn() { - pev->classname = MAKE_STRING( "weapon_9mmAR" ); // hack to allow for old names Precache(); - SET_MODEL( ENT( pev ), "models/w_9mmAR.mdl" ); + SET_MODEL( ENT( pev ), "models/w_nailgun.mdl" ); m_iId = WEAPON_MP5; m_iDefaultAmmo = MP5_DEFAULT_GIVE; @@ -59,31 +56,19 @@ void CMP5::Spawn() void CMP5::Precache( void ) { - PRECACHE_MODEL( "models/v_9mmAR.mdl" ); - PRECACHE_MODEL( "models/w_9mmAR.mdl" ); - PRECACHE_MODEL( "models/p_9mmAR.mdl" ); + PRECACHE_MODEL( "models/v_nailgun.mdl" ); + PRECACHE_MODEL( "models/w_nailgun.mdl" ); + PRECACHE_MODEL( "models/p_nailgun.mdl" ); - m_iShell = PRECACHE_MODEL( "models/shell.mdl" );// brass shellTE_MODEL - - PRECACHE_MODEL( "models/grenade.mdl" ); // grenade - - PRECACHE_MODEL( "models/w_9mmARclip.mdl" ); + PRECACHE_MODEL( "models/w_nailround.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); PRECACHE_SOUND( "items/clipinsert1.wav" ); PRECACHE_SOUND( "items/cliprelease1.wav" ); - PRECACHE_SOUND( "weapons/hks1.wav" );// H to the K - PRECACHE_SOUND( "weapons/hks2.wav" );// H to the K - PRECACHE_SOUND( "weapons/hks3.wav" );// H to the K + PRECACHE_SOUND( "weapons/nailgun.wav" ); - PRECACHE_SOUND( "weapons/glauncher.wav" ); - PRECACHE_SOUND( "weapons/glauncher2.wav" ); - - PRECACHE_SOUND( "weapons/357_cock1.wav" ); - - m_usMP5 = PRECACHE_EVENT( 1, "events/mp5.sc" ); - m_usMP52 = PRECACHE_EVENT( 1, "events/mp52.sc" ); + UTIL_PrecacheOther( "nailgun_nail" ); } int CMP5::GetItemInfo( ItemInfo *p ) @@ -91,11 +76,11 @@ int CMP5::GetItemInfo( ItemInfo *p ) p->pszName = STRING( pev->classname ); p->pszAmmo1 = "9mm"; p->iMaxAmmo1 = _9MM_MAX_CARRY; - p->pszAmmo2 = "ARgrenades"; - p->iMaxAmmo2 = M203_GRENADE_MAX_CARRY; + p->pszAmmo2 = NULL; + p->iMaxAmmo2 = -1; p->iMaxClip = MP5_MAX_CLIP; - p->iSlot = 2; - p->iPosition = 0; + p->iSlot = 1; + p->iPosition = 1; p->iFlags = 0; p->iId = m_iId = WEAPON_MP5; p->iWeight = MP5_WEIGHT; @@ -117,7 +102,7 @@ int CMP5::AddToPlayer( CBasePlayer *pPlayer ) BOOL CMP5::Deploy() { - return DefaultDeploy( "models/v_9mmAR.mdl", "models/p_9mmAR.mdl", MP5_DEPLOY, "mp5" ); + return DefaultDeploy( "models/v_nailgun.mdl", "models/p_nailgun.mdl", m_iClip ? MP5_DEPLOY : MP5_DEPLOY_EMPTY, "mp5" ); } void CMP5::PrimaryAttack() @@ -126,114 +111,62 @@ void CMP5::PrimaryAttack() if( m_pPlayer->pev->waterlevel == 3 ) { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = 0.3; return; } if( m_iClip <= 0 ) { PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; + m_flNextPrimaryAttack = 0.3; return; } m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; m_iClip--; - m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; + EMIT_SOUND_DYN( ENT( m_pPlayer->pev ), CHAN_WEAPON, "weapons/nailgun.wav", 1.0, ATTN_NORM, 0, 94 + RANDOM_LONG( 0, 15 ) ); + + SendWeaponAnim( MP5_FIRE1 + RANDOM_LONG( 0, 2 ) ); + + // m_pPlayer->pev->effects = (int)( m_pPlayer->pev->effects ) | EF_MUZZLEFLASH; // player "shoot" animation m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - Vector vecSrc = m_pPlayer->GetGunPosition(); - Vector vecAiming = m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); - Vector vecDir; -#ifdef CLIENT_DLL - if( !bIsMultiplayer() ) -#else - if( !g_pGameRules->IsMultiplayer() ) -#endif - { - // optimized multiplayer. Widened to make it easier to hit a moving player - vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_6DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed ); - } - else - { - // single player spread - vecDir = m_pPlayer->FireBulletsPlayer( 1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_MP5, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed ); + Vector vecAngles = m_pPlayer->pev->punchangle + m_pPlayer->pev->v_angle; + UTIL_MakeVectors( vecAngles ); + vecAngles.x = -vecAngles.x; + + Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 3 + gpGlobals->v_right * 3; + float flSpread = 0.0349; + + float x, y; + do{ + x = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); + y = RANDOM_FLOAT( -0.5, 0.5 ) + RANDOM_FLOAT( -0.5, 0.5 ); } + while( x * x + y * y > 1.0f ); - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usMP5, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); + Vector vecSpread = x * flSpread * gpGlobals->v_up + y * flSpread * gpGlobals->v_right + gpGlobals->v_forward; + Vector vecDest = vecSrc + vecSpread * 2048.0f; - if( !m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 ) - // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); + UTIL_MakeTracer( vecSrc, vecDest ); - m_flNextPrimaryAttack = GetNextAttackDelay( 0.1 ); - - if( m_flNextPrimaryAttack < UTIL_WeaponTimeBase() ) - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; + CNailGunNail *pNail = CNailGunNail::NailCreate( FALSE ); + pNail->pev->origin = vecSrc; + pNail->pev->angles = vecAngles; + pNail->pev->owner = m_pPlayer->edict(); + pNail->pev->velocity = vecSpread * 1600.0f; + pNail->pev->speed = 1600.0f; + pNail->pev->avelocity.z = 30; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1f; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); -} - -void CMP5::SecondaryAttack( void ) -{ - // don't fire underwater - if( m_pPlayer->pev->waterlevel == 3 ) - { - PlayEmptySound( ); - m_flNextPrimaryAttack = 0.15; - return; - } - - if( m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] == 0 ) - { - PlayEmptySound(); - return; - } - - m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = BRIGHT_GUN_FLASH; - - m_pPlayer->m_iExtraSoundTypes = bits_SOUND_DANGER; - m_pPlayer->m_flStopExtraSoundTime = UTIL_WeaponTimeBase() + 0.2; - - m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType]--; - - // player "shoot" animation - m_pPlayer->SetAnimation( PLAYER_ATTACK1 ); - - UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); - - // we don't add in player velocity anymore. - CGrenade::ShootContact( m_pPlayer->pev, - m_pPlayer->pev->origin + m_pPlayer->pev->view_ofs + gpGlobals->v_forward * 16, - gpGlobals->v_forward * 800 ); - - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - PLAYBACK_EVENT( flags, m_pPlayer->edict(), m_usMP52 ); - - m_flNextPrimaryAttack = GetNextAttackDelay( 1 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5;// idle pretty soon after shooting. - - if( !m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] ) - // HEV suit - indicate out of ammo condition - m_pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 ); + if( !m_iClip ) + SendWeaponAnim( MP5_LONGIDLE_EMPTY ); + m_pPlayer->pev->punchangle.x -= 1.0f; } void CMP5::Reload( void ) @@ -248,8 +181,6 @@ void CMP5::WeaponIdle( void ) { ResetEmptySound(); - m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES ); - if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; @@ -257,11 +188,11 @@ void CMP5::WeaponIdle( void ) switch( RANDOM_LONG( 0, 1 ) ) { case 0: - iAnim = MP5_LONGIDLE; + iAnim = m_iClip ? MP5_LONGIDLE : MP5_LONGIDLE_EMPTY; break; default: case 1: - iAnim = MP5_IDLE1; + iAnim = m_iClip ? MP5_IDLE1 : MP5_IDLE1_EMPTY; break; } @@ -270,23 +201,17 @@ void CMP5::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again. } -BOOL CMP5::IsUseable() -{ - //Can be used if the player has AR grenades. - Solokiller - return CBasePlayerWeapon::IsUseable() || m_pPlayer->m_rgAmmo[m_iSecondaryAmmoType] > 0; -} - class CMP5AmmoClip : public CBasePlayerAmmo { void Spawn( void ) { Precache(); - SET_MODEL( ENT( pev ), "models/w_9mmARclip.mdl" ); + SET_MODEL( ENT( pev ), "models/w_nailround.mdl" ); CBasePlayerAmmo::Spawn(); } void Precache( void ) { - PRECACHE_MODEL( "models/w_9mmARclip.mdl" ); + PRECACHE_MODEL( "models/w_nailround.mdl" ); PRECACHE_SOUND( "items/9mmclip1.wav" ); } BOOL AddAmmo( CBaseEntity *pOther ) @@ -300,59 +225,4 @@ class CMP5AmmoClip : public CBasePlayerAmmo } }; -LINK_ENTITY_TO_CLASS( ammo_mp5clip, CMP5AmmoClip ) -LINK_ENTITY_TO_CLASS( ammo_9mmAR, CMP5AmmoClip ) - -class CMP5Chainammo : public CBasePlayerAmmo -{ - void Spawn( void ) - { - Precache(); - SET_MODEL( ENT( pev ), "models/w_chainammo.mdl" ); - CBasePlayerAmmo::Spawn(); - } - void Precache( void ) - { - PRECACHE_MODEL( "models/w_chainammo.mdl" ); - PRECACHE_SOUND( "items/9mmclip1.wav" ); - } - BOOL AddAmmo( CBaseEntity *pOther ) - { - int bResult = ( pOther->GiveAmmo( AMMO_CHAINBOX_GIVE, "9mm", _9MM_MAX_CARRY ) != -1 ); - if( bResult ) - { - EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); - } - return bResult; - } -}; - -LINK_ENTITY_TO_CLASS( ammo_9mmbox, CMP5Chainammo ) - -class CMP5AmmoGrenade : public CBasePlayerAmmo -{ - void Spawn( void ) - { - Precache(); - SET_MODEL( ENT( pev ), "models/w_ARgrenade.mdl" ); - CBasePlayerAmmo::Spawn(); - } - void Precache( void ) - { - PRECACHE_MODEL( "models/w_ARgrenade.mdl" ); - PRECACHE_SOUND( "items/9mmclip1.wav" ); - } - BOOL AddAmmo( CBaseEntity *pOther ) - { - int bResult = ( pOther->GiveAmmo( AMMO_M203BOX_GIVE, "ARgrenades", M203_GRENADE_MAX_CARRY ) != -1 ); - - if( bResult ) - { - EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); - } - return bResult; - } -}; - -LINK_ENTITY_TO_CLASS( ammo_mp5grenades, CMP5AmmoGrenade ) -LINK_ENTITY_TO_CLASS( ammo_ARgrenades, CMP5AmmoGrenade ) +LINK_ENTITY_TO_CLASS( ammo_nailround, CMP5AmmoClip ) diff --git a/dlls/multiplay_gamerules.cpp b/dlls/multiplay_gamerules.cpp index 7922d413..8599b1bd 100644 --- a/dlls/multiplay_gamerules.cpp +++ b/dlls/multiplay_gamerules.cpp @@ -406,7 +406,8 @@ BOOL CHalfLifeMultiplay::ClientConnected( edict_t *pEntity, const char *pszName, #ifndef NO_VOICEGAMEMGR g_VoiceGameMgr.ClientConnected( pEntity ); #endif - return TRUE; + ALERT( at_error, "Sorry, there's no multiplayer mode in Poke646!\n" ); + return FALSE; } extern int gmsgSayText; diff --git a/dlls/player.cpp b/dlls/player.cpp index 8034a887..76d3fbad 100644 --- a/dlls/player.cpp +++ b/dlls/player.cpp @@ -119,28 +119,6 @@ TYPEDESCRIPTION CBasePlayer::m_playerSaveData[] = DEFINE_FIELD( CBasePlayer, m_iHideHUD, FIELD_INTEGER ), DEFINE_FIELD( CBasePlayer, m_iFOV, FIELD_INTEGER ), - // Music - DEFINE_FIELD( CBasePlayer, m_bSong01_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong02_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong03_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong04_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong05_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_bSong06_Played, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_flMusicCheckWait, FIELD_TIME ), - - // Player exert. - DEFINE_FIELD( CBasePlayer, m_iExertLevel, FIELD_INTEGER ), - DEFINE_FIELD( CBasePlayer, m_flExertRate, FIELD_FLOAT ), - DEFINE_FIELD( CBasePlayer, m_flExertUpdateStart, FIELD_TIME ), - - DEFINE_FIELD( CBasePlayer, m_fHudVisible, FIELD_BOOLEAN ), - DEFINE_FIELD( CBasePlayer, m_fUpdateHudVisibility, FIELD_BOOLEAN ), - - // Xensquasher - DEFINE_FIELD( CBasePlayer, m_flStartCharge, FIELD_TIME ), - DEFINE_FIELD( CBasePlayer, m_flPlayAftershock, FIELD_TIME ), - DEFINE_FIELD( CBasePlayer, m_flNextAmmoBurn, FIELD_TIME ), - //DEFINE_FIELD( CBasePlayer, m_fDeadTime, FIELD_FLOAT ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_fGameHUDInitialized, FIELD_INTEGER ), // only used in multiplayer games //DEFINE_FIELD( CBasePlayer, m_flStopExtraSoundTime, FIELD_TIME ), @@ -206,13 +184,11 @@ int gmsgShowMenu = 0; int gmsgGeigerRange = 0; int gmsgTeamNames = 0; int gmsgBhopcap = 0; +int gmsgPlayMP3 = 0; int gmsgStatusText = 0; int gmsgStatusValue = 0; -int gmsgStartUp = 0; -int gmsgScope = 0; - void LinkUserMessages( void ) { // Already taken care of? @@ -245,7 +221,7 @@ void LinkUserMessages( void ) gmsgGameMode = REG_USER_MSG( "GameMode", 1 ); gmsgMOTD = REG_USER_MSG( "MOTD", -1 ); gmsgServerName = REG_USER_MSG( "ServerName", -1 ); - gmsgAmmoPickup = REG_USER_MSG( "AmmoPickup", 2 ); + gmsgAmmoPickup = REG_USER_MSG( "AmmoPickup", 3 ); gmsgWeapPickup = REG_USER_MSG( "WeapPickup", 1 ); gmsgItemPickup = REG_USER_MSG( "ItemPickup", -1 ); gmsgHideWeapon = REG_USER_MSG( "HideWeapon", 1 ); @@ -253,15 +229,14 @@ void LinkUserMessages( void ) gmsgShowMenu = REG_USER_MSG( "ShowMenu", -1 ); gmsgShake = REG_USER_MSG( "ScreenShake", sizeof(ScreenShake) ); gmsgFade = REG_USER_MSG( "ScreenFade", sizeof(ScreenFade) ); - gmsgAmmoX = REG_USER_MSG( "AmmoX", 2 ); + gmsgAmmoX = REG_USER_MSG( "AmmoX", 3 ); + gmsgPlayMP3 = REG_USER_MSG( "PlayMP3", -1 ); gmsgTeamNames = REG_USER_MSG( "TeamNames", -1 ); - gmsgBhopcap = REG_USER_MSG( "Bhopcap", 1 ); gmsgStatusText = REG_USER_MSG( "StatusText", -1 ); gmsgStatusValue = REG_USER_MSG( "StatusValue", 3 ); - gmsgStartUp = REG_USER_MSG( "StartUp", 2 ); - gmsgScope = REG_USER_MSG( "Scope", 1 ); + gmsgBhopcap = REG_USER_MSG( "Bhopcap", 1 ); } LINK_ENTITY_TO_CLASS( player, CBasePlayer ) @@ -838,14 +813,12 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) pev->weaponmodel = 0; if( removeSuit ) - { pev->weapons = 0; - - HidePlayerHUD(); - } else pev->weapons &= ~WEAPON_ALLWEAPONS; + m_iHideHUD |= HIDEHUD_WEAPONS; + // Turn off flashlight ClearBits( pev->effects, EF_DIMLIGHT ); @@ -853,7 +826,7 @@ void CBasePlayer::RemoveAllItems( BOOL removeSuit ) m_rgAmmo[i] = 0; if( satchelfix.value ) - DeactivateSatchels( this ); + DeactivatePipebombs( this ); UpdateClientData(); @@ -1116,27 +1089,6 @@ void CBasePlayer::SetAnimation( PLAYER_ANIM playerAnim ) ResetSequenceInfo(); } -/* -=========== -TabulateAmmo -This function is used to find and store -all the ammo we have into the ammo vars. -============ -*/ -void CBasePlayer::TabulateAmmo() -{ - ammo_9mm = AmmoInventory( GetAmmoIndex( "9mm" ) ); - ammo_357 = AmmoInventory( GetAmmoIndex( "357" ) ); - ammo_argrens = AmmoInventory( GetAmmoIndex( "ARgrenades" ) ); - ammo_bolts = AmmoInventory( GetAmmoIndex( "bolts" ) ); - ammo_buckshot = AmmoInventory( GetAmmoIndex( "buckshot" ) ); - ammo_rockets = AmmoInventory( GetAmmoIndex( "rockets" ) ); - ammo_uranium = AmmoInventory( GetAmmoIndex( "uranium" ) ); - ammo_hornets = AmmoInventory( GetAmmoIndex( "Hornets" ) ); - ammo_nails = AmmoInventory( GetAmmoIndex( "nails" ) ); - ammo_xencandy = AmmoInventory( GetAmmoIndex( "xencandy" ) ); -} - /* =========== WaterMove @@ -1962,59 +1914,6 @@ void CBasePlayer::PreThink( void ) { pev->velocity = g_vecZero; } - - // Only try to play music if wait time has elapsed. - if( m_flMusicCheckWait <= gpGlobals->time ) - { - if( !m_bSong01_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "po_haz01" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/hazard.mp3\n" ); - m_bSong01_Played = TRUE; - } - } - if( !m_bSong02_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "po_aud01" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/audion.mp3\n" ); - m_bSong02_Played = TRUE; - } - } - if( !m_bSong03_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "po_sew01" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/sewer.mp3\n" ); - m_bSong03_Played = TRUE; - } - } - if( !m_bSong04_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "po_lib01" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/library.mp3\n" ); - m_bSong04_Played = TRUE; - } - } - if( !m_bSong05_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "po_eas01" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/eastend.mp3\n" ); - m_bSong05_Played = TRUE; - } - } - if( !m_bSong06_Played ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "credits" ) ) - { - CLIENT_COMMAND( edict(), "play sound/mp3/credits.mp3\n" ); - m_bSong06_Played = TRUE; - } - } - } } /* Time based Damage works as follows: 1) There are several types of timebased damage: @@ -2592,8 +2491,6 @@ pt_end: else pev->angles = m_vecLastViewAngles; - UpdateExertLevel(); - // Track button info so we can detect 'pressed' and 'released' buttons next frame m_afButtonLast = pev->button; @@ -2809,6 +2706,7 @@ void CBasePlayer::Spawn( void ) g_engfuncs.pfnSetPhysicsKeyValue( edict(), "slj", "0" ); g_engfuncs.pfnSetPhysicsKeyValue( edict(), "hl", "1" ); + SET_CLIENT_MAX_SPEED( edict(), PLAYER_MAX_SPEED ); pev->fov = m_iFOV = 0;// init field of view. m_iClientFOV = -1; // make sure fov reset is sent @@ -2873,17 +2771,6 @@ void CBasePlayer::Spawn( void ) m_flNextChatTime = gpGlobals->time; - m_bSong01_Played = - m_bSong02_Played = - m_bSong03_Played = - m_bSong04_Played = - m_bSong05_Played = - m_bSong06_Played = FALSE; - - m_fHudVisible = FALSE; - m_fUpdateHudVisibility = FALSE; - m_flMusicCheckWait = gpGlobals->time + 0.1f; // Give a bit of time before attempting to use MP3 player. - g_pGameRules->PlayerSpawn( this ); } @@ -3007,9 +2894,6 @@ int CBasePlayer::Restore( CRestore &restore ) // Barring that, we clear it out here instead of using the incorrect restored time value. m_flNextAttack = UTIL_WeaponTimeBase(); #endif - m_fUpdateHudVisibility = TRUE; - - m_flMusicCheckWait = gpGlobals->time + 0.5f; return status; } @@ -3454,19 +3338,18 @@ void CBasePlayer::CheatImpulseCommands( int iImpulse ) break; case 101: gEvilImpulse101 = TRUE; - GiveNamedItem( "item_suit" ); GiveNamedItem( "weapon_heaterpipe" ); + GiveNamedItem( "weapon_bradnailer" ); + GiveNamedItem( "ammo_nailclip" ); + GiveNamedItem( "weapon_nailgun" ); + GiveNamedItem( "ammo_nailround" ); GiveNamedItem( "weapon_shotgun" ); GiveNamedItem( "ammo_buckshot" ); GiveNamedItem( "weapon_cmlwbr" ); GiveNamedItem( "ammo_bolts" ); - GiveNamedItem( "weapon_pipebomb" ); - GiveNamedItem( "weapon_bradnailer" ); - GiveNamedItem( "ammo_nailclip" ); - GiveNamedItem( "ammo_nailround" ); - GiveNamedItem( "weapon_nailgun" ); GiveNamedItem( "weapon_xs" ); GiveNamedItem( "ammo_xencandy" ); + GiveNamedItem( "weapon_pipebomb" ); gEvilImpulse101 = FALSE; break; @@ -3627,6 +3510,8 @@ int CBasePlayer::AddPlayerItem( CBasePlayerItem *pItem ) g_pGameRules->PlayerGotWeapon( this, pItem ); pItem->CheckRespawn(); + m_iHideHUD &= ~HIDEHUD_WEAPONS; + pItem->m_pNext = m_rgpPlayerItems[pItem->iItemSlot()]; m_rgpPlayerItems[pItem->iItemSlot()] = pItem; @@ -3722,12 +3607,10 @@ int CBasePlayer::GiveAmmo( int iCount, const char *szName, int iMax ) // Send the message that ammo has been picked up MESSAGE_BEGIN( MSG_ONE, gmsgAmmoPickup, NULL, pev ); WRITE_BYTE( GetAmmoIndex( szName ) ); // ammo ID - WRITE_BYTE( iAdd ); // amount + WRITE_SHORT( iAdd ); // amount MESSAGE_END(); } - TabulateAmmo(); - return i; } @@ -3832,7 +3715,7 @@ void CBasePlayer::SendAmmoUpdate( void ) // send "Ammo" update message MESSAGE_BEGIN( MSG_ONE, gmsgAmmoX, NULL, pev ); WRITE_BYTE( i ); - WRITE_BYTE( Q_max( Q_min( m_rgAmmo[i], 254 ), 0 ) ); // clamp the value to one byte + WRITE_SHORT( Q_max( m_rgAmmo[i], 0 ) ); // clamp the value to 2 bytes MESSAGE_END(); } } @@ -3887,77 +3770,6 @@ void CBasePlayer::UpdateClientData( void ) InitStatusBar(); } - // - // Poke646 & Vendetta - Give suit to toggle hud on map po_aud01 or po_orl01 - // - if( !( pev->weapons & ( 1 << WEAPON_SUIT ) ) ) - { - if( FStrEq( STRING( gpGlobals->mapname ), "po_haz01" ) ) - { - pev->weapons |= ( 1 << WEAPON_SUIT ); - - // Force HUD update. - m_fHudVisible = TRUE; - - // - // Make HUD completely transparent. - // - HidePlayerHUD( TRUE ); - } - else if( FStrEq( STRING( gpGlobals->mapname ), "po_aud01" ) ) - { - pev->weapons |= ( 1 << WEAPON_SUIT ); - - // - // Make HUD completely transparent and slowly increase it's alpha. - // - ShowPlayerHUD(); - } - else if( FStrEq( STRING( gpGlobals->mapname ), "credits" ) ) - { - pev->weapons = 0; - - // - // Make HUD completely transparent and slowly increase it's alpha. - // - HidePlayerHUD( TRUE ); - } - } - - // Update HUD visibility. - if( m_fUpdateHudVisibility ) - { - // If player is frozen, tell client to hide HUD, - // if visible. - if( ( pev->flags & FL_FROZEN ) && m_fHudVisible ) - { - if( pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - HidePlayerHUD(); - } - } - // If player is not frozen, tell client to show HUD, - // if not visible. - else if( !( pev->flags & FL_FROZEN ) && !m_fHudVisible ) - { - if( pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - ShowPlayerHUD(); - } - } - else - { - if( pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - m_fHudVisible = FALSE; - - ShowPlayerHUD( TRUE ); - } - } - - m_fUpdateHudVisibility = FALSE; - } - if( m_iHideHUD != m_iClientHideHUD ) { MESSAGE_BEGIN( MSG_ONE, gmsgHideWeapon, NULL, pev ); @@ -4612,6 +4424,27 @@ BOOL CBasePlayer::HasNamedPlayerItem( const char *pszItemName ) return FALSE; } +CBasePlayerItem *CBasePlayer::GiveNamedPlayerItem( const char *pszItemName ) +{ + CBasePlayerItem *pItem; + int i; + + for( i = 0; i < MAX_ITEM_TYPES; i++ ) + { + pItem = m_rgpPlayerItems[i]; + + while( pItem ) + { + if( !strcmp( pszItemName, STRING( pItem->pev->classname ) ) ) + { + return pItem; + } + pItem = pItem->m_pNext; + } + } + + return 0; +} //========================================================= // //========================================================= @@ -4635,82 +4468,6 @@ BOOL CBasePlayer::SwitchWeapon( CBasePlayerItem *pWeapon ) return TRUE; } -void CBasePlayer::IncrementExertLevel( int amount ) -{ - m_iExertLevel += Q_min( amount, PLAYER_EXERT_LEVEL_MAX - m_iExertLevel ); -} - -void CBasePlayer::DecrementExertLevel( int amount ) -{ - m_iExertLevel -= Q_min( amount, m_iExertLevel ); -} - -void CBasePlayer::SetExertLevel( int level ) -{ - m_iExertLevel = clamp( level, PLAYER_EXERT_LEVEL_MIN, PLAYER_EXERT_LEVEL_MAX ); -} - -int CBasePlayer::GetExertLevel( void ) const -{ - return m_iExertLevel; -} - -void CBasePlayer::UpdateExertLevel( void ) -{ - if( m_iExertLevel > PLAYER_EXERT_LEVEL_MIN ) - { - // Slowly decrease exert level. - if( ( gpGlobals->time - m_flExertUpdateStart ) > m_flExertRate ) - { - float temp = (float)m_iExertLevel * 0.0625f; - - if( temp < 1 ) - temp = 1; - - m_iExertLevel -= Q_min( m_iExertLevel, temp ); - - m_flExertRate = PLAYER_EXERT_RATE; - m_flExertUpdateStart = gpGlobals->time; - } - } - -#ifndef CLIENT_DLL - // ALERT( at_console, "Player exert level: %d\n", m_iExertLevel ); -#endif -} - -void CBasePlayer::ShowPlayerHUD( BOOL bInstant ) -{ - if( m_fHudVisible ) - return; - - m_fHudVisible = TRUE; - - MESSAGE_BEGIN( MSG_ONE, gmsgStartUp, NULL, pev ); - WRITE_BYTE( 255 ); // Target alpha - if( bInstant ) - WRITE_BYTE( 255 ); // Startup alpha - else - WRITE_BYTE( 0 ); // Startup alpha - MESSAGE_END(); -} - -void CBasePlayer::HidePlayerHUD( BOOL bInstant ) -{ - if( !m_fHudVisible ) - return; - - m_fHudVisible = FALSE; - - MESSAGE_BEGIN( MSG_ONE, gmsgStartUp, NULL, pev ); - WRITE_BYTE( 0 ); // Target alpha - if( bInstant ) - WRITE_BYTE( 0 ); // Startup alpha - else - WRITE_BYTE( 255 ); // Startup alpha - MESSAGE_END(); -} - //========================================================= // Dead HEV suit prop //========================================================= @@ -4803,12 +4560,7 @@ void CStripWeapons::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE } if( pPlayer ) - { - if( !FStrEq( STRING( gpGlobals->mapname ), "po_xen01" ) ) - pPlayer->RemoveAllItems( TRUE ); - else - pPlayer->RemoveAllItems( FALSE ); - } + pPlayer->RemoveAllItems( FALSE ); } class CRevertSaved : public CPointEntity diff --git a/dlls/player.h b/dlls/player.h index 6dd4d7fe..476863be 100644 --- a/dlls/player.h +++ b/dlls/player.h @@ -23,6 +23,7 @@ #define DAMAGE_FOR_FALL_SPEED (float) 100 / ( PLAYER_FATAL_FALL_SPEED - PLAYER_MAX_SAFE_FALL_SPEED )// damage per unit per second. #define PLAYER_MIN_BOUNCE_SPEED 200 #define PLAYER_FALL_PUNCH_THRESHHOLD (float)350 // won't punch player's screen/make scrape noise unless player falling at least this fast. +#define PLAYER_MAX_SPEED 220 // // Player PHYSICS FLAGS bits @@ -61,18 +62,6 @@ #define TEAM_NAME_LENGTH 16 -// -// Player exert. -// - -#define PLAYER_EXERT_LEVEL_MIN 0 -#define PLAYER_EXERT_LEVEL_MAX 50 -#define PLAYER_EXERT_RATE 0.2f - -#define PLAYER_BREATHE_LEVEL 5 -#define PLAYER_BREATHE_VOLUME_MAX 2.0f -#define PLAYER_BREATHE_SOUND "player/breathe2.wav" - typedef enum { PLAYER_IDLE, @@ -277,6 +266,7 @@ public: void DropPlayerItem ( char *pszItemName ); BOOL HasPlayerItem( CBasePlayerItem *pCheckItem ); BOOL HasNamedPlayerItem( const char *pszItemName ); + CBasePlayerItem *GiveNamedPlayerItem( const char *pszItemName ); BOOL HasWeapons( void );// do I have ANY weapons? void SelectPrevItem( int iItem ); void SelectNextItem( int iItem ); @@ -317,8 +307,6 @@ public: void SetCustomDecalFrames( int nFrames ); int GetCustomDecalFrames( void ); - void TabulateAmmo( void ); - Vector m_vecLastViewAngles; float m_flStartCharge; @@ -337,35 +325,6 @@ public: float m_flNextChatTime; - // Music - BOOL m_bSong01_Played; - BOOL m_bSong02_Played; - BOOL m_bSong03_Played; - BOOL m_bSong04_Played; - BOOL m_bSong05_Played; - BOOL m_bSong06_Played; - float m_flMusicCheckWait; - - // - // Exert - // - void IncrementExertLevel( int amount ); - void DecrementExertLevel( int amount ); - void SetExertLevel( int level ); - int GetExertLevel( void ) const; - - void UpdateExertLevel( void ); - - int m_iExertLevel; - float m_flExertRate; - float m_flExertUpdateStart; - - // HUD visibility - void ShowPlayerHUD( BOOL bInstant = FALSE ); - void HidePlayerHUD( BOOL bInstant = FALSE ); - - BOOL m_fHudVisible; - BOOL m_fUpdateHudVisibility; bool m_bSentBhopcap; // If false, the player just joined and needs a bhopcap message. }; diff --git a/dlls/playermonster.cpp b/dlls/playermonster.cpp index cd3484ab..8747b3c0 100644 --- a/dlls/playermonster.cpp +++ b/dlls/playermonster.cpp @@ -82,7 +82,7 @@ void CPlayerMonster :: HandleAnimEvent( MonsterEvent_t *pEvent ) //========================================================= int CPlayerMonster::ISoundMask( void ) { - return NULL; + return 0; } //========================================================= diff --git a/dlls/poke646/bradnailer.cpp b/dlls/poke646/bradnailer.cpp deleted file mode 100644 index e90e684c..00000000 --- a/dlls/poke646/bradnailer.cpp +++ /dev/null @@ -1,326 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "nail.h" - -enum bradnailer_e { - BRADNAILER_IDLE1 = 0, - BRADNAILER_IDLE2, - BRADNAILER_IDLE3, - BRADNAILER_SHOOT, - BRADNAILER_SHOOT_EMPTY, - BRADNAILER_RELOAD, - BRADNAILER_RELOAD_NOT_EMPTY, - BRADNAILER_DRAW, - BRADNAILER_HOLSTER, - BRADNAILER_ADD_SILENCER, - BRADNAILER_UPRIGHT_TO_TILT, - BRADNAILER_TILT_TO_UPRIGHT, - BRADNAILER_FASTSHOOT, -}; - -LINK_ENTITY_TO_CLASS(weapon_bradnailer, CBradnailer); - -void CBradnailer::Spawn() -{ - Precache(); - m_iId = WEAPON_BRADNAILER; - SET_MODEL(ENT(pev), "models/w_bradnailer.mdl"); - - m_iDefaultAmmo = BRADNAILER_DEFAULT_GIVE; - - FallInit();// get ready to fall down. -} - - -void CBradnailer::Precache(void) -{ - PRECACHE_MODEL("models/v_bradnailer.mdl"); - PRECACHE_MODEL("models/w_bradnailer.mdl"); - PRECACHE_MODEL("models/p_bradnailer.mdl"); - - m_iShell = PRECACHE_MODEL("models/shell.mdl");// brass shell - - PRECACHE_SOUND("items/9mmclip1.wav"); - PRECACHE_SOUND("items/9mmclip2.wav"); - - PRECACHE_SOUND("weapons/bradnailer.wav"); - - m_usFireBradnailer = PRECACHE_EVENT(1, "events/bradnailer.sc"); - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); - - UTIL_PrecacheOther( "nail" ); -} - -int CBradnailer::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = "nails"; - p->iMaxAmmo1 = NAILS_MAX_CARRY; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = BRADNAILER_MAX_CLIP; - p->iSlot = 1; - p->iPosition = 0; - p->iFlags = 0; - p->iId = m_iId = WEAPON_BRADNAILER; - p->iWeight = BRADNAILER_WEIGHT; - - return 1; -} - -BOOL CBradnailer::Deploy() -{ - return DefaultDeploy("models/v_bradnailer.mdl", "models/p_bradnailer.mdl", BRADNAILER_DRAW, "bradnailer", 0); -} - -BOOL CBradnailer::CanHolster(void) -{ - return (m_fInAttack == 0); -} - -void CBradnailer::Holster(int skiplocal /*= 0*/) -{ - m_fInReload = FALSE;// cancel any reload in progress. - - m_pPlayer->m_flNextAttack = gpGlobals->time + 0.5; - SendWeaponAnim(BRADNAILER_HOLSTER); - - m_fInAttack = 0; -} - -void CBradnailer::SecondaryAttack(void) -{ - if (m_iClip <= 0) - { - Reload(); - m_flNextSecondaryAttack = 0.15f; - return; - } - - if (m_flNextSecondaryAttack > gpGlobals->time) - return; - - if (m_fInAttack == 0) - { -#ifndef CLIENT_DLL - //ALERT(at_console, "BRADNAILER_UPRIGHT_TO_TILT\n" ); -#endif - - SendWeaponAnim(BRADNAILER_UPRIGHT_TO_TILT, UseDecrement()); - - m_fInAttack = 1; - - m_flTimeWeaponIdle = gpGlobals->time + 0.7; - m_flNextSecondaryAttack = gpGlobals->time + 0.7; - m_flNextPrimaryAttack = gpGlobals->time + 2.0; - return; - } - else if (m_fInAttack == 1) - { - if (m_flTimeWeaponIdle < gpGlobals->time) - { -#ifndef CLIENT_DLL - //ALERT(at_console, "Fire\n"); -#endif - Fire(0.05, 0.2, FALSE, TRUE); - - m_fInAttack = 1; - - m_flTimeWeaponIdle = gpGlobals->time + 0.2f; - m_flNextPrimaryAttack = gpGlobals->time + 0.5; - } - } -} - -void CBradnailer::PrimaryAttack(void) -{ - if (m_fInAttack != 0) - { - m_flNextPrimaryAttack = gpGlobals->time + 0.5; - return; - } - - if (m_iClip <= 0) - { - Reload(); - m_flNextPrimaryAttack = 0.15f; - return; - } - - Fire(0.01f, 0.3f, TRUE, FALSE); - - m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 0.3f; - - m_flTimeWeaponIdle = gpGlobals->time + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); -} - -void CBradnailer::Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim, BOOL fFastShoot) -{ - m_iClip--; - - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; - - int flags; - -//#if defined( CLIENT_WEAPONS ) -// flags = FEV_NOTHOST; -//#else - flags = 0; -//#endif - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - - m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; - - Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; - UTIL_MakeVectors(anglesAim); - - anglesAim.x = -anglesAim.x; - // Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; - Vector vecSrc; - Vector vecAiming; - - if (fFastShoot) - { - vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 2 + gpGlobals->v_up * -2; - } - else - { - vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 8 + gpGlobals->v_right * 3 + gpGlobals->v_up * -2; - } - - if (fUseAutoAim) - { - vecAiming = m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); - } - else - { - vecAiming = gpGlobals->v_forward; - } - - Vector vecDir; - vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, Vector(flSpread, flSpread, flSpread), 8192, BULLET_PLAYER_NAIL1, 2, 0, m_pPlayer->pev, m_pPlayer->random_seed); - - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usFireBradnailer, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, fFastShoot, 0); - -#ifndef CLIENT_DLL - - CNail *pNail = CNail::NailCreate(); - pNail->pev->origin = vecSrc; - pNail->pev->angles = anglesAim; - pNail->pev->owner = m_pPlayer->edict(); - - if (m_pPlayer->pev->waterlevel == 3) - { - pNail->pev->velocity = vecAiming * NAIL_WATER_VELOCITY; - pNail->pev->speed = NAIL_WATER_VELOCITY; - } - else - { - pNail->pev->velocity = vecAiming * NAIL_AIR_VELOCITY; - pNail->pev->speed = NAIL_AIR_VELOCITY; - } - pNail->pev->avelocity.z = 10; -#endif - -} - - -void CBradnailer::Reload(void) -{ - if (m_fInAttack != 0) - return; - - if (m_flNextPrimaryAttack > gpGlobals->time) - return; - - if (m_pPlayer->ammo_nails <= 0) - return; - - int iAnim = (m_iClip == 0) ? BRADNAILER_RELOAD : BRADNAILER_RELOAD_NOT_EMPTY; - - int iResult = DefaultReload(BRADNAILER_MAX_CLIP, iAnim, 2.3); - - if (iResult) - { - m_fInAttack = 0; - - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, iAnim, 0, 0, 0); - } -} - -BOOL CBradnailer::ShouldWeaponIdle(void) -{ - return (m_iClip == 0) || ((m_fInAttack != 0) && (m_pPlayer->pev->button & IN_ATTACK)); -} - -void CBradnailer::WeaponIdle(void) -{ - ResetEmptySound(); - - m_pPlayer->GetAutoaimVector(AUTOAIM_10DEGREES); - - if (m_flTimeWeaponIdle > gpGlobals->time) - return; - - if (m_fInAttack != 0) - { -#ifndef CLIENT_DLL - //ALERT(at_console, "BRADNAILER_TILT_TO_UPRIGHT\n"); -#endif - - SendWeaponAnim(BRADNAILER_TILT_TO_UPRIGHT, UseDecrement()); - - m_fInAttack = 0; - m_flTimeWeaponIdle = gpGlobals->time + 0.5f; - m_flNextPrimaryAttack = m_flNextSecondaryAttack = gpGlobals->time + 0.5f; - } - else - { - // only idle if the slid isn't back - if (m_iClip != 0) - { - int iAnim; - float flRand = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 0.0, 1.0); - - if (flRand <= 0.3 + 0 * 0.75) - { - iAnim = BRADNAILER_IDLE3; - m_flTimeWeaponIdle = gpGlobals->time + 49.0 / 16; - } - else if (flRand <= 0.6 + 0 * 0.875) - { - iAnim = BRADNAILER_IDLE1; - m_flTimeWeaponIdle = gpGlobals->time + 60.0 / 16.0; - } - else - { - iAnim = BRADNAILER_IDLE2; - m_flTimeWeaponIdle = gpGlobals->time + 40.0 / 16.0; - } - SendWeaponAnim(iAnim, 1); - } - } -} diff --git a/dlls/poke646/cmlwbr.cpp b/dlls/poke646/cmlwbr.cpp deleted file mode 100644 index 73bb104a..00000000 --- a/dlls/poke646/cmlwbr.cpp +++ /dev/null @@ -1,456 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "shake.h" -#include "gamerules.h" -#include "crossbow.h" - -extern int gmsgScope; - -enum cmlwbr_e { - CMLWBR_IDLE1 = 0, // drawn - CMLWBR_IDLE2, // undrawn - CMLWBR_FIDGET1, // drawn - CMLWBR_FIDGET2, // undrawn - CMLWBR_FIRE1, - CMLWBR_RELOAD, // drawn - CMLWBR_DRAWBACK, - CMLWBR_UNDRAW, - CMLWBR_DRAW1, // drawn - CMLWBR_DRAW2, // undrawn - CMLWBR_HOLSTER1, // drawn - CMLWBR_HOLSTER2, // undrawn -}; - -LINK_ENTITY_TO_CLASS(weapon_cmlwbr, CCmlwbr); - -void CCmlwbr::Spawn() -{ - Precache(); - m_iId = WEAPON_CMLWBR; - SET_MODEL(ENT(pev), "models/w_crossbow.mdl"); - - m_iDefaultAmmo = CMLWBR_DEFAULT_GIVE; - - SetDrawn( FALSE ); - - m_fInSpecialReload = 0; - - FallInit();// get ready to fall down. -} - -int CCmlwbr::AddToPlayer(CBasePlayer *pPlayer) -{ - if (CBasePlayerWeapon::AddToPlayer(pPlayer)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev); - WRITE_BYTE(m_iId); - MESSAGE_END(); - return TRUE; - } - return FALSE; -} - -void CCmlwbr::Precache(void) -{ - PRECACHE_MODEL("models/w_crossbow.mdl"); - PRECACHE_MODEL("models/v_cmlwbr.mdl"); - PRECACHE_MODEL("models/p_cmlwbr.mdl"); - - PRECACHE_SOUND("weapons/cmlwbr_drawback.wav"); - PRECACHE_SOUND("weapons/cmlwbr_fire.wav"); - PRECACHE_SOUND("weapons/cmlwbr_reload.wav"); - PRECACHE_SOUND("weapons/cmlwbr_undraw.wav"); - PRECACHE_SOUND("weapons/cmlwbr_zoom.wav"); - - PRECACHE_SOUND("weapons/xbow_fire1.wav"); - PRECACHE_SOUND("weapons/xbow_reload1.wav"); - - UTIL_PrecacheOther("crossbow_bolt"); - - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); - m_usCmlwbr = PRECACHE_EVENT(1, "events/cmlwbr.sc"); -} - - -int CCmlwbr::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = "bolts"; - p->iMaxAmmo1 = BOLT_MAX_CARRY; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = CMLWBR_MAX_CLIP; - p->iSlot = 2; - p->iPosition = 1; - p->iId = WEAPON_CMLWBR; - p->iFlags = 0; - p->iWeight = CMLWBR_WEIGHT; - return 1; -} - - -BOOL CCmlwbr::Deploy() -{ - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6f; - - if (IsDrawn()) - return DefaultDeploy("models/v_cmlwbr.mdl", "models/p_cmlwbr.mdl", CMLWBR_DRAW1, "bow"); - - return DefaultDeploy("models/v_cmlwbr.mdl", "models/p_cmlwbr.mdl", CMLWBR_DRAW2, "bow"); -} - -void CCmlwbr::Holster(int skiplocal /* = 0 */) -{ - m_fInReload = FALSE;// cancel any reload in progress. - - if (m_fInZoom) - { - ZoomOut(); - } - - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - - if (IsDrawn()) - SendWeaponAnim(CMLWBR_HOLSTER1); - else - SendWeaponAnim(CMLWBR_HOLSTER2); - - m_fInSpecialReload = 0; - - STOP_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_reload.wav"); - STOP_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_zoom.wav"); - STOP_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_drawback.wav"); - STOP_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_undraw.wav"); -} - -void CCmlwbr::PrimaryAttack(void) -{ - if (!IsDrawn() || (m_fInSpecialReload != 0)) - return; - - FireBolt(); -} - -void CCmlwbr::FireBolt() -{ -#ifndef CLIENT_DLL - //ALERT(at_console, "FireBolt\n"); -#endif - - TraceResult tr; - - if (m_iClip == 0) - { - PlayEmptySound(); - return; - } - - m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME; - - m_iClip--; - - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usCmlwbr, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, m_iClip, m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType], 0, 0); - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - - Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; - UTIL_MakeVectors(anglesAim); - - anglesAim.x = -anglesAim.x; - Vector vecSrc = m_pPlayer->GetGunPosition() - gpGlobals->v_up * 2; - Vector vecDir = gpGlobals->v_forward; - -#ifndef CLIENT_DLL - CCrossbowBolt *pBolt = CCrossbowBolt::BoltCreate(); - pBolt->pev->origin = vecSrc; - pBolt->pev->angles = anglesAim; - pBolt->pev->owner = m_pPlayer->edict(); - - if (m_pPlayer->pev->waterlevel == 3) - { - pBolt->pev->velocity = vecDir * BOLT_WATER_VELOCITY; - pBolt->pev->speed = BOLT_WATER_VELOCITY; - } - else - { - pBolt->pev->velocity = vecDir * BOLT_AIR_VELOCITY; - pBolt->pev->speed = BOLT_AIR_VELOCITY; - } - pBolt->pev->avelocity.z = 10; -#endif - - m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(0.6f); - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5f; - - // Undraw. - SetDrawn(FALSE); -} - - -void CCmlwbr::SecondaryAttack() -{ - if (!IsDrawn() || (m_fInSpecialReload != 0)) - return; - - ToggleZoom(); - - pev->nextthink = UTIL_WeaponTimeBase() + 0.1; - // m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; -} - - -void CCmlwbr::Reload(void) -{ - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 || m_iClip == CMLWBR_MAX_CLIP) - return; - - // don't reload until recoil is done - if (m_flNextPrimaryAttack > UTIL_WeaponTimeBase()) - return; - -#ifndef CLIENT_DLL - //ALERT(at_console, "RELOAD\n"); -#endif - - if (m_pPlayer->pev->fov != 0) - { - ZoomOut(); - } - - if (m_fInAttack != 0) - { - m_fInSpecialReload = 1; - } - - if (m_fInSpecialReload == 0) - { - Undraw(); - - m_fInSpecialReload = 1; - } - else if (m_fInSpecialReload == 1) - { - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) - return; - - DoReload(); - - m_fInSpecialReload = 0; - } -} - - -void CCmlwbr::WeaponIdle(void) -{ - m_pPlayer->GetAutoaimVector(AUTOAIM_2DEGREES); // get the autoaim vector but ignore it; used for autoaim crosshair in DM - - ResetEmptySound(); - - if (m_flTimeWeaponIdle < UTIL_WeaponTimeBase()) - { - if (m_iClip == 0 && m_fInSpecialReload == 0 && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) - { - Reload(); - } - else - { - if (m_fInSpecialReload != 0 && m_iClip != CMLWBR_MAX_CLIP) - { - Reload(); - } - else if(!IsDrawn()) - { - DrawBack(); - } - else - { - int iAnim; - float flRand = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 0, 1); - if (flRand <= 0.75) - { - if (m_iClip) - { - iAnim = CMLWBR_IDLE1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 93.0 / 30.0; - } - else - { - iAnim = CMLWBR_IDLE2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 93.0 / 30.0; - } - } - else - { - if (m_iClip) - { - iAnim = CMLWBR_FIDGET1; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 90.0 / 30.0; - } - else - { - iAnim = CMLWBR_FIDGET2; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 80.0 / 30.0; - } - } - SendWeaponAnim(iAnim, UseDecrement()); - } - } - } -} - -BOOL CCmlwbr::ShouldWeaponIdle(void) -{ - return (!IsDrawn() || m_fInSpecialReload != 0); -} - -BOOL CCmlwbr::IsDrawn(void) -{ - return (m_fInAttack == 0); -} - -void CCmlwbr::SetDrawn(BOOL bDrawn) -{ - m_fInAttack = (bDrawn) ? 0 : 1; -} - - -void CCmlwbr::ToggleZoom(void) -{ - if (m_pPlayer->pev->fov == 0) - { - ZoomIn(50); - } - else if (m_pPlayer->pev->fov == 50) - { - ZoomIn(25); - } - else - { - ZoomOut(); - } -} - -void CCmlwbr::ZoomIn(int iFOV) -{ - m_pPlayer->pev->fov = m_pPlayer->m_iFOV = iFOV; - - m_fInZoom = 1; - - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_zoom.wav", VOL_NORM, ATTN_NORM); - -#ifndef CLIENT_DLL - MESSAGE_BEGIN(MSG_ONE, gmsgScope, NULL, m_pPlayer->pev); - WRITE_BYTE(1); - MESSAGE_END(); - - UTIL_ScreenFade(m_pPlayer, Vector(0, 0, 0), 0.1, 0.1, 255, FFADE_IN | FFADE_OUT); -#endif -} - -void CCmlwbr::ZoomOut(void) -{ - m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; - - m_fInZoom = 0; - - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_zoom.wav", VOL_NORM, ATTN_NORM); - -#ifndef CLIENT_DLL - MESSAGE_BEGIN(MSG_ONE, gmsgScope, NULL, m_pPlayer->pev); - WRITE_BYTE(0); - MESSAGE_END(); -#endif -} - -void CCmlwbr::DoReload() -{ - if (DefaultReload(CMLWBR_MAX_CLIP, CMLWBR_RELOAD, 4.7)) // 4.7 - { - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_reload.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0, 0xF)); - } - - SetDrawn(FALSE); - - m_flNextPrimaryAttack = GetNextAttackDelay(6.0); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 4.8; -} - -void CCmlwbr::DrawBack(void) -{ - SendWeaponAnim(CMLWBR_DRAWBACK); - - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_drawback.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0, 0xF)); - - SetDrawn(TRUE); - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.3; - m_flNextPrimaryAttack = m_flNextSecondaryAttack = GetNextAttackDelay(1.3); -} - -void CCmlwbr::Undraw() -{ - SendWeaponAnim(CMLWBR_UNDRAW); - - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cmlwbr_undraw.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0, 0xF)); - - SetDrawn(FALSE); - - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.4; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.4; - m_flNextPrimaryAttack = GetNextAttackDelay(1.4); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 7.4; -} - -class CCmlwbrAmmo : public CBasePlayerAmmo -{ - void Spawn(void) - { - Precache(); - SET_MODEL(ENT(pev), "models/w_crossbow_clip.mdl"); - CBasePlayerAmmo::Spawn(); - } - void Precache(void) - { - PRECACHE_MODEL("models/w_crossbow_clip.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); - } - BOOL AddAmmo(CBaseEntity *pOther) - { - if (pOther->GiveAmmo(AMMO_CMLWBRCLIP_GIVE, "bolts", BOLT_MAX_CARRY) != -1) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); - return TRUE; - } - return FALSE; - } -}; -LINK_ENTITY_TO_CLASS(ammo_bolts, CCmlwbrAmmo); diff --git a/dlls/poke646/firetrail.cpp b/dlls/poke646/firetrail.cpp index 587f7bcc..b87d1848 100644 --- a/dlls/poke646/firetrail.cpp +++ b/dlls/poke646/firetrail.cpp @@ -23,23 +23,47 @@ // Fire Trail class CFireTrail : public CBaseEntity { +public: void Spawn(void); void Think(void); void Touch(CBaseEntity *pOther); int ObjectCaps(void) { return FCAP_DONT_SAVE; } + + int Save( CSave &save ); + int Restore( CRestore &restore ); + static TYPEDESCRIPTION m_SaveData[]; +private: + int m_spriteScale; // what's the exact fireball sprite scale? }; -LINK_ENTITY_TO_CLASS(fire_trail, CFireTrail); +LINK_ENTITY_TO_CLASS( fire_trail, CFireTrail ); -void CFireTrail::Spawn(void) +TYPEDESCRIPTION CFireTrail::m_SaveData[] = { - pev->velocity = RANDOM_FLOAT(200, 300) * pev->angles; - pev->velocity.x += RANDOM_FLOAT(-100.f, 100.f); - pev->velocity.y += RANDOM_FLOAT(-100.f, 100.f); - if (pev->velocity.z >= 0) + DEFINE_FIELD( CFireTrail, m_spriteScale, FIELD_INTEGER ), +}; + +IMPLEMENT_SAVERESTORE( CFireTrail, CBaseEntity ) + +void CFireTrail::Spawn( void ) +{ + pev->velocity = RANDOM_FLOAT(100.0f, 150.0f) * pev->angles; + if( RANDOM_LONG( 0, 1 ) ) + pev->velocity.x += RANDOM_FLOAT(-300.f, -100.f); + else + pev->velocity.x += RANDOM_FLOAT(100.f, 300.f); + + if( RANDOM_LONG( 0, 1 ) ) + pev->velocity.y += RANDOM_FLOAT(-300.f, -100.f); + else + pev->velocity.y += RANDOM_FLOAT(100.f, 300.f); + + if( pev->velocity.z >= 0 ) pev->velocity.z += 200; else pev->velocity.z -= 200; + + m_spriteScale = RANDOM_LONG( 7, 13 ); pev->movetype = MOVETYPE_BOUNCE; pev->gravity = 0.5; pev->nextthink = gpGlobals->time + 0.1; @@ -53,14 +77,18 @@ void CFireTrail::Spawn(void) pev->angles = g_vecZero; } - void CFireTrail::Think(void) { - CSprite* pSprite = CSprite::SpriteCreate("sprites/zerogxplode.spr", pev->origin, TRUE); - pSprite->AnimateAndDie(RANDOM_FLOAT(15.0f, 20.0f)); - pSprite->SetTransparency( kRenderTransAdd, 255, 255, 255, 192, kRenderFxNoDissipation ); - pSprite->SetScale(pev->speed); - pSprite->pev->frame = pSprite->Frames() - ((Q_max(0, pev->speed - (0.1 * pSprite->pev->framerate)) * pSprite->Frames()) / pev->maxspeed); + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_EXPLOSION); + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z ); + WRITE_SHORT( g_sModelIndexFireball ); + WRITE_BYTE( (BYTE)( m_spriteScale * pev->speed ) ); // scale * 10 + WRITE_BYTE( 15 ); // framerate + WRITE_BYTE( TE_EXPLFLAG_NOSOUND ); + MESSAGE_END(); pev->speed -= 0.1; if (pev->speed > 0) diff --git a/dlls/poke646/genericmodel.cpp b/dlls/poke646/genericmodel.cpp index e737474d..30deef70 100644 --- a/dlls/poke646/genericmodel.cpp +++ b/dlls/poke646/genericmodel.cpp @@ -21,6 +21,8 @@ #include "weapons.h" #include "player.h" +#define SF_MODEL_ANIMATE 1 + class CGenericModel : public CBaseAnimating { public: @@ -29,8 +31,6 @@ public: void Precache(void); void KeyValue(KeyValueData* pkvd); - void EXPORT IdleThink(void); - virtual int Save(CSave &save); virtual int Restore(CRestore &restore); static TYPEDESCRIPTION m_SaveData[]; @@ -50,74 +50,34 @@ IMPLEMENT_SAVERESTORE(CGenericModel, CBaseAnimating); void CGenericModel::KeyValue(KeyValueData* pkvd) { // UNDONE_WC: explicitly ignoring these fields, but they shouldn't be in the map file! - if (FStrEq(pkvd->szKeyName, "sequencename")) + if( FStrEq( pkvd->szKeyName, "sequencename" ) ) { - m_iszSequence = ALLOC_STRING(pkvd->szValue); + m_iszSequence = ALLOC_STRING( pkvd->szValue ); pkvd->fHandled = TRUE; } else CBaseDelay::KeyValue(pkvd); } -void CGenericModel::Spawn(void) +void CGenericModel::Spawn() { Precache(); pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_NONE; - pev->takedamage = DAMAGE_NO; SET_MODEL( ENT(pev), STRING(pev->model) ); - UTIL_SetSize( pev, Vector(0, 0, 0), Vector(0, 0, 0) ); + UTIL_SetSize( pev, g_vecZero, g_vecZero ); - if (!FStringNull(m_iszSequence)) + if( FBitSet( pev->spawnflags, SF_MODEL_ANIMATE ) ) { - pev->sequence = LookupSequence(STRING(m_iszSequence)); - - if (pev->sequence < 0) - { - ALERT(at_warning, "Generic model %s: Unknown sequence named: %s\n", STRING(pev->model), STRING(m_iszSequence)); - pev->sequence = 0; - } + pev->sequence = LookupSequence( STRING( m_iszSequence ) ); + pev->animtime = gpGlobals->time; + pev->framerate = 1.0f; } - else - { - pev->sequence = 0; - } - - pev->frame = 0; - pev->framerate = 1.0f; - - SetThink(&CGenericModel::IdleThink); - SetTouch(NULL); - SetUse(NULL); - - pev->nextthink = gpGlobals->time + 0.1; } -void CGenericModel::Precache(void) +void CGenericModel::Precache() { - PRECACHE_MODEL((char*)STRING(pev->model)); + PRECACHE_MODEL( STRING( pev->model ) ); } - -void CGenericModel::IdleThink(void) -{ - float flInterval = StudioFrameAdvance(); - - pev->nextthink = gpGlobals->time + 0.5; - - DispatchAnimEvents(flInterval); - - if (m_fSequenceFinished) - { - if (m_fSequenceLoops) - { - pev->frame = 0; - ResetSequenceInfo(); - } - else - { - SetThink( NULL ); - } - } -} \ No newline at end of file diff --git a/dlls/poke646/heaterpipe.cpp b/dlls/poke646/heaterpipe.cpp deleted file mode 100644 index ff2bce96..00000000 --- a/dlls/poke646/heaterpipe.cpp +++ /dev/null @@ -1,313 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "gamerules.h" - - -#define HEATERPIPE_BODYHIT_VOLUME 128 -#define HEATERPIPE_WALLHIT_VOLUME 512 - -#define HEATERPIPE_FIRE_RATE_MIN 0.5f -#define HEATERPIPE_FIRE_RATE_MAX 2.0f - -#define HEATERPIPE_FIRE_RATE_RATIO 0.75f - -void FindHullIntersection(const Vector &vecSrc, TraceResult &tr, float *mins, float *maxs, edict_t *pEntity); - -LINK_ENTITY_TO_CLASS(weapon_heaterpipe, CHeaterPipe); - - -enum heaterpipe_e { - HEATERPIPE_IDLE = 0, - HEATERPIPE_DRAW, - HEATERPIPE_HOLSTER, - HEATERPIPE_ATTACK1HIT, - HEATERPIPE_ATTACK1MISS, - HEATERPIPE_ATTACK2MISS, - HEATERPIPE_ATTACK2HIT, - HEATERPIPE_ATTACK3MISS, - HEATERPIPE_ATTACK3HIT, - HEATERPIPE_IDLE2, - HEATERPIPE_IDLE3, -}; - - -void CHeaterPipe::Spawn() -{ - Precache(); - m_iId = WEAPON_HEATERPIPE; - SET_MODEL(ENT(pev), "models/w_heaterpipe.mdl"); - m_iClip = -1; - - FallInit();// get ready to fall down. -} - - -void CHeaterPipe::Precache(void) -{ - PRECACHE_MODEL("models/v_heaterpipe.mdl"); - PRECACHE_MODEL("models/w_heaterpipe.mdl"); - PRECACHE_MODEL("models/p_heaterpipe.mdl"); - PRECACHE_SOUND("weapons/pipe_hit1.wav"); - PRECACHE_SOUND("weapons/pipe_hit2.wav"); - PRECACHE_SOUND("weapons/cbar_hitbod1.wav"); - PRECACHE_SOUND("weapons/cbar_hitbod2.wav"); - PRECACHE_SOUND("weapons/cbar_hitbod3.wav"); - PRECACHE_SOUND("weapons/pipe_miss.wav"); - - m_usHeaterPipe = PRECACHE_EVENT(1, "events/heaterpipe.sc"); -} - -int CHeaterPipe::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = NULL; - p->iMaxAmmo1 = -1; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = WEAPON_NOCLIP; - p->iSlot = 0; - p->iPosition = 1; - p->iId = WEAPON_HEATERPIPE; - p->iWeight = HEATERPIPE_WEIGHT; - return 1; -} - - - -BOOL CHeaterPipe::Deploy() -{ - return DefaultDeploy("models/v_heaterpipe.mdl", "models/p_heaterpipe.mdl", HEATERPIPE_DRAW, "heaterpipe"); -} - -void CHeaterPipe::Holster(int skiplocal /* = 0 */) -{ - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - SendWeaponAnim(HEATERPIPE_HOLSTER); - - STOP_SOUND(ENT(pev), CHAN_ITEM, "player/breathe2.wav"); -} - -void CHeaterPipe::PrimaryAttack() -{ - if (!Swing(1)) - { - SetThink(&CHeaterPipe::SwingAgain); - pev->nextthink = gpGlobals->time + 0.1; - } -} - - -void CHeaterPipe::Smack() -{ - DecalGunshot(&m_trHit, BULLET_PLAYER_CROWBAR); -} - - -void CHeaterPipe::SwingAgain(void) -{ - Swing(0); -} - - -void CHeaterPipe::WeaponIdle(void) -{ - STOP_SOUND(ENT(pev), CHAN_ITEM, "player/breathe2.wav"); -} - -int CHeaterPipe::Swing(int fFirst) -{ - int fDidHit = FALSE; - - TraceResult tr; - - UTIL_MakeVectors(m_pPlayer->pev->v_angle); - Vector vecSrc = m_pPlayer->GetGunPosition(); - Vector vecEnd = vecSrc + gpGlobals->v_forward * 32; - - UTIL_TraceLine(vecSrc, vecEnd, dont_ignore_monsters, ENT(m_pPlayer->pev), &tr); - -#ifndef CLIENT_DLL - if (tr.flFraction >= 1.0) - { - UTIL_TraceHull(vecSrc, vecEnd, dont_ignore_monsters, head_hull, ENT(m_pPlayer->pev), &tr); - if (tr.flFraction < 1.0) - { - // Calculate the point of intersection of the line (or hull) and the object we hit - // This is and approximation of the "best" intersection - CBaseEntity *pHit = CBaseEntity::Instance(tr.pHit); - if (!pHit || pHit->IsBSPModel()) - FindHullIntersection(vecSrc, tr, VEC_DUCK_HULL_MIN, VEC_DUCK_HULL_MAX, m_pPlayer->edict()); - vecEnd = tr.vecEndPos; // This is the point on the actual surface (the hull could have hit space) - } - } -#endif - - if (m_pPlayer->m_iExertLevel < PLAYER_EXERT_LEVEL_MAX) - { - m_pPlayer->m_iExertLevel++; - } - - if (m_pPlayer->m_iExertLevel > PLAYER_BREATHE_LEVEL) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, PLAYER_BREATHE_SOUND, PLAYER_BREATHE_VOLUME_MAX, ATTN_NORM); - } - - float flNextAttackTime = HEATERPIPE_FIRE_RATE_MIN; - - if (m_pPlayer->m_iExertLevel >= 4) - { - float flMinFireRate = HEATERPIPE_FIRE_RATE_MIN; - float flLongestFireRate = HEATERPIPE_FIRE_RATE_MAX - flMinFireRate; - flNextAttackTime = flNextAttackTime + (((m_pPlayer->m_iExertLevel - 4) * flLongestFireRate) / (PLAYER_EXERT_LEVEL_MAX - 4)); - } - - m_pPlayer->m_flExertUpdateStart = gpGlobals->time; - m_pPlayer->m_flExertRate = flNextAttackTime; - -#ifndef CLIENT_DLL - // ALERT(at_console, "HeaterPipe fire rate: %f\n", flNextAttackTime); -#endif - - - if (tr.flFraction >= 1.0) - { - PLAYBACK_EVENT_FULL(FEV_NOTHOST, m_pPlayer->edict(), m_usHeaterPipe, - 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0, 0, 0, - 0.0, 0, 0.0); - - if (fFirst) - { - // miss - m_flNextPrimaryAttack = GetNextAttackDelay(flNextAttackTime); - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - } - } - else - { - switch (((m_iSwing++) % 3)) - { - case 0: - SendWeaponAnim(HEATERPIPE_ATTACK1HIT, 0); break; - case 1: - SendWeaponAnim(HEATERPIPE_ATTACK2HIT, 0); break; - case 2: - SendWeaponAnim(HEATERPIPE_ATTACK3HIT, 0); break; - } - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - -#ifndef CLIENT_DLL - - // hit - fDidHit = TRUE; - CBaseEntity *pEntity = CBaseEntity::Instance(tr.pHit); - - ClearMultiDamage(); - - if ((m_flNextPrimaryAttack + 1 < UTIL_WeaponTimeBase()) || g_pGameRules->IsMultiplayer()) - { - // first swing does full damage - pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar, gpGlobals->v_forward, &tr, DMG_CLUB); - } - else - { - // subsequent swings do half - pEntity->TraceAttack(m_pPlayer->pev, gSkillData.plrDmgCrowbar / 2, gpGlobals->v_forward, &tr, DMG_CLUB); - } - ApplyMultiDamage(m_pPlayer->pev, m_pPlayer->pev); - - // play thwack, smack, or dong sound - float flVol = 1.0; - int fHitWorld = TRUE; - - if (pEntity) - { - if (pEntity->Classify() != CLASS_NONE && pEntity->Classify() != CLASS_MACHINE) - { - // play thwack or smack sound - switch (RANDOM_LONG(0, 2)) - { - case 0: - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM); break; - case 1: - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM); break; - case 2: - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM); break; - } - m_pPlayer->m_iWeaponVolume = HEATERPIPE_BODYHIT_VOLUME; - if (!pEntity->IsAlive()) - return TRUE; - else - flVol = 0.1; - - fHitWorld = FALSE; - } - } - - // play texture hit sound - // UNDONE: Calculate the correct point of intersection when we hit with the hull instead of the line - - if (fHitWorld) - { - float fvolbar = TEXTURETYPE_PlaySound(&tr, vecSrc, vecSrc + (vecEnd - vecSrc) * 2, BULLET_PLAYER_CROWBAR); - - if (g_pGameRules->IsMultiplayer()) - { - // override the volume here, cause we don't play texture sounds in multiplayer, - // and fvolbar is going to be 0 from the above call. - - fvolbar = 1; - } - - // also play crowbar strike - switch (RANDOM_LONG(0, 1)) - { - case 0: - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pipe_hit1.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0, 3)); - break; - case 1: - EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/pipe_hit2.wav", fvolbar, ATTN_NORM, 0, 98 + RANDOM_LONG(0, 3)); - break; - } - - // delay the decal a bit - m_trHit = tr; - } - - m_pPlayer->m_iWeaponVolume = flVol * HEATERPIPE_WALLHIT_VOLUME; -#endif - m_flNextPrimaryAttack = GetNextAttackDelay(flNextAttackTime * HEATERPIPE_FIRE_RATE_RATIO); - - SetThink(&CHeaterPipe::Smack); - pev->nextthink = UTIL_WeaponTimeBase() + 0.2; - - - } - return fDidHit; -} - - - diff --git a/dlls/poke646/mp3.cpp b/dlls/poke646/mp3.cpp new file mode 100644 index 00000000..9806ff5f --- /dev/null +++ b/dlls/poke646/mp3.cpp @@ -0,0 +1,98 @@ +/*** +* +* Copyright (c) 1996-2001, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "player.h" +#include "gamerules.h" +#include "mp3.h" + +extern int gmsgPlayMP3; +#define SF_AMBIENTMP3_LOOP 1 + +LINK_ENTITY_TO_CLASS( ambient_mp3, CAmbientMP3 ) + +CAmbientMP3 *CAmbientMP3::AmbientMP3Create( const char *pszSound ) +{ + // Create a new entity with CCrossbowBolt private data + CAmbientMP3 *pMPlayer = GetClassPtr( (CAmbientMP3 *)NULL ); + pMPlayer->pev->classname = MAKE_STRING( "ambient_mp3" ); + pMPlayer->pev->message = MAKE_STRING( pszSound ); + pMPlayer->Spawn(); + + return pMPlayer; +} + +void CAmbientMP3::Spawn( void ) +{ + if( pev->message && strlen( STRING( pev->message ) ) >= 1 ) + { + pev->solid = SOLID_NOT; + pev->movetype = MOVETYPE_NONE; + SetUse( &CAmbientMP3::ToggleUse ); + } + else + { + ALERT( at_console, "ambient_mp3 without soundfile at: %f, %f, %f, removing self...\n", pev->origin.x, pev->origin.y, pev->origin.z ); + UTIL_Remove( this ); + } +} + +void CAmbientMP3::ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +{ + edict_t *pClient; + const char *pszSound; + int i; + BOOL loop; + + loop = pev->spawnflags & SF_AMBIENTMP3_LOOP; + pszSound = STRING( pev->message ); + + if( FStrEq( pszSound, "#po_soundtrack#" ) ) + { + pszSound = 0; + + for( i = 0; i < g_soundtrackCount; i++ ) + { + if( FStrEq( g_soundtracklist[i].mapname, STRING( gpGlobals->mapname ) ) ) + { + pszSound = g_soundtracklist[i].soundfile; + loop = g_soundtracklist[i].loop; + break; + } + } + } + + if( !pszSound ) + { + UTIL_Remove( this ); + return; + } + + // manually find the single player. + pClient = g_engfuncs.pfnPEntityOfEntIndex( 1 ); + + if( pClient ) + { + MESSAGE_BEGIN( MSG_ONE, gmsgPlayMP3, NULL, pClient ); + WRITE_STRING( pszSound ); + WRITE_BYTE( loop ); + MESSAGE_END(); + } + + UTIL_Remove( this ); +} + diff --git a/dlls/poke646/mp3.h b/dlls/poke646/mp3.h new file mode 100644 index 00000000..df2aec0b --- /dev/null +++ b/dlls/poke646/mp3.h @@ -0,0 +1,7 @@ +class CAmbientMP3 : public CPointEntity +{ +public: + static CAmbientMP3 *AmbientMP3Create( const char *pszSound ); + void Spawn( void ); + void EXPORT ToggleUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); +}; diff --git a/dlls/poke646/nail.cpp b/dlls/poke646/nail.cpp index 237337af..6be1dc54 100644 --- a/dlls/poke646/nail.cpp +++ b/dlls/poke646/nail.cpp @@ -25,109 +25,116 @@ #include "nail.h" -LINK_ENTITY_TO_CLASS(nail, CNail); +LINK_ENTITY_TO_CLASS( nailgun_nail, CNailGunNail ) -CNail *CNail::NailCreate(void) +CNailGunNail *CNailGunNail::NailCreate( BOOL bIsBradnailer ) { // Create a new entity with CCrossbowBolt private data - CNail *pBolt = GetClassPtr((CNail *)NULL); - pBolt->pev->classname = MAKE_STRING("nail"); - pBolt->Spawn(); - - return pBolt; + CNailGunNail *pNail = GetClassPtr((CNailGunNail *)NULL); + pNail->pev->classname = MAKE_STRING("nailgun_nail"); + pNail->m_bIsBradnailer = bIsBradnailer; + pNail->Spawn(); + + return pNail; } -void CNail::Spawn() +void CNailGunNail::Spawn() { Precache(); pev->movetype = MOVETYPE_FLY; pev->solid = SOLID_BBOX; - pev->gravity = 0.0; + pev->gravity = 0.5; SET_MODEL(ENT(pev), "models/nail.mdl"); UTIL_SetOrigin(pev, pev->origin); - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); + UTIL_SetSize(pev, g_vecZero, g_vecZero); - SetTouch(&CNail::NailTouch); - SetThink(&CNail::NailThink); + SetTouch(&CNailGunNail::NailTouch); + SetThink(&CNailGunNail::BubbleThink); pev->nextthink = gpGlobals->time + 0.2; } -void CNail::Precache() +void CNailGunNail::Precache() { PRECACHE_MODEL("models/nail.mdl"); PRECACHE_SOUND("weapons/brad_hit1.wav"); PRECACHE_SOUND("weapons/brad_hit2.wav"); } -int CNail::Classify(void) +int CNailGunNail::Classify() { return CLASS_NONE; } -void CNail::NailTouch(CBaseEntity *pOther) +void CNailGunNail::NailTouch( CBaseEntity *pOther ) { - SetTouch(NULL); - SetThink(NULL); + SetTouch( NULL ); + SetThink( NULL ); - if (pOther->pev->takedamage) + if( pOther->pev->takedamage ) { TraceResult tr = UTIL_GetGlobalTrace(); - entvars_t *pevOwner; - - pevOwner = VARS(pev->owner); + entvars_t *pevOwner = VARS( pev->owner ); // UNDONE: this needs to call TraceAttack instead ClearMultiDamage(); - //pOther->TraceAttack(pevOwner, 0, pev->velocity.Normalize(), &tr, DMG_NEVERGIB); + pOther->TraceAttack( pevOwner, m_bIsBradnailer ? gSkillData.plrDmg9MM : gSkillData.plrDmgMP5, pev->velocity.Normalize(), &tr, DMG_NEVERGIB ); - ApplyMultiDamage(pev, pevOwner); + ApplyMultiDamage( pev, pevOwner ); - pev->velocity = Vector(0, 0, 0); + pev->velocity = g_vecZero; // play body "thwack" sound - switch (RANDOM_LONG(0, 1)) + switch( RANDOM_LONG( 0, 1 ) ) { case 0: - EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/brad_hit1.wav", 1, ATTN_NORM); break; + EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/brad_hit1.wav", 1, ATTN_NORM ); + break; case 1: - EMIT_SOUND(ENT(pev), CHAN_BODY, "weapons/brad_hit2.wav", 1, ATTN_NORM); break; + if( m_bIsBradnailer ) + EMIT_SOUND( ENT( pev ), CHAN_BODY, "weapons/brad_hit2.wav", 1, ATTN_NORM ); + break; } - Killed(pev, GIB_NEVER); + Killed( pev, GIB_NEVER ); } else { - EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "weapons/brad_hit1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 98 + RANDOM_LONG(0, 7)); + // EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "weapons/brad_hit1.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 98 + RANDOM_LONG(0, 7)); - SetThink(&CNail::SUB_Remove); + SetThink( &CBaseEntity::SUB_Remove ); pev->nextthink = gpGlobals->time;// this will get changed below if the bolt is allowed to stick in what it hit. - if (FClassnameIs(pOther->pev, "worldspawn")) + if( FClassnameIs( pOther->pev, "worldspawn" ) ) { // if what we hit is static architecture, can stay around for a while. Vector vecDir = pev->velocity.Normalize(); - UTIL_SetOrigin(pev, pev->origin - vecDir * 12); - pev->angles = UTIL_VecToAngles(vecDir); + UTIL_SetOrigin( pev, pev->origin - vecDir * RANDOM_LONG( 6, 10 ) ); + pev->angles = UTIL_VecToAngles( vecDir ); pev->solid = SOLID_NOT; pev->movetype = MOVETYPE_FLY; - pev->velocity = Vector(0, 0, 0); + pev->velocity = g_vecZero; pev->avelocity.z = 0; - pev->angles.z = RANDOM_LONG(0, 360); - pev->nextthink = gpGlobals->time + 10.0; + pev->angles.z = RANDOM_LONG( 0, 360 ); + pev->nextthink = gpGlobals->time + 2.0; } - /*if (UTIL_PointContents(pev->origin) != CONTENTS_WATER) + if( UTIL_PointContents( pev->origin ) != CONTENTS_WATER && RANDOM_LONG( 0, 4 ) == 4 ) { - UTIL_Sparks(pev->origin); - }*/ + UTIL_Sparks( pev->origin ); + } } } -void CNail::NailThink(void) +void CNailGunNail::BubbleThink() { pev->nextthink = gpGlobals->time + 0.1; + + if( pev->waterlevel == 0 ) + return; + + UTIL_BubbleTrail( pev->origin - pev->velocity * 0.1, pev->origin, 1 ); } diff --git a/dlls/poke646/nail.h b/dlls/poke646/nail.h index 0a30cbec..23c30631 100644 --- a/dlls/poke646/nail.h +++ b/dlls/poke646/nail.h @@ -22,16 +22,18 @@ //========================================================= // Nail projectile //========================================================= -class CNail : public CBaseEntity +class CNailGunNail : public CBaseEntity { - void Spawn(void); - void Precache(void); - int Classify(void); - void EXPORT NailThink(void); - void EXPORT NailTouch(CBaseEntity *pOther); - public: - static CNail *NailCreate(void); + void Spawn(); + void Precache(); + int Classify(); + void EXPORT NailTouch( CBaseEntity *pOther ); + void EXPORT BubbleThink(); + static CNailGunNail *NailCreate( BOOL bIsBradnailer ); + +private: + BOOL m_bIsBradnailer; }; -#endif // NAIL_H \ No newline at end of file +#endif // NAIL_H diff --git a/dlls/poke646/nailgun.cpp b/dlls/poke646/nailgun.cpp deleted file mode 100644 index ac2d11b4..00000000 --- a/dlls/poke646/nailgun.cpp +++ /dev/null @@ -1,290 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "soundent.h" -#include "gamerules.h" -#include "nail.h" - -enum nailgun_e -{ - NAILGUN_LONGIDLE = 0, - NAILGUN_IDLE1, - NAILGUN_LAUNCH, - NAILGUN_RELOAD, - NAILGUN_DEPLOY, - NAILGUN_FIRE1, - NAILGUN_FIRE2, - NAILGUN_FIRE3, - NAILGUN_DEPLOY_EMPTY, - NAILGUN_LONGIDLE_EMPTY, - NAILGUN_IDLE1_EMPTY, -}; - - -LINK_ENTITY_TO_CLASS(weapon_nailgun, CNailgun); - -void CNailgun::Spawn() -{ - Precache(); - SET_MODEL(ENT(pev), "models/w_nailgun.mdl"); - m_iId = WEAPON_NAILGUN; - - m_iDefaultAmmo = NAILGUN_DEFAULT_GIVE; - - FallInit();// get ready to fall down. -} - - -void CNailgun::Precache(void) -{ - PRECACHE_MODEL("models/v_nailgun.mdl"); - PRECACHE_MODEL("models/w_nailgun.mdl"); - PRECACHE_MODEL("models/p_nailgun.mdl"); - - m_iShell = PRECACHE_MODEL("models/shell.mdl");// brass shellTE_MODEL - - PRECACHE_MODEL("models/w_nailclip.mdl"); - PRECACHE_MODEL("models/w_nailround.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); - - PRECACHE_SOUND("items/clipinsert1.wav"); - PRECACHE_SOUND("items/cliprelease1.wav"); - - PRECACHE_SOUND("weapons/nailgun.wav"); - - PRECACHE_SOUND("weapons/357_cock1.wav"); - - m_usNailgun = PRECACHE_EVENT(1, "events/nailgun.sc"); - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); - - UTIL_PrecacheOther( "nail" ); -} - -int CNailgun::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = "nails"; - p->iMaxAmmo1 = NAILS_MAX_CARRY; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = NAILGUN_MAX_CLIP; - p->iSlot = 1; - p->iPosition = 1; - p->iFlags = 1; - p->iId = m_iId = WEAPON_NAILGUN; - p->iWeight = NAILGUN_WEIGHT; - - return 1; -} - -int CNailgun::AddToPlayer(CBasePlayer *pPlayer) -{ - if (CBasePlayerWeapon::AddToPlayer(pPlayer)) - { - MESSAGE_BEGIN(MSG_ONE, gmsgWeapPickup, NULL, pPlayer->pev); - WRITE_BYTE(m_iId); - MESSAGE_END(); - return TRUE; - } - return FALSE; -} - -BOOL CNailgun::Deploy() -{ - int iAnim; - if (m_iClip == 0) - iAnim = NAILGUN_DEPLOY_EMPTY; - else - iAnim = NAILGUN_DEPLOY; - - return DefaultDeploy("models/v_nailgun.mdl", "models/p_nailgun.mdl", iAnim, "nailgun"); -} - - -void CNailgun::PrimaryAttack() -{ - // don't fire underwater - if (m_pPlayer->pev->waterlevel == 3) - { - PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; - return; - } - - if (m_iClip <= 0) - { - PlayEmptySound(); - m_flNextPrimaryAttack = 0.15; - return; - } - - m_pPlayer->m_iWeaponVolume = NORMAL_GUN_VOLUME; - m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH; - - m_iClip--; - - - m_pPlayer->pev->effects = (int)(m_pPlayer->pev->effects) | EF_MUZZLEFLASH; - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - - Vector anglesAim = m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle; - UTIL_MakeVectors(anglesAim); - - anglesAim.x = -anglesAim.x; - Vector vecSrc = m_pPlayer->GetGunPosition() + gpGlobals->v_forward * 8 + gpGlobals->v_right * 4 + gpGlobals->v_up * -4; - Vector vecAiming = gpGlobals->v_forward; - - Vector vecDir; - vecDir = m_pPlayer->FireBulletsPlayer(1, vecSrc, vecAiming, VECTOR_CONE_3DEGREES, 8192, BULLET_PLAYER_NAIL2, 0, 0, m_pPlayer->pev, m_pPlayer->random_seed); - - int flags; -#if defined( CLIENT_WEAPONS ) - flags = FEV_NOTHOST; -#else - flags = 0; -#endif - - PLAYBACK_EVENT_FULL(flags, m_pPlayer->edict(), m_usNailgun, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0); - -#ifndef CLIENT_DLL - CNail *pNail = CNail::NailCreate(); - pNail->pev->origin = vecSrc; - pNail->pev->angles = anglesAim; - pNail->pev->owner = m_pPlayer->edict(); - - if (m_pPlayer->pev->waterlevel == 3) - { - pNail->pev->velocity = vecAiming * NAIL_WATER_VELOCITY; - pNail->pev->speed = NAIL_WATER_VELOCITY; - } - else - { - pNail->pev->velocity = vecAiming * NAIL_AIR_VELOCITY; - pNail->pev->speed = NAIL_AIR_VELOCITY; - } - pNail->pev->avelocity.z = 10; -#endif - - m_flNextPrimaryAttack = GetNextAttackDelay(0.1); - - if (m_flNextPrimaryAttack < UTIL_WeaponTimeBase()) - m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1; - - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); -} - -void CNailgun::Reload(void) -{ - if (m_pPlayer->ammo_nails <= 0) - return; - - int iAnim = NAILGUN_RELOAD; - int iResult = DefaultReload(NAILGUN_MAX_CLIP, iAnim, 1.6); - - if (iResult) - { - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, iAnim, 0, 0, 0); - } -} - - -void CNailgun::WeaponIdle(void) -{ - ResetEmptySound(); - - m_pPlayer->GetAutoaimVector(AUTOAIM_5DEGREES); - - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) - return; - - int iAnim; - switch (RANDOM_LONG(0, 1)) - { - case 0: - iAnim = (m_iClip == 0) ? NAILGUN_LONGIDLE_EMPTY : NAILGUN_LONGIDLE; - break; - - default: - case 1: - iAnim = (m_iClip == 0) ? NAILGUN_IDLE1_EMPTY : NAILGUN_IDLE1; - break; - } - - SendWeaponAnim(iAnim); - - m_flTimeWeaponIdle = UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); // how long till we do this again. -} - - - -class CNailAmmoClip : public CBasePlayerAmmo -{ - void Spawn(void) - { - Precache(); - SET_MODEL(ENT(pev), "models/w_nailclip.mdl"); - CBasePlayerAmmo::Spawn(); - } - void Precache(void) - { - PRECACHE_MODEL("models/w_nailclip.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); - } - BOOL AddAmmo(CBaseEntity *pOther) - { - int bResult = (pOther->GiveAmmo(AMMO_NAILCLIP_GIVE, "nails", NAILS_MAX_CARRY) != -1); - if (bResult) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); - } - return bResult; - } -}; -LINK_ENTITY_TO_CLASS(ammo_nailclip, CNailAmmoClip); - - -class CNailAmmoRound : public CBasePlayerAmmo -{ - void Spawn(void) - { - Precache(); - SET_MODEL(ENT(pev), "models/w_nailround.mdl"); - CBasePlayerAmmo::Spawn(); - } - void Precache(void) - { - PRECACHE_MODEL("models/w_nailround.mdl"); - PRECACHE_SOUND("items/9mmclip1.wav"); - } - BOOL AddAmmo(CBaseEntity *pOther) - { - int bResult = (pOther->GiveAmmo(AMMO_NAILROUND_GIVE, "nails", NAILS_MAX_CARRY) != -1); - if (bResult) - { - EMIT_SOUND(ENT(pev), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM); - } - return bResult; - } -}; -LINK_ENTITY_TO_CLASS(ammo_nailround, CNailAmmoRound); diff --git a/dlls/poke646/pipebomb.cpp b/dlls/poke646/pipebomb.cpp deleted file mode 100644 index 2a723ff4..00000000 --- a/dlls/poke646/pipebomb.cpp +++ /dev/null @@ -1,227 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "gamerules.h" -#include "pipebomb.h" - -LINK_ENTITY_TO_CLASS(monster_pipebomb, CPipeBombGrenade); - - -TYPEDESCRIPTION CPipeBombGrenade::m_SaveData[] = -{ - DEFINE_FIELD(CPipeBombGrenade, m_hOwner, FIELD_EHANDLE), - DEFINE_FIELD(CPipeBombGrenade, m_thrownByPlayer, FIELD_INTEGER), -}; - -IMPLEMENT_SAVERESTORE(CPipeBombGrenade, CGrenade); - -//========================================================= -// Deactivate - do whatever it is we do to an orphaned -// satchel when we don't want it in the world anymore. -//========================================================= -void CPipeBombGrenade::Deactivate(void) -{ - pev->solid = SOLID_NOT; - UTIL_Remove(this); -} - - -void CPipeBombGrenade::Spawn(void) -{ - Precache(); - // motor - pev->movetype = MOVETYPE_BOUNCE; - pev->solid = SOLID_BBOX; - - SET_MODEL(ENT(pev), "models/w_pipebomb.mdl"); - //UTIL_SetSize(pev, Vector( -16, -16, -4), Vector(16, 16, 32)); // Old box -- size of headcrab monsters/players get blocked by this - UTIL_SetSize(pev, Vector(-4, -4, -4), Vector(4, 4, 4)); // Uses point-sized, and can be stepped over - UTIL_SetOrigin(pev, pev->origin); - - SetTouch(&CPipeBombGrenade::BombSlide); - SetUse(&CPipeBombGrenade::DetonateUse); - SetThink(&CPipeBombGrenade::BombThink); - pev->nextthink = gpGlobals->time + 0.1; - - pev->gravity = 0.5; - pev->friction = 0.8; - - pev->dmg = gSkillData.plrDmgSatchel; - // ResetSequenceInfo( ); - pev->sequence = 1; -} - - -void CPipeBombGrenade::BombSlide(CBaseEntity *pOther) -{ - entvars_t *pevOther = pOther->pev; - - // don't hit the guy that launched this grenade - if (pOther->edict() == pev->owner) - return; - - // pev->avelocity = Vector (300, 300, 300); - pev->gravity = 1;// normal gravity now - - // HACKHACK - On ground isn't always set, so look for ground underneath - TraceResult tr; - UTIL_TraceLine(pev->origin, pev->origin - Vector(0, 0, 10), ignore_monsters, edict(), &tr); - - if (tr.flFraction < 1.0) - { - // add a bit of static friction - pev->velocity = pev->velocity * 0.95; - pev->avelocity = pev->avelocity * 0.9; - // play sliding sound, volume based on velocity - } - if (!(pev->flags & FL_ONGROUND) && pev->velocity.Length2D() > 10) - { - BounceSound(); - } - StudioFrameAdvance(); -} - - -void CPipeBombGrenade::BombThink(void) -{ - StudioFrameAdvance(); - pev->nextthink = gpGlobals->time + 0.1; - - if (!IsInWorld()) - { - UTIL_Remove(this); - return; - } - - if (pev->waterlevel == 3) - { - pev->movetype = MOVETYPE_FLY; - pev->velocity = pev->velocity * 0.8; - pev->avelocity = pev->avelocity * 0.9; - pev->velocity.z += 8; - } - else if (pev->waterlevel == 0) - { - pev->movetype = MOVETYPE_BOUNCE; - } - else - { - pev->velocity.z -= 8; - } - if ((pev->flags & FL_ONGROUND) && pev->velocity.Length() <= 1) - { - if (pev->owner != NULL) - { - m_hOwner = CBaseEntity::Instance(pev->owner); - pev->owner = NULL; - } - - SetThink(NULL); - SetTouch(&CPipeBombGrenade::PickupTouch); - } -} - -void CPipeBombGrenade::Precache(void) -{ - PRECACHE_MODEL("models/w_pipebomb.mdl"); - PRECACHE_SOUND("weapons/pb_bounce1.wav"); - PRECACHE_SOUND("weapons/pb_bounce2.wav"); - PRECACHE_SOUND("weapons/pb_bounce3.wav"); -} - -void CPipeBombGrenade::BounceSound(void) -{ - switch (RANDOM_LONG(0, 2)) - { - case 0: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/pb_bounce1.wav", 1, ATTN_NORM); break; - case 1: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/pb_bounce2.wav", 1, ATTN_NORM); break; - case 2: EMIT_SOUND(ENT(pev), CHAN_VOICE, "weapons/pb_bounce3.wav", 1, ATTN_NORM); break; - } -} - -void CPipeBombGrenade::PickupTouch(CBaseEntity* pOther) -{ - if (pOther != m_hOwner || !pOther->IsPlayer()) - return; - - CBasePlayer* pPlayer = (CBasePlayer*)pOther; - - - CPipeBomb *pSatchel = (CPipeBomb*)Create("weapon_pipebomb", pPlayer->pev->origin, pPlayer->pev->angles); - if (pSatchel) - { - BOOL found = FALSE; - CBasePlayerItem* pItem = NULL; - for (int i = 0; i < MAX_ITEM_TYPES && !found; i++) - { - pItem = pPlayer->m_rgpPlayerItems[i]; - - while (pItem) - { - if (pItem->m_iId == WEAPON_PIPEBOMB) - { - ((CPipeBomb*)pItem)->m_chargeReady = 2; - ((CPipeBomb*)pItem)->WeaponIdle(); - found = TRUE; - break; - } - - pItem = pItem->m_pNext; - } - } - } - - SetThink(&CPipeBombGrenade::SUB_Remove); - SetTouch(NULL); - pev->nextthink = gpGlobals->time; - - //ALERT(at_console, "Pickup touch.\n"); -} - -//========================================================= -// DeactivateSatchels - removes all satchels owned by -// the provided player. Should only be used upon death. -// -// Made this global on purpose. -//========================================================= -void DeactivatePipebombs(CBasePlayer *pOwner) -{ - edict_t *pFind; - - pFind = FIND_ENTITY_BY_CLASSNAME(NULL, "monster_pipebomb"); - - while (!FNullEnt(pFind)) - { - CBaseEntity *pEnt = CBaseEntity::Instance(pFind); - CPipeBombGrenade *pPipebomb = (CPipeBombGrenade *)pEnt; - - if (pPipebomb) - { - if (pPipebomb->pev->owner == pOwner->edict()) - { - pPipebomb->Deactivate(); - } - } - - pFind = FIND_ENTITY_BY_CLASSNAME(pFind, "monster_pipebomb"); - } -} \ No newline at end of file diff --git a/dlls/poke646/robocop.cpp b/dlls/poke646/robocop.cpp index 6d78933c..0b8f438d 100644 --- a/dlls/poke646/robocop.cpp +++ b/dlls/poke646/robocop.cpp @@ -25,10 +25,9 @@ #include "explode.h" #define ROBOCOP_EYE_SPRITE_NAME "sprites/gargeye1.spr" -#define ROBOCOP_EYE_BEAM_NAME "sprites/laserbeam.spr" -#define ROBOCOP_EYE_SPOT_NAME "sprites/glow02.spr" +#define ROBOCOP_EYE_BEAM_NAME "sprites/smoke.spr" +#define ROBOCOP_EYE_SPOT_NAME "sprites/gargeye1.spr" -#define ROBOCOP_MAX_SHOCKWAVE_RADIUS 384 #define ROBOCOP_MAX_MORTAR_RADIUS 256 #define ROBOCOP_MORTAR_CHARGE_TIME 2.0f @@ -40,8 +39,13 @@ #define ROBOCOP_RANGE_ATTACK_DIST 512 #define ROBOCOP_MAX_CHASE_DIST 1024 -#define ROBOCOP_DEATH_DURATION 10.0f +#define ROBOCOP_DEATH_DURATION 2.1f +#define ROBOCOP_GIB_MODEL "models/metalplategibs.mdl" +// Robocop is immune to any damage but this +#define ROBOCOP_DAMAGE (DMG_ENERGYBEAM|DMG_CRUSH|DMG_MORTAR|DMG_BLAST) + +void SpawnExplosion( Vector center, float randomRange, float time, int magnitude ); // AI Nodes for RoboCop class CInfoRCNode : public CPointEntity @@ -197,7 +201,10 @@ public: void ScheduleChange(void); BOOL ShouldGibMonster(int iGib) { return FALSE; } void Killed(entvars_t *pevAttacker, int iGib); + void UpdateOnRemove(); + void TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ); + int TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ); Schedule_t *GetSchedule(void); Schedule_t *GetScheduleOfType(int Type); void StartTask(Task_t *pTask); @@ -241,7 +248,7 @@ public: void SetupNodes(float flRadius); int m_iSpriteTexture; - + int m_iRobocopGibModel; CSprite* m_pEyeGlow; // Glow around the eyes int m_eyeBrightness; // Brightness target @@ -263,8 +270,6 @@ public: int m_lastsector; float m_flNextSparkTime; - - static const char* pSparkSounds[]; }; void CreateRoboCopNodes(CRoboCop* pOwner); @@ -296,16 +301,6 @@ TYPEDESCRIPTION CRoboCop::m_SaveData[] = IMPLEMENT_SAVERESTORE(CRoboCop, CBaseMonster); -const char* CRoboCop::pSparkSounds[] = -{ - "buttons/spark1.wav", - "buttons/spark2.wav", - "buttons/spark3.wav", - "buttons/spark4.wav", - "buttons/spark5.wav", - "buttons/spark6.wav", -}; - //========================================================= // AI Schedules Specific to this monster //========================================================= @@ -399,13 +394,16 @@ void CRoboCop::SetYawSpeed(void) { int ys; - ys = 120; - -#if 0 - switch (m_Activity) + switch( m_Activity ) { + case ACT_TURN_LEFT: + case ACT_TURN_RIGHT: + ys = 180; + break; + default: + ys = 90; + break; } -#endif pev->yaw_speed = ys; } @@ -420,11 +418,8 @@ void CRoboCop::HandleAnimEvent(MonsterEvent_t *pEvent) { case ROBOCOP_AE_RIGHT_FOOT: case ROBOCOP_AE_LEFT_FOOT: - switch (RANDOM_LONG(0, 1)) - { - case 0: EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "robocop/rc_step1.wav", 1, ATTN_NORM, 0, 70); break; - case 1: EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, "robocop/rc_step2.wav", 1, ATTN_NORM, 0, 70); break; - } + UTIL_ScreenShake( pev->origin, 4.0, 3.0, 1.0, 250.0 ); + EMIT_SOUND_DYN( ENT( pev ), CHAN_BODY, RANDOM_LONG( 0, 1 ) ? "robocop/rc_step2.wav" : "robocop/rc_step1.wav", 1, ATTN_NORM, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); break; case ROBOCOP_AE_FIST: @@ -490,14 +485,16 @@ void CRoboCop::Precache() PRECACHE_SOUND("robocop/rc_laser.wav"); PRECACHE_SOUND("robocop/rc_step1.wav"); PRECACHE_SOUND("robocop/rc_step2.wav"); - - PRECACHE_SOUND_ARRAY(pSparkSounds); + PRECACHE_SOUND("ambience/sparks.wav"); PRECACHE_MODEL(ROBOCOP_EYE_SPRITE_NAME); PRECACHE_MODEL(ROBOCOP_EYE_BEAM_NAME); - PRECACHE_MODEL(ROBOCOP_EYE_SPOT_NAME); + // PRECACHE_MODEL(ROBOCOP_EYE_SPOT_NAME); - m_iSpriteTexture = PRECACHE_MODEL("sprites/shockwave.spr"); + m_iSpriteTexture = PRECACHE_MODEL("sprites/xbeam3.spr"); + m_iRobocopGibModel = PRECACHE_MODEL( ROBOCOP_GIB_MODEL ); + + UTIL_PrecacheOther( "monster_mortar" ); } //========================================================= @@ -513,6 +510,37 @@ void CRoboCop::MonsterThink(void) m_flGroundSpeed = 200; } +void CRoboCop::TraceAttack( entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType ) +{ + bitsDamageType &= ROBOCOP_DAMAGE; + + if( IsAlive() && !FBitSet( bitsDamageType, ROBOCOP_DAMAGE ) ) + { + if( pev->dmgtime != gpGlobals->time || (RANDOM_LONG( 0, 100 ) < 20 ) ) + { + UTIL_Ricochet( ptr->vecEndPos, RANDOM_FLOAT( 0.5, 1.5 ) ); + pev->dmgtime = gpGlobals->time; + } + + flDamage = 0; + } + + CBaseMonster::TraceAttack( pevAttacker, flDamage, vecDir, ptr, bitsDamageType ); +} + +int CRoboCop::TakeDamage( entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType ) +{ + if( IsAlive() ) + { + if( !FBitSet( bitsDamageType, ROBOCOP_DAMAGE ) ) + flDamage *= 0.01; + if( bitsDamageType & DMG_BLAST ) + SetConditions( bits_COND_LIGHT_DAMAGE ); + } + + return CBaseMonster::TakeDamage( pevInflictor, pevAttacker, flDamage, bitsDamageType ); +} + //========================================================= // FCanCheckAttacks - this is overridden for alien grunts // because they can use their smart weapons against unseen @@ -536,7 +564,7 @@ BOOL CRoboCop::FCanCheckAttacks(void) //========================================================= BOOL CRoboCop::CheckMeleeAttack1(float flDot, float flDist) { - if (flDist <= ROBOCOP_MELEE_ATTACK_DIST) + if( flDot >= 0.8f && flDist < gSkillData.robocopSWRadius ) { return TRUE; } @@ -553,7 +581,7 @@ BOOL CRoboCop::CheckRangeAttack1(float flDot, float flDist) if (m_flNextMortarAttack > gpGlobals->time) return FALSE; - if (flDist > ROBOCOP_MELEE_ATTACK_DIST && flDist < ROBOCOP_RANGE_ATTACK_DIST && !HasConditions(bits_COND_CAN_MELEE_ATTACK1)) + if (flDot >= 0.8f && flDist > gSkillData.robocopSWRadius && flDist < 4096.0f && !HasConditions(bits_COND_CAN_MELEE_ATTACK1)) { return TRUE; } @@ -586,7 +614,19 @@ void CRoboCop::Killed(entvars_t *pevAttacker, int iGib) CBaseMonster::Killed(pevAttacker, GIB_NEVER); } +void CRoboCop::UpdateOnRemove() +{ + CBaseEntity::UpdateOnRemove(); + EyeOff(); + DestroyEffects(); + + if (m_pTemp) + { + UTIL_Remove(m_pTemp); + m_pTemp = NULL; + } +} void CRoboCop::PrescheduleThink(void) { CBaseMonster::PrescheduleThink(); @@ -753,11 +793,11 @@ void CRoboCop::StartTask(Task_t *pTask) case TASK_DIE: m_flWaitFinished = gpGlobals->time + ROBOCOP_DEATH_DURATION; - m_flNextSparkTime = gpGlobals->time + RANDOM_FLOAT(0, 0.5f); + m_flNextSparkTime = gpGlobals->time + 0.3f; + pev->renderamt = 19; pev->renderfx = kRenderFxGlowShell; - pev->rendercolor = Vector(64, 64, 255); - CBaseMonster::StartTask(pTask); - break; + pev->rendercolor = Vector(67, 85, 255); + pev->health = 0; default: CBaseMonster::StartTask(pTask); break; @@ -868,57 +908,60 @@ void CRoboCop::RunTask(Task_t *pTask) case TASK_DIE: if (m_flWaitFinished > gpGlobals->time) { - if (gpGlobals->time > m_flNextSparkTime) + if( pev->frame >= 255.0f ) { - float flRemainingWaitTime = m_flWaitFinished - gpGlobals->time; - float flRemainingProp = flRemainingWaitTime / ROBOCOP_DEATH_DURATION; + EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "common/null.wav", 1.0, ATTN_NORM, 0, 100); + MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_BREAKMODEL ); - if (flRemainingProp < 0) - flRemainingProp = 0; + // position + WRITE_COORD( pev->origin.x ); + WRITE_COORD( pev->origin.y ); + WRITE_COORD( pev->origin.z ); - Vector vSparkPos = pev->origin; - Vector forward, right, up; + // size + WRITE_COORD( 200 ); + WRITE_COORD( 200 ); + WRITE_COORD( 128 ); - Vector angles = pev->angles; - angles.x = 0; + // velocity + WRITE_COORD( 0 ); + WRITE_COORD( 0 ); + WRITE_COORD( 0 ); - UTIL_MakeVectors(angles); + // randomization + WRITE_BYTE( 200 ); - forward = gpGlobals->v_forward; - right = gpGlobals->v_right; - up = gpGlobals->v_up; + // Model + WRITE_SHORT( m_iRobocopGibModel ); //model id# - float halfHeight = pev->view_ofs.z * 0.5f; - float halfWidth = 32; + // # of shards + WRITE_BYTE( 20 ); - float flMinHeight = 4; - float flMaxHeight = flMinHeight + flRemainingProp * pev->view_ofs.z; + // duration + WRITE_BYTE( 20 );// 3.0 seconds - float flCenterZ = (flMinHeight + flMaxHeight) / 2; + // flags + WRITE_BYTE( BREAK_FLESH ); + MESSAGE_END(); - vSparkPos = vSparkPos + forward * ((1 - flRemainingProp) * 180); - vSparkPos = vSparkPos + right * halfWidth * (RANDOM_LONG(-1, 1) + RANDOM_FLOAT(0, 1)); - vSparkPos = vSparkPos + up * (flCenterZ + RANDOM_LONG(-1, 1) * RANDOM_FLOAT(0, 1)); + SpawnExplosion( pev->origin, 70, 0, 150 ); - UTIL_Sparks(vSparkPos); + int trailCount = RANDOM_LONG( 2, 4 ); + for( int i = 0; i < trailCount; i++ ) + Create( "fire_trail", pev->origin, Vector( 0, 0, 1 ), NULL ); - EMIT_SOUND_DYN(ENT(pev), CHAN_BODY, RANDOM_SOUND_ARRAY(pSparkSounds), 1.0, 0.6, 0, RANDOM_LONG(95, 105)); - - m_flNextSparkTime = gpGlobals->time + RANDOM_FLOAT(0.3f, 0.5f); + SetBodygroup( 0, 1 ); + return; } } - else + if (gpGlobals->time > m_flNextSparkTime) { - pev->renderfx = kRenderFxNone; - pev->rendercolor.x = - pev->rendercolor.y = - pev->rendercolor.z = 255; - - m_flNextSparkTime = 0; - - CBaseMonster::RunTask(pTask); + Create( "spark_shower", pev->origin, Vector( 0, 0, 1 ), NULL ); + EMIT_SOUND_DYN(ENT(pev), CHAN_VOICE, "ambience/sparks.wav", 1.0, ATTN_NORM, 0, 100); + m_flNextSparkTime = gpGlobals->time + 0.3f; + return; } - break; default: CBaseMonster::RunTask(pTask); break; @@ -933,58 +976,56 @@ void CRoboCop::SonicAttack(void) { float flAdjustedDamage; float flDist; + Vector vecDist; + int i, r, g, b; - EMIT_SOUND(ENT(pev), CHAN_WEAPON, "robocop/rc_fist.wav", 1, ATTN_NORM); + UTIL_MakeVectors( pev->angles ); + Vector vecSrc = pev->origin + 12 * gpGlobals->v_right + 95 * gpGlobals->v_forward; - // blast circles - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_BEAMCYLINDER); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 16); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 16 + ROBOCOP_MAX_SHOCKWAVE_RADIUS / .2); // reach damage radius over .3 seconds - WRITE_SHORT(m_iSpriteTexture); - WRITE_BYTE(0); // startframe - WRITE_BYTE(0); // framerate - WRITE_BYTE(2); // life - WRITE_BYTE(16); // width - WRITE_BYTE(0); // noise - WRITE_BYTE(62); // r - WRITE_BYTE(33); // g - WRITE_BYTE(211); // b - WRITE_BYTE(255); //brightness - WRITE_BYTE(0); // speed - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_BEAMCYLINDER); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 16); - WRITE_COORD(pev->origin.x); - WRITE_COORD(pev->origin.y); - WRITE_COORD(pev->origin.z + 16 + (ROBOCOP_MAX_SHOCKWAVE_RADIUS / 2) / .2); // reach damage radius over .3 seconds - WRITE_SHORT(m_iSpriteTexture); - WRITE_BYTE(0); // startframe - WRITE_BYTE(0); // framerate - WRITE_BYTE(2); // life - WRITE_BYTE(16); // width - WRITE_BYTE(0); // noise - WRITE_BYTE(62); // r - WRITE_BYTE(33); // g - WRITE_BYTE(211); // b - WRITE_BYTE(255); //brightness - WRITE_BYTE(0); // speed - MESSAGE_END(); + for( i = 0; i < 3; i++ ) + { + switch( i ) + { + case 0: + r = 101, g = 133, b = 221; + break; + case 1: + r = 67, g = 85, b = 255; + break; + case 2: + r = 62, g = 33, b = 211; + break; + } + + // blast circles + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_BEAMCYLINDER ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z + 16 ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z + gSkillData.robocopSWRadius / ( ( i + 1 ) * .2 ) ); // reach damage radius over .3 seconds + WRITE_SHORT( m_iSpriteTexture ); + WRITE_BYTE( 0 ); // startframe + WRITE_BYTE( 10 ); // framerate + WRITE_BYTE( i + 2 ); // life + WRITE_BYTE( 32 ); // width + WRITE_BYTE( 0 ); // noise + WRITE_BYTE( r ); // r + WRITE_BYTE( g ); // g + WRITE_BYTE( b ); // b + WRITE_BYTE( 255 ); //brightness + WRITE_BYTE( 0 ); // speed + MESSAGE_END(); + } // Shake the screen. UTIL_ScreenShake(pev->origin, 12.0, 100.0, 2.0, 1000); CBaseEntity *pEntity = NULL; // iterate on all entities in the vicinity. - while ((pEntity = UTIL_FindEntityInSphere(pEntity, pev->origin, ROBOCOP_MAX_SHOCKWAVE_RADIUS)) != NULL) + while ((pEntity = UTIL_FindEntityInSphere(pEntity, pev->origin, gSkillData.robocopSWRadius)) != NULL) { if ( pEntity->pev->takedamage != DAMAGE_NO ) { @@ -995,12 +1036,10 @@ void CRoboCop::SonicAttack(void) // This means that you must get out of the houndeye's attack range entirely to avoid damage. // Calculate full damage first - // solo - flAdjustedDamage = gSkillData.robocopDmgFist; + vecDist = pEntity->Center() - vecSrc; + flDist = Q_max( 0, gSkillData.robocopSWRadius - vecDist.Length() ); - flDist = (pEntity->Center() - pev->origin).Length(); - - flAdjustedDamage -= (flDist / ROBOCOP_MAX_SHOCKWAVE_RADIUS) * flAdjustedDamage; + flDist = flDist / gSkillData.robocopSWRadius; if (!FVisible(pEntity)) { @@ -1009,24 +1048,35 @@ void CRoboCop::SonicAttack(void) // if this entity is a client, and is not in full view, inflict half damage. We do this so that players still // take the residual damage if they don't totally leave the houndeye's effective radius. We restrict it to clients // so that monsters in other parts of the level don't take the damage and get pissed. - flAdjustedDamage *= 0.5; + flDist *= 0.5; } else if (!FClassnameIs(pEntity->pev, "func_breakable") && !FClassnameIs(pEntity->pev, "func_pushable")) { // do not hurt nonclients through walls, but allow damage to be done to breakables - flAdjustedDamage = 0; + flDist = 0; } } + flAdjustedDamage = gSkillData.robocopDmgFist * flDist; //ALERT ( at_aiconsole, "Damage: %f\n", flAdjustedDamage ); if (flAdjustedDamage > 0) { - pEntity->TakeDamage(pev, pev, flAdjustedDamage, DMG_SONIC | DMG_ALWAYSGIB); + pEntity->TakeDamage(pev, pev, flAdjustedDamage, DMG_SONIC); + } + if( pEntity->IsPlayer() ) + { + vecDist = vecDist.Normalize(); + vecDist.x = vecDist.x * flDist * 600.0f; + vecDist.y = vecDist.y * flDist * 600.0f; + vecDist.z = flDist * 450.0f; + pEntity->pev->velocity = vecDist + pEntity->pev->velocity; + pEntity->pev->punchangle.x = 5; } } } } + EMIT_SOUND_DYN( edict(), CHAN_WEAPON, "robocop/rc_fist.wav", 1.0, ATTN_NORM, 0, PITCH_NORM + RANDOM_LONG( -10, 10 ) ); } @@ -1035,110 +1085,9 @@ void CRoboCop::SonicAttack(void) //========================================================= void CRoboCop::MortarAttack(Vector vecSrc) { - float flAdjustedDamage; - float flDist; - - - // blast circles - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, vecSrc); - WRITE_BYTE(TE_BEAMCYLINDER); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z + 16); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z + 16 + ROBOCOP_MAX_MORTAR_RADIUS / .2); // reach damage radius over .3 seconds - WRITE_SHORT(m_iSpriteTexture); - WRITE_BYTE(0); // startframe - WRITE_BYTE(0); // framerate - WRITE_BYTE(2); // life - WRITE_BYTE(12); // width // 16 - WRITE_BYTE(0); // noise - WRITE_BYTE(255); // r - WRITE_BYTE(128); // g - WRITE_BYTE(64); // b - WRITE_BYTE(255); //brightness - WRITE_BYTE(0); // speed - MESSAGE_END(); - - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_BEAMCYLINDER); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z + 16); - WRITE_COORD(vecSrc.x); - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z + 16 + (ROBOCOP_MAX_MORTAR_RADIUS / 2) / .2); // reach damage radius over .3 seconds - WRITE_SHORT(m_iSpriteTexture); - WRITE_BYTE(0); // startframe - WRITE_BYTE(0); // framerate - WRITE_BYTE(2); // life - WRITE_BYTE(12); // width // 16 - WRITE_BYTE(0); // noise - WRITE_BYTE(255); // r - WRITE_BYTE(128); // g - WRITE_BYTE(64); // b - WRITE_BYTE(255); //brightness - WRITE_BYTE(0); // speed - MESSAGE_END(); - - // Explosion - MESSAGE_BEGIN(MSG_PAS, SVC_TEMPENTITY, vecSrc); - WRITE_BYTE( TE_EXPLOSION ); // This makes a dynamic light and the explosion sprites/sound - WRITE_COORD(vecSrc.x); // Send to PAS because of the sound - WRITE_COORD(vecSrc.y); - WRITE_COORD(vecSrc.z); - WRITE_SHORT( g_sModelIndexFireball ); - WRITE_BYTE( 50 ); // scale * 10 - WRITE_BYTE( 15 ); // framerate - WRITE_BYTE(TE_EXPLFLAG_NONE | TE_EXPLFLAG_NODLIGHTS); - MESSAGE_END(); - - CBaseEntity *pEntity = NULL; - // iterate on all entities in the vicinity. - while ((pEntity = UTIL_FindEntityInSphere(pEntity, vecSrc, ROBOCOP_MAX_MORTAR_RADIUS)) != NULL) - { - if (pEntity->pev->takedamage != DAMAGE_NO) - { - // Robocop does not take damage from it's own attacks. - if (pEntity != this) - { - // houndeyes do FULL damage if the ent in question is visible. Half damage otherwise. - // This means that you must get out of the houndeye's attack range entirely to avoid damage. - // Calculate full damage first - - // solo - flAdjustedDamage = 20;// gSkillData.robocopDmgMortar; - - flDist = (pEntity->Center() - vecSrc).Length(); - - flAdjustedDamage -= (flDist / ROBOCOP_MAX_MORTAR_RADIUS) * flAdjustedDamage; - - if (!FVisible(pEntity)) - { - if (pEntity->IsPlayer()) - { - // if this entity is a client, and is not in full view, inflict half damage. We do this so that players still - // take the residual damage if they don't totally leave the houndeye's effective radius. We restrict it to clients - // so that monsters in other parts of the level don't take the damage and get pissed. - flAdjustedDamage *= 0.5; - } - else if (!FClassnameIs(pEntity->pev, "func_breakable") && !FClassnameIs(pEntity->pev, "func_pushable")) - { - // do not hurt nonclients through walls, but allow damage to be done to breakables - flAdjustedDamage = 0; - } - } - - //ALERT ( at_aiconsole, "Damage: %f\n", flAdjustedDamage ); - - if (flAdjustedDamage > 0) - { - pEntity->TakeDamage(pev, pev, flAdjustedDamage, DMG_SONIC | DMG_ALWAYSGIB); - } - } - } - } + CBaseEntity *pMortar = Create( "monster_mortar", vecSrc, g_vecZero, 0 ); + pMortar->pev->nextthink = gpGlobals->time + 0.1; + pMortar->pev->dmg = gSkillData.robocopDmgMortar; } void CRoboCop::StartMortarAttack(void) @@ -1225,7 +1174,7 @@ BOOL CRoboCop::IsEnemyReachable(CBaseEntity* pEnemy) void CRoboCop::CreateEyeGlow(void) { m_pEyeGlow = CSprite::SpriteCreate(ROBOCOP_EYE_SPRITE_NAME, pev->origin, FALSE); - m_pEyeGlow->SetTransparency(kRenderGlow, 255, 255, 255, 0, kRenderFxNoDissipation); + m_pEyeGlow->SetTransparency(kRenderTransAdd, 255, 255, 255, 0, kRenderFxNoDissipation); m_pEyeGlow->SetAttachment(edict(), 1); m_pEyeGlow->SetScale(0.5f); } @@ -1238,7 +1187,7 @@ void CRoboCop::DestroyEyeGlow(void) void CRoboCop::CreateBeam(void) { - m_pBeam = CBeam::BeamCreate(ROBOCOP_EYE_BEAM_NAME, 20); + m_pBeam = CBeam::BeamCreate(ROBOCOP_EYE_BEAM_NAME, 30); m_pBeam->PointEntInit(pev->origin, entindex()); m_pBeam->SetEndAttachment(1); m_pBeam->SetBrightness(0); @@ -1254,8 +1203,8 @@ void CRoboCop::DestroyBeam(void) void CRoboCop::CreateSpot(void) { m_pBeamSpot = CSprite::SpriteCreate(ROBOCOP_EYE_SPOT_NAME, pev->origin, FALSE); - m_pBeamSpot->SetTransparency(kRenderGlow, 255, 0, 0, 0, kRenderFxNoDissipation); - m_pBeamSpot->SetScale(0.15f); + m_pBeamSpot->SetTransparency(kRenderTransAdd, 255, 255, 255, 0, kRenderFxNoDissipation); + m_pBeamSpot->SetScale(0.30f); } void CRoboCop::DestroySpot(void) @@ -1321,7 +1270,7 @@ void CRoboCop::EyeUpdate(void) if (m_pEyeGlow) { - m_pEyeGlow->pev->renderamt = UTIL_Approach(m_eyeBrightness, m_pEyeGlow->pev->renderamt, 26); + m_pEyeGlow->pev->renderamt = UTIL_Approach(m_eyeBrightness, m_pEyeGlow->pev->renderamt, 30); if (m_pEyeGlow->pev->renderamt == 0) m_pEyeGlow->pev->effects |= EF_NODRAW; else diff --git a/dlls/poke646/weapon_pipebomb.cpp b/dlls/poke646/weapon_pipebomb.cpp deleted file mode 100644 index c621535e..00000000 --- a/dlls/poke646/weapon_pipebomb.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "nodes.h" -#include "player.h" -#include "gamerules.h" -#include "pipebomb.h" - - -enum pipebomb_e { - PIPEBOMB_IDLE1 = 0, - PIPEBOMB_FIDGET1, - PIPEBOMB_DRAW, - PIPEBOMB_DROP -}; - -enum pipebomb_watch_e { - PIPEBOMB_WATCH_IDLE1 = 0, - PIPEBOMB_WATCH_FIDGET1, - PIPEBOMB_WATCH_DRAW, - PIPEBOMB_WATCH_FIRE, - PIPEBOMB_WATCH_HOLSTER -}; - - -LINK_ENTITY_TO_CLASS(weapon_pipebomb, CPipeBomb); - - -//========================================================= -//========================================================= -int CPipeBomb::AddToPlayer(CBasePlayer *pPlayer) -{ - int bResult = CBasePlayerItem::AddToPlayer(pPlayer); - - pPlayer->pev->weapons |= (1 << m_iId); - m_chargeReady = 0;// this satchel charge weapon now forgets that any satchels are deployed by it. - - if (bResult) - { - return AddWeapon(); - } - return FALSE; -} - -void CPipeBomb::Spawn() -{ - Precache(); - m_iId = WEAPON_PIPEBOMB; - SET_MODEL(ENT(pev), "models/w_pipebomb.mdl"); - - m_iDefaultAmmo = PIPEBOMB_DEFAULT_GIVE; - - FallInit();// get ready to fall down. -} - - -void CPipeBomb::Precache(void) -{ - PRECACHE_MODEL("models/v_pipebomb.mdl"); - PRECACHE_MODEL("models/v_pipebomb_watch.mdl"); - PRECACHE_MODEL("models/w_pipebomb.mdl"); - PRECACHE_MODEL("models/p_pipebomb.mdl"); - PRECACHE_MODEL("models/p_pipebomb_watch.mdl"); - - UTIL_PrecacheOther("monster_pipebomb"); - - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); -} - - -int CPipeBomb::GetItemInfo(ItemInfo *p) -{ - p->pszName = STRING(pev->classname); - p->pszAmmo1 = "Pipe Bombs"; - p->iMaxAmmo1 = PIPEBOMB_MAX_CARRY; - p->pszAmmo2 = NULL; - p->iMaxAmmo2 = -1; - p->iMaxClip = WEAPON_NOCLIP; - p->iSlot = 4; - p->iPosition = 0; - p->iFlags = ITEM_FLAG_SELECTONEMPTY | ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE; - p->iId = m_iId = WEAPON_PIPEBOMB; - p->iWeight = PIPEBOMB_WEIGHT; - - return 1; -} - - -BOOL CPipeBomb::Deploy() -{ - - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15); - - if (m_chargeReady) - return DefaultDeploy("models/v_pipebomb_watch.mdl", "models/p_pipebomb_watch.mdl", PIPEBOMB_WATCH_DRAW, "hive"); - else - return DefaultDeploy("models/v_pipebomb.mdl", "models/p_pipebomb.mdl", PIPEBOMB_DRAW, "trip"); - - - return TRUE; -} - - -void CPipeBomb::Holster(int skiplocal /* = 0 */) -{ - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; - - if (m_chargeReady) - { - SendWeaponAnim(PIPEBOMB_WATCH_HOLSTER); - } - else - { - SendWeaponAnim(PIPEBOMB_DROP); - } - - EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "common/null.wav", 1.0, ATTN_NORM); - - if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] && !m_chargeReady) - { - m_pPlayer->pev->weapons &= ~(1 << WEAPON_PIPEBOMB); - SetThink(&CPipeBomb::DestroyItem); - pev->nextthink = gpGlobals->time + 0.1; - } -} - - - -void CPipeBomb::PrimaryAttack() -{ - switch (m_chargeReady) - { - case 0: - { - Throw(); - } - break; - case 1: - { - SendWeaponAnim(PIPEBOMB_WATCH_FIRE); - - edict_t *pPlayer = m_pPlayer->edict(); - - CBaseEntity *pSatchel = NULL; - - while ((pSatchel = UTIL_FindEntityInSphere(pSatchel, m_pPlayer->pev->origin, 4096)) != NULL) - { - if (FClassnameIs(pSatchel->pev, "monster_pipebomb")) - { - if ( pSatchel->pev->owner == pPlayer || pSatchel->m_thrownByPlayer == 1) - { - pSatchel->Use(m_pPlayer, m_pPlayer, USE_ON, 0); - m_chargeReady = 2; - } - } - } - - m_chargeReady = 2; - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.5; - break; - } - - case 2: - // we're reloading, don't allow fire - { - } - break; - } -} - - -void CPipeBomb::SecondaryAttack(void) -{ - if (m_chargeReady != 2) - { - Throw(); - } -} - - -void CPipeBomb::Redraw(void) -{ -#ifndef CLIENT_DLL - m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_pipebomb.mdl"); - m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_pipebomb.mdl"); -#else - LoadVModel("models/v_pipebomb.mdl", m_pPlayer); -#endif - - // SendWeaponAnim(PIPEBOMB_DRAW, 0); - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, PIPEBOMB_DRAW, 0, 0, 0); - - // use tripmine animations - strcpy(m_pPlayer->m_szAnimExtention, "trip"); - - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_chargeReady = 0; -} - -void CPipeBomb::Throw(void) -{ - if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) - { - Vector vecSrc = m_pPlayer->pev->origin; - - Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity; - -#ifndef CLIENT_DLL - CBaseEntity *pSatchel = Create("monster_pipebomb", vecSrc, Vector(0, 0, 0), m_pPlayer->edict()); - pSatchel->pev->velocity = vecThrow; - pSatchel->pev->avelocity.y = 400; - pSatchel->m_thrownByPlayer = 1; - - m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_pipebomb_watch.mdl"); - m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_pipebomb_watch.mdl"); -#else - LoadVModel("models/v_pipebomb_watch.mdl", m_pPlayer); -#endif - - // SendWeaponAnim(PIPEBOMB_WATCH_DRAW); - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, PIPEBOMB_WATCH_DRAW, 0, 0, 0); - - // player "shoot" animation - m_pPlayer->SetAnimation(PLAYER_ATTACK1); - - m_chargeReady = 1; - - m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--; - - m_flNextPrimaryAttack = GetNextAttackDelay(1.0); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - } -} - -BOOL CPipeBomb::ShouldWeaponIdle(void) -{ - return FALSE; -} - -void CPipeBomb::WeaponIdle(void) -{ - if (m_chargeReady == 2) - { - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() - 0.1; - } - - if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase()) - return; - - switch (m_chargeReady) - { - case 0: - SendWeaponAnim(PIPEBOMB_FIDGET1); - // use tripmine animations - strcpy(m_pPlayer->m_szAnimExtention, "trip"); - break; - case 1: - SendWeaponAnim(PIPEBOMB_WATCH_FIDGET1); - // use hivehand animations - strcpy(m_pPlayer->m_szAnimExtention, "hive"); - break; - case 2: - if (!m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]) - { - m_chargeReady = 0; - RetireWeapon(); - return; - } - -#ifndef CLIENT_DLL - m_pPlayer->pev->viewmodel = MAKE_STRING("models/v_pipebomb.mdl"); - m_pPlayer->pev->weaponmodel = MAKE_STRING("models/p_pipebomb.mdl"); -#else - LoadVModel("models/v_pipebomb.mdl", m_pPlayer); -#endif - - // SendWeaponAnim(PIPEBOMB_DRAW, 0); - PLAYBACK_EVENT_FULL(0, m_pPlayer->edict(), m_usReload, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, PIPEBOMB_DRAW, 0, 0, 0); - - // use tripmine animations - strcpy(m_pPlayer->m_szAnimExtention, "trip"); - - m_flNextPrimaryAttack = GetNextAttackDelay(0.5); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; - m_chargeReady = 0; - break; - } - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 10, 15);// how long till we do this again. -} \ No newline at end of file diff --git a/dlls/poke646/xenspit.cpp b/dlls/poke646/xenspit.cpp deleted file mode 100644 index 160796e4..00000000 --- a/dlls/poke646/xenspit.cpp +++ /dev/null @@ -1,351 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - - -#include "extdll.h" -#include "util.h" -#include "cbase.h" -#include "monsters.h" -#include "weapons.h" -#include "schedule.h" -#include "nodes.h" -#include "effects.h" -#include "decals.h" -#include "soundent.h" -#include "game.h" -#include "xenspit.h" - -LINK_ENTITY_TO_CLASS(xensmallspit, CXenSmallSpit); - -TYPEDESCRIPTION CXenSmallSpit::m_SaveData[] = -{ - DEFINE_FIELD(CXenSmallSpit, m_iTrail, FIELD_INTEGER), - DEFINE_FIELD(CXenSmallSpit, m_flCycle, FIELD_FLOAT), - DEFINE_FIELD(CXenSmallSpit, m_pBeam, FIELD_CLASSPTR), - DEFINE_FIELD(CXenSmallSpit, m_vecOldVelocity, FIELD_VECTOR), -}; - -IMPLEMENT_SAVERESTORE(CXenSmallSpit, CBaseEntity); - -void CXenSmallSpit::Spawn(void) -{ - Precache(); - - pev->movetype = MOVETYPE_FLY; - pev->classname = MAKE_STRING("xensmallspit"); - - pev->solid = SOLID_BBOX; - pev->rendermode = kRenderTransAdd; - pev->renderamt = 255; - - SET_MODEL(ENT(pev), "sprites/hotglow.spr"); - pev->frame = 0; - pev->scale = 0.5; - pev->gravity = 0; - pev->dmg = gSkillData.plrDmgGauss; - - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); - - // trail - MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY ); - WRITE_BYTE( TE_BEAMFOLLOW ); - WRITE_SHORT( entindex() ); // entity - WRITE_SHORT( m_iTrail ); // model - WRITE_BYTE( 10 ); // life - WRITE_BYTE( 4 ); // width - WRITE_BYTE( 161 ); // r, g, b - WRITE_BYTE( 188 ); // r, g, b - WRITE_BYTE( 0 ); // r, g, b - WRITE_BYTE( 128 ); // brightness - - MESSAGE_END(); - - m_pBeam = NULL; - m_pParent = NULL; -} - -void CXenSmallSpit::Precache() -{ - PRECACHE_MODEL("sprites/hotglow.spr"); - - m_iTrail = PRECACHE_MODEL("sprites/laserbeam.spr"); - - PRECACHE_MODEL("sprites/laserbeam.spr"); -} - -CXenSmallSpit* CXenSmallSpit::ShootStraight(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity) -{ - CXenSmallSpit *pSpit = GetClassPtr((CXenSmallSpit *)NULL); - pSpit->Spawn(); - - UTIL_SetOrigin(pSpit->pev, vecStart); - pSpit->pev->angles = vecAngles; - pSpit->pev->velocity = vecVelocity; - pSpit->pev->owner = ENT(pevOwner); - pSpit->m_vecOldVelocity = vecVelocity; - - pSpit->m_flCycle = 0.0f; - pSpit->m_pParent = NULL; - - pSpit->SetThink(&CXenSmallSpit::StraightThink); - pSpit->pev->nextthink = gpGlobals->time + 0.01; - - return pSpit; -} - -CXenSmallSpit* CXenSmallSpit::ShootCycle(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity, CBaseEntity* pParent, float flCycle) -{ - CXenSmallSpit *pSpit = GetClassPtr((CXenSmallSpit *)NULL); - pSpit->Spawn(); - - UTIL_SetOrigin(pSpit->pev, vecStart); - pSpit->pev->angles = vecAngles; - pSpit->pev->velocity = vecVelocity; - pSpit->pev->owner = ENT(pevOwner); - pSpit->m_vecOldVelocity = vecVelocity; - - pSpit->m_flCycle = flCycle; - pSpit->m_pParent = pParent; - - pSpit->SetThink(&CXenSmallSpit::CycleThink); - pSpit->pev->nextthink = gpGlobals->time + 0.01; - - return pSpit; -} - -void CXenSmallSpit::Touch(CBaseEntity *pOther) -{ - if (m_pParent != NULL) - return; - - if (FClassnameIs(pOther->pev, STRING(pev->classname))) - return; - - // ALERT(at_console, " CXenSmallSpit::Touch START\n"); - - TraceResult tr; - - RadiusDamage(pev->origin, pev, pev, pev->dmg, 80, CLASS_NONE, DMG_POISON | DMG_ALWAYSGIB); - - if (!pOther->pev->takedamage) - { - // make a splat on the wall - UTIL_TraceLine(pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT(pev), &tr); - UTIL_DecalTrace(&tr, DECAL_SMALLSCORCH1 + RANDOM_LONG(0, 2)); - } - - if (m_pBeam) - { - UTIL_Remove(m_pBeam); - m_pBeam = NULL; - } - - // light. - MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_DLIGHT); - WRITE_COORD(pev->origin.x); // X - WRITE_COORD(pev->origin.y); // Y - WRITE_COORD(pev->origin.z); // Z - WRITE_BYTE(8); // radius * 0.1 - WRITE_BYTE(161); // r - WRITE_BYTE(188); // g - WRITE_BYTE(0); // b - WRITE_BYTE(10); // time * 10 - WRITE_BYTE(2); // decay * 0.1 - MESSAGE_END(); - - m_pParent = NULL; - - SetThink(&CXenSmallSpit::SUB_Remove); - SetTouch(NULL); - pev->nextthink = gpGlobals->time; - - // ALERT(at_console, " CXenSmallSpit::Touch END\n"); -} - -void CXenSmallSpit::StraightThink(void) -{ - pev->nextthink = gpGlobals->time + 0.01f; - - m_flCycle += 0.02f; - - if (m_flCycle >= 1) - m_flCycle = 0; - - pev->velocity.z = m_vecOldVelocity.z + sin(m_flCycle * 2 * M_PI) * 16; -} - -void CXenSmallSpit::CycleThink(void) -{ - pev->nextthink = gpGlobals->time + 0.01f; - - m_flCycle += 0.02f; - - if (m_flCycle >= 1) - m_flCycle = 0; -} - - - - - -LINK_ENTITY_TO_CLASS(xenlargespit, CXenLargeSpit); - -TYPEDESCRIPTION CXenLargeSpit::m_SaveData[] = -{ - DEFINE_FIELD(CXenLargeSpit, m_iChildCount, FIELD_INTEGER), - DEFINE_ARRAY(CXenLargeSpit, m_pChildren, FIELD_CLASSPTR, XENSPIT_MAX_PROJECTILES), -}; - -IMPLEMENT_SAVERESTORE(CXenLargeSpit, CBaseEntity); - - -void CXenLargeSpit::Spawn(void) -{ - Precache(); - - pev->movetype = MOVETYPE_FLY; - pev->classname = MAKE_STRING("xenlargespit"); - - pev->solid = SOLID_BBOX; - pev->rendermode = kRenderTransAdd; - pev->renderamt = 255; - - SET_MODEL(ENT(pev), "sprites/glow02.spr"); - pev->frame = 0; - pev->scale = 0.5; - pev->gravity = 0; - pev->dmg = gSkillData.plrDmgGauss; - - pev->renderamt = 0; - - UTIL_SetSize(pev, Vector(0, 0, 0), Vector(0, 0, 0)); - - for (int i = 0; i < XENSPIT_MAX_PROJECTILES; i++) - m_pChildren[i] = NULL; -} - -void CXenLargeSpit::Precache() -{ - PRECACHE_MODEL("sprites/glow02.spr"); -} - -CXenLargeSpit* CXenLargeSpit::Shoot(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity) -{ - CXenLargeSpit *pSpit = GetClassPtr((CXenLargeSpit *)NULL); - pSpit->Spawn(); - - UTIL_SetOrigin(pSpit->pev, vecStart); - pSpit->pev->angles = vecAngles; - pSpit->pev->velocity = vecVelocity; - pSpit->pev->owner = ENT(pevOwner); - - pSpit->SetThink(&CXenLargeSpit::CycleThink); - pSpit->pev->nextthink = gpGlobals->time + 0.01; - - return pSpit; -} - -void CXenLargeSpit::Touch(CBaseEntity *pOther) -{ - // ALERT(at_console, " CXenLargeSpit::Touch START\n"); - - float damage = Q_max(pev->dmg, pev->dmg * m_iChildCount); - - RadiusDamage(pev->origin, pev, pev, damage, 110, CLASS_NONE, DMG_POISON | DMG_ALWAYSGIB); - - TraceResult tr; - - if (!pOther->pev->takedamage) - { - // make a splat on the wall - UTIL_TraceLine(pev->origin, pev->origin + pev->velocity * 10, dont_ignore_monsters, ENT(pev), &tr); - UTIL_DecalTrace(&tr, DECAL_SMALLSCORCH1 + RANDOM_LONG(0, 2)); - } - - for (int i = 0; i < m_iChildCount; i++) - { - if (m_pChildren[i]) - { - UTIL_Remove(m_pChildren[i]); - m_pChildren[i] = NULL; - } - } - - m_iChildCount = 0; - - // light. - MESSAGE_BEGIN(MSG_PVS, SVC_TEMPENTITY, pev->origin); - WRITE_BYTE(TE_DLIGHT); - WRITE_COORD(pev->origin.x); // X - WRITE_COORD(pev->origin.y); // Y - WRITE_COORD(pev->origin.z); // Z - WRITE_BYTE(12); // radius * 0.1 - WRITE_BYTE(161); // r - WRITE_BYTE(188); // g - WRITE_BYTE(0); // b - WRITE_BYTE(10); // time * 10 - WRITE_BYTE(2); // decay * 0.1 - MESSAGE_END(); - - SetThink(&CXenLargeSpit::SUB_Remove); - SetTouch(NULL); - pev->nextthink = gpGlobals->time + 0.1f; - - // ALERT(at_console, " CXenLargeSpit::Touch START\n"); -} - -void CXenLargeSpit::CycleThink(void) -{ - pev->nextthink = gpGlobals->time + 0.1f; - - Vector src, forward, right, up, cross; - - forward = pev->velocity.Normalize(); - - Vector horizontal = Vector(pev->velocity.x, pev->velocity.y, 0).Normalize(); - Vector direction = forward; - - float flDot = DotProduct(direction, horizontal); - if (flDot < 0.5) - cross = Vector(1, 0, 0); - else - cross = Vector(0, 0, 1); - - right = CrossProduct(direction, cross); - up = CrossProduct(right, direction); - - for (int i = 0; i < m_iChildCount; i++) - { - CXenSmallSpit* pSpit = (CXenSmallSpit*)m_pChildren[i]; - if (pSpit) - { - float cs, sn, dist; - cs = cos(pSpit->m_flCycle * 2 * M_PI); - sn = sin(pSpit->m_flCycle * 2 * M_PI); - dist = Q_max(2, 2 * m_iChildCount); - - // ALERT(at_console, "cs: %.2f. sn: %.2f\n", cs, sn); - - Vector target = (right * cs * dist) + (up * sn * dist); - - src = pev->origin + target * -2; - pSpit->pev->origin = src; - pSpit->pev->velocity = pev->velocity; - } - } -} - - diff --git a/dlls/poke646/xenspit.h b/dlls/poke646/xenspit.h deleted file mode 100644 index 06d22ed0..00000000 --- a/dlls/poke646/xenspit.h +++ /dev/null @@ -1,71 +0,0 @@ -/*** -* -* Copyright (c) 1996-2001, Valve LLC. All rights reserved. -* -* This product contains software technology licensed from Id -* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. -* All Rights Reserved. -* -* Use, distribution, and modification of this source code and/or resulting -* object code is restricted to non-commercial enhancements to products from -* Valve LLC. All other use, distribution, or modification is prohibited -* without written permission from Valve LLC. -* -****/ - -#ifndef XENSPIT_H -#define XENSPIT_H - -#ifdef _WIN32 -#pragma once -#endif - -#define XENSPIT_MAX_PROJECTILES 4 - -class CXenLargeSpit : public CBaseEntity -{ -public: - void Spawn(void); - void Precache(void); - - static CXenLargeSpit* Shoot(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity); - void Touch(CBaseEntity *pOther); - void EXPORT CycleThink(void); - - virtual int Save(CSave &save); - virtual int Restore(CRestore &restore); - static TYPEDESCRIPTION m_SaveData[]; - - CBaseEntity* m_pChildren[XENSPIT_MAX_PROJECTILES]; - int m_iChildCount; -}; - - -class CXenSmallSpit : public CBaseEntity -{ -public: - void Spawn(void); - void Precache(void); - - static CXenSmallSpit* ShootStraight(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity); - static CXenSmallSpit* ShootCycle(entvars_t *pevOwner, Vector vecStart, Vector vecAngles, Vector vecVelocity, CBaseEntity* pParent, float flCycle = 0.0f); - void Touch(CBaseEntity *pOther); - void EXPORT CycleThink(void); - void EXPORT StraightThink(void); - - virtual int Save(CSave &save); - virtual int Restore(CRestore &restore); - static TYPEDESCRIPTION m_SaveData[]; - - int m_iTrail; - float m_flCycle; - Vector m_vecOldVelocity; - - CBaseEntity* m_pParent; - - CBeam* m_pBeam; -}; - - - -#endif // XENSPIT_H \ No newline at end of file diff --git a/dlls/poke646/xensquasher.cpp b/dlls/poke646/xensquasher.cpp index 3d87a37c..4b051717 100644 --- a/dlls/poke646/xensquasher.cpp +++ b/dlls/poke646/xensquasher.cpp @@ -39,7 +39,7 @@ enum xensquasher_e { XS_FIRE2, XS_HOLSTER, XS_DRAW, - XS_RELOAD, + XS_RELOAD }; LINK_ENTITY_TO_CLASS(weapon_xs, CXenSquasher); @@ -81,18 +81,11 @@ void CXenSquasher::Precache(void) PRECACHE_SOUND("weapons/xs_shot.wav"); PRECACHE_SOUND("weapons/xs_windup.wav"); - m_iGlow = PRECACHE_MODEL("sprites/hotglow.spr"); - m_iBalls = PRECACHE_MODEL("sprites/hotglow.spr"); - m_iBeam = PRECACHE_MODEL("sprites/smoke.spr"); - - m_usXSFire = PRECACHE_EVENT(1, "events/xs.sc"); m_usXSSpin = PRECACHE_EVENT(1, "events/xsspin.sc"); - m_usReload = PRECACHE_EVENT(1, "events/reload.sc"); PRECACHE_MODEL("sprites/glow02.spr"); - UTIL_PrecacheOther("xensmallspit"); - UTIL_PrecacheOther("xenlargespit"); + UTIL_PrecacheOther("xs_beam"); } int CXenSquasher::AddToPlayer(CBasePlayer *pPlayer) diff --git a/dlls/poke646/xsbeam.cpp b/dlls/poke646/xsbeam.cpp new file mode 100644 index 00000000..0a5d2ce8 --- /dev/null +++ b/dlls/poke646/xsbeam.cpp @@ -0,0 +1,213 @@ +/*** +* +* Copyright (c) 1996-2001, Valve LLC. All rights reserved. +* +* This product contains software technology licensed from Id +* Software, Inc. ("Id Technology"). Id Technology (c) 1996 Id Software, Inc. +* All Rights Reserved. +* +* Use, distribution, and modification of this source code and/or resulting +* object code is restricted to non-commercial enhancements to products from +* Valve LLC. All other use, distribution, or modification is prohibited +* without written permission from Valve LLC. +* +****/ + + +#include "extdll.h" +#include "util.h" +#include "cbase.h" +#include "monsters.h" +#include "weapons.h" +#include "schedule.h" +#include "nodes.h" +#include "effects.h" +#include "decals.h" +#include "soundent.h" +#include "game.h" +#include "xsbeam.h" + +LINK_ENTITY_TO_CLASS( xs_beam, CXSBeam ) + +TYPEDESCRIPTION CXSBeam::m_SaveData[] = +{ + DEFINE_FIELD( CXSBeam, m_iTrail, FIELD_INTEGER ), + DEFINE_FIELD( CXSBeam, m_iBeamCount, FIELD_INTEGER ), + DEFINE_FIELD( CXSBeam, m_flDeflectionDist, FIELD_FLOAT ), + DEFINE_FIELD( CXSBeam, m_flDmg, FIELD_FLOAT ), + DEFINE_ARRAY( CXSBeam, m_flDeflectionDot, FIELD_FLOAT, XENSQUASHER_MAX_BEAMS ), + DEFINE_FIELD( CXSBeam, m_vecOldOrigin, FIELD_VECTOR ), + DEFINE_ARRAY( CXSBeam, m_pBeam, FIELD_CLASSPTR, XENSQUASHER_MAX_BEAMS ), +}; + +IMPLEMENT_SAVERESTORE( CXSBeam, CBaseEntity ) + +void CXSBeam::Spawn() +{ + Precache(); + + pev->movetype = MOVETYPE_FLY; + pev->solid = SOLID_BBOX; + pev->gravity = 0.5f; + + SET_MODEL( ENT( pev ), "models/grenade.mdl" ); + + pev->effects |= EF_NODRAW; + + UTIL_SetSize( pev, g_vecZero, g_vecZero ); + + if( m_flDmg >= 150.0f ) + { + m_flDeflectionDist = 22.0f; + } + else if( m_flDmg >= 100.0f ) + { + m_flDeflectionDist = 17.0f; + } + else if( m_flDmg >= 50.0f ) + { + m_flDeflectionDist = 10.0f; + } + else + { + m_flDeflectionDist = 5.0f; + } + + SetTouch( &CXSBeam::BeamTouch ); + SetThink( &CXSBeam::FlyThink ); + pev->nextthink = gpGlobals->time + 0.01f; +} + +void CXSBeam::Precache() +{ + PRECACHE_MODEL( "sprites/hotglow.spr" ); + m_iTrail = PRECACHE_MODEL( "sprites/smoke.spr" ); +} + +CXSBeam* CXSBeam::CXSBeamCreate( float flDamage ) +{ + CXSBeam *pBeam = GetClassPtr( (CXSBeam *)NULL ); + pBeam->pev->classname = MAKE_STRING( "xs_beam" ); + pBeam->m_flDmg = flDamage; + pBeam->m_iBeamCount = Q_min( static_cast( ( flDamage + 50.0f ) * 0.02f ), XENSQUASHER_MAX_BEAMS ); + pBeam->Spawn(); + + return pBeam; +} + +void CXSBeam::Init() +{ + int i; + for( i = 0; i < m_iBeamCount; i++ ) + { + m_pBeam[i] = CSprite::SpriteCreate( "sprites/hotglow.spr", pev->origin, FALSE ); + if( m_pBeam[i] ) + { + m_pBeam[i]->pev->scale = 0.5; + m_pBeam[i]->SetTransparency( kRenderGlow, 255, 255, 255, 255, kRenderFxFadeFast ); + UTIL_SetOrigin( m_pBeam[i]->pev, pev->origin ); + + m_pBeam[i]->pev->spawnflags |= SF_SPRITE_TEMPORARY; + + // rocket trail + MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_BEAMFOLLOW ); + WRITE_SHORT( m_pBeam[i]->entindex() ); // entity + WRITE_SHORT( m_iTrail ); // model + WRITE_BYTE( 5 ); // life + WRITE_BYTE( 4 ); // width + WRITE_BYTE( 192 ); // r + WRITE_BYTE( 224 ); // g + WRITE_BYTE( 0 ); // b + WRITE_BYTE( 192 ); // brightness + MESSAGE_END(); + } + } + + if( m_iBeamCount == 3 ) + { + m_flDeflectionDot[0] = 0.0f; + m_flDeflectionDot[1] = 0.33f; + m_flDeflectionDot[2] = 0.66f; + } + else + { + m_flDeflectionDot[0] = 0.25f; + m_flDeflectionDot[1] = 0.75f; + m_flDeflectionDot[2] = 0.0f; + m_flDeflectionDot[3] = 0.5f; + } +} + +void CXSBeam::BeamTouch( CBaseEntity *pOther ) +{ + SetTouch( NULL ); + SetThink( NULL ); + + TraceResult tr = UTIL_GetGlobalTrace(); + + UTIL_DecalTrace( &tr, DECAL_SMALLSCORCH1 + RANDOM_LONG( 0, 2 ) ); + + float flRadius = m_flDmg * 0.08 + 8; + + MESSAGE_BEGIN( MSG_PVS, SVC_TEMPENTITY, pev->origin ); + WRITE_BYTE( TE_DLIGHT ); + WRITE_COORD( pev->origin.x ); // X + WRITE_COORD( pev->origin.y ); // Y + WRITE_COORD( pev->origin.z ); // Z + WRITE_BYTE( flRadius ); // radius * 0.1 + WRITE_BYTE( 192 ); // r + WRITE_BYTE( 224 ); // g + WRITE_BYTE( 0 ); // b + WRITE_BYTE( flRadius * 2.5f ); // time * 10 + WRITE_BYTE( 4 ); // decay * 0.1 + MESSAGE_END(); + + RadiusDamage( pev->origin, pev, pev, m_flDmg, 10 * flRadius, CLASS_NONE, DMG_POISON | DMG_ALWAYSGIB ); + + for( ; m_iBeamCount > 1; --m_iBeamCount ) + { + UTIL_Remove( m_pBeam[m_iBeamCount - 1] ); + } + + if( FClassnameIs( pOther->pev, "worldspawn" ) ) + { + m_pBeam[0]->pev->origin = tr.vecEndPos; + + float flQuarterRadius = flRadius / 4.0f; + m_pBeam[0]->Expand(0, 255.0f / flQuarterRadius ); + + SetThink( &CXSBeam::RemoveThink ); + pev->nextthink = gpGlobals->time + flQuarterRadius; + } + else + { + UTIL_Remove( m_pBeam[0] ); + Killed( pev, GIB_NEVER ); + } +} + +void CXSBeam::FlyThink() +{ + int i; + float flCenter; + + UTIL_MakeVectors( pev->angles ); + + flCenter = ( pev->origin - m_vecOldOrigin ).Length() * 0.01f; + + for( i = 0; i < m_iBeamCount; i++ ) + { + float flDist = m_flDeflectionDot[i] * 360.0f * ( M_PI / 180.0f ) + flCenter; + Vector vecSin = sin( flDist ) * m_flDeflectionDist * gpGlobals->v_up; + Vector vecCos = cos( flDist ) * m_flDeflectionDist * gpGlobals->v_right; + m_pBeam[i]->pev->origin = pev->origin + vecSin + vecCos; + } + pev->nextthink = gpGlobals->time + 0.05f; +} + +void CXSBeam::RemoveThink() +{ + SetThink( NULL ); + Killed( pev, GIB_NEVER ); +} diff --git a/dlls/poke646/pipebomb.h b/dlls/poke646/xsbeam.h similarity index 50% rename from dlls/poke646/pipebomb.h rename to dlls/poke646/xsbeam.h index 6a16cafd..fc79d7ac 100644 --- a/dlls/poke646/pipebomb.h +++ b/dlls/poke646/xsbeam.h @@ -12,35 +12,34 @@ * without written permission from Valve LLC. * ****/ - -#ifndef PIPEBOMBGRENADE_H -#define PIPEBOMBGRENADE_H - -#ifdef _WIN32 #pragma once -#endif +#ifndef XSBEAM_H +#define XSBEAM_H -class CPipeBombGrenade : public CGrenade +#define XENSQUASHER_MAX_BEAMS 4 + +class CXSBeam : public CBaseEntity { public: + void Spawn(); + void Precache(); - void Spawn(void); - void Precache(void); - void BounceSound(void); + static CXSBeam* CXSBeamCreate( float flDamage ); + void Init(); + void EXPORT BeamTouch(CBaseEntity *pOther); + void EXPORT FlyThink(); + void EXPORT RemoveThink(); - void EXPORT BombSlide(CBaseEntity *pOther); - void EXPORT BombThink(void); - void EXPORT PickupTouch(CBaseEntity* pOther); - - virtual int Save(CSave &save); - virtual int Restore(CRestore &restore); + int Save(CSave &save); + int Restore(CRestore &restore); static TYPEDESCRIPTION m_SaveData[]; - - EHANDLE m_hOwner; - -public: - void Deactivate(void); + int m_iTrail; + int m_iBeamCount; + float m_flDmg; + float m_flDeflectionDist; + float m_flDeflectionDot[XENSQUASHER_MAX_BEAMS]; + Vector m_vecOldOrigin; + CSprite *m_pBeam[XENSQUASHER_MAX_BEAMS]; }; - -#endif // PIPEBOMBGRENADE_H \ No newline at end of file +#endif // XSBEAM_H diff --git a/dlls/satchel.cpp b/dlls/satchel.cpp index dc8724bd..4cc4ad6a 100644 --- a/dlls/satchel.cpp +++ b/dlls/satchel.cpp @@ -47,67 +47,77 @@ enum satchel_radio_e SATCHEL_RADIO_HOLSTER }; -class CSatchelCharge : public CGrenade -{ - Vector m_lastBounceOrigin; // Used to fix a bug in engine: when object isn't moving, but its speed isn't 0 and on ground isn't set - void Spawn( void ); - void Precache( void ); - void BounceSound( void ); - - void EXPORT SatchelSlide( CBaseEntity *pOther ); - void EXPORT SatchelThink( void ); - -public: - void Deactivate( void ); -}; - -LINK_ENTITY_TO_CLASS( monster_satchel, CSatchelCharge ) +LINK_ENTITY_TO_CLASS( monster_satchel, CPipebombCharge ) //========================================================= // Deactivate - do whatever it is we do to an orphaned // satchel when we don't want it in the world anymore. //========================================================= -void CSatchelCharge::Deactivate( void ) +void CPipebombCharge::Deactivate( void ) { pev->solid = SOLID_NOT; UTIL_Remove( this ); } -void CSatchelCharge::Spawn( void ) +void CPipebombCharge::PipebombUse( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) +{ + pev->owner = m_hOwner->edict(); + + SetThink( &CGrenade::Detonate ); + pev->nextthink = gpGlobals->time; +} + +void CPipebombCharge::Spawn( void ) { Precache(); // motor pev->movetype = MOVETYPE_BOUNCE; pev->solid = SOLID_BBOX; - SET_MODEL( ENT( pev ), "models/w_satchel.mdl" ); + SET_MODEL( ENT( pev ), "models/w_pipebomb.mdl" ); //UTIL_SetSize( pev, Vector( -16, -16, -4 ), Vector( 16, 16, 32 ) ); // Old box -- size of headcrab monsters/players get blocked by this UTIL_SetSize( pev, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ) ); // Uses point-sized, and can be stepped over UTIL_SetOrigin( pev, pev->origin ); - SetTouch( &CSatchelCharge::SatchelSlide ); - SetUse( &CGrenade::DetonateUse ); - SetThink( &CSatchelCharge::SatchelThink ); + SetTouch( &CPipebombCharge::PipebombSlide ); + SetUse( &CPipebombCharge::PipebombUse ); + SetThink( &CPipebombCharge::PipebombThink ); pev->nextthink = gpGlobals->time + 0.1; pev->gravity = 0.5; - pev->friction = 0.8; + pev->friction = 0.5; pev->dmg = gSkillData.plrDmgSatchel; // ResetSequenceInfo(); pev->sequence = 1; + m_flDropTime = gpGlobals->time; } -void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) +void CPipebombCharge::PipebombSlide( CBaseEntity *pOther ) { //entvars_t *pevOther = pOther->pev; // don't hit the guy that launched this grenade - if( pOther->edict() == pev->owner ) - return; + if( pOther->edict() == m_hOwner->edict() ) + { + if( pev->velocity.Length2D() < 10.0f + && m_flDropTime + 0.5f <= gpGlobals->time + && pOther->GiveAmmo( SATCHEL_DEFAULT_GIVE, "Satchel Charge", SATCHEL_MAX_CARRY ) != -1 ) + { + CBasePlayer *pPlayer = static_cast( pOther ); + EMIT_SOUND( ENT( pev ), CHAN_ITEM, "items/9mmclip1.wav", 1, ATTN_NORM ); + + UTIL_Remove( this ); + + CPipebomb *pPipebomb = static_cast( pPlayer->GiveNamedPlayerItem( "weapon_pipebomb" ) ); + if( pPipebomb ) + pPipebomb->PipebombReload(); + } + return; + } // pev->avelocity = Vector( 300, 300, 300 ); - pev->gravity = 1;// normal gravity now + pev->gravity = 0.7f;// normal gravity now // HACKHACK - On ground isn't always set, so look for ground underneath TraceResult tr; @@ -116,7 +126,7 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) if( tr.flFraction < 1.0 ) { // add a bit of static friction - pev->velocity = pev->velocity * 0.95; + pev->velocity = pev->velocity * 0.7; pev->avelocity = pev->avelocity * 0.9; // play sliding sound, volume based on velocity } @@ -131,12 +141,15 @@ void CSatchelCharge::SatchelSlide( CBaseEntity *pOther ) // StudioFrameAdvance(); } -void CSatchelCharge::SatchelThink( void ) +void CPipebombCharge::PipebombThink( void ) { // There is no model animation so commented this out to prevent net traffic // StudioFrameAdvance(); pev->nextthink = gpGlobals->time + 0.1; + if( pev->owner && m_flDropTime + 0.5f <= gpGlobals->time ) + pev->owner = 0; + if( !IsInWorld() ) { UTIL_Remove( this ); @@ -160,38 +173,38 @@ void CSatchelCharge::SatchelThink( void ) } } -void CSatchelCharge::Precache( void ) +void CPipebombCharge::Precache( void ) { - PRECACHE_MODEL( "models/w_satchel.mdl" ); - PRECACHE_SOUND( "weapons/g_bounce1.wav" ); - PRECACHE_SOUND( "weapons/g_bounce2.wav" ); - PRECACHE_SOUND( "weapons/g_bounce3.wav" ); + PRECACHE_SOUND( "weapons/pb_bounce1.wav" ); + PRECACHE_SOUND( "weapons/pb_bounce2.wav" ); + PRECACHE_SOUND( "weapons/pb_bounce3.wav" ); + m_iTrail = PRECACHE_MODEL( "sprites/white.spr" ); } -void CSatchelCharge::BounceSound( void ) +void CPipebombCharge::BounceSound( void ) { switch( RANDOM_LONG( 0, 2 ) ) { case 0: - EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce1.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/pb_bounce1.wav", 1, ATTN_NORM ); break; case 1: - EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce2.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/pb_bounce2.wav", 1, ATTN_NORM ); break; case 2: - EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/g_bounce3.wav", 1, ATTN_NORM ); + EMIT_SOUND( ENT( pev ), CHAN_VOICE, "weapons/pb_bounce3.wav", 1, ATTN_NORM ); break; } } -LINK_ENTITY_TO_CLASS( weapon_satchel, CSatchel ) +LINK_ENTITY_TO_CLASS( weapon_pipebomb, CPipebomb ) //========================================================= // CALLED THROUGH the newly-touched weapon's instance. The existing player weapon is pOriginal //========================================================= -int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) +int CPipebomb::AddDuplicate( CBasePlayerItem *pOriginal ) { - CSatchel *pSatchel; + CPipebomb *pPipebomb; #ifdef CLIENT_DLL if( bIsMultiplayer() ) @@ -199,9 +212,9 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) if( g_pGameRules->IsMultiplayer() ) #endif { - pSatchel = (CSatchel *)pOriginal; + pPipebomb = (CPipebomb *)pOriginal; - if( pSatchel->m_chargeReady != SATCHEL_IDLE ) + if( pPipebomb->m_chargeReady != SATCHEL_IDLE ) { // player has some satchels deployed. Refuse to add more. return FALSE; @@ -213,7 +226,7 @@ int CSatchel::AddDuplicate( CBasePlayerItem *pOriginal ) //========================================================= //========================================================= -int CSatchel::AddToPlayer( CBasePlayer *pPlayer ) +int CPipebomb::AddToPlayer( CBasePlayer *pPlayer ) { int bResult = CBasePlayerItem::AddToPlayer( pPlayer ); @@ -227,29 +240,29 @@ int CSatchel::AddToPlayer( CBasePlayer *pPlayer ) return FALSE; } -void CSatchel::Spawn() +void CPipebomb::Spawn() { Precache(); m_iId = WEAPON_SATCHEL; - SET_MODEL( ENT( pev ), "models/w_satchel.mdl" ); + SET_MODEL( ENT( pev ), "models/w_pipebomb.mdl" ); m_iDefaultAmmo = SATCHEL_DEFAULT_GIVE; - + FallInit();// get ready to fall down. } -void CSatchel::Precache( void ) +void CPipebomb::Precache( void ) { - PRECACHE_MODEL( "models/v_satchel.mdl" ); - PRECACHE_MODEL( "models/v_satchel_radio.mdl" ); - PRECACHE_MODEL( "models/w_satchel.mdl" ); - PRECACHE_MODEL( "models/p_satchel.mdl" ); - PRECACHE_MODEL( "models/p_satchel_radio.mdl" ); + PRECACHE_MODEL( "models/v_pipebomb.mdl" ); + PRECACHE_MODEL( "models/v_pipebomb_watch.mdl" ); + PRECACHE_MODEL( "models/w_pipebomb.mdl" ); + PRECACHE_MODEL( "models/p_pipebomb.mdl" ); + PRECACHE_MODEL( "models/p_pipebomb_watch.mdl" ); UTIL_PrecacheOther( "monster_satchel" ); } -int CSatchel::GetItemInfo( ItemInfo *p ) +int CPipebomb::GetItemInfo( ItemInfo *p ) { p->pszName = STRING( pev->classname ); p->pszAmmo1 = "Satchel Charge"; @@ -258,7 +271,7 @@ int CSatchel::GetItemInfo( ItemInfo *p ) p->iMaxAmmo2 = -1; p->iMaxClip = WEAPON_NOCLIP; p->iSlot = 4; - p->iPosition = 1; + p->iPosition = 0; p->iFlags = ITEM_FLAG_SELECTONEMPTY | ITEM_FLAG_LIMITINWORLD | ITEM_FLAG_EXHAUSTIBLE; p->iId = m_iId = WEAPON_SATCHEL; p->iWeight = SATCHEL_WEIGHT; @@ -268,12 +281,12 @@ int CSatchel::GetItemInfo( ItemInfo *p ) //========================================================= //========================================================= -BOOL CSatchel::IsUseable( void ) +BOOL CPipebomb::IsUseable( void ) { return CanDeploy(); } -BOOL CSatchel::CanDeploy( void ) +BOOL CPipebomb::CanDeploy( void ) { if( m_pPlayer->m_rgAmmo[PrimaryAmmoIndex()] > 0 ) { @@ -290,20 +303,20 @@ BOOL CSatchel::CanDeploy( void ) return FALSE; } -BOOL CSatchel::Deploy() +BOOL CPipebomb::Deploy() { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0; m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); if( m_chargeReady ) - return DefaultDeploy( "models/v_satchel_radio.mdl", "models/p_satchel_radio.mdl", SATCHEL_RADIO_DRAW, "hive" ); + return DefaultDeploy( "models/w_pipebomb_watch.mdl", "models/p_pipebomb_watch.mdl", SATCHEL_RADIO_DRAW, "hive" ); else - return DefaultDeploy( "models/v_satchel.mdl", "models/p_satchel.mdl", SATCHEL_DRAW, "trip" ); + return DefaultDeploy( "models/v_pipebomb.mdl", "models/w_pipebomb.mdl", SATCHEL_DRAW, "trip" ); return TRUE; } -void CSatchel::Holster( int skiplocal /* = 0 */ ) +void CPipebomb::Holster( int skiplocal /* = 0 */ ) { m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5; @@ -324,7 +337,7 @@ void CSatchel::Holster( int skiplocal /* = 0 */ ) } } -void CSatchel::PrimaryAttack() +void CPipebomb::PrimaryAttack() { switch( m_chargeReady ) { @@ -339,15 +352,16 @@ void CSatchel::PrimaryAttack() edict_t *pPlayer = m_pPlayer->edict(); - CBaseEntity *pSatchel = NULL; + CBaseEntity *pEnt = NULL; - while( ( pSatchel = UTIL_FindEntityInSphere( pSatchel, m_pPlayer->pev->origin, 4096 ) ) != NULL ) + while( ( pEnt = UTIL_FindEntityInSphere( pEnt, m_pPlayer->pev->origin, 4096 ) ) != NULL ) { - if( FClassnameIs( pSatchel->pev, "monster_satchel" ) ) + if( FClassnameIs( pEnt->pev, "monster_satchel" ) ) { - if( pSatchel->pev->owner == pPlayer ) + CPipebombCharge *pPipebomb = (CPipebombCharge *)pEnt; + if( pPipebomb->m_hOwner->edict() == pPlayer ) { - pSatchel->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); + pPipebomb->Use( m_pPlayer, m_pPlayer, USE_ON, 0 ); } } } @@ -364,7 +378,7 @@ void CSatchel::PrimaryAttack() } } -void CSatchel::SecondaryAttack( void ) +void CPipebomb::SecondaryAttack( void ) { if( m_chargeReady != SATCHEL_RELOAD ) { @@ -372,7 +386,7 @@ void CSatchel::SecondaryAttack( void ) } } -void CSatchel::Throw( void ) +void CPipebomb::Throw( void ) { if( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] ) { @@ -381,14 +395,16 @@ void CSatchel::Throw( void ) Vector vecThrow = gpGlobals->v_forward * 274 + m_pPlayer->pev->velocity; - CBaseEntity *pSatchel = Create( "monster_satchel", vecSrc, Vector( 0, 0, 0 ), m_pPlayer->edict() ); - pSatchel->pev->velocity = vecThrow; - pSatchel->pev->avelocity.y = 400; + CPipebombCharge *pPipebomb = (CPipebombCharge *)Create( "monster_satchel", vecSrc, g_vecZero, m_pPlayer->edict() ); + pPipebomb->pev->velocity = vecThrow; + pPipebomb->pev->avelocity.y = 400; + pPipebomb->m_hOwner = m_pPlayer; + pPipebomb->pev->owner = pPipebomb->m_hOwner->edict(); - m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_satchel_radio.mdl" ); - m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_satchel_radio.mdl" ); + m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_pipebomb_watch.mdl" ); + m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_pipebomb_watch.mdl" ); #else - LoadVModel( "models/v_satchel_radio.mdl", m_pPlayer ); + LoadVModel( "models/v_pipebomb_watch.mdl", m_pPlayer ); #endif SendWeaponAnim( SATCHEL_RADIO_DRAW ); @@ -405,7 +421,7 @@ void CSatchel::Throw( void ) } } -void CSatchel::WeaponIdle( void ) +void CPipebomb::WeaponIdle( void ) { if( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() ) return; @@ -431,10 +447,10 @@ void CSatchel::WeaponIdle( void ) } #ifndef CLIENT_DLL - m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_satchel.mdl" ); - m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_satchel.mdl" ); + m_pPlayer->pev->viewmodel = MAKE_STRING( "models/v_pipebomb.mdl" ); + m_pPlayer->pev->weaponmodel = MAKE_STRING( "models/p_pipebomb.mdl" ); #else - LoadVModel( "models/v_satchel.mdl", m_pPlayer ); + LoadVModel( "models/v_pipebomb.mdl", m_pPlayer ); #endif SendWeaponAnim( SATCHEL_DRAW ); @@ -449,13 +465,41 @@ void CSatchel::WeaponIdle( void ) m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );// how long till we do this again. } +void CPipebomb::PipebombReload() +{ + int i = 0; + + edict_t *pPlayer = m_pPlayer->edict(); + + CBaseEntity *pEntity = NULL; + + while( ( pEntity = UTIL_FindEntityInSphere( pEntity, m_pPlayer->pev->origin, 4096 ) ) != NULL ) + { + if( FClassnameIs( pEntity->pev, "monster_satchel" ) ) + { + CPipebombCharge *pPipebomb = (CPipebombCharge *)pEntity; + if( pPipebomb->m_hOwner->edict() == pPlayer ) + { + ++i; + } + } + } + + if( i < 2 ) + { + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.5; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase(); + m_chargeReady = SATCHEL_RELOAD; + } +} + //========================================================= -// DeactivateSatchels - removes all satchels owned by +// DeactivatePipebombs - removes all pipebombs owned by // the provided player. Should only be used upon death. // // Made this global on purpose. //========================================================= -void DeactivateSatchels( CBasePlayer *pOwner ) +void DeactivatePipebombs( CBasePlayer *pOwner ) { edict_t *pFind; @@ -464,13 +508,13 @@ void DeactivateSatchels( CBasePlayer *pOwner ) while( !FNullEnt( pFind ) ) { CBaseEntity *pEnt = CBaseEntity::Instance( pFind ); - CSatchelCharge *pSatchel = (CSatchelCharge *)pEnt; + CPipebombCharge *pPipebomb = (CPipebombCharge *)pEnt; - if( pSatchel ) + if( pPipebomb ) { - if( pSatchel->pev->owner == pOwner->edict() ) + if( pPipebomb->m_hOwner->edict() == pOwner->edict() ) { - pSatchel->Deactivate(); + pPipebomb->Deactivate(); } } diff --git a/dlls/schedule.h b/dlls/schedule.h index 6414ff15..3373ab32 100644 --- a/dlls/schedule.h +++ b/dlls/schedule.h @@ -86,87 +86,87 @@ typedef enum TASK_WAIT_FACE_ENEMY, TASK_WAIT_PVS, TASK_SUGGEST_STATE, - TASK_WALK_TO_TARGET, + TASK_WALK_TO_TARGET, //5 TASK_RUN_TO_TARGET, TASK_MOVE_TO_TARGET_RANGE, TASK_GET_PATH_TO_ENEMY, TASK_GET_PATH_TO_ENEMY_LKP, - TASK_GET_PATH_TO_ENEMY_CORPSE, + TASK_GET_PATH_TO_ENEMY_CORPSE, //10 TASK_GET_PATH_TO_LEADER, TASK_GET_PATH_TO_SPOT, TASK_GET_PATH_TO_TARGET, TASK_GET_PATH_TO_HINTNODE, - TASK_GET_PATH_TO_LASTPOSITION, + TASK_GET_PATH_TO_LASTPOSITION, //15 TASK_GET_PATH_TO_BESTSOUND, TASK_GET_PATH_TO_BESTSCENT, TASK_RUN_PATH, TASK_WALK_PATH, - TASK_STRAFE_PATH, + TASK_STRAFE_PATH, //20 TASK_CLEAR_MOVE_WAIT, TASK_STORE_LASTPOSITION, TASK_CLEAR_LASTPOSITION, TASK_PLAY_ACTIVE_IDLE, - TASK_FIND_HINTNODE, + TASK_FIND_HINTNODE, //25 TASK_CLEAR_HINTNODE, TASK_SMALL_FLINCH, TASK_FACE_IDEAL, TASK_FACE_ROUTE, - TASK_FACE_ENEMY, + TASK_FACE_ENEMY, //30 TASK_FACE_HINTNODE, TASK_FACE_TARGET, TASK_FACE_LASTPOSITION, TASK_RANGE_ATTACK1, - TASK_RANGE_ATTACK2, + TASK_RANGE_ATTACK2, //35 TASK_MELEE_ATTACK1, TASK_MELEE_ATTACK2, TASK_RELOAD, TASK_RANGE_ATTACK1_NOTURN, - TASK_RANGE_ATTACK2_NOTURN, + TASK_RANGE_ATTACK2_NOTURN, //40 TASK_MELEE_ATTACK1_NOTURN, TASK_MELEE_ATTACK2_NOTURN, TASK_RELOAD_NOTURN, TASK_SPECIAL_ATTACK1, - TASK_SPECIAL_ATTACK2, + TASK_SPECIAL_ATTACK2, //45 TASK_CROUCH, TASK_STAND, TASK_GUARD, TASK_STEP_LEFT, - TASK_STEP_RIGHT, + TASK_STEP_RIGHT, //50 TASK_STEP_FORWARD, TASK_STEP_BACK, TASK_DODGE_LEFT, TASK_DODGE_RIGHT, - TASK_SOUND_ANGRY, + TASK_SOUND_ANGRY, //55 TASK_SOUND_DEATH, TASK_SET_ACTIVITY, TASK_SET_SCHEDULE, TASK_SET_FAIL_SCHEDULE, - TASK_CLEAR_FAIL_SCHEDULE, - TASK_PLAY_SEQUENCE, + TASK_CLEAR_FAIL_SCHEDULE,// 60 + TASK_PLAY_SEQUENCE, TASK_PLAY_SEQUENCE_FACE_ENEMY, TASK_PLAY_SEQUENCE_FACE_TARGET, TASK_SOUND_IDLE, - TASK_SOUND_WAKE, + TASK_SOUND_WAKE, //65 TASK_SOUND_PAIN, TASK_SOUND_DIE, TASK_FIND_COVER_FROM_BEST_SOUND,// tries lateral cover first, then node cover TASK_FIND_COVER_FROM_ENEMY,// tries lateral cover first, then node cover - TASK_FIND_LATERAL_COVER_FROM_ENEMY, - TASK_FIND_NODE_COVER_FROM_ENEMY, + TASK_FIND_LATERAL_COVER_FROM_ENEMY, //70 + TASK_FIND_NODE_COVER_FROM_ENEMY, TASK_FIND_NEAR_NODE_COVER_FROM_ENEMY,// data for this one is the MAXIMUM acceptable distance to the cover. TASK_FIND_FAR_NODE_COVER_FROM_ENEMY,// data for this one is there MINIMUM aceptable distance to the cover. TASK_FIND_COVER_FROM_ORIGIN, - TASK_EAT, + TASK_EAT, //75 TASK_DIE, TASK_WAIT_FOR_SCRIPT, TASK_PLAY_SCRIPT, TASK_ENABLE_SCRIPT, - TASK_PLANT_ON_SCRIPT, + TASK_PLANT_ON_SCRIPT, //80 TASK_FACE_SCRIPT, TASK_WAIT_RANDOM, TASK_WAIT_INDEFINITE, TASK_STOP_MOVING, - TASK_TURN_LEFT, + TASK_TURN_LEFT, //85 TASK_TURN_RIGHT, TASK_REMEMBER, TASK_FORGET, diff --git a/dlls/scientist.cpp b/dlls/scientist.cpp index 7e94b286..8016499b 100644 --- a/dlls/scientist.cpp +++ b/dlls/scientist.cpp @@ -1052,11 +1052,8 @@ MONSTERSTATE CScientist::GetIdealState( void ) } BOOL CScientist::CanHeal( void ) -{ - if( ( m_healTime > gpGlobals->time ) || ( m_hTargetEnt == 0 ) || ( m_hTargetEnt->pev->health > ( m_hTargetEnt->pev->max_health * 0.5 ) ) ) - return FALSE; - - return TRUE; +{ + return FALSE; } void CScientist::Heal( void ) diff --git a/dlls/shotgun.cpp b/dlls/shotgun.cpp index b3a060c3..ba08f6f8 100644 --- a/dlls/shotgun.cpp +++ b/dlls/shotgun.cpp @@ -59,6 +59,8 @@ void CShotgun::Precache( void ) m_iShell = PRECACHE_MODEL( "models/shotgunshell.mdl" );// shotgun shell + PRECACHE_MODEL( "sprites/wallsmoke.spr" ); + PRECACHE_SOUND( "items/9mmclip1.wav" ); PRECACHE_SOUND( "weapons/dbarrel1.wav" );//shotgun @@ -74,7 +76,6 @@ void CShotgun::Precache( void ) PRECACHE_SOUND( "weapons/scock1.wav" ); // cock gun m_usSingleFire = PRECACHE_EVENT( 1, "events/shotgun1.sc" ); - m_usDoubleFire = PRECACHE_EVENT( 1, "events/shotgun2.sc" ); } int CShotgun::AddToPlayer( CBasePlayer *pPlayer ) @@ -121,11 +122,10 @@ void CShotgun::PrimaryAttack() return; } - if( m_iClip <= 0 ) + if( m_iClip <= 1 ) { Reload(); - if( m_iClip == 0 ) - PlayEmptySound(); + PlayEmptySound(); return; } @@ -155,24 +155,21 @@ void CShotgun::PrimaryAttack() PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usSingleFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, 0, 0, 0, 0 ); - m_flNextPrimaryAttack = GetNextAttackDelay( 1.15 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.15; + m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.2; if( m_iClip != 0 ) - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 5.0; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.0; else - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.15; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.2; m_fInSpecialReload = 0; UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle ); - // Take the inverse forward unit vector and zero out z. - // Only horizontal impulse allowed. - Vector vecImpulse = -gpGlobals->v_forward; - vecImpulse.z = 0; + Vector oldVelocity = m_pPlayer->pev->velocity; // Send player impulse. - m_pPlayer->pev->velocity = m_pPlayer->pev->velocity + vecImpulse * 200; + m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - gpGlobals->v_forward * 200; + m_pPlayer->pev->velocity = m_pPlayer->pev->velocity - ( m_pPlayer->pev->velocity - oldVelocity ) * 0.5f; } void CShotgun::SecondaryAttack( void ) @@ -193,10 +190,10 @@ void CShotgun::Reload( void ) { SendWeaponAnim( SHOTGUN_START_RELOAD ); m_fInSpecialReload = 1; - m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.6; - m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6; - m_flNextPrimaryAttack = GetNextAttackDelay( 1.0 ); - m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 1.0; + m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.4; + m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.4; + m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.8; + m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.8; return; } else if( m_fInSpecialReload == 1 ) diff --git a/dlls/sound.cpp b/dlls/sound.cpp index f8587ed0..07000a6b 100644 --- a/dlls/sound.cpp +++ b/dlls/sound.cpp @@ -980,6 +980,52 @@ void CEnvSound::Spawn() pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 0.0, 0.5 ); } +int g_soundtrackCount; +soundtrack_t g_soundtracklist[30]; + +void SOUNDTRACKLIST_Init() +{ + char buffer[512] = {0,}; + int i, j = 0; + byte *pMemFile; + int fileSize, filePos = 0; + + pMemFile = g_engfuncs.pfnLoadFileForMe( "sound/soundtrack.txt", &fileSize ); + if( !pMemFile ) + return; + + // for each line in the file... + while( memfgets( pMemFile, fileSize, filePos, buffer, 511 ) != NULL && j < 30 ) + { + char *pos; + + // skip whitespace + i = 0; + while( buffer[i] && isspace( buffer[i] ) ) + i++; + + if( !buffer[i] ) + continue; + + // skip comment lines + if( buffer[i] == '/' ) + continue; + + if( 3 > sscanf( &buffer[i], "\"%31[^\"]\" \"%31[^\"]\" \"%d\" ", \ + g_soundtracklist[j].mapname, g_soundtracklist[j].soundfile, &g_soundtracklist[j].loop ) ) + continue; + + pos = strchr( g_soundtracklist[j].mapname, '.' ); + *pos = '\0'; + + j++; + } + + g_soundtrackCount = j; + + g_engfuncs.pfnFreeFile( pMemFile ); +} + // ==================== SENTENCE GROUPS, UTILITY FUNCTIONS ====================================== #define CSENTENCE_LRU_MAX 32 // max number of elements per sentence group @@ -1739,16 +1785,8 @@ float TEXTURETYPE_PlaySound( TraceResult *ptr, Vector vecSrc, Vector vecEnd, in return 0.0; // crowbar already makes this sound fvol = 1.0; fvolbar = 0.2; - if( iBulletType == BULLET_PLAYER_NAIL1 || iBulletType == BULLET_PLAYER_NAIL2 ) - { - rgsz[0] = "weapons/brad_hit1.wav"; - rgsz[1] = "weapons/brad_hit2.wav"; - } - else - { - rgsz[0] = "weapons/bullet_hit1.wav"; - rgsz[1] = "weapons/bullet_hit2.wav"; - } + rgsz[0] = "weapons/bullet_hit1.wav"; + rgsz[1] = "weapons/bullet_hit2.wav"; fattn = 1.0; cnt = 2; break; diff --git a/dlls/triggers.cpp b/dlls/triggers.cpp index 64bd47ea..43752316 100644 --- a/dlls/triggers.cpp +++ b/dlls/triggers.cpp @@ -27,6 +27,7 @@ #include "saverestore.h" #include "trains.h" // trigger_camera has train functionality #include "gamerules.h" +#include "weapons.h" #define SF_TRIGGER_PUSH_START_OFF 2//spawnflag that makes trigger_push spawn turned OFF #define SF_TRIGGER_HURT_TARGETONCE 1// Only fire hurt target once @@ -2105,6 +2106,7 @@ class CTriggerCamera : public CBaseDelay public: void Spawn( void ); void KeyValue( KeyValueData *pkvd ); + void EXPORT CallAgain(); void Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ); void EXPORT FollowTarget( void ); void Move( void ); @@ -2127,6 +2129,10 @@ public: float m_acceleration; float m_deceleration; int m_state; + EHANDLE m_hActivator; + EHANDLE m_hCaller; + USE_TYPE m_useType; + float m_flValue; }; LINK_ENTITY_TO_CLASS( trigger_camera, CTriggerCamera ) @@ -2147,6 +2153,10 @@ TYPEDESCRIPTION CTriggerCamera::m_SaveData[] = DEFINE_FIELD( CTriggerCamera, m_acceleration, FIELD_FLOAT ), DEFINE_FIELD( CTriggerCamera, m_deceleration, FIELD_FLOAT ), DEFINE_FIELD( CTriggerCamera, m_state, FIELD_INTEGER ), + DEFINE_FIELD( CTriggerCamera, m_hActivator, FIELD_EHANDLE ), + DEFINE_FIELD( CTriggerCamera, m_hCaller, FIELD_EHANDLE ), + DEFINE_FIELD( CTriggerCamera, m_useType, FIELD_INTEGER ), + DEFINE_FIELD( CTriggerCamera, m_flValue, FIELD_FLOAT ), }; IMPLEMENT_SAVERESTORE( CTriggerCamera, CBaseDelay ) @@ -2191,6 +2201,11 @@ void CTriggerCamera::KeyValue( KeyValueData *pkvd ) CBaseDelay::KeyValue( pkvd ); } +void CTriggerCamera::CallAgain() +{ + Use( m_hActivator, m_hCaller, m_useType, m_flValue ); +} + void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { if( !ShouldToggle( useType, m_state ) ) @@ -2210,6 +2225,22 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP m_hPlayer = pActivator; + if( pActivator->pev->iuser4 ) + { + CBasePlayer *pPlayer = (CBasePlayer *)pActivator; + if( FClassnameIs( pPlayer->m_pActiveItem->pev, "weapon_cmlwbr" ) ) + { + CCrossbow *pCrossbow = (CCrossbow *)pPlayer->m_pActiveItem; + pCrossbow->ZoomOut(); + m_hActivator = pActivator; + m_hCaller = pCaller; + m_useType = useType; + m_flValue = value; + SetThink( &CTriggerCamera::CallAgain ); + pev->nextthink = gpGlobals->time + 0.1f; + } + } + m_flReturnTime = gpGlobals->time + m_flWait; pev->speed = m_initialSpeed; m_targetSpeed = m_initialSpeed; @@ -2232,17 +2263,10 @@ void CTriggerCamera::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYP if( FBitSet( pev->spawnflags, SF_CAMERA_PLAYER_TAKECONTROL ) ) { ( (CBasePlayer *)pActivator )->EnableControl( FALSE ); - - if( !( FStrEq( STRING( gpGlobals->mapname ), "po_haz01" ) && FStrEq( STRING( pev->targetname ), "cam" ) ) && - !( FStrEq( STRING( gpGlobals->mapname ), "po_aud01" ) && FStrEq( STRING( pev->targetname ), "cam" ) ) ) - { - if( ( (CBasePlayer *)pActivator )->pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - ( (CBasePlayer *)pActivator )->HidePlayerHUD(); - } - } } + SetBits( ( (CBasePlayer *)pActivator )->m_iHideHUD, HIDEHUD_WEAPONS | HIDEHUD_HEALTH ); + if( m_sPath ) { m_pentPath = Instance( FIND_ENTITY_BY_TARGETNAME( NULL, STRING( m_sPath ) ) ); @@ -2296,17 +2320,10 @@ void CTriggerCamera::FollowTarget() { if( m_hPlayer->IsAlive() ) { + CBasePlayer *pPlayer = (CBasePlayer *)( (CBaseEntity *)m_hPlayer ); SET_VIEW( m_hPlayer->edict(), m_hPlayer->edict() ); - ( (CBasePlayer *)( (CBaseEntity *)m_hPlayer ) )->EnableControl( TRUE ); - - if( !( FStrEq( STRING( gpGlobals->mapname ), "po_aud01" ) && FStrEq( STRING( pev->targetname ), "cam" ) ) && - !( FStrEq( STRING( gpGlobals->mapname ), "credits" ) && FStrEq( STRING( pev->targetname ), "credits_cam" ) ) ) - { - if( ( (CBasePlayer *)( (CBaseEntity *)m_hPlayer ) )->pev->weapons & ( 1 << WEAPON_SUIT ) ) - { - ( (CBasePlayer *)( (CBaseEntity *)m_hPlayer ) )->ShowPlayerHUD(); - } - } + pPlayer->EnableControl( TRUE ); + ClearBits( pPlayer->m_iHideHUD, HIDEHUD_WEAPONS | HIDEHUD_HEALTH ); } SUB_UseTargets( this, USE_TOGGLE, 0 ); pev->avelocity = Vector( 0, 0, 0 ); diff --git a/dlls/util.cpp b/dlls/util.cpp index 94c8c68c..202a3044 100644 --- a/dlls/util.cpp +++ b/dlls/util.cpp @@ -31,6 +31,20 @@ #include "weapons.h" #include "gamerules.h" + +void UTIL_MakeTracer( const Vector &vecSrc, const Vector &vecDest ) +{ + MESSAGE_BEGIN( MSG_PAS, SVC_TEMPENTITY, vecSrc ); + WRITE_BYTE( TE_TRACER ); + WRITE_COORD( vecSrc.x ); + WRITE_COORD( vecSrc.y ); + WRITE_COORD( vecSrc.z ); + WRITE_COORD( vecDest.x ); + WRITE_COORD( vecDest.y ); + WRITE_COORD( vecDest.z ); + MESSAGE_END(); +} + float UTIL_WeaponTimeBase( void ) { #if defined( CLIENT_WEAPONS ) diff --git a/dlls/util.h b/dlls/util.h index 7f9dea70..d2f6adcd 100644 --- a/dlls/util.h +++ b/dlls/util.h @@ -500,6 +500,17 @@ extern DLL_GLOBAL int g_Language; #define CBSENTENCENAME_MAX 16 #define CVOXFILESENTENCEMAX 1536 // max number of sentences in game. NOTE: this must match // CVOXFILESENTENCEMAX in engine\sound.h!!! +typedef struct soundtrack_s +{ + char mapname[32]; + char soundfile[32]; + BOOL loop; +} soundtrack_t; + +extern int g_soundtrackCount; +extern soundtrack_t g_soundtracklist[30]; + +void SOUNDTRACKLIST_Init(); extern char gszallsentencenames[CVOXFILESENTENCEMAX][CBSENTENCENAME_MAX]; extern int gcallsentences; @@ -577,5 +588,6 @@ void UTIL_UnsetGroupTrace( void ); int UTIL_SharedRandomLong( unsigned int seed, int low, int high ); float UTIL_SharedRandomFloat( unsigned int seed, float low, float high ); +void UTIL_MakeTracer( const Vector &vecSrc, const Vector &vecDest ); float UTIL_WeaponTimeBase( void ); #endif // UTIL_H diff --git a/dlls/weapons.cpp b/dlls/weapons.cpp index 68d9aaf3..53a3d4fb 100644 --- a/dlls/weapons.cpp +++ b/dlls/weapons.cpp @@ -170,8 +170,6 @@ void DecalGunshot( TraceResult *pTrace, int iBulletType ) case BULLET_MONSTER_MP5: case BULLET_PLAYER_BUCKSHOT: case BULLET_PLAYER_357: - case BULLET_PLAYER_NAIL1: - case BULLET_PLAYER_NAIL2: default: // smoke and decal UTIL_GunshotDecalTrace( pTrace, DamageDecal( pEntity, DMG_BULLET ) ); @@ -346,10 +344,6 @@ void W_Precache( void ) g_sModelIndexLaser = PRECACHE_MODEL( g_pModelNameLaser ); g_sModelIndexLaserDot = PRECACHE_MODEL( "sprites/laserdot.spr" ); - g_sModelIndexShockwave = PRECACHE_MODEL( "sprites/shockwave.spr" ); // shockwave explosion - - PRECACHE_MODEL( "sprites/wallsmoke.spr" ); - // used by explosions PRECACHE_MODEL( "models/grenade.mdl" ); PRECACHE_MODEL( "sprites/explode1.spr" ); @@ -368,11 +362,6 @@ void W_Precache( void ) PRECACHE_SOUND( "items/weapondrop1.wav" );// weapon falls to the ground PRECACHE_MODEL( "models/w_grenade.mdl" ); - - PRECACHE_SOUND( "weapons/brad_hit1.wav" ); // hit by nail - PRECACHE_SOUND( "weapons/brad_hit2.wav" ); // hit by nail - - UTIL_PrecacheOther( "fire_trail" ); // pipebomb explosion effect. } TYPEDESCRIPTION CBasePlayerItem::m_SaveData[] = @@ -600,8 +589,6 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_iClip += j; m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] -= j; - m_pPlayer->TabulateAmmo(); - m_fInReload = FALSE; } @@ -617,7 +604,6 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fFireOnEmpty = TRUE; } - m_pPlayer->TabulateAmmo(); SecondaryAttack(); m_pPlayer->pev->button &= ~IN_ATTACK2; } @@ -628,7 +614,6 @@ void CBasePlayerWeapon::ItemPostFrame( void ) m_fFireOnEmpty = TRUE; } - m_pPlayer->TabulateAmmo(); PrimaryAttack(); } else if( m_pPlayer->pev->button & IN_RELOAD && iMaxClip() != WEAPON_NOCLIP && !m_fInReload ) @@ -933,7 +918,6 @@ BOOL CBasePlayerWeapon::DefaultDeploy( const char *szViewModel, const char *szWe if( !CanDeploy() ) return FALSE; - m_pPlayer->TabulateAmmo(); m_pPlayer->pev->viewmodel = MAKE_STRING( szViewModel ); m_pPlayer->pev->weaponmodel = MAKE_STRING( szWeaponModel ); strcpy( m_pPlayer->m_szAnimExtention, szAnimExt ); @@ -1572,79 +1556,43 @@ TYPEDESCRIPTION CShotgun::m_SaveData[] = { DEFINE_FIELD( CShotgun, m_flNextReload, FIELD_TIME ), DEFINE_FIELD( CShotgun, m_fInSpecialReload, FIELD_INTEGER ), - DEFINE_FIELD( CShotgun, m_flNextReload, FIELD_TIME ), // DEFINE_FIELD( CShotgun, m_iShell, FIELD_INTEGER ), DEFINE_FIELD( CShotgun, m_flPumpTime, FIELD_TIME ), }; IMPLEMENT_SAVERESTORE( CShotgun, CBasePlayerWeapon ) -TYPEDESCRIPTION CGauss::m_SaveData[] = +TYPEDESCRIPTION CCrossbow::m_SaveData[] = { - DEFINE_FIELD( CGauss, m_fInAttack, FIELD_INTEGER ), + DEFINE_FIELD( CCrossbow, m_fInAttack, FIELD_INTEGER ), + DEFINE_FIELD( CCrossbow, m_fInZoom, FIELD_INTEGER ), +}; + +IMPLEMENT_SAVERESTORE( CCrossbow, CBasePlayerWeapon ) + +TYPEDESCRIPTION CXS::m_SaveData[] = +{ + DEFINE_FIELD( CXS, m_fInAttack, FIELD_INTEGER ), //DEFINE_FIELD( CGauss, m_flStartCharge, FIELD_TIME ), //DEFINE_FIELD( CGauss, m_flPlayAftershock, FIELD_TIME ), //DEFINE_FIELD( CGauss, m_flNextAmmoBurn, FIELD_TIME ), - DEFINE_FIELD( CGauss, m_fPrimaryFire, FIELD_BOOLEAN ), + DEFINE_FIELD( CXS, m_fPrimaryFire, FIELD_BOOLEAN ), }; -IMPLEMENT_SAVERESTORE( CGauss, CBasePlayerWeapon ) +IMPLEMENT_SAVERESTORE( CXS, CBasePlayerWeapon ) -TYPEDESCRIPTION CEgon::m_SaveData[] = +TYPEDESCRIPTION CPipebomb::m_SaveData[] = { - //DEFINE_FIELD( CEgon, m_pBeam, FIELD_CLASSPTR ), - //DEFINE_FIELD( CEgon, m_pNoise, FIELD_CLASSPTR ), - //DEFINE_FIELD( CEgon, m_pSprite, FIELD_CLASSPTR ), - DEFINE_FIELD( CEgon, m_shootTime, FIELD_TIME ), - DEFINE_FIELD( CEgon, m_fireState, FIELD_INTEGER ), - DEFINE_FIELD( CEgon, m_fireMode, FIELD_INTEGER ), - DEFINE_FIELD( CEgon, m_shakeTime, FIELD_TIME ), - DEFINE_FIELD( CEgon, m_flAmmoUseTime, FIELD_TIME ), + DEFINE_FIELD( CPipebomb, m_chargeReady, FIELD_INTEGER ), }; -IMPLEMENT_SAVERESTORE( CEgon, CBasePlayerWeapon ) +IMPLEMENT_SAVERESTORE( CPipebomb, CBasePlayerWeapon ) -TYPEDESCRIPTION CSatchel::m_SaveData[] = +TYPEDESCRIPTION CPipebombCharge::m_SaveData[] = { - DEFINE_FIELD( CSatchel, m_chargeReady, FIELD_INTEGER ), + DEFINE_FIELD( CPipebombCharge, m_flDropTime, FIELD_FLOAT ), + DEFINE_FIELD( CPipebombCharge, m_iTrail, FIELD_INTEGER ), + DEFINE_FIELD( CPipebombCharge, m_hOwner, FIELD_EHANDLE ), }; -IMPLEMENT_SAVERESTORE( CSatchel, CBasePlayerWeapon ) - -TYPEDESCRIPTION CBradnailer::m_SaveData[] = -{ - DEFINE_FIELD( CBradnailer, m_flNextPrimaryAttack, FIELD_TIME ), - DEFINE_FIELD( CBradnailer, m_flNextSecondaryAttack, FIELD_TIME ), - DEFINE_FIELD( CBradnailer, m_flTimeWeaponIdle, FIELD_TIME ), -}; - -IMPLEMENT_SAVERESTORE( CBradnailer, CBasePlayerWeapon ) - -TYPEDESCRIPTION CCmlwbr::m_SaveData[] = -{ - DEFINE_FIELD( CCmlwbr, m_fInAttack, FIELD_INTEGER ), - DEFINE_FIELD( CCmlwbr, m_fInZoom, FIELD_INTEGER ), -}; - -IMPLEMENT_SAVERESTORE( CCmlwbr, CBasePlayerWeapon ) - -TYPEDESCRIPTION CXenSquasher::m_SaveData[] = -{ - DEFINE_FIELD( CXenSquasher, m_fInAttack, FIELD_INTEGER ), - DEFINE_FIELD( CXenSquasher, m_flNextPrimaryAttack, FIELD_TIME ), - DEFINE_FIELD( CXenSquasher, m_flNextSecondaryAttack, FIELD_TIME ), - DEFINE_FIELD( CXenSquasher, m_flTimeWeaponIdle, FIELD_TIME ), - //DEFINE_FIELD( CGauss, m_flStartCharge, FIELD_TIME ), - //DEFINE_FIELD( CGauss, m_flPlayAftershock, FIELD_TIME ), - //DEFINE_FIELD( CGauss, m_flNextAmmoBurn, FIELD_TIME ), - DEFINE_FIELD( CXenSquasher, m_fPrimaryFire, FIELD_BOOLEAN ), -}; - -IMPLEMENT_SAVERESTORE( CXenSquasher, CBasePlayerWeapon ) - -TYPEDESCRIPTION CPipeBomb::m_SaveData[] = -{ - DEFINE_FIELD( CPipeBomb, m_thrownByPlayer, FIELD_INTEGER ), -}; - -IMPLEMENT_SAVERESTORE( CPipeBomb, CSatchel ) +IMPLEMENT_SAVERESTORE( CPipebombCharge, CGrenade ) diff --git a/dlls/weapons.h b/dlls/weapons.h index f0497044..e6b5f6e4 100644 --- a/dlls/weapons.h +++ b/dlls/weapons.h @@ -21,7 +21,7 @@ class CBasePlayer; extern int gmsgWeapPickup; -void DeactivateSatchels( CBasePlayer *pOwner ); +void DeactivatePipebombs( CBasePlayer *pOwner ); // Contact Grenade / Timed grenade / Satchel Charge class CGrenade : public CBaseMonster @@ -68,7 +68,7 @@ public: #define WEAPON_MP5 4 #define WEAPON_CROSSBOW 6 #define WEAPON_SHOTGUN 7 -#define WEAPON_GAUSS 9 +#define WEAPON_XS 9 #define WEAPON_SATCHEL 14 #define WEAPON_ALLWEAPONS (~(1<spawnflags & SF_WORLD_AMBIENT_MP3 ) + { + CAmbientMP3 *pMPlayer = CAmbientMP3::AmbientMP3Create( "#po_soundtrack#" ); + + if( pMPlayer ) + { + pMPlayer->SetThink( &CBaseEntity::SUB_CallUseToggle ); + pMPlayer->pev->nextthink = gpGlobals->time + 1.0f; + } + pev->spawnflags &= ~SF_WORLD_AMBIENT_MP3; + } if( pev->spawnflags & SF_WORLD_DARK ) CVAR_SET_FLOAT( "v_dark", 1.0 ); else @@ -666,6 +678,8 @@ void CWorld::Precache( void ) // void CWorld::KeyValue( KeyValueData *pkvd ) { + if( !( pev->spawnflags & SF_WORLD_AMBIENT_MP3 ) ) + pev->spawnflags |= SF_WORLD_AMBIENT_MP3; if( FStrEq( pkvd->szKeyName, "skyname" ) ) { // Sent over net now. From 0c56465e95580b11d588e4bac2dbe8345f068224 Mon Sep 17 00:00:00 2001 From: Night Owl Date: Thu, 25 Oct 2018 10:10:14 +0500 Subject: [PATCH 199/199] Use crowbar idle animation. --- dlls/Android.mk | 2 +- dlls/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/dlls/Android.mk b/dlls/Android.mk index 93a6da78..a1f96aba 100644 --- a/dlls/Android.mk +++ b/dlls/Android.mk @@ -14,7 +14,7 @@ LOCAL_MODULE_FILENAME = libserver_hardfp endif LOCAL_CFLAGS += -D_LINUX -DCLIENT_WEAPONS -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -D_snprintf=snprintf \ - -fno-exceptions -DNO_VOICEGAMEMGR -w + -fno-exceptions -DNO_VOICEGAMEMGR -DCROWBAR_IDLE_ANIM -w LOCAL_CPPFLAGS := $(LOCAL_CFLAGS) diff --git a/dlls/CMakeLists.txt b/dlls/CMakeLists.txt index 6ab4e655..24e6a859 100644 --- a/dlls/CMakeLists.txt +++ b/dlls/CMakeLists.txt @@ -25,6 +25,8 @@ project (SVDLL) set (SVDLL_LIBRARY server) +add_definitions(-DCROWBAR_IDLE_ANIM) + if(NOT MSVC) add_compile_options(-fno-exceptions) # GCC/Clang flag add_compile_options(-Wno-invalid-offsetof) # GCC/Clang flag