Exemplo n.º 1
0
        private void SendLoginGame(string sUser, string sPaswd)
        {
            PacketOut pack = new PacketOut();

            pack.WriteCmd(PacketTypes.LOGIN, PacketTypes.LoginPacketTypes.cLogin);
            pack.WriteString(sUser);
            MD5 md5 = MD5.Create();

            byte[] data_paswd = Coding.GetDefauleCoding().GetBytes(sPaswd);
            data_paswd = md5.ComputeHash(data_paswd);
            StringBuilder sBuilder = new StringBuilder();

            for (int i = 0; i < data_paswd.Length; i++)
            {
                sBuilder.Append(data_paswd[i].ToString("x2"));
            }
            sPaswd = sBuilder.ToString();
            pack.WriteString(sPaswd);

            uint         gameServerSpanID = 1;
            uint         gameServerID     = 1;
            const string sign             = "ab6e03537c22c1b7f6763178a5882df7";
            const string time             = "1445486107";
            const string identity         = "000000198010100000";

            pack.WriteUInt32(gameServerSpanID);
            pack.WriteUInt32(gameServerID);
            pack.WriteString(sign);
            pack.WriteString(time);
            pack.WriteString(identity);
            this.Send(pack.GetBuffer());
            Account = sUser;
        }
Exemplo n.º 2
0
        //构造封包
        public byte[] StructurePack(byte[] pDataBytes)
        {
            uint dataCK = m_Encrypt.GetCRC16(pDataBytes);
            //包头
            PacketOut PackHead = new PacketOut();

            PackHead.WriteUInt16((UInt16)GamePackEx.DEFAULT_TAG);
            PackHead.WriteUInt16((UInt16)pDataBytes.Length);
            PackHead.WriteUInt16((UInt16)dataCK);
            PackHead.WriteUInt16(this.HEADER_CHECK_KEY);
            this.HEADER_CHECK_KEY++;
            if (this.HEADER_CHECK_KEY > 0xFFFF)
            {
                this.HEADER_CHECK_KEY = 0;
            }
            PackHead.WriteInt32(0);
            PackHead.WriteInt32(0);

            //计算包头CRC
            byte[] HeaderBytes = PackHead.GetBuffer();
            uint   headerCRC   = m_Encrypt.GetCRC16(HeaderBytes);

            byte[] crc_data = BitConverter.GetBytes(headerCRC);
            Buffer.BlockCopy(crc_data, 0, HeaderBytes, 6, sizeof(int));
            m_Encrypt.Encode(HeaderBytes, 4, 4);

            PacketOut pack = new PacketOut();

            pack.WriteBuff(HeaderBytes);
            pack.WriteBuff(pDataBytes);
            return(pack.GetBuffer());
        }
Exemplo n.º 3
0
        //连接成功后的第一次发送数据
        public void SendFirstSelfSalt()
        {
            uint      seed = m_Encrypt.GetSelfSalt();
            PacketOut pack = new PacketOut();

            pack.WriteUInt32(seed);
            this.m_Client.Send(pack.GetBuffer());
        }
Exemplo n.º 4
0
        private void SendEnterGameScene(uint nAccountId, uint nRoleId)
        {
            PacketOut pack = new PacketOut();

            pack.WriteCmd(PacketTypes.LOGIC, PacketTypes.LogicPacketTypes.cLoginGame);
            pack.WriteUInt32(nAccountId);
            pack.WriteUInt32(nRoleId);
            pack.WriteUInt32(0); //出生点id
            m_pSession.Send(pack.GetBuffer());
        }
Exemplo n.º 5
0
        public void OnReceive(byte[] data)
        {
            //校验状态
            if (this.SocketState < SocketState.COMMUNICATION)
            {
                this.SocketState = SocketState.COMMUNICATION;
                PackIn pack = new PackIn(data);
                uint   salt = pack.ReadUInt32();
                m_Encrypt.SetTargetSalt(salt);


                PacketOut pack_out = new PacketOut();
                pack_out.WriteUInt16((UInt16)m_Encrypt.getCheckKey());
                this.m_Client.Send(pack_out.GetBuffer());

                this.SendLoginGame("xb", "a");
                return;
            }

            this.GamePack.ProcessNetData(data);
        }
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteUInt32(gameid);
     outpack.WriteUInt32(sortid);
     outpack.WriteBuff(item.GetBuffer());
     //outpack.WriteInt32(playerid);
     //outpack.WriteUInt32(itemid);
     //outpack.WriteUInt16(postion);
     //outpack.WriteByte(stronglv);
     //outpack.WriteByte(gemcount);
     //outpack.WriteUInt32(gem1);
     //outpack.WriteUInt32(gem2);
     //outpack.WriteString(forgename);
     //outpack.WriteUInt16(amount);
     //outpack.WriteInt32(war_ghost_exp);
     //outpack.WriteByte(di_attack);
     //outpack.WriteByte(shui_attack);
     //outpack.WriteByte(huo_attack);
     //outpack.WriteByte(feng_attack);
     //outpack.WriteInt32(property);
     //outpack.WriteByte(gem3);
     //outpack.WriteInt32(god_strong);
     //outpack.WriteInt32(god_exp);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteInt32(id);
     outpack.WriteByte(friendtype);
     outpack.WriteUInt32(friendid);
     outpack.WriteString(friendname);
     return outpack.GetBuffer();
 }
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mparam);
     outpack.WriteString(account);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteUInt32(gameid);
     outpack.WriteInt32(key);
     outpack.WriteInt32(key2);
     outpack.WriteBuff(account);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Exemplo n.º 10
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteInt32(player_id);
     outpack.WriteBuff(mInfo.GetBuffer());
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Exemplo n.º 11
0
 public byte[] GetBuff()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteByte(mType);
     outpack.WriteString(text);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Exemplo n.º 12
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteUInt32(id);
     outpack.WriteUInt32(itemid);
     outpack.WriteString(name);
     outpack.WriteFloat(phyatk_grow_rate);
     outpack.WriteFloat(phyatk_grow_rate_max);
     outpack.WriteFloat(magicatk_grow_rate);
     outpack.WriteFloat(magicatk_grow_rate_max);
     outpack.WriteFloat(life_grow_rate);
     outpack.WriteFloat(defense_grow_rate);
     outpack.WriteFloat(magicdef_grow_rate);
     outpack.WriteInt32(init_life);
     outpack.WriteInt32(init_atk_min);
     outpack.WriteInt32(init_atk_max);
     outpack.WriteInt32(init_magicatk_min);
     outpack.WriteInt32(init_magicatk_max);
     outpack.WriteInt32(init_defense);
     outpack.WriteInt32(init_magicdef);
     outpack.WriteInt32(luck);
     outpack.WriteInt32(intimacy);
     outpack.WriteInt16(level);
     outpack.WriteInt32(card);
     outpack.WriteInt32(exp);
     outpack.WriteInt32(quality);
     outpack.WriteInt32(recall_count);
     outpack.WriteInt32(wuxing);
     outpack.WriteInt32(mListMagicInfo.Count);
     for (int i = 0; i < mListMagicInfo.Count; i++)
     {
         outpack.WriteInt32(mListMagicInfo[i].id);
         //这里的owernid 宿主在上面一个包含类里面,所以不用写
         outpack.WriteUInt32(mListMagicInfo[i].magicid);
         outpack.WriteUInt32(mListMagicInfo[i].exp);
     }
         return outpack.GetBuffer();
 }
Exemplo n.º 13
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteString(members_name);
     outpack.WriteLong(money);
     outpack.WriteInt16(rank);
     outpack.WriteBool(boChange);
     return outpack.GetBuffer();
 }
Exemplo n.º 14
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteUInt32(id);
     outpack.WriteString(name);
     outpack.WriteByte(title);
     outpack.WriteInt32(leader_id);
     outpack.WriteString(leader_name);
     outpack.WriteLong(money);
     outpack.WriteString(notice);
     outpack.WriteInt32(list_member.Count);
     for (int i = 0; i < list_member.Count; i++)
     {
         outpack.WriteBuff(list_member[i].GetBuffer());
     }
      return outpack.GetBuffer();
 }
Exemplo n.º 15
0
        public byte[] GetBuffer()
        {
            PacketOut outpack = new PacketOut();

            outpack.WriteBuff(InternalPacket.HEAD);
            outpack.WriteUInt16(mParam);

            outpack.WriteInt32(playerid);
            outpack.WriteInt32(key);
            outpack.WriteInt32(key2);
            outpack.WriteInt32(mListItem.Count);
            for (int i = 0; i < mListItem.Count; i++)
            {
                RoleData_Item item = mListItem[i];
                outpack.WriteBuff(item.GetBuffer());
                //outpack.WriteUInt32(item.id);
                //outpack.WriteUInt32(item.itemid);
                //outpack.WriteUInt16(item.postion);
                //outpack.WriteByte(item.stronglv);
                //outpack.WriteByte(item.gemcount);
                //outpack.WriteUInt32(item.gem1);
                //outpack.WriteUInt32(item.gem2);
                //outpack.WriteString(item.forgename);
                //outpack.WriteUInt16(item.amount);
                //outpack.WriteInt32(item.war_ghost_exp);
                //outpack.WriteByte(item.di_attack);
                //outpack.WriteByte(item.shui_attack);
                //outpack.WriteByte(item.huo_attack);
                //outpack.WriteByte(item.feng_attack);
                //outpack.WriteInt32(item.property);
                //outpack.WriteByte(item.gem3);
                //outpack.WriteInt32(item.god_strong);
                //outpack.WriteInt32(item.god_exp);

            }
            outpack.WriteBuff(InternalPacket.TAIL);
            return outpack.GetBuffer();
        }
Exemplo n.º 16
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteUInt32(id);
     outpack.WriteString(name);
     outpack.WriteULong(guanjue);
     return outpack.GetBuffer();
 }
Exemplo n.º 17
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteUInt32(gameid);
     outpack.WriteInt32(accountid);
     outpack.WriteString(name);
     outpack.WriteUInt32(lookface);
     outpack.WriteByte(profession);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Exemplo n.º 18
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteInt32(accountid);
     outpack.WriteBool(IsExit);
     outpack.WriteString(name);
     outpack.WriteUInt32(lookface);
     outpack.WriteUInt32(hair);
     outpack.WriteByte(level);
     outpack.WriteInt32(exp);
     outpack.WriteUInt32(life);
     outpack.WriteUInt32(mana);
     outpack.WriteByte(profession);
     outpack.WriteInt16(pk);
     outpack.WriteLong(gold);
     outpack.WriteLong(gamegold);
     outpack.WriteLong(stronggold);
     outpack.WriteUInt32(mapid);
     outpack.WriteInt16(x);
     outpack.WriteInt16(y);
     outpack.WriteString(hotkey);
     outpack.WriteULong(guanjue);
     outpack.WriteByte(godlevel);
     outpack.WriteByte(maxeudemon);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Exemplo n.º 19
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteInt32(ownerid);
     outpack.WriteInt32(key);
     outpack.WriteInt32(key2);
     outpack.WriteInt32(mListMagic.Count);
     for (int i = 0; i < mListMagic.Count; i++)
     {
         MagicInfo item = mListMagic[i];
         outpack.WriteInt32(item.id);
         outpack.WriteUInt32(item.magicid);
         outpack.WriteByte(item.level);
         outpack.WriteUInt32(item.exp);
     }
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Exemplo n.º 20
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteByte(ret);
     outpack.WriteInt32(play_id);
     outpack.WriteInt32(legion_id);
     outpack.WriteLong(money);
     outpack.WriteUInt32(boss_id);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }
Exemplo n.º 21
0
        public byte[] GetBuffer()
        {
            PacketOut outpack = new PacketOut();

            outpack.WriteBuff(InternalPacket.HEAD);
            outpack.WriteUInt16(mParam);
            outpack.WriteInt32(list_item.Count);
            for (int i = 0; i < list_item.Count; i++)
            {
                outpack.WriteBuff(list_item[i].GetBuffer());
            }
            outpack.WriteBuff(InternalPacket.TAIL);
            return outpack.GetBuffer();
        }
Exemplo n.º 22
0
 public byte[] GetBuffer()
 {
     PacketOut outpack = new PacketOut();
     outpack.WriteBuff(InternalPacket.HEAD);
     outpack.WriteUInt16(mParam);
     outpack.WriteUInt32(gameid);
     outpack.WriteString(name);
     outpack.WriteBuff(InternalPacket.TAIL);
     return outpack.GetBuffer();
 }