Opened 9 years ago

Closed 8 years ago

#3383 closed defect (fixed)

[PATCH] Lobby - coding convention

Reported by: elexis Owned by: elexis
Priority: Should Have Milestone: Alpha 20
Component: Multiplayer lobby Keywords: patch
Cc: Patch:

Description

  • object keys should be quoted
  • objects should have a space after { and before }
  • global variables should have a capital letter following the g_ prefix
  • constants should be declared as such
  • each is deprecated
  • trailing whitespace should be removed

Attachments (4)

lobby_coding_convention_v1.patch (23.3 KB ) - added by elexis 9 years ago.
for ... of unfortunately doesn't work with g_SpamMonitor), so I used for ... in there.
lobby_coding_convention_v2.patch (33.4 KB ) - added by elexis 9 years ago.
More cleanup as discussed in IRC.
lobby_coding_convention_v3.patch (50.1 KB ) - added by elexis 9 years ago.
lobby_coding_convention_v4.patch (49.5 KB ) - added by elexis 9 years ago.

Download all attachments as: .zip

Change History (16)

by elexis, 9 years ago

for ... of unfortunately doesn't work with g_SpamMonitor), so I used for ... in there.

by elexis, 9 years ago

More cleanup as discussed in IRC.

by elexis, 9 years ago

comment:1 by elexis, 9 years ago

  • Fixed moderator translation (where translate was called on arbitrary strings after converting them to uppercase)
  • moved color hardcoding to constants
  • removed pony-colors and the ability to colorize every character of usernames individually o.O
  • eliminated useless variables
  • early returns
  • fat arrows
  • let instead of var
  • refactored commonly used functions like colorize(), setSenderFont() and returnToMainMenu()

by elexis, 9 years ago

comment:2 by elexis, 9 years ago

Some minor changes after a review by leper on september 1st in irc:

  • Removed the "invalid nick" check which should be prohibited in the Xmpp server, not in the GUI of the client
  • Simplified the object key substitutions in addChatMessage
  • Moved the bracket for the Engine.PushGuiPage calls and new global arrays
  • Doesn't introduce a setFont function, but explicitly adds the "[font='...']" + txt + "[/font]" tags. I still think we should refactor that, but that should happen in a new ticket then as these tags are added in like 60 lines.
  • That "gone" state exists and you reproduce it by joining with a regular xmpp client and setting your state to "extended away".
  • Removes some newlines

comment:3 by elexis, 9 years ago

Keywords: review removed
Milestone: Alpha 19Alpha 20

Too much to rebase and review for the remaining a19 time, also no benefits to the user, only to devs.

Last edited 9 years ago by elexis (previous) (diff)

comment:4 by elexis, 8 years ago

In 17316:

Lobby cleanup.

Designate constants as such.
Comply with naming convention for globals.
Quote object keys.
Add few JSDoc comments.

Refs #3383.

comment:5 by elexis, 8 years ago

In 17359:

Renames to g_MapSizes, g_UserRating and g_SpamMonitor. Refs #3383 #3440

comment:6 by elexis, 8 years ago

In 17360:

Remove useless global g_SpecialKey. Refs #3383

comment:7 by elexis, 8 years ago

In 17364:

Add JSdoc comments to all lobby globals and remove g_MapSizes because it is only used locally. Refs #3383

comment:8 by elexis, 8 years ago

In 17366:

Lobby cleanup. Simplifies updatePlayerList() and moves hardcoded color values to the top of the file for easy access. Refs #3383

comment:9 by elexis, 8 years ago

In 17368:

Fix two oversights and simplify mapfilter-initialization. Refs #3383

comment:10 by elexis, 8 years ago

In 17369:

Lobby cleanup. Refs #3383

Removes a broken translation in displayProfile().
Removes many unused functions, variables and comments.
Moves filter initialization to new function.
Moves hardcoded system color to g_SystemColor.
Simplifies a lot without changing the logic otherwise.

comment:11 by elexis, 8 years ago

In 17370:

Lobby cleanup. Refs #3383

Remove wrong attempt to display private-messages in the lobby.
Move hardcoded font to g_SenderFont global.
Replace some variables with references.
Correct indentation in ircFormat().

comment:12 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 17371:

Lobby cleanup. Fixes #3383

Note: See TracTickets for help on using tickets.