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);
Bot *GetBot (int index);
Bot *GetBot (edict_t *ent);
Bot *FindOneValidAliveBot (void);
Bot *GetAliveBot (void);
Bot *GetHighestFragsBot (int team);
int GetHumansNum (void);

View file

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

View file

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

View file

@ -969,7 +969,7 @@ void Engine::ProcessMessageCapture (void *ptr)
if (yb_communication_type.GetInt () == 2)
{
Bot *notify = bots.FindOneValidAliveBot ();
Bot *notify = bots.GetAliveBot ();
if (notify != nullptr && notify->m_notKilled)
notify->HandleChatterMessage (strVal);
@ -988,7 +988,7 @@ void Engine::ProcessMessageCapture (void *ptr)
if (yb_communication_type.GetInt () == 2)
{
Bot *notify = bots.FindOneValidAliveBot ();
Bot *notify = bots.GetAliveBot ();
if (notify != nullptr && notify->m_notKilled)
notify->HandleChatterMessage (strVal);
@ -1069,6 +1069,7 @@ void Engine::ProcessMessageCapture (void *ptr)
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)
{
engine.PushVariableToStack (name, initval, type, regMissing, regVal, this);

View file

@ -275,7 +275,7 @@ Bot *BotManager::GetBot (edict_t *ent)
return GetBot (GetIndex (ent));
}
Bot *BotManager::FindOneValidAliveBot (void)
Bot *BotManager::GetAliveBot (void)
{
// 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);
}
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
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || GetBot (ent))
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || IsValidBot (ent))
return;
if (isPlayerConnection)
if (isPlayerConnecting)
{
if (yb_autovacate_smart_kick.GetBool ())
AddPlayerToCheckTeamQueue (ent);
@ -370,15 +370,18 @@ void BotManager::AdjustQuota (bool isPlayerConnection, edict_t *ent)
m_balanceCount--;
}
}
else if (m_balanceCount <= 0)
else if (m_balanceCount < 0)
{
AddRandom ();
AddRandom (false);
m_balanceCount++;
}
}
void BotManager::AddPlayerToCheckTeamQueue (edict_t *ent)
{
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || IsValidBot (ent))
return;
// entity must be unique
bool hasFound = false;
@ -397,8 +400,8 @@ void BotManager::AddPlayerToCheckTeamQueue (edict_t *ent)
void BotManager::VerifyPlayersHasJoinedTeam (int &desiredCount)
{
if (m_trackedPlayers.IsEmpty ())
return;
if (!engine.IsDedicatedServer () || !yb_autovacate.GetBool () || m_trackedPlayers.IsEmpty ())
return;
for (int i = 0; i < engine.MaxClients (); i++)
{
@ -1082,7 +1085,7 @@ int BotManager::GetHumansJoinedTeam (void)
{
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++;
}
return count;