From 2a28e70af88496edd828308548ac6ae64facf241 Mon Sep 17 00:00:00 2001 From: RandomityGuy <31925790+RandomityGuy@users.noreply.github.com> Date: Thu, 30 May 2024 23:18:43 +0530 Subject: [PATCH] versioning for hosted servers --- src/gui/MPServerListGui.hx | 9 ++++++++- src/net/MasterServerClient.hx | 4 +++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gui/MPServerListGui.hx b/src/gui/MPServerListGui.hx index fc729245..35812db6 100644 --- a/src/gui/MPServerListGui.hx +++ b/src/gui/MPServerListGui.hx @@ -151,6 +151,13 @@ class MPServerListGui extends GuiImage { nextButton.gamepadAccelerator = ["X"]; nextButton.pressedAction = (e) -> { if (curSelection != -1) { + var selectedServerVersion = ourServerList[curSelection].version; + if (selectedServerVersion != MarbleGame.currentVersion) { + var pup = new MessageBoxOkDlg("You are using a different version of the game than the server. Please update your game."); + MarbleGame.canvas.pushDialog(pup); + return; + } + MarbleGame.canvas.setContent(new MultiplayerLoadingGui("Connecting")); var failed = true; haxe.Timer.delay(() -> { @@ -158,7 +165,7 @@ class MPServerListGui extends GuiImage { if (MarbleGame.canvas.content is MultiplayerLoadingGui) { var loadGui:MultiplayerLoadingGui = cast MarbleGame.canvas.content; if (loadGui != null) { - loadGui.setErrorStatus("Failed to connect to server"); + loadGui.setErrorStatus("Failed to connect to server. Please try again."); Net.disconnect(); } } diff --git a/src/net/MasterServerClient.hx b/src/net/MasterServerClient.hx index a2aad21e..fc10a8eb 100644 --- a/src/net/MasterServerClient.hx +++ b/src/net/MasterServerClient.hx @@ -13,6 +13,7 @@ typedef RemoteServerInfo = { players:Int, maxPlayers:Int, platform:Int, + version:String } class MasterServerClient { @@ -185,7 +186,8 @@ class MasterServerClient { privateServer: serverInfo.privateServer, inviteCode: serverInfo.inviteCode, state: serverInfo.state, - platform: serverInfo.platform + platform: serverInfo.platform, + version: MarbleGame.currentVersion })); }