Skip to content

Commit 5425520

Browse files
committed
Applying FileEx's reviews
1 parent f7fcde0 commit 5425520

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Client/mods/deathmatch/logic/CRegisteredCommands.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
*****************************************************************************/
1010

1111
#include "StdInc.h"
12+
#include "CClientGame.h"
1213

1314
using std::list;
1415

@@ -27,6 +28,12 @@ bool CRegisteredCommands::AddCommand(CLuaMain* pLuaMain, const char* szKey, cons
2728
assert(pLuaMain);
2829
assert(szKey);
2930

31+
if (CommandExists(szKey, NULL))
32+
{
33+
g_pClientGame->GetScriptDebugging()->LogWarning(pLuaMain->GetVM(), "addCommandHandler: Attempt to register duplicate command '%s'", szKey);
34+
return false;
35+
}
36+
3037
// Check if we already have this key and handler
3138
SCommand* pCommand = GetCommand(szKey, pLuaMain);
3239
if (pCommand)

Server/mods/deathmatch/logic/CRegisteredCommands.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include "CClient.h"
1919
#include "CConsoleClient.h"
2020
#include "CPlayer.h"
21+
#include "CGame.h"
22+
#include "CScriptDebugging.h"
2123

2224
CRegisteredCommands::CRegisteredCommands(CAccessControlListManager* pACLManager)
2325
{
@@ -35,11 +37,17 @@ bool CRegisteredCommands::AddCommand(CLuaMain* pLuaMain, const char* szKey, cons
3537
assert(pLuaMain);
3638
assert(szKey);
3739

40+
if (CommandExists(szKey, NULL))
41+
{
42+
g_pGame->GetScriptDebugging()->LogWarning(pLuaMain->GetVM(), "addCommandHandler: Attempt to register duplicate command '%s'", szKey);
43+
return false;
44+
}
45+
3846
// Check if we already have this key and handler
3947
SCommand* pCommand = GetCommand(szKey, pLuaMain);
4048

4149
if (pCommand && iLuaFunction == pCommand->iLuaFunction)
42-
return false;
50+
return false;
4351

4452
// Create the entry
4553
pCommand = new SCommand;

0 commit comments

Comments
 (0)