diff --git a/core/ConCmdManager.cpp b/core/ConCmdManager.cpp index 2b2ea4b2..11133b09 100644 --- a/core/ConCmdManager.cpp +++ b/core/ConCmdManager.cpp @@ -155,11 +155,8 @@ void ConCmdManager::SetCommandClient(int client) m_CmdClient = client + 1; } -ResultType ConCmdManager::DispatchClientCommand(int client, ResultType type) +ResultType ConCmdManager::DispatchClientCommand(int client, const char *cmd, int args, ResultType type) { - const char *cmd = engine->Cmd_Argv(0); - int args = engine->Cmd_Argc() - 1; - ConCmdInfo *pInfo; if (sm_trie_retrieve(m_pCmds, cmd, (void **)&pInfo)) { diff --git a/core/ConCmdManager.h b/core/ConCmdManager.h index a456a47d..10dc54e7 100644 --- a/core/ConCmdManager.h +++ b/core/ConCmdManager.h @@ -115,7 +115,7 @@ public: int adminflags, const char *description, int flags); - ResultType DispatchClientCommand(int client, ResultType type); + ResultType DispatchClientCommand(int client, const char *cmd, int args, ResultType type); void UpdateAdminCmdFlags(const char *cmd, OverrideType type, FlagBits bits); bool LookForSourceModCommand(const char *cmd); bool CheckCommandAccess(int client, const char *cmd, FlagBits flags); diff --git a/core/MenuStyle_Radio.cpp b/core/MenuStyle_Radio.cpp index e2487af7..abf1eda8 100644 --- a/core/MenuStyle_Radio.cpp +++ b/core/MenuStyle_Radio.cpp @@ -96,10 +96,8 @@ bool CRadioStyle::IsSupported() return (g_ShowMenuId != -1); } -bool CRadioStyle::OnClientCommand(int client) +bool CRadioStyle::OnClientCommand(int client, const char *cmd) { - const char *cmd = engine->Cmd_Argv(0); - if (strcmp(cmd, "menuselect") == 0) { if (!m_players[client].bInMenu) diff --git a/core/MenuStyle_Radio.h b/core/MenuStyle_Radio.h index 23be7c51..ae8d7fd3 100644 --- a/core/MenuStyle_Radio.h +++ b/core/MenuStyle_Radio.h @@ -70,7 +70,7 @@ public: //IUserMessageListener void OnUserMessageSent(int msg_id); public: bool IsSupported(); - bool OnClientCommand(int client); + bool OnClientCommand(int client, const char *cmd); public: CRadioDisplay *MakeRadioDisplay(CRadioMenu *menu=NULL); void FreeRadioDisplay(CRadioDisplay *display); diff --git a/core/MenuStyle_Valve.cpp b/core/MenuStyle_Valve.cpp index d3347a5d..0ff81f0d 100644 --- a/core/MenuStyle_Valve.cpp +++ b/core/MenuStyle_Valve.cpp @@ -53,10 +53,8 @@ CBaseMenuPlayer *ValveMenuStyle::GetMenuPlayer(int client) return &m_players[client]; } -bool ValveMenuStyle::OnClientCommand(int client) +bool ValveMenuStyle::OnClientCommand(int client, const char *cmd) { - const char *cmd = engine->Cmd_Argv(0); - if (strcmp(cmd, "sm_vmenuselect") == 0) { int key_press = atoi(engine->Cmd_Argv(1)); diff --git a/core/MenuStyle_Valve.h b/core/MenuStyle_Valve.h index 83441e49..b4865700 100644 --- a/core/MenuStyle_Valve.h +++ b/core/MenuStyle_Valve.h @@ -59,7 +59,7 @@ class ValveMenuStyle : { public: ValveMenuStyle(); - bool OnClientCommand(int client); + bool OnClientCommand(int client, const char *cmd); public: //BaseMenuStyle CBaseMenuPlayer *GetMenuPlayer(int client); void SendDisplay(int client, IMenuPanel *display); diff --git a/core/PlayerManager.cpp b/core/PlayerManager.cpp index c559c2dd..7d221d94 100644 --- a/core/PlayerManager.cpp +++ b/core/PlayerManager.cpp @@ -535,23 +535,28 @@ void PlayerManager::OnClientDisconnect_Post(edict_t *pEntity) void PlayerManager::OnClientCommand(edict_t *pEntity) { + /** + * We cache this because the engine is not re-entrant. + */ + char cmd[300]; + int args = engine->Cmd_Argc() - 1; + strncopy(cmd, engine->Cmd_Argv(0), sizeof(cmd)); + int client = engine->IndexOfEdict(pEntity); cell_t res = Pl_Continue; - bool result = g_ValveMenuStyle.OnClientCommand(client); + bool result = g_ValveMenuStyle.OnClientCommand(client, cmd); if (result) { res = Pl_Handled; } else { - result = g_RadioMenuStyle.OnClientCommand(client); + result = g_RadioMenuStyle.OnClientCommand(client, cmd); if (result) { res = Pl_Handled; } } - int args = engine->Cmd_Argc() - 1; - cell_t res2 = Pl_Continue; m_clcommand->PushCell(client); m_clcommand->PushCell(args); @@ -567,7 +572,7 @@ void PlayerManager::OnClientCommand(edict_t *pEntity) RETURN_META(MRES_SUPERCEDE); } - res = g_ConCmds.DispatchClientCommand(client, (ResultType)res); + res = g_ConCmds.DispatchClientCommand(client, cmd, args, (ResultType)res); if (res >= Pl_Handled) {