#3281 closed defect (fixed)
[PATCH] Lobby - Some playernames not highlighted in the chat
Reported by: | elexis | Owned by: | Stan |
---|---|---|---|
Priority: | Should Have | Milestone: | Alpha 19 |
Component: | Multiplayer lobby | Keywords: | patch |
Cc: | Patch: |
Description (last modified by )
If someone types your name in the chat, that occurance will be replaced with a colored version of your name.
However this doesn't work for some people like ffm.
The code that deals with this function is in lobby.js
:
function addChatMessage(msg) ... // Highlight local user's nick if (msg.text.indexOf(g_Name) != -1 && g_Name != msg.from) msg.text = msg.text.replace(new RegExp('\\b' + '\\' + g_Name + '\\b', "g"), colorPlayerName(g_Name));
Here a doc about the RegExp
that fails: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp
As far as I can tell the '\\'
shouldn't be added, since the regex looks for form feed characters, if the name starts with f then.
Attachments (4)
Change History (12)
by , 9 years ago
Attachment: | t3281_fix_highlighted_playername_regex.patch added |
---|
comment:1 by , 9 years ago
Description: | modified (diff) |
---|---|
Summary: | [PATCH] Lobby - Some playernames not colored in the chat → [PATCH] Lobby - Some playernames not highlighted in the chat |
by , 9 years ago
Attachment: | t3281_highlighted_playername_almost_without_regex.patch added |
---|
by , 9 years ago
Attachment: | t3281_highlighted_playername_almost_without_regex_v1.1.patch added |
---|
Cleaned line 875.
follow-up: 8 comment:2 by , 9 years ago
Why not just skip the work needed to decide if the nick is not in a word (which might or might not give strange results with some non-latin chars at some point), and just highlight it stupidly? Does not really fix the issue of possibly splitting some chars, but that would be the fault of indexOf
returning that as a match.
Which would result in being able to use a simple replace
. Short nicks that are common in some words are not really that common.
comment:3 by , 9 years ago
Owner: | set to |
---|
by , 9 years ago
Working version that just replace the name http://imgur.com/FvE7rTm Proof.
comment:4 by , 9 years ago
Keywords: | review patch added |
---|
comment:8 by , 5 years ago
Description: | modified (diff) |
---|
Replying to leper:
Why not just skip the work needed to decide if the nick is not in a word (which might or might not give strange results with some non-latin chars at some point), and just highlight it stupidly? Does not really fix the issue of possibly splitting some chars, but that would be the fault of
indexOf
returning that as a match.Which would result in being able to use a simple
replace
. Short nicks that are common in some words are not really that common.
There's a difference between changing code style because one finds it nicer one way over the other, and deciding a function to knowingly return wrong values that was already written to account for that case.
This issue is reported by players multiple times per year, and those that are affected are pinged very often (acoustically as r18545).
(09:01:09 PM) T: I receive a notification in the chat if it says "t" in a sentence.. Triumvir, elexis
2017-09/2017-09-24-QuakeNet-#0ad-dev.log:13:05 < bb1> so lobby rubbish bbl etc pings me 2017-12/2017-12-14-QuakeNet-#0ad-dev.log:13:00 < bb1> y so I don't get pingen on "lobby"
(It's not only people with 1-3 letters in the nick. Players with 4 letters in the nick and some vowels aren't so rarely affected either that one could neglect that. We also have multiple hannibals online sometimes.)
Which doesn't mean that attachment:t3281_highlighted_playername_almost_without_regex_v1.1.patch
was the cleanest or correct code either.
Replaces the RegExp with a function with less side effects. Still uses a RegExp to check if a single character is alphanumerical.