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:
parent
ccfbb5479d
commit
c298e607ae
4 changed files with 8 additions and 9 deletions
|
|
@ -152,7 +152,7 @@ public:
|
||||||
return m_lastWinner;
|
return m_lastWinner;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t getBotCount () {
|
int32_t getBotCount () const {
|
||||||
return m_bots.length <int32_t> ();
|
return m_bots.length <int32_t> ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -197,7 +197,7 @@ public:
|
||||||
m_botsCanPause = pause;
|
m_botsCanPause = pause;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasBombSay (int type) {
|
bool hasBombSay (int type) const {
|
||||||
return (m_bombSayStatus & type) == type;
|
return (m_bombSayStatus & type) == type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -243,7 +243,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// some bots are online ?
|
// some bots are online ?
|
||||||
bool hasBotsOnline () {
|
bool hasBotsOnline () const {
|
||||||
return getBotCount () > 0;
|
return getBotCount () > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2832,8 +2832,6 @@ void Bot::checkParachute () {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bot::frame () {
|
void Bot::frame () {
|
||||||
pev->flags |= FL_FAKECLIENT; // restore fake client bit
|
|
||||||
|
|
||||||
if (m_updateTime <= game.time ()) {
|
if (m_updateTime <= game.time ()) {
|
||||||
update ();
|
update ();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -747,7 +747,7 @@ BotName *BotConfig::pickBotName () {
|
||||||
for (size_t i = 0; i < m_botNames.length () * 2; ++i) {
|
for (size_t i = 0; i < m_botNames.length () * 2; ++i) {
|
||||||
auto bn = &m_botNames.random ();
|
auto bn = &m_botNames.random ();
|
||||||
|
|
||||||
if (bn->name.length () < 3 || bn->usedBy != -1) {
|
if (bn->name.empty () || bn->usedBy != -1) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
return bn;
|
return bn;
|
||||||
|
|
|
||||||
|
|
@ -263,7 +263,6 @@ BotCreateResult BotManager::create (StringRef name, int difficulty, int personal
|
||||||
bot = engfuncs.pfnCreateFakeClient (resultName.chars ());
|
bot = engfuncs.pfnCreateFakeClient (resultName.chars ());
|
||||||
|
|
||||||
if (game.isNullEntity (bot)) {
|
if (game.isNullEntity (bot)) {
|
||||||
ctrl.msg ("Maximum players reached (%d/%d). Unable to create Bot.", game.maxClients (), game.maxClients ());
|
|
||||||
return BotCreateResult::MaxPlayersReached;
|
return BotCreateResult::MaxPlayersReached;
|
||||||
}
|
}
|
||||||
auto object = cr::makeUnique <Bot> (bot, difficulty, personality, team, skin);
|
auto object = cr::makeUnique <Bot> (bot, difficulty, personality, team, skin);
|
||||||
|
|
@ -393,6 +392,8 @@ void BotManager::maintainQuota () {
|
||||||
cv_quota.set (0); // reset quota
|
cv_quota.set (0); // reset quota
|
||||||
}
|
}
|
||||||
else if (createResult == BotCreateResult::MaxPlayersReached) {
|
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
|
m_addRequests.clear (); // maximum players reached, so set quota to maximum players
|
||||||
cv_quota.set (getBotCount ());
|
cv_quota.set (getBotCount ());
|
||||||
}
|
}
|
||||||
|
|
@ -1109,7 +1110,7 @@ Bot::Bot (edict_t *bot, int difficulty, int personality, int team, int skin) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MDLL_ClientPutInServer (bot);
|
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...
|
// initialize all the variables for this bot...
|
||||||
m_notStarted = true; // hasn't joined game yet
|
m_notStarted = true; // hasn't joined game yet
|
||||||
|
|
@ -1612,7 +1613,7 @@ void Bot::newRound () {
|
||||||
startTask (Task::Normal, TaskPri::Normal, kInvalidNodeIndex, 0.0f, true);
|
startTask (Task::Normal, TaskPri::Normal, kInvalidNodeIndex, 0.0f, true);
|
||||||
|
|
||||||
// restore fake client bit, just in case
|
// restore fake client bit, just in case
|
||||||
pev->flags |= FL_FAKECLIENT;
|
pev->flags |= FL_CLIENT | FL_FAKECLIENT;
|
||||||
|
|
||||||
if (rg.chance (50)) {
|
if (rg.chance (50)) {
|
||||||
pushChatterMessage (Chatter::NewRound);
|
pushChatterMessage (Chatter::NewRound);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue