versioning for hosted servers

This commit is contained in:
RandomityGuy 2024-05-30 23:18:43 +05:30
parent ad6afce5d7
commit 2a28e70af8
2 changed files with 11 additions and 2 deletions

View file

@ -151,6 +151,13 @@ class MPServerListGui extends GuiImage {
nextButton.gamepadAccelerator = ["X"]; nextButton.gamepadAccelerator = ["X"];
nextButton.pressedAction = (e) -> { nextButton.pressedAction = (e) -> {
if (curSelection != -1) { 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")); MarbleGame.canvas.setContent(new MultiplayerLoadingGui("Connecting"));
var failed = true; var failed = true;
haxe.Timer.delay(() -> { haxe.Timer.delay(() -> {
@ -158,7 +165,7 @@ class MPServerListGui extends GuiImage {
if (MarbleGame.canvas.content is MultiplayerLoadingGui) { if (MarbleGame.canvas.content is MultiplayerLoadingGui) {
var loadGui:MultiplayerLoadingGui = cast MarbleGame.canvas.content; var loadGui:MultiplayerLoadingGui = cast MarbleGame.canvas.content;
if (loadGui != null) { if (loadGui != null) {
loadGui.setErrorStatus("Failed to connect to server"); loadGui.setErrorStatus("Failed to connect to server. Please try again.");
Net.disconnect(); Net.disconnect();
} }
} }

View file

@ -13,6 +13,7 @@ typedef RemoteServerInfo = {
players:Int, players:Int,
maxPlayers:Int, maxPlayers:Int,
platform:Int, platform:Int,
version:String
} }
class MasterServerClient { class MasterServerClient {
@ -185,7 +186,8 @@ class MasterServerClient {
privateServer: serverInfo.privateServer, privateServer: serverInfo.privateServer,
inviteCode: serverInfo.inviteCode, inviteCode: serverInfo.inviteCode,
state: serverInfo.state, state: serverInfo.state,
platform: serverInfo.platform platform: serverInfo.platform,
version: MarbleGame.currentVersion
})); }));
} }