public void RoomMyInfoDivide(Session p, PacketRead r) { r.Jump(6); ushort roomid = (ushort)r.Get_Short(); Room room = RoomExists(roomid); int TempCount = -1; for (int i = 0; i < room.m_usMaxUsers; i++) { if (room.m_dwSlots[i].Active == false) { continue; } TempCount++; if (room.m_dwSlots[i].usr == p) { PacketWrite pw = new PacketWrite(); pw.Int(0); pw.Int(room.m_usUsers()); pw.Int(TempCount); pw.UnicodeStr(room.m_dwSlots[i].usr.PInfo.m_strLogin); pw.Int(room.m_dwSlots[i].usr.PInfo.m_dwUserUID); pw.UnicodeStr(room.m_dwSlots[i].usr.PInfo.m_strNickName); pw.Int(i); pw.Byte(room.m_dwSlots[i].usr.PInfo.m_ucCharType); pw.Int(0); pw.HexArray("00 FF 00 FF 00 FF 00 00 00 00"); pw.Byte((byte)room.GetTeam(room.m_dwSlots[i].usr)); pw.HexArray("00 00 00 00 64 00 00"); pw.Int(room.m_dwSlots[i].usr.PInfo.m_iGamePoint); pw.Short(0); Serializables.SerializeStages(room.m_dwSlots[i].usr, pw); if (room.m_sSearchLeader() == room.m_dwSlots[i].usr) { pw.Bool(true); } else { pw.Bool(false); } pw.HexArray("01 00 00 00 00 00 00 00 00 00 00 00 00"); Serializables.m_roomCharacterInfo(room.m_dwSlots[i].usr, pw); pw.HexArray("00 00 00 02 76 19 A8 C0 10 0C D6 BA 00 00 00 01 7F 39 00 00 00 00 00 00 00 00 00 00 00"); pw.Byte(room.m_dwSlots[i].Status); pw.HexArray("00 00 00 00 00 12 C8 F2 00 00 00 00 00 D6 D9 BE 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 42 00 52 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 00 06 11 16 00 00 00 00 00 00 00 00 46 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 D8 00 00 01 A0 04 7B 00 00 00 00 00 00 00 00"); p.SendPacket(pw, 1472); break; } } }
public void Send(PacketWrite write, short opcode, bool compressed, short prefix) { using (var packetWrite = new PacketWrite()) { packetWrite.Short(opcode); packetWrite.Int(write.Length); packetWrite.Bool(compressed); packetWrite.Bytes(write.Packet); } }
private void RoomInfo(Session p, Room room) { PacketWrite pw = new PacketWrite(); pw.UShort(room.m_usRoomID); pw.UnicodeStr(room.m_strRoomName); pw.Byte(1); if (room.m_strRoomPasswd.Length > 0) { pw.Bool(true); } else { pw.Bool(false); } pw.UnicodeStr(room.m_strRoomPasswd); pw.Short(room.m_usUsers()); pw.Short(room.m_usMaxUsers); pw.Bool(room.m_bPlaying); pw.Byte(11); pw.Byte(room.m_cGameCategory); pw.Int(room.m_iGameMode); pw.Int(room.m_iSubGameMode); pw.Bool(room.m_bRandomableMap); pw.Int(room.m_iMapID); pw.Int(room.m_iP2PVersion); for (short j = 0; j < room.m_usMaxUsers; j++) { pw.Bool(room.m_dwSlots[j].Open); } if (room.m_usMaxUsers == 4) { pw.Bool(false); pw.Bool(false); } pw.Int(-1); pw.Int(room.m_cDifficulty); pw.HexArray("00 00 00 00 01"); pw.WriteIP(GameServer.m_dwIP); pw.UShort(GameServer.m_usURelayServerPort); pw.WriteIP(GameServer.m_dwIP); pw.UShort(GameServer.m_usTRelayServerPort); pw.HexArray("01 00 01 00 00 01 2C 00 00 00 14 00 02 26 24 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 00 00 00 00 00 00 00 00 00 04 42 00 52 00 00 06 01 00 00 00 00 00 00 00 06 00 00 00 00 FF FF FF FF"); p.SendPacket(pw, 1558); }
public static void KRoomInfo(Session right, PacketWrite ks) { libcomservice.REQUEST.Room room = right.PInfo.CurRoom; ks.UShort(room.m_usRoomID); ks.UnicodeStr(room.m_strRoomName); ks.Bool(room.m_bPublic); ks.Bool(room.m_bGuild); ks.UnicodeStr(room.m_strRoomPasswd); ks.Short(room.m_usUsers()); ks.Short(7); ks.Bool(room.m_bPlaying); ks.Byte(room.m_cGrade); ks.Byte(room.m_cGameCategory); ks.Int(room.m_iGameMode); ks.Int(room.m_iSubGameMode); ks.Bool(room.m_bRandomableMap); ks.Int(room.m_iMapID); ks.Int(room.m_iP2PVersion); for (short j = 0; j < room.m_usMaxUsers; j++) { ks.Bool(room.m_dwSlots[j].Open); } if (room.m_usMaxUsers == 4) { ks.Bool(false); ks.Bool(false); } ks.Int(room.m_vecMonsterSlot); ks.Int(room.m_cDifficulty); ks.HexArray("00 00 00 00 01"); ks.WriteIP(GameServer.m_dwIP); ks.UShort(GameServer.m_usURelayServerPort); ks.WriteIP(GameServer.m_dwIP); ks.UShort(GameServer.m_usTRelayServerPort); }
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); } }
public void EnterRoom(Session p, PacketRead r) { try { r.Jump(4); ushort roomID = (ushort)r.Get_Short(); string Password = r.UnicodeString(); r.Jump(5); string userLogin = r.UnicodeString(); r.Jump(4); string userNick = r.UnicodeString(); r.Jump(4); p.PInfo.m_ucCharType = r.Byte(); Room room = RoomExists(roomID); if (room == null) { PacketWrite pw2 = new PacketWrite(); pw2.Int(1); p.SendPacket(pw2, 54); return; } else if (room.m_abTotalSlotsOpen() == 0) { PacketWrite pw2 = new PacketWrite(); pw2.Int(1); p.SendPacket(pw2, 54); return; } else if (room.m_bPlaying == true) { PacketWrite pw2 = new PacketWrite(); pw2.Int(1); p.SendPacket(pw2, 54); return; } else if (room.m_strRoomPasswd != Password) { PacketWrite pw2 = new PacketWrite(); pw2.Int(1); p.SendPacket(pw2, 54); return; } int pos = 0; if (room.m_cGameCategory == 2) { pos = room.m_abSlotOpen(); } else { byte Team1 = 0, Team2 = 0; int EmptyPos1 = -1, EmptyPos2 = -1; for (int i = 0; i < 3; i++) { if (room.m_dwSlots[i].Active == true) { Team1++; } if (EmptyPos1 == -1 && room.m_dwSlots[i].Open == true) { EmptyPos1 = i; } } for (int i = 3; i < 6; i++) { if (room.m_dwSlots[i].Active == true) { Team2++; } if (EmptyPos2 == -1 && room.m_dwSlots[i].Open == true) { EmptyPos2 = i; } } pos = EmptyPos1; if (Team1 >= Team2) { pos = EmptyPos2; } } room.m_dwSlots[pos].Active = true; room.m_dwSlots[pos].usr = p; room.m_dwSlots[pos].Open = false; room.m_dwSlots[pos].AFK = false; room.m_dwSlots[pos].Deaths = 0; room.m_dwSlots[pos].Kills = 0; room.m_dwSlots[pos].Win = 0; room.m_dwSlots[pos].PositionSlot = pos; room.m_dwSlots[pos].Leader = false; p.PInfo.CurRoom = room; p.PInfo.m_cStatus = "ROOM"; GameServer.UsersList.Remove(p); PacketWrite pw = new PacketWrite(); pw.UnicodeStr(p.PInfo.m_strLogin); pw.Int(p.PInfo.m_dwUserUID); pw.UnicodeStr(p.PInfo.m_strNickName); pw.Int(pos); pw.Byte(p.PInfo.m_ucCharType); pw.Int(0); pw.HexArray("00 FF 00 FF 00 FF 00 00 00 00"); pw.Byte((byte)(pos / 3)); pw.HexArray("01 00 00 00 64 00 00"); pw.Int(p.PInfo.m_iGamePoint); pw.Short(0); Serializables.SerializeStages(p, pw); if (room.m_sSearchLeader() == p) { pw.Bool(true); } else { pw.Bool(false); } pw.HexArray("01 00 00 00 00 00 00 00 00 00 00 00 00"); Serializables.m_roomCharacterInfo(p, pw); pw.HexArray("00 00 00 02 76 19 A8 C0 10 0C D6 BA 00 00 00 01 7F 39 00 00 00 00 00 00 00 00 00 00 00"); pw.Byte(room.m_dwSlots[pos].Status); pw.HexArray("00 00 00 00 00 12 C8 F2 00 00 00 00 00 D6 D9 BE 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 42 00 52 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 00 06 11 16 00 00 00 00 00 00 00 00 46 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 97 D8 00 00 01 A0 04 7B 00 00 00 00 00 00 00 00"); room.SendForAllPlayersInRoom(pw, 54); RoomInfo(p, room); RoomInfoDivide(p, room); } catch (Exception ex) { Log.Write("{0}", ex.StackTrace); PacketWrite pw = new PacketWrite(); pw.Int(1); p.SendPacket(pw, 54); p.PInfo.CurRoom = null; p.PInfo.m_cStatus = "LOBBY"; GameServer.UsersList.Add(p); } }
public void ListRooms(Session p, PacketRead r) { try { byte RoomType = r.Byte(); byte RoomMode = r.Byte(); int RoomsCount = 0; foreach (ushort i in GameServer.List_Rooms.Keys) { if (p.PInfo.m_dwChannelUID == 6) { if (RoomMode != GameServer.List_Rooms[i].m_iGameMode) { continue; } } else { if (GameServer.List_Rooms[i].m_cGameCategory != 0) { continue; } } if (RoomType == 1) { if (GameServer.List_Rooms[i].m_bPlaying == true || GameServer.List_Rooms[i].m_abTotalSlotsOpen() == 0) { continue; } } RoomsCount += 1; } PacketWrite pw = new PacketWrite(); pw.Int(RoomsCount); foreach (ushort RoomPosition in GameServer.List_Rooms.Keys) { if (p.PInfo.m_dwChannelUID == 6) { if (RoomMode != GameServer.List_Rooms[RoomPosition].m_iGameMode) { continue; } } else { if (GameServer.List_Rooms[RoomPosition].m_cGameCategory != 0) { continue; } } if (RoomType == 1) { if (GameServer.List_Rooms[RoomPosition].m_bPlaying == true || GameServer.List_Rooms[RoomPosition].m_abTotalSlotsOpen() == 0) { continue; } } pw.UShort(GameServer.List_Rooms[RoomPosition].m_usRoomID); pw.UnicodeStr(GameServer.List_Rooms[RoomPosition].m_strRoomName); if (GameServer.List_Rooms[RoomPosition].m_strRoomPasswd.Length > 0) { pw.Bool(false); } else { pw.Bool(true); } pw.Byte(0); pw.UnicodeStr(GameServer.List_Rooms[RoomPosition].m_strRoomPasswd); pw.Short((short)(GameServer.List_Rooms[RoomPosition].m_abTotalSlotsOpen() + 1)); pw.Short(GameServer.List_Rooms[RoomPosition].m_usUsers()); pw.Bool(GameServer.List_Rooms[RoomPosition].m_bPlaying); pw.HexArray("6F 0C CC FA 0B 08 00 00 00 20 63 00 00 F5 00 00 00 03 00 00 00 00"); pw.Short(0); pw.Short(GameServer.List_Rooms[RoomPosition].m_usUsers()); for (int x = 0; x < GameServer.List_Rooms[RoomPosition].m_usMaxUsers; x++) { if (GameServer.List_Rooms[RoomPosition].m_dwSlots[x].Active) { pw.UnicodeStr(GameServer.List_Rooms[RoomPosition].m_dwSlots[x].usr.PInfo.m_strNickName); pw.Byte(11); } } pw.HexArray("00 00 00 00 01 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00 04 42 00 52 00 00 00 00 00 07 00 00 00 00 FF FF FF FF"); } p.SendPacket(PacketCompress.HalfCompress(pw.Get_Packet()), 49); } catch { PacketWrite pw = new PacketWrite(); pw.Int(0); p.SendPacket(PacketCompress.HalfCompress(pw.Get_Packet()), 49); } }