De-fuckup the /help command handler.

- Put "/help " (with a space after it) in the history so that it's useful.
- Don't return the usage as an error, or the chat entry field
  won't clear. What the fucking fuck? Seriously, there was a 3-fucking-line
  comment in here about doing the right thing and someone ignored it
  and made it do the wrong thing.

SK has been doing the wrong thing in response to chat errors, and now I worry
that games that used to do the right thing have changed to do things
incorrectly because the fucking help command has been fucked up for 2 years.
This commit is contained in:
Ray J. Greenwell
2012-09-07 11:37:38 -07:00
parent 41fab5576e
commit ac9083dda5
@@ -1185,6 +1185,9 @@ public class ChatDirector extends BasicDirector
public String handleCommand (SpeakService speakSvc, String command,
String args, String[] history)
{
// put "/help " in the history
history[0] = command + " ";
String hcmd = "";
// grab the command they want help on
@@ -1203,20 +1206,24 @@ public class ChatDirector extends BasicDirector
// handle "/help help" and "/help someboguscommand"
Map<String, CommandHandler> possibleCommands = getCommandHandlers(hcmd);
String usage;
if (_handlers.get(hcmd) == this || possibleCommands.isEmpty()) {
return getUsage(command);
usage = getUsage(command);
} else if (possibleCommands.size() > 1) {
return getUsage(command, possibleCommands);
usage = getUsage(command, possibleCommands);
} else {
// if there is only one possible command display its usage
Map.Entry<String, CommandHandler> entry =
possibleCommands.entrySet().iterator().next();
usage = entry.getValue().getUsage(entry.getKey());
}
// if there is only one possible command display its usage
Map.Entry<String, CommandHandler> entry =
possibleCommands.entrySet().iterator().next();
// this is a little funny, but we display the feedback message by hand and return
// SUCCESS so that the chat entry field doesn't think that we've failed and
// preserve our command text
displayFeedback(null, entry.getValue().getUsage(entry.getKey()));
displayFeedback(null, usage);
return ChatCodes.SUCCESS;
}