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();
 }
Example #2
0
        public static void SendConnectMapServer(GameSession session, int key, int key2)
        {
            byte[] defdata  = { 232, 16, 67, 3 };
            byte[] defdata2 = { 121, 39,  0,  0, 49, 50, 48, 46, 49, 51, 50, 46, 54,
                                57,  46, 49, 52, 55,  0,  0,  0,  0,  0,  0,  0,  0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            byte[] ipdata = Coding.GetDefauleCoding().GetBytes(m_GameServerIP);

            PacketOut packout = new PacketOut(session.GetGamePackKeyEx());

            packout.WriteUInt16(84);
            packout.WriteUInt16(PacketProtoco.S_GAMESERVERINFO);
            packout.WriteInt32(key);
            packout.WriteInt32(key2);
            packout.WriteInt32(m_GameServerPort);
            packout.WriteBuff(defdata);
            packout.WriteBuff(ipdata);
            for (int i = 0; i < 28 - ipdata.Length; i++)
            {
                packout.WriteByte(0);
            }
            packout.WriteBuff(defdata2);

            defdata = packout.Flush();
            server.SendData(session.m_Socket, defdata);
        }
Example #3
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());
        }
Example #4
0
        public void SetTrading(bool v)
        {
            mIsTrad = v;
            PacketOut outpack = null;

            if (mIsTrad)
            {
                PlayerObject target = UserEngine.Instance().FindPlayerObjectToTypeID(GetTradTarget());
                if (target == null)
                {
                    SetTrading(false);
                    return;
                }
                outpack = new PacketOut(target.GetGamePackKeyEx());
                outpack.WriteUInt16(16);
                outpack.WriteUInt16(1056);
                outpack.WriteUInt32(play.GetTypeId());

                outpack.WriteUInt32(3);
                outpack.WriteUInt32(1);
                target.SendData(outpack.Flush());
            }
            else
            {
                byte[] data = { 16, 0, 32, 4, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0 };
                outpack = new PacketOut(play.GetGamePackKeyEx());
                outpack.WriteBuff(data);
                play.SendData(outpack.Flush());
                play.LeftNotice("交易失败!");

                //返还魔石、金币 道具与装备
                play.ChangeAttribute(GameStruct.UserAttribute.GOLD, mnGold);
                if (mnGameGold > 0)
                {
                    play.ChangeAttribute(GameStruct.UserAttribute.GAMEGOLD, mnGameGold);
                }
                if (mnGold > 0)
                {
                    play.ChangeAttribute(GameStruct.UserAttribute.GOLD, mnGameGold);
                }
                //装备
                for (int i = 0; i < mListItem.Count; i++)
                {
                    play.GetItemSystem().AddTradItem(mListItem[i]);
                }
                //返还幻兽
                for (int i = 0; i < mListEudemon.Count; i++)
                {
                    play.GetEudemonSystem().AddEudemon(mListEudemon[i]);
                }
                mListItem.Clear();
                mListEudemon.Clear();
            }
        }
Example #5
0
        //播放动作-
        //action_id :动作id
        //play : 参数如果不为空,则只对该角色播放动作,否则广播
        public void PlayFaceAcion(uint action_id, PlayerObject play = null)
        {
            PacketOut outpack;

            if (play == null)
            {
                outpack = new PacketOut();
            }
            else
            {
                outpack = new PacketOut(play.GetGamePackKeyEx());
            }
            outpack.WriteUInt16(28);
            outpack.WriteUInt16(1010);
            outpack.WriteUInt32(0);
            outpack.WriteUInt32(this.GetTypeId());
            outpack.WriteUInt32(23855267);
            outpack.WriteUInt32(mInfo.dir);
            outpack.WriteUInt32(action_id);
            outpack.WriteUInt32(9530);
            byte[] data = outpack.Flush();
            if (play != null)
            {
                play.SendData(data);
                return;
            }
            //this.RefreshVisibleObject();
            foreach (RefreshObject o in mVisibleList.Values)
            {
                BaseObject obj = o.obj;
                if (obj.type == OBJECTTYPE.PLAYER)
                {
                    PlayerObject _play = obj as PlayerObject;
                    outpack = new PacketOut(_play.GetGamePackKeyEx());
                    outpack.WriteBuff(data);
                    _play.SendData(outpack.Flush());
                }
            }
        }
 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();
 }
 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();
 }
 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();
 }
Example #10
0
        //查看摊位
        //ptich_obj_id 摊位对象id
        //page 页码
        public void LookPtich(PlayerObject play, uint ptich_obj_id)
        {
            int ptich_id = -1;

            for (int i = 0; i < mListPtichInfo.Count; i++)
            {
                if (mListPtichInfo[i].PtichObj == null)
                {
                    continue;
                }
                if (mListPtichInfo[i].PtichObj.GetTypeId() == ptich_obj_id)
                {
                    ptich_id = i;
                    break;
                }
            }
            if (ptich_id == -1)
            {
                return;
            }
            // 摊位信息
            byte[]    senddata = { 42, 0, 105, 4, 244, 1, 0, 0, 64, 66, 15, 0, 36, 52, 156, 8, 3, 0, 0, 0, 30, 214, 44, 135, 2, 0, 0, 0, 164, 3, 178, 5, 1, 0 };
            PacketOut outpack  = new PacketOut();

            outpack.WriteBuff(senddata);
            outpack.WriteInt16((short)(ptich_id + 1));
            byte[] data2 = { 1, 4, 202, 165, 213, 189 };
            outpack.WriteBuff(data2);
            play.SendData(outpack.Flush(), true);
            //出售的道具信息
            for (int i = 0; i < mListPtichInfo[ptich_id].mSellItemList.Count; i++)
            {
                RoleItemInfo     item_info = null;
                RoleData_Eudemon eudemon   = null;
                if (mListPtichInfo[ptich_id].mSellItemList[i].item_id >= IDManager.eudemon_start_id)
                {
                    eudemon = mListPtichInfo[ptich_id].play.GetEudemonSystem().FindEudemon(
                        mListPtichInfo[ptich_id].mSellItemList[i].item_id);
                    if (eudemon == null)
                    {
                        continue;
                    }
                    item_info = mListPtichInfo[ptich_id].play.GetItemSystem().FindItem(eudemon.itemid);
                }
                else
                {
                    item_info = mListPtichInfo[ptich_id].play.GetItemSystem().FindItem(
                        mListPtichInfo[ptich_id].mSellItemList[i].item_id);
                }

                if (item_info != null)
                {
                    NetMsg.MsgPtichItemInfo msg = new NetMsg.MsgPtichItemInfo(item_info,
                                                                              ptich_obj_id, mListPtichInfo[ptich_id].mSellItemList[i].price, mListPtichInfo[ptich_id].mSellItemList[i].sell_type);
                    play.SendData(msg.GetBuffer(), true);
                    //发送幻兽信息
                    if (item_info.typeid >= IDManager.eudemon_start_id)
                    {
                        mListPtichInfo[ptich_id].play.GetEudemonSystem().SendLookPtichEudemonInfo(play, eudemon);
                        // play.GetEudemonSystem().SendEudemonInfo(eudemon, false, true);
                    }
                }
            }
            //道具id
            //摊位对象id
            //魔石价格
            //道具基础id
            //最大损耗  172, 38,
            //当前损耗  172, 38,
            //摊位栏 3
            //是否鉴定 0.已鉴定 1.未鉴定
            //未知 50
            //第一个宝石 30
            //第二个宝石 30
            //未知 0,0
            //强化等级 12
            //32.未知
            //33.未知
            //34.未知
            //35.未知
            //36/37.38.39 未知
            //40.41. 战魂等级
            //42-51 未知
            //52 地攻击
            //53 水攻击
            //54 火攻击
            //55 风攻击
            //56 特效
            //64 第三个宝石
            // byte[] data = { 101, 0, 84, 4, 13, 11, 150, 7, 67,162,1,0, 172, 13, 0, 0, 132, 70, 2, 0, 172, 38, 172, 38, 3, 0, 50, 30, 30, 0, 0, 12, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 10, 209, 215, 253, 136, 133, 101, 159, 111, 235, 112, 0, 0, 0, 0, 0 };
            //    play.SendData(GameServer.PtichData, true);
            //107075

            //  收到网络协议:长度:98协议号:1108
            //byte[] data1 = { 98, 0, 84, 4, 110, 134, 61, 138, 67, 162, 1, 0, 14, 0, 0, 0, 118, 91, 16, 0, 0, 0, 0, 0, 3, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 9, 198, 230, 210, 236, 202, 222, 79, 208, 205, 0, 0, 0 };
            //play.SendData(data1,true);
//收到网络协议:长度:24协议号:2037
//byte[] data3 = {24,0,245,7,3,0,0,0,110,134,61,138,1,0,0,0,24,0,0,0,138,2,0,0};
//            play.SendData(data3,true);
////收到网络协议:长度:496协议号:2037
//            byte[] data4 = { 240, 1, 245, 7, 3, 0, 0, 0, 110, 134, 61, 138, 60, 0, 0, 0, 6, 0, 0, 0, 159, 8, 0, 0, 7, 0, 0, 0, 159, 8, 0, 0, 10, 0, 0, 0, 81, 0, 0, 0, 8, 0, 0, 0, 150, 0, 0, 0, 9, 0, 0, 0, 83, 94, 121, 19, 55, 0, 0, 0, 0, 0, 0, 0, 12, 0, 0, 0, 2, 0, 0, 0, 14, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 16, 0, 0, 0, 0, 0, 0, 0, 17, 0, 0, 0, 0, 0, 0, 0, 18, 0, 0, 0, 0, 0, 0, 0, 19, 0, 0, 0, 2, 0, 0, 0, 21, 0, 0, 0, 5, 0, 0, 0, 23, 0, 0, 0, 1, 0, 0, 0, 25, 0, 0, 0, 244, 5, 0, 0, 26, 0, 0, 0, 33, 5, 0, 0, 27, 0, 0, 0, 165, 3, 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4, true);
        }
        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();
        }
 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();
 }
 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();
 }
 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();
 }
 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();
 }
 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();
 }
        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();
        }
 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();
 }