fix: unrelated client messages by resetting client command issuer, if not handled by the bot (related #360 )
This commit is contained in:
parent
e6fe2a6a22
commit
10db943cdf
2 changed files with 20 additions and 8 deletions
|
|
@ -217,6 +217,9 @@ public:
|
||||||
// for the server commands
|
// for the server commands
|
||||||
void handleEngineCommands ();
|
void handleEngineCommands ();
|
||||||
|
|
||||||
|
// wrapper for menus and commands
|
||||||
|
bool handleClientSideCommandsWrapper (edict_t *ent, bool isMenus);
|
||||||
|
|
||||||
// for the client commands
|
// for the client commands
|
||||||
bool handleClientCommands (edict_t *ent);
|
bool handleClientCommands (edict_t *ent);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1571,6 +1571,10 @@ bool BotControl::executeCommands () {
|
||||||
// do not allow to execute stuff for non admins
|
// do not allow to execute stuff for non admins
|
||||||
if (m_ent != game.getLocalEntity () && !(client.flags & ClientFlags::Admin)) {
|
if (m_ent != game.getLocalEntity () && !(client.flags & ClientFlags::Admin)) {
|
||||||
msg ("Access to %s commands is restricted.", product.name);
|
msg ("Access to %s commands is restricted.", product.name);
|
||||||
|
|
||||||
|
// reset issuer, but returns "true" to suppress "unknown command" message
|
||||||
|
setIssuer (nullptr);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1919,20 +1923,25 @@ void BotControl::handleEngineCommands () {
|
||||||
executeCommands ();
|
executeCommands ();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BotControl::handleClientCommands (edict_t *ent) {
|
bool BotControl::handleClientSideCommandsWrapper (edict_t *ent, bool isMenus) {
|
||||||
collectArgs ();
|
collectArgs ();
|
||||||
setIssuer (ent);
|
setIssuer (ent);
|
||||||
|
|
||||||
setFromConsole (true);
|
setFromConsole (!isMenus);
|
||||||
return executeCommands ();
|
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) {
|
bool BotControl::handleMenuCommands (edict_t *ent) {
|
||||||
collectArgs ();
|
return handleClientSideCommandsWrapper (ent, true);
|
||||||
setIssuer (ent);
|
|
||||||
|
|
||||||
setFromConsole (false);
|
|
||||||
return ctrl.executeMenus ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void BotControl::enableDrawModels (bool enable) {
|
void BotControl::enableDrawModels (bool enable) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue