diff --git a/src/MarbleGame.hx b/src/MarbleGame.hx index 5691411a..e9aefaba 100644 --- a/src/MarbleGame.hx +++ b/src/MarbleGame.hx @@ -88,7 +88,6 @@ class MarbleGame { return; // don't pause } - paused = true; handlePauseGame(); // Focus the shit again var jsCanvas = @:privateAccess Window.getInstance().canvas; @@ -260,7 +259,6 @@ class MarbleGame { || (Net.isMP && paused && !(MarbleGame.canvas.children[MarbleGame.canvas.children.length - 1] is MPExitGameDlg))) { return; // don't pause } - paused = !paused; handlePauseGame(); } } @@ -288,57 +286,63 @@ class MarbleGame { } } + public function showPauseUI() { + if (world.isMultiplayer) { + exitGameDlg = new MPExitGameDlg(() -> { + canvas.popDialog(exitGameDlg); + paused = !paused; + var w = getWorld(); + w.setCursorLock(true); + }, () -> { + canvas.popDialog(exitGameDlg); + quitMission(Net.isClient); + if (Net.isMP && Net.isClient) { + Net.disconnect(); + canvas.setContent(new JoinServerGui()); + } + }); + } else { + exitGameDlg = new ExitGameDlg((sender) -> { + canvas.popDialog(exitGameDlg); + var w = getWorld(); + if (MarbleGame.instance.toRecord) { + MarbleGame.canvas.pushDialog(new ReplayNameDlg(() -> { + quitMission(); + })); + } else { + quitMission(Net.isClient); + if (Net.isMP && Net.isClient) { + Net.disconnect(); + } + } + }, (sender) -> { + canvas.popDialog(exitGameDlg); + paused = !paused; + var w = getWorld(); + w.setCursorLock(true); + }, (sender) -> { + canvas.popDialog(exitGameDlg); + var w = getWorld(); + w.restart(w.marble, true); + // world.setCursorLock(true); + paused = !paused; + }); + } + canvas.pushDialog(exitGameDlg); + } + public function handlePauseGame() { - if (paused && world._ready) { + if (!paused && world._ready) { + paused = true; Console.log("Game paused"); world.setCursorLock(false); if (Util.isTouchDevice()) { this.touchInput.movementInput.forceRelease(); } - if (world.isMultiplayer) { - exitGameDlg = new MPExitGameDlg(() -> { - canvas.popDialog(exitGameDlg); - paused = !paused; - var w = getWorld(); - w.setCursorLock(true); - }, () -> { - canvas.popDialog(exitGameDlg); - quitMission(Net.isClient); - if (Net.isMP && Net.isClient) { - Net.disconnect(); - canvas.setContent(new JoinServerGui()); - } - }); - } else { - exitGameDlg = new ExitGameDlg((sender) -> { - canvas.popDialog(exitGameDlg); - var w = getWorld(); - if (MarbleGame.instance.toRecord) { - MarbleGame.canvas.pushDialog(new ReplayNameDlg(() -> { - quitMission(); - })); - } else { - quitMission(Net.isClient); - if (Net.isMP && Net.isClient) { - Net.disconnect(); - } - } - }, (sender) -> { - canvas.popDialog(exitGameDlg); - paused = !paused; - var w = getWorld(); - w.setCursorLock(true); - }, (sender) -> { - canvas.popDialog(exitGameDlg); - var w = getWorld(); - w.restart(w.marble, true); - // world.setCursorLock(true); - paused = !paused; - }); - } - canvas.pushDialog(exitGameDlg); + showPauseUI(); } else { if (world._ready) { + paused = false; Console.log("Game unpaused"); if (exitGameDlg != null) canvas.popDialog(exitGameDlg); diff --git a/src/net/BitStream.hx b/src/net/BitStream.hx index e07bb73e..f44db72e 100644 --- a/src/net/BitStream.hx +++ b/src/net/BitStream.hx @@ -77,10 +77,11 @@ class InputBitStream { public function readString() { var length = readUInt16(); var str = ""; + var buf = new StringBuf(); for (i in 0...length) { - str += String.fromCharCode(readByte()); + buf.addChar(readByte()); } - return str; + return buf.toString(); } } diff --git a/src/net/MasterServerClient.hx b/src/net/MasterServerClient.hx index c1870e6f..d2fed971 100644 --- a/src/net/MasterServerClient.hx +++ b/src/net/MasterServerClient.hx @@ -102,7 +102,6 @@ class MasterServerClient { instance = null; } #if hl - stopMutex.acquire(); stopping = true; stopMutex.release(); if (myToken == wsToken) {