diff --git a/inc/yapb.h b/inc/yapb.h index aa1760d..16d922c 100644 --- a/inc/yapb.h +++ b/inc/yapb.h @@ -822,6 +822,7 @@ private: bool updateLiftStates (); bool canRunHeavyWeight (); + void markStale (); void instantChatter (int type); void update (); void runMovement (); diff --git a/src/linkage.cpp b/src/linkage.cpp index 5c61d76..8f892cf 100644 --- a/src/linkage.cpp +++ b/src/linkage.cpp @@ -55,6 +55,13 @@ namespace variadic { // sometimes actually by their side, that's why we strongly recommend to check it here too. In // case it's a bot asking for a client command, we handle it like we do for bot commands + if (game.isNullEntity (ent)) { + if (game.is (GameFlags::Metamod)) { + RETURN_META (MRES_SUPERCEDE); + } + return; + } + va_list ap; auto buffer = strings.chars (); @@ -62,7 +69,7 @@ namespace variadic { vsnprintf (buffer, StringBuffer::StaticBufferSize, format, ap); va_end (ap); - if (util.isFakeClient (ent)) { + if (util.isFakeClient (ent) || (ent->v.flags & FL_DORMANT)) { auto bot = bots[ent]; if (bot) { @@ -227,9 +234,6 @@ CR_EXPORT int GetEntityAPI (gamefuncs_t *table, int) { for (auto &bot : bots) { if (bot->pev == &ent->v) { - bot->showChaterIcon (false); - - conf.clearUsedName (bot.get ()); // clear the bot name bots.erase (bot.get ()); // remove the bot from bots array break; diff --git a/src/manager.cpp b/src/manager.cpp index eb53acd..36a4eb9 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -1112,6 +1112,11 @@ bool BotManager::isTeamStacked (int team) { void BotManager::erase (Bot *bot) { for (auto &e : m_bots) { if (e.get () == bot) { + bot->showChaterIcon (false); + bot->markStale (); + + conf.clearUsedName (bot); // clear the bot name + e.reset (); m_bots.remove (e); // remove from bots array @@ -1418,14 +1423,20 @@ void Bot::kick () { if (!(pev->flags & FL_CLIENT) || strings.isEmpty (username)) { return; } - - // clear fakeclient bit - pev->flags &= ~FL_FAKECLIENT; + markStale (); game.serverCommand ("kick \"%s\"", username); ctrl.msg ("Bot '%s' kicked.", username); } +void Bot::markStale () { + // clear fakeclient bit + pev->flags &= ~FL_FAKECLIENT; + + // make as not receiveing any messages + pev->flags |= FL_DORMANT; +} + void Bot::updateTeamJoin () { // this function handles the selection of teams & class