Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#3435 closed defect (fixed)

[PATCH] Chat & Developer overlay broken in visual replay

Reported by: elexis Owned by: mimo
Priority: Should Have Milestone: Alpha 19
Component: UI & Simulation Keywords: patch
Cc: Patch:

Description (last modified by elexis)

If you replay a match from the menu and then type something into the chat or try to open the developers overlay, errors about missing PlayerData will appear.

It would be nice to fix it, since the developers overlay allows to change the perspective.

Chat Error:

WARNING: JavaScript warning: gui/session/messages.js line 403
reference to undefined property msg.player
WARNING: JavaScript warning: gui/session/messages.js line 228
reference to undefined property g_Players[player]
ERROR: JavaScript error: gui/session/messages.js line 228
TypeError: g_Players[player] is undefined
  getUsernameAndColor@gui/session/messages.js:228:6
  addChatMessage@gui/session/messages.js:403:3
  submitChatInput@gui/session/messages.js:374:56
  __eventhandler119 (press)@chatInput press:0:1

Developers Overlay error:

ERROR: JavaScript error: gui/session/messages.js line 228
TypeError: g_Players[player] is undefined
  getUsernameAndColor@gui/session/messages.js:228:6
  addChatMessage@gui/session/messages.js:403:3
  submitChatDirectly@gui/session/messages.js:346:56
  toggleDeveloperOverlay@gui/session/menu.js:692:3
  __eventhandler102 (press)@devCommands press:0:1

Thanks ffm for informing me!

Attachments (1)

t3435_fix_player_assignments_in_replays_v1.patch (1.4 KB ) - added by elexis 9 years ago.
Fix both!

Download all attachments as: .zip

Change History (8)

comment:1 by elexis, 9 years ago

Description: modified (diff)

comment:2 by elexis, 9 years ago

The cause of this is the player assignments being wrong.

For visual replay menu, they are {}, while in the autostart version they are {"local":{"name":"You","player":1}}.

In a multiplayergame as observer, they are {"C295F113566BEBFD":{"name":"elexis","player":-1,"status":1}}.

So ideally that should be {"local":{"name":"You","player":-1}} in both cases. Not sure right now what the status property meant, maybe online/offline.

comment:3 by elexis, 9 years ago

Ok guys, here is what happens:

Visual Replay Autostart

The visual-replay-auotstart doesn't provide initData for init(initData, hotloadData) defined in session.js. That's the reason why the default player assignment used in singleplayer (defined in session.js) is used:

var g_PlayerAssignments = { "local": { "name": translate("You"), "player": 1 } };

That's why the visualreplay started from command line doesn't break chat.

Visual Replay Menu

The replay menu however offers initData in reallyStartVisualReplay(), defined in replay_actions.js and it explicitly states:

playerAssignments": {}

which is why it breaks.

Both cases should be fixed, since the player in autostart-replays isn't player 1, but observer (-1). We switch the active player using in AutostartVisualReplay() of GameSetup.cpp after creating the game, but that change doesn't make it into the player assignments. A consequence of that is that if you type chat in autostart-visualreplay, it gets printed in blue (the default color of player 1). It should be white for the spectator. There might be more hidden bugs like that, so we should fix it too.

by elexis, 9 years ago

Fix both!

comment:4 by elexis, 9 years ago

Component: Core engineUI & Simulation
Keywords: patch review added
Milestone: BacklogAlpha 19
Summary: Chat & Developer overlay broken in visual replay started from menu[patch] Chat & Developer overlay broken in visual replay

a19 since mimo is interested in commiting this.

comment:5 by mimo, 9 years ago

Owner: set to mimo
Resolution: fixed
Status: newclosed

In 17063:

fix developper overlay in visual replay, patch by elexis, fixes #3435

comment:6 by mimo, 9 years ago

Keywords: review removed

Thanks for the patch

comment:7 by Palaxin, 8 years ago

Summary: [patch] Chat & Developer overlay broken in visual replay[PATCH] Chat & Developer overlay broken in visual replay
Note: See TracTickets for help on using tickets.