fixed bomb defuse check doesn't verify pressing IN_USE button of client

fixed potential crash bug in IsPointOccupied
processing global refactoring
This commit is contained in:
jeefo 2016-03-01 22:52:17 +03:00
commit d5a8b3642b
18 changed files with 717 additions and 739 deletions

View file

@ -48,7 +48,7 @@ int Bot::GetNearbyEnemiesNearPosition(const Vector &origin, float radius)
bool Bot::IsEnemyHiddenByRendering (edict_t *enemy)
{
if (IsEntityNull (enemy) || !yb_check_enemy_rendering.GetBool ())
if (IsNullEntity (enemy) || !yb_check_enemy_rendering.GetBool ())
return false;
entvars_t &v = enemy->v;
@ -183,7 +183,7 @@ bool Bot::CheckVisibility (edict_t *target, Vector *origin, byte *bodyPart)
bool Bot::IsEnemyViewable (edict_t *player)
{
if (IsEntityNull (player))
if (IsNullEntity (player))
return false;
bool forceTrueIfVisible = false;
@ -218,7 +218,7 @@ bool Bot::LookupEnemy (void)
if (m_seeEnemyTime + 3.0f < engine.Time ())
m_states &= ~STATE_SUSPECT_ENEMY;
if (!IsEntityNull (m_enemy) && m_enemyUpdateTime > engine.Time ())
if (!IsNullEntity (m_enemy) && m_enemyUpdateTime > engine.Time ())
{
player = m_enemy;
@ -228,7 +228,7 @@ bool Bot::LookupEnemy (void)
}
// the old enemy is no longer visible or
if (IsEntityNull (newEnemy))
if (IsNullEntity (newEnemy))
{
m_enemyUpdateTime = engine.Time () + 0.5f;
@ -289,7 +289,7 @@ bool Bot::LookupEnemy (void)
}
}
if (IsEntityNull (newEnemy) && !IsEntityNull (shieldEnemy))
if (IsNullEntity (newEnemy) && !IsNullEntity (shieldEnemy))
newEnemy = shieldEnemy;
}
@ -314,7 +314,7 @@ bool Bot::LookupEnemy (void)
}
else
{
if (m_seeEnemyTime + 3.0 < engine.Time () && (m_hasC4 || HasHostage () || !IsEntityNull (m_targetEntity)))
if (m_seeEnemyTime + 3.0 < engine.Time () && (m_hasC4 || HasHostage () || !IsNullEntity (m_targetEntity)))
RadioMessage (Radio_EnemySpotted);
m_targetEntity = NULL; // stop following when we see an enemy...
@ -345,7 +345,7 @@ bool Bot::LookupEnemy (void)
Bot *friendBot = bots.GetBot (g_clients[j].ent);
if (friendBot != NULL && friendBot->m_seeEnemyTime + 2.0f < engine.Time () && IsEntityNull (friendBot->m_lastEnemy) && IsVisible (pev->origin, ENT (friendBot->pev)) && friendBot->IsInViewCone (pev->origin))
if (friendBot != NULL && friendBot->m_seeEnemyTime + 2.0f < engine.Time () && IsNullEntity (friendBot->m_lastEnemy) && IsVisible (pev->origin, ENT (friendBot->pev)) && friendBot->IsInViewCone (pev->origin))
{
friendBot->m_lastEnemy = newEnemy;
friendBot->m_lastEnemyOrigin = m_lastEnemyOrigin;
@ -357,7 +357,7 @@ bool Bot::LookupEnemy (void)
return true;
}
}
else if (!IsEntityNull (m_enemy))
else if (!IsNullEntity (m_enemy))
{
newEnemy = m_enemy;
m_lastEnemy = newEnemy;
@ -406,7 +406,7 @@ bool Bot::LookupEnemy (void)
}
// check if bots should reload...
if ((m_aimFlags <= AIM_PREDICT_PATH && m_seeEnemyTime + 3.0f < engine.Time () && !(m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) && IsEntityNull (m_lastEnemy) && IsEntityNull (m_enemy) && GetTaskId () != TASK_SHOOTBREAKABLE && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) || g_roundEnded)
if ((m_aimFlags <= AIM_PREDICT_PATH && m_seeEnemyTime + 3.0f < engine.Time () && !(m_states & (STATE_SEEING_ENEMY | STATE_HEARING_ENEMY)) && IsNullEntity (m_lastEnemy) && IsNullEntity (m_enemy) && GetTaskId () != TASK_SHOOTBREAKABLE && GetTaskId () != TASK_PLANTBOMB && GetTaskId () != TASK_DEFUSEBOMB) || g_roundEnded)
{
if (!m_reloadState)
m_reloadState = RELOAD_PRIMARY;
@ -560,7 +560,7 @@ bool Bot::IsFriendInLineOfFire (float distance)
engine.TestLine (EyePosition (), EyePosition () + 10000.0f * pev->v_angle, TRACE_IGNORE_NONE, GetEntity (), &tr);
// check if we hit something
if (!IsEntityNull (tr.pHit) && tr.pHit != g_worldEntity)
if (!IsNullEntity (tr.pHit) && tr.pHit != g_worldEntity)
{
int playerIndex = IndexOfEntity (tr.pHit) - 1;
@ -731,7 +731,7 @@ void Bot::FireWeapon (void)
}
// or if friend in line of fire, stop this too but do not update shoot time
if (!IsEntityNull (m_enemy))
if (!IsNullEntity (m_enemy))
{
if (IsFriendInLineOfFire (distance))
{
@ -753,7 +753,7 @@ void Bot::FireWeapon (void)
goto WeaponSelectEnd;
// use knife if near and good difficulty (l33t dude!)
if (m_difficulty >= 3 && pev->health > 80.0f && !IsEntityNull (enemy) && pev->health >= enemy->v.health && distance < 100.0f && !IsOnLadder () && !IsGroupOfEnemies (pev->origin))
if (m_difficulty >= 3 && pev->health > 80.0f && !IsNullEntity (enemy) && pev->health >= enemy->v.health && distance < 100.0f && !IsOnLadder () && !IsGroupOfEnemies (pev->origin))
goto WeaponSelectEnd;
// loop through all the weapons until terminator is found...
@ -844,7 +844,7 @@ WeaponSelectEnd:
{
if (distance >= 750.0f && !IsShieldDrawn ())
pev->button |= IN_ATTACK2; // draw the shield
else if (IsShieldDrawn () || (!IsEntityNull (m_enemy) && ((m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable(m_enemy))))
else if (IsShieldDrawn () || (!IsNullEntity (m_enemy) && ((m_enemy->v.button & IN_RELOAD) || !IsEnemyViewable(m_enemy))))
pev->button |= IN_ATTACK2; // draw out the shield
m_shieldCheckTime = engine.Time () + 1.0f;
@ -863,7 +863,7 @@ WeaponSelectEnd:
m_zoomCheckTime = engine.Time ();
if (!IsEntityNull (m_enemy) && (m_states & STATE_SEEING_ENEMY))
if (!IsNullEntity (m_enemy) && (m_states & STATE_SEEING_ENEMY))
{
m_moveSpeed = 0.0f;
m_strafeSpeed = 0.0f;
@ -1011,7 +1011,7 @@ void Bot::FocusEnemy (void)
void Bot::CombatFight (void)
{
// no enemy? no need to do strafing
if (IsEntityNull (m_enemy))
if (IsNullEntity (m_enemy))
return;
float distance = (m_lookAt - EyePosition ()).GetLength2D (); // how far away is the enemy scum?
@ -1223,7 +1223,7 @@ bool Bot::IsEnemyProtectedByShield (edict_t *enemy)
{
// this function returns true, if enemy protected by the shield
if (IsEntityNull (enemy) || IsShieldDrawn ())
if (IsNullEntity (enemy) || IsShieldDrawn ())
return false;
// check if enemy has shield and this shield is drawn
@ -1408,12 +1408,12 @@ int Bot::GetHighestWeapon (void)
void Bot::SelectWeaponByName (const char *name)
{
FakeClientCommand (GetEntity (), name);
engine.IssueBotCommand (GetEntity (), name);
}
void Bot::SelectWeaponbyNumber (int num)
{
FakeClientCommand (GetEntity (), g_weaponSelect[num].weaponName);
engine.IssueBotCommand (GetEntity (), g_weaponSelect[num].weaponName);
}
void Bot::AttachToUser (void)