Page MenuHomeWildfire Games

Add lobby help command and unify lobby commands
ClosedPublic

Authored by elexis on Apr 12 2017, 9:00 PM.

Details

Reviewers
vladislavbelov
Group Reviewers
Restricted Owners Package(Owns No Changed Paths)
Commits
rP19475: Move lobby chat commands in a global object and add /help command to explain…
Summary

Added /help command, commands moved to unified global list.

Glad to see any suggestions about descriptions of commands.

Test Plan
  1. Go to lobby
  2. Enter /help command
  3. Check that it's shown with a dependence on your role

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 1104
Build 1739: Vulcan BuildJenkins

Event Timeline

There are a very large number of changes, so older changes are hidden. Show Older Changes
vladislavbelov edited the summary of this revision. (Show Details)Apr 12 2017, 9:03 PM
Vulcan added a subscriber: Vulcan.Apr 12 2017, 9:45 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (305 tests).................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (305 tests).................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/751/ for more details.

elexis requested changes to this revision.Apr 13 2017, 12:47 AM

Looks good, nice structure!

We must test that it still works with the kick reason, can make you a temporary mod if you want.

binaries/data/mods/public/gui/lobby/lobby.js
214

All chat commands. A (...) sent.

218

to 'Away'

219

fat arrow function
every statement on a separate line

240

why not foo.privileges?
Does that role in actually work? Don't we need an indexOf there?

241

Will need a translation comment, otherwise transifex people don't know what the string means.

\n shouldn't be part of the translated string.

Oh wait, translate() missing too

1287

I've added those @params some time ago, but they are pointless. Comments should only be added if they add non-obvious information

This revision now requires changes to proceed.Apr 13 2017, 12:47 AM
elexis retitled this revision from Add help command and unified command to Add lobby help command and unify lobby commands.Apr 13 2017, 12:48 AM
vladislavbelov edited edge metadata.
vladislavbelov marked 6 inline comments as done.

Fixed elexis's comments, added some checks.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (305 tests).................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (305 tests).................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/754/ for more details.

elexis requested changes to this revision.Apr 14 2017, 9:31 PM
elexis added inline comments.
binaries/data/mods/public/gui/lobby/lobby.js
219

still arrow functions IMO

231

ban should be right below kick. Logical order trumps alphabetical order IMO

chat functions should be grouped too

234

Broken, kick is also supported if there is no reason given

235

(I guess someone would suggest using ...args, but this is good as is here)

250

Guess what's missing.

Also tooltip.js has this bug, but we shouldn't it repeat here to end a string with a colon and use a sprintf placeholder instead

252

(Alphabetical ordering could be done here, but it's probably better for the user too if it's grouped logically, no?)

255

That command is the command and description is the description is self-evident. What transifex people can't guess from the string itself is where it is used, so the important part of you Translation comment is that it's about chat commands. So perhaps "// Translation: Chat command help format" or something like that might work. Translation and code comments should only contain unique information

274

Either make those privileges properties a boolean or disable chat command if the role is "visitor" for muted people

971

Didn't check the regex voodoo, but perhaps ircSplit could be nuked too then? Perhaps a new regex function used in both places if that is easily possible?

1284

colorizeLobbyChatCommand to avoid name collisions?
Probably better to nuke the function, repeat the "color=" part in both calls but make the color a global variable, as that fits better with the other global color variables we have in this file

This revision now requires changes to proceed.Apr 14 2017, 9:31 PM
vladislavbelov edited edge metadata.
vladislavbelov marked 7 inline comments as done.

Added comments, function(args) replaced by args =>, commands disabled for muted people.

vladislavbelov added inline comments.Apr 15 2017, 6:15 PM
binaries/data/mods/public/gui/lobby/lobby.js
971

Also ircSplit couldn't nuked so far it's used. Also it has a little bit different task.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (305 tests).................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (305 tests).................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/774/ for more details.

elexis requested changes to this revision.Apr 17 2017, 4:19 AM
elexis added inline comments.
binaries/data/mods/public/gui/lobby/lobby.js
216

g_ChatCommands seems nicer, in particular since g_SpecialCommands sounds like there might be non-special commands. Change was approved by Vladislav in irc.

255

format can be inlined. The translation comment still works, even if there is a sprintf before, as long as the comment is on the line above.

Thanks for the better translation comment!

257

unneeded parenthesis

971

Since it is planned to hide the chat input altogehter for visitors, we don't need visitor checks anymore. They won't be able to /quit or /away manually anymore. Capitis Diminutio Maxima or so.

Might be nicer to have g_ChatCommands[cmd] N times instead of N-1 times + one occurance of`cmd in g_SpecialCommands` (approved by Vladislav on irc today)

971–973

(The conjugation of split is split, split split)

973

This fancy parsiong would be good for a command line tool, but it is not used for any of the current commands and it actually reduces the usability of the /kick /ban commands.

For example when typing /kick someDude You said "something bad" and then "something worse" therefore gtfo the kick reason will become "You said".

We want everything as given from after the nickname (second space, if that space exists)

1284

bump.

All the other colors are globals, so this one should be global too.
If we avoid the "color=" redundancy, then it should be done for all equally.

This revision now requires changes to proceed.Apr 17 2017, 4:19 AM

Would be nice to commit this, since the variable object is nicer to read IMO and I've already recommended the help command once when it didn't even exist

binaries/data/mods/public/gui/lobby/lobby.js
257

If you agree with the proposed change in D339 that visitors don't have chat input field anymore (which I encourage you to do as they should expect to not be able to type chat anymore), then this should become a moderator boolean until XMPP specs change

971
  • This visitor check is wrong as they could still use some commands like help or away, but the visitor check can be removed entirely if visitors won't be able to type chat anymore after D339
  • Not wrong currently, but g_ChatCommands[cmd] would be nicer to read
973

We want everything as given from after the nickname (second space, if that space exists)

1284

Nuke function + global color var

vladislavbelov added inline comments.Apr 28 2017, 2:46 PM
binaries/data/mods/public/gui/lobby/lobby.js
255

I don't want to call translate with same params for each command.

elexis added inline comments.Apr 28 2017, 4:35 PM
binaries/data/mods/public/gui/lobby/lobby.js
255

Not really a performance issue, it is cached in JS (and in C++ too):

function translate(message)
{
	var translation = g_translations[message];
	if (!translation)
		return g_translations[message] = Engine.Translate(message);
	return translation;
}

This function could even be simplified and the removal of creation of the variable could also be removed. (Don't know if the JIT is smart enough to do that on it's own).

I wrote D390 so that the unneeded variable creation in translate vanishes too. A JS cache of a JS cache (of a C++ cache) isn't that useful, we don't do that in the overwhelming majority of translate calls, especially if the function is called maybe 3 times per game and is done in microseconds either way, so can just have it shorter too.

To measure the exact number of microseconds that we would save, D190 could be used

vladislavbelov edited edge metadata.
vladislavbelov marked 7 inline comments as done.

Args have all string to line end, renamed SpecialCommands to ChatCommands.

Removed colorizeCommand.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/905/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/906/ for more details.

elexis commandeered this revision.Apr 29 2017, 5:40 AM
elexis edited reviewers, added: vladislavbelov; removed: elexis.

Notice this assumes all commands start with slash, so "@mute" as proposed by scythetwirler won't work but should be listed in theory

(Also chat commands are bad because noone knows they exist, so noone will know about /help either.
There should be a help button or question mark icon button that shows chat commands and ideally implement one button for each command.)

binaries/data/mods/public/gui/lobby/lobby.js
214

Those are 2 sentences, so no comma but period.
First sentence self-evident, so unneeded.

"if the command shouldn't be sent" kind of wrong, as the command is sent, but it is not sent as text after executing the command.

Better return true if the chat should be sent, so that the reader doesn't have to think about the negation.
(Could avoid return false; then and rely on implicit return on undefined, but better to specify it explicitly)

218

Why no capitalization + periods?

235

args[1] || "" is shorter than the ternary

If statements should be avoided too where possible to minimize cyclomatic complexity and nesting.

-> Engine.LobbyKick(args[0] || "", args[1] || ""); instead of

			if (args.length >= 1)
					Engine.LobbyKick(args[0], args.length >= 2 ? args[1] : "");
252

(Self-evident that it's a list -> "Chat commands")

253

(If we don't inline those role Engine.LobbyGetPlayerRole to delete the local variables and don't care about performance, then we could have one global and update it once D339 is in)

255

1-2 microseconds for calling translate() 10 times, without D390

257

Don't see how this was Done

269

s/usage/example since an example doesn't define the usage

270

args =>false

272

(This bloack should be merged with the "say" from the switch statement sometime)

Why do we actually have /say? It will just raise question what that command is useful for and the answer will be nothing.

But I recall asking that before 2015-12-03-QuakeNet-#0ad-dev.log:

22:00 < elexis> (uaaah, why do we have /say for the lobby)
22:01 <@leper> elexis: to /say /kick
273

It does not only display it but also sends the message to the room

292

At least move it above the code, so that we have a separation of data and logic.
Better move it to the other colors IMO.

Why does the name Lobby have to appear in the variable name? There is only lobby chat in the lobby

971

(Having g_ChatCommands[cmd] twice makes it easier to check as compared to two different terms)

976

Why isn't there a role check if we already added that information?

981

the command "foo" is not supported.
Are we actually sorry?

982

(Not an issue, but having the style consistent with the sprintf calls would be preferable)

1284

Removed function call but not the unused function

elexis updated this revision to Diff 1524.Apr 29 2017, 5:41 AM

See remarks above

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/917/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running release tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!
Running debug tests...
Running cxxtest tests (306 tests)..................................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/918/ for more details.

In D323#16113, @elexis wrote:

(Also chat commands are bad because noone knows they exist, so noone will know about /help either.
There should be a help button or question mark icon button that shows chat commands and ideally implement one button for each command.)

Should be, yes, we told about it, I want to split it, not add button and help together.

vladislavbelov accepted this revision.Apr 29 2017, 8:44 PM
This revision was automatically updated to reflect the committed changes.