protected override void OnClientDisconnected(EzClient client) { Database.UpsertCharacter(client.Character, client.Account.Id); Database.UpsertSetting(client.Setting, client.Account.Id); if (client.Room != null) { Room room = client.Room; room.Leave(client); IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(room); Send(room, 10, roomCharacterPacket); IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(client.Channel); Send(client.Channel.GetLobbyClients(), 13, announceRoomPacket); } if (client.Channel != null) { Channel channel = client.Channel; channel.Leave(client); IBuffer characterList = LobbyCharacterListPacket.Create(channel); Send(channel.GetLobbyClients(), 2, characterList); } }
public override void Handle(EzClient client, EzPacket packet) { if (client.Room == null) { RoomInfo info = new RoomInfo(); info.PasswordProtected = packet.Data.ReadInt16() > 0; packet.Data.ReadInt32(); // 69~6A info.Password = packet.Data.ReadFixedString(4, Utils.KoreanEncoding); packet.Data.ReadInt32(); packet.Data.ReadInt32(); info.MaxPlayer = packet.Data.ReadByte(); info.GameType = (GameType)packet.Data.ReadByte(); // SinglePlayer / MultiPlayer info.GameGroupType = (GameGroupType)packet.Data.ReadByte(); // Individual / Team info.AllowViewer = packet.Data.ReadByte() > 0; info.MaxDifficulty = (DifficultyType)packet.Data.ReadByte(); info.SelectedSong = packet.Data.ReadInt32(Endianness.Big); info.Name = packet.Data.ReadFixedString(20, Utils.KoreanEncoding); Room room = client.Channel.CreateRoom(info, client); IBuffer openRoomPacket = RoomPacket.CreateOpenRoomPacket(client.Room, client); Send(client, 9, openRoomPacket); IBuffer characterList = LobbyCharacterListPacket.Create(client.Channel); Send(client.Channel.GetLobbyClients(), 2, characterList); _logger.Debug("Opened Room"); } else { //HEX:05-00-39-00-00-00-00-00-00-67-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-01-00-00-00-0A- //00-00-00-0E-C3-CA-BA-B8-B8-B8-20-BF-C0-BC-BC-BF-E4-21-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 //HEX:05-00-39-00-00-00-00-00-00-67-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-01-00-00-00-0A- //00-00-00-0E-C3-CA-BA-B8-B8-B8-20-BF-C0-BC-BC-BF-E4-21-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 IBuffer joinRoomPacket = RoomPacket.CreateJoinRoomPacket(client.Room, client); Send(client, 8, joinRoomPacket); _logger.Debug("Joined Room"); } IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(client.Room); Send(client, 10, roomCharacterPacket); IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(client.Channel); Send(client.Channel.GetLobbyClients(), 13, announceRoomPacket); client.Room.Log(_logger); }
public override int Id => 8; //뒤로 가기 public override void Handle(EzClient client, EzPacket packet) { if (client.Player.Playing) { client.Player.Playing = false; client.Player.Ready = false; } else { IBuffer response = EzServer.Buffer.Provide(); response.WriteByte(1); response.WriteByte(0); response.WriteByte(7); response.WriteByte(0); response.WriteByte((byte)client.Session.ChannelId); //1-xCH / 0=1ch 1=2ch 2=3ch 3=4ch Send(client, 5, response); if (client.Room != null) { Room room = client.Room; room.Leave(client); IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(room); Send(room, 10, roomCharacterPacket); _logger.Debug("Character {0} left room {1}", client.Character.Name, room.Info.Name); } else { _logger.Error("Character {0} left NULL room", client.Character.Name); } IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(client.Channel); Send(client.Channel.GetLobbyClients(), 13, announceRoomPacket); IBuffer characterList = LobbyCharacterListPacket.Create(client.Channel); Send(client.Channel.GetLobbyClients(), 2, characterList); } }
// 06-00-15-00-00-00-00- 00-00- 00-6A- 00-00-01- 00-00-00-00- 00-00-00-00-00-00-00-00-01-00 // 6A ? // 01 Room number //HEX:06-00-15-00-00-00-00- 00-00- 00-67- 00-00-03 -00-00-00-00 -00-00-00-00-00-00-00-00-01-00 //ASCII:. . . . . . . . . . g . . . s d d d . . . . . . . . . . //HEX:06-00-15-00-00-00-00- 00- 01- 00-67 -00-00-00- 73-64-64-64- 00-00-00-00-00-00-00-00-01-00 // 06-00-15-00-00-00-00- 00-01-00-67- 00-00-00-71-77-65-00-00-00-00-00-00-00-00-00-01-00 // 06-00-15-00-00-00-00- 00-00-00-67- 00-00-01-00-00-00-00-00-00-00-00-00-00-00-00-01-00 // 12 = exit room TODO // 11 = join room public override void Handle(EzClient client, EzPacket packet) { byte quickStart = packet.Data.ReadByte(); byte passwordProtected = packet.Data.ReadByte(); byte unknown0 = packet.Data.ReadByte(); byte channel = packet.Data.ReadByte(); // Channel + 100, 0 Indexed byte unknown1 = packet.Data.ReadByte(); byte unknown2 = packet.Data.ReadByte(); byte roomNumber = packet.Data.ReadByte(); string password = packet.Data.ReadFixedString(4, Utils.KoreanEncoding); _logger.Debug("Channel: {0}, Password {1}, Room#:{2}, QuickStart:{3}, PwProtected:{4}", channel - 100 + 1, password, roomNumber, quickStart, passwordProtected); Room room; if (quickStart > 0) { room = client.Channel.GetQuickRoom(); if (room == null) { _logger.Debug("No QuickStart Room found"); IBuffer joinErrorPacket = RoomPacket.CreateJoinErrorPacket(); Send(client, 8, joinErrorPacket); return; } } else { room = client.Channel.GetRoom(roomNumber); } if (room == null) { _logger.Error("Invalid room"); IBuffer joinErrorPacket = RoomPacket.CreateJoinErrorPacket(); Send(client, 8, joinErrorPacket); return; } if (passwordProtected > 0 && room.Info.Password != password) { _logger.Error("Invalid password ({0}) for room with password ({1})", password, room.Info.Password); IBuffer joinErrorPacket = RoomPacket.CreateJoinErrorPacket(); Send(client, 8, joinErrorPacket); return; } room.Join(client); IBuffer joinRoomPacket = RoomPacket.CreateJoinRoomPacket(room, client); Send(client, 8, joinRoomPacket); IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(room); Send(room, 10, roomCharacterPacket); IBuffer announceJoinPacket = RoomPacket.AnnounceJoin(client); Send(room, 11, announceJoinPacket); IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(client.Channel); Send(client.Channel.GetLobbyClients(), 13, announceRoomPacket); IBuffer characterList = LobbyCharacterListPacket.Create(client.Channel); Send(client.Channel.GetLobbyClients(), 2, characterList); _logger.Debug("Character {0} joined room {1}", client.Character.Name, room.Info.Name); }
public override void Handle(EzClient client, EzPacket packet) { RoomOptionType roomOption = (RoomOptionType)packet.Data.ReadInt32(); _logger.Debug("Change Option: {0}", roomOption); IBuffer buffer = EzServer.Buffer.Provide(); switch (roomOption) { case RoomOptionType.ChangeReady: { bool ready = packet.Data.ReadInt32() > 0; int unknown1A = packet.Data.ReadInt32(); _logger.Debug("ready: {0}", ready); _logger.Debug("unknown1A: {0}", unknown1A); // Slot? buffer.WriteByte(0); buffer.WriteByte(0); buffer.WriteInt32((int)roomOption); buffer.WriteInt32(ready ? 1 : 0); buffer.WriteInt32(unknown1A); client.Player.Ready = ready; IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(client.Room); Send(client.Room, 10, roomCharacterPacket); break; } case RoomOptionType.ChangeTeam: { TeamType team = (TeamType)packet.Data.ReadInt32(); int unknown0B = packet.Data.ReadInt32(); _logger.Debug("unknown0B: {0}", unknown0B); buffer.WriteByte(0); buffer.WriteByte(0); buffer.WriteInt32((int)roomOption); buffer.WriteInt32((int)team); buffer.WriteInt32(unknown0B); client.Player.Team = team; IBuffer roomCharacterPacket = RoomPacket.CreateCharacterPacket(client.Room); Send(client.Room, 10, roomCharacterPacket); break; } case RoomOptionType.ChangeFade: client.Room.Info.FadeEffect = (FadeEffectType)packet.Data.ReadInt32(); int unknown0C = packet.Data.ReadInt32(); _logger.Debug("unknown0C: {0}", unknown0C); buffer.WriteByte(0); buffer.WriteByte(0); buffer.WriteInt32((int)roomOption); buffer.WriteInt32((int)client.Room.Info.FadeEffect); buffer.WriteInt32(unknown0C); break; case RoomOptionType.ChangeNote: client.Room.Info.NoteEffect = (NoteEffectType)packet.Data.ReadInt32(); int unknown0D = packet.Data.ReadInt32(); _logger.Debug("unknown0D: {0}", unknown0D); buffer.WriteByte(0); buffer.WriteByte(0); buffer.WriteInt32((int)roomOption); buffer.WriteInt32((int)client.Room.Info.NoteEffect); buffer.WriteInt32(unknown0D); break; case RoomOptionType.ChangeSongAndDifficulty: client.Room.Info.RandomSong = false; client.Room.Info.SelectedSong = packet.Data.ReadInt32(); client.Room.Info.Difficulty = (DifficultyType)packet.Data.ReadInt32(); buffer.WriteByte(0); buffer.WriteByte(0); buffer.WriteInt32((int)roomOption); buffer.WriteInt32((int)client.Room.Info.SelectedSong); buffer.WriteInt32((int)client.Room.Info.Difficulty); break; case RoomOptionType.StartGame: int unknown0E = packet.Data.ReadInt32(); int unknown1E = packet.Data.ReadInt32(); _logger.Debug("unknown0E: {0}", unknown0E); _logger.Debug("unknown1E: {0}", unknown1E); buffer.WriteByte(0); buffer.WriteByte(0); buffer.WriteInt32((int)roomOption); buffer.WriteInt32(unknown0E); buffer.WriteInt32(unknown1E); break; case RoomOptionType.ChangeRandom: client.Room.Info.RandomSong = true; client.Room.Info.SelectedSong = packet.Data.ReadInt32(); client.Room.Info.Difficulty = (DifficultyType)packet.Data.ReadInt32(); buffer.WriteByte(0); buffer.WriteByte(0); buffer.WriteInt32((int)roomOption); buffer.WriteInt32((int)client.Room.Info.SelectedSong); buffer.WriteInt32((int)client.Room.Info.Difficulty); break; case RoomOptionType.ViewVideo: // TODO deduct 1000 coins. break; } Send(client.Room, 16, buffer); IBuffer announceRoomPacket = RoomPacket.CreateAnnounceRoomPacket(client.Channel); Send(client.Channel.GetLobbyClients(), 13, announceRoomPacket); client.Room.Log(_logger); }