示例#1
0
        public static void Run()
        {
            lock (_lock_session)
            {
                foreach (GameSession session in m_DicSession.Values)
                {
                    byte[] retData = session.m_GamePack.GetData();
                    if (retData != null)
                    {
                        PackIn packin = new PackIn(retData);
                        ushort tag    = packin.ReadUInt16();
                        switch (tag)
                        {
                        case PacketProtoco.C_LOGINGAME:
                        {
                            packin.ReadUInt32();

                            int _key = 0, _key2 = 0;
                            GenerateKey.GenerateKey_(ref _key, ref _key2);
                            //取封包帐号- 发给dbserver
                            byte[] bAccount = packin.ReadBuff(16);

                            String account = Coding.GetDefauleCoding().GetString(bAccount);
                            GameBase.Network.Internal.QueryRole query = new GameBase.Network.Internal.QueryRole(session.gameid, _key, _key2, bAccount);
                            mTcpClient.SendData(query.GetBuffer());

                            Log.Instance().WriteLog("帐号登录!" + account);
                            break;
                        }
                        }
                    }
                }
            }
        }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     gameid = inpack.ReadUInt32();
     sortid = inpack.ReadUInt32();
     item.Create(null, inpack);
     //playerid = inpack.ReadInt32();
     //itemid = inpack.ReadUInt32();
     //postion = inpack.ReadUInt16();
     //stronglv = inpack.ReadByte();
     //gemcount = inpack.ReadByte();
     //gem1 = inpack.ReadUInt32();
     //gem2 = inpack.ReadUInt32();
     //forgename = inpack.ReadString();
     //amount = inpack.ReadUInt16();
     //war_ghost_exp = inpack.ReadInt32();
     //di_attack = inpack.ReadByte();
     //shui_attack = inpack.ReadByte();
     //huo_attack = inpack.ReadByte();
     //feng_attack = inpack.ReadByte();
     //property = inpack.ReadInt32();
     //gem3 = inpack.ReadByte();
     //god_strong = inpack.ReadInt32();
     //god_exp = inpack.ReadInt32();
 }
示例#3
0
 public byte   bState;      //0 角色被删 1 被封号 2 正常
 public void PackToStruct(PackIn pack)
 {
     nId     = pack.ReadUInt32();
     szName  = pack.ReadString();
     bFaceId = pack.ReadByte();
     bSex    = pack.ReadByte();
     bLevel  = pack.ReadByte();
     bJob    = pack.ReadByte();
     pack.ReadByte(); //原本的阵营位
     bCircle     = pack.ReadByte();
     bApoteoSize = pack.ReadByte();
     szGuildName = pack.ReadString();
     bState      = pack.ReadByte();
 }
示例#4
0
        public static void ProcessDBNetMsg()
        {
            byte[] data = mDBPacket.GetData();
            if (data == null)
            {
                return;
            }
            PackIn inpack = new PackIn(data);
            ushort param  = inpack.ReadUInt16();

            switch (param)
            {
            case GameBase.Network.Internal.Define.QUERYROLE_RET:
            {
                uint gameid = inpack.ReadUInt32();
                int  key    = inpack.ReadInt32();
                int  key2   = inpack.ReadInt32();
                byte ret    = inpack.ReadByte();
                if (ret == 1)     //有这个帐号--
                {
                    GameSession session = FindGameSessionToGameID(gameid);
                    if (session != null)
                    {
                        //发送数据给客户端,连接mapserver
                        Log.Instance().WriteLog("通知客户端登录MapServer");
                        SendConnectMapServer(session, key, key2);
                    }
                }
                else if (ret == 2)     //重复登录,踢下线
                {
                    GameSession session = FindGameSessionToGameID(gameid);
                    if (session != null)
                    {
                        lock (_lock_session)
                        {
                            m_DicSession.Remove(session.m_Socket);
                        }

                        session.Dispose();
                    }
                }

                break;
            }
            }
        }
示例#5
0
        private void DoQueryRole(PackIn pack)
        {
            uint nAccountId = pack.ReadUInt32();
            byte nCount     = pack.ReadByte();

            if (nCount >= 0 && nCount < 100)
            {
                for (int i = 0; i < /*nCount*/ 1 /*取第一个角色*/; i++)
                {
                    TSimplePlayerInfo info = new TSimplePlayerInfo();
                    info.PackToStruct(pack);
                    info.nAccountId           = nAccountId;
                    m_pActor.SimplePlayerInfo = info;

                    Console.WriteLine("登录游戏成功:" + m_pSession.Account + "  选择进入游戏:" + info.szName);
                }
                this.SendEnterGameScene(nAccountId, m_pActor.SimplePlayerInfo.nId);
            }
        }
示例#6
0
        public void ProcessNetData(PackIn pack)
        {
            byte id = pack.ReadByte();

            switch (id)
            {
            case PacketTypes.LoginPacketTypes.sQueryRole:
            {
                DoQueryRole(pack);

                break;
            }

            default:
            {
                Console.WriteLine("登录系统未知协议号:" + id);
                break;
            }
            }
        }
示例#7
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);
        }
示例#8
0
        private void ProcessNetData()
        {
            byte[] data = m_GamePack.GetData();
            if (data != null)
            {
                PackIn packIn = new PackIn(data);
                byte   sysId  = packIn.ReadByte();
                switch (sysId)
                {
                case PacketTypes.LOGIN:
                {
                    m_Actor.GetLoginSystem().ProcessNetData(packIn);

                    break;
                }

                default:
                {
                    Console.WriteLine("未知的系统id:" + sysId + " 协议号:" + packIn.ReadByte());
                    break;
                }
                }
            }
        }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     accountid = inpack.ReadInt32();
 }
 public void Create(PackIn inpack)
 {
     id = inpack.ReadUInt32();
     name = inpack.ReadString();
     title = inpack.ReadByte();
     leader_id = inpack.ReadInt32();
     leader_name = inpack.ReadString();
     money = inpack.ReadLong();
     notice = inpack.ReadString();
     int count = inpack.ReadInt32();
     for (int i = 0; i < count; i++)
     {
         LegionMember member = new LegionMember();
         member.Create(inpack);
         list_member.Add(member);
     }
 }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     ret = inpack.ReadByte();
     play_id = inpack.ReadInt32();
     legion_id = inpack.ReadInt32();
     money = inpack.ReadInt32();
     boss_id = inpack.ReadUInt32();
 }
 public void Create(PackIn inpack)
 {
     id = inpack.ReadUInt32();
     name = inpack.ReadString();
     guanjue = inpack.ReadULong();
 }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadInt16();
     account = inpack.ReadString();
 }
 public void Create(byte[] msg, PackIn inpack)
 {
     id = inpack.ReadInt32();
     friendtype = inpack.ReadByte();
     friendid = inpack.ReadUInt32();
     friendname = inpack.ReadString();
 }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     info.Create(inpack);
 }
        public void Create(byte[] msg)
        {
            PackIn inpack = new PackIn(msg);

            inpack.ReadUInt16();
            player_id = inpack.ReadInt32();
            mInfo.Create(inpack);
        }
        public short y; //所在地图坐标y

        #endregion Fields

        #region Constructors

        public RoleInfo(byte[] msg = null)
        {
            mParam = Define.ROLEINFO;
            gameid = 0;
            isRole = false;
            mKey = 0;
            mKey1 = 0;
            accountid = 0;
            sAccount = "";
            name = "";
            lookface = 0;
            hair = 0;
            lv = 0;
            exp = 0;
            life = 0;
            mana = 0;
            profession = 0;
            pk = 0;
            gold = 0;
            gamegold = 0;
            mapid = 0;
            x = 0;
            y = 0;
            playerid = 0;
            hotkey = "";
            guanjue = 0;
            godlevel = 0;
            maxeudemon = 2;
            if (msg != null)
            {
                PackIn inpack = new PackIn(msg);
                mParam = inpack.ReadUInt16();
                gameid = inpack.ReadUInt32();

                mKey = inpack.ReadInt32();
                mKey1 = inpack.ReadInt32();
                accountid = inpack.ReadInt32();
                sAccount = inpack.ReadString();
                playerid = inpack.ReadInt32();
                isRole = inpack.ReadBool();
                if (isRole)
                {
                    name = inpack.ReadString();
                    lookface = inpack.ReadUInt32();
                    hair = inpack.ReadUInt32();
                    lv = inpack.ReadByte();
                    exp = inpack.ReadUInt32();
                    life = inpack.ReadUInt32();
                    mana = inpack.ReadUInt32();
                    profession = inpack.ReadByte();
                    pk = inpack.ReadInt16();
                    gold = inpack.ReadInt32();
                    gamegold = inpack.ReadInt32();
                    stronggold = inpack.ReadInt32();
                    mapid = inpack.ReadInt32();
                    x = inpack.ReadInt16();
                    y = inpack.ReadInt16();
                    hotkey = inpack.ReadString();
                    guanjue = inpack.ReadULong();
                    godlevel = inpack.ReadInt32();
                    maxeudemon = inpack.ReadByte();
                }

            }
        }
        public void Create(byte[] msg)
        {
            PackIn inpack = new PackIn(msg);

            inpack.ReadUInt16();
            accountid = inpack.ReadInt32();
            IsExit = inpack.ReadBool();
            name = inpack.ReadString();
            lookface = inpack.ReadUInt32();
            hair = inpack.ReadUInt32();
            level = inpack.ReadByte();
            exp = inpack.ReadInt32();
            life = inpack.ReadUInt32();
            mana = inpack.ReadUInt32();
            profession = inpack.ReadByte();
            pk = inpack.ReadInt16();
            gold = inpack.ReadLong();
            gamegold = inpack.ReadLong();
            stronggold = inpack.ReadLong();
            mapid = inpack.ReadUInt32();
            x = inpack.ReadInt16();
            y = inpack.ReadInt16();
            hotkey = inpack.ReadString();
            guanjue = inpack.ReadULong();
            godlevel = inpack.ReadByte();
            maxeudemon = inpack.ReadByte();
        }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     playerid = inpack.ReadInt32();
     key = inpack.ReadInt32();
     key2 = inpack.ReadInt32();
     int count = inpack.ReadInt32();
     for (int i = 0; i < count; i++)
     {
         RoleData_Eudemon eudemon = new RoleData_Eudemon();
         eudemon.Create(null, inpack);
         list_item.Add(eudemon);
     }
 }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     ownerid = inpack.ReadInt32();
     key = inpack.ReadInt32();
     key2 = inpack.ReadInt32();
     int count = inpack.ReadInt32();
     for (int i = 0; i < count; i++)
     {
         MagicInfo item = new MagicInfo();
         item.id = inpack.ReadInt32();
         item.magicid = inpack.ReadUInt32();
         item.level = inpack.ReadByte();
         item.exp = inpack.ReadUInt32();
         mListMagic.Add(item);
     }
 }
        public void Create(byte[] msg = null, PackIn _inpack = null)
        {
            PackIn inpack = null;
            if (_inpack != null)
            {
                inpack = _inpack;
            }
            else inpack = new PackIn(msg); ;

            id = inpack.ReadUInt32();
            playerid = inpack.ReadInt32();
            itemid = inpack.ReadUInt32();
            postion = inpack.ReadUInt16();
            stronglv = inpack.ReadByte();

            gem1 = inpack.ReadUInt32();
            gem2 = inpack.ReadUInt32();
            forgename = inpack.ReadString();
            amount = inpack.ReadUInt16();
            war_ghost_exp = inpack.ReadInt32();
            di_attack = inpack.ReadByte();
            shui_attack = inpack.ReadByte();
            huo_attack = inpack.ReadByte();
            feng_attack = inpack.ReadByte();
            property = inpack.ReadInt32();
            gem3 = inpack.ReadUInt32();
            god_strong = inpack.ReadInt32();
            god_exp = inpack.ReadInt32();
        }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadInt16();
     int count = inpack.ReadInt32();
     for (int i = 0; i < count; i++)
     {
         LegionInfo info = new LegionInfo();
         info.Create(inpack);
         list_item.Add(info);
     }
 }
 public void Create(byte[] data)
 {
     PackIn inpack = new PackIn(data);
     inpack.ReadUInt16();
     gameid = inpack.ReadUInt32();
     accountid = inpack.ReadInt32();
     name = inpack.ReadString();
     lookface = inpack.ReadUInt32();
     profession = inpack.ReadByte();
 }
 public void Create(PackIn inpack)
 {
     members_name = inpack.ReadString();
     money = inpack.ReadLong();
     rank = inpack.ReadInt16();
     boChange = inpack.ReadBool();
 }
 public void Create(byte[] data)
 {
     PackIn inpack = new PackIn(data);
     inpack.ReadUInt16();
     gameid = inpack.ReadUInt32();
     name = inpack.ReadString();
 }
        public void Creaet(byte[] msg)
        {
            PackIn inpack = new PackIn(msg);
            inpack.ReadInt16();
            id = inpack.ReadInt32();

            account = inpack.ReadString();
            order = inpack.ReadString();
            money = inpack.ReadInt32();
        }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     playerid = inpack.ReadInt32();
     key = inpack.ReadInt32();
     key2 = inpack.ReadInt32();
     int count = inpack.ReadInt32();
     for (int i = 0; i < count; i++)
     {
         RoleData_Friend item = new RoleData_Friend();
         item.Create(null, inpack);
         list_item.Add(item);
     }
 }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     mParam = inpack.ReadUInt16();
     gameid = inpack.ReadUInt32();
     key = inpack.ReadInt32();
     key2 = inpack.ReadInt32();
     account = inpack.ReadBuff(16);
 }
 public void Create(byte[] msg = null, PackIn _inpack = null)
 {
     PackIn inpack = null;
     if (msg != null)
     {
         inpack = new PackIn(msg);
     }
     else inpack = _inpack;
     id = inpack.ReadUInt32();
     itemid = inpack.ReadUInt32();
     name = inpack.ReadString();
     phyatk_grow_rate = inpack.ReadFloat();
     phyatk_grow_rate_max = inpack.ReadFloat();
     magicatk_grow_rate = inpack.ReadFloat();
     magicatk_grow_rate_max = inpack.ReadFloat();
     life_grow_rate = inpack.ReadFloat();
     defense_grow_rate = inpack.ReadFloat();
     magicdef_grow_rate = inpack.ReadFloat();
     init_life = inpack.ReadInt32();
     init_atk_min = inpack.ReadInt32();
     init_atk_max = inpack.ReadInt32();
     init_magicatk_min = inpack.ReadInt32();
     init_magicatk_max = inpack.ReadInt32();
     init_defense = inpack.ReadInt32();
     init_magicdef = inpack.ReadInt32();
     luck = inpack.ReadInt32();
     intimacy = inpack.ReadInt32();
     level = inpack.ReadInt16();
     card = inpack.ReadInt32();
     exp = inpack.ReadInt32();
     quality = inpack.ReadInt32();
     recall_count = inpack.ReadInt32();
     wuxing = inpack.ReadInt32();
     int nMagicCount = inpack.ReadInt32();
     for (int i = 0; i < nMagicCount; i++)
     {
         GameBase.Network.Internal.MagicInfo info = new GameBase.Network.Internal.MagicInfo();
         //这里的owernid 宿主在上面一个包含类里面,所以不用读
         info.id = inpack.ReadInt32();
         info.magicid = inpack.ReadUInt32();
         info.exp = inpack.ReadUInt32();
         mListMagicInfo.Add(info);
     }
 }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     gameid = inpack.ReadUInt32();
     key = inpack.ReadInt32();
     key2 = inpack.ReadInt32();
     ret = inpack.ReadByte();
 }
        public void Create(byte[] msg)
        {
            PackIn inpack = new PackIn(msg);
            inpack.ReadUInt16();

            playerid = inpack.ReadInt32();
            key = inpack.ReadInt32();
            key2 = inpack.ReadInt32();
            int count = inpack.ReadInt32();
            for (int i = 0; i < count; i++)
            {
                RoleData_Item item = new RoleData_Item();
                item.Create(null, inpack);
                //-----------------------------------------------
                //item.id = inpack.ReadUInt32();
                //item.itemid = inpack.ReadUInt32();
                //item.postion = inpack.ReadUInt16();
                //item.stronglv = inpack.ReadByte();
                //item.gemcount = inpack.ReadByte();
                //item.gem1 = inpack.ReadUInt32();
                //item.gem2 = inpack.ReadUInt32();
                //item.forgename = inpack.ReadString();
                //item.amount = inpack.ReadUInt16();

                //item.war_ghost_exp = inpack.ReadInt32();
                //item.di_attack = inpack.ReadByte();
                //item.shui_attack = inpack.ReadByte();
                //item.huo_attack = inpack.ReadByte();
                //item.feng_attack = inpack.ReadByte();
                //item.property = inpack.ReadInt32();
                //item.gem3 = inpack.ReadByte();
                //item.god_strong = inpack.ReadInt32();
                //item.god_exp = inpack.ReadInt32();
                //------------------------------------------------

                mListItem.Add(item);
            }
        }
示例#32
0
        public void Run()
        {
            byte[] data = mPacket.GetData();
            if (data == null)
            {
                return;
            }
            PackIn inpack = new PackIn(data);
            ushort param  = inpack.ReadUInt16();

            switch (param)
            {
            case GameBase.Network.Internal.Define.OPENLOGINSERVER:
            case GameBase.Network.Internal.Define.OPENMAPSERVER:
            {
                mType = inpack.ReadByte();
                mName = inpack.ReadString();
                Log.Instance().WriteLog("server connect...type:" + mType.ToString() + " name:" + mName);
                //如果是mapserver 组 就发额外的数据
                if (mType == GameBase.Network.Internal.Define.TYPE_MAPSERVER)
                {
                    //爵位
                    GuanJue.GetInstance().SendData(0);
                    //军团信息
                    Legion.GetInstance().SendData(0);
                    //充值信息
                    PayManager.Instance().SendData(0);
                }
                break;
            }

            case GameBase.Network.Internal.Define.QUERYROLE:
            {
                ProcessQueryRole(data);
                break;
            }

            case GameBase.Network.Internal.Define.ROLEINFO_RET:
            {
                ProcessRoleInfo_Ret(data);
                break;
            }

            case GameBase.Network.Internal.Define.QUERYROLENAME:
            {
                ProcessQueryRoleName(data);
                break;
            }

            case GameBase.Network.Internal.Define.CREATEROLE:
            {
                ProcessCreateRole(data);
                break;
            }

            case GameBase.Network.Internal.Define.SAVEROLEDATA_ATTR:
            {
                ProcessSaveRoleData_Attr(data);
                break;
            }

            case GameBase.Network.Internal.Define.ADDROLEDATA_ITEM:
            {
                ProcessAddRoleData_Item(data);
                break;
            }

            case GameBase.Network.Internal.Define.DELETEROLEDATA_ITEM:
            {
                ProcessDeleteRoleData_Item(data);
                break;
            }

            case GameBase.Network.Internal.Define.SAVEROLEDATA_ITEM:
            {
                ProcessSaveRoleData_Item(data);
                break;
            }

            case GameBase.Network.Internal.Define.SAVEROLEDATA_MAGIC:
            {
                ProcessSaveRoleData_Magic(data);
                break;
            }

            case GameBase.Network.Internal.Define.SAVEROLEDATA_EUDEMON:
            {
                ProcessSaveRoleData_Eudemon(data);
                break;
            }

            case GameBase.Network.Internal.Define.SAVEROLEDATA_FRIEND:
            {
                ProcessSaveRoleData_Friend(data);
                break;
            }

            case GameBase.Network.Internal.Define.UPDATEGUANJUEDATA:
            {
                ProcessUpdateGuanJueData(data);
                break;
            }

            case GameBase.Network.Internal.Define.CREATELEGION:
            {
                ProcessCreateLegion(data);
                break;
            }

            case GameBase.Network.Internal.Define.UPDATELEGION:
            {
                ProcessUpdateLegion(data);
                break;
            }

            case GameBase.Network.Internal.Define.UPDATEPAYRECINFO:
            {
                ProcessUpdatePayrecInfo(data);
                break;
            }
            }
        }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     playerid = inpack.ReadInt32();
     id = inpack.ReadUInt32();
     postion = inpack.ReadUInt16();
 }
 public void Create(byte[] data)
 {
     PackIn inpack = new PackIn(data);
     inpack.ReadUInt16();
     playerid = inpack.ReadInt32();
     gameid = inpack.ReadUInt32();
     tag = inpack.ReadBool();
 }
 public void Create(byte[] msg)
 {
     PackIn inpack = new PackIn(msg);
     inpack.ReadUInt16();
     gameid = inpack.ReadUInt32();
     sordid = inpack.ReadUInt32();
     id = inpack.ReadUInt32();
 }
示例#36
0
        public void ProcessDBNetMsg()
        {
            if (!mbConnect && System.Environment.TickCount - mnReconnectTick > 5000)//五秒重连
            {
                mTcpDBClient.ReConnect();
                mnReconnectTick = System.Environment.TickCount;
            }
            byte[] buff = null;
            lock (_lock)
            {
                buff = mDBPacket.GetData();
            }

            if (buff == null)
            {
                return;
            }
            PackIn inpack = new PackIn(buff);
            ushort param  = inpack.ReadUInt16();

            switch (param)
            {
            case GameBase.Network.Internal.Define.ROLEINFO:
            {
                GameBase.Network.Internal.RoleInfo roleinfo = new GameBase.Network.Internal.RoleInfo(buff);
                //判断是否有缓存数据-
                PlayerObject cacheplay = UserEngine.Instance().GetCachePlay(roleinfo.sAccount);
                if (cacheplay != null)
                {
                    Log.Instance().WriteLog("检测到角色缓存数据,保存中!" + cacheplay.GetName());
                    UserEngine.Instance().RemoveCachePlay(cacheplay);
                    cacheplay.ExitGame();
                    return;
                }
                UserEngine.Instance().AddTempPlayObject(roleinfo);

                //回发给dbserver 表示收到了角色信息- 让他通知loginserver 发数据给玩家连接mapserver
                GameBase.Network.Internal.RoleInfo_Ret ret = new GameBase.Network.Internal.RoleInfo_Ret();
                ret.gameid    = roleinfo.gameid;
                ret.key       = roleinfo.mKey;
                ret.key2      = roleinfo.mKey1;
                ret.accountid = roleinfo.accountid;
                mTcpDBClient.SendData(ret.GetBuffer());
                Log.Instance().WriteLog("收到临时角色信息:" + roleinfo.sAccount + " id:" + roleinfo.accountid.ToString());
                break;
            }

            case GameBase.Network.Internal.Define.QUERYROLENAME_RET:
            {
                QueryRoleName_Ret ret = new QueryRoleName_Ret();
                ret.Create(buff);
                TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(ret.gameid);
                if (temp == null)
                {
                    Log.Instance().WriteLog("找到玩家对象..在--ProcessDBNetMsg code:2");
                    break;
                }

                NetMsg.MsgNotice notice = new NetMsg.MsgNotice();
                notice.Create(null, temp.play.GetGamePackKeyEx());
                temp.play.SendData(notice.GetQueryNameBuff(!ret.tag));

                break;
            }

            case GameBase.Network.Internal.Define.CREATEROLE_RET:
            {
                CreateRole_Ret ret = new CreateRole_Ret();
                ret.Create(buff);
                TempPlayObject temp = UserEngine.Instance().GetTempPlayObj(ret.gameid);
                if (temp == null)
                {
                    Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:3");
                    break;
                }


                UserEngine.Instance().RemoveTempPlayObject(ret.gameid);         //从临时列表出移除--
                //进入游戏
                temp.play.GetBaseAttr().account_id = temp.accountid;
                temp.play.GetBaseAttr().player_id  = ret.playerid;
                temp.play.EnterGame(null, true);
                break;
            }

            case GameBase.Network.Internal.Define.ADDROLEDATA_ITEM_RET:
            {
                GameBase.Network.Internal.AddRoleData_Item_Ret ret = new GameBase.Network.Internal.AddRoleData_Item_Ret();
                ret.Create(buff);
                PlayerObject play = UserEngine.Instance().FindPlayerObjectToID(ret.gameid);
                if (play == null)
                {
                    Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:4");
                    break;
                }
                play.GetItemSystem().AwardItem_Ret(ret.sordid, ret.id);
                break;
            }

            case GameBase.Network.Internal.Define.LOADROLEDATA_ITEM:
            {
                GameBase.Network.Internal.ROLEDATA_ITEM item = new GameBase.Network.Internal.ROLEDATA_ITEM();
                item.Create(buff);
                TempPlayObject play = UserEngine.Instance().GetTempPlayObj(item.key, item.key2);
                if (play == null)
                {
                    Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:5");
                    break;
                }
                for (int i = 0; i < item.mListItem.Count; i++)
                {
                    play.play.GetItemSystem().AddItemInfo(item.mListItem[i]);
                }
                break;
            }

            case GameBase.Network.Internal.Define.LOADROLEDATA_MAGIC:
            {
                GameBase.Network.Internal.RoleData_Magic magic = new GameBase.Network.Internal.RoleData_Magic();
                magic.Create(buff);
                TempPlayObject play = UserEngine.Instance().GetTempPlayObj(magic.key, magic.key2);
                if (play == null)
                {
                    Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:6");
                    break;
                }
                for (int i = 0; i < magic.mListMagic.Count; i++)
                {
                    GameBase.Network.Internal.MagicInfo info = magic.mListMagic[i];
                    play.play.GetMagicSystem().AddMagicInfo(info);
                }

                break;
            }

            case GameBase.Network.Internal.Define.KICKGAMEPLAY:
            {
                GameBase.Network.Internal.KickGamePlay kickplay = new GameBase.Network.Internal.KickGamePlay();
                kickplay.Create(buff);
                PlayerObject play = UserEngine.Instance().FindPlayerObjectToAccountId(kickplay.accountid);
                if (play != null)
                {
                    SessionManager.Instance().RemoveSession(play.GetGameSession().m_Socket);
                    play.Kick();
                }
                break;
            }

            case GameBase.Network.Internal.Define.LOADROLEDATA_EUDEMON:
            {
                GameBase.Network.Internal.ROLEDATE_EUDEMON eudemon = new GameBase.Network.Internal.ROLEDATE_EUDEMON();
                eudemon.Create(buff);

                TempPlayObject play = UserEngine.Instance().GetTempPlayObj(eudemon.key, eudemon.key2);
                if (play == null)
                {
                    //只是为了下断点后延迟问题解决方案
                    PlayerObject _play = UserEngine.Instance().FindPlayerObjectToPlayerId(eudemon.playerid);
                    if (_play == null)
                    {
                        Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:6");
                    }
                    else
                    {
                        _play.GetEudemonSystem().DB_Load(eudemon);
                        _play.GetEudemonSystem().SendAllEudemonInfo();
                    }

                    break;
                }
                else
                {
                    play.play.GetEudemonSystem().DB_Load(eudemon);
                }


                break;
            }

            case GameBase.Network.Internal.Define.LOADROLEDATA_FRIEND:
            {
                GameBase.Network.Internal.ROLEDATA_FRIEND friend = new GameBase.Network.Internal.ROLEDATA_FRIEND();
                friend.Create(buff);
                TempPlayObject play = UserEngine.Instance().GetTempPlayObj(friend.key, friend.key2);
                if (play == null)
                {
                    //只是为了下断点后延迟问题解决方案
                    PlayerObject _play = UserEngine.Instance().FindPlayerObjectToPlayerId(friend.playerid);
                    if (_play == null)
                    {
                        Log.Instance().WriteLog("未找到玩家对象..在--ProcessDBNetMsg code:7");
                    }
                    else
                    {
                        _play.GetFriendSystem().DB_Load(friend);
                        _play.GetFriendSystem().SendAllFriendInfo();
                    }

                    break;
                }
                else
                {
                    play.play.GetFriendSystem().DB_Load(friend);
                }

                break;
            }

            case GameBase.Network.Internal.Define.GUANJUEDATA:     //爵位数据
            {
                GameBase.Network.Internal.GUANJUEINFO juewei = new GameBase.Network.Internal.GUANJUEINFO();
                juewei.Create(buff);
                GuanJueManager.Instance().DB_Load(juewei);
                break;
            }

            case GameBase.Network.Internal.Define.LOADLEGION:     //军团数据
            {
                GameBase.Network.Internal.LEGIONINFO info = new GameBase.Network.Internal.LEGIONINFO();
                info.Create(buff);
                LegionManager.Instance().DB_Load(info);
                break;
            }

            case GameBase.Network.Internal.Define.CREATELEGION_RET:    //创建军团返回数据
            {
                GameBase.Network.Internal.CreateLegion_Ret info = new GameBase.Network.Internal.CreateLegion_Ret();
                info.Create(buff);
                LegionManager.Instance().CreateLegion_Ret(info);
                break;
            }

            case GameBase.Network.Internal.Define.LOADPAYRECINFO:     //充值数据
            {
                GameBase.Network.Internal.PackPayRecInfo info = new GameBase.Network.Internal.PackPayRecInfo();
                info.Creaet(buff);
                PayManager.Instance().DB_Load(info);
                break;
            }
            }
        }
示例#37
0
        public void ProcessNetData(byte[] data)
        {
            byte[] dedata = new byte[data.Length];
            Buffer.BlockCopy(data, 0, dedata, 0, data.Length);
            m_stream.Write(dedata, 0, dedata.Length);
            PackIn packin  = new PackIn(m_stream.GetBuffer());
            int    nCurPos = 0; //记录当前流位置

            while (true)
            {
                ushort tag = packin.ReadUInt16();
                nCurPos += sizeof(ushort);
                if (tag != DEFAULT_TAG)
                {
                    continue;
                }
                int nLen = packin.ReadUInt16();
                nCurPos += sizeof(ushort);
                //    //预留4字节
                packin.ReadUInt32();
                nCurPos += sizeof(uint);
                //    //读取消息消耗时间
                packin.ReadInt32();
                nCurPos += sizeof(int);
                packin.ReadInt32();
                nCurPos += sizeof(int);
                if (nLen > m_stream.Length - nCurPos)     //封包不是完整的
                {
                    if (m_stream.Length == dedata.Length) //非法封包
                    {
                        m_stream.SetLength(0);
                        return;
                    }
                    break;
                }
                nCurPos += nLen;
                byte[] reData = packin.ReadBuff(nLen);
                if (reData == null || reData.Length == 0)
                {
                    break;
                }
                m_ListData.Enqueue(reData);
                if (nCurPos == m_stream.Length)
                {
                    break;
                }
            }
            int rema_Len = (int)m_stream.Length - nCurPos;

            if (rema_Len > 0)
            {
                dedata = new byte[rema_Len];
                Buffer.BlockCopy(m_stream.GetBuffer(), nCurPos, dedata, 0, rema_Len);
            }
            m_stream.SetLength(0);
            if (rema_Len > 0)
            {
                m_stream.Write(dedata, 0, dedata.Length);
            }
            return;
        }