Opened 9 years ago

Closed 8 years ago

Last modified 8 years ago

#3270 closed defect (fixed)

Private messages for observers cause error

Reported by: elexis Owned by: elexis
Priority: Nice to Have Milestone: Alpha 20
Component: UI & Simulation Keywords:
Cc: Patch:

Description

If you send a private message addressed to an observer using /msg, then the following error is thrown on the observer client (but not on the sender):

WARNING: JavaScript warning: gui/session/messages.js line 656
reference to undefined property g_Players[Engine.GetPlayerID(...)]
ERROR: JavaScript error: gui/session/messages.js line 656
TypeError: g_Players[Engine.GetPlayerID(...)] is undefined
  parseChatCommands@gui/session/messages.js:656:7
  addChatMessage@gui/session/messages.js:412:4
  handleNetMessage@gui/session/messages.js:288:61
  onTick@gui/session/session.js:402:3
  __eventhandler145 (tick)@sn tick:0:1

Looks like a simple check is missing.

PMs from observers to players are prohibited already. Should PMs from players to observers be prohibited as well?

Change History (6)

comment:1 by elexis, 9 years ago

It would also be nice if observers were allowed to send private messages to each other, so that they can comment on the gameplay without disturbing the players.

Also the /observers command might be implemented to send a message only to observers.

comment:2 by elexis, 9 years ago

attachment:t3241_kick_v4.3.patch:ticket:3241 contains a fix that should be extracted for this ticket. In particular the function GetHostGUID and/or GetPlayerGUID was needed.

comment:3 by leper, 9 years ago

In 16953:

Prevent observers from using most chat commands. Refs #2879.

Chat prefixed with /all could circumvent the check. Fix this by only allowing /me.
(Note that this is not a full solution, see #3270.)

Refactors the cheat and chat input code based on changes in some of elexis' patches.

comment:4 by elexis, 8 years ago

Receiving PMs as observer is still broken.

Also /team doesn't echo the chatmessage locally while /allies and /enemies do (both on svn and a19).

comment:5 by elexis, 8 years ago

Owner: set to elexis
Resolution: fixed
Status: newclosed

In 17565:

Session chat cleanup.

Unify switch-statement using objects.
Do not parse recursively, but do a linear 2-step process. Remove msg.me property and move "/me" parsing out of that function.
Early return instead of using msg.hide.
Add observer-checks for private messages to impede abuse and fix #3270.
Remove the "/all" command, since it doesn't add functionality but complexity.
Remove a TODO as displaying multiple contexts ("/team /allies text"?) is not useful currently and made the previous code error-prone.

comment:6 by elexis, 8 years ago

Milestone: BacklogAlpha 20

Notice the bots send chat messages to allies. That's why many checks use the playerID.

In case an "/observer" command or PMs from observer to observer should be supported in the future, NetClient.cpp must expose it's GUID to JS via ScriptFunctions.cpp. Many fun edgecases arise from the inconsistency of accessing the playerproperties either by ID or GUID.

Note: See TracTickets for help on using tickets.