From dc1b920820f8eaba813823c4c367a71e6af8ee48 Mon Sep 17 00:00:00 2001 From: aurhat Date: Sat, 20 Jun 2015 16:01:56 +0200 Subject: [PATCH] Cleanup bot code (server related) --- source/src/bot/bot.h | 3 +-- source/src/bot/bot_ai.cpp | 18 +++++++++--------- source/src/bot/bot_util.cpp | 17 ++++------------- source/src/bot/bot_waypoint.cpp | 2 -- source/src/bot/botmanager.cpp | 29 +++-------------------------- 5 files changed, 17 insertions(+), 52 deletions(-) diff --git a/source/src/bot/bot.h b/source/src/bot/bot.h index fbc6cc94..7ea4029a 100644 --- a/source/src/bot/bot.h +++ b/source/src/bot/bot.h @@ -44,7 +44,6 @@ #include "bot_util.h" #include "bot_waypoint.h" -extern bool dedserv; extern itemstat itemstats[]; #ifdef RELEASE_BUILD @@ -54,7 +53,7 @@ inline void debugbeam(vec &s, vec &e) { } #else inline void condebug(const char *s, int a = 0, int b = 0, int c = 0) { /*conoutf(s, a, b, c);*/ } inline void debugnav(const char *s, int a = 0, int b = 0, int c = 0) { /*conoutf(s, a, b, c);*/ } -inline void debugbeam(vec &s, vec &e) { /*if (!dedserv) particle_trail(1, 500, s, e);*/ } +inline void debugbeam(vec &s, vec &e) { /*particle_trail(1, 500, s, e);*/ } #endif #define JUMP_HEIGHT 4.0f // NOT accurate diff --git a/source/src/bot/bot_ai.cpp b/source/src/bot/bot_ai.cpp index 7e8a27b6..0d2c76a9 100644 --- a/source/src/bot/bot_ai.cpp +++ b/source/src/bot/bot_ai.cpp @@ -129,10 +129,10 @@ bool CBot::FindEnemy(void) float flDist, flNearestDist = 99999.9f; short EnemyVal, BestEnemyVal = -100; - // First loop through all players - loopv(players) + // First loop through all bots + loopv(bots) { - d = players[i]; // Handy shortcut + d = bots[i]; // Handy shortcut if (d == m_pMyEnt || !d || isteam(d->team, m_pMyEnt->team) || (d->state != CS_ALIVE)) continue; @@ -239,10 +239,10 @@ bool CBot::CheckHunt(void) short EnemyVal, BestEnemyVal = -100; vec BestOldPos; - // First loop through all players - loopv(players) + // First loop through all bots + loopv(bots) { - d = players[i]; // Handy shortcut + d = bots[i]; // Handy shortcut if (d == m_pMyEnt || !d || isteam(d->team, m_pMyEnt->team) || (d->state != CS_ALIVE)) continue; @@ -1953,10 +1953,10 @@ void CBot::HearSound(int n, vec *o) float flDist, flNearestDist = 3.0f; // Range of 3 units playerent *pNearest = NULL; - // Check all players first - loopv(players) + // Check all bots first + loopv(bots) { - playerent *d = players[i]; + playerent *d = bots[i]; if (d == m_pMyEnt || !d || (d->state != CS_ALIVE) || isteam(m_pMyEnt->team, d->team)) diff --git a/source/src/bot/bot_util.cpp b/source/src/bot/bot_util.cpp index 7c5136f6..aa966c69 100644 --- a/source/src/bot/bot_util.cpp +++ b/source/src/bot/bot_util.cpp @@ -208,11 +208,11 @@ void TraceLine(vec from, vec to, dynent *pTracer, bool CheckPlayers, traceresult if (CheckPlayers) { - // Check if the 'line' collides with players - loopv(players) + // Check if the 'line' collides with bots + loopv(bots) { - playerent *d = players[i]; - if(!d || (d==pTracer) || (d->state != CS_ALIVE)) continue; // Only check valid players + playerent *d = bots[i]; + if(!d || (d==pTracer) || (d->state != CS_ALIVE)) continue; // Only check valid bots flDist = GetDistance(from, d->o); @@ -476,15 +476,6 @@ bool IsInGame(dynent *d) { if (d == player1) return true; - else - { - loopv(players) - { - if (!players[i]) continue; - if (players[i] == d) - return true; - } - } } return false; } diff --git a/source/src/bot/bot_waypoint.cpp b/source/src/bot/bot_waypoint.cpp index 98e8b99e..3370574e 100644 --- a/source/src/bot/bot_waypoint.cpp +++ b/source/src/bot/bot_waypoint.cpp @@ -544,8 +544,6 @@ void CWaypointClass::SaveWPExpFile() void CWaypointClass::Think() { - if (dedserv) return; - #ifdef WP_FLOOD FloodThink(); #endif diff --git a/source/src/bot/botmanager.cpp b/source/src/bot/botmanager.cpp index 07892645..05feeebf 100644 --- a/source/src/bot/botmanager.cpp +++ b/source/src/bot/botmanager.cpp @@ -13,9 +13,6 @@ #include "cube.h" #include "bot.h" -bool dedserv = false; -#define CS_DEDHOST 0xFF - extern void respawnself(); CBotManager BotManager; @@ -74,13 +71,6 @@ void CBotManager::Think() } m_fReAddBotDelay = -1.0f; } - // If this is a ded server check if there are any players, if not bots should be idle - if (dedserv) - { - bool botsbeidle = true; - loopv(players) { if (players[i] && (players[i]->state != CS_DEDHOST)) { botsbeidle = false; break; } } - if (botsbeidle) return; - } // Let all bots 'think' loopv(bots) { @@ -168,20 +158,13 @@ const char *CBotManager::GetBotName() { ChoiceVal = 50; - loopv(players) - { - if (players[i] && (players[i]->state != CS_DEDHOST) && - !strcasecmp(players[i]->name, m_szBotNames[j])) - ChoiceVal -= 10; - } - loopv(bots) { if (bots[i] && (!strcasecmp(bots[i]->name, m_szBotNames[j]))) ChoiceVal -= 10; } - if ((player1->state != CS_DEDHOST) && !strcasecmp(player1->name, m_szBotNames[j])) + if (!strcasecmp(player1->name, m_szBotNames[j])) ChoiceVal -= 10; if (ChoiceVal <= 0) @@ -258,9 +241,9 @@ const char *CBotManager::GetBotTeam() { teamsize[player1->team]++; } - loopv(players) if(players[i] && team_isactive(players[i]->team)) + loopv(bots) if(bots[i] && team_isactive(bots[i]->team)) { - teamsize[players[i]->team]++; + teamsize[bots[i]->team]++; } biggestTeam = teamsize[1] > teamsize[0]; return teamnames[biggestTeam ^ 1]; @@ -275,12 +258,6 @@ const char *CBotManager::GetBotTeam() { ChoiceVal = 50; /* UNDONE? - loopv(players) - { - if (players[i] && (!strcasecmp(players[i]->name, m_szBotNames[j]))) - ChoiceVal -= 10; - } - loopv(bots) { if (bots[i] && (!strcasecmp(bots[i]->name, m_szBotNames[j])))