public static void ProcessDeleteChar(Client client, PacketReader packetReader) { var uid = packetReader.ReadMuid(); var index = packetReader.ReadInt32(); var name = packetReader.ReadString(); var result = Results.Accepted; if (uid != client.GetMuid() || !Globals.AcceptedString.IsMatch(name) || index < 0 || index > 4) { client.Disconnect(); return; } var cid = Globals.GunzDatabase.GetCid(client.ClientPlayer.PlayerAccount.AccountId, index); if (cid == 0) { result = Results.CharacterDeleteDisabled; } else { Globals.GunzDatabase.DeleteCharacter(client.ClientPlayer.PlayerAccount.AccountId, cid); } Match.ResponseDeleteCharacter(client, result); }
public static void ProcessCreateChar(Client client, PacketReader packetReader) { var uid = packetReader.ReadMuid(); var index = packetReader.ReadInt32(); var name = packetReader.ReadString(); var sex = packetReader.ReadInt32(); var hair = packetReader.ReadInt32(); var face = packetReader.ReadInt32(); var costume = packetReader.ReadInt32(); var result = Results.Accepted; if (uid != client.GetMuid() || index < 0 || index > 4 || sex < 0 || sex > 1) { client.Disconnect(); return; } if (!Globals.AcceptedString.IsMatch(name)) result = Results.CharacterEnterName; else if (Globals.GunzDatabase.GetCharacterCount(client.ClientPlayer.PlayerAccount.AccountId) >= 4) result = Results.CharacterNameNonExistant; else if (Globals.GunzDatabase.CharacterExists(name)) result = Results.CharacterNameInUse; else if (!Globals.GunzDatabase.CreateCharacter(client.ClientPlayer.PlayerAccount.AccountId, (byte)index, name, sex, hair, face, costume)) result = Results.CharacterInvalidName; Match.ResponseCreateChar(client, result, name); }
public static void ProcessAccountCharList(Client client, PacketReader packetReader) { client.Unload(); var characters = Globals.GunzDatabase.GetCharacterList(client.ClientPlayer.PlayerAccount.AccountId); Match.ResponseCharList(client, characters); }
public void AddToQueue(Client client) { lock (_objectLock) { WaitQueue.Enqueue(client); } }
public static void ClanInfo(Client client, string clanName) { var player = client.ClientPlayer; var info = new ClanInfo(); var clanId = Globals.GunzDatabase.GetClanId(clanName); Globals.GunzDatabase.GetClanInfo(clanId, ref info); if (info == null) return; info.ConnectedMembers = Convert.ToInt16(TcpServer.GetClanMembers(clanId).Count); using (var packet = new PacketWriter(Operation.MatchClanResponseClanInfo, CryptFlags.Encrypt)) { packet.Write(1, 78); packet.Write(info.Name, 16); packet.Write(info.Level); packet.Write(info.Points); packet.Write(info.TotalPoints); packet.Write(info.Ranking); packet.Write(info.Master, 32); packet.Write(info.Wins); packet.Write(info.Losses); packet.Write(info.MemberCount); packet.Write(info.ConnectedMembers); packet.Write(info.ClanId); packet.Write(info.EmblemChecksum); client.Send(packet); } }
public static void Remove(Client client) { lock (_objectLock) { Clients.Remove(client); } }
public void Chat(Client client, string message) { if (message.StartsWith("/dtrank ")) { var args = message.Substring(message.IndexOf(" ") + 1); var dtrank = Int32.Parse(args); client.GetCharacter().DuelRank = dtrank; Refresh(); } if (message.StartsWith("/cw ")) { var args = message.Substring(message.IndexOf(" ") + 1); var c = Network.TcpServer.GetClientFromName(args); List<Client> red = new List<Client>(); List<Client> blue = new List<Client>(); red.Add(c); blue.Add(client); _stages.CreateClanwar(red, blue); } lock (_objectLock) ChannelPackets.ResponseChat(_traits.Playerlist, _traits.ChannelId, client.GetCharacter().Name, message, client.ClientPlayer.PlayerAccount.Access); }
public override void GameLeaveBattle(Client client) { if (CurrentBerserker == client) CurrentBerserker = null; base.GameLeaveBattle(client); }
public virtual void GameInfoCallback(Client client) { var traits = _stage.GetTraits(); lock (_stage.ObjectLock) { Battle.BattleResponseInfo(client, _teamScores[0], _teamScores[1], traits.Players); } client.ClientPlayer.PlayerStats.Spawned = true; client.ClientPlayer.PlayerStats.RequestedInfo = true; client.ClientPlayer.PlayerStats.Loaded = true; ProcessRoundState(); if ((!IsTeam() && !IsQuestDerived() && !IsDuel()) || IsExtreme()) { Battle.StageRoundUpdate(client, traits.StageId, traits.CurrentRound, traits.Round); Spawn(client); } else if (IsTeam()) { if (_roundState != RoundState.Play) { client.ClientPlayer.PlayerStats.Entered = true; } else { client.ClientPlayer.PlayerStats.Entered = false; client.ClientPlayer.PlayerStats.Spawned = false; Battle.StageRoundUpdate(client, traits.StageId, traits.CurrentRound, traits.Round); } } }
public override void OnGameKill(Client killer, Client victim) { if (killer == CurrentBerserker && CurrentStage.GetTraits().Name.ToLower().Contains("[sb]")) { lock (CurrentStage.ObjectLock) { Battle.AssignBerserker(CurrentStage.GetTraits().Players, CurrentBerserker.GetMuid()); } } if (victim == CurrentBerserker || CurrentBerserker == null) { lock (CurrentStage.ObjectLock) { CurrentBerserker = killer; Battle.AssignBerserker(CurrentStage.GetTraits().Players, CurrentBerserker.GetMuid()); } } if (killer.ClientPlayer.PlayerStats.Kills == CurrentStage.GetTraits().RoundCount) { GameInProgress = false; ItemSpawns.Abort(); GameOver(); } else { Spawn(victim, 5); } }
public static void ResponseChannelList(Client client, List<Channel> channels) { using (var packet = new PacketWriter(Operation.ChannelList, CryptFlags.Decrypt)) { packet.Write(channels.Count, 88); Int16 index = 0; foreach (var c in channels) { var traits = c.GetTraits(); packet.Write(traits.ChannelId); packet.Write(++index); packet.Write((Int16)traits.Playerlist.Count); packet.Write((Int16)traits.MaxUsers); packet.Write((Int16)traits.MinLevel); packet.Write((Int16)traits.MaxLevel); packet.Write((byte)traits.Type); packet.Write(traits.ChannelName, 64); packet.Write(false); packet.Write(0); } client.Send(packet); } }
public static void ResponseAllPlayerList(Client client, List<Client> clients, Muid channelId) { using (var packet = new PacketWriter(Operation.ChannelResponseAllPlayerList, CryptFlags.Encrypt)) { packet.Write(channelId); packet.Write(clients.Count, 73); foreach (var c in clients) { packet.Write(c.GetMuid()); packet.Write(c.GetCharacter().Name, 32); packet.Write(c.GetCharacter().ClanName, 16); packet.Write((byte)c.GetCharacter().Level); packet.Write((byte)c.GetCharacter().DuelRank);//dagger for duel tourney. packet.Write((Int32)c.ClientPlayer.PlayerLocation); packet.Write((byte)c.ClientPlayer.PlayerAccount.Access); packet.Write((byte)2); packet.Write(c.GetCharacter().ClanId); packet.Write(0);//unknown. packet.Write((byte)3);//unknown } client.Send(packet); } }
public static void ResponseCharacterItemList(Client client) { using (var packet = new PacketWriter(Operation.MatchResponseCharacterItemList, CryptFlags.Decrypt)) { packet.Write(client.GetCharacter().Bp); packet.Write(17, 8); for (var i = 0; i < 17; ++i) { packet.Write(0); packet.Write(client.GetCharacter().EquippedItems[i].ItemCid); } packet.Write(client.GetCharacter().Items.Count, 24); foreach (var i in client.GetCharacter().Items) { packet.Write(0); packet.Write(i.ItemCid); packet.Write(i.ItemId); packet.Write(i.RentHour); packet.Write(0); packet.Write(i.Quantity); } packet.Write(0, 12); client.Send(packet); } }
public virtual void GameKillCallback(Client killer, Client victim) { victim.ClientPlayer.PlayerStats.Spawned = false; if (_gameType == ObjectStageGameType.Training) { var uids = new Pair<Muid, Muid>(killer.GetMuid(), victim.GetMuid()); var args = new Pair<UInt32, UInt32>(0, 0); lock (CurrentStage.ObjectLock) { Battle.GameDie(CurrentStage.GetTraits().Players, uids, args); } } else { if (killer != victim) { var exp = ExpManager.GetExpFromKill(killer.GetCharacter().Level, victim.GetCharacter().Level); killer.GetCharacter().Xp += exp; var uids = new Pair<Muid, Muid>(killer.GetMuid(), victim.GetMuid()); var args = new Pair<UInt32, UInt32>((exp << 16), 0); lock (CurrentStage.ObjectLock) { Battle.GameDie(CurrentStage.GetTraits().Players, uids, args); //killer.GetCharacter().Level = // (Int16) ExpManager.GetLevel((Int32) killer.GetCharacter().Xp); Log.Write("Exp Gained: {0} | Exp To Next Level: {1} | Current Exp: {2}", exp, ExpManager.GetExp(killer.GetCharacter().Level + 1), killer.GetCharacter().Xp); if (ExpManager.Level(killer.GetCharacter().Level, killer.GetCharacter().Xp)) { killer.GetCharacter().Level++; Battle.GameLevelUp(CurrentStage.GetTraits().Players, killer.GetMuid(), killer.GetCharacter().Level); EventManager.AddCallback( () => Globals.GunzDatabase.UpdateLevel(killer.GetCharacter().CharacterId, killer.GetCharacter().Xp, killer.GetCharacter().Level)); } } killer.ClientPlayer.PlayerStats.Kills++; victim.ClientPlayer.PlayerStats.Deaths++; if (killer.ClientPlayer.PlayerStats.Kills%20 == 0) { EventManager.AddCallback( () => Globals.GunzDatabase.UpdateLevel(killer.GetCharacter().CharacterId, killer.GetCharacter().Xp, killer.GetCharacter().Level)); } } } OnGameKill(killer, victim); }
public static void Notify(Client client, Int32 error) { using (var packet = new PacketWriter(Operation.MatchNotify, CryptFlags.Encrypt)) { packet.Write(error); client.Send(packet); } }
public static void AgentError(Client client, Int32 error) { using (var packet = new PacketWriter(Operation.AgentError, CryptFlags.Encrypt)) { packet.Write(error); client.Send(packet); } }
public static void ResponseBuyItem(Client client, Results results) { using (var packet = new PacketWriter(Operation.MatchResponseBuyItem, CryptFlags.Decrypt)) { packet.Write((Int32)results); client.Send(packet); } }
public static void ProccessLateJoin(Client client, PacketReader packet) { if (client.GetStage() == null) return; Battle.ResponseLateJoin(client); client.GetStage().GetTraits().Ruleset.GameLateJoinCallback(client); }
public static void ExpelMemberNotAllowed(Client client) { using (var expelMember = new PacketWriter(Operation.MatchClanAdminResponseLeaveMember, CryptFlags.Encrypt)) { expelMember.Write((Int32)Results.ClanNotAuthorized); client.Send(expelMember); } }
public static void ResponsePeerRelay(Client client, Muid playerId) { using (var packet = new PacketWriter(Operation.MatchResponsePeerRelay, CryptFlags.Encrypt)) { packet.Write(playerId); client.Send(packet); } }
public static void ReserveStageToAgent(Client client, Muid stageId) { using (var packet = new PacketWriter(Operation.AgentStageReserve, CryptFlags.Encrypt)) { packet.Write(stageId); client.Send(packet); } }
public static void BattleResponseInfo(Client client, int red, int blue, List<Client> players) { using (var packet = new PacketWriter(Operation.BattleResponseInfo, CryptFlags.Encrypt)) { var traits = client.GetStage().GetTraits(); packet.Write(traits.StageId); packet.Write(1, 6); packet.Write((byte)red); packet.Write((byte)blue); packet.Write(0); //TODO: Add rulesets here. if (!traits.Ruleset.IsBerserker() || !traits.Ruleset.IsAssassination() || ((Berserker)traits.Ruleset).CurrentBerserker == null) { packet.Write(0, 0); } else if (traits.Ruleset.IsBerserker()) { var berserker = traits.Ruleset as Berserker; if (berserker != null && berserker.CurrentBerserker != null) { packet.Write(1, 9); packet.Write((byte)8); packet.Write(berserker.CurrentBerserker.GetMuid()); } } else if (traits.Ruleset.IsAssassination()) { var rule = traits.Ruleset as Assassination; if (rule.RedVip != null && rule.BlueVip != null) { packet.Write(1, 17); packet.Write((byte) ObjectStageGameType.Assassination); packet.Write(rule.RedVip.GetMuid()); packet.Write(rule.BlueVip.GetMuid()); } else { packet.Write(0,0); } } packet.Write(players.Count, 17); foreach (var c in players) { packet.Write(c.GetMuid()); packet.Write(c.ClientPlayer.PlayerStats.Spawned); packet.Write(c.ClientPlayer.PlayerStats.Kills); packet.Write(c.ClientPlayer.PlayerStats.Deaths); } client.Send(packet); } }
public static void ProcessBattleInfo(Client client, PacketReader packetReader) { if (client.GetStage() == null) { Log.Write("NULL Stage?"); return; } client.GetStage().GetTraits().Ruleset.GameInfoCallback(client); }
public static void ResponseLiveCheckk(Client client, Int32 timeStamp) { using (var packet = new PacketWriter(Operation.MatchAgentResponseLiveCheck, CryptFlags.Encrypt)) { packet.Write(timeStamp); client.Send(packet); } }
public static void ProcessChat(Client client, PacketReader packet) { var uidChar = packet.ReadMuid(); var uidChan = packet.ReadMuid(); var message = packet.ReadString(); if (client.GetChannel() != null) client.GetChannel().Chat(client, message); }
public static void LadderPrepare(Client client, int teamNumber) { using (var packet = new PacketWriter(Operation.LadderPrepare, CryptFlags.Encrypt)) { packet.Write(client.GetMuid()); packet.Write(teamNumber); client.Send(packet); } }
public static void ResponseBridgePeer(Client client) { using (var packet = new PacketWriter(Operation.BridgeResponse, CryptFlags.Decrypt)) { packet.Write(client.GetMuid()); packet.Write((Int32)Results.Accepted); client.Send(packet); } }
public static void ResponseCharInfo(Client client) { using (var packet = new PacketWriter(Operation.MatchResponseAccountCharInfo, CryptFlags.Encrypt)) { packet.Write(client.GetCharacter().CharNum); packet.Write(client.GetCharacter()); client.Send(packet); } }
public static void Announce(Client client, string message) { using (var packet = new PacketWriter(Operation.AdminAnnounce, CryptFlags.Decrypt)) { packet.Write(client.GetMuid()); packet.Write(message); packet.Write(0); TcpServer.GlobalPacket(packet); } }
public static void RelayPeer(Client client, Bunny.Utility.Tuple<Muid,Muid,Muid> uids) { using (var packet = new PacketWriter(Operation.AgentRelayPeer, CryptFlags.Encrypt)) { packet.Write(uids.First); packet.Write(uids.Second); packet.Write(uids.Third); client.Send(packet); } }