Exemple #1
0
 protected override UpdaterResult fetchUpdateResult()
 {
     double b = _link.GetFee();
     UpdaterResult r = new UpdaterResult();
     r.DoubleVals.Add(b);
     return r;
 }
Exemple #2
0
        void StartUp(object sender, EventArgs a)
        {
            Logger.Logged            += OnLogged;
            Heartbeat.UriChanged     += OnHeartbeatUrlChanged;
            Server.PlayerListChanged += OnPlayerListChanged;
            Server.ShutdownEnded     += OnServerShutdownEnded;


#if !DEBUG
            try {
#endif
            Server.InitLibrary(args);
            Server.InitServer();

            Text = "fCraft " + Updater.CurrentRelease.VersionString + " - " + ConfigKey.ServerName.GetString();
            Application.DoEvents();
            //StartServer();

            UpdaterResult update = Updater.CheckForUpdates();

            if (update.UpdateAvailable)
            {
                new UpdateWindow(update, false).ShowDialog();
            }

            StartServer();
#if !DEBUG
        }

        catch (Exception ex) {
            Logger.LogAndReportCrash("Unhandled exception in fCraftUI.StartUp", "fCraftUI", ex, true);
            Shutdown(ShutdownReason.Crashed, false);
        }
#endif
        }
Exemple #3
0
 public UpdateWindow(UpdaterResult _update, UI _parent, bool _auto)
 {
     InitializeComponent();
     parent         = _parent;
     update         = _update;
     auto           = _auto;
     changelog.Text = update.ChangeLog;
     title.Text     = String.Format("A new version is available: v{0:0.000}, released {1:0} day(s) ago.",
                                    Decimal.Divide(update.NewVersionNumber, 1000),
                                    DateTime.Now.Subtract(update.ReleaseDate).TotalDays);
     Shown += Download;
 }
Exemple #4
0
 public UpdateWindow( UpdaterResult update, bool auto ) {
     InitializeComponent();
     updaterFullPath = Path.Combine( Paths.WorkingPath, Paths.UpdaterFileName );
     updateResult = update;
     autoUpdate = auto;
     CreateDetailedChangeLog();
     lVersion.Text = String.Format( lVersion.Text,
                                    Updater.CurrentRelease.VersionString,
                                    updateResult.LatestRelease.VersionString,
                                    updateResult.LatestRelease.Age.TotalDays );
     Shown += Download;
 }
Exemple #5
0
        static void Main(string[] args)
        {
            World world = new World("");

            world.OnLog       += Log;
            world.OnURLChange += SetURL;

            if (world.Init())
            {
                if (args.Length == 1)
                {
                    world.LoadMap(args[0]);
                }
                else
                {
                    world.LoadMap(Map.DefaultFileName);
                }

                UpdaterResult update = Updater.CheckForUpdates(world);
                if (update.UpdateAvailable)
                {
                    Console.WriteLine("** A new version of fCraft is available: v{0:0.000}, released {1:0} day(s) ago. **",
                                      Decimal.Divide(update.NewVersionNumber, 1000),
                                      DateTime.Now.Subtract(update.ReleaseDate).TotalDays);
                }

                System.Diagnostics.Process.GetCurrentProcess().PriorityClass = world.config.GetBasePriority();

                if (world.Start())
                {
                    Console.Title = "fCraft " + Updater.GetVersionString() + " - " + world.config.GetString("ServerName");
                    string input = "";
                    Console.WriteLine("** To shut down the server, type /exit **");
                    while ((input = Console.ReadLine()) != "/exit")
                    {
                        Player.Console.ParseMessage(input, true);
                    }
                    world.ShutDown();
                }
                else
                {
                    Console.WriteLine("** Failed to start the server **");
                    world.ShutDown();
                    Console.ReadLine();
                }
            }
            else
            {
                Console.WriteLine("** Failed to initialize the server **");
                world.ShutDown();
                Console.ReadLine();
            }
        }
Exemple #6
0
 internal CheckedForUpdatesEventArgs([NotNull] string url, [NotNull] UpdaterResult result)
 {
     if (url == null)
     {
         throw new ArgumentNullException("url");
     }
     if (result == null)
     {
         throw new ArgumentNullException("result");
     }
     Url    = url;
     Result = result;
 }
Exemple #7
0
 public UpdateWindow( UpdaterResult update ) {
     InitializeComponent();
     updaterFullPath = Path.Combine( Paths.WorkingPath, Paths.UpdateInstallerFileName );
     updateResult = update;
     autoUpdate = (ConfigKey.UpdaterMode.GetEnum<UpdaterMode>() == UpdaterMode.Auto);
     CreateDetailedChangeLog();
     lVersion.Text = String.Format( lVersion.Text,
                                    Updater.CurrentRelease.VersionString,
                                    updateResult.LatestRelease.VersionString,
                                    updateResult.LatestRelease.Age.TotalDays );
     Shown += Download;
     DialogResult = DialogResult.OK;
 }
Exemple #8
0
 public UpdateWindow(UpdaterResult update, bool auto)
 {
     InitializeComponent();
     updaterFullPath = Path.Combine(Paths.WorkingPath, Paths.UpdaterFileName);
     updateResult    = update;
     autoUpdate      = auto;
     CreateDetailedChangeLog();
     lVersion.Text = String.Format(lVersion.Text,
                                   Updater.CurrentRelease.VersionString,
                                   updateResult.LatestRelease.VersionString,
                                   updateResult.LatestRelease.Age.TotalDays);
     Shown += Download;
 }
Exemple #9
0
        static void CheckForUpdates()
        {
            UpdaterMode updaterMode = ConfigKey.UpdaterMode.GetEnum <UpdaterMode>();

            if (updaterMode == UpdaterMode.Disabled)
            {
                return;
            }

            UpdaterResult update = Updater.CheckForUpdates();

            if (!update.UpdateAvailable)
            {
                return;
            }

            Console.WriteLine("** A new version of fCraft is available: {0}, released {1:0} day(s) ago. **",
                              update.LatestRelease.VersionString,
                              update.LatestRelease.Age.TotalDays);
            if (updaterMode != UpdaterMode.Notify)
            {
                WebClient client = new WebClient();
                client.DownloadProgressChanged += OnUpdateDownloadProgress;
                client.DownloadFileCompleted   += OnUpdateDownloadCompleted;
                client.DownloadFileAsync(update.DownloadUri, Paths.UpdaterFileName);
                UpdateDownloadWaiter.WaitOne();
                if (updateFailed)
                {
                    return;
                }

                if (updaterMode == UpdaterMode.Prompt)
                {
                    Console.WriteLine("Restart the server and update now? y/n");
                    var key = Console.ReadKey();
                    if (key.KeyChar == 'y')
                    {
                        RestartForUpdate();
                    }
                    else
                    {
                        Console.WriteLine("You can update manually by shutting down the server and running " +
                                          Paths.UpdaterFileName);
                    }
                }
                else
                {
                    RestartForUpdate();
                }
            }
        }
Exemple #10
0
 public UpdateWindow(UpdaterResult update)
 {
     InitializeComponent();
     updaterFullPath = Path.Combine(Paths.WorkingPath, Paths.UpdateInstallerFileName);
     updateResult    = update;
     autoUpdate      = (ConfigKey.UpdaterMode.GetEnum <UpdaterMode>() == UpdaterMode.Auto);
     CreateDetailedChangeLog();
     lVersion.Text = String.Format(lVersion.Text,
                                   Updater.CurrentRelease.VersionString,
                                   updateResult.LatestRelease.VersionString,
                                   updateResult.LatestRelease.Age.TotalDays);
     Shown       += Download;
     DialogResult = DialogResult.OK;
 }
Exemple #11
0
        void StartUp(object sender, EventArgs a)
        {
            world = new World("");

            world.OnLog              += Log;
            world.OnURLChange        += SetURL;
            world.OnPlayerListChange += UpdatePlayerList;


            if (world.Init())
            {
                Text = "fCraft " + Updater.GetVersionString() + " - " + world.config.GetString("ServerName");

                UpdaterResult update = Updater.CheckForUpdates(world);
                if (update.UpdateAvailable)
                {
                    if (world.config.GetString("AutomaticUpdates") == "Notify")
                    {
                        Log(String.Format(Environment.NewLine +
                                          "*** A new version of fCraft is available: v{0:0.000}, released {1:0} day(s) ago. ***" +
                                          Environment.NewLine,
                                          Decimal.Divide(update.NewVersionNumber, 1000),
                                          DateTime.Now.Subtract(update.ReleaseDate).TotalDays), LogType.ConsoleOutput);
                        StartServer();
                    }
                    else
                    {
                        UpdateWindow updateWindow = new UpdateWindow(update, this, world.config.GetString("AutomaticUpdates") == "Auto");
                        updateWindow.StartPosition = FormStartPosition.CenterParent;
                        updateWindow.ShowDialog();
                    }
                }
                else
                {
                    StartServer();
                }
            }
            else
            {
                world.log.Log("---- Could Not Initialize World ----", LogType.FatalError);
                world = null;
            }
        }
Exemple #12
0
 internal CheckedForUpdatesEventArgs( string url, UpdaterResult result ) {
     Url = url;
     Result = result;
 }
Exemple #13
0
        void StartupThread()
        {
#if !DEBUG
            try {
#endif
            Server.InitLibrary(Environment.GetCommandLineArgs());
            if (shutdownPending)
            {
                return;
            }

            Server.InitServer();
            if (shutdownPending)
            {
                return;
            }

            BeginInvoke((Action)OnInitSuccess);

            // check for updates
            UpdaterMode updaterMode = ConfigKey.UpdaterMode.GetEnum <UpdaterMode>();
            if (updaterMode != UpdaterMode.Disabled)
            {
                UpdaterResult update = Updater.CheckForUpdates();
                if (shutdownPending)
                {
                    return;
                }
                if (update.UpdateAvailable)
                {
                    if (updaterMode == UpdaterMode.Notify)
                    {
                        String updateMsg = String.Format("An fCraft update is available! Visit www.fCraft.net to download. " +
                                                         "Local version: {0}. Latest available version: {1}.",
                                                         Updater.CurrentRelease.VersionString,
                                                         update.LatestRelease.VersionString);
                        Logger.LogToConsole(updateMsg);
                    }
                    else
                    {
                        DialogResult result = new UpdateWindow(update).ShowDialog();
                        if (result == DialogResult.Cancel)
                        {
                            // startup aborted (restart for update)
                            return;
                        }
                    }
                }
            }

            // set process priority
            if (!ConfigKey.ProcessPriority.IsBlank())
            {
                try {
                    Process.GetCurrentProcess().PriorityClass = ConfigKey.ProcessPriority.GetEnum <ProcessPriorityClass>();
                } catch (Exception) {
                    Logger.Log(LogType.Warning,
                               "MainForm.StartServer: Could not set process priority, using defaults.");
                }
            }

            if (shutdownPending)
            {
                return;
            }
            if (Server.StartServer())
            {
                startupComplete = true;
                BeginInvoke((Action)OnStartupSuccess);
            }
            else
            {
                BeginInvoke((Action)OnStartupFailure);
            }
#if !DEBUG
        }

        catch (Exception ex) {
            Logger.LogAndReportCrash("Unhandled exception in ServerGUI.StartUp", "ServerGUI", ex, true);
            Shutdown(ShutdownReason.Crashed);
        }
#endif
        }
Exemple #14
0
 internal CheckedForUpdatesEventArgs(string url, UpdaterResult result)
 {
     Url    = url;
     Result = result;
 }
Exemple #15
0
        static void Main(string[] args)
        {
            Logger.Logged        += OnLogged;
            Heartbeat.UriChanged += OnHeartbeatUrlChanged;

#if !DEBUG
            try {
#endif
            Server.InitLibrary(args);

            Server.InitServer();

            UpdaterMode updaterMode = ConfigKey.UpdaterMode.GetEnum <UpdaterMode>();
            if (updaterMode != UpdaterMode.Disabled)
            {
                UpdaterResult update = Updater.CheckForUpdates();
                if (update.UpdateAvailable)
                {
                    Console.WriteLine("** A new version of fCraft is available: {0}, released {1:0} day(s) ago. **",
                                      update.LatestRelease.VersionString,
                                      update.LatestRelease.Age.TotalDays);
                }
            }

            if (!ConfigKey.ProcessPriority.IsBlank())
            {
                try {
                    Process.GetCurrentProcess().PriorityClass = ConfigKey.ProcessPriority.GetEnum <ProcessPriorityClass>();
                } catch (Exception) {
                    Logger.Log("Program.Main: Could not set process priority, using defaults.", LogType.Warning);
                }
            }

            if (Server.StartServer())
            {
                Console.Title = "fCraft " + Updater.CurrentRelease.VersionString + " - " + ConfigKey.ServerName.GetString();
                Console.WriteLine("** Running fCraft version {0}. **", Updater.CurrentRelease.VersionString);
                Console.WriteLine("** Server is now ready. Type /shutdown to exit safely. **");

                while (!Server.IsShuttingDown)
                {
                    string cmd = Console.ReadLine();
                    if (cmd.Equals("/clear", StringComparison.OrdinalIgnoreCase))
                    {
                        Console.Clear();
                    }
                    else
                    {
                        try {
                            Player.Console.ParseMessage(cmd, true);
                        } catch (Exception ex) {
                            Logger.LogAndReportCrash("Error while executing a command from console", "fCraftConsole", ex, false);
                        }
                    }
                }
            }
            else
            {
                ReportFailure(ShutdownReason.FailedToStart);
            }
#if !DEBUG
        }

        catch (Exception ex) {
            ReportFailure(ShutdownReason.Crashed);
            Logger.LogAndReportCrash("Unhandled exception in fCraftConsole", "fCraftConsole", ex, true);
        } finally {
            Console.ResetColor();
        }
#endif
        }
Exemple #16
0
        void StartupThread()
        {
#if !DEBUG
            try {
#endif
            Server.InitLibrary(Environment.GetCommandLineArgs());
            if (shutdownPending)
            {
                return;
            }

            Server.InitServer();
            if (shutdownPending)
            {
                return;
            }

            BeginInvoke((Action)OnInitSuccess);

            UpdaterResult update = Updater.CheckForUpdates();
            if (shutdownPending)
            {
                return;
            }

            if (update.UpdateAvailable)
            {
                new UpdateWindow(update, false).ShowDialog();
            }

            if (!ConfigKey.ProcessPriority.IsBlank())
            {
                try {
                    Process.GetCurrentProcess().PriorityClass = ConfigKey.ProcessPriority.GetEnum <ProcessPriorityClass>();
                } catch (Exception) {
                    Logger.Log(LogType.Warning,
                               "MainForm.StartServer: Could not set process priority, using defaults.");
                }
            }

            if (shutdownPending)
            {
                return;
            }
            if (Server.StartServer())
            {
                startupComplete = true;
                BeginInvoke((Action)OnStartupSuccess);
            }
            else
            {
                BeginInvoke((Action)OnStartupFailure);
            }
#if !DEBUG
        }

        catch (Exception ex) {
            Logger.LogAndReportCrash("Unhandled exception in ServerGUI.StartUp", "ServerGUI", ex, true);
            Shutdown(ShutdownReason.Crashed, Server.HasArg(ArgKey.ExitOnCrash));
        }
#endif
        }