fix: do not update fakeclient bit on every frame

cfg: allow bots to have name with at least one character
This commit is contained in:
jeefo 2024-02-19 23:16:03 +03:00
commit c298e607ae
No known key found for this signature in database
GPG key ID: 927BCA0779BEA8ED
4 changed files with 8 additions and 9 deletions

View file

@ -152,7 +152,7 @@ public:
return m_lastWinner;
}
int32_t getBotCount () {
int32_t getBotCount () const {
return m_bots.length <int32_t> ();
}
@ -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;
}

View file

@ -2832,8 +2832,6 @@ void Bot::checkParachute () {
}
void Bot::frame () {
pev->flags |= FL_FAKECLIENT; // restore fake client bit
if (m_updateTime <= game.time ()) {
update ();
}

View file

@ -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;

View file

@ -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> (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);