Esempio n. 1
0
        public override MyDownloadWorldResult DownloadWorld()
        {
            MyTrace.Send(TraceWindow.Multiplayer, "World request sent");
            MyDownloadWorldResult ret = new MyDownloadWorldResult(MyMultiplayer.WorldDownloadChannel, Lobby.GetOwner(), this);

            MyControlWorldRequestMsg msg = new MyControlWorldRequestMsg();

            SendControlMessage(ServerId, ref msg);
            return(ret);
        }
Esempio n. 2
0
        public MyObjectBuilder_World ProcessWorldDownloadResult(MyDownloadWorldResult result)
        {
            MyTrace.Send(TraceWindow.Multiplayer, "World data processed");
            m_voxelMapData = result.WorldData.VoxelMaps.Dictionary;

            MyLog.Default.WriteLine("ProcessWorldDownloadResult voxel maps:");
            foreach (var voxelmap in m_voxelMapData)
            {
                MyLog.Default.WriteLine(voxelmap.Key);
            }

            return(result.WorldData);
        }
Esempio n. 3
0
        public override MyDownloadWorldResult DownloadWorld()
        {
            MyTrace.Send(TraceWindow.Multiplayer, "World request sent");
            MyDownloadWorldResult ret = new MyDownloadWorldResult(MyMultiplayer.WorldDownloadChannel, Lobby.GetOwner(), this);

            MyControlWorldRequestMsg msg = new MyControlWorldRequestMsg();
            SendControlMessage(ServerId, ref msg);
            return ret;
        }
Esempio n. 4
0
 public MyObjectBuilder_World ProcessWorldDownloadResult(MyDownloadWorldResult result)
 {
     MyTrace.Send(TraceWindow.Multiplayer, "World data processed");
     m_voxelMapData = result.WorldData.VoxelMaps.Dictionary;
     return(result.WorldData);
 }
Esempio n. 5
0
        private static void OnDownloadProgressChanged(MyGuiScreenProgress progress, MyDownloadWorldResult result, MyMultiplayerBase multiplayer)
        {
            switch (result.State)
            {
                case MyDownloadWorldStateEnum.Success:
                    progress.CloseScreen();
                    var world = multiplayer.ProcessWorldDownloadResult(result);

                    CheckDx11AndJoin(world, multiplayer);
                    break;

                case MyDownloadWorldStateEnum.InProgress:
                    if (result.ReceivedBlockCount == 1)
                        MyLog.Default.WriteLine("First world part received");
                    string percent = (result.Progress * 100).ToString("0.");
                    float size = result.ReceivedDatalength;
                    string prefix = MyUtils.FormatByteSizePrefix(ref size);
                    string worldSize = size.ToString("0.") + " " + prefix + "B";
                    if (progress.Text != null)
                        progress.Text.Clear();
                    if (float.IsNaN(result.Progress))
                    {
                        MyLog.Default.WriteLine("World requested - preemble received");
                        if (progress.Text != null)
                            progress.Text.Append(MyTexts.Get(MyCommonTexts.DialogWaitingForWorldData));
                    }
                    else
                    {
                        if (progress.Text != null)
                            progress.Text.AppendFormat(MyTexts.GetString(MyCommonTexts.DialogTextDownloadingWorld), percent, worldSize);
                    }
                    break;

                case MyDownloadWorldStateEnum.WorldNotAvailable:
                    MyLog.Default.WriteLine("World requested - world not available");
                    progress.Cancel();
                    MyGuiSandbox.Show(MyCommonTexts.DialogDownloadWorld_WorldDoesNotExists);
                    multiplayer.Dispose();
                    break;

                case MyDownloadWorldStateEnum.ConnectionFailed:
                    MyLog.Default.WriteLine("World requested - connection failed");
                    progress.Cancel();
                    MyGuiSandbox.Show(MyTexts.AppendFormat(new StringBuilder(), MyCommonTexts.MultiplayerErrorConnectionFailed, result.ConnectionError));
                    multiplayer.Dispose();
                    break;

                case MyDownloadWorldStateEnum.DeserializationFailed:
                case MyDownloadWorldStateEnum.InvalidMessage:
                    MyLog.Default.WriteLine("World requested - message invalid (wrong version?)");
                    progress.Cancel();
                    MyGuiSandbox.Show(MyCommonTexts.DialogTextDownloadWorldFailed);
                    multiplayer.Dispose();
                    break;

                default:
                    throw new InvalidBranchException();
            }
        }