fix: unrelated client messages by resetting client command issuer, if not handled by the bot (related #360 )

This commit is contained in:
dmitry 2022-09-10 15:47:41 +03:00
commit 10db943cdf
No known key found for this signature in database
GPG key ID: 8297CE728B7A7E37
2 changed files with 20 additions and 8 deletions

View file

@ -1571,6 +1571,10 @@ bool BotControl::executeCommands () {
// do not allow to execute stuff for non admins
if (m_ent != game.getLocalEntity () && !(client.flags & ClientFlags::Admin)) {
msg ("Access to %s commands is restricted.", product.name);
// reset issuer, but returns "true" to suppress "unknown command" message
setIssuer (nullptr);
return true;
}
@ -1919,20 +1923,25 @@ void BotControl::handleEngineCommands () {
executeCommands ();
}
bool BotControl::handleClientCommands (edict_t *ent) {
bool BotControl::handleClientSideCommandsWrapper (edict_t *ent, bool isMenus) {
collectArgs ();
setIssuer (ent);
setFromConsole (true);
return executeCommands ();
setFromConsole (!isMenus);
auto result = isMenus ? executeMenus () : executeCommands ();
if (!result) {
setIssuer (nullptr);
}
return result;
}
bool BotControl::handleClientCommands (edict_t *ent) {
return handleClientSideCommandsWrapper (ent, false);
}
bool BotControl::handleMenuCommands (edict_t *ent) {
collectArgs ();
setIssuer (ent);
setFromConsole (false);
return ctrl.executeMenus ();
return handleClientSideCommandsWrapper (ent, true);
}
void BotControl::enableDrawModels (bool enable) {