about summary refs log tree commit diff
path: root/src/game
diff options
context:
space:
mode:
authorMarius "Teelevision" Neugebauer <marius@teele.eu>2014-04-05 05:31:10 +0200
committerMarius "Teelevision" Neugebauer <marius@teele.eu>2014-04-05 05:31:10 +0200
commite0d9aeefcf1e884f6f612c054f29b331961a821e (patch)
treef1f9decc9eb5d4934cb969af0ac4275038c3a59b /src/game
parent92195db17d92856206ba4bcadb9426c98a47bccc (diff)
downloadzcatch-e0d9aeefcf1e884f6f612c054f29b331961a821e.tar.gz
zcatch-e0d9aeefcf1e884f6f612c054f29b331961a821e.zip
added range estimate to bot detection message; small adjustments
Diffstat (limited to 'src/game')
-rw-r--r--src/game/server/gamecontext.cpp19
-rw-r--r--src/game/server/player.cpp1
-rw-r--r--src/game/server/player.h1
3 files changed, 15 insertions, 6 deletions
diff --git a/src/game/server/gamecontext.cpp b/src/game/server/gamecontext.cpp
index 29295ef9..3a9e7543 100644
--- a/src/game/server/gamecontext.cpp
+++ b/src/game/server/gamecontext.cpp
@@ -532,7 +532,7 @@ void CGameContext::OnTick()
 	// check each player, check only if an admin is online
 	if(g_Config.m_SvBotDetection && Server()->GetNumLoggedInAdmins())
 	{
-		char aBuf[128];
+		char aBuf[128], bBuf[64];
 		const vec2 *pos, *posVictim;
 		float d, precision;
 		CCharacter *ci, *cj;
@@ -568,7 +568,7 @@ void CGameContext::OnTick()
 						indexAdd = min(3, (int)(precision / 50000));
 						p->m_AimBotLastDetectionPos = ci->m_Pos;
 						// prepare console output
-						str_format(aBuf, sizeof(aBuf), "player=%d victim=%d index=%d precision=%d speed=%d distance=%d", i, j, p->m_AimBotIndex + indexAdd, (int)precision, (int)p->m_AimBotTargetSpeed, (int)d);
+						str_format(bBuf, sizeof(bBuf), "precision=%d speed=%d distance=%d", (int)precision, (int)p->m_AimBotTargetSpeed, (int)d);
 					}
 					
 					// follow bot detection
@@ -589,7 +589,7 @@ void CGameContext::OnTick()
 						indexAdd = 1;
 						p->m_AimBotLastDetectionPos = *pos;
 						// prepare console output
-						str_format(aBuf, sizeof(aBuf), "player=%d victim=%d index=%d", i, j, p->m_AimBotIndex + indexAdd);
+						bBuf[0] = 0;
 					}
 					
 					// detected
@@ -597,8 +597,10 @@ void CGameContext::OnTick()
 					{
 						p->m_AimBotLastDetection = Server()->Tick();
 						p->m_AimBotLastDetectionPosVictim = *posVictim;
-						++p->m_AimBotIndex;
+						p->m_AimBotIndex += indexAdd;
+						p->m_AimBotRange = max(p->m_AimBotRange, (int)length(target));
 						// log to console
+						str_format(aBuf, sizeof(aBuf), "player=%d victim=%d index=%d %s", i, j, p->m_AimBotIndex, bBuf);
 						Console()->Print(IConsole::OUTPUT_LEVEL_STANDARD, "botdetect", aBuf);
 						// don't check other players
 						break;
@@ -613,7 +615,7 @@ void CGameContext::OnTick()
 				p->m_IsAimBot = Server()->Tick();
 				// alert the admins
 				char aBuf[128];
-				str_format(aBuf, sizeof(aBuf), "+++ '%s' (id=%d) might be botting +++", Server()->ClientName(i), i);
+				str_format(aBuf, sizeof(aBuf), "+++ '%s' (id=%d,range=%d) might be botting +++", Server()->ClientName(i), i, p->m_AimBotRange);
 				for(int j = 0; j < MAX_CLIENTS; ++j)
 					if(Server()->IsAuthed(j))
 						SendChatTarget(j, aBuf);
@@ -621,7 +623,12 @@ void CGameContext::OnTick()
 			
 			// reduce once every seconds (tolerance)
 			if(((Server()->Tick() % Server()->TickSpeed()) == 0) && p->m_AimBotIndex)
-				--p->m_AimBotIndex;
+			{
+				if(!(--p->m_AimBotIndex))
+				{
+					p->m_AimBotRange = 0;
+				}
+			}
 		}
 	}
 
diff --git a/src/game/server/player.cpp b/src/game/server/player.cpp
index 17fcd566..092b85a1 100644
--- a/src/game/server/player.cpp
+++ b/src/game/server/player.cpp
@@ -40,6 +40,7 @@ CPlayer::CPlayer(CGameContext *pGameServer, int ClientID, int Team)
 	// bot detection
 	m_IsAimBot = 0;
 	m_AimBotIndex = 0;
+	m_AimBotRange = 0;
 	m_AimBotLastDetection = 0;
 	m_AimBotTargetSpeed = .0;
 	m_CurrentTarget.x = 0;
diff --git a/src/game/server/player.h b/src/game/server/player.h
index b16e2589..32860106 100644
--- a/src/game/server/player.h
+++ b/src/game/server/player.h
@@ -135,6 +135,7 @@ public:
 	// bot detection
 	int m_IsAimBot;
 	int m_AimBotIndex;
+	int m_AimBotRange;
 	float m_AimBotTargetSpeed;
 	vec2 m_CurrentTarget;
 	vec2 m_LastTarget;