Skip to content

Commit 968b807

Browse files
committed
1 parent 3ee1705 commit 968b807

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

src/game/server/tf/tf_gamestats.cpp

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ extern ConVar tf_mm_trusted;
4040
static ConVar tf_stats_nogameplaycheck( "tf_stats_nogameplaycheck", "0", FCVAR_NONE , "Disable normal check for valid gameplay, send stats regardless." );
4141
//static ConVar tf_stats_track( "tf_stats_track", "1", FCVAR_NONE, "Turn on//off tf stats tracking." );
4242
//static ConVar tf_stats_verbose( "tf_stats_verbose", "0", FCVAR_NONE, "Turn on//off verbose logging of stats." );
43+
#ifdef BDSBASE
44+
ConVar tf_stats_bogus_damage_max("tf_stats_bogus_damage_max", "1500", FCVAR_REPLICATED, "Maximum Damage before Bogus warning");
45+
ConVar tf_stats_bogus_damage_mvm_max("tf_stats_bogus_damage_mvm_max", "5000", FCVAR_REPLICATED, "Maximum Damage in MvM before Bogus warning");
46+
ConVar tf_stats_bogus_healing_max("tf_stats_bogus_healing_max", "1000", FCVAR_REPLICATED, "Maximum Healing before Bogus warning");
47+
ConVar tf_stats_bogus_block_damage_max("tf_stats_bogus_block_damage_max", "3000", FCVAR_REPLICATED, "Maximum Damage Blocked before Bogus warning");
48+
ConVar tf_stats_bogus_return("tf_stats_bogus_return", "1", FCVAR_REPLICATED, "Return without recording stats if bogus values are found");
49+
#endif
4350

4451
CTFGameStats CTF_GameStats;
4552

@@ -719,11 +726,28 @@ void CTFGameStats::Event_PlayerHealedOther( CTFPlayer *pPlayer, float amount )
719726
// make sure value is sane
720727
int iAmount = (int) amount;
721728
Assert( iAmount >= 0 );
729+
#ifdef BDSBASE
730+
Assert(iAmount <= tf_stats_bogus_healing_max.GetInt());
731+
if (iAmount < 0 || iAmount > tf_stats_bogus_healing_max.GetInt())
732+
#else
722733
Assert( iAmount <= 1000 );
723734
if ( iAmount < 0 || iAmount > 1000 )
735+
#endif
724736
{
737+
#ifdef BDSBASE
738+
if (tf_stats_bogus_return.GetBool())
739+
{
740+
DevMsg("CTFGameStats: Bogus Healing value found, %d, ignoring\n", iAmount);
741+
return;
742+
}
743+
else
744+
{
745+
DevMsg("CTFGameStats: Bogus Healing value found, %d\n", iAmount);
746+
}
747+
#else
725748
DevMsg( "CTFGameStats: bogus healing value of %d reported, ignoring\n", iAmount );
726749
return;
750+
#endif
727751
}
728752
IncrementStat( pPlayer, TFSTAT_HEALING, (int) amount );
729753

@@ -755,11 +779,28 @@ void CTFGameStats::Event_PlayerHealedOtherAssist( CTFPlayer *pPlayer, float amou
755779
// make sure value is sane
756780
int iAmount = (int) amount;
757781
Assert( iAmount >= 0 );
782+
#ifdef BDSBASE
783+
Assert(iAmount <= tf_stats_bogus_healing_max.GetInt());
784+
if (iAmount < 0 || iAmount > tf_stats_bogus_healing_max.GetInt())
785+
#else
758786
Assert( iAmount <= 1000 );
759787
if ( iAmount < 0 || iAmount > 1000 )
788+
#endif
760789
{
790+
#ifdef BDSBASE
791+
if (tf_stats_bogus_return.GetBool())
792+
{
793+
DevMsg("CTFGameStats: Bogus Healing value found, %d, ignoring\n", iAmount);
794+
return;
795+
}
796+
else
797+
{
798+
DevMsg("CTFGameStats: Bogus Healing value found, %d\n", iAmount);
799+
}
800+
#else
761801
DevMsg( "CTFGameStats: bogus healing value of %d reported, ignoring\n", iAmount );
762802
return;
803+
#endif
763804
}
764805
IncrementStat( pPlayer, TFSTAT_HEALING_ASSIST, (int) amount );
765806
}
@@ -769,11 +810,28 @@ void CTFGameStats::Event_PlayerHealedOtherAssist( CTFPlayer *pPlayer, float amou
769810
//-----------------------------------------------------------------------------
770811
void CTFGameStats::Event_PlayerBlockedDamage( CTFPlayer *pPlayer, int nAmount )
771812
{
813+
#ifdef BDSBASE
814+
Assert(pPlayer && nAmount > 0 && nAmount < tf_stats_bogus_block_damage_max.GetInt());
815+
if (nAmount < 0 || nAmount > tf_stats_bogus_block_damage_max.GetInt())
816+
#else
772817
Assert( pPlayer && nAmount > 0 && nAmount < 3000 );
773818
if ( nAmount < 0 || nAmount > 3000 )
819+
#endif
774820
{
821+
#ifdef BDSBASE
822+
if (tf_stats_bogus_return.GetBool())
823+
{
824+
DevMsg("CTFGameStats: Bogus Blocked Damage value found, %d, ignoring\n", nAmount);
825+
return;
826+
}
827+
else
828+
{
829+
DevMsg("CTFGameStats: Bogus Blocked Damage value found, %d\n", nAmount);
830+
}
831+
#else
775832
DevMsg( "CTFGameStats: bogus blocked damage value of %d reported, ignoring\n", nAmount );
776833
return;
834+
#endif
777835
}
778836
IncrementStat( pPlayer, TFSTAT_DAMAGE_BLOCKED, nAmount );
779837
}
@@ -1033,15 +1091,38 @@ void CTFGameStats::Event_PlayerFiredWeapon( CTFPlayer *pPlayer, bool bCritical )
10331091
void CTFGameStats::Event_PlayerDamage( CBasePlayer *pBasePlayer, const CTakeDamageInfo &info, int iDamageTaken )
10341092
{
10351093
// defensive guard against insanely huge damage values that apparently get into the stats system once in a while -- ignore insane values
1094+
#ifdef BDSBASE
1095+
int INSANE_PLAYER_DAMAGE = TFGameRules()->IsMannVsMachineMode() ? tf_stats_bogus_damage_mvm_max.GetFloat() : tf_stats_bogus_damage_max.GetFloat();
1096+
#else
10361097
const int INSANE_PLAYER_DAMAGE = TFGameRules()->IsMannVsMachineMode() ? 5000 : 1500;
1098+
#endif
10371099

10381100
if ( sv_cheats && !sv_cheats->GetBool() )
10391101
{
10401102
Assert( iDamageTaken >= 0 );
10411103
}
1104+
#ifdef BDSBASE
1105+
if ((iDamageTaken < 0))
1106+
#else
10421107
if ( ( iDamageTaken < 0 ) || ( iDamageTaken > INSANE_PLAYER_DAMAGE ) )
1108+
#endif
10431109
return;
10441110

1111+
#ifdef BDSBASE
1112+
if (iDamageTaken > INSANE_PLAYER_DAMAGE)
1113+
{
1114+
if (tf_stats_bogus_return.GetBool())
1115+
{
1116+
DevMsg("CTFGameStats: Bogus Damage value found, %d, ignoring\n", iDamageTaken);
1117+
return;
1118+
}
1119+
else
1120+
{
1121+
DevMsg("CTFGameStats: Bogus Damage value found, %d\n", iDamageTaken);
1122+
}
1123+
}
1124+
#endif
1125+
10451126
CObjectSentrygun *pSentry = NULL;
10461127
CTFPlayer *pTarget = ToTFPlayer( pBasePlayer );
10471128
CTFPlayer *pAttacker = ToTFPlayer( info.GetAttacker() );

0 commit comments

Comments
 (0)