Пример #1
0
        static void ShowModDebugInfo()
        {
            var info = new RemoteData();

            JoinData.ReadServerData(JoinData.WriteServerData(true), info);
            for (int i = 0; i < 200; i++)
            {
                info.remoteMods.Add(info.remoteMods.Last());
            }
            info.remoteFiles.Add("rwmt.multiplayer", new ModFile()
            {
                relPath = "/Test/Test.xml"
            });
            //info.remoteFiles.Add("ludeon.rimworld", new ModFile() { relPath = "/Test/Test.xml" });

            Find.WindowStack.Add(new JoinDataWindow(info));
        }
Пример #2
0
        public void HandleJoinData(ByteReader data)
        {
            Multiplayer.session.gameName = data.ReadString();
            Multiplayer.session.playerId = data.ReadInt32();

            var remoteInfo = new RemoteData
            {
                remoteRwVersion = data.ReadString(),
                remoteMpVersion = data.ReadString(),
                remoteAddress   = Multiplayer.session.address,
                remotePort      = Multiplayer.session.port,
                remoteSteamHost = Multiplayer.session.steamHost
            };

            var defDiff  = false;
            var defsData = new ByteReader(data.ReadPrefixedBytes());

            foreach (var local in MultiplayerData.localDefInfos)
            {
                var status = (DefCheckStatus)defsData.ReadByte();
                local.Value.status = status;

                if (status != DefCheckStatus.Ok)
                {
                    defDiff = true;
                }
            }

            JoinData.ReadServerData(data.ReadPrefixedBytes(), remoteInfo);

            OnMainThread.Schedule(Complete, 0.3f);

            void Complete()
            {
                if (JoinData.CompareToLocal(remoteInfo) && !defDiff)
                {
                    StartDownloading();
                    return;
                }

                if (defDiff)
                {
                    Multiplayer.StopMultiplayer();
                }

                var connectingWindow = Find.WindowStack.WindowOfType <BaseConnectingWindow>();

                MpUI.ClearWindowStack();

                var defDiffStr = "\n\n" + MultiplayerData.localDefInfos
                                 .Where(kv => kv.Value.status != DefCheckStatus.Ok)
                                 .Take(10)
                                 .Join(kv => $"{kv.Key}: {kv.Value.status}", "\n");

                Find.WindowStack.Add(new JoinDataWindow(remoteInfo)
                {
                    connectAnywayDisabled = defDiff ? "MpMismatchDefsDiff".Translate() + defDiffStr : null,
                    connectAnywayCallback = () =>
                    {
                        Find.WindowStack.Add(connectingWindow);
                        StartDownloading();
                    }
                });

                void StartDownloading()
                {
                    connection.Send(Packets.Client_WorldRequest);
                    subState = JoiningState.Waiting;
                }
            }
        }