mirror of
https://gitea.sffempire.ru/Kolyah35/minecraft-pe-0.6.1.git
synced 2026-03-19 22:43:32 +00:00
Game now actually pauses when in a local world and when the server is set to be invisible.
This commit is contained in:
@@ -451,20 +451,21 @@ void Minecraft::update() {
|
|||||||
// }
|
// }
|
||||||
//}
|
//}
|
||||||
|
|
||||||
if (pause && level != NULL) {
|
// If we're paused (local world / invisible server), freeze gameplay and
|
||||||
float lastA = timer.a;
|
// networking and only keep UI responsive.
|
||||||
timer.advanceTime();
|
bool freezeGame = pause;
|
||||||
timer.a = lastA;
|
|
||||||
} else {
|
if (!freezeGame) {
|
||||||
timer.advanceTime();
|
timer.advanceTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (raknetInstance) {
|
if (raknetInstance && !freezeGame) {
|
||||||
raknetInstance->runEvents(netCallback);
|
raknetInstance->runEvents(netCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
TIMER_PUSH("tick");
|
TIMER_PUSH("tick");
|
||||||
int toTick = timer.ticks;
|
int toTick = freezeGame ? 1 : timer.ticks;
|
||||||
|
if (!freezeGame) timer.ticks = 0;
|
||||||
for (int i = 0; i < toTick; ++i, ++ticks)
|
for (int i = 0; i < toTick; ++i, ++ticks)
|
||||||
tick(i, toTick-1);
|
tick(i, toTick-1);
|
||||||
|
|
||||||
@@ -589,7 +590,9 @@ void Minecraft::tick(int nTick, int maxTick) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
TIMER_POP_PUSH("particles");
|
TIMER_POP_PUSH("particles");
|
||||||
|
if (!pause) {
|
||||||
particleEngine->tick();
|
particleEngine->tick();
|
||||||
|
}
|
||||||
if (screen) {
|
if (screen) {
|
||||||
screenMutex = true;
|
screenMutex = true;
|
||||||
screen->tick();
|
screen->tick();
|
||||||
@@ -1018,6 +1021,17 @@ bool Minecraft::isOnline()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Minecraft::pauseGame(bool isBackPaused) {
|
void Minecraft::pauseGame(bool isBackPaused) {
|
||||||
|
// Only freeze gameplay when running a local server and it is not accepting
|
||||||
|
// incoming connections (invisible server), which includes typical single-
|
||||||
|
// player/lobby mode. If the server is visible, the game should keep ticking.
|
||||||
|
bool canFreeze = false;
|
||||||
|
if (raknetInstance && raknetInstance->isServer() && netCallback) {
|
||||||
|
ServerSideNetworkHandler* ss = (ServerSideNetworkHandler*) netCallback;
|
||||||
|
if (!ss->allowsIncomingConnections())
|
||||||
|
canFreeze = true;
|
||||||
|
}
|
||||||
|
pause = canFreeze;
|
||||||
|
|
||||||
#ifndef STANDALONE_SERVER
|
#ifndef STANDALONE_SERVER
|
||||||
if (screen != NULL) return;
|
if (screen != NULL) return;
|
||||||
screenChooser.setScreen(isBackPaused? SCREEN_PAUSEPREV : SCREEN_PAUSE);
|
screenChooser.setScreen(isBackPaused? SCREEN_PAUSEPREV : SCREEN_PAUSE);
|
||||||
@@ -1070,6 +1084,8 @@ void Minecraft::setScreen( Screen* screen )
|
|||||||
|
|
||||||
//noRender = false;
|
//noRender = false;
|
||||||
} else {
|
} else {
|
||||||
|
// Closing a screen and returning to the game should unpause.
|
||||||
|
pause = false;
|
||||||
grabMouse();
|
grabMouse();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user