Hide MRES_SUPERCEDE from command hook callbacks.
This commit is contained in:
parent
b048dc7b10
commit
5757b729ac
@ -142,7 +142,9 @@ void CommandCallback(DISPATCH_ARGS)
|
|||||||
EngineArgs args(command);
|
EngineArgs args(command);
|
||||||
|
|
||||||
AutoEnterCommand autoEnterCommand(&args);
|
AutoEnterCommand autoEnterCommand(&args);
|
||||||
g_ConCmds.InternalDispatch(&args);
|
if (g_ConCmds.InternalDispatch(&args))
|
||||||
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
|
RETURN_META(MRES_IGNORED);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::SetCommandClient(int client)
|
void ConCmdManager::SetCommandClient(int client)
|
||||||
@ -216,7 +218,7 @@ ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int
|
|||||||
return (ResultType)result;
|
return (ResultType)result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConCmdManager::InternalDispatch(const ICommandArgs *args)
|
bool ConCmdManager::InternalDispatch(const ICommandArgs *args)
|
||||||
{
|
{
|
||||||
int client = m_CmdClient;
|
int client = m_CmdClient;
|
||||||
|
|
||||||
@ -224,7 +226,7 @@ void ConCmdManager::InternalDispatch(const ICommandArgs *args)
|
|||||||
{
|
{
|
||||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||||
if (!pPlayer || !pPlayer->IsConnected())
|
if (!pPlayer || !pPlayer->IsConnected())
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -242,11 +244,11 @@ void ConCmdManager::InternalDispatch(const ICommandArgs *args)
|
|||||||
* case-insensitive. We can't even use our sortedness.
|
* case-insensitive. We can't even use our sortedness.
|
||||||
*/
|
*/
|
||||||
if (client == 0 && !engine->IsDedicatedServer())
|
if (client == 0 && !engine->IsDedicatedServer())
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
ConCmdList::iterator item = FindInList(cmd);
|
ConCmdList::iterator item = FindInList(cmd);
|
||||||
if (item == m_CmdList.end())
|
if (item == m_CmdList.end())
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
pInfo = *item;
|
pInfo = *item;
|
||||||
}
|
}
|
||||||
@ -256,7 +258,7 @@ void ConCmdManager::InternalDispatch(const ICommandArgs *args)
|
|||||||
* "nicer" when we expose explicit say hooks.
|
* "nicer" when we expose explicit say hooks.
|
||||||
*/
|
*/
|
||||||
if (g_ChatTriggers.WasFloodedMessage())
|
if (g_ChatTriggers.WasFloodedMessage())
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
cell_t result = Pl_Continue;
|
cell_t result = Pl_Continue;
|
||||||
int argc = args->ArgC() - 1;
|
int argc = args->ArgC() - 1;
|
||||||
@ -308,11 +310,9 @@ void ConCmdManager::InternalDispatch(const ICommandArgs *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (result >= Pl_Handled)
|
if (result >= Pl_Handled)
|
||||||
{
|
return !pInfo->sourceMod;
|
||||||
if (!pInfo->sourceMod)
|
|
||||||
RETURN_META(MRES_SUPERCEDE);
|
return false;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
|
bool ConCmdManager::CheckAccess(int client, const char *cmd, AdminCmdInfo *pAdmin)
|
||||||
@ -604,9 +604,9 @@ ConCmdInfo *ConCmdManager::AddOrFindCommand(const char *name, const char *descri
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
TrackConCommandBase(pCmd, this);
|
TrackConCommandBase(pCmd, this);
|
||||||
CommandHook::Callback callback = [this] (const ICommandArgs *args) {
|
CommandHook::Callback callback = [this] (const ICommandArgs *args) -> bool {
|
||||||
AutoEnterCommand autoEnterCommand(args);
|
AutoEnterCommand autoEnterCommand(args);
|
||||||
this->InternalDispatch(args);
|
return this->InternalDispatch(args);
|
||||||
};
|
};
|
||||||
pInfo->sh_hook = sCoreProviderImpl.AddCommandHook(pCmd, callback);
|
pInfo->sh_hook = sCoreProviderImpl.AddCommandHook(pCmd, callback);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ public:
|
|||||||
bool LookForSourceModCommand(const char *cmd);
|
bool LookForSourceModCommand(const char *cmd);
|
||||||
bool LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags);
|
bool LookForCommandAdminFlags(const char *cmd, FlagBits *pFlags);
|
||||||
private:
|
private:
|
||||||
void InternalDispatch(const ICommandArgs *args);
|
bool InternalDispatch(const ICommandArgs *args);
|
||||||
ResultType RunAdminCommand(ConCmdInfo *pInfo, int client, int args);
|
ResultType RunAdminCommand(ConCmdInfo *pInfo, int client, int args);
|
||||||
ConCmdInfo *AddOrFindCommand(const char *name, const char *description, int flags);
|
ConCmdInfo *AddOrFindCommand(const char *name, const char *description, int flags);
|
||||||
void SetCommandClient(int client);
|
void SetCommandClient(int client);
|
||||||
|
@ -169,8 +169,10 @@ void CommandHook::Dispatch(DISPATCH_ARGS)
|
|||||||
EngineArgs args(command);
|
EngineArgs args(command);
|
||||||
|
|
||||||
AddRef();
|
AddRef();
|
||||||
callback_(&args);
|
bool rval = callback_(&args);
|
||||||
Release();
|
Release();
|
||||||
|
if (rval)
|
||||||
|
RETURN_META(MRES_SUPERCEDE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void CommandHook::Zap()
|
void CommandHook::Zap()
|
||||||
|
@ -65,7 +65,8 @@ class ICommandArgs;
|
|||||||
class CommandHook : public ke::Refcounted<CommandHook>
|
class CommandHook : public ke::Refcounted<CommandHook>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef ke::Lambda<void(const ICommandArgs *)> Callback;
|
// return false to RETURN_META(MRES_IGNORED), or true to SUPERCEDE.
|
||||||
|
typedef ke::Lambda<bool(const ICommandArgs *)> Callback;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
CommandHook(ConCommand *cmd, const Callback &callback, bool post);
|
CommandHook(ConCommand *cmd, const Callback &callback, bool post);
|
||||||
|
Loading…
Reference in New Issue
Block a user