Beispiel #1
0
        public void HandleMessage(IServerMessageBase msg)
        {
            if (!(msg.Data is ScenarioBaseMsgData msgData))
            {
                return;
            }

            if (msgData.ScenarioMessageType == ScenarioMessageType.Data)
            {
                var data = (ScenarioDataMsgData)msgData;
                for (var i = 0; i < data.ScenarioCount; i++)
                {
                    var scenarioNode = ConfigNodeSerializer.Deserialize(data.ScenariosData[i].Data, data.ScenariosData[i].NumBytes);
                    if (scenarioNode != null)
                    {
                        var entry = new ScenarioEntry
                        {
                            ScenarioName = data.ScenariosData[i].Module,
                            ScenarioNode = scenarioNode
                        };
                        System.ScenarioQueue.Enqueue(entry);
                    }
                    else
                    {
                        LunaLog.LogError($"[LMP]: Scenario data has been lost for {data.ScenariosData[i].Module}");
                        ScreenMessages.PostScreenMessage($"Scenario data has been lost for {data.ScenariosData[i].Module}", 5f, ScreenMessageStyle.UPPER_CENTER);
                    }
                }
                MainSystem.NetworkState = ClientState.ScenariosSynced;
            }
        }
Beispiel #2
0
        public void HandleMessage(IMessageData messageData)
        {
            var msgData = messageData as ScenarioBaseMsgData;

            if (msgData?.ScenarioMessageType == ScenarioMessageType.Data)
            {
                var data = ((ScenarioDataMsgData)messageData).ScenarioNameData;
                foreach (var scenario in data)
                {
                    var scenarioNode = ConfigNodeSerializer.Deserialize(scenario.Value);
                    if (scenarioNode != null)
                    {
                        var entry = new ScenarioEntry
                        {
                            ScenarioName = scenario.Key,
                            ScenarioNode = scenarioNode
                        };
                        System.ScenarioQueue.Enqueue(entry);
                    }
                    else
                    {
                        LunaLog.LogError($"[LMP]: Scenario data has been lost for {scenario.Key}");
                        ScreenMessages.PostScreenMessage($"Scenario data has been lost for {scenario.Key}", 5f, ScreenMessageStyle.UPPER_CENTER);
                    }
                }
                MainSystem.NetworkState = ClientState.ScneariosSynced;
            }
        }
Beispiel #3
0
 //If the scene field is blank, KSP will throw an error while starting the game, meaning players will be unable to join the server.
 private static void CheckForBlankSceneSoTheGameDoesntBugOut(ScenarioEntry scenarioEntry)
 {
     if (scenarioEntry.ScenarioNode.GetValue("scene") == string.Empty)
     {
         var nodeName = scenarioEntry.ScenarioModule;
         LunaScreenMsg.PostScreenMessage($"{nodeName} is badly behaved!", 3, ScreenMessageStyle.UPPER_CENTER);
         LunaLog.Log($"[LMP]: {nodeName} is badly behaved!");
         scenarioEntry.ScenarioNode.SetValue("scene", "7, 8, 5, 6, 9");
     }
 }
Beispiel #4
0
 //If the scene field is blank, KSP will throw an error while starting the game, meaning players will be unable to join the server.
 private static void CheckForBlankSceneSoTheGameDoesntBugOut(ScenarioEntry scenarioEntry)
 {
     if (scenarioEntry.ScenarioNode.GetValue("scene") == string.Empty)
     {
         var nodeName = scenarioEntry.ScenarioName;
         ScreenMessages.PostScreenMessage(nodeName + " is badly behaved!");
         Debug.Log($"[LMP]: {nodeName} is badly behaved!");
         scenarioEntry.ScenarioNode.SetValue("scene", "7, 8, 5, 6, 9");
     }
 }
Beispiel #5
0
        private static void QueueScenarioBytes(string scenarioModule, byte[] scenarioData, int numBytes)
        {
            var scenarioNode = ConfigNodeSerializer.Deserialize(scenarioData, numBytes);

            if (scenarioNode != null)
            {
                var entry = new ScenarioEntry
                {
                    ScenarioModule = scenarioModule,
                    ScenarioNode   = scenarioNode
                };
                System.ScenarioQueue.Enqueue(entry);
            }
            else
            {
                LunaLog.LogError($"[LMP]: Scenario data has been lost for {scenarioModule}");
            }
        }