Пример #1
0
        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);
            }
        }
Пример #2
0
        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);
            }
        }
Пример #3
0
        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);
            }
        }
Пример #4
0
        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);
            }
        }
Пример #5
0
 public static void ReserveStageToAgent(Client client, Muid stageId)
 {
     using (var packet = new PacketWriter(Operation.AgentStageReserve, CryptFlags.Encrypt))
     {
         packet.Write(stageId);
         client.Send(packet);
     }
 }
Пример #6
0
 public static void ResponseBuyItem(Client client, Results results)
 {
     using (var packet = new PacketWriter(Operation.MatchResponseBuyItem, CryptFlags.Decrypt))
     {
         packet.Write((Int32)results);
         client.Send(packet);
     }
 }
Пример #7
0
 public static void ExpelMemberNotAllowed(Client client)
 {
     using (var expelMember = new PacketWriter(Operation.MatchClanAdminResponseLeaveMember, CryptFlags.Encrypt))
     {
         expelMember.Write((Int32)Results.ClanNotAuthorized);
         client.Send(expelMember);
     }
 }
Пример #8
0
 public static void Notify(Client client, Int32 error)
 {
     using (var packet = new PacketWriter(Operation.MatchNotify, CryptFlags.Encrypt))
     {
         packet.Write(error);
         client.Send(packet);
     }
 }
Пример #9
0
 public static void ResponsePeerRelay(Client client, Muid playerId)
 {
     using (var packet = new PacketWriter(Operation.MatchResponsePeerRelay, CryptFlags.Encrypt))
     {
         packet.Write(playerId);
         client.Send(packet);
     }
 }
Пример #10
0
 public static void AgentError(Client client, Int32 error)
 {
     using (var packet = new PacketWriter(Operation.AgentError, CryptFlags.Encrypt))
     {
         packet.Write(error);
         client.Send(packet);
     }
 }
Пример #11
0
        public static void ResponseLiveCheckk(Client client, Int32 timeStamp)
        {
            using (var packet = new PacketWriter(Operation.MatchAgentResponseLiveCheck, CryptFlags.Encrypt))
            {
                packet.Write(timeStamp);

                client.Send(packet);
            }
        }
Пример #12
0
        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);
            }
        }
Пример #13
0
        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);
            }
        }
Пример #14
0
        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);
            }
        }
Пример #15
0
        public static void AgentLocateToClient(Client client, Muid agentId)
        {
            using (var packet = new PacketWriter(Operation.AgentLocateToClient, CryptFlags.Encrypt))
            {
                packet.Write(agentId);
                packet.Write(Globals.Config.Agent.RemoteIp);
                packet.Write((Int32)Globals.Config.Agent.TcpPort);
                packet.Write((Int32)Globals.Config.Agent.UdpPort);

                Log.Write("Telling client to locate to: {0}:{1}:{2}", Globals.Config.Agent.RemoteIp,
                          Globals.Config.Agent.TcpPort, Globals.Config.Agent.UdpPort);
                client.Send(packet);
            }
        }
Пример #16
0
        public static void ResponseChannelJoin(Client client)
        {
            var traits = client.GetChannel().GetTraits();

            using (var packet = new PacketWriter(Operation.ChannelResponseJoin, CryptFlags.Encrypt))
            {
                packet.Write(traits.ChannelId);
                packet.Write((Int32)traits.Type);
                packet.Write(traits.ChannelName);
                packet.Write(true);

                client.Send(packet);
            }
        }
Пример #17
0
        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);
            }
        }
Пример #18
0
        public static void GameResponseTimesync(Client client, Int32 time)
        {
            using (var packet = new PacketWriter(Operation.GameResponseTimeSync, CryptFlags.Encrypt))
            {
                packet.Write(time);

                var timesync = time;
                client.ClientPlayer.LastTimeSync = (int)timesync;

                packet.Write(timesync);

                client.Send(packet);
            }
        }
Пример #19
0
        public static void DuelQueue(Client client, List<Client> players, byte queueLength, byte streak, bool roundEnd = false)
        {
            using (var packet = new PacketWriter(Operation.MatchDuelQueueInfo, CryptFlags.Encrypt))
            {
                packet.Write(131);
                foreach (var player in players)
                {
                    packet.Write(player == null ? new Muid(0, 0) : player.GetMuid());
                }

                packet.Write(queueLength);
                packet.Write(streak);
                packet.Write(roundEnd);

                client.Send(packet);
            }
        }
Пример #20
0
 public static void ProcessQuestRequestStageLevel(Client client, PacketReader packetReader)
 {
     using (var packet = new PacketWriter(Operation.QuestResponseStageLevel, CryptFlags.Encrypt))
     {
         packet.Write(0);
         client.Send(packet);
     }
 }
Пример #21
0
        public static void ResponseObjectCache(Client client, ObjectCache cache, List<Client> clients)
        {
            using (var packet = new PacketWriter(Operation.MatchObjectCache, CryptFlags.Encrypt))
            {
                packet.Write((byte)cache);
                packet.Write(clients.Count, 176);

                foreach (var c in clients)
                {
                    packet.Write(0);
                    packet.Write(c.GetMuid());
                    packet.Write(c.GetCharacter().Name, 32);
                    packet.Write(c.GetCharacter().ClanName, 16);
                    packet.Write((Int32)c.GetCharacter().Level);
                    packet.Write((Int32)c.ClientPlayer.PlayerAccount.Access);
                    packet.Write(0);
                    packet.Write(0);
                    packet.Write(c.GetCharacter().ClanId);
                    packet.Write(0);
                    packet.Write((Int32)c.GetCharacter().Sex);
                    packet.Write(c.GetCharacter().Hair);
                    packet.Write(c.GetCharacter().Face);
                    packet.Write((Int16)0);

                    foreach (var item in c.GetCharacter().EquippedItems)
                    {
                        packet.Write(item.ItemId);
                    }

                    packet.Write(c.GetCharacter().Rank);//rank
                    packet.Write(c.GetCharacter().Kills);//kill
                    packet.Write(c.GetCharacter().Deaths);//death
                    packet.Write(c.GetCharacter().DuelRank);//duel
                }

                client.Send(packet);
            }
        }
Пример #22
0
        public static void SpawnWorldItem(Client client, ItemSpawn item)
        {
            using (var packet = new PacketWriter(Operation.MatchWorldItemSpawn, CryptFlags.Encrypt))
            {
                packet.Write(1, 12);
                packet.Write((UInt16)item.ItemUid);
                packet.Write((UInt16)item.ItemId);
                packet.Write((UInt16)1);
                packet.Write((UInt16)item.Position.X);
                packet.Write((UInt16)item.Position.Y);
                packet.Write((UInt16)item.Position.Z);

                client.Send(packet);
            }
        }
Пример #23
0
        public static void ResponseStageJoin(Client client, Results result)
        {
            using (var packet = new PacketWriter(Operation.StageJoin, CryptFlags.Encrypt))
            {
                packet.Write(client.GetMuid());
                packet.Write(client.GetStage().GetTraits().StageId);
                packet.Write(client.GetStage().GetTraits().StageIndex);
                packet.Write(client.GetStage().GetTraits().Name);

                client.Send(packet);
            }
        }
Пример #24
0
 public static void UnbindPeer(Client client, Muid playerId)
 {
     using (var packet = new PacketWriter(Operation.AgentPeerUnbind, CryptFlags.Encrypt))
     {
         packet.Write(playerId);
         client.Send(packet);
     }
 }
Пример #25
0
        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);
            }
        }
Пример #26
0
        public static void ResponseLateJoin(Client client)
        {
            using (var packet = new PacketWriter(Operation.StageResponseForcedEntry, CryptFlags.Encrypt))
            {
                packet.Write(0);

                client.Send(packet);
            }
        }
Пример #27
0
        public static void ResponsePeerList(Client client, List<Client> clients)
        {
            using (var packet = new PacketWriter(Operation.StageResponsePeerList, CryptFlags.Encrypt))
            {
                packet.Write(client.GetStage().GetTraits().StageId);

                packet.Write(clients.Count, 394);
                foreach (var c in clients)
                {
                    packet.Write(c.GetMuid());

                    if (c.PeerEnd == null)
                    {
                        packet.Write(new byte[4], 0, 4);
                        packet.Write(0);
                    }
                    else
                    {
                        packet.Write(c.PeerEnd.Address.GetAddressBytes(), 0, 4);
                        packet.Write(c.PeerEnd.Port);
                    }

                    packet.Write(c.GetCharacter().Name, 32);
                    packet.Write(c.GetCharacter().ClanName, 16);
                    packet.Write((Int32)c.GetCharacter().ClanGrade);//clan rank
                    packet.Write(c.GetCharacter().ClanPoint);//clan points
                    packet.Write((byte)0);//?
                    packet.Write(c.GetCharacter().Level);
                    packet.Write(c.GetCharacter().Sex);
                    packet.Write(c.GetCharacter().Hair);
                    packet.Write(c.GetCharacter().Face);
                    packet.Write(c.GetCharacter().Xp);
                    packet.Write(c.GetCharacter().Bp);
                    packet.Write(c.GetCharacter().BonusRate);
                    packet.Write(c.GetCharacter().Prize);
                    packet.Write(c.GetCharacter().Hp);
                    packet.Write(c.GetCharacter().Ap);
                    packet.Write(c.GetCharacter().MaxWeight);
                    packet.Write(c.GetCharacter().SafeFalls);
                    packet.Write(c.GetCharacter().Fr);
                    packet.Write(c.GetCharacter().Cr);
                    packet.Write(c.GetCharacter().Er);
                    packet.Write(c.GetCharacter().Wr);
                    foreach (var nItem in c.GetCharacter().EquippedItems)
                        packet.Write(nItem.ItemId);

                    packet.Write((Int32)c.ClientPlayer.PlayerAccount.Access);
                    packet.Write(c.GetCharacter().ClanId);
                    packet.Write(c.GetCharacter().DuelRank); // duel tourney

                    byte[] obfuscation = new byte[] { 0x00, 0x00, 0x00, 0x00, 0x79, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7B, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6E, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6D, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4B, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x72, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4C, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7F, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4A, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x4C, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
                    packet.Write(obfuscation);
                    packet.Write((byte)c.ClientPlayer.PlayerTeam);
                    packet.Write((byte)0);
                    packet.Write((Int16)0);
                }

                client.Send(packet);
            }
        }
Пример #28
0
        public static void ResponseStageList(Client client, byte previous, byte next, List<Stage> stages)
        {
            using (var packet = new PacketWriter(Operation.StageList, CryptFlags.Encrypt))
            {
                packet.Write(previous);
                packet.Write(next);

                packet.Write(stages.Count, 90);

                var traits = from stage in stages
                             select stage.GetTraits();

                var index = client.ClientPlayer.StageIndex;

                foreach (var info in traits)
                {
                    packet.Write(info.StageId);
                    packet.Write(++index);
                    packet.Write(info.Name, 64);
                    packet.Write(Convert.ToByte(info.Players.Count));
                    packet.Write(info.MaxPlayers);
                    packet.Write((Int32)info.State);
                    packet.Write((Int32)info.Gametype);

                    switch (info.Map)
                    {
                        case "Battle Arena":
                            packet.Write(Convert.ToByte(RelayMaps.BattleArena));
                            break;
                        case "Prison II":
                            packet.Write(Convert.ToByte(RelayMaps.PrisonII));
                            break;
                        case "Lost Shrine":
                            packet.Write(Convert.ToByte(RelayMaps.LostShrine));
                            break;
                        case "Shower Room":
                            packet.Write(Convert.ToByte(RelayMaps.Shower_Room));
                            break;
                        case "RelayMap":
                            packet.Write(Convert.ToByte(RelayMaps.RelayMap));
                            break;
                        default:
                            packet.Write(Convert.ToByte(Enum.Parse(typeof(RelayMaps), info.Map)));
                            break;
                    }

                    if (!info.ForcedEntry)
                        packet.Write((Int32)StageType.Regular);
                    else if (info.Password.Length > 0)
                        packet.Write((Int32)StageType.Locked);
                    else if (info.Locked)
                        packet.Write((Int32)StageType.LevelRestricted);
                    else
                        packet.Write((Int32)StageType.None);

                    packet.Write(Convert.ToByte(info.Master.GetCharacter().Level));
                    packet.Write(info.Level);
                }

                client.Send(packet);
            }
        }
Пример #29
0
        public static void StageRoundUpdate(Client client, Muid stageId, Int32 curRound, RoundState roundState, Int32 winner = 0)
        {
            using (var packet = new PacketWriter(Operation.StageRoundState, CryptFlags.Encrypt))
            {
                packet.Write(stageId);
                packet.Write(curRound);
                packet.Write((Int32)roundState);
                packet.Write(winner);

                client.Send(packet);
            }
        }
Пример #30
0
        public static void ResponseCharList(Client client, List<Pair<string, byte>> characters)
        {
            using (var packet = new PacketWriter(Operation.MatchResponseAccountCharList, CryptFlags.Encrypt))
            {
                packet.Write(characters.Count, 34);

                for (byte a = 0; a < characters.Count; a++)
                {
                    packet.Write(characters[a].First, 32);
                    packet.Write(a);
                    packet.Write(characters[a].Second);
                }

                client.Send(packet);
            }
        }