コード例 #1
0
        public void CM_SELECT_CHARACTER(Saga.Shared.PacketLib.Login.CMSG_FINDCHARACTERDETAILS cpkt)
        {
            LoginSession session;

            if (LoginSessionHandler.sessions.TryGetValue(cpkt.SessionId, out session))
            {
                //ASSIGN RAW BYTES
                SMSG_CHARACTERDETAILS spkt = new SMSG_CHARACTERDETAILS();
                spkt.SetRawBytes(cpkt.GetRawBytes());
                spkt.SessionId = cpkt.SessionId;
                session.CachedCharacterStates[cpkt.CharacterId] = (byte[])spkt;

                //GET CHARACTER-INDEX
                int index = session.list.FindIndex(
                    delegate(CharInfo info)
                {
                    return(info.charId == cpkt.CharacterId);
                }
                    );

                //INVOKE CHARACTER GET
                if (index < 0)
                {
                    return;
                }
                CMSG_REQUESTCHARACTERDETAILS cpkt2 = new CMSG_REQUESTCHARACTERDETAILS();
                cpkt2.Index     = (byte)index;
                cpkt2.SessionId = cpkt.SessionId;
                session.client.OnGetCharData(cpkt2);
            }
        }
コード例 #2
0
        internal void OnGetCharData(CMSG_REQUESTCHARACTERDETAILS cpkt)
        {
            //HELPER VARIABLES
            CharInfo    info;
            ServerInfo2 info2;

            byte[]       cachedbuffer;
            LoginSession session;

            //GET CHARACTER DETAILS - WE CACHE THE DETAILS
            //SO WE DON'T OVERLOAD THE BACKEND, BUT INSTEAD THE FRONTEND
            if (LoginSessionHandler.sessions.TryGetValue(cpkt.SessionId, out session))
            {
                if (cpkt.Index <= session.list.Count)
                {
                    info = session.list[cpkt.Index];

                    if (session.CachedCharacterStates.TryGetValue(info.charId, out cachedbuffer))
                    {
                        this.Send(cachedbuffer);
                    }
                    else
                    {
                        if (ServerManager2.Instance.server.TryGetValue(session.World, out info2))
                        {
                            info2.client.SM_SELECT_CHARACTER(info.charId, cpkt.SessionId);
                        }
                    }
                }
            }
        }