fix: clear grenade pointers before checking active grenades (ref #436)

This commit is contained in:
jeefo 2023-04-17 12:59:26 +03:00
commit 048f47e863
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED

View file

@ -122,10 +122,6 @@ bool Bot::seesEntity (const Vector &dest, bool fromBody) {
void Bot::avoidGrenades () {
// checks if bot 'sees' a grenade, and avoid it
if (!bots.hasActiveGrenades ()) {
return;
}
// check if old pointers to grenade is invalid
if (game.isNullEntity (m_avoidGrenade)) {
m_avoidGrenade = nullptr;
@ -135,6 +131,10 @@ void Bot::avoidGrenades () {
m_avoidGrenade = nullptr;
m_needAvoidGrenade = 0;
}
if (!bots.hasActiveGrenades ()) {
return;
}
auto &activeGrenades = bots.getActiveGrenades ();
// find all grenades on the map
@ -158,11 +158,7 @@ void Bot::avoidGrenades () {
m_preventFlashing = game.time () + rg.get (1.0f, 2.0f);
}
}
else if (strcmp (model, "hegrenade.mdl") == 0) {
if (!game.isNullEntity (m_avoidGrenade)) {
continue;
}
else if (game.isNullEntity (m_avoidGrenade) && strcmp (model, "hegrenade.mdl") == 0) {
if (game.getTeam (pent->v.owner) == m_team || pent->v.owner == ent ()) {
continue;
}