private static void RunDekessler()
        {
            var removalCount = 0;

            var vesselList = VesselStoreSystem.CurrentVesselsInXmlFormat.ToArray();

            foreach (var vesselKeyVal in vesselList)
            {
                if (IsVesselDebris(vesselKeyVal.Key, vesselKeyVal.Value))
                {
                    LunaLog.Normal($"Removing debris vessel: {vesselKeyVal.Key}");

                    VesselStoreSystem.RemoveVessel(vesselKeyVal.Key);

                    //Send a vessel remove message
                    var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <VesselRemoveMsgData>();
                    msgData.VesselId = vesselKeyVal.Key;

                    MessageQueuer.SendToAllClients <VesselSrvMsg>(msgData);

                    removalCount++;
                }
            }

            if (removalCount > 0)
            {
                LunaLog.Normal($"Removed {removalCount} debris");
            }
        }
Beispiel #2
0
        private static void HandleVesselDock(ClientStructure client, VesselBaseMsgData message)
        {
            var msgData = (VesselDockMsgData)message;

            LunaLog.Debug($"Docking message received! Dominant vessel: {msgData.DominantVesselId}");

            if (VesselContext.RemovedVessels.Contains(msgData.WeakVesselId))
            {
                return;
            }

            if (VesselStoreSystem.VesselExists(msgData.DominantVesselId))
            {
                LunaLog.Debug($"Saving DOCKED vessel {msgData.DominantVesselId} from {client.PlayerName}. Bytes: {msgData.NumBytes}");
            }
            VesselDataUpdater.RawConfigNodeInsertOrUpdate(msgData.DominantVesselId, Encoding.UTF8.GetString(msgData.FinalVesselData, 0, msgData.NumBytes));

            //Now remove the weak vessel but DO NOT add to the removed vessels as they might undock!!!
            LunaLog.Debug($"Removing weak docked vessel {msgData.WeakVesselId}");
            VesselStoreSystem.RemoveVessel(msgData.WeakVesselId);

            MessageQueuer.RelayMessage <VesselSrvMsg>(client, msgData);

            //Tell all clients to remove the weak vessel
            var removeMsgData = ServerContext.ServerMessageFactory.CreateNewMessageData <VesselRemoveMsgData>();

            removeMsgData.VesselId = msgData.WeakVesselId;

            MessageQueuer.SendToAllClients <VesselSrvMsg>(removeMsgData);
        }
Beispiel #3
0
        private static void RunNuke()
        {
            uint removalCount = 0;

            var vesselList = VesselStoreSystem.CurrentVessels.ToArray();

            foreach (var vesselKeyVal in vesselList)
            {
                if (vesselKeyVal.Value.Fields.GetSingle("landed").Value.ToLower() == "true" &&
                    vesselKeyVal.Value.Fields.GetSingle("landedAt").Value.ToLower().Contains("ksc") ||
                    vesselKeyVal.Value.Fields.GetSingle("landedAt").Value.ToLower().Contains("runway") ||
                    vesselKeyVal.Value.Fields.GetSingle("landedAt").Value.ToLower().Contains("launchpad"))
                {
                    LunaLog.Normal($"Removing vessel: {vesselKeyVal.Key} from KSC");

                    VesselStoreSystem.RemoveVessel(vesselKeyVal.Key);

                    //Send a vessel remove message
                    var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <VesselRemoveMsgData>();
                    msgData.VesselId = vesselKeyVal.Key;

                    MessageQueuer.SendToAllClients <VesselSrvMsg>(msgData);

                    removalCount++;
                }
            }

            if (removalCount > 0)
            {
                LunaLog.Normal($"Nuked {removalCount} vessels around the KSC");
            }
        }
        private static void HandleVesselRemove(ClientStructure client, VesselBaseMsgData message)
        {
            var data = (VesselRemoveMsgData)message;

            if (data.Force)
            {
                LunaLog.Debug($"Received a FORCED remove against vessel {data.VesselId} from {client.PlayerName}");
            }

            if (!data.Force && LockSystem.LockQuery.ControlLockExists(data.VesselId) && !LockSystem.LockQuery.ControlLockBelongsToPlayer(data.VesselId, client.PlayerName))
            {
                return;
            }

            if (VesselStoreSystem.VesselExists(data.VesselId))
            {
                LunaLog.Debug($"Removing vessel {data.VesselId} from {client.PlayerName}");
                VesselStoreSystem.RemoveVessel(data.VesselId);
            }

            if (data.AddToKillList)
            {
                VesselContext.RemovedVessels.Add(data.VesselId);
            }

            //Relay the message.
            MessageQueuer.SendToAllClients <VesselSrvMsg>(data);
        }
        //Removes all matching vessels
        private static void RunRemove(string vesselType, string vesselSituation, string vesselSplashed, string vesselName)
        {
            var removalCount = 0;
            var vesselList   = VesselStoreSystem.CurrentVessels.ToArray();

            foreach (var vesselKeyVal in vesselList.Where(v => IsVesselFound(v.Value, vesselType, vesselSituation, vesselSplashed, vesselName)))
            {
                LunaLog.Normal($"Removing vessel: {vesselKeyVal.Key}");

                VesselStoreSystem.RemoveVessel(vesselKeyVal.Key);

                var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <VesselRemoveMsgData>();
                msgData.VesselId = vesselKeyVal.Key;
                MessageQueuer.SendToAllClients <VesselSrvMsg>(msgData);

                removalCount++;
            }

            LunaLog.Normal(removalCount > 0 ? $"Removed {removalCount} vessel(s) ..." : "Removed nothing ...");
        }
Beispiel #6
0
        private static void HandleVesselCouple(ClientStructure client, VesselBaseMsgData message)
        {
            var msgData = (VesselCoupleMsgData)message;

            LunaLog.Debug($"Coupling message received! Dominant vessel: {msgData.VesselId}");
            MessageQueuer.RelayMessage <VesselSrvMsg>(client, msgData);

            if (VesselContext.RemovedVessels.Contains(msgData.CoupledVesselId))
            {
                return;
            }

            //Now remove the weak vessel but DO NOT add to the removed vessels as they might undock!!!
            LunaLog.Debug($"Removing weak coupled vessel {msgData.CoupledVesselId}");
            VesselStoreSystem.RemoveVessel(msgData.CoupledVesselId);

            //Tell all clients to remove the weak vessel
            var removeMsgData = ServerContext.ServerMessageFactory.CreateNewMessageData <VesselRemoveMsgData>();

            removeMsgData.VesselId = msgData.CoupledVesselId;

            MessageQueuer.SendToAllClients <VesselSrvMsg>(removeMsgData);
        }
Beispiel #7
0
        //Removes all matching vessels
        private static void RunRemove(string vesselType, string vesselSituation, string vesselSplashed, string vesselName, string orbName)
        {
            //Declare variables
            var removalCount = 0;
            var vesselList   = VesselStoreSystem.CurrentVesselsInXmlFormat.ToArray();

            //Cycle vesselList
            foreach (var vesselKeyVal in vesselList)
            {
                //Check if vessel can be found
                if (IsVesselFound(vesselKeyVal.Value, vesselType, vesselSituation, vesselSplashed, vesselName, orbName))
                {
                    //Send a vessel remove server console message
                    LunaLog.Normal($"Removing vessel: {vesselKeyVal.Key}");

                    //Remove vessel from universe
                    VesselStoreSystem.RemoveVessel(vesselKeyVal.Key);

                    //Send a vessel remove message to all clients
                    var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <VesselRemoveMsgData>();
                    msgData.VesselId = vesselKeyVal.Key;
                    MessageQueuer.SendToAllClients <VesselSrvMsg>(msgData);

                    //Increase counter
                    removalCount++;
                }
            }
            //Send message remove info
            if (removalCount > 0)
            {
                LunaLog.Normal($"Removed {removalCount} vessel(s) ...");
            }
            else
            {
                LunaLog.Normal($"Removed nothing ...");
            }
        }