Skip to content

Commit a381f24

Browse files
authored
Merge pull request #132 from Necktrox/fix/command-censoring
Censor onClientConsole for login command
2 parents be207c9 + 06c6cfd commit a381f24

File tree

1 file changed

+14
-34
lines changed

1 file changed

+14
-34
lines changed

Client/mods/deathmatch/ClientCommands.cpp

Lines changed: 14 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,13 @@ bool COMMAND_Executed ( const char* szCommand, const char* szArguments, bool bHa
3434
// Has the core already handled this command?
3535
if ( !bHandled )
3636
{
37-
//char szBuffer [256];
38-
CLuaArguments Arguments;
39-
4037
const char* szCommandBufferPointer = szCommand;
4138

4239
if ( !bHandleRemotely )
4340
{
4441
// Is the command "say" and the arguments start with '/' ? (command comes from the chatbox)
4542
if ( stricmp ( szCommand, "chatboxsay" ) == 0 )
4643
{
47-
/* This code seems redundant, the chatbox now properly simulates commands.
48-
// His line starts with '/'?
49-
if ( *szArguments == '/' )
50-
{
51-
// Copy the characters after the slash to the 0 terminator to a seperate buffer
52-
strncpy ( szBuffer, &szArguments [ 1 ], 256 );
53-
szBuffer [ 255 ] = 0;
54-
55-
// Split it into command and arguments
56-
char* szNewCommand = strtok ( szBuffer, " " );
57-
char* szNewArguments = strtok ( NULL, "\0" );
58-
if ( szNewCommand )
59-
{
60-
// Execute it as another command
61-
if ( szNewArguments )
62-
{
63-
g_pCore->GetCommands ()->Execute ( szNewCommand, szNewArguments );
64-
}
65-
else
66-
{
67-
g_pCore->GetCommands ()->Execute ( szNewCommand, "" );
68-
}
69-
70-
return true;
71-
}
72-
}
73-
*/
7444
szCommandBufferPointer = "say";
7545
}
7646
}
@@ -90,11 +60,21 @@ bool COMMAND_Executed ( const char* szCommand, const char* szArguments, bool bHa
9060
g_pClientGame->GetRegisteredCommands ()->ProcessCommand ( szCommandBufferPointer, szArguments );
9161

9262
// Call the onClientConsole event
93-
Arguments.PushString ( strClumpedCommand );
63+
auto pLocalPlayer = g_pClientGame->GetLocalPlayer();
64+
65+
if ( pLocalPlayer ) {
66+
CLuaArguments Arguments;
67+
68+
// Censor input for /login command
69+
if ( !stricmp( szCommandBufferPointer, "login" ) ) {
70+
Arguments.PushString( SString( "%s ***", szCommandBufferPointer ) );
71+
}
72+
else {
73+
Arguments.PushString( strClumpedCommand );
74+
}
9475

95-
// Call the event on the local player's onClientConsole first
96-
if ( g_pClientGame->GetLocalPlayer () )
97-
g_pClientGame->GetLocalPlayer ()->CallEvent ( "onClientConsole", Arguments, true );
76+
pLocalPlayer->CallEvent( "onClientConsole", Arguments, true );
77+
}
9878

9979
// Write the chatlength and the content
10080
NetBitStreamInterface* pBitStream = g_pNet->AllocateNetBitStream ();

0 commit comments

Comments
 (0)