public static void JoinGame(GameServerItem server) { MyAnalyticsHelper.SetEntry(MyGameEntryEnum.Join); if (server.ServerVersion != MyFinalBuildConstants.APP_VERSION) { var sb = new StringBuilder(); sb.AppendFormat(MyTexts.GetString(MyCommonTexts.MultiplayerError_IncorrectVersion), MyFinalBuildConstants.APP_VERSION, server.ServerVersion); MyGuiSandbox.Show(sb, MyCommonTexts.MessageBoxCaptionError); return; } if (MyFakes.ENABLE_MP_DATA_HASHES) { var serverHash = server.GetGameTagByPrefix("datahash"); if (serverHash != "" && serverHash != MyDataIntegrityChecker.GetHashBase64()) { MyGuiSandbox.Show(MyCommonTexts.MultiplayerError_DifferentData); MySandboxGame.Log.WriteLine("Different game data when connecting to server. Local hash: " + MyDataIntegrityChecker.GetHashBase64() + ", server hash: " + serverHash); return; } } UInt32 unixTimestamp = (UInt32)(DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1))).TotalSeconds; SteamAPI.Instance.AddFavoriteGame(server.AppID, System.Net.IPAddressExtensions.ToIPv4NetworkOrder(server.NetAdr.Address), (UInt16)server.NetAdr.Port, (UInt16)server.NetAdr.Port, FavoriteEnum.History, unixTimestamp); MyMultiplayerClient multiplayer = new MyMultiplayerClient(server, new MySyncLayer(new MyTransportLayer(MyMultiplayer.GameEventChannel))); MyMultiplayer.Static = multiplayer; MyMultiplayer.Static.SyncLayer.AutoRegisterGameEvents = false; MyMultiplayer.Static.SyncLayer.RegisterGameEvents(); multiplayer.SendPlayerData(MySteam.UserName); string gamemode = server.GetGameTagByPrefix("gamemode"); if (MyFakes.ENABLE_BATTLE_SYSTEM && gamemode == "B") { StringBuilder text = MyTexts.Get(MySpaceTexts.DialogTextJoiningBattle); MyGuiScreenProgress progress = new MyGuiScreenProgress(text, MyCommonTexts.Cancel); MyGuiSandbox.AddScreen(progress); progress.ProgressCancelled += () => { multiplayer.Dispose(); MySessionLoader.UnloadAndExitToMenu(); }; multiplayer.OnJoin += delegate { MyJoinGameHelper.OnJoinBattle(progress, SteamSDK.Result.OK, new LobbyEnterInfo() { EnterState = LobbyEnterResponseEnum.Success }, multiplayer); }; } else { StringBuilder text = MyTexts.Get(MyCommonTexts.DialogTextJoiningWorld); MyGuiScreenProgress progress = new MyGuiScreenProgress(text, MyCommonTexts.Cancel); MyGuiSandbox.AddScreen(progress); progress.ProgressCancelled += () => { multiplayer.Dispose(); if (MyMultiplayer.Static != null) { MyMultiplayer.Static.Dispose(); } }; multiplayer.OnJoin += delegate { MyJoinGameHelper.OnJoin(progress, SteamSDK.Result.OK, new LobbyEnterInfo() { EnterState = LobbyEnterResponseEnum.Success }, multiplayer); }; } }