Page MenuHomeWildfire Games

Reset ready state when non-observers join in gamesetup
ClosedPublic

Authored by Imarok on Jan 7 2017, 2:46 PM.

Details

Summary

The ready state needs to be reset, when non-observers join.
This fixes the unintended "Host is ready" chat message and the wrong label on the ready button.

Test Plan
  1. Start a host.
  2. Enter the gamesetup with a second client and press ready.
  3. Enter the gamesetup with a third client.

Diff Detail

Repository
rP 0 A.D. Public Repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Imarok updated this revision to Diff 156.Jan 7 2017, 2:46 PM
Imarok retitled this revision from to Reset ready state when non-observers join.
Imarok updated this object.
Imarok edited the test plan for this revision. (Show Details)
Imarok updated the Trac tickets for this revision.
Owners added a subscriber: Restricted Owners Package.Jan 7 2017, 2:46 PM
Imarok updated this revision to Diff 157.Jan 7 2017, 2:51 PM

Fix indentation

Vulcan added a subscriber: Vulcan.Jan 7 2017, 3:30 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/111/ for more details.

Vulcan added a comment.Jan 7 2017, 4:14 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/112/ for more details.

elexis requested changes to this revision.EditedJan 9 2017, 1:39 PM
elexis added a reviewer: elexis.
elexis added a subscriber: elexis.

Thanks for finding out that it wasn't the networking rewrite but one of my commits from a day before!
See comment in #4452 for the commit that broke and how it broke it.

The suggested change resets often enough, but too often,
since it resets for non-controllers, even if a client rejoins that was an observer before and is not becoming a player, if all playerslots are assigned.

This revision now requires changes to proceed.Jan 9 2017, 1:39 PM
Imarok updated this revision to Diff 189.Jan 10 2017, 3:16 PM
Imarok edited edge metadata.

Reset the ready state only when a player joins

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/135/ for more details.

elexis commandeered this revision.Jan 11 2017, 12:28 AM
elexis edited reviewers, added: Imarok; removed: elexis.

As discussed in IRC, this code calls resetReadyData if a client becomes assigned to freeSlot while this wasn't the case before rP18299. Thus the code doesn't exactly represent the required code flow anymore / leaves the wrong impression that we need to reset in that one case when we don't..
Hence suggesting this the following diff which also adds a comment removes and removes the second early return and the negation in the condition to make things easier to read.

elexis updated this revision to Diff 195.Jan 11 2017, 12:32 AM

Call resetReadyData for controllers and non-controllers if a client joined the game that is already known to be a player
while not calling it if an observer joined the game that is becoming assigned to a playerslot.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/139/ for more details.

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/140/ for more details.

Imarok requested changes to this revision.Jan 12 2017, 3:33 PM
Imarok edited edge metadata.

Your patch introduces a new bug: Host a game and change no setting -> join with a client and set the client to ready -> the client will not see the notification: "myName is ready!"

This revision now requires changes to proceed.Jan 12 2017, 3:33 PM

Somehow I could reproduce it the day you posted it, but now the same code works magically (perhaps I don't have a fitting persist-match-settings file? :P)

to reproduce without the right persist-mapsettings: start the host -> set the second player slot to Unassigned -> go back to main menu -> host again -> join with a second client -> click "I'm ready"

Imarok added a comment.Feb 6 2017, 7:36 PM

I further hunted down this bug:
the bug occurs when a client joins into an unassigned slot, because your patch doesn't resetReady for every player joining.
The bug doesn't occur when a client joins into an AI slot, because this triggers a gamesetup message which then resets ready.

Imarok added a comment.Feb 7 2017, 5:55 PM
In D50#1723, @elexis wrote:

As discussed in IRC, this code calls resetReadyData if a client becomes assigned to freeSlot while this wasn't the case before rP18299. Thus the code doesn't exactly represent the required code flow anymore / leaves the wrong impression that we need to reset in that one case when we don't..
Hence suggesting this the following diff which also adds a comment removes and removes the second early return and the negation in the condition to make things easier to read.

The bug with joining an unassigned slot is present before rP18299 (tested with rP18288), so your assumption is not valid anymore.

Imarok retitled this revision from Reset ready state when non-observers join to Reset ready state when non-observers join in gamesetup.Feb 7 2017, 6:03 PM
elexis added a comment.Feb 8 2017, 4:38 AM

The bug you discovered is present at least in rP17428
Blame page: https://code.wildfiregames.com/source/0ad/browse/ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js;17428$443
I guess it might have been added when ready buttons were implemented in rP15006 (alpha 16)

The code we see in rP17428 however also reset if a client joins that is assigned to an unassigned playerslot, so that can't be the reasoning.
What completely boggles my mind is that it matters whether if the replaced playerslot was an AI or an unassigned player...
At least that seems like a good point to start investigating.

Also going to copy & paste said alpha 16 code as those ready functions dont interfer with all the other code that has changed.
code-travolta

Imarok added a comment.Feb 8 2017, 9:44 AM
In D50#4642, @elexis wrote:

The code we see in rP17428 however also reset if a client joins that is assigned to an unassigned playerslot, so that can't be the reasoning.

I guess you mean L473 in rP17428. Afaics, this only resets ready when a player rejoins.

What completely boggles my mind is that it matters whether if the replaced playerslot was an AI or an unassigned player...
At least that seems like a good point to start investigating.

As already said, this is the case, because joining into an unassigned slot triggers no game setup message, but joining into an AI slot triggers one. And a game setup message triggers resetReady.

elexis added a comment.Feb 8 2017, 4:29 PM
In D50#4647, @Imarok wrote:

As already said, this is the case, because joining into an unassigned slot triggers no game setup message, but joining into an AI slot triggers one. And a game setup message triggers resetReady.

Ah,
onClientJoin
-> Engine.AssignNetworkPlayer
-> handlePlayerAssignmentMessage
-> updatePlayerList
-> // There was a human, so make sure we don't have any AI left
-> Engine.SetNetworkGameAttributes
-> handleGamesetupMessage
->updateGUIObjects
-> resetReadyData
...obviously.
My branch moves the removal of the AI slot to onClientJoin to reduce the indirection, so I guess that was the right move.

In D50#4647, @Imarok wrote:

I guess you mean L473 in rP17428. Afaics, this only resets ready when a player rejoins.

Confirmed with alpha 19, starting host, having another client join and ready up, then joining with another client to an unassigned slot does not reset the ready data!
Indeed that particular line only resets for rejoining clients (as the client is already present in the delivered player assignments).
So if I'm seeing this correctly, rP15171 is the revision that introduced assigning of joining clients that were not present before to (assumed, refs rP17443) unused player slots, but missed to resetReadyData, which was only incidentally the case when an AI got removed from the slot.

Please commandeer the revision, so I can accept your fix! :-)
With regards to your proposed patch (id 189), we still don't need to find a free slot if the client is already a rejoining player and some of the comments don't seem to add information.
Also make sure the commit message refers to both revisions and tickets.

Imarok commandeered this revision.Feb 9 2017, 5:02 PM
Imarok edited reviewers, added: elexis; removed: Imarok.
Vulcan added a comment.Feb 9 2017, 6:18 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/338/ for more details.

Imarok updated this revision to Diff 499.Feb 10 2017, 3:01 PM

Diff 189 with less comments

elexis accepted this revision.Feb 10 2017, 3:24 PM

Finally we can bury this one!

This revision is now accepted and ready to land.Feb 10 2017, 3:24 PM

Build is green

Updating workspaces.
Build (release)...
Build (debug)...
Running debug tests...
Running cxxtest tests (302 tests)..............................................................................................................................................................................................................................................................................................................OK!

http://jw:8080/job/phabricator/344/ for more details.

This revision was automatically updated to reflect the committed changes.
elexis changed the visibility from "All Users" to "Public (No Login Required)".Jul 1 2018, 3:19 PM