Quote:
Originally Posted by Powerlord
It's a matter of readability, not functionality. sCommand means 3 different things at different points:
|
I agree that separate variables would be awesome. However we don't have pointers in Pawn, so while it's an excuse for this, it's mine. If we could point to arrays with a single cell, that would make my day.
Quote:
Originally Posted by Powerlord
1. The command name at the first ReplyToCommand.
|
Said buffer is only used when argc is < 2 (If memory serves me right). This is there so we're not hard coding command names. At the bottom of the if (argc < 2), there should be a return Plugin_Handled, otherwise you've found a major issue! If so, thanks! It's there so if someone adds the alias sm_powerlordcvarsuppressionsuperawesomecomman d and points it to the function, no changes will be required and the same will happen.
Quote:
Originally Posted by Powerlord
2. The second argument at the StringToInt.
|
Totally! As you can see, the result of the operation on the buffer is stored to a cell with a value of 0 or 1. -1 if it's unknown or invalid.
Quote:
Originally Posted by Powerlord
3. The first argument at the second, third, and fourth ReplyToCommands.
|
Second argument to the second, third, and fourth ReplyToCommand. In this case it's changed to the cvar that it is suppressing.
Quote:
Originally Posted by Powerlord
This is one of those things that makes maintenance programmers (want to) kill previous programmers.
|
A better fitting name for the Array would be Junk or something I suppose? sCommand made sense as it's the command name for the first, then turns into the 2nd arg, and then the first. If this was C, I'd have 3 char pointers to show this, but it isn't. If I add comments would it help you? I normally do, but this was more of a "Oh, this doesn't exist. I'll share it." thing.
Quote:
Originally Posted by Powerlord
Speaking of functionality, it might be a good idea to check if the ConVar exists (checking FindConVar against INVALID_HANDLE) before adding it to the trie, returning common.phrases's "Unable to find cvar" phrase if not found:
PHP Code:
// In OnPluginStart LoadTranslations("common.phrases");
// in OnSupressConVar's case 0: new Handle:convar = FindConVar(sCommand); if (convar == INVALID_HANDLE) { ReplyToCommand(client, "%s%t", PLUGIN_PREFIX, "Unable to find cvar", sCommand); return Plugin_Handled; } else { CloseHandle(convar); }
|
Good idea! The only bad thing I can see coming from this is late loading a plugin then expecting the ConVar to be suppressed when this actually errored out.