Fixed autovacate thing once again.

Temporary disabled engine PVS & PAS checks for testing.
This commit is contained in:
jeefo 2016-11-01 23:57:51 +03:00
commit 10b89ca011
5 changed files with 24 additions and 16 deletions

View file

@ -1313,7 +1313,7 @@ public:
int GetIndex (edict_t *ent); int GetIndex (edict_t *ent);
Bot *GetBot (int index); Bot *GetBot (int index);
Bot *GetBot (edict_t *ent); Bot *GetBot (edict_t *ent);
Bot *FindOneValidAliveBot (void); Bot *GetAliveBot (void);
Bot *GetHighestFragsBot (int team); Bot *GetHighestFragsBot (int team);
int GetHumansNum (void); int GetHumansNum (void);

View file

@ -5868,12 +5868,14 @@ void Bot::ReactOnSound (void)
{ {
int hearEnemyIndex = -1; int hearEnemyIndex = -1;
#if 0
Vector pasOrg = EyePosition (); Vector pasOrg = EyePosition ();
if (pev->flags & FL_DUCKING) if (pev->flags & FL_DUCKING)
pasOrg = pasOrg + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN); pasOrg = pasOrg + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN);
uint8 *pas = ENGINE_SET_PAS (reinterpret_cast <float *> (&pasOrg)); uint8 *pas = ENGINE_SET_PAS (reinterpret_cast <float *> (&pasOrg));
#endif
float minDistance = 99999.0f; float minDistance = 99999.0f;
@ -5889,10 +5891,10 @@ void Bot::ReactOnSound (void)
if (distance > client.hearingDistance) if (distance > client.hearingDistance)
continue; continue;
#if 0
if (!ENGINE_CHECK_VISIBILITY (client.ent, pas)) if (!ENGINE_CHECK_VISIBILITY (client.ent, pas))
continue; continue;
#endif
if (distance < minDistance) if (distance < minDistance)
{ {
hearEnemyIndex = i; hearEnemyIndex = i;

View file

@ -238,6 +238,7 @@ bool Bot::LookupEnemy (void)
// ignore shielded enemies, while we have real one // ignore shielded enemies, while we have real one
edict_t *shieldEnemy = nullptr; edict_t *shieldEnemy = nullptr;
#if 0
// setup potentially visible set for this bot // setup potentially visible set for this bot
Vector potentialVisibility = EyePosition (); Vector potentialVisibility = EyePosition ();
@ -245,6 +246,7 @@ bool Bot::LookupEnemy (void)
potentialVisibility = potentialVisibility + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN); potentialVisibility = potentialVisibility + (VEC_HULL_MIN - VEC_DUCK_HULL_MIN);
uint8 *pvs = ENGINE_SET_PVS (reinterpret_cast <float *> (&potentialVisibility)); uint8 *pvs = ENGINE_SET_PVS (reinterpret_cast <float *> (&potentialVisibility));
#endif
// search the world for players... // search the world for players...
for (int i = 0; i < engine.MaxClients (); i++) for (int i = 0; i < engine.MaxClients (); i++)
@ -255,11 +257,11 @@ bool Bot::LookupEnemy (void)
continue; continue;
player = client.ent; player = client.ent;
#if 0
// let the engine check if this player is potentially visible // let the engine check if this player is potentially visible
if (!ENGINE_CHECK_VISIBILITY (player, pvs)) if (!ENGINE_CHECK_VISIBILITY (player, pvs))
continue; continue;
#endif
// do some blind by smoke grenade // do some blind by smoke grenade
if (m_blindRecognizeTime < engine.Time () && IsBehindSmokeClouds (player)) if (m_blindRecognizeTime < engine.Time () && IsBehindSmokeClouds (player))
{ {

View file

@ -969,7 +969,7 @@ void Engine::ProcessMessageCapture (void *ptr)
if (yb_communication_type.GetInt () == 2) if (yb_communication_type.GetInt () == 2)
{ {
Bot *notify = bots.FindOneValidAliveBot (); Bot *notify = bots.GetAliveBot ();
if (notify != nullptr && notify->m_notKilled) if (notify != nullptr && notify->m_notKilled)
notify->HandleChatterMessage (strVal); notify->HandleChatterMessage (strVal);
@ -988,7 +988,7 @@ void Engine::ProcessMessageCapture (void *ptr)
if (yb_communication_type.GetInt () == 2) if (yb_communication_type.GetInt () == 2)
{ {
Bot *notify = bots.FindOneValidAliveBot (); Bot *notify = bots.GetAliveBot ();
if (notify != nullptr && notify->m_notKilled) if (notify != nullptr && notify->m_notKilled)
notify->HandleChatterMessage (strVal); notify->HandleChatterMessage (strVal);
@ -1069,6 +1069,7 @@ void Engine::ProcessMessageCapture (void *ptr)
m_msgBlock.state++; // and finally update network message state m_msgBlock.state++; // and finally update network message state
} }
// console var registrator
ConVar::ConVar (const char *name, const char *initval, VarType type, bool regMissing, const char *regVal) : m_eptr (nullptr) ConVar::ConVar (const char *name, const char *initval, VarType type, bool regMissing, const char *regVal) : m_eptr (nullptr)
{ {
engine.PushVariableToStack (name, initval, type, regMissing, regVal, this); engine.PushVariableToStack (name, initval, type, regMissing, regVal, this);

View file

@ -275,7 +275,7 @@ Bot *BotManager::GetBot (edict_t *ent)
return GetBot (GetIndex (ent)); return GetBot (GetIndex (ent));
} }
Bot *BotManager::FindOneValidAliveBot (void) Bot *BotManager::GetAliveBot (void)
{ {
// this function finds one bot, alive bot :) // this function finds one bot, alive bot :)
@ -353,14 +353,14 @@ void BotManager::AddBot (const String &name, const String &difficulty, const Str
m_creationTab.Push (bot); m_creationTab.Push (bot);
} }
void BotManager::AdjustQuota (bool isPlayerConnection, edict_t *ent) void BotManager::AdjustQuota (bool isPlayerConnecting, edict_t *ent)
{ {
// this function increases or decreases bot quota amount depending on auto vacate variables // this function increases or decreases bot quota amount depending on auto vacate variables
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || GetBot (ent)) if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || IsValidBot (ent))
return; return;
if (isPlayerConnection) if (isPlayerConnecting)
{ {
if (yb_autovacate_smart_kick.GetBool ()) if (yb_autovacate_smart_kick.GetBool ())
AddPlayerToCheckTeamQueue (ent); AddPlayerToCheckTeamQueue (ent);
@ -370,15 +370,18 @@ void BotManager::AdjustQuota (bool isPlayerConnection, edict_t *ent)
m_balanceCount--; m_balanceCount--;
} }
} }
else if (m_balanceCount <= 0) else if (m_balanceCount < 0)
{ {
AddRandom (); AddRandom (false);
m_balanceCount++; m_balanceCount++;
} }
} }
void BotManager::AddPlayerToCheckTeamQueue (edict_t *ent) void BotManager::AddPlayerToCheckTeamQueue (edict_t *ent)
{ {
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || IsValidBot (ent))
return;
// entity must be unique // entity must be unique
bool hasFound = false; bool hasFound = false;
@ -397,8 +400,8 @@ void BotManager::AddPlayerToCheckTeamQueue (edict_t *ent)
void BotManager::VerifyPlayersHasJoinedTeam (int &desiredCount) void BotManager::VerifyPlayersHasJoinedTeam (int &desiredCount)
{ {
if (m_trackedPlayers.IsEmpty ()) if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || m_trackedPlayers.IsEmpty ())
return; return;
for (int i = 0; i < engine.MaxClients (); i++) for (int i = 0; i < engine.MaxClients (); i++)
{ {
@ -1082,7 +1085,7 @@ int BotManager::GetHumansJoinedTeam (void)
{ {
const Client &client = g_clients[i]; const Client &client = g_clients[i];
if ((client.flags & (CF_USED | CF_ALIVE)) && m_bots[i] == nullptr && client.team != SPECTATOR && !(client.ent->v.flags & FL_FAKECLIENT) && client.ent->v.movetype != MOVETYPE_FLY) if ((client.flags & (CF_USED | CF_ALIVE)) && m_bots[i] == nullptr && client.team != SPECTATOR && !(client.ent->v.flags & FL_FAKECLIENT))
count++; count++;
} }
return count; return count;