# HG changeset patch # User David Anderson # Date 1187198088 0 # Node ID 2047dc42d80038df68fa06f69c4e13756f3e080a # Parent 9db842b7a9feadcb8dc9e3572e1d86a1c28a8231 fixed bug amb571 (FakeClientCommand having weird side effects) diff -r 9db842b7a9fe -r 2047dc42d800 core/ConCmdManager.cpp --- a/core/ConCmdManager.cpp Wed Aug 15 16:21:28 2007 +0000 +++ b/core/ConCmdManager.cpp Wed Aug 15 17:14:48 2007 +0000 @@ -155,11 +155,8 @@ 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 -r 9db842b7a9fe -r 2047dc42d800 core/ConCmdManager.h --- a/core/ConCmdManager.h Wed Aug 15 16:21:28 2007 +0000 +++ b/core/ConCmdManager.h Wed Aug 15 17:14:48 2007 +0000 @@ -115,7 +115,7 @@ 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 -r 9db842b7a9fe -r 2047dc42d800 core/MenuStyle_Radio.cpp --- a/core/MenuStyle_Radio.cpp Wed Aug 15 16:21:28 2007 +0000 +++ b/core/MenuStyle_Radio.cpp Wed Aug 15 17:14:48 2007 +0000 @@ -96,10 +96,8 @@ 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 -r 9db842b7a9fe -r 2047dc42d800 core/MenuStyle_Radio.h --- a/core/MenuStyle_Radio.h Wed Aug 15 16:21:28 2007 +0000 +++ b/core/MenuStyle_Radio.h Wed Aug 15 17:14:48 2007 +0000 @@ -70,7 +70,7 @@ 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 -r 9db842b7a9fe -r 2047dc42d800 core/MenuStyle_Valve.cpp --- a/core/MenuStyle_Valve.cpp Wed Aug 15 16:21:28 2007 +0000 +++ b/core/MenuStyle_Valve.cpp Wed Aug 15 17:14:48 2007 +0000 @@ -53,10 +53,8 @@ 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 -r 9db842b7a9fe -r 2047dc42d800 core/MenuStyle_Valve.h --- a/core/MenuStyle_Valve.h Wed Aug 15 16:21:28 2007 +0000 +++ b/core/MenuStyle_Valve.h Wed Aug 15 17:14:48 2007 +0000 @@ -59,7 +59,7 @@ { 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 -r 9db842b7a9fe -r 2047dc42d800 core/PlayerManager.cpp --- a/core/PlayerManager.cpp Wed Aug 15 16:21:28 2007 +0000 +++ b/core/PlayerManager.cpp Wed Aug 15 17:14:48 2007 +0000 @@ -535,23 +535,28 @@ 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 @@ RETURN_META(MRES_SUPERCEDE); } - res = g_ConCmds.DispatchClientCommand(client, (ResultType)res); + res = g_ConCmds.DispatchClientCommand(client, cmd, args, (ResultType)res); if (res >= Pl_Handled) {