Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #3139-Pause on menu #3303

Merged
merged 7 commits into from
Apr 15, 2018
Merged

Conversation

Arihant-Joshi
Copy link
Contributor

@Arihant-Joshi Arihant-Joshi commented Mar 25, 2018

Contains

Fixes #3139 .

How to test

Pressing Escape in the game pauses the world time.

Outstanding before merging

Maybe the getPlayerCount() method could be a separate file, so that other developers may use it too.
The player count may be updated whenever a player joins/leaves so that the engine doesn't iterate over all clients every time the escape menu is pressed.
Maybe raise a new issue for this?

@Arihant-Joshi Arihant-Joshi changed the title Pause on menu Fixes #3139-Pause on menu Mar 25, 2018
@Cervator
Copy link
Member

Huh, wonder why our build bot didn't catch this. Lets see:

Gooey: Test this please
@GooeyHub: Test this please

Thanks for the PR @Arihant-Joshi :-)

In which ways have you tested this one, curiously? Single player, one player connected to a headless server, server+client + client, 2 players on headless, etc?

@GooeyHub
Copy link
Member

Hooray Jenkins reported success with all tests good!

@Arihant-Joshi
Copy link
Contributor Author

To test for it working(or rather not working if more than one player in the server), I simply changed the line
if(getPlayerCount()==1) {
to
if(getPlayerCount()==2) {
(see commit
89aae6e

The menu stopped working(as the check to pause now was playerCount()==2) when only one player was connected, which is expected behavior(only for that test).

@Arihant-Joshi
Copy link
Contributor Author

Anyhow there still seems to be an issue with my PR with the game time pausing after closing the inventory by pressing the escape key.
Need some time to work on it.

@Arihant-Joshi
Copy link
Contributor Author

Fixed the issue with previous commits by changing the check from (ESCAPE) ButtonState.DOWN to
nuiManager.isOpen("engine:pauseMenu")

Also, should I put the code for checking the player count in a different class? If yes, where?

@Cervator
Copy link
Member

Heya @Arihant-Joshi. Sorry about the delay, coming out from a period without enough time to really dig into PRs :-)

So on looking at this more closely I see two issues:

  1. You've got some trivial whitespace issues that violate our code style standards. Could you please make sure you have Checkstyle working in your IDE and run it before committing code? Easy fix :-)
  2. I'm not sure this approach is right. Pausing the game is fair if you're playing in single player mode - but this approach actually also triggers if you're the sole player on a headless server. At that point time pauses locally but continues on the server, leading to some really weird issues

Ideally you should be able to base the check on some different logic, maybe related to whether the network system is live at all. If it isn't it is pretty safe to assume single player mode.

This does actually work fine in legit single player, for instance with JS running you finally wouldn't starve to death just from going AFK. But the implications of checking this way are problematic :-)

@Arihant-Joshi
Copy link
Contributor Author

Arihant-Joshi commented Apr 14, 2018

I did that so that the player may pause even on multiplayer if he is the only person online.
Should I change the code to only work for singleplayer?

@Arihant-Joshi
Copy link
Contributor Author

I did away with the approach of counting the number of players on a server, in favor of checking whether the Network Mode is None(Single Player).
Also did the thing using checkstyle :-)

@Cervator
Copy link
Member

Thanks! That works well now :-)

The trick in multiplayer is that you have both a client plus a server even if there's only one player active. The client thinks time is paused with the menu up but the server doesn't, resulting in strange behavior as you unpause and the server has been expecting time has in fact passed, and starts trying to update the player accordingly :-)

It would be possible to pause time both on the client and the server. You could even do it if any one player had that menu up but ... at some point that probably gets silly. Fair enough that single player is different, at least for now 👍

Added you to the game credits during the merge! I did remove one unused remaining variable, but that's trivial. Appreciate the style fixes.

@Cervator Cervator merged commit 73abcba into MovingBlocks:develop Apr 15, 2018
@Cervator Cervator added the Topic: UI/UX Requests, Issues and Changes related to screens, artwork, sound and overall user experience label Apr 15, 2018
Cervator added a commit that referenced this pull request Apr 15, 2018
@Cervator Cervator added this to the v2.0.0 milestone Apr 15, 2018
@Arihant-Joshi Arihant-Joshi deleted the pauseOnMenu branch April 15, 2018 07:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Topic: UI/UX Requests, Issues and Changes related to screens, artwork, sound and overall user experience
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants