示例#1
0
        private static void Main(string[] args)
        {
            // Changes the CurrentCulture of the current thread to the invariant
            // culture.
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // Setup any per-user folder structer that we need.
            SetupUserFolders();

            List<string> extraArguments = new List<string>();
            try
            {
                bool patch = true;
            #if PERFHUD_BUILD
                patch = false;
            #endif
                bool unhandledArguments = false;
                string logFileOverride = null;
                string updateUrl = null;
                string patchUrl = null;
                bool force_scan = false;
                bool exit_after_patch = false;
                for (int i = 0; i < args.Length; ++i)
                {
                    switch (args[i])
                    {
                        case "--noupdate":
                        case "--no_client_update":
                            patch = false;
                            break;
                        case "--update_url":
                            Debug.Assert(i + 1 < args.Length);
                            updateUrl = args[++i];
                            break;
                        case "--patch_url":
                        case "--patcher_url":
                            Debug.Assert(i + 1 < args.Length);
                            patchUrl = args[++i];
                            break;
                        case "--force_scan":
                            force_scan = true;
                            break;
                        // Now handle arguments we want to pass through
                        case "--master":
                        case "--world":
                        case "--login_page":
                        case "--world_settings_file":
                        case "--log_level":
                            Debug.Assert(i + 1 < args.Length);
                            extraArguments.Add(args[i]);
                            extraArguments.Add(args[++i]);
                            break;
                        case "--log_config":
                            Debug.Assert(i + 1 < args.Length);
                            logFileOverride = args[++i];
                            break;
                        default:
                            if (!exit_after_patch)
                                unhandledArguments = true;
                            exit_after_patch = true;
                            break;
                    }
                }

                // initialize logging
                bool interactive = System.Windows.Forms.SystemInformation.UserInteractive;
                string logConfigFile = Path.Combine(ConfigFolder, "LogConfig.xml");
                if (logFileOverride != null)
                    logConfigFile = logFileOverride;
                LogUtil.InitializeLogging(logConfigFile, Path.Combine("..", "DefaultLogConfig.xml"), FallbackLogfile, interactive);

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                foreach (string s in args)
                {
                    sb.AppendFormat("{0} ", s);
                }

                log.InfoFormat("Client command line arguments: {0}", sb.ToString());

                if (unhandledArguments)
                    log.Info("Got extra arguments; Will exit after patch if a client patch is required.");

                if (patch)
                {
                    log.Info("Checking if restart required");
                    try
                    {
                        if (Patch(updateUrl, patchUrl, extraArguments.ToArray(), force_scan, exit_after_patch))
                        {
                            log.Info("Restart required");
                            return;
                        }
                    }
                    catch (Exception e)
                    {
                        LogUtil.ExceptionLog.ErrorFormat("Version determination failed: {0}", e);
                        throw;
                    }
                }

                string errorMessage = null;
                string errorPage = null;

                // this.Hide();
                // this.WindowState = FormWindowState.Minimized;
                // create an instance of the client class and start it up
                // We use the using declaration here so that we dispose of the object
                using (Client client = new Multiverse.Base.Client())
                {
            #if PERFHUD_BUILD
                    client.standalone = true;
                    client.PatchMedia = false;
                    client.Repository = "../../../Media/";
                    // Debug.Assert(false, "Breakpoint for Debug");
            #endif
                    for (int i = 0; i < args.Length; ++i)
                    {
                        switch (args[i])
                        {
                            case "--standalone":
                                client.standalone = true;
                                client.WorldId = "standalone";
                                break;
                            case "--debug":
                                client.doTraceConsole = true;
                                break;
                            case "--simple_terrain":
                                client.simpleTerrain = true;
                                break;
                            case "--config":
                                client.doDisplayConfig = true;
                                break;
                            case "--tocFile":
                                Debug.Assert(i + 1 < args.Length);
                                client.uiModules.Add(args[++i]);
                                break;
                            case "--master":
                                Debug.Assert(i + 1 < args.Length);
                                client.MasterServer = args[++i];
                                break;
                            case "--world":
                            case "--world_id":
                                Debug.Assert(i + 1 < args.Length);
                                client.WorldId = args[++i];
                                break;
                            case "--character":
                                Debug.Assert(i + 1 < args.Length);
                                client.CharacterId = long.Parse(args[++i]);
                                break;
                            case "--login_url":
                                Debug.Assert(i + 1 < args.Length);
                                client.LoginUrl = args[++i];
                                break;
                            case "--login_page":
                                Debug.Assert(i + 1 < args.Length);
                                client.LoginUrl = LoginBase + args[++i];
                                break;
                            case "--noupdate":
                            case "--no_media_update":
                                client.PatchMedia = false;
                                break;
                            case "--world_patcher_url":
                                Debug.Assert(i + 1 < args.Length);
                                log.Warn("--world_patcher_url argument will not be honored by the login patcher");
                                client.WorldPatcherUrl = args[++i];
                                break;
                            case "--world_update_url":
                                Debug.Assert(i + 1 < args.Length);
                                log.Warn("--world_update_url argument will not be honored by the login patcher");
                                client.WorldUpdateUrl = args[++i];
                                break;
                            case "--world_settings_file":
                                Debug.Assert(i + 1 < args.Length);
                                WorldSettingsFile = args[++i];
                                break;
                            case "--logcollisions":
                                client.logCollisions = true;
                                break;
                            case "--frames_between_sleeps":
                                Debug.Assert(i + 1 < args.Length);
                                client.FramesBetweenSleeps = int.Parse(args[++i]);
                                break;
                            case "--log_level":
                                Debug.Assert(i + 1 < args.Length);
                                SetLogLevel(args[++i], false);
                                break;
                            case "--development":
                                client.UseRepository = true;
                                client.FramesBetweenSleeps = 2;
                                client.PatchMedia = false;
                                break;
                            case "--use_default_repository":
                                client.UseRepository = true;
                                client.PatchMedia = false;
                                break;
                            case "--repository_path":
                                client.RepositoryPaths.Add(args[++i]);
                                client.PatchMedia = false;
                                client.UseRepository = true;
                                break;
                            case "--maxfps":
                                client.MaxFPS = int.Parse(args[++i]);
                                break;
                            case "--log_terrain":
                                client.LogTerrainConfig = true;
                                break;
                            case "--coop_input":
                                // Used when running from the debugger
                                client.UseCooperativeInput = true;
                                break;
                            case "--tcp":
                                client.UseTCP = true;
                                break;
                            case "--rdp":
                                client.UseTCP = false;
                                break;
                            case "--display_config":
                                client.manualDisplayConfigString = args[++i];
                                break;
                            case "--fullscreen":
                                client.manualFullscreen = true;
                                break;
                            case "--fixed_fps":
                                client.FixedFPS = int.Parse(args[++i]);
                                break;
                            case "--client_patch_only":
                                return;
                            case "--media_patch_only":
                                client.ExitAfterMediaPatch = true;
                                break;
                            case "--allow_resize":
                                Debug.Assert(i + 1 < args.Length);
                                client.AllowResize = bool.Parse(args[++i]);
                                break;
                            case "--log_config":
                                // this is handled up above, but ignore it here
                                Debug.Assert(i + 1 < args.Length);
                                ++i;
                                break;
                            // These are the arguments used by the patcher
                            case "--no_client_update":
                            case "--force_scan":
                                break;
                            case "--update_url":
                            case "--patch_url":
                            case "--patcher_url":
                                ++i;
                                break;
                            default:
                                // Handle -Dproperty=value arguments
                                if (args[i].StartsWith("-D") && args[i].Contains("="))
                                {
                                    char[] delims = { '=' };
                                    string[] tmp = args[i].Substring(2).Split(delims, 2);
                                    client.SetParameter(tmp[0], tmp[1]);
                                }
                                else
                                {
                                    Console.WriteLine("Invalid argument " + args[i]);
                                }
                                break;
                        }
                    }
                    client.GameWorld = new Multiverse.Base.MarsWorld(client);

                    client.SourceConfig(Path.Combine(ConfigFolder, WorldSettingsFile));
                    try
                    {
                        client.Start();
                    }
                    catch (Exception ex)
                    {
                        LogUtil.ExceptionLog.ErrorFormat("Exiting client due to exception: {0}", ex);
                        errorMessage = ex.Message;
                    }
                    log.Info("Exiting client");
                    if (errorPage == null)
                        errorPage = client.ErrorPage;
                    if (errorMessage == null)
                        errorMessage = client.ErrorMessage;
                } // using client
                bool errorShown = false;
                if (errorPage != null)
                {
                    string fullPath = Path.GetFullPath("../html/" + errorPage);
                    if (File.Exists(fullPath))
                    {
                        Multiverse.Base.HtmlWindow tmp = new Multiverse.Base.HtmlWindow("file://" + fullPath);
                        tmp.Text = "Multiverse Client Error";
                        tmp.ShowDialog();
                        errorShown = true;
                    }
                }
                if (!errorShown && errorMessage != null)
                {
                    Dialog tmp = new Dialog();
                    tmp.TopMost = true;
                    tmp.Text = "Client Shutting Down!";
                    tmp.Message = errorMessage;
                    tmp.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                // call the existing global exception handler
                LogUtil.ExceptionLog.ErrorFormat("Exited client due to exception: {0}", ex);
                Dialog tmp = new Dialog();
                tmp.TopMost = true;
                tmp.Text = "Alert";
                tmp.Message = ex.Message;
                tmp.ShowDialog();
            }
            finally
            {
                log.Info("Cleaning up");
                log.Info("Exiting Client");
                LogManager.Shutdown();
                GC.Collect();
                // Kernel.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
                // this.WindowState = FormWindowState.Normal;
                // this.Show();
                Application.Exit();
            }
        }
        public WidgetManager(Window rootWindow, Client client,
							 WorldManager worldManager)
        {
            this.client = client;
            this.worldManager = worldManager;
            this.window = rootWindow;
        }
        // Move the desired displacement, limited by hitting an
        // obstacle.  Then, if we're not already at the terrain level,
        // "fall" until we are either at the terrain level, or hit an
        // obstacle
        public static Vector3 MoveMobNode(MobNode mobNode, Vector3 requestedDisplacement, Client client)
        {
            //             Logger.Log(0, "MoveMobNode oid {0} requestedDisplacement {1}", mobNode.Oid, requestedDisplacement);
            //             log.DebugFormat("MoveMobNode: mobNode oid {0}, name {1}, followTerrain {2}, position {3}, disp {4}",
            //                             mobNode.Oid, mobNode.Name, mobNode.FollowTerrain, mobNode.Position, requestedDisplacement);
            Vector3 start = mobNode.Position;
            MovingObject mo = mobNode.Collider;
            bool collided = false;
            // Zero the y coordinate of displacement, because it seems
            // that it can be arbitrarily large
            Vector3 desiredDisplacement = requestedDisplacement;
            if (mobNode.FollowTerrain)
                desiredDisplacement.y = 0;
            if (desiredDisplacement.LengthSquared <= float.Epsilon)
                return start;
            if (MO.DoLog)
                MO.Log("MoveMobNode called with mobNode {0} at {1}, disp of {2}",
                       mobNode.Oid, start, requestedDisplacement);
            if (collisionManager == null) {
                log.Info("MoveMobNode: returning because collisionManager isn't initialized");
                return start + desiredDisplacement;
            }
            if (mo == null || mo.parts.Count == 0) {
                if (MO.DoLog)
                    MO.Log("MoveMobNode returning because no collision volume for node");
                return start + requestedDisplacement;
            }
            if (mobNode is Player && NowColliding(mo, "Testing player collision on entry")) {
                if (client.MillisecondsStuckBeforeGotoStuck != 0) {
                    if (!playerStuck) {
                        stuckGotoTime = DateTime.Now.AddMilliseconds(client.MillisecondsStuckBeforeGotoStuck);
                        playerStuck = true;
                    }
                    else if (DateTime.Now >= stuckGotoTime) {
                        // We issue the goto command to move us out of the
                        // collision volume
                        client.Write("Executing /stuck command because player has been in a collision volume for " + client.MillisecondsStuckBeforeGotoStuck + " milliseconds");
                        client.NetworkHelper.SendTargettedCommand(client.Player.Oid, "/stuck");
                        playerStuck = false;
                        return start;
                    }
                }
            }
            else
                playerStuck = false;
            // If we haven't completed setup to this extent, just give up
            CollisionParms parms = new CollisionParms();
            Vector3 pos = FindMobNodeDisplacement(mobNode, parms, desiredDisplacement, out collided);
            //             log.DebugFormat("MoveMobNode: mobNode oid {0}, name {1}, mob node position {2}, displacement {3}",
            //                 mobNode.Oid, mobNode.Name, pos, requestedDisplacement);
            float h = worldManager.GetHeightAt(pos);
            // If we're already below ground level, just set our
            // level to ground level.  This will have to be modified
            // if we deal with caves
            if (pos.y - h < 0) {
            //                 log.DebugFormat("MoveMobNode: mobNode oid {0}, name {1} below terrain level", mobNode.Oid, mobNode.Name);
                mo.AddDisplacement(new Vector3(0f, h - pos.y, 0f));
                pos.y = h;
                if (MO.DoLog && (pos.y - h) < -.001 * Client.OneMeter)
                    MO.Log(string.Format(" MobNode at {0} is below ground height {1}!",
                                         pos, h));
            } // else {
                if (mobNode.FollowTerrain) {
            // 					NowColliding(mo, " Before falling loop");
                    // Fall toward the terrain or an obstacle, whichever comes
                    // first
                    float step = mo.StepSize(new Vector3(0, h, 0));
                    while (true) {
                        if (Math.Abs(pos.y - h) < CollisionAPI.VerticalTerrainThreshold * Client.OneMeter) {
                            mo.AddDisplacement(new Vector3(0f, h - pos.y, 0f));
                            pos.y = h;
                            break;
                        } else {
                            float dy = -Math.Min(pos.y - h, step);
                            Vector3 displacement = new Vector3(0, dy, 0);
                            Vector3 cd = displacement;
                            if (MO.DoLog) {
                                MO.Log(" Testing for collision falling {0}", dy);
                                TraceMOBottom(mo, " Before falling");
                            }
                            if (collisionManager.TestCollision(mo, ref displacement, parms)) {
                                if (MO.DoLog) {
                                    TraceMOBottom(mo, " After TestCollision after falling");
                                    NowColliding(mo, " After TestCollision after falling");
                                    MO.Log(" Collision when object {0} falls from {1} to {2}",
                                           parms.part.handle, pos, pos + cd);
                                    TraceObstacle(parms.obstacle);
                                    MO.Log(" Adding dy {0} - displacement.y {1} to pos {2}",
                                           dy, displacement.y, pos);
                                }
                                pos.y += dy - displacement.y;
                                break;
                            }
                            if (MO.DoLog)
                                MO.Log(" Didn't collide falling; dy {0}, pos {1}",
                                       dy, pos);
                            pos.y += dy;
                        }
                    }
                } else {
                    if (MO.DoLog)
                        MO.Log(" Not falling because mobNode {0} doesn't have FollowTerrain",
                            mobNode.Oid);
                }
            // 			}

            if (MO.DoLog) {
                NowColliding(mo, " Leaving MoveMobNode");
                MO.Log("MoveMobNode returning pos {0}", pos);
                MO.Log("");
            }
            if (collided)
                log.DebugFormat("MoveMobNode collided: mobNode oid {0}, name {1}, orig pos {2}, displacement {3}, new pos {4}",
                    mobNode.Oid, mobNode.Name, start, requestedDisplacement, pos);
            else
                log.DebugFormat("MoveMobNode didn't collide: mobNode oid {0}, name {1}, orig pos {2}, displacement {3}, new pos {4}",
                    mobNode.Oid, mobNode.Name, start, requestedDisplacement, pos);
            return pos;
        }
        public Client()
        {
            this.MasterServer = DefaultMasterServer;
            this.LoginUrl = DefaultLoginUrl;
            this.WorldId = string.Empty;
            this.CharacterId = 0;
            log.InfoFormat("Starting up client; client version number is {0}", this.Version);
            // SetupDebug();

            if (instance == null)
                instance = this;
            ConfigManager.Initialize(LocalConfigFile);
        }
        public NameManager(Window rootWindow, Client client, 
						   WorldManager worldManager)
            : base(rootWindow, client, worldManager)
        {
            // Renderer that can be used to render stuff to a mesh
            // meshRenderer = new MultiverseRenderer(rootWindow);
            // font = new MultiverseFont("MV-Tahoma-30", "Tahoma", 30, meshRenderer,
            // 				          FontFlags.None, (char)32, (char)127);

            // fontMaterial = (Material)MaterialManager.Instance.Create("font-material");
            // SetupFontMaterial();

            nameDictionary = new Dictionary<long, NameNode>();

            if (FontManager.Instance.ContainsKey("NameFont"))
                font = FontManager.Instance.GetFont("NameFont");
            else
                font = FontManager.Instance.CreateFont2("NameFont", "Verdana", 10);
        }
        public BaseInputHandler(Client client)
        {
            this.client = client;
            client.InputHandler = this;

            // retrieve and initialize the input system
            InputReader reader = PlatformManager.Instance.CreateInputReader();
            reader.Initialize(client.Window, true, true, false,
                              !client.UseCooperativeInput, !client.UseCooperativeInput);

            reader.UseKeyboardEvents = true;
            reader.UseMouseEvents = true;

            Attach(reader);
        }
        public DefaultInputHandler(Client client)
            : base(client)
        {
            this.sceneManager = client.WorldManager.SceneManager;

            ParameterRegistry.RegisterSubsystemHandlers("Camera", setCameraParameterHandler,
                                                        getCameraParameterHandler);

            cameraTargetOffset = headHeightAbovePlayerOrigin * Vector3.UnitY;
             		    cameraOrientation = Quaternion.FromAngleAxis(MathUtil.DegreesToRadians(-20.0f), Vector3.UnitX);
        }
 public GuiInputHandler(Client client)
     : base(client)
 {
 }
        /// <summary>
        ///   Simple constructor that takes a reference to the game client, 
        ///   and sets up the basic game state.
        ///   In this case, that state contains information about inventory,
        ///   quests, group membership, and the colors to use for chat.
        /// </summary>
        /// <param name="client">the client class</param>
        public MarsWorld(Client client)
        {
            this.client = client;

            // Set up the global instance
            instance = this;
        }
示例#10
0
        private static void Main(string[] args)
        {
            // Changes the CurrentCulture of the current thread to the invariant
            // culture.
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            // Setup any per-user folder structer that we need.
            SetupUserFolders();

            List <string> extraArguments = new List <string>();

            try
            {
                bool patch = true;
#if PERFHUD_BUILD
                patch = false;
#endif
                bool   unhandledArguments = false;
                string logFileOverride    = null;
                string updateUrl          = null;
                string patchUrl           = null;
                bool   force_scan         = false;
                bool   exit_after_patch   = false;
                for (int i = 0; i < args.Length; ++i)
                {
                    switch (args[i])
                    {
                    case "--noupdate":
                    case "--no_client_update":
                        patch = false;
                        break;

                    case "--update_url":
                        Debug.Assert(i + 1 < args.Length);
                        updateUrl = args[++i];
                        break;

                    case "--patch_url":
                    case "--patcher_url":
                        Debug.Assert(i + 1 < args.Length);
                        patchUrl = args[++i];
                        break;

                    case "--force_scan":
                        force_scan = true;
                        break;

                    // Now handle arguments we want to pass through
                    case "--master":
                    case "--world":
                    case "--login_page":
                    case "--world_settings_file":
                    case "--log_level":
                        Debug.Assert(i + 1 < args.Length);
                        extraArguments.Add(args[i]);
                        extraArguments.Add(args[++i]);
                        break;

                    case "--log_config":
                        Debug.Assert(i + 1 < args.Length);
                        logFileOverride = args[++i];
                        break;

                    default:
                        if (!exit_after_patch)
                        {
                            unhandledArguments = true;
                        }
                        exit_after_patch = true;
                        break;
                    }
                }

                // initialize logging
                bool   interactive   = System.Windows.Forms.SystemInformation.UserInteractive;
                string logConfigFile = Path.Combine(ConfigFolder, "LogConfig.xml");
                if (logFileOverride != null)
                {
                    logConfigFile = logFileOverride;
                }
                LogUtil.InitializeLogging(logConfigFile, Path.Combine("..", "DefaultLogConfig.xml"), FallbackLogfile, interactive);

                System.Text.StringBuilder sb = new System.Text.StringBuilder();
                foreach (string s in args)
                {
                    sb.AppendFormat("{0} ", s);
                }

                log.InfoFormat("Client command line arguments: {0}", sb.ToString());

                if (unhandledArguments)
                {
                    log.Info("Got extra arguments; Will exit after patch if a client patch is required.");
                }

                if (patch)
                {
                    log.Info("Checking if restart required");
                    try
                    {
                        if (Patch(updateUrl, patchUrl, extraArguments.ToArray(), force_scan, exit_after_patch))
                        {
                            log.Info("Restart required");
                            return;
                        }
                    }
                    catch (Exception e)
                    {
                        LogUtil.ExceptionLog.ErrorFormat("Version determination failed: {0}", e);
                        throw;
                    }
                }

                string errorMessage = null;
                string errorPage    = null;

                // this.Hide();
                // this.WindowState = FormWindowState.Minimized;
                // create an instance of the client class and start it up
                // We use the using declaration here so that we dispose of the object
                using (Client client = new Multiverse.Base.Client())
                {
#if PERFHUD_BUILD
                    client.standalone = true;
                    client.PatchMedia = false;
                    client.Repository = "../../../Media/";
                    // Debug.Assert(false, "Breakpoint for Debug");
#endif
                    for (int i = 0; i < args.Length; ++i)
                    {
                        switch (args[i])
                        {
                        case "--standalone":
                            client.standalone = true;
                            client.WorldId    = "standalone";
                            break;

                        case "--debug":
                            client.doTraceConsole = true;
                            break;

                        case "--simple_terrain":
                            client.simpleTerrain = true;
                            break;

                        case "--config":
                            client.doDisplayConfig = true;
                            break;

                        case "--tocFile":
                            Debug.Assert(i + 1 < args.Length);
                            client.uiModules.Add(args[++i]);
                            break;

                        case "--master":
                            Debug.Assert(i + 1 < args.Length);
                            client.MasterServer = args[++i];
                            break;

                        case "--world":
                        case "--world_id":
                            Debug.Assert(i + 1 < args.Length);
                            client.WorldId = args[++i];
                            break;

                        case "--character":
                            Debug.Assert(i + 1 < args.Length);
                            client.CharacterId = long.Parse(args[++i]);
                            break;

                        case "--login_url":
                            Debug.Assert(i + 1 < args.Length);
                            client.LoginUrl = args[++i];
                            break;

                        case "--login_page":
                            Debug.Assert(i + 1 < args.Length);
                            client.LoginUrl = LoginBase + args[++i];
                            break;

                        case "--noupdate":
                        case "--no_media_update":
                            client.PatchMedia = false;
                            break;

                        case "--world_patcher_url":
                            Debug.Assert(i + 1 < args.Length);
                            log.Warn("--world_patcher_url argument will not be honored by the login patcher");
                            client.WorldPatcherUrl = args[++i];
                            break;

                        case "--world_update_url":
                            Debug.Assert(i + 1 < args.Length);
                            log.Warn("--world_update_url argument will not be honored by the login patcher");
                            client.WorldUpdateUrl = args[++i];
                            break;

                        case "--world_settings_file":
                            Debug.Assert(i + 1 < args.Length);
                            WorldSettingsFile = args[++i];
                            break;

                        case "--logcollisions":
                            client.logCollisions = true;
                            break;

                        case "--frames_between_sleeps":
                            Debug.Assert(i + 1 < args.Length);
                            client.FramesBetweenSleeps = int.Parse(args[++i]);
                            break;

                        case "--log_level":
                            Debug.Assert(i + 1 < args.Length);
                            SetLogLevel(args[++i], false);
                            break;

                        case "--development":
                            client.UseRepository       = true;
                            client.FramesBetweenSleeps = 2;
                            client.PatchMedia          = false;
                            break;

                        case "--use_default_repository":
                            client.UseRepository = true;
                            client.PatchMedia    = false;
                            break;

                        case "--repository_path":
                            client.RepositoryPaths.Add(args[++i]);
                            client.PatchMedia    = false;
                            client.UseRepository = true;
                            break;

                        case "--maxfps":
                            client.MaxFPS = int.Parse(args[++i]);
                            break;

                        case "--log_terrain":
                            client.LogTerrainConfig = true;
                            break;

                        case "--coop_input":
                            // Used when running from the debugger
                            client.UseCooperativeInput = true;
                            break;

                        case "--tcp":
                            client.UseTCP = true;
                            break;

                        case "--rdp":
                            client.UseTCP = false;
                            break;

                        case "--display_config":
                            client.manualDisplayConfigString = args[++i];
                            break;

                        case "--fullscreen":
                            client.manualFullscreen = true;
                            break;

                        case "--fixed_fps":
                            client.FixedFPS = int.Parse(args[++i]);
                            break;

                        case "--client_patch_only":
                            return;

                        case "--media_patch_only":
                            client.ExitAfterMediaPatch = true;
                            break;

                        case "--allow_resize":
                            Debug.Assert(i + 1 < args.Length);
                            client.AllowResize = bool.Parse(args[++i]);
                            break;

                        case "--log_config":
                            // this is handled up above, but ignore it here
                            Debug.Assert(i + 1 < args.Length);
                            ++i;
                            break;

                        // These are the arguments used by the patcher
                        case "--no_client_update":
                        case "--force_scan":
                            break;

                        case "--update_url":
                        case "--patch_url":
                        case "--patcher_url":
                            ++i;
                            break;

                        default:
                            // Handle -Dproperty=value arguments
                            if (args[i].StartsWith("-D") && args[i].Contains("="))
                            {
                                char[]   delims = { '=' };
                                string[] tmp    = args[i].Substring(2).Split(delims, 2);
                                client.SetParameter(tmp[0], tmp[1]);
                            }
                            else
                            {
                                Console.WriteLine("Invalid argument " + args[i]);
                            }
                            break;
                        }
                    }
                    client.GameWorld = new Multiverse.Base.MarsWorld(client);

                    client.SourceConfig(Path.Combine(ConfigFolder, WorldSettingsFile));
                    try
                    {
                        client.Start();
                    }
                    catch (Exception ex)
                    {
                        LogUtil.ExceptionLog.ErrorFormat("Exiting client due to exception: {0}", ex);
                        errorMessage = ex.Message;
                    }
                    log.Info("Exiting client");
                    if (errorPage == null)
                    {
                        errorPage = client.ErrorPage;
                    }
                    if (errorMessage == null)
                    {
                        errorMessage = client.ErrorMessage;
                    }
                } // using client
                bool errorShown = false;
                if (errorPage != null)
                {
                    string fullPath = Path.GetFullPath("../html/" + errorPage);
                    if (File.Exists(fullPath))
                    {
                        Multiverse.Base.HtmlWindow tmp = new Multiverse.Base.HtmlWindow("file://" + fullPath);
                        tmp.Text = "Multiverse Client Error";
                        tmp.ShowDialog();
                        errorShown = true;
                    }
                }
                if (!errorShown && errorMessage != null)
                {
                    Dialog tmp = new Dialog();
                    tmp.TopMost = true;
                    tmp.Text    = "Client Shutting Down!";
                    tmp.Message = errorMessage;
                    tmp.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                // call the existing global exception handler
                LogUtil.ExceptionLog.ErrorFormat("Exited client due to exception: {0}", ex);
                Dialog tmp = new Dialog();
                tmp.TopMost = true;
                tmp.Text    = "Alert";
                tmp.Message = ex.Message;
                tmp.ShowDialog();
            }
            finally
            {
                log.Info("Cleaning up");
                log.Info("Exiting Client");
                LogManager.Shutdown();
                GC.Collect();
                // Kernel.SetProcessWorkingSetSize(Process.GetCurrentProcess().Handle, -1, -1);
                // this.WindowState = FormWindowState.Normal;
                // this.Show();
                Application.Exit();
            }
        }