-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Conversation
Huh, wonder why our build bot didn't catch this. Lets see: Gooey: 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? |
Hooray Jenkins reported success with all tests good! |
To test for it working(or rather not working if more than one player in the server), I simply changed the line 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). |
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. |
Fixed the issue with previous commits by changing the check from (ESCAPE) ButtonState.DOWN to Also, should I put the code for checking the player count in a different class? If yes, where? |
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:
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 :-) |
I did that so that the player may pause even on multiplayer if he is the only person online. |
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). |
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. |
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?