From c298e607aef4236284f6a3c69a3aad4c4d53bb00 Mon Sep 17 00:00:00 2001 From: jeefo Date: Mon, 19 Feb 2024 23:16:03 +0300 Subject: [PATCH] fix: do not update fakeclient bit on every frame cfg: allow bots to have name with at least one character --- inc/manager.h | 6 +++--- src/botlib.cpp | 2 -- src/config.cpp | 2 +- src/manager.cpp | 7 ++++--- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/inc/manager.h b/inc/manager.h index 29fb035..daca54f 100644 --- a/inc/manager.h +++ b/inc/manager.h @@ -152,7 +152,7 @@ public: return m_lastWinner; } - int32_t getBotCount () { + int32_t getBotCount () const { return m_bots.length (); } @@ -197,7 +197,7 @@ public: m_botsCanPause = pause; } - bool hasBombSay (int type) { + bool hasBombSay (int type) const { return (m_bombSayStatus & type) == type; } @@ -243,7 +243,7 @@ public: } // some bots are online ? - bool hasBotsOnline () { + bool hasBotsOnline () const { return getBotCount () > 0; } diff --git a/src/botlib.cpp b/src/botlib.cpp index 087acba..b43ffc1 100644 --- a/src/botlib.cpp +++ b/src/botlib.cpp @@ -2832,8 +2832,6 @@ void Bot::checkParachute () { } void Bot::frame () { - pev->flags |= FL_FAKECLIENT; // restore fake client bit - if (m_updateTime <= game.time ()) { update (); } diff --git a/src/config.cpp b/src/config.cpp index d6b5156..96c7d7b 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -747,7 +747,7 @@ BotName *BotConfig::pickBotName () { for (size_t i = 0; i < m_botNames.length () * 2; ++i) { auto bn = &m_botNames.random (); - if (bn->name.length () < 3 || bn->usedBy != -1) { + if (bn->name.empty () || bn->usedBy != -1) { continue; } return bn; diff --git a/src/manager.cpp b/src/manager.cpp index 281c699..0d1bc20 100644 --- a/src/manager.cpp +++ b/src/manager.cpp @@ -263,7 +263,6 @@ BotCreateResult BotManager::create (StringRef name, int difficulty, int personal bot = engfuncs.pfnCreateFakeClient (resultName.chars ()); if (game.isNullEntity (bot)) { - ctrl.msg ("Maximum players reached (%d/%d). Unable to create Bot.", game.maxClients (), game.maxClients ()); return BotCreateResult::MaxPlayersReached; } auto object = cr::makeUnique (bot, difficulty, personality, team, skin); @@ -393,6 +392,8 @@ void BotManager::maintainQuota () { cv_quota.set (0); // reset quota } else if (createResult == BotCreateResult::MaxPlayersReached) { + ctrl.msg ("Maximum players reached (%d/%d). Unable to create Bot.", game.maxClients (), game.maxClients ()); + m_addRequests.clear (); // maximum players reached, so set quota to maximum players cv_quota.set (getBotCount ()); } @@ -1109,7 +1110,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int skin) { } MDLL_ClientPutInServer (bot); - bot->v.flags |= FL_FAKECLIENT; // set this player as fakeclient + bot->v.flags |= FL_CLIENT | FL_FAKECLIENT; // set this player as fake client // initialize all the variables for this bot... m_notStarted = true; // hasn't joined game yet @@ -1612,7 +1613,7 @@ void Bot::newRound () { startTask (Task::Normal, TaskPri::Normal, kInvalidNodeIndex, 0.0f, true); // restore fake client bit, just in case - pev->flags |= FL_FAKECLIENT; + pev->flags |= FL_CLIENT | FL_FAKECLIENT; if (rg.chance (50)) { pushChatterMessage (Chatter::NewRound);