コード例 #1
0
ファイル: Sessions.cs プロジェクト: Raitou/SeasonVEP2Emu
        private void SESSION_RECEIVE(byte[] _buffer, int _size)
        {
            int        pos       = 0;
            PacketRead RB_BUFFER = new PacketRead(_buffer, 0);
            ushort     size      = RB_BUFFER.UShort();

            while (pos < _size)
            {
                if (C_Running == false)
                {
                    return;
                }
                if (pos >= _size)
                {
                    return;
                }
                try
                {
                    byte[] n_buffer = new byte[size];
                    Array.Copy(_buffer, pos, n_buffer, 0, size);

                    PacketRead r0 = new PacketRead(n_buffer, 0);

                    pos += (ushort)((_buffer[pos + 1] << 8) | (_buffer[pos]));
                    ushort new_size = r0.UShort();
                    r0.Short();
                    r0.Int();

                    byte[] iv          = r0.Buffer_Array_Bytes(8);
                    byte[] content     = r0.Buffer_Array_Bytes(new_size - 16 - 10);
                    byte[] get_payload = Cryptography.DECRYPT(content, iv);

                    PacketRead rb       = new PacketRead(get_payload, 0, true);
                    ushort     packetId = (ushort)((get_payload[0] << 8) | (get_payload[1]));

                    if (HRecv.HANDLER.ContainsKey(packetId))
                    {
                        Log.Write("clog : KTRUser::KSkTRUser::OnRecvCompleted({6}), {0}-{1}-{2}. {3}:{4}:{5}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Second, DateTime.Now.Minute, DateTime.Now.Hour, packetId);

                        Type type = Type.GetType(HRecv.TYPE_HANDLER[packetId].ToString());

                        object classInstance = Activator.CreateInstance(type, null);

                        HRecv.HANDLER[packetId].Invoke(classInstance, new object[] { this, rb });
                    }
                    else
                    {
                        Log.Write("clog : KTRUser::KSkTRUser::OnRecvFailed,Packet unknown {6}! {0}-{1}-{2}. {3}:{4}:{5}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Second, DateTime.Now.Minute, DateTime.Now.Hour, packetId);
                        Log.Write("\nclog : KTRUser::KSkTRUser::OnRecvFailed, Payload: \n{0}", BitConverter.ToString(get_payload).Replace("-", " "));
                        PacketWrite p = new PacketWrite();
                        p.Int(0);
                        SendPacket(p, (short)(packetId + 1));
                    }
                }
                catch (Exception ex)
                {
                    Log.Write("{0} \n {1}", ex.Message, ex.StackTrace);
                }
            }
        }
コード例 #2
0
ファイル: Serializables.cs プロジェクト: Raitou/SeasonVEP2Emu
        public static void KRoomInfo(Session right, PacketRead rs)
        {
            libcomservice.REQUEST.Room room = new libcomservice.REQUEST.Room();

            ushort m_usRoomID = rs.UShort();

            room.m_strRoomName   = rs.UnicodeString();
            room.m_bPublic       = rs.Bool();
            room.m_bGuild        = rs.Bool();
            room.m_strRoomPasswd = rs.UnicodeString();
            short m_usUsers = rs.Short();

            room.m_usMaxUsers     = rs.Get_Short();
            room.m_bPlaying       = rs.Bool();
            room.m_cGrade         = rs.Byte();
            room.m_cGameCategory  = rs.Byte();
            room.m_iGameMode      = rs.Int();
            room.m_iSubGameMode   = rs.Int();
            room.m_bRandomableMap = rs.Bool();
            room.m_iMapID         = rs.Int();
            room.m_iP2PVersion    = rs.Int();
            byte[] m_abSlotOpen = rs.Buffer_Array_Bytes(6);
            room.m_vecMonsterSlot = rs.Int();
            room.m_cDifficulty    = rs.Int();
            rs.Jump(17);

            ushort index_room = 0;

            for (ushort i = 1; i < GameServer.m_usMaxUsers; i++)
            {
                if (GameServer.List_Rooms.ContainsKey(i))
                {
                    continue;
                }
                index_room = i;
                break;
            }
            room.m_usRoomID = index_room;

            room.m_dwSlots[0].Active = true;
            room.m_dwSlots[0].usr    = right;
            room.m_dwSlots[0].Leader = true;
            room.m_dwSlots[0].Open   = false;
            room.m_dwSlots[0].Status = 0;
            room.m_dwSlots[0].AFK    = false;
            room.m_dwSlots[0].Team   = 0;

            for (int i = 1; i < room.m_usMaxUsers; i++)
            {
                room.m_dwSlots[i].Active = false;
                room.m_dwSlots[i].usr    = null;
                room.m_dwSlots[i].Leader = false;
                room.m_dwSlots[i].Open   = true;
                room.m_dwSlots[i].Status = 0;
                room.m_dwSlots[i].AFK    = false;
                room.m_dwSlots[i].Team   = 0;
            }
            right.PInfo.CurRoom = room;
        }
コード例 #3
0
        public void CreateRoom(Session p, PacketRead r)
        {
            //===================
            // 0; OK..
            // 1; 현재 채널에 더이상의 방을 만들 수 없음.
            // 2; 존재하지 않는 캐릭터가 선택되었습니다.
            // 3; 입장할수 있는 올바른 레벨이 아닙니다.
            try
            {
                int m_dwOK = 0;
                Serializables.KRoomInfo(p, r);
                byte[] restant = r.Buffer_Array_Bytes(78);
                Serializables.KUserInfo(p, r);

                PacketWrite pw = new PacketWrite();
                pw.Int(m_dwOK);
                Serializables.KUserInfo(p, pw);
                Serializables.SerializeStages(p, pw);
                pw.HexArray("01 01 00 00 00 00 00 00 00 00 00 00 00 00");
                Serializables.m_roomCharacterInfo(p, pw);
                pw.HexArray("00 00 00 02 6B 00 A8 C0 E4 02 2D B1 00 00 00 01 7F 1A 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 E5 6A 00 00 00 00 00 D9 92 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 04 5A 00 5A 00 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 D2 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 D2 F0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 01 00 00 00 00 85 89 82 21 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                Serializables.KRoomInfo(p, pw);
                pw.ArrayBytes(restant);

                p.SendPacket(pw, 57);
                GameServer.List_Rooms.Add(p.PInfo.CurRoom.m_usRoomID, p.PInfo.CurRoom);
                GameServer.UsersList.Remove(p);
                p.PInfo.m_cStatus = "ROOM";
            }
            catch (Exception ex)
            {
                Log.Write("\n===========:Error:===========\n{0}\n{1}\n=============================n", ex.Message, ex.StackTrace);
                PacketWrite pw = new PacketWrite();
                pw.Int(1);
                pw.UnicodeStr(p.PInfo.m_strLogin);
                pw.Int(p.PInfo.m_dwUserUID);
                pw.UnicodeStr(p.PInfo.m_strNickName);
                p.SendPacket(pw, 57);
            }
        }
コード例 #4
0
ファイル: VerifyAccount.cs プロジェクト: Raitou/SeasonVEP2Emu
        public void Login(Session p, PacketRead r)
        {
            //33 = +1
            //1249 - normal
            try
            {
                byte[] Crc32  = new byte[] { 0x43, 0x7D, 0x7A, 0x7A };
                int    m_dwOK = 0;
                p.PInfo.m_strLogin  = r.String();
                p.PInfo.m_strPasswd = r.String();
                p.PInfo.m_bMale     = r.Bool();
                p.PInfo.m_iVersion  = r.Int();
                r.Int();
                byte[] checksum = r.Buffer_Array_Bytes(4);
                //Log.WriteHex("Checksum:",checksum);

                PacketWrite pw = new PacketWrite();

                Log.Write("clog : KTRUser::KSkTRUser::CheckLogin::User {0} and Passwd {1}", p.PInfo.m_strLogin, p.PInfo.m_strPasswd);
                int Login_Acess = Querys.Execute_VerifyAccount(p, p.PInfo.m_strLogin, p.PInfo.m_strPasswd);
                if (Login_Acess == 0)
                {
                    p.Req.ExpTable(p);
                    p.Req.ServerTime(p);
                    p.Req.NewCharChoice(p);
                    p.PCharacters.LoadCharacters(p.PInfo.m_strLogin, p.PInfo.m_dwUserUID);
                    p.PStages.LoadStages(p);
                    p.PInventory.InventoryItens(p);
                    p.PLetter.LoadLetter(p.PInfo.m_dwUserUID);
                    Log.Write("clog : KTRUser::KSkTRUser::OnClientLoginOK(), {0}-{1}-{2}.", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day);
                }
                else if (Login_Acess == 14)
                {
                    m_dwOK = 7;
                }
                if (checksum != Crc32)
                {
                    m_dwOK = 10;
                }
                pw.UnicodeStr(p.PInfo.m_strLogin);
                pw.UnicodeStr(p.PInfo.m_strNickName);
                pw.Int(0);
                pw.Str(p.PInfo.m_strPasswd);
                pw.HexArray("00 2E 00 37 00 32 00 31 00 00 C8 72 D1 BF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 FF 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00");
                pw.Byte(0);     //m_cAuthLevel
                pw.Int(100);    //m_iAge
                pw.Bool(false); //m_bAgreePrivateInfo
                pw.Byte(0);     //m_cPCBangType
                Serializables.m_mapCharacterInfo(p, pw);
                pw.UShort(GameServer.m_usUdpPort);
                pw.Int(p.PInfo.m_dwUserUID);
                pw.UnicodeStr(GameServer.m_strServerName);
                pw.Int(GameServer.m_iSessionInfo);
                pw.HexArray("00 00 00 00");
                Serializables.SerializeStages(p, pw);
                pw.UInt(3222798336);//C0 18 00 00 //m_nConnectType
                Serializables.m_vecMissionSlot(p, pw);
                pw.Int(0);
                pw.HexArray("29 E1 85 22 02 00 74 85 00 00 00 01 00 00 00 00 00 00 00 00");
                pw.UnicodeStr("MsgServer_02");
                pw.Str(GameServer.m_dwIP);
                pw.UShort(GameServer.m_usMsgPort);
                pw.HexArray("00 00 02 9D 00 00 00 00 00 00 00 00 FF FF FF FF FF FF FF FF");
                pw.Str(GameServer.m_dwIP);
                pw.HexArray("00 00 00 00 00 00 00 00 03 5A 35 55 C0 5A 35 55 C0 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 01 00 00 00 01 61 D0 5E 60 00 D0 FF F9 3D AC 0C F9 74 00 5A 35 55 00 00 00 00 00 73 E6 5F 5A 33 2C A0 00 00 00 00");
                //Chars
                pw.HexArray("00 00 00 15 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 02 00 00 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 03 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 04 00 00 00 04 00 00 00 00 00 00 00 00 00 00 00 00 00 05 00 00 00 05 00 00 00 00 00 00 00 00 00 00 00 00 00 06 00 00 00 06 00 00 00 00 00 00 00 00 00 00 00 00 00 07 00 00 00 07 00 00 00 00 00 00 00 00 00 00 00 00 00 08 00 00 00 08 00 00 00 00 00 00 00 00 00 00 00 00 00 09 00 00 00 09 00 00 00 00 00 00 00 00 00 00 00 00 00 0A 00 00 00 0A 00 00 00 00 00 00 00 00 00 00 00 00 00 0B 00 00 00 0B 00 00 00 00 00 00 00 00 00 00 00 00 00 0C 00 00 00 0C 00 00 00 00 00 00 00 00 00 00 00 00 00 0D 00 00 00 0D 00 00 00 00 00 00 00 00 00 00 00 00 00 0E 00 00 00 0E 00 00 00 00 00 00 00 00 00 00 00 00 00 0F 00 00 00 0F 00 00 00 00 00 00 00 00 00 00 00 00 00 10 00 00 00 10 00 00 00 00 00 00 00 00 00 00 00 00 00 11 00 00 00 11 00 00 00 00 00 00 00 00 00 00 00 00 00 12 00 00 00 12 00 00 00 00 00 00 00 00 00 00 00 00 00 13 00 00 00 13 00 00 00 00 00 00 00 00 00 00 00 00 00 14 00 00 00 14 00 00 00 00 00 00 00 00 00 00");
                pw.HexArray("00 00 00 03 00 00 00 C6 00 0C 22 CC 00 00 00 00 00 00 00 C7 00 0C F1 FC 00 00 00 00 00 00 00 C9 00 15 6D 0A 00 00 00 01");
                pw.Int(p.PInfo.m_dwSlots);
                pw.Byte(255);
                pw.Byte(0);
                pw.Byte(0);
                p.SendPacket(pw, 34);
                p.Shop.SendMyVirtualCash(p);
                p.HeroDugeons.HeroDungeonInfo(p);
                UdpPort(p);
                sends(p);
            }
            catch (Exception Ex)
            {
                Log.Write("{0} \n\n {1}", Ex.Message, Ex.StackTrace);
            }
        }
コード例 #5
0
ファイル: Serializables.cs プロジェクト: Raitou/SeasonVEP2Emu
        public static void KEquipItemInfo(Session right, PacketRead rs, int m_vecCharInfo)
        {
            for (int i = 0; i < m_vecCharInfo; i += 1)
            {
                byte m_cCharIndex     = rs.Byte();
                int  m_vecEquipInfo   = rs.Int();
                int  m_dwCharPosition = right.PCharacters.PositionCharacter(m_cCharIndex, right);
                for (int x = 0; x < m_vecEquipInfo; x += 1)
                {
                    int    m_dwID      = rs.Int();
                    int    m_dwUnk     = rs.Int();
                    int    m_dwUID     = rs.Int();
                    byte   m_cUpgrade  = rs.Byte();
                    byte   m_cGrade    = rs.Byte();
                    int    m_dwLevel   = rs.Int();
                    byte[] test        = rs.Buffer_Array_Bytes(9);
                    int    m_dwAtrribs = rs.Int();
                    for (int x2 = 0; x2 < m_dwAtrribs; x2++)
                    {
                        rs.Jump(7);
                    }
                    right.PCharacters.AddEquipment(m_dwID, m_dwUID, m_dwCharPosition, right);
                    //Log.Write("Character:{0} Equips: {1} Current Item:{2} Atribbs:{3}", m_cCharIndex, m_vecEquipInfo, m_dwID, m_dwAtrribs);
                }
                int m_vecDelInfo = rs.Int();
                for (int x = 0; x < m_vecDelInfo; x += 1)
                {
                    int    m_dwID      = rs.Int();
                    int    m_dwUnk     = rs.Int();
                    int    m_dwUID     = rs.Int();
                    byte   m_cUpgrade  = rs.Byte();
                    byte   m_cGrade    = rs.Byte();
                    int    m_dwLevel   = rs.Int();
                    byte[] test        = rs.Buffer_Array_Bytes(9);
                    int    m_dwAtrribs = rs.Int();
                    for (int x2 = 0; x2 < m_dwAtrribs; x2++)
                    {
                        rs.Jump(7);
                    }
                    right.PCharacters.RemoveEquipment(m_dwID, m_dwCharPosition, right);
                }
                int    m_dwPetIsNew = rs.Int();
                int    m_dwPetUID   = rs.Int();
                int    m_dwPetID    = rs.Int();
                string m_strPetName = rs.String();
                int    m_mapInitExp = rs.Int();
                for (int x = 0; x < m_mapInitExp; x++)
                {
                    rs.Byte();
                    rs.Int();
                }
                uint m_dwExp          = rs.UInt();
                int  m_iLevel         = rs.Int();
                byte m_cPromotion     = rs.Byte();
                int  m_nHatchingID    = rs.Int();
                int  m_iInitSatiation = rs.Int();
                int  m_iSatiation     = rs.Int();
                uint m_vecEquipItem   = rs.UInt();
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].Slot1.Clear();
                for (uint x = 0; x < m_vecEquipItem; x++)
                {
                    uint m_dwPetAtkId = rs.UInt();
                    rs.Jump(4);
                    uint m_dwPetAtkUID = rs.UInt();
                    rs.Byte();
                    right.PCharacters.AddAtkPetSlot1((int)m_dwPetAtkId, m_dwPetAtkUID, m_dwCharPosition, right);
                }
                uint m_vecEquipItem2 = rs.UInt();
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].Slot2.Clear();
                for (uint x = 0; x < m_vecEquipItem2; x++)
                {
                    uint m_dwPetAtkId = rs.UInt();
                    rs.Jump(4);
                    uint m_dwPetAtkUID = rs.UInt();
                    rs.Byte();
                    right.PCharacters.AddAtkPetSlot2((int)m_dwPetAtkId, m_dwPetAtkUID, m_dwCharPosition, right);
                }
                byte[] restantPet = rs.Buffer_Array_Bytes(14);
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_dwUID          = m_dwPetUID;
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_dwID           = m_dwPetID;
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_strName        = m_strPetName;
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_cPromotion     = m_cPromotion;
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_dwEXP          = m_dwExp;
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_iInitSatiation = m_iInitSatiation;
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_iLevel         = m_iLevel;
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_iSatiation     = m_iSatiation;
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_mapInitExp     = m_mapInitExp;
                right.PCharacters.CharInfo[m_dwCharPosition].Pets[0].m_nHatchingID    = m_nHatchingID;
                //Log.Write("Character:{0} PetID: {1} PetName:{2} Equips:{3}", m_cCharIndex, m_dwPetID, m_strPetName, m_vecEquipItem);

                rs.Jump(41);
            }
        }