Page MenuHomeWildfire Games

Prevent players from sending useless diplomacy changed messages
ClosedPublic

Authored by Sandarac on May 9 2017, 2:43 AM.

Details

Summary

Currently it is possible to repeatedly send useless diplomacy changed messages with others players (f.e. becoming "allies" with a player you are already allied with). It makes sense to disable the button that corresponds to your current stance towards another player.

Test Plan

Open up the diplomacy menu in a game, and notice that the button is disabled for your current diplomacy stance with other players, so you can no longer send pointless diplomacy changed messages by spamming the button.

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

Sandarac created this revision.May 9 2017, 2:43 AM
Sandarac updated this revision to Diff 1784.May 9 2017, 7:26 AM

Disable the buttons in the diplomacy menu when the game is paused, and do the same in the barter menu for consistency (after discussion with @elexis).

Vulcan added a subscriber: Vulcan.May 9 2017, 9:53 AM

Build is green

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

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

Build is green

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

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

Sandarac updated this revision to Diff 1896.May 13 2017, 8:47 AM

Toggle diplomacy and barter buttons of menus that are open when the game becomes paused.

Build is green

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

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

elexis edited edge metadata.May 24 2017, 6:50 PM

Just like all the other patches that disable things if the game is officially paused, I'm not a fan of this patch since I've always used pauses to already queue some commands in advance.
If the game is paused for 10 minutes and I figure that it's time to send all my allies a different amount of resources or change the diplomacy, I was able to and could then focus on the economy or military units after the pause has ended.
With the patch applied, you will have to remember everything, you will have to wait before being able to process the things you have remembered, which adds to the torture of other clients having paused for an unknown amount of time.
Besides preventing players from sending useful diplomacy changed messages, it also doesn't prevent sending of useless (duplicate) diplomacy cahnged messages, so the title is misleading. Perhaps you can ask fatherbushido or Imarok to convince me that this is a must have again.

binaries/data/mods/public/gui/session/menu.js
1138 ↗(On Diff #1896)

Nuke all that hardcoding and just iterate over all children of diplomacyPlayer[n] and diplomacyPlayer[n]_tribute[r] with type="button" and rely on people still considering pausing when adding new buttons to the diplomacy dialog.

Sandarac updated this revision to Diff 2178.May 24 2017, 8:09 PM

Don't send the diplomacy network command if it a pointless one (i.e. clicking on the enemy button with a player you are already allies with).

Build is green

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

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

The previous version might be okay if the duplication is nuked (even if I don't like it. Just remind me again that I'm alone with my liking of being able to send commands while it's paused). Engine.GetGUIObjectByName("parent").children yields the children GUI objects, there is an example in gamesetup.js.

Why not (very carefully, as there is ceasefire and initial diplomacy things going on) add these early returns to Player.js, so that not even a screen that isn't updated during the same turn, a trigger script nor the sim can broadcast a diplomacy changed message if the stance wouldn't be changed (Thus the patch fully living up to the title and fixing all situations)?

binaries/data/mods/public/gui/session/menu.js
432 ↗(On Diff #2178)

Better disable the button (if we don't care about the button not being updated until the next turn (Implementing a cache for that is ugly, see #3210)). See pastebin yesterday.

In D461#22270, @elexis wrote:

Just like all the other patches that disable things if the game is officially paused

Such as?

I'm not a fan of this patch since I've always used pauses to already queue some commands in advance.

This doesn't seem like it should be allowed to happen, as if the game is paused, it should be (by definition) actually paused, and prevent players from spamming commands (possibly unintentionally, from new players) that can build up without any response or indication from the gui.

Besides preventing players from sending useful diplomacy changed messages, it also doesn't prevent sending of useless (duplicate) diplomacy cahnged messages, so the title is misleading.

Actually, if one follows the test plan for this diff, they would notice it does prevent sending of useless/duplicate diplomacy changed messages, so I'm not sure where exactly this is coming from.

In D461#22270, @elexis wrote:

Just like all the other patches that disable things if the game is officially paused

Such as?

Mostly rP18204. I had created #4009, so maybe we can just say that the diplo dialog is still enabled if the slim pause GUI is implemented and activated. Also there was some patch by vladislav hiding the construction panel, can't find it.

I'm not a fan of this patch since I've always used pauses to already queue some commands in advance.

This doesn't seem like it should be allowed to happen, as if the game is paused, it should be (by definition) actually paused, and prevent players from spamming commands (possibly unintentionally, from new players) that can build up without any response or indication from the gui.

Well, agree that there should be an indication by the GUI. It would be great to have it immediately, but it should be implemented in a way that doesn't cause harm to the reader.

Besides preventing players from sending useful diplomacy changed messages, it also doesn't prevent sending of useless (duplicate) diplomacy cahnged messages, so the title is misleading.

Actually, if one follows the test plan for this diff, they would notice it does prevent sending of useless/duplicate diplomacy changed messages, so I'm not sure where exactly this is coming from.

Duplicate messages are still sent until the next turn arrives. This is short in SP (200ms) but long in MP (500ms and too often there are games where each turn consumes more than 1s, as in units walking for 500ms then having the walk animation without moving while waiting for some lagging client for 500ms). It should really be fixed in the sim IMO, but as I said, disabling stuff in the GUI just assuming the simstate to be true and potentially disabling if its paused is ok too.

elexis accepted this revision.May 28 2017, 4:38 AM

Accepting the first revision as Sandarac is primarily concerned about reducing the duplicate messages arriving at the AI without changing the sim (i.e. not really caring about preventing pause actions which I'd prefer to keep if possible somehow)

This revision is now accepted and ready to land.May 28 2017, 4:38 AM
This revision was automatically updated to reflect the committed changes.