public static void Initialize()
        {
            EventSink.ClientVersionReceived += EventSink_ClientVersionReceived;

            Required = new ClientVersion("5.0.0");
            Recommended = new ClientVersion("7.0.34.6");

            if (m_DetectClientRequirement)
            {
                string path = Core.FindDataFile("client.exe");

                if (File.Exists(path))
                {
                    FileVersionInfo info = FileVersionInfo.GetVersionInfo(path);

                    if (info.FileMajorPart != 0 || info.FileMinorPart != 0 || info.FileBuildPart != 0 ||
                        info.FilePrivatePart != 0)
                    {
                        Required = new ClientVersion(info.FileMajorPart, info.FileMinorPart, info.FileBuildPart,
                            info.FilePrivatePart);
                    }
                }
            }

            if (Required != null)
            {
                Utility.PushColor(ConsoleColor.White);
                Console.WriteLine("Client Restriction: Required client {0}. Action taken: {1}", Required,
                    m_OldClientResponse);
                Console.WriteLine("Client Restriction: Recommended client {0}.", Recommended);
                Utility.PopColor();
            }
        }
示例#2
0
        public RuntimePatcher(ClientVersion clientVersion, Stream stream, bool leaveOpen = false)
        {
            if (clientVersion == null)
                throw new ArgumentNullException("clientVersion");

            if (stream == null)
                throw new ArgumentNullException("stream");

            this.clientVersion = clientVersion;
            this.stream = stream;
            this.writer = new BinaryWriter(stream, Encoding.UTF8, leaveOpen);
        }
示例#3
0
        public static void HandleCharEnum(Packet packet)
        {
            var count = packet.ReadByte("Count");

            for (var i = 0; i < count; i++)
            {
                var guid = packet.ReadGuid("GUID");
                var name = packet.ReadCString("Name");
                var race = packet.ReadEnum <Race>("Race", TypeCode.Byte);
                var clss = packet.ReadEnum <Class>("Class", TypeCode.Byte);
                packet.ReadEnum <Gender>("Gender", TypeCode.Byte);

                packet.ReadByte("Skin");
                packet.ReadByte("Face");
                packet.ReadByte("Hair Style");
                packet.ReadByte("Hair Color");
                packet.ReadByte("Facial Hair");

                var level = packet.ReadByte("Level");
                var zone  = packet.ReadEntryWithName <UInt32>(StoreNameType.Zone, "Zone Id");
                var mapId = packet.ReadEntryWithName <Int32>(StoreNameType.Map, "Map Id");

                var pos = packet.ReadVector3("Position");
                packet.ReadInt32("Guild Id");
                packet.ReadEnum <CharacterFlag>("Character Flags", TypeCode.Int32);

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
                {
                    packet.ReadEnum <CustomizationFlag>("Customization Flags", TypeCode.Int32);
                }

                var firstLogin = packet.ReadBoolean("First Login");
                packet.ReadInt32("Pet Display Id");
                packet.ReadInt32("Pet Level");
                packet.ReadEnum <CreatureFamily>("Pet Family", TypeCode.Int32);

                for (var j = 0; j < 19; j++)
                {
                    packet.ReadInt32("Equip Display Id");
                    packet.ReadEnum <InventoryType>("Equip Inventory Type", TypeCode.Byte);
                    packet.ReadInt32("Equip Aura Id");
                }

                int bagCount = ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_3_11685) ? 4 : 1;
                for (var j = 0; j < bagCount; j++)
                {
                    packet.ReadInt32("Bag Display Id");
                    packet.ReadEnum <InventoryType>("Bag Inventory Type", TypeCode.Byte);
                    packet.ReadInt32("Bag Aura Id");
                }

                if (firstLogin)
                {
                    var startPos = new StartPosition {
                        Map = mapId, Position = pos, Zone = zone
                    };
                    Storage.StartPositions.TryAdd(new Tuple <Race, Class>(race, clss), startPos);
                }

                var playerInfo = new Player {
                    Race = race, Class = clss, Name = name, FirstLogin = firstLogin, Level = level
                };
                Storage.Objects.AddOrUpdate(guid, playerInfo);
            }
        }
示例#4
0
        public static void HandleQuestQueryResponse(Packet packet)
        {
            var id = packet.ReadEntry("Quest ID");

            if (id.Value) // entry is masked
            {
                return;
            }

            var quest = new QuestTemplate
            {
                Method = packet.ReadEnum <QuestMethod>("Method", TypeCode.Int32),
                Level  = packet.ReadInt32("Level")
            };

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
            {
                quest.MinLevel = packet.ReadInt32("Min Level");
            }

            quest.ZoneOrSort = packet.ReadEnum <QuestSort>("Sort", TypeCode.Int32);

            quest.Type = packet.ReadEnum <QuestType>("Type", TypeCode.Int32);

            quest.SuggestedPlayers = packet.ReadUInt32("Suggested Players");

            quest.RequiredFactionId    = new uint[2];
            quest.RequiredFactionValue = new int[2];
            for (var i = 0; i < 2; i++)
            {
                quest.RequiredFactionId[i]    = packet.ReadUInt32("Required Faction ID", i);
                quest.RequiredFactionValue[i] = packet.ReadInt32("Required Faction Rep", i);
            }

            quest.NextQuestIdChain = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Quest, "Next Chain Quest");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
            {
                quest.RewardXPId = packet.ReadUInt32("Quest XP ID");
            }

            quest.RewardOrRequiredMoney = packet.ReadInt32("Reward/Required Money");

            quest.RewardMoneyMaxLevel = packet.ReadUInt32("Reward Money Max Level");

            quest.RewardSpell = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Reward Spell");

            quest.RewardSpellCast = packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Reward Spell Cast");

            quest.RewardHonor = packet.ReadInt32("Reward Honor");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
            {
                quest.RewardHonorMultiplier = packet.ReadSingle("Reward Honor Multiplier");
            }

            quest.SourceItemId = (uint)packet.ReadEntryWithName <UInt32>(StoreNameType.Item, "Source Item ID");

            quest.Flags = packet.ReadEnum <QuestFlags>("Flags", TypeCode.Int32);

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                quest.MinimapTargetMark = packet.ReadUInt32("Minimap Target Mark"); // missing enum. 1- Skull, 16 - Unknown, but exist
            }
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V2_4_0_8089))
            {
                quest.RewardTitleId = packet.ReadUInt32("Reward Title ID");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
            {
                quest.RequiredPlayerKills = packet.ReadUInt32("Required Player Kills");
                quest.RewardTalents       = packet.ReadUInt32("Bonus Talents");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
            {
                quest.RewardArenaPoints = packet.ReadUInt32("Bonus Arena Points");
            }

            // TODO: Find when was this added/removed and what is it
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958) && (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_1_13164)))
            {
                packet.ReadInt32("Unknown Int32");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                quest.RewardSkillId        = packet.ReadUInt32("RewSkillId");
                quest.RewardSkillPoints    = packet.ReadUInt32("RewSkillPoints");
                quest.RewardReputationMask = packet.ReadUInt32("RewRepMask");
                quest.QuestGiverPortrait   = packet.ReadUInt32("QuestGiverPortrait");
                quest.QuestTurnInPortrait  = packet.ReadUInt32("QuestTurnInPortrait");
            }

            quest.RewardItemId    = new uint[4];
            quest.RewardItemCount = new uint[4];
            for (var i = 0; i < 4; i++)
            {
                quest.RewardItemId[i]    = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Reward Item ID", i);
                quest.RewardItemCount[i] = packet.ReadUInt32("Reward Item Count", i);
            }

            quest.RewardChoiceItemId    = new uint[6];
            quest.RewardChoiceItemCount = new uint[6];
            for (var i = 0; i < 6; i++)
            {
                quest.RewardChoiceItemId[i]    = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Reward Choice Item ID", i);
                quest.RewardChoiceItemCount[i] = packet.ReadUInt32("Reward Choice Item Count", i);
            }

            const int repCount = 5;

            quest.RewardFactionId              = new uint[repCount];
            quest.RewardFactionValueId         = new int[repCount];
            quest.RewardFactionValueIdOverride = new uint[repCount];
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
            {
                for (var i = 0; i < repCount; i++)
                {
                    quest.RewardFactionId[i] = packet.ReadUInt32("Reward Faction ID", i);
                }

                for (var i = 0; i < repCount; i++)
                {
                    quest.RewardFactionValueId[i] = packet.ReadInt32("Reward Reputation ID", i);
                }

                for (var i = 0; i < repCount; i++)
                {
                    quest.RewardFactionValueIdOverride[i] = packet.ReadUInt32("Reward Reputation ID Override", i);
                }
            }

            quest.PointMapId = packet.ReadUInt32("Point Map ID");

            quest.PointX = packet.ReadSingle("Point X");

            quest.PointY = packet.ReadSingle("Point Y");

            quest.PointOption = packet.ReadUInt32("Point Opt");

            quest.Title = packet.ReadCString("Title");

            quest.Objectives = packet.ReadCString("Objectives");

            quest.Details = packet.ReadCString("Details");

            quest.EndText = packet.ReadCString("End Text");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
            {
                quest.CompletedText = packet.ReadCString("Return Text");
            }

            var reqId = new KeyValuePair <int, bool> [4];

            quest.RequiredNpcOrGo         = new int[4];
            quest.RequiredNpcOrGoCount    = new uint[4];
            quest.RequiredSourceItemId    = new uint[4];
            quest.RequiredSourceItemCount = new uint[4];
            var reqItemFieldCount = ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_8_9464) ? 6 : 4;

            quest.RequiredItemId    = new uint[reqItemFieldCount];
            quest.RequiredItemCount = new uint[reqItemFieldCount];

            for (var i = 0; i < 4; i++)
            {
                reqId[i] = packet.ReadEntry();
                quest.RequiredNpcOrGo[i] = reqId[i].Key;
                var isGo = reqId[i].Value;

                packet.WriteLine("[" + i + "] Required " + (isGo ? "GO" : "NPC") +
                                 " ID: " + StoreGetters.GetName(isGo ? StoreNameType.GameObject : StoreNameType.Unit, reqId[i].Key));

                quest.RequiredNpcOrGoCount[i] = packet.ReadUInt32("Required Count", i);

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
                {
                    quest.RequiredSourceItemId[i] = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Required Source Item ID", i);
                }

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
                {
                    quest.RequiredSourceItemCount[i] = packet.ReadUInt32("Source Item Count", i);
                }

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V3_0_8_9464))
                {
                    quest.RequiredItemId[i]    = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Required Item ID", i);
                    quest.RequiredItemCount[i] = packet.ReadUInt32("Required Item Count", i);
                }
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_8_9464))
            {
                for (var i = 0; i < reqItemFieldCount; i++)
                {
                    quest.RequiredItemId[i]    = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Item, "Required Item ID", i);
                    quest.RequiredItemCount[i] = packet.ReadUInt32("Required Item Count", i);
                }
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                quest.RequiredSpell = (uint)packet.ReadEntryWithName <UInt32>(StoreNameType.Spell, "Required Spell");
            }

            quest.ObjectiveText = new string[4];
            for (var i = 0; i < 4; i++)
            {
                quest.ObjectiveText[i] = packet.ReadCString("Objective Text", i);
            }

            quest.RewardCurrencyId      = new uint[4];
            quest.RewardCurrencyCount   = new uint[4];
            quest.RequiredCurrencyId    = new uint[4];
            quest.RequiredCurrencyCount = new uint[4];
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                for (var i = 0; i < 4; ++i)
                {
                    quest.RewardCurrencyId[i]    = packet.ReadUInt32("Reward Currency ID", i);
                    quest.RewardCurrencyCount[i] = packet.ReadUInt32("Reward Currency Count", i);
                }

                for (var i = 0; i < 4; ++i)
                {
                    quest.RequiredCurrencyId[i]    = packet.ReadUInt32("Required Currency ID", i);
                    quest.RequiredCurrencyCount[i] = packet.ReadUInt32("Required Currency Count", i);
                }

                quest.QuestGiverTextWindow = packet.ReadCString("QuestGiver Text Window");
                quest.QuestGiverTargetName = packet.ReadCString("QuestGiver Target Name");
                quest.QuestTurnTextWindow  = packet.ReadCString("QuestTurn Text Window");
                quest.QuestTurnTargetName  = packet.ReadCString("QuestTurn Target Name");

                quest.SoundAccept = packet.ReadUInt32("Sound Accept");
                quest.SoundTurnIn = packet.ReadUInt32("Sound TurnIn");
            }

            packet.AddSniffData(StoreNameType.Quest, id.Key, "QUERY_RESPONSE");

            Storage.QuestTemplates.Add((uint)id.Key, quest, packet.TimeSpan);
        }
示例#5
0
        private static void Main(string[] args)
        {
            SetUpConsole();

            var files = args.ToList();

            if (files.Count == 0)
            {
                PrintUsage();
                return;
            }

            // config options are handled in Misc.Settings
            Utilities.RemoveConfigOptions(ref files);

            if (!Utilities.GetFiles(ref files))
            {
                EndPrompt();
                return;
            }

            Thread.CurrentThread.CurrentCulture     = CultureInfo.InvariantCulture;
            CultureInfo.DefaultThreadCurrentCulture = CultureInfo.InvariantCulture;

            if (Settings.UseDBC)
            {
                var startTime = DateTime.Now;

                DBC.DBC.Load();

                var span = DateTime.Now.Subtract(startTime);
                Trace.WriteLine($"DBC loaded in { span.ToFormattedString() }.");
            }

            // Disable DB when we don't need its data (dumping to a binary file)
            if (!Settings.DumpFormatWithSQL())
            {
                SQLConnector.Enabled = false;
                SSHTunnel.Enabled    = false;
            }
            else
            {
                Filters.Initialize();
            }

            SQLConnector.ReadDB();

            var count = 0;

            foreach (var file in files)
            {
                SessionHandler.ZStreams.Clear();
                if (Settings.ClientBuild != Enums.ClientVersionBuild.Zero)
                {
                    ClientVersion.SetVersion(Settings.ClientBuild);
                }

                try
                {
                    var sf = new SniffFile(file, Settings.DumpFormat, Tuple.Create(++count, files.Count));
                    sf.ProcessFile();
                }
                catch (IOException ex)
                {
                    Console.WriteLine($"Can't process {file}. Skipping. Message: {ex.Message}");
                }
            }

            if (!string.IsNullOrWhiteSpace(Settings.SQLFileName) && Settings.DumpFormatWithSQL())
            {
                Builder.DumpSQL("Dumping global sql", Settings.SQLFileName, SniffFile.GetHeader("multi"));
            }

            SQLConnector.Disconnect();
            SSHTunnel.Disconnect();

            if (Settings.LogErrors)
            {
                Logger.WriteErrors();
            }

            Trace.Listeners.Remove("ConsoleMirror");

            EndPrompt();
        }
示例#6
0
        public static void HandleNpcGossip(Packet packet)
        {
            var gossip = new Gossip();

            var guid = packet.ReadGuid("GUID");

            gossip.ObjectType  = guid.GetObjectType();
            gossip.ObjectEntry = guid.GetEntry();

            var menuId = packet.ReadUInt32("Menu Id");

            if (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria))
            {
                packet.ReadUInt32("Friendship Faction");
            }

            var textId = packet.ReadUInt32("Text Id");

            if (guid.GetObjectType() == ObjectType.Unit)
            {
                if (Storage.Objects.ContainsKey(guid))
                {
                    ((Unit)Storage.Objects[guid].Item1).GossipId = menuId;
                }
            }

            var count = packet.ReadUInt32("Amount of Options");

            gossip.GossipOptions = new List <GossipOption>((int)count);
            for (var i = 0; i < count; i++)
            {
                var gossipOption = new GossipOption
                {
                    Index         = packet.ReadUInt32("Index", i),
                    OptionIcon    = packet.ReadEnum <GossipOptionIcon>("Icon", TypeCode.Byte, i),
                    Box           = packet.ReadBoolean("Box", i),
                    RequiredMoney = packet.ReadUInt32("Required money", i),
                    OptionText    = packet.ReadCString("Text", i),
                    BoxText       = packet.ReadCString("Box Text", i)
                };

                gossip.GossipOptions.Add(gossipOption);
            }

            if (Storage.Gossips.ContainsKey(Tuple.Create(menuId, textId)))
            {
                var oldGossipOptions = Storage.Gossips[Tuple.Create(menuId, textId)];
                if (oldGossipOptions != null)
                {
                    foreach (var gossipOptions in gossip.GossipOptions)
                    {
                        oldGossipOptions.Item1.GossipOptions.Add(gossipOptions);
                    }
                }
            }
            else
            {
                Storage.Gossips.Add(Tuple.Create(menuId, textId), gossip, packet.TimeSpan);
            }

            packet.AddSniffData(StoreNameType.Gossip, (int)menuId, guid.GetEntry().ToString(CultureInfo.InvariantCulture));

            var questgossips = packet.ReadUInt32("Amount of Quest gossips");

            for (var i = 0; i < questgossips; i++)
            {
                packet.ReadEntryWithName <UInt32>(StoreNameType.Quest, "Quest ID", i);

                packet.ReadUInt32("Icon", i);
                packet.ReadInt32("Level", i);
                packet.ReadEnum <QuestFlags>("Flags", TypeCode.UInt32, i);
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
                {
                    packet.ReadEnum <QuestFlags2>("Flags 2", TypeCode.UInt32, i);
                }

                packet.ReadBoolean("Change Icon", i);
                packet.ReadCString("Title", i);
            }
        }
示例#7
0
        public static string CreatureTemplateNonWDB(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_template))
            {
                return(string.Empty);
            }

            var levels = GetLevels(units);

            foreach (var unit in units)
            {
                if (Storage.CreatureTemplatesNonWDB.Any(creature => creature.Item1.Entry == unit.Key.GetEntry()))
                {
                    continue;
                }

                var npc = unit.Value;
                int minLevel, maxLevel;

                if (npc.ScalingMinLevel != null && npc.ScalingMaxLevel != null)
                {
                    minLevel = (int)npc.ScalingMinLevel;
                    maxLevel = (int)npc.ScalingMaxLevel;
                }
                else
                {
                    minLevel = (int)levels[unit.Key.GetEntry()].Item1;
                    maxLevel = (int)levels[unit.Key.GetEntry()].Item2;
                }

                var template = new CreatureTemplateNonWDB
                {
                    Entry            = unit.Key.GetEntry(),
                    GossipMenuId     = npc.GossipId,
                    MinLevel         = minLevel,
                    MaxLevel         = maxLevel,
                    Faction          = npc.Faction.GetValueOrDefault(35),
                    NpcFlag          = npc.NpcFlags.GetValueOrDefault(NPCFlags.None),
                    SpeedRun         = npc.Movement.RunSpeed,
                    SpeedWalk        = npc.Movement.WalkSpeed,
                    BaseAttackTime   = npc.MeleeTime.GetValueOrDefault(2000),
                    RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000),
                    UnitClass        = (uint)npc.Class.GetValueOrDefault(Class.Warrior),
                    UnitFlags        = npc.UnitFlags.GetValueOrDefault(UnitFlags.None),
                    UnitFlags2       = npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None),
                    UnitFlags3       = npc.UnitFlags3.GetValueOrDefault(UnitFlags3.None),
                    DynamicFlags     = npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None),
                    VehicleID        = npc.Movement.VehicleId,
                    HoverHeight      = npc.HoverHeight.GetValueOrDefault(1.0f)
                };

                if (Settings.UseDBC)
                {
                    var creatureDiff = DBC.DBC.CreatureDifficulty.Where(diff => diff.Value.CreatureID == unit.Key.GetEntry());
                    if (creatureDiff.Any())
                    {
                        template.MinLevel = creatureDiff.Select(lv => lv.Value.MinLevel).First();
                        template.MaxLevel = creatureDiff.Select(lv => lv.Value.MaxLevel).First();
                        template.Faction  = creatureDiff.Select(lv => lv.Value.FactionTemplateID).First();
                    }
                }

                if (template.Faction == 1 || template.Faction == 2 || template.Faction == 3 ||
                    template.Faction == 4 || template.Faction == 5 || template.Faction == 6 ||
                    template.Faction == 115 || template.Faction == 116 || template.Faction == 1610 ||
                    template.Faction == 1629 || template.Faction == 2203 || template.Faction == 2204) // player factions
                {
                    template.Faction = 35;
                }

                template.UnitFlags &= ~UnitFlags.IsInCombat;
                template.UnitFlags &= ~UnitFlags.PetIsAttackingTarget;
                template.UnitFlags &= ~UnitFlags.PlayerControlled;
                template.UnitFlags &= ~UnitFlags.Silenced;
                template.UnitFlags &= ~UnitFlags.PossessedByPlayer;

                if (!ClientVersion.AddedInVersion(ClientType.WarlordsOfDraenor))
                {
                    template.DynamicFlags &= ~UnitDynamicFlags.Lootable;
                    template.DynamicFlags &= ~UnitDynamicFlags.Tapped;
                    template.DynamicFlags &= ~UnitDynamicFlags.TappedByPlayer;
                    template.DynamicFlags &= ~UnitDynamicFlags.TappedByAllThreatList;
                }
                else
                {
                    template.DynamicFlagsWod &= ~UnitDynamicFlagsWOD.Lootable;
                    template.DynamicFlagsWod &= ~UnitDynamicFlagsWOD.Tapped;
                    template.DynamicFlagsWod &= ~UnitDynamicFlagsWOD.TappedByPlayer;
                    template.DynamicFlagsWod &= ~UnitDynamicFlagsWOD.TappedByAllThreatList;
                }

                // has trainer flag but doesn't have prof nor class trainer flag
                if ((template.NpcFlag & NPCFlags.Trainer) != 0 &&
                    ((template.NpcFlag & NPCFlags.ProfessionTrainer) == 0 ||
                     (template.NpcFlag & NPCFlags.ClassTrainer) == 0))
                {
                    var subname = GetSubName((int)unit.Key.GetEntry(), false); // Fall back
                    var entry   = Storage.CreatureTemplates.Where(creature => creature.Item1.Entry == unit.Key.GetEntry());
                    if (entry.Any())
                    {
                        var sub = entry.Select(creature => creature.Item1.SubName).First();
                        if (sub.Length > 0)
                        {
                            template.NpcFlag |= ProcessNpcFlags(sub);
                            Trace.WriteLine($"Entry: { unit.Key.GetEntry() } NpcFlag: { template.NpcFlag }");
                        }
                        else // If the SubName doesn't exist or is cached, fall back to DB method
                        {
                            template.NpcFlag |= ProcessNpcFlags(subname);
                        }
                    }
                    else // In case we have NonWDB data which doesn't have an entry in CreatureTemplates
                    {
                        template.NpcFlag |= ProcessNpcFlags(subname);
                    }
                }

                Storage.CreatureTemplatesNonWDB.Add(template);
            }

            var templatesDb = SQLDatabase.Get(Storage.CreatureTemplatesNonWDB);

            return(SQLUtil.Compare(Storage.CreatureTemplatesNonWDB, templatesDb, StoreNameType.Unit));
        }
示例#8
0
        private static void EventSink_ClientVersionReceived(ClientVersionReceivedArgs e)
        {
            string        kickMessage = null;
            NetState      state       = e.State;
            ClientVersion version     = e.Version;

            if (state.Mobile.AccessLevel > AccessLevel.Player)
            {
                return;
            }

            if (Required != null && version < Required && (m_OldClientResponse == OldClientResponse.Kick || (m_OldClientResponse == OldClientResponse.LenientKick && (DateTime.Now - state.Mobile.CreationTime) > m_AgeLeniency && state.Mobile is PlayerMobile && ((PlayerMobile)state.Mobile).GameTime > m_GameTimeLeniency)))
            {
                kickMessage = String.Format("This server requires your client version be at least {0}.", Required);
            }
            else if (!AllowGod || !AllowRegular || !AllowUOTD)
            {
                if (!AllowGod && version.Type == ClientType.God)
                {
                    kickMessage = "This server does not allow god clients to connect.";
                }
                else if (!AllowRegular && version.Type == ClientType.Regular)
                {
                    kickMessage = "This server does not allow regular clients to connect.";
                }
                else if (!AllowUOTD && state.IsUOTDClient)
                {
                    kickMessage = "This server does not allow UO:TD clients to connect.";
                }

                if (!AllowGod && !AllowRegular && !AllowUOTD)
                {
                    kickMessage = "This server does not allow any clients to connect.";
                }
                else if (AllowGod && !AllowRegular && !AllowUOTD && version.Type != ClientType.God)
                {
                    kickMessage = "This server requires you to use the god client.";
                }
                else if (kickMessage != null)
                {
                    if (AllowRegular && AllowUOTD)
                    {
                        kickMessage += " You can use regular or UO:TD clients.";
                    }
                    else if (AllowRegular)
                    {
                        kickMessage += " You can use regular clients.";
                    }
                    else if (AllowUOTD)
                    {
                        kickMessage += " You can use UO:TD clients.";
                    }
                }
            }

            if (kickMessage != null)
            {
                state.Mobile.SendMessage(0x22, kickMessage);
                state.Mobile.SendMessage(0x22, "You will be disconnected in {0} seconds.", KickDelay.TotalSeconds);

                Timer.DelayCall(KickDelay, delegate
                {
                    if (state.Socket != null)
                    {
                        Console.WriteLine("Client: {0}: Disconnecting, bad version", state);
                        state.Dispose();
                    }
                });
            }
            else if (Required != null && version < Required)
            {
                switch (m_OldClientResponse)
                {
                case OldClientResponse.Warn:
                {
                    state.Mobile.SendMessage(0x22, "Your client is out of date. Please update your client.", Required);
                    state.Mobile.SendMessage(0x22, "This server reccomends that your client version be at least {0}.", Required);
                    break;
                }

                case OldClientResponse.LenientKick:
                case OldClientResponse.Annoy:
                {
                    SendAnnoyGump(state.Mobile);
                    break;
                }
                }
            }
        }
示例#9
0
        static void PatchClient(UserSettings settings, SuspendedProcess process, ClientVersion clientVersion, IPAddress serverIPAddress, int serverPort)
        {
            if (settings.ShouldRedirectClient && serverIPAddress == null)
                throw new ArgumentNullException("serverIPAddress", "Server IP address must be specified when redirecting the client");

            if (settings.ShouldRedirectClient && serverPort <= 0)
                throw new ArgumentOutOfRangeException("Server port number must be greater than zero when redirecting the client");

            using (var stream = new ProcessMemoryStream(process.ProcessId))
            using (var patcher = new RuntimePatcher(clientVersion, stream, leaveOpen: true))
            {
                // Apply server hostname/port patch
                if (settings.ShouldRedirectClient && clientVersion.ServerHostnamePatchAddress > 0 && clientVersion.ServerPortPatchAddress > 0)
                {
                    Debug.WriteLine("Applying server redirect patch...");
                    patcher.ApplyServerHostnamePatch(serverIPAddress);
                    patcher.ApplyServerPortPatch(serverPort);
                }

                // Apply intro video patch
                if (settings.ShouldSkipIntro && clientVersion.IntroVideoPatchAddress > 0)
                {
                    Debug.WriteLine("Applying intro video patch...");
                    patcher.ApplySkipIntroVideoPatch();
                }

                // Apply multiple instances patch
                if (settings.ShouldAllowMultipleInstances && clientVersion.MultipleInstancePatchAddress > 0)
                {
                    Debug.WriteLine("Applying multiple instance patch...");
                    patcher.ApplyMultipleInstancesPatch();
                }

                // Apply hide walls patch
                if (settings.ShouldHideWalls && clientVersion.HideWallsPatchAddress > 0)
                {
                    Debug.WriteLine("Applying hide walls patch...");
                    patcher.ApplyHideWallsPatch();
                }
            }
        }
 public AuthIDPersistence(ClientVersion v)
 {
     Age     = DateTime.UtcNow;
     Version = v;
 }
示例#11
0
        public static void HandleGetGarrisonInfoResult(Packet packet)
        {
            packet.ReadInt32("FactionIndex");
            var garrisonCount = packet.ReadUInt32("GarrisonCount");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_2_5_24330))
            {
                var followerSoftcapCount = packet.ReadUInt32("FollowerSoftCapCount");
                for (var i = 0u; i < followerSoftcapCount; ++i)
                {
                    ReadFollowerSoftCapInfo(packet, i);
                }
            }

            for (int i = 0; i < garrisonCount; i++)
            {
                packet.ReadInt32E <GarrisonType>("GarrTypeID", i);
                packet.ReadInt32E <GarrisonSite>("GarrSiteID", i);
                packet.ReadInt32E <GarrisonSiteLevel>("GarrSiteLevelID", i);

                var garrisonBuildingInfoCount          = packet.ReadUInt32("GarrisonBuildingInfoCount", i);
                var garrisonPlotInfoCount              = packet.ReadUInt32("GarrisonPlotInfoCount", i);
                var garrisonFollowerCount              = packet.ReadUInt32("GarrisonFollowerCount", i);
                var garrisonMissionCount               = packet.ReadUInt32("GarrisonMissionCount", i);
                var garrisonMissionRewardsCount        = packet.ReadUInt32("GarrisonMissionRewardsCount", i);
                var garrisonMissionOvermaxRewardsCount = packet.ReadUInt32("GarrisonMissionOvermaxRewardsCount", i);
                var areaBonusCount        = packet.ReadUInt32("GarrisonMissionAreaBonusCount", i);
                var talentsCount          = packet.ReadUInt32("Talents", i);
                var canStartMissionCount  = packet.ReadUInt32("CanStartMission", i);
                var archivedMissionsCount = packet.ReadUInt32("ArchivedMissionsCount", i);

                packet.ReadInt32("NumFollowerActivationsRemaining", i);
                packet.ReadUInt32("NumMissionsStartedToday", i);
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_2_0_23826) && ClientVersion.RemovedInVersion(ClientVersionBuild.V7_2_5_24330))
                {
                    packet.ReadInt32("FollowerSoftCap", i);
                }

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V7_2_0_23826))
                {
                    for (int j = 0; j < garrisonBuildingInfoCount; j++)
                    {
                        ReadGarrisonBuildingInfo(packet, "BuildingInfo", i, j);
                    }
                }

                for (int j = 0; j < garrisonPlotInfoCount; j++)
                {
                    V6_0_2_19033.Parsers.GarrisonHandler.ReadGarrisonPlotInfo(packet, "PlotInfo", i, j);
                }

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V7_2_0_23826))
                {
                    for (int j = 0; j < garrisonFollowerCount; j++)
                    {
                        ReadGarrisonFollower(packet, "Follower", i, j);
                    }
                }

                for (int j = 0; j < garrisonMissionCount; j++)
                {
                    ReadGarrisonMission(packet, "Mission", i, j);
                }

                for (int j = 0; j < garrisonMissionRewardsCount; j++)
                {
                    ReadGarrisonMissionOvermaxRewards(packet, "MissionRewards", i, j);
                }

                for (int j = 0; j < garrisonMissionOvermaxRewardsCount; j++)
                {
                    ReadGarrisonMissionOvermaxRewards(packet, "MissionOvermaxRewards", i, j);
                }

                for (int j = 0; j < areaBonusCount; j++)
                {
                    V6_0_2_19033.Parsers.GarrisonHandler.ReadGarrisonMissionBonusAbility(packet, "MissionAreaBonus", i, j);
                }

                for (int j = 0; j < talentsCount; j++)
                {
                    ReadGarrisonTalents(packet, "Talents", i, j);
                }

                for (int j = 0; j < archivedMissionsCount; j++)
                {
                    packet.ReadInt32("ArchivedMissions", i, j);
                }

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_2_0_23826))
                {
                    for (int j = 0; j < garrisonBuildingInfoCount; j++)
                    {
                        ReadGarrisonBuildingInfo(packet, "BuildingInfo", i, j);
                    }
                }

                packet.ResetBitReader();

                for (int j = 0; j < canStartMissionCount; j++)
                {
                    packet.ReadBit("CanStartMission", i, j);
                }

                packet.ResetBitReader();

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_2_0_23826))
                {
                    for (int j = 0; j < garrisonFollowerCount; j++)
                    {
                        ReadGarrisonFollower(packet, "Follower", i, j);
                    }
                }
            }
        }
示例#12
0
        public static void HandleAuthResponse(Packet packet)
        {
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_4_21315))
            {
                packet.ReadUInt32E <BattlenetRpcErrorCode>("Result");
            }
            else
            {
                packet.ReadByteE <ResponseCode>("Auth Code");
            }

            var ok     = packet.ReadBit("Success");
            var queued = packet.ReadBit("Queued");

            if (ok)
            {
                packet.ReadUInt32("VirtualRealmAddress");
                var realms = packet.ReadUInt32();
                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V6_2_4_21315))
                {
                    packet.ReadUInt32("TimeRemaining");
                    packet.ReadUInt32("TimeOptions");
                }
                packet.ReadUInt32("TimeRested");
                packet.ReadByte("ActiveExpansionLevel");
                packet.ReadByte("AccountExpansionLevel");
                packet.ReadUInt32("TimeSecondsUntilPCKick");
                var races     = packet.ReadUInt32("AvailableRaces");
                var classes   = packet.ReadUInt32("AvailableClasses");
                var templates = packet.ReadUInt32("Templates");
                packet.ReadUInt32("AccountCurrency");

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_4_21315))
                {
                    packet.ResetBitReader();
                    packet.ReadUInt32("BillingPlan");
                    packet.ReadUInt32("TimeRemain");
                    packet.ReadBit("InGameRoom");
                    packet.ReadBit("InGameRoom");
                    packet.ReadBit("InGameRoom");
                }

                for (var i = 0; i < realms; ++i)
                {
                    packet.ReadUInt32("VirtualRealmAddress", i);
                    packet.ResetBitReader();
                    packet.ReadBit("IsLocal", i);
                    packet.ReadBit("unk", i);
                    var nameLen1 = packet.ReadBits(8);
                    var nameLen2 = packet.ReadBits(8);
                    packet.ReadWoWString("RealmNameActual", nameLen1, i);
                    packet.ReadWoWString("RealmNameNormalized", nameLen2, i);
                }

                for (var i = 0; i < races; ++i)
                {
                    packet.ReadByteE <Race>("Race", i);
                    packet.ReadByteE <ClientType>("RequiredExpansion", i);
                }

                for (var i = 0; i < classes; ++i)
                {
                    packet.ReadByteE <Class>("Class", i);
                    packet.ReadByteE <ClientType>("RequiredExpansion", i);
                }

                for (var i = 0; i < templates; ++i)
                {
                    packet.ReadUInt32("TemplateSetId", i);
                    var templateClasses = packet.ReadUInt32();
                    for (var j = 0; j < templateClasses; ++j)
                    {
                        packet.ReadByteE <Class>("Class", i, j);
                        packet.ReadByte("FactionGroup", i, j);
                    }

                    packet.ResetBitReader();
                    var nameLen = packet.ReadBits(7);
                    var descLen = packet.ReadBits(10);
                    packet.ReadWoWString("Name", nameLen, i);
                    packet.ReadWoWString("Description", descLen, i);
                }

                packet.ResetBitReader();
                packet.ReadBit("Trial");
                packet.ReadBit("ForceCharacterTemplate");
                var horde    = packet.ReadBit(); // NumPlayersHorde
                var alliance = packet.ReadBit(); // NumPlayersAlliance
                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V6_2_4_21315))
                {
                    packet.ReadBit("IsVeteranTrial");
                }

                if (horde)
                {
                    packet.ReadUInt16("NumPlayersHorde");
                }

                if (alliance)
                {
                    packet.ReadUInt16("NumPlayersAlliance");
                }
            }

            if (queued)
            {
                packet.ReadUInt32("QueuePos");
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_4_21315))
                {
                    packet.ReadUInt32("WaitTime");
                }
                packet.ResetBitReader();
                packet.ReadBit("HasFCM");
            }
        }
示例#13
0
			public AuthIDPersistence(ClientVersion v)
			{
				this.Age = DateTime.Now;
				this.Version = v;
			}
示例#14
0
        public ClientVersionViewModel(ClientVersion clientVersion)
            : base(null, null)
        {
            if (clientVersion == null)
                throw new ArgumentNullException("clientVersion");

            this.clientVersion = clientVersion;
        }
示例#15
0
        public static void HandleCreatureQueryResponse(Packet packet)
        {
            var entry = packet.ReadEntry("Entry");

            if (entry.Value)
            {
                return;
            }

            CreatureTemplate creature = new CreatureTemplate
            {
                Entry = (uint)entry.Key
            };

            var name = new string[4];

            for (int i = 0; i < name.Length; i++)
            {
                name[i] = packet.ReadCString("Name", i);
            }
            creature.Name = name[0];

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_1_0_13914))
            {
                var femaleName = new string[4];
                for (int i = 0; i < femaleName.Length; i++)
                {
                    femaleName[i] = packet.ReadCString("Female Name", i);
                }
                creature.FemaleName = femaleName[0];
            }

            creature.SubName = packet.ReadCString("Sub Name");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_0_5_16048))
            {
                creature.TitleAlt = packet.ReadCString("TitleAlt");
            }

            creature.IconName = packet.ReadCString("Icon Name");

            creature.TypeFlags = packet.ReadUInt32E <CreatureTypeFlag>("Type Flags");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_1_0_13914))    // Might be earlier or later
            {
                creature.TypeFlags2 = packet.ReadUInt32("Creature Type Flags 2"); // Missing enum
            }
            creature.Type = packet.ReadInt32E <CreatureType>("Type");

            creature.Family = packet.ReadInt32E <CreatureFamily>("Family");

            creature.Rank = packet.ReadInt32E <CreatureRank>("Rank");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                creature.KillCredits = new uint?[2];
                for (int i = 0; i < 2; ++i)
                {
                    creature.KillCredits[i] = packet.ReadUInt32("Kill Credit", i);
                }
            }
            else // Did they stop sending pet spell data after 3.1?
            {
                packet.ReadInt32("Unk Int");
                creature.PetSpellDataID = packet.ReadUInt32("Pet Spell Data Id");
            }

            creature.ModelIDs = new uint?[4];
            for (int i = 0; i < 4; i++)
            {
                creature.ModelIDs[i] = packet.ReadUInt32("Model ID", i);
            }

            creature.HealthModifier = packet.ReadSingle("Modifier 1");
            creature.ManaModifier   = packet.ReadSingle("Modifier 2");

            creature.RacialLeader = packet.ReadBool("Racial Leader");

            int qItemCount = ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_0_10192) ? 6 : 4;

            //TODO: Move to creature_questitem
            //creature.QuestItems = new uint[qItemCount];

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                for (int i = 0; i < qItemCount; i++)
                {
                    /*creature.QuestItems[i] = (uint)*/ packet.ReadInt32 <ItemId>("Quest Item", i);
                }

                creature.MovementID = packet.ReadUInt32("Movement ID");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                creature.RequiredExpansion = packet.ReadUInt32E <ClientType>("Expansion");
            }

            packet.AddSniffData(StoreNameType.Unit, entry.Key, "QUERY_RESPONSE");

            Storage.CreatureTemplates.Add(creature, packet.TimeSpan);

            if (BinaryPacketReader.GetLocale() != LocaleConstant.enUS)
            {
                CreatureTemplateLocale localesCreature = new CreatureTemplateLocale
                {
                    ID       = (uint)entry.Key,
                    Name     = creature.Name,
                    NameAlt  = creature.FemaleName,
                    Title    = creature.SubName,
                    TitleAlt = creature.TitleAlt
                };

                Storage.LocalesCreatures.Add(localesCreature, packet.TimeSpan);
            }

            ObjectName objectName = new ObjectName
            {
                ObjectType = ObjectType.Unit,
                ID         = entry.Key,
                Name       = creature.Name
            };

            Storage.ObjectNames.Add(objectName, packet.TimeSpan);
        }
示例#16
0
        private static MovementInfo ReadMovementUpdateBlock(Packet packet, WowGuid guid, object index)
        {
            var moveInfo = new MovementInfo();

            packet.ResetBitReader();

            packet.ReadBit("NoBirthAnim", index);
            packet.ReadBit("EnablePortals", index);
            packet.ReadBit("PlayHoverAnim", index);
            packet.ReadBit("IsSuppressingGreetings", index);

            var hasMovementUpdate     = packet.ReadBit("HasMovementUpdate", index);
            var hasMovementTransport  = packet.ReadBit("HasMovementTransport", index);
            var hasStationaryPosition = packet.ReadBit("Stationary", index);
            var hasCombatVictim       = packet.ReadBit("HasCombatVictim", index);
            var hasServerTime         = packet.ReadBit("HasServerTime", index);
            var hasVehicleCreate      = packet.ReadBit("HasVehicleCreate", index);
            var hasAnimKitCreate      = packet.ReadBit("HasAnimKitCreate", index);
            var hasRotation           = packet.ReadBit("HasRotation", index);
            var hasAreaTrigger        = packet.ReadBit("HasAreaTrigger", index);
            var hasGameObject         = packet.ReadBit("HasGameObject", index);

            packet.ReadBit("ThisIsYou", index);
            packet.ReadBit("ReplaceActive", index);

            var sceneObjCreate        = packet.ReadBit("SceneObjCreate", index);
            var scenePendingInstances = packet.ReadBit("ScenePendingInstances", index);

            var pauseTimesCount = packet.ReadUInt32("PauseTimesCount", index);

            if (hasMovementUpdate) // 392
            {
                moveInfo = ReadMovementStatusData(packet, index);

                moveInfo.WalkSpeed = packet.ReadSingle("WalkSpeed", index) / 2.5f;
                moveInfo.RunSpeed  = packet.ReadSingle("RunSpeed", index) / 7.0f;
                packet.ReadSingle("RunBackSpeed", index);
                packet.ReadSingle("SwimSpeed", index);
                packet.ReadSingle("SwimBackSpeed", index);
                packet.ReadSingle("FlightSpeed", index);
                packet.ReadSingle("FlightBackSpeed", index);
                packet.ReadSingle("TurnRate", index);
                packet.ReadSingle("PitchRate", index);

                var movementForceCount = packet.ReadInt32("MovementForceCount", index);

                for (var i = 0; i < movementForceCount; ++i)
                {
                    packet.ReadPackedGuid128("Id", index);
                    packet.ReadVector3("Direction", index);
                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_1_2_19802)) // correct?
                    {
                        packet.ReadVector3("TransportPosition", index);
                    }
                    packet.ReadInt32("TransportID", index);
                    packet.ReadSingle("Magnitude", index);
                    packet.ReadByte("Type", index);
                }

                packet.ResetBitReader();

                moveInfo.HasSplineData = packet.ReadBit("HasMovementSpline", index);

                if (moveInfo.HasSplineData)
                {
                    packet.ReadInt32("ID", index);
                    packet.ReadVector3("Destination", index);

                    packet.ResetBitReader();

                    var hasMovementSplineMove = packet.ReadBit("MovementSplineMove", index);
                    if (hasMovementSplineMove)
                    {
                        packet.ResetBitReader();

                        packet.ReadBitsE <SplineFlag434>("SplineFlags", ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173) ? 28 : 25, index);
                        var face = packet.ReadBits("Face", 2, index);

                        var hasJumpGravity = packet.ReadBit("HasJumpGravity", index);
                        var hasSpecialTime = packet.ReadBit("HasSpecialTime", index);

                        packet.ReadBitsE <SplineMode>("Mode", 2, index);

                        var hasSplineFilterKey = packet.ReadBit("HasSplineFilterKey", index);

                        packet.ReadUInt32("Elapsed", index);
                        packet.ReadUInt32("Duration", index);

                        packet.ReadSingle("DurationModifier", index);
                        packet.ReadSingle("NextDurationModifier", index);

                        var pointsCount = packet.ReadUInt32("PointsCount", index);

                        if (face == 3) // FaceDirection
                        {
                            packet.ReadSingle("FaceDirection", index);
                        }

                        if (face == 2) // FaceGUID
                        {
                            packet.ReadPackedGuid128("FaceGUID", index);
                        }

                        if (face == 1) // FaceSpot
                        {
                            packet.ReadVector3("FaceSpot", index);
                        }

                        if (hasJumpGravity)
                        {
                            packet.ReadSingle("JumpGravity", index);
                        }

                        if (hasSpecialTime)
                        {
                            packet.ReadInt32("SpecialTime", index);
                        }

                        if (hasSplineFilterKey)
                        {
                            var filterKeysCount = packet.ReadUInt32("FilterKeysCount", index);
                            for (var i = 0; i < filterKeysCount; ++i)
                            {
                                packet.ReadSingle("In", index, i);
                                packet.ReadSingle("Out", index, i);
                            }

                            if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173))
                            {
                                packet.ResetBitReader();
                            }

                            packet.ReadBits("FilterFlags", 2, index);
                        }

                        for (var i = 0; i < pointsCount; ++i)
                        {
                            packet.ReadVector3("Points", index, i);
                        }
                    }
                }
            }

            if (hasMovementTransport) // 456
            {
                moveInfo.TransportGuid   = packet.ReadPackedGuid128("TransportGUID", index);
                moveInfo.TransportOffset = packet.ReadVector4("TransportPosition", index);
                var seat = packet.ReadByte("VehicleSeatIndex", index);
                packet.ReadUInt32("MoveTime", index);

                packet.ResetBitReader();

                var hasPrevMoveTime = packet.ReadBit("HasPrevMoveTime", index);
                var hasVehicleRecID = packet.ReadBit("HasVehicleRecID", index);

                if (hasPrevMoveTime)
                {
                    packet.ReadUInt32("PrevMoveTime", index);
                }

                if (hasVehicleRecID)
                {
                    packet.ReadInt32("VehicleRecID", index);
                }

                if (moveInfo.TransportGuid.HasEntry() && moveInfo.TransportGuid.GetHighType() == HighGuidType.Vehicle &&
                    guid.HasEntry() && guid.GetHighType() == HighGuidType.Creature)
                {
                    VehicleTemplateAccessory vehicleAccessory = new VehicleTemplateAccessory
                    {
                        Entry          = moveInfo.TransportGuid.GetEntry(),
                        AccessoryEntry = guid.GetEntry(),
                        SeatId         = seat
                    };
                    Storage.VehicleTemplateAccessories.Add(vehicleAccessory, packet.TimeSpan);
                }
            }

            if (hasStationaryPosition) // 480
            {
                moveInfo.Position    = packet.ReadVector3();
                moveInfo.Orientation = packet.ReadSingle();

                packet.AddValue("Stationary Position", moveInfo.Position, index);
                packet.AddValue("Stationary Orientation", moveInfo.Orientation, index);
            }

            if (hasCombatVictim) // 504
            {
                packet.ReadPackedGuid128("CombatVictim Guid", index);
            }

            if (hasServerTime) // 516
            {
                packet.ReadUInt32("ServerTime", index);
            }

            if (hasVehicleCreate) // 528
            {
                moveInfo.VehicleId = packet.ReadUInt32("RecID", index);
                packet.ReadSingle("InitialRawFacing", index);
            }

            if (hasAnimKitCreate) // 538
            {
                packet.ReadUInt16("AiID", index);
                packet.ReadUInt16("MovementID", index);
                packet.ReadUInt16("MeleeID", index);
            }

            if (hasRotation) // 552
            {
                moveInfo.Rotation = packet.ReadPackedQuaternion("GameObject Rotation", index);
            }

            if (hasAreaTrigger) // 772
            {
                // CliAreaTrigger
                packet.ReadInt32("ElapsedMs", index);

                packet.ReadVector3("RollPitchYaw1", index);

                packet.ResetBitReader();

                packet.ReadBit("HasAbsoluteOrientation", index);
                packet.ReadBit("HasDynamicShape", index);
                packet.ReadBit("HasAttached", index);
                packet.ReadBit("HasFaceMovementDir", index);
                packet.ReadBit("HasFollowsTerrain", index);

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173))
                {
                    packet.ReadBit("Unk bit WoD62x", index);
                }

                var hasTargetRollPitchYaw  = packet.ReadBit("HasTargetRollPitchYaw", index);
                var hasScaleCurveID        = packet.ReadBit("HasScaleCurveID", index);
                var hasMorphCurveID        = packet.ReadBit("HasMorphCurveID", index);
                var hasFacingCurveID       = packet.ReadBit("HasFacingCurveID", index);
                var hasMoveCurveID         = packet.ReadBit("HasMoveCurveID", index);
                var hasAreaTriggerSphere   = packet.ReadBit("HasAreaTriggerSphere", index);
                var hasAreaTriggerBox      = packet.ReadBit("HasAreaTriggerBox", index);
                var hasAreaTriggerPolygon  = packet.ReadBit("HasAreaTriggerPolygon", index);
                var hasAreaTriggerCylinder = packet.ReadBit("HasAreaTriggerCylinder", index);
                var hasAreaTriggerSpline   = packet.ReadBit("HasAreaTriggerSpline", index);

                if (hasTargetRollPitchYaw)
                {
                    packet.ReadVector3("TargetRollPitchYaw", index);
                }

                if (hasScaleCurveID)
                {
                    packet.ReadInt32("ScaleCurveID, index");
                }

                if (hasMorphCurveID)
                {
                    packet.ReadInt32("MorphCurveID", index);
                }

                if (hasFacingCurveID)
                {
                    packet.ReadInt32("FacingCurveID", index);
                }

                if (hasMoveCurveID)
                {
                    packet.ReadInt32("MoveCurveID", index);
                }

                if (hasAreaTriggerSphere)
                {
                    packet.ReadSingle("Radius", index);
                    packet.ReadSingle("RadiusTarget", index);
                }

                if (hasAreaTriggerBox)
                {
                    packet.ReadVector3("Extents", index);
                    packet.ReadVector3("ExtentsTarget", index);
                }

                if (hasAreaTriggerPolygon)
                {
                    var verticesCount       = packet.ReadInt32("VerticesCount", index);
                    var verticesTargetCount = packet.ReadInt32("VerticesTargetCount", index);
                    packet.ReadSingle("Height", index);
                    packet.ReadSingle("HeightTarget", index);

                    for (var i = 0; i < verticesCount; ++i)
                    {
                        packet.ReadVector2("Vertices", index, i);
                    }

                    for (var i = 0; i < verticesTargetCount; ++i)
                    {
                        packet.ReadVector2("VerticesTarget", index, i);
                    }
                }

                if (hasAreaTriggerCylinder)
                {
                    packet.ReadSingle("Radius", index);
                    packet.ReadSingle("RadiusTarget", index);
                    packet.ReadSingle("Height", index);
                    packet.ReadSingle("HeightTarget", index);
                    packet.ReadSingle("Float4", index);
                    packet.ReadSingle("Float5", index);
                }

                if (hasAreaTriggerSpline)
                {
                    AreaTriggerHandler.ReadAreaTriggerSpline(packet, index);
                }
            }

            if (hasGameObject) // 788
            {
                packet.ReadInt32("WorldEffectID", index);

                packet.ResetBitReader();

                var bit8 = packet.ReadBit("bit8", index);
                if (bit8)
                {
                    packet.ReadInt32("Int1", index);
                }
            }

            if (sceneObjCreate) // 1184
            {
                packet.ResetBitReader();

                var hasSceneLocalScriptData = packet.ReadBit("HasSceneLocalScriptData", index);
                var petBattleFullUpdate     = packet.ReadBit("HasPetBattleFullUpdate", index);

                if (hasSceneLocalScriptData)
                {
                    packet.ResetBitReader();
                    var dataLength = packet.ReadBits(7);
                    packet.ReadWoWString("Data", dataLength, index);
                }

                if (petBattleFullUpdate)
                {
                    BattlePetHandler.ReadPetBattleFullUpdate(packet, index);
                }
            }

            if (scenePendingInstances) // 1208
            {
                var sceneInstanceIDs = packet.ReadInt32("SceneInstanceIDsCount");

                for (var i = 0; i < sceneInstanceIDs; ++i)
                {
                    packet.ReadInt32("SceneInstanceIDs", index, i);
                }
            }

            for (var i = 0; i < pauseTimesCount; ++i)
            {
                packet.ReadInt32("PauseTimes", index, i);
            }

            return(moveInfo);
        }
示例#17
0
        private static void ReadPeriodicAuraLog(Packet packet, object index = null)
        {
            packet.ReadPackedGuid("Target GUID", index);
            packet.ReadPackedGuid("Caster GUID", index);
            packet.ReadInt32 <SpellId>("Spell ID", index);
            var count = packet.ReadInt32("Count", index);

            for (var i = 0; i < count; i++)
            {
                var aura = packet.ReadUInt32E <AuraType>("Aura Type", index);
                switch (aura)
                {
                case AuraType.PeriodicDamage:
                case AuraType.PeriodicDamagePercent:
                {
                    packet.ReadUInt32("Damage", index);

                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
                    {
                        packet.ReadUInt32("Over damage", index);
                    }

                    packet.ReadUInt32("Spell Proto", index);
                    packet.ReadUInt32("Absorb", index);
                    packet.ReadUInt32("Resist", index);

                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_2_9901))
                    {
                        packet.ReadByte("Critical", index);
                    }

                    break;
                }

                case AuraType.PeriodicHeal:
                case AuraType.ObsModHealth:
                {
                    packet.ReadUInt32("Damage", index);

                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
                    {
                        packet.ReadUInt32("Over damage", index);
                    }

                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
                    {
                        // no idea when this was added exactly
                        packet.ReadUInt32("Absorb", index);
                    }

                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_2_9901))
                    {
                        packet.ReadByte("Critical", index);
                    }

                    break;
                }

                case AuraType.ObsModPower:
                case AuraType.PeriodicEnergize:
                {
                    packet.ReadInt32E <PowerType>("Power type", index);
                    packet.ReadUInt32("Amount", index);
                    break;
                }

                case AuraType.PeriodicManaLeech:
                {
                    packet.ReadInt32E <PowerType>("Power type", index);
                    packet.ReadUInt32("Amount", index);
                    packet.ReadSingle("Gain multiplier", index);
                    break;
                }
                }
            }
        }
示例#18
0
        private void ProcessFileImpl()
        {
            if (_compression != FileCompression.None)
            {
                _tempName = Decompress();
            }

            switch (_dumpFormat)
            {
            case DumpFormatType.StatisticsPreParse:
            {
                var packets = ReadPackets();
                if (packets.Count == 0)
                {
                    break;
                }

                var firstPacket = packets.First();
                var lastPacket  = packets.Last();

                // CSV format
                // ReSharper disable once UseStringInterpolation
                Trace.WriteLine(string.Format("{0};{1};{2};{3};{4};{5};{6};{7};{8}",
                                              FileName,                                              // - sniff file name
                                              firstPacket.Time,                                      // - time of first packet
                                              lastPacket.Time,                                       // - time of last packet
                                              (lastPacket.Time - firstPacket.Time).TotalSeconds,     // - sniff duration (seconds)
                                              packets.Count,                                         // - packet count
                                              packets.AsParallel().Sum(packet => packet.Length),     // - total packets size (bytes)
                                              packets.AsParallel().Average(packet => packet.Length), // - average packet size (bytes)
                                              packets.AsParallel().Min(packet => packet.Length),     // - smaller packet size (bytes)
                                              packets.AsParallel().Max(packet => packet.Length)));   // - larger packet size (bytes)

                break;
            }

            case DumpFormatType.SniffDataOnly:
            case DumpFormatType.SqlOnly:
            case DumpFormatType.Text:
            case DumpFormatType.HexOnly:
            {
                var outFileName = Path.ChangeExtension(FileName, null) + "_parsed.txt";

                if (Utilities.FileIsInUse(outFileName) && Settings.DumpFormat != DumpFormatType.SqlOnly)
                {
                    // If our dump format requires a .txt to be created,
                    // check if we can write to that .txt before starting parsing
                    Trace.WriteLine($"Save file {outFileName} is in use, parsing will not be done.");
                    break;
                }

                Store.Store.SQLEnabledFlags = Settings.SQLOutputFlag;
                File.Delete(outFileName);

                _stats.SetStartTime(DateTime.Now);

                var threadCount = Settings.Threads;
                if (threadCount == 0)
                {
                    threadCount = Environment.ProcessorCount;
                }

                ThreadPool.SetMinThreads(threadCount + 2, 4);

                var written = false;
                using (var writer = (Settings.DumpFormatWithText() ? new StreamWriter(outFileName, true) : null))
                {
                    var firstRead  = true;
                    var firstWrite = true;

                    var reader = _compression != FileCompression.None ? new Reader(_tempName, _sniffType) : new Reader(FileName, _sniffType);

                    var pwp = new ParallelWorkProcessor <Packet>(() =>    // read
                        {
                            if (!reader.PacketReader.CanRead())
                            {
                                return(Tuple.Create <Packet, bool>(null, true));
                            }

                            Packet packet;
                            var b = reader.TryRead(out packet);

                            if (firstRead)
                            {
                                Trace.WriteLine(
                                    $"{_logPrefix}: Parsing {Utilities.BytesToString(reader.PacketReader.GetTotalSize())} of packets. Detected version {ClientVersion.VersionString}");

                                firstRead = false;
                            }

                            return(Tuple.Create(packet, b));
                        }, packet => // parse
                        {
                            // Parse the packet, adding text to Writer and stuff to the stores
                            if (packet.Direction == Direction.BNClientToServer ||
                                packet.Direction == Direction.BNServerToClient)
                            {
                                BattlenetHandler.ParseBattlenet(packet);
                            }
                            else
                            {
                                Handler.Parse(packet);
                            }

                            // Update statistics
                            _stats.AddByStatus(packet.Status);
                            return(packet);
                        },
                                                                 packet => // write
                        {
                            ShowPercentProgress("Processing...", reader.PacketReader.GetCurrentSize(), reader.PacketReader.GetTotalSize());

                            if (!packet.Status.HasAnyFlag(Settings.OutputFlag) || !packet.WriteToFile)
                            {
                                packet.ClosePacket();
                                return;
                            }

                            written = true;

                            if (firstWrite)
                            {
                                // ReSharper disable AccessToDisposedClosure
                                writer?.WriteLine(GetHeader(FileName));
                                // ReSharper restore AccessToDisposedClosure

                                firstWrite = false;
                            }

                            // get packet header if necessary
                            if (Settings.LogPacketErrors)
                            {
                                switch (packet.Status)
                                {
                                case ParsedStatus.WithErrors:
                                    _withErrorHeaders.Add(packet.GetHeader());
                                    break;

                                case ParsedStatus.NotParsed:
                                    _skippedHeaders.Add(packet.GetHeader());
                                    break;

                                case ParsedStatus.NoStructure:
                                    _noStructureHeaders.Add(packet.GetHeader());
                                    break;
                                }
                            }

// ReSharper disable AccessToDisposedClosure
                            if (writer != null)
                            {
                                // Write to file
                                writer.WriteLine(packet.Writer);
                                writer.Flush();
                            }
// ReSharper restore AccessToDisposedClosure

                            // Close Writer, Stream - Dispose
                            packet.ClosePacket();
                        }, threadCount);

                    pwp.WaitForFinished(Timeout.Infinite);

                    reader.PacketReader.Dispose();

                    _stats.SetEndTime(DateTime.Now);
                }

                if (written)
                {
                    Trace.WriteLine($"{_logPrefix}: Saved file to '{outFileName}'");
                }
                else
                {
                    Trace.WriteLine($"{_logPrefix}: No file produced");
                    File.Delete(outFileName);
                }

                Trace.WriteLine($"{_logPrefix}: {_stats}");

                if (Settings.SQLOutputFlag != 0 || HotfixSettings.Instance.ShouldLog())
                {
                    WriteSQLs();
                }

                if (Settings.LogPacketErrors)
                {
                    WritePacketErrors();
                }

                GC.Collect();     // Force a GC collect after parsing a file. It seems to help.

                break;
            }

            case DumpFormatType.Pkt:
            {
                var packets = ReadPackets();
                if (packets.Count == 0)
                {
                    break;
                }

                if (Settings.FilterPacketsNum < 0)
                {
                    var packetsPerSplit = Math.Abs(Settings.FilterPacketsNum);
                    var totalPackets    = packets.Count;

                    var numberOfSplits = (int)Math.Ceiling((double)totalPackets / packetsPerSplit);

                    for (var i = 0; i < numberOfSplits; ++i)
                    {
                        var fileNamePart = FileName + "_part_" + (i + 1) + ".pkt";

                        var packetsPart = packets.Take(packetsPerSplit).ToList();
                        packets.RemoveRange(0, packetsPart.Count);

                        BinaryDump(fileNamePart, packetsPart);
                    }
                }
                else
                {
                    var fileNameExcerpt = Path.ChangeExtension(FileName, null) + "_excerpt.pkt";
                    BinaryDump(fileNameExcerpt, packets);
                }

                break;
            }

            case DumpFormatType.PktSplit:
            {
                var packets = ReadPackets();
                if (packets.Count == 0)
                {
                    break;
                }

                SplitBinaryDump(packets);
                break;
            }

            case DumpFormatType.PktDirectionSplit:
            {
                var packets = ReadPackets();
                if (packets.Count == 0)
                {
                    break;
                }

                DirectionSplitBinaryDump(packets);
                break;
            }

            case DumpFormatType.PktSessionSplit:
            {
                var packets = ReadPackets();
                if (packets.Count == 0)
                {
                    break;
                }

                SessionSplitBinaryDump(packets);
                break;
            }

            case DumpFormatType.CompressSniff:
            {
                if (_compression != FileCompression.None)
                {
                    Trace.WriteLine($"Skipped compressing file {FileName}");
                    break;
                }

                Compress();
                break;
            }

            case DumpFormatType.SniffVersionSplit:
            {
                var reader = _compression != FileCompression.None ? new Reader(_tempName, _sniffType) : new Reader(FileName, _sniffType);

                if (ClientVersion.IsUndefined() && reader.PacketReader.CanRead())
                {
                    Packet packet;
                    reader.TryRead(out packet);
                    packet.ClosePacket();
                }

                reader.PacketReader.Dispose();

                var version = ClientVersion.IsUndefined() ? "unknown" : ClientVersion.VersionString;

                var realFileName = GetCompressedFileName();

                var destPath = Path.Combine(Path.GetDirectoryName(realFileName), version,
                                            Path.GetFileName(realFileName));

                var destDir = Path.GetDirectoryName(destPath);
                if (!Directory.Exists(destDir))
                {
                    Directory.CreateDirectory(destDir);
                }

                File.Move(realFileName, destPath);

                Trace.WriteLine("Moved " + realFileName + " to " + destPath);

                break;
            }

            case DumpFormatType.ConnectionIndexes:
            {
                var packets = ReadPackets();
                if (packets.Count == 0)
                {
                    break;
                }

                using (var writer = new StreamWriter(Path.ChangeExtension(FileName, null) + "_connidx.txt"))
                {
                    if (ClientVersion.Build <= ClientVersionBuild.V6_0_3_19342)
                    {
                        writer.WriteLine("# Warning: versions before 6.1 might not have proper ConnectionIndex values.");
                    }

                    IEnumerable <IGrouping <Tuple <int, Direction>, Packet> > groupsOpcode = packets
                                                                                             .GroupBy(packet => Tuple.Create(packet.Opcode, packet.Direction))
                                                                                             .OrderBy(grouping => grouping.Key.Item2);

                    foreach (var groupOpcode in groupsOpcode)
                    {
                        var groups = groupOpcode
                                     .GroupBy(packet => packet.ConnectionIndex)
                                     .OrderBy(grouping => grouping.Key)
                                     .ToList();

                        writer.Write("{0} {1,-50}: ", groupOpcode.Key.Item2, Opcodes.GetOpcodeName(groupOpcode.Key.Item1, groupOpcode.Key.Item2));

                        for (var i = 0; i < groups.Count; i++)
                        {
                            var idx = groups[i].Key;
                            writer.Write("{0} ({1}{2})", idx, (idx & 1) != 0 ? "INSTANCE" : "REALM", (idx & 2) != 0 ? "_NEW" : "");

                            if (i != groups.Count - 1)
                            {
                                writer.Write(", ");
                            }
                        }

                        writer.WriteLine();
                    }
                }

                break;
            }

            case DumpFormatType.Fusion:
            {
                var packets = ReadPackets();
                if (packets.Count == 0)
                {
                    break;
                }

                FusionDump(packets);
                break;
            }

            default:
            {
                Trace.WriteLine($"{_logPrefix}: Dump format is none, nothing will be processed.");
                break;
            }
            }
        }
示例#19
0
 static void SetBuild(uint build)
 {
     ClientVersion.SetVersion((ClientVersionBuild)build);
 }
示例#20
0
        public static string CreatureTemplateAddon(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_template_addon))
            {
                return(string.Empty);
            }

            var addons = new DataBag <CreatureTemplateAddon>();

            foreach (var unit in units)
            {
                var npc = unit.Value;

                if (Settings.AreaFilters.Length > 0)
                {
                    if (!(npc.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                    {
                        continue;
                    }
                }

                if (Settings.MapFilters.Length > 0)
                {
                    if (!(npc.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters)))
                    {
                        continue;
                    }
                }

                var auras        = string.Empty;
                var commentAuras = string.Empty;
                if (npc.Auras != null && npc.Auras.Count != 0)
                {
                    foreach (var aura in npc.Auras.Where(aura =>
                                                         aura != null &&
                                                         (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria) ?
                                                          aura.AuraFlags.HasAnyFlag(AuraFlagMoP.NoCaster) :
                                                          aura.AuraFlags.HasAnyFlag(AuraFlag.NotCaster))))
                    {
                        auras        += aura.SpellId + " ";
                        commentAuras += StoreGetters.GetName(StoreNameType.Spell, (int)aura.SpellId, false) + ", ";
                    }
                    auras        = auras.TrimEnd(' ');
                    commentAuras = commentAuras.TrimEnd(',', ' ');
                }

                var addon = new CreatureTemplateAddon
                {
                    Entry           = unit.Key.GetEntry(),
                    PathID          = 0,
                    MountID         = npc.Mount.GetValueOrDefault(),
                    Bytes1          = npc.Bytes1.GetValueOrDefault(),
                    Bytes2          = npc.Bytes2.GetValueOrDefault(),
                    Emote           = 0,
                    AIAnimKit       = npc.AIAnimKit.GetValueOrDefault(0),
                    MovementAnimKit = npc.MovementAnimKit.GetValueOrDefault(0),
                    MeleeAnimKit    = npc.MeleeAnimKit.GetValueOrDefault(0),
                    Auras           = auras,
                    CommentAuras    = commentAuras
                };

                if (addons.ContainsKey(addon))
                {
                    continue;
                }

                addons.Add(addon);
            }

            var addonsDb = SQLDatabase.Get(addons);

            return(SQLUtil.Compare(addons, addonsDb,
                                   addon =>
            {
                var comment = StoreGetters.GetName(StoreNameType.Unit, (int)addon.Entry.GetValueOrDefault());
                if (!string.IsNullOrEmpty(addon.CommentAuras))
                {
                    comment += " - " + addon.CommentAuras;
                }
                return comment;
            }));
        }
示例#21
0
        public static bool IsClientVersionValid(string versionText, out ClientVersion version)
        {
            version = 0;

            if (!string.IsNullOrEmpty(versionText))
            {
                versionText = versionText.ToLower();

                string[] buff = versionText.ToLower()
                                .Split('.');

                if (buff.Length <= 2 || buff.Length > 4)
                {
                    return(false);
                }

                if (int.TryParse(buff[0], out int major) && major >= byte.MinValue && major <= byte.MaxValue)
                {
                    int extra = 0;

                    if (int.TryParse(buff[1], out int minor) && minor >= byte.MinValue && minor <= byte.MaxValue)
                    {
                        int extra_index = 2;
                        int build       = 0;

                        if (buff.Length == 4)
                        {
                            if (!(int.TryParse(buff[extra_index], out build) && build >= byte.MinValue && build <= byte.MaxValue))
                            {
                                return(false);
                            }

                            extra_index++;
                        }

                        int i = 0;

                        for (;
                             i < buff[extra_index]
                             .Length;
                             i++)
                        {
                            char c = buff[extra_index][i];

                            if (char.IsLetter(c))
                            {
                                extra = (byte)c;

                                break;
                            }
                        }

                        if (extra != 0)
                        {
                            if (buff[extra_index]
                                .Length - i > 1)
                            {
                                return(false);
                            }
                        }
                        else if (i <= 0)
                        {
                            return(false);
                        }

                        if (!(int.TryParse
                              (
                                  buff[extra_index]
                                  .Substring(0, i), out int num_extra
                              ) && num_extra >= byte.MinValue && num_extra <= byte.MaxValue))
                        {
                            return(false);
                        }

                        if (extra != 0)
                        {
                            char start = 'a';
                            int  index = 0;

                            while (start != extra && start <= 'z')
                            {
                                start++;
                                index++;
                            }

                            extra = index;
                        }

                        if (extra_index == 2)
                        {
                            build     = num_extra;
                            num_extra = extra;
                        }

                        version = (ClientVersion)(((major & 0xFF) << 24) | ((minor & 0xFF) << 16) | ((build & 0xFF) << 8) | (num_extra & 0xFF));

                        return(true);
                    }
                }
            }

            return(false);
        }
示例#22
0
        private static Dictionary <int, List <UpdateField> > ReadDynamicValuesUpdateBlock(Packet packet, ObjectType type, object index, bool isCreating)
        {
            var dict = new Dictionary <int, List <UpdateField> >();

            if (!ClientVersion.AddedInVersion(ClientVersionBuild.V5_0_4_16016))
            {
                return(dict);
            }

            int objectEnd  = UpdateFields.GetUpdateField(ObjectDynamicField.OBJECT_DYNAMIC_END);
            var maskSize   = packet.ReadByte();
            var updateMask = new int[maskSize];

            for (var i = 0; i < maskSize; i++)
            {
                updateMask[i] = packet.ReadInt32();
            }

            var mask = new BitArray(updateMask);

            for (var i = 0; i < mask.Count; ++i)
            {
                if (!mask[i])
                {
                    continue;
                }

                string key = "Dynamic Block Value " + i;
                if (i < objectEnd)
                {
                    key = UpdateFields.GetUpdateFieldName <ObjectDynamicField>(i);
                }
                else
                {
                    switch (type)
                    {
                    case ObjectType.Container:
                    {
                        if (i < UpdateFields.GetUpdateField(ItemDynamicField.ITEM_DYNAMIC_END))
                        {
                            goto case ObjectType.Item;
                        }

                        key = UpdateFields.GetUpdateFieldName <ContainerDynamicField>(i);
                        break;
                    }

                    case ObjectType.Item:
                    {
                        key = UpdateFields.GetUpdateFieldName <ItemDynamicField>(i);
                        break;
                    }

                    case ObjectType.Player:
                    {
                        if (i < UpdateFields.GetUpdateField(UnitDynamicField.UNIT_DYNAMIC_END))
                        {
                            goto case ObjectType.Unit;
                        }

                        key = UpdateFields.GetUpdateFieldName <PlayerDynamicField>(i);
                        break;
                    }

                    case ObjectType.Unit:
                    {
                        key = UpdateFields.GetUpdateFieldName <UnitDynamicField>(i);
                        break;
                    }

                    case ObjectType.GameObject:
                    {
                        key = UpdateFields.GetUpdateFieldName <GameObjectDynamicField>(i);
                        break;
                    }

                    case ObjectType.DynamicObject:
                    {
                        key = UpdateFields.GetUpdateFieldName <DynamicObjectDynamicField>(i);
                        break;
                    }

                    case ObjectType.Corpse:
                    {
                        key = UpdateFields.GetUpdateFieldName <CorpseDynamicField>(i);
                        break;
                    }

                    case ObjectType.AreaTrigger:
                    {
                        key = UpdateFields.GetUpdateFieldName <AreaTriggerDynamicField>(i);
                        break;
                    }

                    case ObjectType.SceneObject:
                    {
                        key = UpdateFields.GetUpdateFieldName <SceneObjectDynamicField>(i);
                        break;
                    }

                    case ObjectType.Conversation:
                    {
                        key = UpdateFields.GetUpdateFieldName <ConversationDynamicField>(i);
                        break;
                    }
                    }
                }

                var flag = packet.ReadUInt16();
                var cnt  = flag & 0x7FFF;
                if ((flag & 0x8000) != 0)
                {
                    packet.ReadUInt32(key + " Size", index);
                }

                var vals = new int[cnt];
                for (var j = 0; j < cnt; ++j)
                {
                    vals[j] = packet.ReadInt32();
                }

                var values    = new List <UpdateField>();
                var fieldMask = new BitArray(vals);
                for (var j = 0; j < fieldMask.Count; ++j)
                {
                    if (!fieldMask[j])
                    {
                        continue;
                    }

                    var    blockVal = packet.ReadUpdateField();
                    string value    = blockVal.UInt32Value + "/" + blockVal.SingleValue;
                    packet.AddValue(key, value, index, j);

                    values.Add(blockVal);
                }

                dict.Add(i, values);
            }

            return(dict);
        }
示例#23
0
        public static void HandleSubmitComplaints(Packet packet)
        {
            V6_0_2_19033.Parsers.TicketHandler.ReadCliSupportTicketHeader(packet, "Header");
            V6_0_2_19033.Parsers.TicketHandler.ReadCliSupportTicketChatLog(packet, "ChatLog");

            packet.ReadPackedGuid128("TargetCharacterGUID");

            packet.ReadBits("ComplaintType", 5); // enum CliComplaintType

            var noteLength = packet.ReadBits("NoteLength", 10);

            var hasMailInfo            = packet.ReadBit("HasMailInfo");
            var hasCalendarInfo        = packet.ReadBit("HasCalendarInfo");
            var hasPetInfo             = packet.ReadBit("HasPetInfo");
            var hasGuildInfo           = packet.ReadBit("HasGuildInfo");
            var hasLFGListSearchResult = packet.ReadBit("HasLFGListSearchResult");
            var hasLFGListApplicant    = packet.ReadBit("HasLFGListApplicant");
            var hasClubMessage         = packet.ReadBit("HasClubMessage");
            var hasClubFinderResult    = packet.ReadBit("HasClubFinderResult");

            bool hasUnk910 = false;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V9_1_0_39185))
            {
                hasUnk910 = packet.ReadBit();
            }

            packet.ResetBitReader();

            if (hasClubMessage)
            {
                packet.ReadBit("IsUsingPlayerVoice");
                packet.ResetBitReader();
            }
            packet.ReadWoWString("Note", noteLength);

            if (hasMailInfo)
            {
                V6_0_2_19033.Parsers.TicketHandler.ReadCliSupportTicketMailInfo(packet, "MailInfo");
            }

            if (hasCalendarInfo)
            {
                V6_0_2_19033.Parsers.TicketHandler.ReadCliSupportTicketCalendarEventInfo(packet, "CalendarInfo");
            }

            if (hasPetInfo)
            {
                V6_0_2_19033.Parsers.TicketHandler.ReadCliSupportTicketPetInfo(packet, "PetInfo");
            }

            if (hasGuildInfo)
            {
                V6_0_2_19033.Parsers.TicketHandler.ReadCliSupportTicketGuildInfo(packet, "GuidInfo");
            }

            if (hasLFGListSearchResult)
            {
                V6_0_2_19033.Parsers.TicketHandler.ReadCliSupportTicketLFGListSearchResult(packet, "LFGListSearchResult");
            }

            if (hasLFGListApplicant)
            {
                V6_0_2_19033.Parsers.TicketHandler.ReadCliSupportTicketLFGListApplicant(packet, "LFGListApplicant");
            }

            if (hasClubFinderResult)
            {
                ReadClubFinderResult(packet, "ClubFinderResult");
            }

            if (hasUnk910)
            {
                ReadUnused910(packet, "Unused910");
            }
        }
示例#24
0
        public static void HandleServerTrainerList(Packet packet)
        {
            var npcTrainer = new NpcTrainer();

            var guid = packet.ReadGuid("GUID");

            npcTrainer.Type = packet.ReadEnum <TrainerType>("Type", TypeCode.Int32);

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6a_13623))
            {
                packet.ReadInt32("Unk Int32"); // Same unk exists in CMSG_TRAINER_BUY_SPELL
            }
            var count = packet.ReadInt32("Count");

            npcTrainer.TrainerSpells = new List <TrainerSpell>(count);
            for (var i = 0; i < count; ++i)
            {
                var trainerSpell = new TrainerSpell();

                trainerSpell.Spell = (uint)packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Spell ID", i);

                packet.ReadEnum <TrainerSpellState>("State", TypeCode.Byte, i);

                trainerSpell.Cost = packet.ReadUInt32("Cost", i);

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6a_13623))
                {
                    trainerSpell.RequiredLevel      = packet.ReadByte("Required Level", i);
                    trainerSpell.RequiredSkill      = packet.ReadUInt32("Required Skill", i);
                    trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i);
                    if (ClientVersion.RemovedInVersion(ClientVersionBuild.V5_1_0_16309))
                    {
                        packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Chain Spell ID", i, 0);
                        packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Chain Spell ID", i, 1);
                    }
                    else
                    {
                        packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Required Spell ID", i);
                    }
                }

                packet.ReadInt32("Profession Dialog", i);
                packet.ReadInt32("Profession Button", i);

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_6a_13623))
                {
                    trainerSpell.RequiredLevel      = packet.ReadByte("Required Level", i);
                    trainerSpell.RequiredSkill      = packet.ReadUInt32("Required Skill", i);
                    trainerSpell.RequiredSkillLevel = packet.ReadUInt32("Required Skill Level", i);
                    packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Chain Spell ID", i, 0);
                    packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Chain Spell ID", i, 1);
                }

                if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_0_6a_13623))
                {
                    packet.ReadInt32("Unk Int32", i);
                }

                npcTrainer.TrainerSpells.Add(trainerSpell);
            }

            npcTrainer.Title = packet.ReadCString("Title");

            Storage.NpcTrainers.Add(guid.GetEntry(), npcTrainer, packet.TimeSpan);
        }
示例#25
0
        public static void HandleGossipPoi(Packet packet)
        {
            var protoPoi = packet.Holder.GossipPoi = new();
            PointsOfInterest gossipPOI = new PointsOfInterest();

            gossipPOI.ID = protoPoi.Id = packet.ReadInt32("ID");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V9_1_0_39185))
            {
                Vector3 pos = packet.ReadVector3("Coordinates");
                gossipPOI.PositionX  = pos.X;
                gossipPOI.PositionY  = pos.Y;
                gossipPOI.PositionZ  = pos.Z;
                protoPoi.Coordinates = new Vec2()
                {
                    X = pos.X, Y = pos.Y
                };
                protoPoi.Height = pos.Z;
            }
            else
            {
                Vector2 pos = packet.ReadVector2("Coordinates");
                gossipPOI.PositionX  = pos.X;
                gossipPOI.PositionY  = pos.Y;
                protoPoi.Coordinates = pos;
            }

            gossipPOI.Icon       = packet.ReadInt32E <GossipPOIIcon>("Icon");
            gossipPOI.Importance = protoPoi.Importance = (uint)packet.ReadInt32("Importance");
            protoPoi.Icon        = (uint)gossipPOI.Icon;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V9_0_5_37503))
            {
                gossipPOI.Unknown905 = packet.ReadInt32("Unknown905");
            }

            packet.ResetBitReader();
            gossipPOI.Flags = gossipPOI.Flags = packet.ReadBits("Flags", 14);
            uint bit84 = packet.ReadBits(6);

            gossipPOI.Name = protoPoi.Name = packet.ReadWoWString("Name", bit84);

            var lastGossipOption    = CoreParsers.NpcHandler.LastGossipOption;
            var tempGossipOptionPOI = CoreParsers.NpcHandler.TempGossipOptionPOI;

            lastGossipOption.ActionPoiId    = gossipPOI.ID;
            tempGossipOptionPOI.ActionPoiId = gossipPOI.ID;

            Storage.GossipPOIs.Add(gossipPOI, packet.TimeSpan);

            if (tempGossipOptionPOI.HasSelection)
            {
                if ((packet.TimeSpan - tempGossipOptionPOI.TimeSpan).Duration() <= TimeSpan.FromMilliseconds(2500))
                {
                    if (tempGossipOptionPOI.ActionMenuId != null)
                    {
                        Storage.GossipMenuOptionActions.Add(new GossipMenuOptionAction {
                            MenuId = tempGossipOptionPOI.MenuId, OptionIndex = tempGossipOptionPOI.OptionIndex, ActionMenuId = tempGossipOptionPOI.ActionMenuId.GetValueOrDefault(), ActionPoiId = gossipPOI.ID
                        }, packet.TimeSpan);
                        //clear temp
                        tempGossipOptionPOI.Reset();
                    }
                }
                else
                {
                    lastGossipOption.Reset();
                    tempGossipOptionPOI.Reset();
                }
            }
        }
示例#26
0
        private static void ReadExtraQuestInfo(ref Packet packet, bool readFlags = true)
        {
            var choiceCount          = packet.ReadUInt32("Choice Item Count");
            var effectiveChoiceCount = ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164) ? 6 : choiceCount;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                for (var i = 0; i < effectiveChoiceCount; i++)
                {
                    packet.ReadEntryWithName <UInt32>(StoreNameType.Item, "Choice Item Id", i);
                }
                for (var i = 0; i < effectiveChoiceCount; i++)
                {
                    packet.ReadUInt32("Choice Item Count", i);
                }
                for (var i = 0; i < effectiveChoiceCount; i++)
                {
                    packet.ReadUInt32("Choice Item Display Id", i);
                }

                packet.ReadUInt32("Reward Item Count");
                const int effectiveRewardCount = 4;

                for (var i = 0; i < effectiveRewardCount; i++)
                {
                    packet.ReadEntryWithName <UInt32>(StoreNameType.Item, "Reward Item Id", i);
                }
                for (var i = 0; i < effectiveRewardCount; i++)
                {
                    packet.ReadUInt32("Reward Item Count", i);
                }
                for (var i = 0; i < effectiveRewardCount; i++)
                {
                    packet.ReadUInt32("Reward Item Display Id", i);
                }
            }
            else
            {
                for (var i = 0; i < choiceCount; i++)
                {
                    packet.ReadEntryWithName <UInt32>(StoreNameType.Item, "Choice Item Id", i);
                    packet.ReadUInt32("Choice Item Count", i);
                    packet.ReadUInt32("Choice Item Display Id", i);
                }

                var rewardCount = packet.ReadUInt32("Reward Item Count");
                for (var i = 0; i < rewardCount; i++)
                {
                    packet.ReadEntryWithName <UInt32>(StoreNameType.Item, "Reward Item Id", i);
                    packet.ReadUInt32("Reward Item Count", i);
                    packet.ReadUInt32("Reward Item Display Id", i);
                }
            }

            packet.ReadUInt32("Money");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_2_10482))
            {
                packet.ReadUInt32("XP");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                packet.ReadUInt32("Title Id");
                packet.ReadUInt32("Unknown UInt32");
                packet.ReadSingle("Unknown float");
                packet.ReadUInt32("Bonus Talents");
                packet.ReadUInt32("Unknown UInt32");
                packet.ReadUInt32("Unknown UInt32");
            }
            else
            {
                packet.ReadUInt32("Honor Points");

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
                {
                    packet.ReadSingle("Honor Multiplier");
                }

                if (readFlags)
                {
                    packet.ReadEnum <QuestFlags>("Quest Flags", TypeCode.UInt32);
                }

                packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Spell Id");
                packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Spell Cast Id");
                packet.ReadUInt32("Title Id");

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
                {
                    packet.ReadUInt32("Bonus Talents");
                }

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
                {
                    packet.ReadUInt32("Arena Points");
                    packet.ReadUInt32("Unk UInt32");
                }
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
            {
                for (var i = 0; i < 5; i++)
                {
                    packet.ReadUInt32("Reputation Faction", i);
                }

                for (var i = 0; i < 5; i++)
                {
                    packet.ReadUInt32("Reputation Value Id", i);
                }

                for (var i = 0; i < 5; i++)
                {
                    packet.ReadInt32("Reputation Value", i);
                }
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Spell Id");
                packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Spell Cast Id");

                for (var i = 0; i < 4; i++)
                {
                    packet.ReadUInt32("Currency Id", i);
                }
                for (var i = 0; i < 4; i++)
                {
                    packet.ReadUInt32("Currency Count", i);
                }

                packet.ReadUInt32("Unknown UInt32");
                packet.ReadUInt32("Unknown UInt32");
            }
        }
        public static void ReadCharactersData(Packet packet, params object[] idx)
        {
            packet.ReadPackedGuid128("Guid", idx);

            packet.ReadUInt64("GuildClubMemberID", idx);

            packet.ReadByte("ListPosition", idx);
            var race  = packet.ReadByteE <Race>("RaceID", idx);
            var klass = packet.ReadByteE <Class>("ClassID", idx);

            packet.ReadByteE <Gender>("SexID", idx);
            packet.ReadByte("SkinID", idx);
            packet.ReadByte("FaceID", idx);
            packet.ReadByte("HairStyle", idx);
            packet.ReadByte("HairColor", idx);
            packet.ReadByte("FacialHairStyle", idx);

            for (uint j = 0; j < 3; ++j)
            {
                packet.ReadByte("CustomDisplay", idx, j);
            }

            packet.ReadByte("ExperienceLevel", idx);
            var zone  = packet.ReadInt32 <ZoneId>("ZoneID", idx);
            var mapId = packet.ReadInt32 <MapId>("MapID", idx);

            var pos = packet.ReadVector3("PreloadPos", idx);

            packet.ReadPackedGuid128("GuildGUID", idx);

            packet.ReadUInt32("Flags", idx);
            packet.ReadUInt32("Flags2", idx);
            packet.ReadUInt32("Flags3", idx);
            packet.ReadUInt32("PetCreatureDisplayID", idx);
            packet.ReadUInt32("PetExperienceLevel", idx);
            packet.ReadUInt32("PetCreatureFamilyID", idx);

            for (uint j = 0; j < 2; ++j)
            {
                packet.ReadInt32("ProfessionIDs", idx, j);
            }

            for (uint j = 0; j < 23; ++j)
            {
                packet.ReadUInt32("DisplayID", idx, "VisualItems", j);
                packet.ReadUInt32("DisplayEnchantID", idx, "VisualItems", j);
                packet.ReadByteE <InventoryType>("InvType", idx, "VisualItems", j);
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_5_31921))
                {
                    packet.ReadByte("Subclass", idx, "VisualItems", j);
                }
            }

            packet.ReadTime("LastPlayedTime", idx);

            packet.ReadInt16("SpecID", idx);
            packet.ReadInt32("Unknown703", idx);
            packet.ReadInt32("InterfaceVersion", idx);
            packet.ReadUInt32("Flags4", idx);
            var mailSenderLengths = new uint[packet.ReadUInt32()];

            packet.ResetBitReader();

            var nameLength = packet.ReadBits("Character Name Length", 6, idx);
            var firstLogin = packet.ReadBit("FirstLogin", idx);

            packet.ReadBit("BoostInProgress", idx);
            packet.ReadBits("UnkWod61x", 5, idx);

            for (var j = 0; j < mailSenderLengths.Length; ++j)
            {
                mailSenderLengths[j] = packet.ReadBits(6);
            }

            for (var j = 0; j < mailSenderLengths.Length; ++j)
            {
                if (mailSenderLengths[j] > 1)
                {
                    packet.ReadDynamicString("MailSender", mailSenderLengths[j], idx);
                }
            }

            packet.ReadWoWString("Character Name", nameLength, idx);

            if (firstLogin)
            {
                PlayerCreateInfo startPos = new PlayerCreateInfo {
                    Race = race, Class = klass, Map = (uint)mapId, Zone = (uint)zone, Position = pos, Orientation = 0
                };
                Storage.StartPositions.Add(startPos, packet.TimeSpan);
            }
        }
示例#28
0
        public static void HandleQuestgiverDetails(Packet packet)
        {
            packet.ReadGuid("GUID1");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
            {
                packet.ReadGuid("GUID2");
            }

            packet.ReadEntryWithName <UInt32>(StoreNameType.Quest, "Quest ID");
            packet.ReadCString("Title");
            packet.ReadCString("Details");
            packet.ReadCString("Objectives");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                packet.ReadCString("QuestGiver Text Window");
                packet.ReadCString("QuestGiver Target Name");
                packet.ReadCString("QuestTurn Text Window");
                packet.ReadCString("QuestTurn Target Name");
                packet.ReadUInt32("QuestGiver Portrait");
                packet.ReadUInt32("QuestTurn Portrait");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_0_10958))
            {
                packet.ReadBoolean("Auto Accept");
            }
            else
            {
                packet.ReadBoolean("Auto Accept", TypeCode.Int32);
            }

            var flags = QuestFlags.None;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_3_3_11685))
            {
                flags = packet.ReadEnum <QuestFlags>("Quest Flags", TypeCode.UInt32);
            }

            packet.ReadUInt32("Suggested Players");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_0_2_9056))
            {
                packet.ReadByte("Unknown byte");
            }

            if (ClientVersion.RemovedInVersion(ClientVersionBuild.V3_3_3a_11723))
            {
                packet.ReadByte("Unk");
                packet.ReadByte("Unk");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_1_13164))
            {
                packet.ReadByte("Start Type");
                packet.ReadEntryWithName <Int32>(StoreNameType.Spell, "Required Spell");
            }

            if (flags.HasAnyFlag(QuestFlags.HiddenRewards))
            {
                packet.ReadUInt32("Hidden Chosen Items");
                packet.ReadUInt32("Hidden Items");
                packet.ReadUInt32("Hidden Money");

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_2_2_10482))
                {
                    packet.ReadUInt32("Hidden XP");
                }
            }

            ReadExtraQuestInfo(ref packet, false);

            var emoteCount = packet.ReadUInt32("Quest Emote Count");

            for (var i = 0; i < emoteCount; i++)
            {
                packet.ReadUInt32("Emote Id", i);
                packet.ReadUInt32("Emote Delay (ms)", i);
            }
        }
        public static void HandleInspectResult815(Packet packet)
        {
            uint itemCount = 0;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_0_30898))
            {
                ReadPlayerModelDisplayInfo(packet, "DisplayInfo");
            }
            else
            {
                packet.ReadPackedGuid128("InspecteeGUID");
                itemCount = packet.ReadUInt32("ItemsCount");
            }
            var glyphCount     = packet.ReadUInt32("GlyphsCount");
            var talentCount    = packet.ReadUInt32("TalentsCount");
            var pvpTalentCount = packet.ReadUInt32("PvpTalentsCount");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V8_2_0_30898))
            {
                packet.ReadInt32("ItemLevel");
            }
            else
            {
                packet.ReadInt32E <Class>("ClassID");
                packet.ReadInt32("SpecializationID");
                packet.ReadInt32E <Gender>("Gender");
            }
            packet.ReadByte("LifetimeMaxRank");
            packet.ReadUInt16("TodayHK");
            packet.ReadUInt16("YesterdayHK");
            packet.ReadUInt32("LifetimeHK");
            packet.ReadUInt32("HonorLevel");

            for (int i = 0; i < glyphCount; i++)
            {
                packet.ReadUInt16("Glyphs", i);
            }

            for (int i = 0; i < talentCount; i++)
            {
                packet.ReadUInt16("Talents", i);
            }

            for (int i = 0; i < pvpTalentCount; i++)
            {
                packet.ReadUInt16("PvpTalents", i);
            }

            packet.ResetBitReader();
            var hasGuildData    = packet.ReadBit("HasGuildData");
            var hasAzeriteLevel = packet.ReadBit("HasAzeriteLevel");

            for (int i = 0; i < 6; i++)
            {
                packet.ReadByte("Bracket", i);
                packet.ReadInt32("Rating", i);
                packet.ReadInt32("Rank", i);
                packet.ReadInt32("WeeklyPlayed", i);
                packet.ReadInt32("WeeklyWon", i);
                packet.ReadInt32("SeasonPlayed", i);
                packet.ReadInt32("SeasonWon", i);
                packet.ReadInt32("WeeklyBestRating", i);
                packet.ReadInt32("Unk710", i);
                packet.ReadInt32("Unk801_1", i);
                packet.ResetBitReader();
                packet.ReadBit("Unk801_2", i);
            }

            if (hasGuildData)
            {
                packet.ReadPackedGuid128("GuildGUID");
                packet.ReadInt32("NumGuildMembers");
                packet.ReadInt32("GuildAchievementPoints");
            }
            if (hasAzeriteLevel)
            {
                packet.ReadInt32("AzeriteLevel");
            }

            for (int i = 0; i < itemCount; i++)
            {
                ReadInspectItemData(packet, i);
            }
        }
示例#30
0
        public static void HandlePartyMemberStats(Packet packet)
        {
            /*
             * -- UNK PACKET
             * var count = packet.ReadBits("counter", 18);
             *
             * var unkGuid = new byte[count][];
             * var unkLen = new uint[count];
             * var unkLen2 = new uint[count];
             * var count2 = new uint[count];
             * var bit28 = new bool[count];
             * var bit16 = new bool[count];
             *
             * for (int i = 0; i < count; i++)
             * {
             *  unkGuid[i] = new byte[8];
             *
             *  count2[i] = packet.ReadBits("counter2", 17, i);
             *  bit16[i] = packet.ReadBit("bit16", i);
             *
             *  if (bit16[i])
             *      packet.StartBitStream(unkGuid[i], 3, 6, 4, 2, 5, 1, 0, 7);
             *
             *  bit28[i] = packet.ReadBit("bit28", i);
             *  unkLen[i] = packet.ReadBits("unkLen", 13, i);
             *  unkLen2[i] = packet.ReadBits("unkLen2", 8, i);
             *
             *  for (int j = 0; j < count2[i]; j++)
             *      packet.ReadBit("unkBit", i, j);
             * }
             *
             * for (int i = 0; i < count; i++)
             * {
             *  for (int j = 0; j < count2[i]; j++)
             *  {
             *      packet.ReadUInt32("unk UInt32", i, j);
             *      packet.ReadUInt32("unk UInt32", i, j);
             *
             *      for (int y = 0; y < 8; y++)
             *      {
             *          packet.ReadUInt32("unk UInt32", i, j, y);
             *          packet.ReadUInt32("unk UInt32", i, j, y);
             *          packet.ReadUInt32("unk UInt32", i, j, y);
             *      }
             *
             *      packet.ReadUInt32("unk UInt32", i, j);
             *      packet.ReadByte("unk Byte", i, j);
             *      packet.ReadUInt32("unk UInt32", i, j);
             *      packet.ReadUInt32("unk UInt32", i, j);
             *      packet.ReadUInt32("unk UInt32", i, j);
             *      packet.ReadUInt32("unk UInt32", i, j);
             *      var bytesCounter = packet.ReadUInt32("unk UInt32", i, j);
             *      if (bytesCounter > 0)
             *          packet.ReadBytes((int)bytesCounter);
             *      packet.ReadUInt32("unk UInt32", i, j);
             *  }
             *
             *  packet.ReadUInt32("unk UInt32", i);
             *
             *  if (bit16[i])
             *  {
             *      packet.ParseBitStream(unkGuid[i], 2, 0, 4, 5, 3, 6, 1, 7);
             *      packet.WriteGuid("Unk GUID", unkGuid[i], i);
             *  }
             *
             *  packet.ReadWoWString("unkString2", unkLen2[i], i);
             *  packet.ReadUInt32("unk UInt32", i);
             *  packet.ReadUInt32("unk UInt32", i);
             *  packet.ReadUInt64("unk UInt64", i);
             *  packet.ReadUInt32("unk UInt32", i);
             *  packet.ReadUInt64("unk UInt64", i);
             *  packet.ReadUInt32("unk UInt32", i);
             *  packet.ReadWoWString("unkString", unkLen[i], i);
             *
             *  if (bit28[i])
             *      packet.ReadUInt32("unk UInt32", i);
             *
             *  packet.ReadByte("unk Byte", i);
             *  packet.ReadUInt32("unk UInt32", i);
             * }
             *
             * packet.ReadUInt32("unk UInt32");*/

            if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing) &&
                packet.Opcode == Opcodes.GetOpcode(Opcode.SMSG_PARTY_MEMBER_STATS_FULL))
            {
                packet.ReadBoolean("Add arena opponent");
            }

            packet.ReadPackedGuid("GUID");
            var updateFlags = packet.ReadEnum <GroupUpdateFlag>("Update Flags", TypeCode.UInt32);

            if (updateFlags.HasFlag(GroupUpdateFlag.Status))
            {
                packet.ReadEnum <GroupMemberStatusFlag>("Status", TypeCode.Int16);
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.CurrentHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Current Health");
                }
                else
                {
                    packet.ReadUInt16("Current Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.MaxHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Max Health");
                }
                else
                {
                    packet.ReadUInt16("Max Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PowerType))
            {
                packet.ReadEnum <PowerType>("Power type", TypeCode.Byte);
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.CurrentPower))
            {
                packet.ReadInt16("Current Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.MaxPower))
            {
                packet.ReadInt16("Max Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.Level))
            {
                packet.ReadInt16("Level");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.Zone))
            {
                packet.ReadEntryWithName <Int16>(StoreNameType.Zone, "Zone Id");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.Position))
            {
                packet.ReadInt16("Position X");
                packet.ReadInt16("Position Y");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.Auras))
            {
                var auraMask = packet.ReadUInt64("Aura Mask");

                var maxAura = ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing) ? 64 : 56;
                for (var i = 0; i < maxAura; ++i)
                {
                    if ((auraMask & (1ul << i)) == 0)
                    {
                        continue;
                    }

                    if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                    {
                        packet.ReadEntryWithName <UInt32>(StoreNameType.Spell, "Spell Id", i);
                    }
                    else
                    {
                        packet.ReadEntryWithName <UInt16>(StoreNameType.Spell, "Spell Id", i);
                    }

                    packet.ReadEnum <AuraFlag>("Aura Flags", TypeCode.Byte, i);
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetGuid))
            {
                packet.ReadGuid("Pet GUID");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetName))
            {
                packet.ReadCString("Pet Name");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetModelId))
            {
                packet.ReadInt16("Pet Modelid");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetCurrentHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Pet Current Health");
                }
                else
                {
                    packet.ReadUInt16("Pet Current Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetMaxHealth))
            {
                if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                {
                    packet.ReadInt32("Pet Max Health");
                }
                else
                {
                    packet.ReadUInt16("Pet Max Health");
                }
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetPowerType))
            {
                packet.ReadEnum <PowerType>("Pet Power type", TypeCode.Byte);
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetCurrentPower))
            {
                packet.ReadInt16("Pet Current Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetMaxPower))
            {
                packet.ReadInt16("Pet Max Power");
            }

            if (updateFlags.HasFlag(GroupUpdateFlag.PetAuras))
            {
                var auraMask = packet.ReadUInt64("Pet Auramask");

                var maxAura = ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing) ? 64 : 56;
                for (var i = 0; i < maxAura; ++i)
                {
                    if ((auraMask & (1ul << i)) == 0)
                    {
                        continue;
                    }

                    if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing))
                    {
                        packet.ReadEntryWithName <UInt32>(StoreNameType.Spell, "Spell Id", i);
                    }
                    else
                    {
                        packet.ReadEntryWithName <UInt16>(StoreNameType.Spell, "Spell Id", i);
                    }

                    packet.ReadEnum <AuraFlag>("Aura Flags", TypeCode.Byte, i);
                }
            }

            if (ClientVersion.AddedInVersion(ClientType.WrathOfTheLichKing) && // no idea when this was added exactly, doesn't exist in 2.4.1
                updateFlags.HasFlag(GroupUpdateFlag.VehicleSeat))
            {
                packet.ReadInt32("Vehicle Seat");
            }
        }
示例#31
0
        public static string GameObject(Dictionary <WowGuid, GameObject> gameObjects)
        {
            if (gameObjects.Count == 0)
            {
                return(string.Empty);
            }

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject))
            {
                return(string.Empty);
            }

            uint count     = 0;
            var  rows      = new RowList <GameObjectModel>();
            var  addonRows = new RowList <GameObjectAddon>();

            foreach (var gameobject in gameObjects)
            {
                Row <GameObjectModel> row = new Row <GameObjectModel>();

                GameObject go = gameobject.Value;

                if (Settings.AreaFilters.Length > 0)
                {
                    if (!(go.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                    {
                        continue;
                    }
                }

                if (Settings.MapFilters.Length > 0)
                {
                    if (!(go.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters)))
                    {
                        continue;
                    }
                }

                uint entry = (uint)go.ObjectData.EntryID;
                if (entry == 0)
                {
                    continue;   // broken entry, nothing to spawn
                }
                bool badTransport = false;

                row.Data.GUID = "@OGUID+" + count;

                row.Data.ID = entry;
                if (!go.IsOnTransport())
                {
                    row.Data.Map = go.Map;
                }
                else
                {
                    int mapId;
                    badTransport = !GetTransportMap(go, out mapId);
                    if (mapId != -1)
                    {
                        row.Data.Map = (uint)mapId;
                    }
                }

                row.Data.ZoneID = 0;
                row.Data.AreaID = 0;

                if (go.Area != -1)
                {
                    row.Data.AreaID = (uint)go.Area;
                }

                if (go.Zone != -1)
                {
                    row.Data.ZoneID = (uint)go.Zone;
                }

                row.Data.SpawnMask = (uint)go.GetDefaultSpawnMask();


                if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_0_3_22248))
                {
                    string data = string.Join(",", go.GetDefaultSpawnDifficulties());
                    if (string.IsNullOrEmpty(data))
                    {
                        data = "0";
                    }

                    row.Data.spawnDifficulties = data;
                }

                row.Data.PhaseMask = go.PhaseMask;

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_3_4_15595) && go.Phases != null)
                {
                    row.Data.PhaseID = string.Join(" - ", go.Phases);
                }

                if (!go.IsOnTransport())
                {
                    row.Data.PositionX   = go.Movement.Position.X;
                    row.Data.PositionY   = go.Movement.Position.Y;
                    row.Data.PositionZ   = go.Movement.Position.Z;
                    row.Data.Orientation = go.Movement.Orientation;
                }
                else
                {
                    row.Data.PositionX   = go.Movement.TransportOffset.X;
                    row.Data.PositionY   = go.Movement.TransportOffset.Y;
                    row.Data.PositionZ   = go.Movement.TransportOffset.Z;
                    row.Data.Orientation = go.Movement.TransportOffset.O;
                }

                var rotation = go.GetStaticRotation();
                row.Data.Rotation = new float?[] { rotation.X, rotation.Y, rotation.Z, rotation.W };

                bool add      = true;
                var  addonRow = new Row <GameObjectAddon>();
                if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon))
                {
                    addonRow.Data.GUID = "@OGUID+" + count;

                    var parentRotation = go.GetParentRotation();

                    if (parentRotation != null)
                    {
                        addonRow.Data.parentRot0 = parentRotation.Value.X;
                        addonRow.Data.parentRot1 = parentRotation.Value.Y;
                        addonRow.Data.parentRot2 = parentRotation.Value.Z;
                        addonRow.Data.parentRot3 = parentRotation.Value.W;

                        if (addonRow.Data.parentRot0 == 0.0f &&
                            addonRow.Data.parentRot1 == 0.0f &&
                            addonRow.Data.parentRot2 == 0.0f &&
                            addonRow.Data.parentRot3 == 1.0f)
                        {
                            add = false;
                        }
                    }
                    else
                    {
                        add = false;
                    }

                    addonRow.Comment += StoreGetters.GetName(StoreNameType.GameObject, (int)gameobject.Key.GetEntry(), false);

                    if (add)
                    {
                        addonRows.Add(addonRow);
                    }
                }

                row.Data.SpawnTimeSecs = go.GetDefaultSpawnTime(go.DifficultyID);
                row.Data.AnimProgress  = go.GameObjectData.PercentHealth;
                row.Data.State         = (uint)go.GameObjectData.State;

                // set some defaults
                row.Data.PhaseGroup = 0;
                row.Data.PhaseID    = "0";

                row.Comment  = StoreGetters.GetName(StoreNameType.GameObject, (int)gameobject.Key.GetEntry(), false);
                row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, go.Area, false) + " - ";
                row.Comment += "Difficulty: " + StoreGetters.GetName(StoreNameType.Difficulty, (int)go.DifficultyID, false) + ")";

                if (go.IsTemporarySpawn())
                {
                    row.CommentOut = true;
                    row.Comment   += " - !!! might be temporary spawn !!!";
                    if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon))
                    {
                        addonRow.CommentOut = true;
                        addonRow.Comment   += " - !!! might be temporary spawn !!!";
                    }
                }
                else if (go.IsTransport())
                {
                    row.CommentOut = true;
                    row.Comment   += " - !!! transport !!!";
                    if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon))
                    {
                        addonRow.CommentOut = true;
                        addonRow.Comment   += " - !!! transport !!!";
                    }
                }
                else if (go.IsOnTransport() && badTransport)
                {
                    row.CommentOut = true;
                    row.Comment   += " - !!! on transport - transport template not found !!!";
                    if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon))
                    {
                        addonRow.CommentOut = true;
                        addonRow.Comment   += " - !!! on transport - transport template not found !!!";
                    }
                }
                else
                {
                    ++count;
                }

                rows.Add(row);
            }

            if (count == 0)
            {
                return(String.Empty);
            }

            StringBuilder result = new StringBuilder();
            // delete query for GUIDs
            var delete = new SQLDelete <GameObjectModel>(Tuple.Create("@OGUID+0", "@OGUID+" + --count));

            result.Append(delete.Build());

            var sql = new SQLInsert <GameObjectModel>(rows, false);

            result.Append(sql.Build());

            if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_addon))
            {
                var addonDelete = new SQLDelete <GameObjectAddon>(Tuple.Create("@OGUID+0", "@OGUID+" + count));
                result.Append(addonDelete.Build());
                var addonSql = new SQLInsert <GameObjectAddon>(addonRows, false);
                result.Append(addonSql.Build());
            }

            return(result.ToString());
        }
示例#32
0
        public static void HandleNameQueryResponse(Packet packet)
        {
            WowGuid guid;

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                guid = packet.ReadPackedGuid("GUID");
                var end = packet.ReadByte("Result");

                /*
                 * if (end == 1)
                 *  DenyItem(&WDB_CACHE_NAME, v11, v12);
                 * if (end == 2)
                 *  RetryItem(&WDB_CACHE_NAME, v11, v12);
                 * if (end == 3)
                 * {
                 *  AddItem(&WDB_CACHE_NAME, (int)&v8, v11, v12);
                 *  SetTemporary(&WDB_CACHE_NAME, v11, v12);
                 * }
                 */
                if (end != 0)
                {
                    return;
                }
            }
            else
            {
                guid = packet.ReadGuid("GUID");
            }

            var name = packet.ReadCString("Name");

            StoreGetters.AddName(guid, name);
            packet.ReadCString("Realm Name");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                packet.ReadByteE <Race>("Race");
                packet.ReadByteE <Gender>("Gender");
                packet.ReadByteE <Class>("Class");
            }
            else
            {
                packet.ReadInt32E <Race>("Race");
                packet.ReadInt32E <Gender>("Gender");
                packet.ReadInt32E <Class>("Class");
            }

            if (!packet.ReadBool("Name Declined"))
            {
                return;
            }

            for (var i = 0; i < 5; i++)
            {
                packet.ReadCString("Declined Name", i);
            }

            var objectName = new ObjectName
            {
                ObjectType = ObjectType.Player,
                ID         = (int)guid.GetLow(),
                Name       = name
            };

            Storage.ObjectNames.Add(objectName, packet.TimeSpan);
        }
示例#33
0
        public static string Creature(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature))
            {
                return(string.Empty);
            }

            uint count     = 0;
            var  rows      = new RowList <Creature>();
            var  addonRows = new RowList <CreatureAddon>();

            foreach (var unit in units)
            {
                Row <Creature> row          = new Row <Creature>();
                bool           badTransport = false;

                Unit creature = unit.Value;

                if (Settings.AreaFilters.Length > 0)
                {
                    if (!(creature.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                    {
                        continue;
                    }
                }

                if (Settings.MapFilters.Length > 0)
                {
                    if (!(creature.Map.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.MapFilters)))
                    {
                        continue;
                    }
                }

                uint entry = (uint)creature.ObjectData.EntryID;
                if (entry == 0)
                {
                    continue;   // broken entry, nothing to spawn
                }
                uint movementType = 0;
                int  spawnDist    = 0;
                row.Data.AreaID = 0;
                row.Data.ZoneID = 0;

                if (creature.Movement.HasWpsOrRandMov)
                {
                    movementType = 1;
                    spawnDist    = 10;
                }

                row.Data.GUID = "@CGUID+" + count;

                row.Data.ID = entry;
                if (!creature.IsOnTransport())
                {
                    row.Data.Map = creature.Map;
                }
                else
                {
                    int mapId;
                    badTransport = !GetTransportMap(creature, out mapId);
                    if (mapId != -1)
                    {
                        row.Data.Map = (uint)mapId;
                    }
                }

                if (creature.Area != -1)
                {
                    row.Data.AreaID = (uint)creature.Area;
                }

                if (creature.Zone != -1)
                {
                    row.Data.ZoneID = (uint)creature.Zone;
                }

                row.Data.SpawnMask = (uint)creature.GetDefaultSpawnMask();

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_0_3_22248))
                {
                    string data = string.Join(",", creature.GetDefaultSpawnDifficulties());
                    if (string.IsNullOrEmpty(data))
                    {
                        data = "0";
                    }

                    row.Data.spawnDifficulties = data;
                }

                row.Data.PhaseMask = creature.PhaseMask;

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_3_4_15595) && creature.Phases != null)
                {
                    string data = string.Join(" - ", creature.Phases);
                    if (string.IsNullOrEmpty(data))
                    {
                        data = "0";
                    }

                    row.Data.PhaseID = data;
                }

                if (!creature.IsOnTransport())
                {
                    row.Data.PositionX   = creature.Movement.Position.X;
                    row.Data.PositionY   = creature.Movement.Position.Y;
                    row.Data.PositionZ   = creature.Movement.Position.Z;
                    row.Data.Orientation = creature.Movement.Orientation;
                }
                else
                {
                    row.Data.PositionX   = creature.Movement.TransportOffset.X;
                    row.Data.PositionY   = creature.Movement.TransportOffset.Y;
                    row.Data.PositionZ   = creature.Movement.TransportOffset.Z;
                    row.Data.Orientation = creature.Movement.TransportOffset.O;
                }

                row.Data.SpawnTimeSecs = creature.GetDefaultSpawnTime(creature.DifficultyID);
                row.Data.SpawnDist     = spawnDist;
                row.Data.MovementType  = movementType;

                // set some defaults
                row.Data.PhaseGroup      = 0;
                row.Data.ModelID         = 0;
                row.Data.CurrentWaypoint = 0;
                row.Data.CurHealth       = 0;
                row.Data.CurMana         = 0;
                row.Data.NpcFlag         = 0;
                row.Data.UnitFlag        = 0;
                row.Data.DynamicFlag     = 0;

                row.Comment  = StoreGetters.GetName(StoreNameType.Unit, (int)unit.Key.GetEntry(), false);
                row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, creature.Area, false) + " - ";
                row.Comment += "Difficulty: " + StoreGetters.GetName(StoreNameType.Difficulty, (int)creature.DifficultyID, false) + ")";

                string auras        = string.Empty;
                string commentAuras = string.Empty;
                if (creature.Auras != null && creature.Auras.Count != 0)
                {
                    foreach (Aura aura in creature.Auras)
                    {
                        if (aura == null)
                        {
                            continue;
                        }

                        // usually "template auras" do not have caster
                        if (ClientVersion.AddedInVersion(ClientType.MistsOfPandaria) ? !aura.AuraFlags.HasAnyFlag(AuraFlagMoP.NoCaster) : !aura.AuraFlags.HasAnyFlag(AuraFlag.NotCaster))
                        {
                            continue;
                        }

                        auras        += aura.SpellId + " ";
                        commentAuras += aura.SpellId + " - " + StoreGetters.GetName(StoreNameType.Spell, (int)aura.SpellId, false) + ", ";
                    }

                    auras        = auras.TrimEnd(' ');
                    commentAuras = commentAuras.TrimEnd(',', ' ');

                    row.Comment += " (Auras: " + commentAuras + ")";
                }

                var addonRow = new Row <CreatureAddon>();
                if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon))
                {
                    addonRow.Data.GUID            = "@CGUID+" + count;
                    addonRow.Data.PathID          = 0;
                    addonRow.Data.Mount           = (uint)creature.UnitData.MountDisplayID;
                    addonRow.Data.Bytes1          = creature.Bytes1;
                    addonRow.Data.Bytes2          = creature.Bytes2;
                    addonRow.Data.Emote           = 0;
                    addonRow.Data.Auras           = auras;
                    addonRow.Data.AIAnimKit       = creature.AIAnimKit.GetValueOrDefault(0);
                    addonRow.Data.MovementAnimKit = creature.MovementAnimKit.GetValueOrDefault(0);
                    addonRow.Data.MeleeAnimKit    = creature.MeleeAnimKit.GetValueOrDefault(0);
                    addonRow.Comment += StoreGetters.GetName(StoreNameType.Unit, (int)unit.Key.GetEntry(), false);
                    if (!string.IsNullOrWhiteSpace(auras))
                    {
                        addonRow.Comment += " - " + commentAuras;
                    }
                    addonRows.Add(addonRow);
                }

                if (creature.IsTemporarySpawn())
                {
                    row.CommentOut = true;
                    row.Comment   += " - !!! might be temporary spawn !!!";
                    if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon))
                    {
                        addonRow.CommentOut = true;
                        addonRow.Comment   += " - !!! might be temporary spawn !!!";
                    }
                }
                else if (creature.IsOnTransport() && badTransport)
                {
                    row.CommentOut = true;
                    row.Comment   += " - !!! on transport - transport template not found !!!";
                    if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon))
                    {
                        addonRow.CommentOut = true;
                        addonRow.Comment   += " - !!! on transport - transport template not found !!!";
                    }
                }
                else
                {
                    ++count;
                }

                if (creature.Movement.HasWpsOrRandMov)
                {
                    row.Comment += " (possible waypoints or random movement)";
                }

                rows.Add(row);
            }

            if (count == 0)
            {
                return(string.Empty);
            }

            StringBuilder result = new StringBuilder();
            // delete query for GUIDs
            var delete = new SQLDelete <Creature>(Tuple.Create("@CGUID+0", "@CGUID+" + --count));

            result.Append(delete.Build());
            var sql = new SQLInsert <Creature>(rows, false);

            result.Append(sql.Build());

            if (Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_addon))
            {
                var addonDelete = new SQLDelete <CreatureAddon>(Tuple.Create("@CGUID+0", "@CGUID+" + count));
                result.Append(addonDelete.Build());
                var addonSql = new SQLInsert <CreatureAddon>(addonRows, false);
                result.Append(addonSql.Build());
            }

            return(result.ToString());
        }
示例#34
0
        private static MovementInfo ReadMovementStatusData(Packet packet, object index)
        {
            var moveInfo = new MovementInfo();

            packet.ReadPackedGuid128("MoverGUID", index);

            packet.ReadUInt32("MoveIndex", index);
            moveInfo.Position    = packet.ReadVector3("Position", index);
            moveInfo.Orientation = packet.ReadSingle("Orientation", index);

            packet.ReadSingle("Pitch", index);
            packet.ReadSingle("StepUpStartElevation", index);

            var int152 = packet.ReadInt32("Int152", index);

            packet.ReadInt32("Int168", index);

            for (var i = 0; i < int152; i++)
            {
                packet.ReadPackedGuid128("RemoveForcesIDs", index, i);
            }

            packet.ResetBitReader();

            moveInfo.Flags      = (MovementFlag)packet.ReadBitsE <Enums.MovementFlag>("Movement Flags", 30, index);
            moveInfo.FlagsExtra = packet.ReadBitsE <MovementFlagExtra>("Extra Movement Flags", ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173) ? 16 : 15, index);

            var hasTransport = packet.ReadBit("Has Transport Data", index);
            var hasFall      = packet.ReadBit("Has Fall Data", index);

            packet.ReadBit("HasSpline", index);
            packet.ReadBit("HeightChangeFailed", index);
            packet.ReadBit("RemoteTimeValid", index);

            if (hasTransport)
            {
                packet.ReadPackedGuid128("Transport Guid", index);
                packet.ReadVector4("Transport Position", index);
                packet.ReadSByte("Transport Seat", index);
                packet.ReadInt32("Transport Time", index);

                packet.ResetBitReader();

                var hasPrevMoveTime = packet.ReadBit("HasPrevMoveTime", index);
                var hasVehicleRecID = packet.ReadBit("HasVehicleRecID", index);

                if (hasPrevMoveTime)
                {
                    packet.ReadUInt32("PrevMoveTime", index);
                }

                if (hasVehicleRecID)
                {
                    packet.ReadUInt32("VehicleRecID", index);
                }
            }

            if (hasFall)
            {
                packet.ReadUInt32("Fall Time", index);
                packet.ReadSingle("JumpVelocity", index);

                packet.ResetBitReader();
                var bit20 = packet.ReadBit("Has Fall Direction", index);
                if (bit20)
                {
                    packet.ReadVector2("Fall", index);
                    packet.ReadSingle("Horizontal Speed", index);
                }
            }

            return(moveInfo);
        }
示例#35
0
        public static void HandlePetSpells(Packet packet)
        {
            var guid = packet.ReadGuid("GUID");

            // Equal to "Clear spells" pre cataclysm
            if (guid.Full == 0)
            {
                return;
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                packet.ReadEnum <CreatureFamily>("Pet Family", TypeCode.UInt16); // vehicles -> 0
            }
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
            {
                packet.ReadUInt16("Unk UInt16");
            }

            packet.ReadUInt32("Expiration Time");

            ReadPetFlags(ref packet);

            var       isPet             = guid.GetHighType() == HighGuidType.Pet;
            var       isVehicle         = guid.GetHighType() == HighGuidType.Vehicle;
            var       isMinion          = guid.GetHighType() == HighGuidType.Unit;
            const int maxCreatureSpells = 10;
            var       spells            = new List <uint>(maxCreatureSpells);

            for (var i = 0; i < maxCreatureSpells; i++) // Read pet/vehicle spell ids
            {
                var spell16 = packet.ReadUInt16();
                var spell8  = packet.ReadByte();
                var spellId = spell16 + (spell8 << 16);
                var slot    = packet.ReadByte("Slot", i);

                if (spellId <= 4)
                {
                    packet.AddValue("Action", spellId, i);
                }
                else
                {
                    packet.AddValue("Spell", StoreGetters.GetName(StoreNameType.Spell, spellId), i);
                }

                // Spells for pets are on DBCs; also no entry in guid
                // We don't need the actions sent for minions (slots lower than 8)
                if (!isPet && (isVehicle || (isMinion && slot >= 8)))
                {
                    spells.Add((uint)spellId);
                }
            }

            if (spells.Count != 0)
            {
                SpellsX spellsCr;
                spellsCr.Spells = spells.ToArray();
                Storage.SpellsX.Add(guid.GetEntry(), spellsCr, packet.TimeSpan);
            }

            var spellCount = packet.ReadByte("Spell Count"); // vehicles -> 0, pets -> != 0. Could this be auras?

            for (var i = 0; i < spellCount; i++)
            {
                packet.ReadEntry <UInt16>(StoreNameType.Spell, "Spell", i);
                packet.ReadInt16("Active", i);
            }

            var cdCount = packet.ReadByte("Cooldown count");

            for (var i = 0; i < cdCount; i++)
            {
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
                {
                    packet.ReadEntry <UInt32>(StoreNameType.Spell, "Spell", i);
                }
                else
                {
                    packet.ReadEntry <UInt16>(StoreNameType.Spell, "Spell", i);
                }

                packet.ReadUInt16("Category", i);
                packet.ReadUInt32("Cooldown", i);
                packet.ReadUInt32("Category Cooldown", i);
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
            {
                var unkLoopCounter = packet.ReadByte("Unk count");
                for (var i = 0; i < unkLoopCounter; i++)
                {
                    packet.ReadUInt32("Unk UInt32 1", i);
                    packet.ReadByte("Unk Byte", i);
                    packet.ReadUInt32("Unk UInt32 2", i);
                }
            }
        }
示例#36
0
			public AuthIDPersistence( ClientVersion v ) {
				Age = DateTime.Now;
				Version = v;
			}
示例#37
0
 /// <summary>
 /// Convert a client version to it's VTankObject equivalent.
 /// </summary>
 /// <param name="version"></param>
 /// <returns></returns>
 public static VTankObject.Version ToIceVersion(ClientVersion version)
 {
     return new VTankObject.Version(
         version.major, version.minor, version.build, version.revision);
 }