Page MenuHomeWildfire Games

Colored playernames in chat messages
Needs ReviewPublic

Authored by ffffffff on Aug 18 2017, 5:02 PM.

Details

Reviewers
elexis
vladislavbelov
Trac Tickets
#4977
Summary

Colorize also playernames in chat message so its faster and easier to see color and name who is meant.

Test Plan
  1. Run the game;
  2. Start the multiplayer match with someone or another opened game;
  3. Check that all player names are colored.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

ffffffff created this revision.Aug 18 2017, 5:02 PM
ffffffff edited the test plan for this revision. (Show Details)
elexis rescinded a token.
elexis awarded a token.
vladislavbelov edited the summary of this revision. (Show Details)Aug 25 2017, 7:56 PM
vladislavbelov edited the test plan for this revision. (Show Details)
vladislavbelov added a reviewer: Restricted Owners Package.
vladislavbelov set the repository for this revision to rP 0 A.D. Public Repository.
vladislavbelov added a subscriber: Restricted Owners Package.
bb added a subscriber: bb.Nov 12 2017, 4:10 PM
bb added inline comments.
binaries/data/mods/public/gui/session/messages.js
1103–1104

why is this check added? observers should still get there ping, and observer messages should be colored too

1109–1111

rewrite to

if (msg.text.indexOf(g_PlayerAssignments[guid].name) != -1)
     msg.text = msg.text.replace(g_PlayerAssignments[guid].name, colorizePlayernameByGUID(guid))

and omnit some braces

ffffffff removed a reviewer: Restricted Owners Package.Nov 18 2017, 11:16 AM
ffffffff added inline comments.
binaries/data/mods/public/gui/session/messages.js
1103–1104

observer are white no?

ping sure hm

ffffffff added inline comments.Nov 18 2017, 11:25 AM
binaries/data/mods/public/gui/session/messages.js
1103–1104

yea i got error sometimes and some lines later its also checked l1124

coloredUsername = msg.guid != -1 ? colorizePlayernameByGUID(msg.guid) : colorizePlayernameByID(msg.player);

not sure keeping it. maybe safe. maybe break.

ffffffff updated this revision to Diff 4261.Nov 18 2017, 11:30 AM
ffffffff updated this revision to Diff 4267.Nov 18 2017, 8:33 PM

contextdiff

ffffffff added inline comments.Nov 22 2017, 1:06 AM
binaries/data/mods/public/gui/session/messages.js
1109–1111

is ok?

1117

instead msg.guid != -1 check g_PlayerAssignments[msg.guid] is better. just make sure guid exist

vladislavbelov requested changes to this revision.Nov 30 2017, 12:02 AM
vladislavbelov added a subscriber: vladislavbelov.

I'm interesting, what happens if there are 4 players: Test, PrefixTest, TestSuffix, PrefixTestSuffix? I think it depends on the g_PlayerAssignments order.

binaries/data/mods/public/gui/session/messages.js
1113

Do we really need a check here? I mean, if the replace didn't find any occurrence, it wouldn't replace anything.

This revision now requires changes to proceed.Nov 30 2017, 12:02 AM
ffffffff updated this revision to Diff 4467.Nov 30 2017, 5:37 PM

Im so glad @vladislavbelov question all of this. Cause the replace in user mentioning in message in lobby is crapped same way. Its needs word barriers to replace. Therefore is the \b regex from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#special-word-boundary

So now it should work good.

binaries/data/mods/public/gui/session/messages.js
1113

away

Mozilla says:

WARNING: Note: JavaScript's regular expression engine defines a specific set of characters to be "word" characters. Any character not in that set is considered a word break. This set of characters is fairly limited: it consists solely of the Roman alphabet in both upper- and lower-case, decimal digits, and the underscore character. Accented characters, such as "é" or "ü" are, unfortunately, treated as word breaks.

Did you test for all possible symbols in names?

ffffffff added a comment.EditedNov 30 2017, 7:33 PM

Mozilla says:

WARNING: Note: JavaScript's regular expression engine defines a specific set of characters to be "word" characters. Any character not in that set is considered a word break. This set of characters is fairly limited: it consists solely of the Roman alphabet in both upper- and lower-case, decimal digits, and the underscore character. Accented characters, such as "é" or "ü" are, unfortunately, treated as word breaks.

Did you test for all possible symbols in names?

i hope they are not allowed for names in accounts? think so :)

Actualy just wanted to have a better replace function as we had before (f.e. in lobby) :)

ok i got some errors need to test further (signs like "(" or ")" which are in names allowed are a problem realy :(

ffffffff updated this revision to Diff 4802.Dec 16 2017, 11:12 PM

easier regex

ffffffff marked 8 inline comments as done.Jan 6 2018, 7:53 PM

Complains left @elexis @vladislavbelov @bb? I am feeling fine. Tests also done in P100.

ffffffff updated the Trac tickets for this revision.Jan 18 2018, 7:12 AM