From d2a4de7b09153abc8ce169a849257f7d67200b63 Mon Sep 17 00:00:00 2001 From: ds Date: Wed, 16 Sep 2020 21:04:22 +0300 Subject: [PATCH] fix: missing client check causing hlds crash. (fixes #159) --- src/botlib.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/botlib.cpp b/src/botlib.cpp index 1f66bdd..a20d3dc 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -5798,8 +5798,12 @@ bool Bot::isBombDefusing (const Vector &bombOrigin) { constexpr auto distanceToBomb = cr::square (140.0f); for (const auto &client : util.getClients ()) { + if (!(client.flags & ClientFlags::Used) || !(client.flags & ClientFlags::Alive)) { + continue; + } + auto bot = bots[client.ent]; - auto bombDistance = (client.ent->v.origin - bombOrigin).lengthSq (); + auto bombDistance = (client.origin - bombOrigin).lengthSq (); if (bot && !bot->m_notKilled) { if (m_team != bot->m_team || bot->getCurrentTaskId () == Task::EscapeFromBomb) { @@ -5815,7 +5819,7 @@ bool Bot::isBombDefusing (const Vector &bombOrigin) { } // take in account peoples too - if ((client.flags & ClientFlags::Used) && (client.flags & ClientFlags::Alive) && client.team == m_team) { + if (client.team == m_team) { // if close enough, mark as progressing if (bombDistance < distanceToBomb && ((client.ent->v.button | client.ent->v.oldbuttons) & IN_USE)) {