예제 #1
0
 public static async void PerformBackups(CancellationToken token)
 {
     while (ServerContext.ServerRunning)
     {
         LunaLog.Debug("Performing backups...");
         VesselStoreSystem.BackupVessels();
         WarpSystem.SaveLatestSubspaceToFile();
         ScenarioStoreSystem.BackupScenarios();
         try
         {
             await Task.Delay(IntervalSettings.SettingsStore.BackupIntervalMs, token);
         }
         catch (TaskCanceledException)
         {
             break;
         }
     }
 }
예제 #2
0
        public void HandleChangeSubspace(ClientStructure client, WarpChangeSubspaceMsgData message)
        {
            if (message.PlayerName != client.PlayerName)
            {
                return;
            }

            var oldSubspace = client.Subspace;
            var newSubspace = message.Subspace;

            if (oldSubspace != newSubspace)
            {
                if (newSubspace < 0)
                {
                    LunaLog.Debug($"{client.PlayerName} is warping");
                }
                else if (WarpContext.Subspaces[newSubspace].Creator != client.PlayerName)
                {
                    LunaLog.Debug($"{client.PlayerName} synced with subspace '{message.Subspace}' created by {WarpContext.Subspaces[newSubspace].Creator}");
                }

                var msgData = ServerContext.ServerMessageFactory.CreateNewMessageData <WarpChangeSubspaceMsgData>();
                msgData.PlayerName = client.PlayerName;
                msgData.Subspace   = message.Subspace;

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

                if (newSubspace != -1)
                {
                    client.Subspace = newSubspace;

                    //Try to remove his old subspace
                    WarpSystem.RemoveSubspace(oldSubspace);
                }
            }
        }