static void Main()
        {
            try
            {
                //String gameDirectory = @"C:\Users\Jonathan Marler\Desktop\CastleDoctrine_v31";
                //String gameDirectory = @"D:\Tools\CastleDoctrine_v32";
                String gameDirectory = Environment.CurrentDirectory;

                String cdServerHostname = "thecastledoctrine.net";
                //String cdServerConnectorString = "gateway:proxy.houston.hp.com:8080%thecastledoctrine.net";


                //
                // Initialize Static Variables
                //
                CDLoader.Load(gameDirectory);
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                houseViewerForm = new HouseViewerForm();

                //
                // Setup WebProxy
                //
                ISocketConnector cdConnector = CDProxy.SetupProxyInterceptor(gameDirectory);


                //
                // Start the listen thread
                //
                EndPoint           cdServerEndPoint = EndPoints.EndPointFromIPOrHost(cdServerHostname, 80);
                GameClientAcceptor acceptor         = new GameClientAcceptor(cdServerEndPoint, cdConnector);
                selectServer = new TcpSelectServer2(new Byte[2048], new TcpSelectListener2[] {
                    new TcpSelectListener2(new IPEndPoint(IPAddress.Any, 80), 32, acceptor.Accept),
                });

                acceptor.selectServer = selectServer;

                Thread listenThread = new Thread(selectServer.Run);
                listenThread.Name = "ListenThread";
                listenThread.Start();

                Application.Run(houseViewerForm);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            finally
            {
                CDProxy.RestoreProxy();
            }
        }
        public static void HandleEncryptedMap(Byte[] mapKey, Byte[] encryptedData)
        {
            //
            // Decrypt the map
            //
            //Console.WriteLine("SHA: {0}", BitConverter.ToString(mapKey));
            //Console.WriteLine("DAT: {0}", BitConverter.ToString(encryptedData));

            String map = CDSha.Decrypt(mapKey, encryptedData);

            String[] objectIds = map.Split('#');
            if (objectIds.Length != 1024)
            {
                throw new FormatException(String.Format(
                                              "Expected map.Split('#') to be 1024 but was {0}", objectIds.Length));
            }

            //CDLoader.PrintMap(objectIds);

            HouseObjectDefinition[] mapObjects = CDLoader.ParseMap(objectIds);
            houseViewerForm.Invoke((Action)(() => { houseViewerForm.LoadMap(mapObjects); }));
        }