コード例 #1
0
		/// <summary>
		/// Add Player to Playerlist (or return player)
		/// </summary>
		internal TServer AddTServer(Int16 Id)
		{
			TServer pl = FindTServer(Id);
			if (pl == null)
			{
				TServer TServer = new TServer();
				this.serverList[Id] = TServer;
				//PlayerList2.Add(Player);
				return TServer;
			}

			return pl;
		}
コード例 #2
0
        /// <summary>
        /// Add Player to Playerlist (or return player)
        /// </summary>
        internal TServer AddTServer(Int16 Id)
        {
            TServer pl = FindTServer(Id);

            if (pl == null)
            {
                TServer TServer = new TServer();
                this.serverList[Id] = TServer;
                //PlayerList2.Add(Player);
                return(TServer);
            }

            return(pl);
        }
コード例 #3
0
        /// <summary>
        /// Handle Received Data
        /// </summary>
        ///
        protected override void HandleData(CString Packet)
        {
            if (this.serverWindow == null)
            {
                this.serverWindow = ServerWindow.GetInstance();
            }

            int  prevPacket = 0;
            uint readc      = 0;

            //System.Console.WriteLine("Test: " + Packet.Text);

            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();

                // Call Packet Callback
                //RemoteControl.CallCallBack(PacketId, (CString)CurPacket.DeepClone());

                Console.WriteLine("ServerLister Packet Received: " + (PacketIn)PacketId);

                // Run Internal Packet Function
                switch ((PacketIn)PacketId)
                {
                case PacketIn.INCORRPASS:
                {
                    CString Message = CurPacket.ReadString();

                    this.serverWindow.ErrorMsg = Message.Text.ToString();
                    this.loginWindow.Show();
                    ErrorWindow.GetInstance().SetTextAndShow(this.serverWindow.ErrorMsg);
                    this.serverWindow.Destroy();

                    break;
                }

                case PacketIn.LEVELBOARD:
                    int serverCount = CurPacket.ReadGUByte1();
                    this.serverWindow.Write_Text("Number of servers: " + serverCount.ToString());
                    this.serverList.Clear();
                    this.listStore.Clear();
                    for (int i = 0; i < serverCount; i++)
                    {
                        // empty byte
                        CurPacket.ReadGUByte1();

                        // add server
                        TServer server = this.serverList.AddTServer((short)i);

                        // parse server
                        server.setName(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setLanguage(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setDescription(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setUrl(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setVersion(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setPCount(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        server.setIp(new CString(CurPacket.ReadChars(CurPacket.ReadGUByte1())));
                        int port;
                        int.TryParse(CurPacket.ReadChars(CurPacket.ReadGUByte1()), out port);
                        server.setPort(port);

                        Gdk.Pixbuf icon;

                        if (server.getType() == "1")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_nuclear.png");
                        }
                        else if (server.getType() == "2")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_gold.png");
                        }
                        else if (server.getType() == "3")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_silver.png");
                        }
                        else if (server.getType() == "4")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_bronze.png");
                        }
                        else if (server.getType() == "5")
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_uc.png");
                        }
                        else
                        {
                            icon = global::Gdk.Pixbuf.LoadFromResource("OpenGraal.GraalIM.Resources.rcicon_uc.png");
                        }

                        ServerWindow sw = ServerWindow.GetInstance();
                        this.listStore.AppendValues(icon, server.name, server.getPCount());
                    }
                    break;

                default:
                    this.serverWindow.Write_Text("[" + Enum.GetName(typeof(PacketIn), PacketId).ToString() + "]: " + CurPacket.ReadString().Text + "\r\n");

                    break;
                }

                prevPacket = PacketId;
            }
            //if (this.serverWindow.ErrorMsg != "error")
            //	this.serverWindow.Hide();
        }