public void RunServer()
		{
			Server = Framework.GetInstance();
			this.form = Abstraction.GetInstance();
			this.Init();
			this.Setup();
		}
		public void RunServer()
		{
			this.Build();
			this.ShowAll();

			//this.Server = Framework.GetInstance();
			this.PMWindowManager = PMWindowList.GetInstance();
			//this.Server.RunServer();
			this.form = Abstraction.GetInstance();
		}
示例#3
0
 /// <summary>
 /// Constructor by Account / Id
 /// </summary>
 internal Player(Int16 Id)
     : base(Id)
 {
     this.Server = Framework.GetInstance();
     this.form = Abstraction.GetInstance();
     this.Id = Id;
     this.ColorManager = new OpenGraal.Common.Players.ColorManager(new OpenGraal.Common.Players.ColorManager.dSendColors(SendColors));
     this.FlagManager = new OpenGraal.Common.Players.FlagManager(new OpenGraal.Common.Players.FlagManager.dSendFlag(SendFlag));
     //this.form.AddPlayer(this.id, this.account);
 }
        public void ReceivedPM(Player Player, CString Message)
        {
            this.form = Abstraction.GetInstance();
            this.form.WriteText(" -!- Received PM from " + Player.Account.ToString() + "!\n");

            PMWindowManager = PMWindowList.GetInstance();
            PMWindow PM = PMWindowManager.AddPMWindow(Player.Id);

            if (PM != null)
            {
                PM.SetMessage(Message);
            }
        }
		public void SendLogin(String Account, String Password, String Nickname)
		{
			this.Codec.Reset(Encrypt.Generation.GEN5);
			//Set the nickname
			this.Nickname = Nickname;
			this.form = Abstraction.GetInstance();
			string versionStr = "G3D0208A";

			// Key Packet // GNW03014 // G3D14097 // G3D0208A // GSERV025
			if (this.form.isRC)
			{
				versionStr = "GSERV025";
			}

			this.SendLogin(Account, Password, Nickname, versionStr, this.form.isRC);

			this.ReceiveData();
		}
		public void ReceivedToall(GraalPlayer Player, CString Message)
		{
			this.form = Abstraction.GetInstance();

			ToallsWindow PM = ToallsWindow.GetInstance();

			if (PM != null)
			{
				PM.SetMessage(Player, Message);
			}
		}
示例#7
0
        /*
        /// <summary>
        /// Send Colors
        /// </summary>
        internal void SendColors()
        {
            this.SendProp(Properties.PLCOLORS);
        }

        /// <summary>
        /// Send Flag to Framework
        /// </summary>
        internal void SendFlag(String FlagName, String FlagValue)
        {
            // fix packet for flag
            //Server.SendGSPacket(new CString() + (byte)GServerConnection.PacketOut.NC_NPCGET + (byte)GServerConnection.NCREQ.PLSETFLAG + (short)Id + FlagName + "=" + FlagValue);
        }

        /// <summary>
        /// Send Prop to GServer
        /// </summary>
        internal void SendProp(Properties PropId)
        {
            //Server.SendGSPacket(new CString() + (byte)GServerConnection.PacketOut.NC_NPCGET + (byte)GServerConnection.NCREQ.PLSETPROPS + (short)this.Id + (byte)PropId + GetProp(PropId));
        }

        /// <summary>
        /// Set Player Guild
        /// </summary>
        internal void SetGuild(string GuildName)
        {
            int guildStart, guildEnd;
            if ((guildStart = Nickname.IndexOf('(')) >= 0)
            {
                if ((guildEnd = Nickname.IndexOf(')', guildStart)) >= 0)
                    Nickname = Nickname.Substring(0, guildStart).TrimEnd();
            }

            if (GuildName != String.Empty)
                Nickname += " (" + GuildName + ")";
        }

        /// <summary>
        /// Set Player Nickname
        /// </summary>
        /// <param name="Nickname"></param>
        internal void SetNick(string Nickname)
        {
            // Set Nickname
            this.Nickname = Nickname;
            this.Guild = "";

            // Parse Guild
            int len = Nickname.LastIndexOf('(');
            if (len != -1)
            {
                int len2 = Nickname.LastIndexOf(')');
                if (len2 > len)
                    this.Guild = Nickname.Substring(len + 1, len2 - len - 1);
            }

            this.form.AddPlayer(this.account, this.Nickname);

        }
        */
        /// <summary>
        /// Set Properties
        /// </summary>
        public void SetProps(CString Packet)
        {
            this.form = Abstraction.GetInstance();
            bool moved = false;

            while (Packet.BytesLeft > 0)
            {
                Int32 PropId = Packet.ReadGUByte1();
                //this.form.AddPlayer(this.Account, this.Account);
                switch ((Properties)PropId)
                {
                    case Properties.NICKNAME: // 0
                        {
                            this.SetNick(Packet.ReadChars(Packet.ReadGUByte1()));
                            //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.Nickname + "");
                            break;
                        }

                    case Properties.MAXPOWER: // 1
                        this.FullHearts = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.FullHearts + "\r\n");
                        break;

                    case Properties.CURPOWER: // 2
                        this.Hearts = (double)Packet.ReadGUByte1() / 2;
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.Hearts + "\r\n");
                        break;

                    case Properties.RUPEESCOUNT: // 3
                        this.Gralats = (int)Packet.ReadGUByte3();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.Gralats + "");
                        break;

                    case Properties.ARROWSCOUNT: // 4
                        this.Arrows = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.Arrows + "\r\n");
                        break;

                    case Properties.BOMBSCOUNT: // 5
                        this.Bombs = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.Bombs + "\r\n");
                        break;

                    case Properties.GLOVEPOWER: // 6
                        this.GlovePower = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.glovepower + "\r\n");
                        break;

                    case Properties.BOMBPOWER: // 7
                        this.BombPower = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.BombPower + "\r\n");
                        break;

                    case Properties.SWORDPOWER: // 8
                        {
                            Int32 sp = Packet.ReadGUByte1();
                            if (sp > 4)
                            {
                                sp -= 30;
                                Int32 len = Packet.ReadGUByte1();
                                if (len > 0)
                                    this.SwordImage = Packet.ReadChars(len);
                            }
                            else
                                this.SwordImage = "sword" + sp + ".png";

                            this.SwordPower = sp;
                            //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.swordpower + "\r\n");
                            break;
                        }

                    case Properties.SHIELDPOWER: // 9
                        {
                            Int32 sp = Packet.ReadGUByte1();
                            if (sp > 3)
                            {
                                sp -= 10;
                                if (sp < 0)
                                    break;
                                Int32 len = Packet.ReadGUByte1();
                                if (len > 0)
                                    this.ShieldImage = Packet.ReadChars(len);
                            }
                            else
                                this.ShieldImage = "shield" + sp + ".png";

                            this.ShieldPower = sp;
                            //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.shieldpower + "\r\n");
                            break;
                        }

                    case Properties.ANIMATION: // 10
                        this.Ani = Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.ani + "\r\n");
                        break;

                    case Properties.HEADIMAGE: // 11
                        {
                            Int32 len = Packet.ReadGUByte1();
                            this.HeadImage = (len < 100 ? "head" + len + ".png" : Packet.ReadChars(len - 100));
                            //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.HeadImage + "");
                            break;
                        }

                    case Properties.CURCHAT:
                        {// 12
                            this.Chat = Packet.ReadChars(Packet.ReadGUByte1());
                            //if (PlayerLevel != null)
                            //	PlayerLevel.CallNPCs("onPlayerChats", new object[] { this });

                            if (this.Chat != null && this.Chat != "" && this.Account != "" && this.Account != null)
                                this.form.WriteText("(" + this.Account + ") " + this.Chat + "");

                            break;
                        }
                    case Properties.PLCOLORS: // 13
                        for (int i = 0; i < 5; i++)
                        {
                            this.ColorManager[i] = Packet.ReadGUByte1();
                            //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.ColorManager[i] + "\r\n");
                        }
                        break;

                    case Properties.PLAYERID: // 14
                        {
                            this.Id = (short)Packet.ReadGUByte2();
                            this.form.AddPlayer(this.Account, this.Account);
                            //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.Id + "");
                            break;

                        }
                    case Properties.PLAYERX: // 15 - obsolete
                        Packet.ReadGUByte1();
                        //this.X = ((double)Packet.ReadGUByte1() / 2);
                        //moved = true;
                    //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte1().ToString() + "\r\n");
                        break;

                    case Properties.PLAYERY: // 16 - obsolete
                        Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte1().ToString() + "\r\n");
                        //this.Y = ((double)Packet.ReadGUByte1() / 2);
                        //moved = true;
                        break;

                    case Properties.PLSPRITE: // 17
                        this.Dir = Packet.ReadGUByte1() % 4;
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.dir + "\r\n");
                        break;

                    case Properties.PLSTATUS: // 18
                        this.PlayerStatus = Packet.ReadGUByte1();
                        if ((this.PlayerStatus & (int)Status.DEAD) != 0)
                        {
                            //if (PlayerLevel != null)
                            //	PlayerLevel.CallNPCs("onPlayerDies", new object[] { this });
                        }
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.PlayerStatus + "");
                        break;

                    case Properties.CARRYSPRITE: // 19
                        Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte1().ToString() + "\r\n");
                        break;

                    case Properties.CURLEVEL: // 20
                        string levelName = Packet.ReadChars(Packet.ReadGUByte1()).Trim();
                        if (this.Level != null)
                            this.Level.DeletePlayer(this);
                        this.Level = Server.FindLevel(levelName);
                        this.Level.AddPlayer(this);
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.Level.Name + "");
                        break;

                    case Properties.HORSEIMG: // 21
                        Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadChars(Packet.ReadGUByte1()).ToString() + "\r\n");
                        break;

                    case Properties.HORSEBUSHES: // 22
                        Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte1().ToString() + "\r\n");
                        break;

                    case Properties.EFFECTCOLOR: // 23
                        {
                            int len = Packet.ReadGUByte1();
                            if (len > 0)
                                Packet.ReadGUByte4();
                            break;
                        }

                    case Properties.CARRYNPC: // 24
                        Packet.ReadGUByte3();
                    //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte3().ToString() + "\r\n");
                        break;

                    case Properties.APCOUNTER: // 25
                        Packet.ReadGUByte2();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte2().ToString() + "\r\n");
                        break;

                    case Properties.MAGICPOINTS: // 26
                        this.Magic = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.Magic.ToString() + "\r\n");
                        break;

                    case Properties.KILLSCOUNT: // 27
                        this.Kills = Packet.ReadGByte3();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.kills.ToString() + "\r\n");
                        break;

                    case Properties.DEATHSCOUNT: // 28
                        this.Deaths = Packet.ReadGByte3();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.deaths.ToString() + "\r\n");
                        break;

                    case Properties.ONLINESECS: // 29
                        this.OnlineTime = Packet.ReadGByte3();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.onlinetime.ToString() + "\r\n");
                        break;

                    case Properties.IPADDRESS: // 30
                        this.IPAddress = new System.Net.IPAddress(Packet.ReadGUByte5()).ToString();
                        this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.IPAddress.ToString() + "");
                        break;

                    case Properties.UDPPORT: // 31
                        int port = Packet.ReadGByte3();
                        this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + port.ToString() + "");
                        break;

                    case Properties.ALIGNMENT: // 32
                        Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte1().ToString() + "\r\n");
                        break;

                    case Properties.ADDITFLAGS: // 33
                        Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte1().ToString() + "\r\n");
                        break;

                    case Properties.ACCOUNTNAME: // 34
                        this.Account = Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.Account + "");
                        break;

                    case Properties.BODYIMAGE: // 35
                        this.BodyImage = Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.bodyimg + "\r\n");
                        break;

                    case Properties.PLRATING: // 36
                        Packet.ReadGUByte3();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte3().ToString() + "\r\n");
                        break;

                    case Properties.GATTRIB1: // 37
                    case Properties.GATTRIB2: // 38
                    case Properties.GATTRIB3: // 39
                    case Properties.GATTRIB4: // 40
                    case Properties.GATTRIB5: // 41
                        Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadChars(Packet.ReadGUByte1()).ToString() + "\r\n");
                        break;

                    case Properties.PLATTACHNPC: // 42
                        Packet.ReadGUByte4();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte4().ToString() + "\r\n");
                        break;

                    case Properties.GMAPLEVELX: // 43
                        GmapX = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + GmapX.ToString() + "\r\n");
                        break;

                    case Properties.GMAPLEVELY: // 44
                        GmapY = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + GmapY.ToString() + "\r\n");
                        break;

                    case Properties.PLAYERZ: // 45
                        Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte1().ToString() + "\r\n");
                        break;

                    case Properties.GATTRIB6: // 46
                    case Properties.GATTRIB7: // 47
                    case Properties.GATTRIB8: // 48
                    case Properties.GATTRIB9: // 49
                        Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadChars(Packet.ReadGUByte1()).ToString() + "\r\n");
                        break;

                    case Properties.JOINLEAVELV: // 50
                        byte joinLeaveLv = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + joinLeaveLv.ToString() + "");
                        break;

                    case Properties.CONNECTED: // 51
                        {
                            //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "] Disconnected\r\n");
                            this.form.RMPlayer(this.Account);
                            Server.PlayerManager.DeletePlayer(Id);

                            // disconnect player.
                            break;
                        }

                    case Properties.LANGUAGE: // 52
                        Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadChars(Packet.ReadGUByte1()).ToString() + "\r\n");
                        break;

                    case Properties.STATUSMSG: // 53
                        byte statusMsg = Packet.ReadGUByte1();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + statusMsg.ToString() + "");
                        break;

                    case Properties.GATTRIB10: // 54
                    case Properties.GATTRIB11: // 55
                    case Properties.GATTRIB12: // 56
                    case Properties.GATTRIB13: // 57
                    case Properties.GATTRIB14: // 58
                    case Properties.GATTRIB15: // 59
                    case Properties.GATTRIB16: // 60
                    case Properties.GATTRIB17: // 61
                    case Properties.GATTRIB18: // 62
                    case Properties.GATTRIB19: // 63
                    case Properties.GATTRIB20: // 64
                    case Properties.GATTRIB21: // 65
                    case Properties.GATTRIB22: // 66
                    case Properties.GATTRIB23: // 67
                    case Properties.GATTRIB24: // 68
                    case Properties.GATTRIB25: // 69
                    case Properties.GATTRIB26: // 70
                    case Properties.GATTRIB27: // 71
                    case Properties.GATTRIB28: // 72
                    case Properties.GATTRIB29: // 73
                    case Properties.GATTRIB30: // 74
                        Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadChars(Packet.ReadGUByte1()).ToString() + "\r\n");
                        break;

                    case Properties.OSTYPE: // 75
                        Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadChars(Packet.ReadGUByte1()).ToString() + "");
                        break;

                    case Properties.TEXTCODEPG: // 76
                        Packet.ReadGUByte3();
                        this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte3().ToString() + "");
                        break;

                    case Properties.UNKNOWN77: // 77
                        this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.Text.ToString() + "");
                        break;

                    case Properties.PIXELX: // 78
                        {
                            int tmp = this.PixelX = Packet.ReadGUByte2();

                            // If the first bit is 1, our position is negative.
                            this.PixelX >>= 1;
                            if ((tmp & 0x0001) != 0)
                                this.PixelX = -this.PixelX;
                            moved = true;
                            //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.PixelX.ToString() + "\r\n");
                            break;
                        }

                    case Properties.PIXELY: // 79
                        {
                            int tmp = this.PixelY = Packet.ReadGUByte2();

                            // If the first bit is 1, our position is negative.
                            this.PixelY >>= 1;
                            if ((tmp & 0x0001) != 0)
                                this.PixelY = -this.PixelY;
                            moved = true;
                            //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + this.PixelY.ToString() + "\r\n");
                            break;
                        }

                    case Properties.PIXELZ: // 80
                        Packet.ReadGUByte2();
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]" + Packet.ReadGUByte2().ToString() + "\r\n");
                        break;

                    case Properties.UNKNOWN81: // 81
                        this.isLocalPlayer = false;
                        this.form.WriteText("(" + this.Account + "(" + this.Id.ToString() + ")) I am on other server.");
                        break;

                    case Properties.COMMUNITY: // 82
                        string communityname = Packet.ReadChars(Packet.ReadGUByte1());
                        //this.form.WriteText("[" + this.Account + "(" + this.Id.ToString() + ")" + "][" + Enum.GetName(typeof(Properties), PropId).ToString() + "]: " + communityname + "");
                        break;

                    default:
                        {
                            //this.form.WriteText("[" + PropId + "] " + Packet.Text + "\r\n");
                            this.form.WriteText("(" + this.Account + "(" + this.Id.ToString() + ")" + ") [" + PropId.ToString() + "]" + Packet.Text.ToString() + "");
                            break;
                        }
                }
            }

            //if (moved && PlayerLevel != null)
            //{
            //bool onGmap = PlayerLevel.Name.EndsWith(".gmap");
            //GraalLevelNPC npc = PlayerLevel.isOnNPC(PixelX + touchtestd[dir*2], PixelY + touchtestd[dir*2+1]);
            //if (npc != null)
            //	npc.Call("onPlayerTouchsMe", new object[] { this });
            //}
        }
示例#8
0
        /*
        /// <summary>
        /// Accept incoming connection for NPC-Control
        /// </summary>
        /// <param name="ar"></param>
        protected void NCControl_Accept(IAsyncResult ar)
        {
            // Accept Socket
            NCConnection Client = new NCConnection(this, (Socket)NCListen.EndAcceptSocket(ar));
            Client.ReceiveData();
            NCList.Add(Client);

            // Listen for incoming connections
            NCListen.BeginAcceptSocket(cNCAccept, NCListen);
        }
        */
        /// <summary>
        /// Run NPC Server
        /// </summary>
        public void RunServer()
        {
            // Run Timeouts
            /*
            foreach (KeyValuePair<String, ServerWeapon> wep in WeaponList)
            {
                ScriptObj obj = (ScriptObj)wep.Value.ScriptObject;
                if (obj != null)
                    obj.RunEvents();
            }

            // Level-Npcs
            lock (TimerLock)
            {
                foreach (KeyValuePair<String, GraalLevel> lvl in LevelList)
                {
                    foreach (KeyValuePair<int, GraalLevelNPC> npc in lvl.Value.NpcList)
                    {
                        ScriptObj obj = (ScriptObj)npc.Value.ScriptObject;
                        if (obj != null)
                            obj.RunEvents();
                    }
                }
            }

            while (Compiler.RunList.Count > 0)
            {
                IRefObject obj;
                lock (Compiler.RunList)
                    obj = Compiler.RunList.Dequeue();
                obj.Call("onCreated", null);
            }
            */
            this.form = Abstraction.GetInstance();

            this.form.Activate();
            this.form.WriteText("--- OpenGraal Instant Messenger / Remote Control ---");
            this.serverWindow = ServerWindow.GetInstance();
            // Default PM
            this.NCMsg = CString.tokenize("I am the Framework for\nthis game server. Almost\nall npc actions are controled\nby me.");

            // Create Compiler
            //Compiler = new GameCompiler(this);

            // Create Player Manager
            PlayerManager = new GraalPlayerList();

            // Connect to GServer
            GSConn = (IGameServer)new Connections.GraalServer();
            GSConn.RunServer();

            if (this.serverWindow.nickname != null && this.serverWindow.nickname != "")
                this.nickname = this.serverWindow.nickname;

            if (this.serverWindow.username != null && this.serverWindow.username != "")
                this.username = this.serverWindow.username;

            if (this.serverWindow.password != null && this.serverWindow.password != "")
                this.password = this.serverWindow.password;

            if (this.serverWindow.gserver != null && this.serverWindow.gserver != "")
                server = this.serverWindow.gserver;

            if (this.serverWindow.gport != null && this.serverWindow.gport != 0)
                this.port = this.serverWindow.gport;

            //GSConn.Disconnect();
            if (!GSConn.Connected)
            {
                this.form.WriteText("Not connected, connecting...");
                this.form.WriteText("Address:\t" + this.server);
                this.form.WriteText("Port:\t\t" + this.port.ToString());
                GSConn.Connect(this.server, this.port);

            }
            else
                this.form.WriteText("Already connected!");

            if (GSConn.Connected)
            {
                GSConn.SendLogin(this.username, this.password, this.nickname);
            }
        }
        /// <summary>
        /// Handle Received Data
        /// </summary>
        /// 
        protected override void HandleData(CString Packet)
        {
            // Check if the instance of Framework is null and get the instance if it is.
            if (Server == null)
                Server = Framework.GetInstance();

            if (this.form == null)
                this.form = Abstraction.GetInstance();

            int prevPacket = 0;
            uint readc = 0;

            while (Packet.BytesLeft > 0)
            {
                CString CurPacket;

                // Grab Single Packet
                if (prevPacket == 100)
                    CurPacket = Packet.ReadChars2(readc);
                else
                    CurPacket = Packet.ReadString('\n');

                // Read Packet Type
                int PacketId = CurPacket.ReadGUByte1();

                // Run Internal Packet Function
                switch ((PacketIn)PacketId)
                {

                // Packet 6 - Set Active Level & Clear
                    case PacketIn.LEVELNAME:
                        //ActiveLevel = Server.FindLevel(CurPacket.ReadString().Text);
                        //ActiveLevel.Clear();
                        break;

                // Paceket 1 - Level Links
                    case PacketIn.LEVELLINK:
                        break;

                // Packet 3 - Level NPC Props
                    case PacketIn.NPCPROPS:
                        {
                            int npcId = CurPacket.ReadGByte3();
                            //if (ActiveLevel != null)
                            //	ActiveLevel.GetNPC(npcId).SetProps(CurPacket);
                            break;
                        }

                // Packet 5 - Level Signs
                    case PacketIn.LEVELSIGN:
                        break;

                // Packet 39 - Level Mod Time
                    case PacketIn.LEVELMODTIME:
                        uint modTime = CurPacket.ReadGUByte5();
                        //if (ActiveLevel != null)
                        //	ActiveLevel.SetModTime(modTime);
                        break;

                    case PacketIn.SIGNATURE:
                        {
                            this.form.WriteText("Connected!");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.PLAYERPROPS + (byte)PLPROPS.NICKNAME + (byte)this.Nickname.Length + this.Nickname);
                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "GraalEngine,pmguilds,\"\"");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "GraalEngine,pmservers,\"all\"");
                            //Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "GraalEngine,pmserverplayers,\"U Classic iPhone\"\n");

                            Server.SendGSPacket(new CString() + (byte)PacketOut.SENDTEXT + "GraalEngine,lister,options,globalpms=true,buddytracking=true,showbuddies=true");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.SENDTEXT + "GraalEngine,lister,verifybuddies,1,1964252486");

                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "GraalEngine,lister,addbuddy,\"unixmad\"");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "GraalEngine,lister,addbuddy,\"stefan\"");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "GraalEngine,lister,addbuddy,\"tig\"");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "GraalEngine,lister,addbuddy,\"skyld\"");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "GraalEngine,lister,addbuddy,\"xor\"");
                            //Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "-ShopGlobal,lister,getglobalitems\n");

                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "-Serverlist,lister,list,all");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "-Serverlist,lister,upgradeinfo\n");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "-Serverlist,lister,subscriptions\n");
                            Server.SendGSPacket(new CString() + (byte)PacketOut.REQUESTTEXT + "-Serverlist,lister,getlockcomputer");

                            // Logging into IRC.
                            Server.SendGSPacket(new CString() + (byte)154 + "-Serverlist_Chat,irc,login,-");
                            Server.SendGSPacket(new CString() + (byte)154 + "-Serverlist_Chat,irc,privmsg,IRCBot,!geteventbots");
                            Server.SendGSPacket(new CString() + (byte)154 + "-Serverlist_Chat,irc,join,#graalim");

                            break;
                        }

                    case PacketIn.BOARDPACKET:
                        {
                            break;
                        }

                    case PacketIn.RAWDATA:
                        readc = CurPacket.ReadGUByte3();
                        Console.WriteLine(":::readc::::" + readc.ToString() + "::::");
                        break;

                // Packet 150 - Delete Level NPC
                    case PacketIn.NPCDEL2:
                        //Server.FindLevel(CurPacket.ReadChars(CurPacket.ReadGUByte1())).DeleteNPC(CurPacket.ReadGByte3());
                        break;

                // Packet 156 - Set Active Level
                    case PacketIn.SETACTIVELEVEL:
                        //ActiveLevel = Server.FindLevel(CurPacket.ReadString().Text);
                        break;

                    case PacketIn.ADDPLAYER:
                        {
                            Player Player = (Player)Server.PlayerManager.AddPlayer(CurPacket.ReadGByte2());

                            if (Player != null)
                            {
                                Player.Account = CurPacket.ReadChars(CurPacket.ReadGUByte1());
                                Player.SetProps(CurPacket);
                            }

                            break;
                        }

                    case PacketIn.DELPLAYER:
                        {
                            short pId = CurPacket.ReadGByte2();
                            Server.PlayerManager.DeletePlayer(pId);
                            break;
                        }

                // Add Player & Set Props
                    case PacketIn.OTHERPLPROPS:
                        {
                            Player Player = (Player)Server.PlayerManager.AddPlayer(CurPacket.ReadGByte2());

                            if (Player != null)
                            {
                                Player.SetProps(CurPacket);
                            }

                            break;
                        }

                    case PacketIn.FLAGSET:
                        {
                            Player Player = (Player)Server.PlayerManager.AddPlayer(CurPacket.ReadGByte2());
                            String FlagName = CurPacket.ReadString('=').Text;
                            String FlagValue = CurPacket.ReadString().Text;
                            if (Player != null)
                                Player.Flags[FlagName] = FlagValue;
                            break;
                        }

                    case PacketIn.PLAYERPROPS:
                        {
                            if (this.form.NCPlayer == null)
                                this.form.NCPlayer = Server.PlayerManager.AddPlayer(0);
                            //this.form.WriteText(" -!- ME!\r\n");
                            this.form.NCPlayer.SetProps(CurPacket);
                            break;
                        }

                // Add weapon to list
                    case PacketIn.NPCWEAPONADD:
                        {
                            String WeaponName = CurPacket.ReadChars(CurPacket.ReadGUByte1());
                            String WeaponImage = CurPacket.ReadChars(CurPacket.ReadGUByte1());
                            String WeaponScript = CurPacket.ReadString().Text;
                            //Server.SetWeapon(WeaponName, WeaponImage, WeaponScript, false);
                            break;
                        }

                // Add/Remove weapon from Player
                    case PacketIn.NPCWEAPONDEL:
                        {
                            Player Player = Server.PlayerManager.AddPlayer(CurPacket.ReadGByte2());
                            if (Player != null)
                            {
                                bool addWeapon = (CurPacket.ReadGByte1() > 0);
                                String name = CurPacket.ReadString().Text;
                                if (addWeapon)
                                    Player.AddWeapon(name);
                                else
                                    Player.DeleteWeapon(name, false);
                            }

                            break;
                        }

                    case PacketIn.UNKNOWN60:
                        {
                            Player Player = Server.PlayerManager.AddPlayer(CurPacket.ReadGByte2());
                            if (Player != null)
                            {
                                while (CurPacket.BytesLeft > 0)
                                    Player.AddWeapon(CurPacket.ReadChars(CurPacket.ReadGUByte1()));
                            }
                            break;
                        }

                    case PacketIn.NEWWORLDTIME: // Remove Class from List
                        Server.NWTime = CurPacket.ReadGByte4();
                        break;

                // Private Message
                    case PacketIn.PRIVATEMESSAGE:
                        {
                            short PlayerId = CurPacket.ReadGByte2();
                            CString Message = CurPacket.ReadString();

                            this.ReceivePM(PlayerId, Message);

                            break;
                        }
                    case PacketIn.TOALL:
                        {

                            short PlayerId = CurPacket.ReadGByte2();
                            CString Message = CurPacket.ReadString();
                            //this.form.WriteText(Message.Text);
                            this.ReceiveToall(PlayerId, Message);

                            break;
                        }
                    case PacketIn.RC_SERVEROPTIONSGET:
                        string serverOptions = CurPacket.ReadString().Untokenize().ToString();
                        this.form.WriteText(serverOptions);
                        break;
                    case PacketIn.RC_SERVERFLAGSGET:
                        int serverFlagsTotal = CurPacket.ReadGByte2();
                        List<string> serverFlags = new List<string>();
                        string serverFlagsString = "";
                        while (CurPacket.BytesLeft > 0)
                        {
                            serverFlags.Add(CurPacket.ReadChars(CurPacket.ReadGUByte1()));
                        }
                        serverFlags.Sort();
                        foreach (string sf in serverFlags)
                            serverFlagsString += sf + "\n";

                        this.ReceivedServerFlags(serverFlagsTotal, serverFlagsString);
                        break;
                    case PacketIn.RC_FOLDERCONFIGGET:
                        //CString s2 = CurPacket.Untokenize();
                        string folderConfig = CurPacket.ReadString().Untokenize().ToString();
                        this.ReceivedFolderConfig(folderConfig);
                        break;
                    case PacketIn.RC_FILEBROWSER_DIR:
                        //CString s2 = CurPacket.Untokenize();
                        this.form.WriteText(CurPacket.ReadString().ToString());
                        break;
                    case PacketIn.RC_FILEBROWSER_DIRLIST:
                        List<string> fileBrowserDirList = new List<string>(CurPacket.ReadString().Untokenize().ToString().Split('\n'));
                        fileBrowserDirList.Sort();
                        foreach (string dir in fileBrowserDirList)
                            this.form.WriteText(dir);
                        break;
                    case PacketIn.RC_FILEBROWSER_MESSAGE:
                        this.form.WriteText(CurPacket.ReadString().ToString());
                        break;
                // Servertext
                    case PacketIn.SERVERTEXT:
                        {
                            CString Message = CurPacket.ReadString();

                            this.form = Abstraction.GetInstance();

                            string TheMessage2 = "";
                            TheMessage2 = CString.untokenize(Message.Text);
                            string[] test = TheMessage2.Split('\n');
                            List<string> test2 = new List<string>(test);

                            if (test2[0].Trim() == "GraalEngine" || test2[0].Trim() == "-Playerlist")
                            {
                                if (test2[1].Trim() == "lister")
                                {
                                }
                            }
                            else if (test2[0].Trim() == "-Serverlist_Chat")
                            {
                                if (test2[1].Trim() == "irc")
                                {
                                    switch (test2[2].Trim())
                                    {
                                        case "join":
                                            {
                                                this.form.OpenIRC(test2[3].Trim());
                                                break;
                                            }

                                        case "addchanneluser"://[SERVERTEXT]: -Serverlist_Chat irc addchanneluser #graal CrypticMyst login1 Gos_Pira
                                            {
                                                this.form.IRC_AddChannelUser(test2[3].Trim(), test2[4].Trim());
                                                break;
                                            }
                                        case "deletechanneluser"://[SERVERTEXT]: -Serverlist_Chat irc delchanneluser #graal CrypticMyst
                                            {
                                                this.form.IRC_AddChannelUser(test2[3].Trim(), test2[4].Trim(), true);
                                                break;
                                            }
                                        case "privmsg":
                                            {
                                                string message = test2[5].Trim();
                                                if (test2[4].Trim().StartsWith("#"))
                                                    this.form.IRC_Privmsg(test2[3].Trim(), test2[4].Trim(), message);
                                                else
                                                {

                                                    this.ReceivePM(test2[3].Trim(), new CString(message));
                                                }
                                                break;
                                            }

                                        default:
                                            {

                                                break;
                                            }
                                    }

                                }
                            }
                            else if (test2[0].Trim() == "-Serverlist")
                            {
                                if (test2[1].Trim() == "lister")
                                {
                                    #region SimpleServerList
                                    if (test2[2].Trim() == "subscriptions2")
                                    {
                                        string subscription = "Trial";
                                        //this.form.WriteText(test2.Count.ToString());

                                        if (test2.Count > 3)
                                        {
                                            //this.form.WriteText(test2.Count.ToString());
                                            string server2 = CString.untokenize(test2[3].Trim());
                                            string[] test3 = server2.Split('\n');
                                            subscription = test3[1].Trim();
                                        }

                                        this.form.SetSubscriptionText("Subscription: " + subscription);
                                    }
                                    else if (test2[2].Trim() == "lockcomputer")
                                    {
                                        int locked = 0;
                                        int.TryParse(test2[3].Trim(), out locked);

                                        this.form.SetLockedByComputerText("Locked by PC-ID: " + ((locked == 1) ? "Yes" : "No"));
                                    }
                                    else if (test2[2].Trim() == "simpleserverlist" || test2[2].Trim() == "serverlist")
                                    {
                                        List<string> servers = test2;
                                        servers.RemoveRange(0, 3);
                                        this.form.WriteText("SERVERS(" + servers.Count + "):");
                                        this.form.WriteText("------------");
                                        //this.form.WriteText("[SERVERTEXT]: " + TheMessage2 + "");
                                        foreach (string server in servers)
                                        {
                                            //CString server2 = new CString();
                                            //server2.Write(server);
                                            if (server != "")
                                            {
                                                string server2 = CString.untokenize(server);
                                                string[] test3 = server2.Split('\n');
                                                //this.form.Write_Text(server2 + "\r\n");
                                                var servername = "";
                                                var servertype = "";
                                                if (test3[1].Trim().Substring(0, 2) == "P " || test3[1].Trim().Substring(0, 2) == "H " || test3[1].Trim().Substring(0, 2) == "3 " || test3[1].Trim().Substring(0, 2) == "U ")
                                                {
                                                    servertype = test3[1].Trim().Substring(0, 2);
                                                    servername = test3[1].Trim().Substring(2, test3[1].Trim().Length - 2);
                                                    if (servertype == "P ")
                                                        servertype = "Gold";
                                                    if (servertype == "H ")
                                                        servertype = "Hosted";
                                                    if (servertype == "3 ")
                                                        servertype = "3D";
                                                    if (servertype == "U ")
                                                        servertype = "Hidden";
                                                }
                                                else
                                                {
                                                    servertype = "Classic";
                                                    servername = test3[1].Trim();
                                                }

                                                var serverid = test3[0].Trim();
                                                var serverpc = test3[2].Trim();

                                                this.form.WriteText(" * Id: " + serverid + " Type: " + servertype + " Name: " + servername + " Players: " + serverpc + "");
                                            }

                                        }
                                        this.form.WriteText("");
                                    }
                                    else
                                        this.form.WriteText("[SERVERTEXT]: " + TheMessage2.Replace("\r\n", ",") + "");
                                    #endregion
                                }
                            }
                            else
                            { }// this.form.WriteText("[SERVERTEXT]: " + TheMessage2.Replace("\r\n", ",") + "");

                            break;
                        }

                    case PacketIn.SHOWIMG:
                        {
                            break;
                        }
                    case PacketIn.DISCMESSAGE:
                        {
                            //Console.WriteLine("PacketId: " + PacketId.ToString());
                            string packetName = "";//Enum.GetName(typeof(PacketIn), PacketId).ToString();
                            this.form.WriteText("Disconnect: " + CurPacket.ReadString().Text + "\r\n");

                            break;
                        }
                    case PacketIn.RC_CHAT:
                        this.form.WriteText(CurPacket.ReadString().Text + "");
                        break;
                    default:
                        {
                            Console.WriteLine("PacketId: " + PacketId.ToString());
                            try
                            {
                                string packetName = Enum.GetName(typeof(PacketIn), PacketId).ToString();
                                this.form.WriteText("[" + packetName + "]: " + CurPacket.ReadString().Text + "");
                            }
                            catch (IndexOutOfRangeException e)
                            {

                            }
                            catch (NullReferenceException e)
                            {

                            }
                            break;
                        }
                }

                prevPacket = PacketId;

            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 private GServerConnection()
 {
     Server = Framework.GetInstance();
     this.form = Abstraction.GetInstance();
     //this.ReceiveData();
 }
        private void ReceiveToall(Player Player, CString Message)
        {
            this.form = Abstraction.GetInstance();
            //this.form.WriteText(" -!- Received toall from " + Player.Account.ToString() + "!\n");

            ToallsWindow PM = ToallsWindow.GetInstance();

            if (PM != null)
            {
                PM.SetMessage(Player, Message);
            }
        }
示例#12
0
        /*
         * /// <summary>
         * /// Accept incoming connection for NPC-Control
         * /// </summary>
         * /// <param name="ar"></param>
         * protected void NCControl_Accept(IAsyncResult ar)
         * {
         *      // Accept Socket
         *      NCConnection Client = new NCConnection(this, (Socket)NCListen.EndAcceptSocket(ar));
         *      Client.ReceiveData();
         *      NCList.Add(Client);
         *
         *      // Listen for incoming connections
         *      NCListen.BeginAcceptSocket(cNCAccept, NCListen);
         * }
         */
        /// <summary>
        /// Run NPC Server
        /// </summary>
        public void RunServer()
        {
            // Run Timeouts

            /*
             * foreach (KeyValuePair<String, ServerWeapon> wep in WeaponList)
             * {
             *      ScriptObj obj = (ScriptObj)wep.Value.ScriptObject;
             *      if (obj != null)
             *              obj.RunEvents();
             * }
             *
             * // Level-Npcs
             * lock (TimerLock)
             * {
             *      foreach (KeyValuePair<String, GraalLevel> lvl in LevelList)
             *      {
             *              foreach (KeyValuePair<int, GraalLevelNPC> npc in lvl.Value.NpcList)
             *              {
             *                      ScriptObj obj = (ScriptObj)npc.Value.ScriptObject;
             *                      if (obj != null)
             *                              obj.RunEvents();
             *              }
             *      }
             * }
             *
             * while (Compiler.RunList.Count > 0)
             * {
             *      IRefObject obj;
             *      lock (Compiler.RunList)
             *              obj = Compiler.RunList.Dequeue();
             *      obj.Call("onCreated", null);
             * }
             */
            this.form = Abstraction.GetInstance();

            this.form.Activate();
            this.form.WriteText("--- OpenGraal Instant Messenger / Remote Control ---");
            this.serverWindow = ServerWindow.GetInstance();
            // Default PM
            this.NCMsg = CString.tokenize("I am the Framework for\nthis game server. Almost\nall npc actions are controled\nby me.");

            // Create Compiler
            //Compiler = new GameCompiler(this);

            // Create Player Manager
            //PlayerManager = new GraalPlayerList();

            // Connect to GServer
            GSConn = new Connections.GraalServer();
            NCConn = new NCConnection();

            GSConn.RunServer();

            if (this.serverWindow.nickname != null && this.serverWindow.nickname != "")
            {
                this.nickname = this.serverWindow.nickname;
            }

            if (this.serverWindow.username != null && this.serverWindow.username != "")
            {
                this.username = this.serverWindow.username;
            }

            if (this.serverWindow.password != null && this.serverWindow.password != "")
            {
                this.password = this.serverWindow.password;
            }

            if (this.serverWindow.gserver != null && this.serverWindow.gserver != "")
            {
                server = this.serverWindow.gserver;
            }

            if (this.serverWindow.gport != null && this.serverWindow.gport != 0)
            {
                this.port = this.serverWindow.gport;
            }

            //GSConn.Disconnect();
            if (!GSConn.Connected)
            {
                this.form.WriteText("Not connected, connecting...");
                this.form.WriteText("Address:\t" + this.server);
                this.form.WriteText("Port:\t\t" + this.port.ToString());
                GSConn.Connect(this.server, this.port);
            }
            else
            {
                this.form.WriteText("Already connected!");
            }

            if (GSConn.Connected)
            {
                GSConn.SendLogin(this.username, this.password, this.nickname);
            }
        }
 /// <summary>
 /// Constructor
 /// </summary>
 public GraalPlayerList()
     : base()
 {
     this.Server = Framework.GetInstance();
     this.form = Abstraction.GetInstance();
 }
		public void InitNcConnection(CString ncip, CString ncport)
		{
			
			this.form = Abstraction.GetInstance();
			this.serverWindow = ServerWindow.GetInstance();
			
			// Connect to GServer
			
			//NCConn.RunServer();

			//GSConn.Disconnect();
			if (!NCConn.Connected)
			{
				this.form.WriteText("Connecting to NpcServer...");
				this.form.WriteText("Address:\t" + ncip.Text);
				this.form.WriteText("Port:\t\t" + ncport.ToString());
				NCConn.Connect(ncip.Text, ncport.ToInt());

			}
			else
				this.form.WriteText("Already connected!");

			if (NCConn.Connected)
			{
				this.form.WriteText("Connected!");
				NCConn.SendLogin(this.username, this.password);
			}
		}