예제 #1
0
        public static string Hotfixes()
        {
            var stringBuilder = new StringBuilder();

            if (BinaryPacketReader.GetLocale() == LocaleConstant.enUS)
            {
                // ReSharper disable once LoopCanBePartlyConvertedToQuery
                foreach (DB2Hash hashValue in Enum.GetValues(typeof(DB2Hash)))
                {
                    if (HotfixSettings.Instance.ShouldLog(hashValue))
                    {
                        HotfixStoreMgr.GetStore(hashValue)?.Serialize(stringBuilder, null);
                    }
                }
            }
            else
            {
                foreach (DB2Hash hashValue in Enum.GetValues(typeof(DB2Hash)))
                {
                    if (!HotfixSettings.Instance.ShouldLog(hashValue))
                    {
                        continue;
                    }

                    var localeBuilder = new StringBuilder();
                    HotfixStoreMgr.GetStore(hashValue)?.Serialize(stringBuilder, localeBuilder);
                    stringBuilder.Append(localeBuilder);
                }
            }

            return(stringBuilder.ToString());
        }
예제 #2
0
 /// <summary>
 /// [addedInVersion, +inf[
 /// </summary>
 /// <param name="name">database field name</param>
 /// <param name="addedInVersion">initial version</param>
 /// <param name="locale">initial locale</param>
 public DBFieldNameAttribute(string name, ClientVersionBuild addedInVersion, LocaleConstant locale)
 {
     if (ClientVersion.AddedInVersion(addedInVersion) && BinaryPacketReader.GetLocale() == locale)
     {
         Name  = name;
         Count = 1;
     }
     else
     {
         Name  = null;
         Count = 0;
     }
 }
예제 #3
0
 /// <summary>
 /// [addedInVersion, +inf[
 /// </summary>
 /// <param name="name">database field name</param>
 /// <param name="locale">initial locale</param>
 public DBFieldNameAttribute(string name, LocaleConstant locale)
 {
     if (BinaryPacketReader.GetLocale() == locale)
     {
         Name  = name;
         Count = 1;
     }
     else
     {
         Name  = null;
         Count = 0;
     }
 }
 private void onReceive(IAsyncResult iar)
 {
     try
     {
         byte[] datagram = udp.EndReceive(iar, ref endpoint);
         udp.BeginReceive(onReceive, null);
         var bpr = new BinaryPacketReader(datagram, true);
         player.updateData(bpr.readUpdateStruct());
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
 }
예제 #5
0
        public bool IsVisible()
        {
            if (Locale != null && Locale != BinaryPacketReader.GetLocale())
            {
                return(false);
            }

            TargetedDatabase target = Settings.TargetedDatabase;

            if (_addedInVersion.HasValue && !_removedInVersion.HasValue)
            {
                return(target >= _addedInVersion.Value);
            }

            if (_addedInVersion.HasValue && _removedInVersion.HasValue)
            {
                return(target >= _addedInVersion.Value && target < _removedInVersion.Value);
            }

            return(true);
        }
예제 #6
0
 private void onReceive(IAsyncResult iar)
 {
     try
     {
         IPEndPoint endpoint = new IPEndPoint(IPAddress.Any, 0);
         byte[]     datagram = udp.EndReceive(iar, ref endpoint);
         udp.BeginReceive(onReceive, null);
         var  bpr      = new BinaryPacketReader(datagram, true);
         uint playerid = bpr.readUInt32();
         var  data     = bpr.readUpdateStruct();
         if (!Client.instance.serverConnection.playersdata.ContainsKey(playerid))
         {
             Client.instance.serverConnection.playersdata.Add(playerid, data);
         }
         else
         {
             Client.instance.serverConnection.playersdata[playerid] = data;
         }
     }
     catch (Exception e)
     {
         Game.Console.Print(e.Message);
     }
 }
예제 #7
0
        public static void HandleQuestQueryResponse(Packet packet)
        {
            packet.ReadInt32("Entry");

            Bit hasData = packet.ReadBit("Has Data");

            if (!hasData)
            {
                return; // nothing to do
            }
            var id = packet.ReadEntry("Quest ID");

            QuestTemplate quest = new QuestTemplate
            {
                ID = (uint)id.Key
            };

            quest.QuestType          = packet.ReadInt32E <QuestType>("QuestType");
            quest.QuestLevel         = packet.ReadInt32("QuestLevel");
            quest.QuestPackageID     = packet.ReadUInt32("QuestPackageID");
            quest.MinLevel           = packet.ReadInt32("QuestMinLevel");
            quest.QuestSortID        = (QuestSort)packet.ReadUInt32("QuestSortID");
            quest.QuestInfoID        = packet.ReadInt32E <QuestInfo>("QuestInfoID");
            quest.SuggestedGroupNum  = packet.ReadUInt32("SuggestedGroupNum");
            quest.RewardNextQuest    = packet.ReadUInt32("RewardNextQuest");
            quest.RewardXPDifficulty = packet.ReadUInt32("RewardXPDifficulty");

            quest.RewardXPMultiplier = packet.ReadSingle("RewardXPMultiplier");

            quest.RewardMoney           = packet.ReadInt32("RewardMoney");
            quest.RewardMoneyDifficulty = packet.ReadUInt32("RewardMoneyDifficulty");

            quest.RewardMoneyMultiplier = packet.ReadSingle("RewardMoneyMultiplier");

            quest.RewardBonusMoney   = packet.ReadUInt32("RewardBonusMoney");
            quest.RewardDisplaySpell = packet.ReadUInt32("RewardDisplaySpell");
            quest.RewardSpellWod     = packet.ReadUInt32("RewardSpell");
            quest.RewardHonorWod     = packet.ReadUInt32("RewardHonor");

            quest.RewardKillHonor = packet.ReadSingle("RewardKillHonor");

            quest.StartItem = packet.ReadUInt32("StartItem");
            quest.Flags     = packet.ReadUInt32E <QuestFlags>("Flags");
            quest.FlagsEx   = packet.ReadUInt32E <QuestFlags2>("FlagsEx");

            quest.RewardItem       = new uint?[4];
            quest.RewardAmount     = new uint?[4];
            quest.ItemDrop         = new uint?[4];
            quest.ItemDropQuantity = new uint?[4];
            for (int i = 0; i < 4; ++i)
            {
                quest.RewardItem[i]       = packet.ReadUInt32("RewardItems", i);
                quest.RewardAmount[i]     = packet.ReadUInt32("RewardAmount", i);
                quest.ItemDrop[i]         = packet.ReadUInt32("ItemDrop", i);
                quest.ItemDropQuantity[i] = packet.ReadUInt32("ItemDropQuantity", i);
            }

            quest.RewardChoiceItemID        = new uint?[6];
            quest.RewardChoiceItemQuantity  = new uint?[6];
            quest.RewardChoiceItemDisplayID = new uint?[6];
            for (int i = 0; i < 6; ++i) // CliQuestInfoChoiceItem
            {
                quest.RewardChoiceItemID[i]        = packet.ReadUInt32("RewardChoiceItemID", i);
                quest.RewardChoiceItemQuantity[i]  = packet.ReadUInt32("RewardChoiceItemQuantity", i);
                quest.RewardChoiceItemDisplayID[i] = packet.ReadUInt32("RewardChoiceItemDisplayID", i);
            }

            quest.POIContinent = packet.ReadUInt32("POIContinent");

            quest.POIx = packet.ReadSingle("POIx");
            quest.POIy = packet.ReadSingle("POIy");

            quest.POIPriorityWod      = packet.ReadInt32("POIPriority");
            quest.RewardTitle         = packet.ReadUInt32("RewardTitle");
            quest.RewardTalents       = packet.ReadUInt32("RewardTalents");
            quest.RewardArenaPoints   = packet.ReadUInt32("RewardArenaPoints");
            quest.RewardSkillLineID   = packet.ReadUInt32("RewardSkillLineID");
            quest.RewardNumSkillUps   = packet.ReadUInt32("RewardNumSkillUps");
            quest.QuestGiverPortrait  = packet.ReadUInt32("PortraitGiver");
            quest.QuestTurnInPortrait = packet.ReadUInt32("PortraitTurnIn");

            quest.RewardFactionID       = new uint?[5];
            quest.RewardFactionValue    = new int?[5];
            quest.RewardFactionOverride = new int?[5];
            for (int i = 0; i < 5; ++i)
            {
                quest.RewardFactionID[i]       = packet.ReadUInt32("RewardFactionID", i);
                quest.RewardFactionValue[i]    = packet.ReadInt32("RewardFactionValue", i);
                quest.RewardFactionOverride[i] = packet.ReadInt32("RewardFactionOverride", i);
            }

            quest.RewardFactionFlags = packet.ReadUInt32("RewardFactionFlags");

            quest.RewardCurrencyID    = new uint?[4];
            quest.RewardCurrencyCount = new uint?[4];
            for (int i = 0; i < 4; ++i)
            {
                quest.RewardCurrencyID[i]    = packet.ReadUInt32("RewardCurrencyID");
                quest.RewardCurrencyCount[i] = packet.ReadUInt32("RewardCurrencyQty");
            }

            quest.SoundAccept = packet.ReadUInt32("AcceptedSoundKitID");
            quest.SoundTurnIn = packet.ReadUInt32("CompleteSoundKitID");
            quest.AreaGroupID = packet.ReadUInt32("AreaGroupID");
            quest.TimeAllowed = packet.ReadUInt32("TimeAllowed");
            uint int2946 = packet.ReadUInt32("CliQuestInfoObjective");

            quest.AllowableRacesWod = packet.ReadInt32("AllowableRaces");

            for (int i = 0; i < int2946; ++i)
            {
                var objectiveId = packet.ReadEntry("Id", i);

                QuestObjective questInfoObjective = new QuestObjective
                {
                    ID      = (uint)objectiveId.Key,
                    QuestID = (uint)id.Key
                };
                questInfoObjective.Type         = packet.ReadByteE <QuestRequirementType>("Quest Requirement Type", i);
                questInfoObjective.StorageIndex = packet.ReadSByte("StorageIndex", i);
                questInfoObjective.ObjectID     = packet.ReadInt32("ObjectID", i);
                questInfoObjective.Amount       = packet.ReadInt32("Amount", i);
                questInfoObjective.Flags        = packet.ReadUInt32("Flags", i);
                questInfoObjective.UnkFloat     = packet.ReadSingle("Float5", i);

                int int280 = packet.ReadInt32("VisualEffects", i);
                for (int j = 0; j < int280; ++j)
                {
                    QuestVisualEffect questVisualEffect = new QuestVisualEffect
                    {
                        ID           = questInfoObjective.ID,
                        Index        = (uint)j,
                        VisualEffect = packet.ReadInt32("VisualEffectId", i, j)
                    };

                    Storage.QuestVisualEffects.Add(questVisualEffect, packet.TimeSpan);
                }

                packet.ResetBitReader();

                uint bits6 = packet.ReadBits(8);
                questInfoObjective.Description = packet.ReadWoWString("Description", bits6, i);

                if (BinaryPacketReader.GetLocale() != LocaleConstant.enUS && questInfoObjective.Description != string.Empty)
                {
                    QuestObjectivesLocale localesQuestObjectives = new QuestObjectivesLocale
                    {
                        ID           = (uint)objectiveId.Key,
                        QuestId      = (uint)id.Key,
                        StorageIndex = questInfoObjective.StorageIndex,
                        Description  = questInfoObjective.Description
                    };

                    Storage.LocalesQuestObjectives.Add(localesQuestObjectives, packet.TimeSpan);
                }

                Storage.QuestObjectives.Add(questInfoObjective, packet.TimeSpan);
            }

            packet.ResetBitReader();

            uint bits26   = packet.ReadBits(9);
            uint bits154  = packet.ReadBits(12);
            uint bits904  = packet.ReadBits(12);
            uint bits1654 = packet.ReadBits(9);
            uint bits1789 = packet.ReadBits(10);
            uint bits2045 = packet.ReadBits(8);
            uint bits2109 = packet.ReadBits(10);
            uint bits2365 = packet.ReadBits(8);
            uint bits2429 = packet.ReadBits(11);

            quest.LogTitle             = packet.ReadWoWString("LogTitle", bits26);
            quest.LogDescription       = packet.ReadWoWString("LogDescription", bits154);
            quest.QuestDescription     = packet.ReadWoWString("QuestDescription", bits904);
            quest.AreaDescription      = packet.ReadWoWString("AreaDescription", bits1654);
            quest.QuestGiverTextWindow = packet.ReadWoWString("PortraitGiverText", bits1789);
            quest.QuestGiverTargetName = packet.ReadWoWString("PortraitGiverName", bits2045);
            quest.QuestTurnTextWindow  = packet.ReadWoWString("PortraitTurnInText", bits2109);
            quest.QuestTurnTargetName  = packet.ReadWoWString("PortraitTurnInName", bits2365);
            quest.QuestCompletionLog   = packet.ReadWoWString("QuestCompletionLog", bits2429);

            if (BinaryPacketReader.GetLocale() != LocaleConstant.enUS)
            {
                LocalesQuest localesQuest = new LocalesQuest
                {
                    ID                 = (uint)id.Key,
                    Locale             = BinaryPacketReader.GetClientLocale(),
                    LogTitle           = quest.LogTitle,
                    LogDescription     = quest.LogDescription,
                    QuestDescription   = quest.QuestDescription,
                    AreaDescription    = quest.AreaDescription,
                    PortraitGiverText  = quest.QuestGiverTextWindow,
                    PortraitGiverName  = quest.QuestGiverTargetName,
                    PortraitTurnInText = quest.QuestTurnTextWindow,
                    PortraitTurnInName = quest.QuestTurnTargetName,
                    QuestCompletionLog = quest.QuestCompletionLog
                };

                Storage.LocalesQuests.Add(localesQuest, packet.TimeSpan);
            }

            Storage.QuestTemplates.Add(quest, packet.TimeSpan);
        }
예제 #8
0
        public static void HandleDBReply(Packet packet)
        {
            var type      = packet.ReadUInt32E <DB2Hash>("TableHash");
            var entry     = packet.ReadInt32("RecordID");
            var timeStamp = packet.ReadUInt32();

            packet.AddValue("Timestamp", Utilities.GetDateTimeFromUnixTime(timeStamp));
            var allow = packet.ReadBit("Allow");

            var size    = packet.ReadInt32("Size");
            var data    = packet.ReadBytes(size);
            var db2File = new Packet(data, packet.Opcode, packet.Time, packet.Direction, packet.Number, packet.Writer, packet.FileName);

            if (entry < 0 || !allow)
            {
                packet.WriteLine("Row {0} has been removed.", -entry);
                HotfixStoreMgr.RemoveRecord(type, entry);
            }
            else
            {
                switch (type)
                {
                case DB2Hash.BroadcastText:
                {
                    var bct = new BroadcastText()
                    {
                        ID    = (uint)entry,
                        Text  = db2File.ReadCString("Text"),
                        Text1 = db2File.ReadCString("Text1"),
                    };

                    bct.EmoteID    = new ushort?[3];
                    bct.EmoteDelay = new ushort?[3];

                    for (int i = 0; i < 3; ++i)
                    {
                        bct.EmoteID[i] = db2File.ReadUInt16("EmoteID", i);
                    }
                    for (int i = 0; i < 3; ++i)
                    {
                        bct.EmoteDelay[i] = db2File.ReadUInt16("EmoteDelay", i);
                    }

                    bct.EmotesID   = db2File.ReadUInt16("EmotesID");
                    bct.LanguageID = db2File.ReadByte("LanguageID");
                    bct.Flags      = db2File.ReadByte("Flags");

                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_3_5_25848))
                    {
                        bct.ConditionID = db2File.ReadUInt32("ConditionID");
                    }

                    bct.SoundEntriesID = new uint?[2];
                    for (int i = 0; i < 2; ++i)
                    {
                        bct.SoundEntriesID[i] = db2File.ReadUInt32("SoundEntriesID", i);
                    }

                    if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_0_3_22248) && ClientVersion.RemovedInVersion(ClientVersionBuild.V7_3_5_25848))
                    {
                        bct.ConditionID = db2File.ReadUInt32("ConditionID");
                    }

                    Storage.BroadcastTexts.Add(bct, packet.TimeSpan);

                    if (BinaryPacketReader.GetLocale() != LocaleConstant.enUS)
                    {
                        BroadcastTextLocale lbct = new BroadcastTextLocale
                        {
                            ID        = bct.ID,
                            TextLang  = bct.Text,
                            Text1Lang = bct.Text1
                        };
                        Storage.BroadcastTextLocales.Add(lbct, packet.TimeSpan);
                    }
                    break;
                }

                default:
                    HotfixStoreMgr.AddRecord(type, entry, db2File);
                    break;
                }

                db2File.ClosePacket(false);
            }
        }
예제 #9
0
        public static void HandleCreatureQueryResponse(Packet packet)
        {
            var entry   = packet.ReadEntry("Entry");
            Bit hasData = packet.ReadBit();

            if (!hasData)
            {
                return; // nothing to do
            }
            CreatureTemplate creature = new CreatureTemplate
            {
                Entry = (uint)entry.Key
            };

            packet.ReadBits(11);
            uint qItemCount = packet.ReadBits(22);
            int  lenS4      = (int)packet.ReadBits(6);

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

            var stringLens = new int[4][];

            for (int i = 0; i < 4; i++)
            {
                stringLens[i]    = new int[2];
                stringLens[i][0] = (int)packet.ReadBits(11);
                stringLens[i][1] = (int)packet.ReadBits(11);
            }

            int lenS5 = (int)packet.ReadBits(11);

            packet.ResetBitReader();

            creature.Family            = packet.ReadInt32E <CreatureFamily>("Family");
            creature.RequiredExpansion = packet.ReadUInt32E <ClientType>("Expansion");
            creature.Type = packet.ReadInt32E <CreatureType>("Type");

            if (lenS5 > 1)
            {
                creature.SubName = packet.ReadCString("Sub Name");
            }

            creature.ModelIDs    = new uint?[4];
            creature.ModelIDs[0] = packet.ReadUInt32("Display ID 0");
            creature.ModelIDs[3] = packet.ReadUInt32("Display ID 3");

            //TODO: move to creature_questitems
            //creature.QuestItems = new uint[qItemCount];
            for (int i = 0; i < qItemCount; ++i)
            {
                /*creature.QuestItems[i] = (uint)*/ packet.ReadInt32 <ItemId>("Quest Item", i);
            }

            var name       = new string[4];
            var femaleName = new string[4];

            for (int i = 0; i < 4; ++i)
            {
                if (stringLens[i][0] > 1)
                {
                    name[i] = packet.ReadCString("Name", i);
                }
                if (stringLens[i][1] > 1)
                {
                    femaleName[i] = packet.ReadCString("Female Name", i);
                }
            }
            creature.Name       = name[0];
            creature.FemaleName = femaleName[0];

            if (lenS4 > 1)
            {
                creature.IconName = packet.ReadCString("Icon Name");
            }

            creature.TypeFlags  = packet.ReadUInt32E <CreatureTypeFlag>("Type Flags");
            creature.TypeFlags2 = packet.ReadUInt32("Creature Type Flags 2"); // Missing enum

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

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

            creature.KillCredits = new uint?[2];
            for (int i = 0; i < 2; ++i)
            {
                creature.KillCredits[i] = packet.ReadUInt32("Kill Credit", i);
            }

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

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

            creature.ModelIDs[1] = packet.ReadUInt32("Display ID 1");
            creature.ModelIDs[2] = packet.ReadUInt32("Display ID 2");

            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);
        }
예제 #10
0
 private static string GetPath()
 {
     return(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + Settings.DBCPath + @"\" + BinaryPacketReader.GetLocale() + @"\");
 }
예제 #11
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);
        }
예제 #12
0
        public static void HandleQuestQueryResponse(Packet packet)
        {
            packet.ReadInt32("Entry");

            Bit hasData = packet.ReadBit("Has Data");

            if (!hasData)
            {
                return; // nothing to do
            }
            var id = packet.ReadEntry("Quest ID");

            QuestTemplate quest = new QuestTemplate
            {
                ID = (uint)id.Key
            };

            quest.QuestType  = packet.ReadInt32E <QuestType>("QuestType");
            quest.QuestLevel = packet.ReadInt32("QuestLevel");
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_3_5_25848))
            {
                quest.QuestMaxScalingLevel = packet.ReadInt32("QuestMaxScalingLevel");
            }
            quest.QuestPackageID     = packet.ReadUInt32("QuestPackageID");
            quest.MinLevel           = packet.ReadInt32("QuestMinLevel");
            quest.QuestSortID        = (QuestSort)packet.ReadUInt32("QuestSortID");
            quest.QuestInfoID        = packet.ReadInt32E <QuestInfo>("QuestInfoID");
            quest.SuggestedGroupNum  = packet.ReadUInt32("SuggestedGroupNum");
            quest.RewardNextQuest    = packet.ReadUInt32("RewardNextQuest");
            quest.RewardXPDifficulty = packet.ReadUInt32("RewardXPDifficulty");

            quest.RewardXPMultiplier = packet.ReadSingle("RewardXPMultiplier");

            quest.RewardMoney           = packet.ReadInt32("RewardMoney");
            quest.RewardMoneyDifficulty = packet.ReadUInt32("RewardMoneyDifficulty");

            quest.RewardMoneyMultiplier = packet.ReadSingle("RewardMoneyMultiplier");

            quest.RewardBonusMoney = packet.ReadUInt32("RewardBonusMoney");

            quest.RewardDisplaySpellLegion = new uint?[3];
            for (int i = 0; i < 3; ++i)
            {
                quest.RewardDisplaySpellLegion[i] = packet.ReadUInt32("RewardDisplaySpell", i);
            }

            quest.RewardSpellWod = packet.ReadUInt32("RewardSpell");
            quest.RewardHonorWod = packet.ReadUInt32("RewardHonor");

            quest.RewardKillHonor = packet.ReadSingle("RewardKillHonor");

            quest.RewardArtifactXPDifficulty = packet.ReadUInt32("RewardArtifactXPDifficulty");
            quest.RewardArtifactXPMultiplier = packet.ReadSingle("RewardArtifactXPMultiplier");
            quest.RewardArtifactCategoryID   = packet.ReadUInt32("RewardArtifactCategoryID");

            quest.StartItem = packet.ReadUInt32("StartItem");
            quest.Flags     = packet.ReadUInt32E <QuestFlags>("Flags");
            quest.FlagsEx   = packet.ReadUInt32E <QuestFlags2>("FlagsEx");

            quest.RewardItem       = new uint?[4];
            quest.RewardAmount     = new uint?[4];
            quest.ItemDrop         = new uint?[4];
            quest.ItemDropQuantity = new uint?[4];
            for (int i = 0; i < 4; ++i)
            {
                quest.RewardItem[i]       = packet.ReadUInt32("RewardItems", i);
                quest.RewardAmount[i]     = packet.ReadUInt32("RewardAmount", i);
                quest.ItemDrop[i]         = packet.ReadUInt32("ItemDrop", i);
                quest.ItemDropQuantity[i] = packet.ReadUInt32("ItemDropQuantity", i);
            }

            quest.RewardChoiceItemID        = new uint?[6];
            quest.RewardChoiceItemQuantity  = new uint?[6];
            quest.RewardChoiceItemDisplayID = new uint?[6];
            for (int i = 0; i < 6; ++i) // CliQuestInfoChoiceItem
            {
                quest.RewardChoiceItemID[i]        = packet.ReadUInt32("RewardChoiceItemID", i);
                quest.RewardChoiceItemQuantity[i]  = packet.ReadUInt32("RewardChoiceItemQuantity", i);
                quest.RewardChoiceItemDisplayID[i] = packet.ReadUInt32("RewardChoiceItemDisplayID", i);
            }

            quest.POIContinent = packet.ReadUInt32("POIContinent");

            quest.POIx = packet.ReadSingle("POIx");
            quest.POIy = packet.ReadSingle("POIy");

            quest.POIPriorityWod      = packet.ReadInt32("POIPriority");
            quest.RewardTitle         = packet.ReadUInt32("RewardTitle");
            quest.RewardArenaPoints   = packet.ReadUInt32("RewardArenaPoints");
            quest.RewardSkillLineID   = packet.ReadUInt32("RewardSkillLineID");
            quest.RewardNumSkillUps   = packet.ReadUInt32("RewardNumSkillUps");
            quest.QuestGiverPortrait  = packet.ReadUInt32("PortraitGiver");
            quest.QuestTurnInPortrait = packet.ReadUInt32("PortraitTurnIn");

            quest.RewardFactionID       = new uint?[5];
            quest.RewardFactionOverride = new int?[5];
            quest.RewardFactionValue    = new int?[5];
            quest.RewardFactionCapIn    = new int?[5];
            for (int i = 0; i < 5; ++i)
            {
                quest.RewardFactionID[i]       = packet.ReadUInt32("RewardFactionID", i);
                quest.RewardFactionValue[i]    = packet.ReadInt32("RewardFactionValue", i);
                quest.RewardFactionOverride[i] = packet.ReadInt32("RewardFactionOverride", i);
                quest.RewardFactionCapIn[i]    = packet.ReadInt32("RewardFactionCapIn", i);
            }

            quest.RewardFactionFlags = packet.ReadUInt32("RewardFactionFlags");

            quest.RewardCurrencyID    = new uint?[4];
            quest.RewardCurrencyCount = new uint?[4];
            for (int i = 0; i < 4; ++i)
            {
                quest.RewardCurrencyID[i]    = packet.ReadUInt32("RewardCurrencyID");
                quest.RewardCurrencyCount[i] = packet.ReadUInt32("RewardCurrencyQty");
            }

            quest.SoundAccept = packet.ReadUInt32("AcceptedSoundKitID");
            quest.SoundTurnIn = packet.ReadUInt32("CompleteSoundKitID");
            quest.AreaGroupID = packet.ReadUInt32("AreaGroupID");
            quest.TimeAllowed = packet.ReadUInt32("TimeAllowed");
            uint cliQuestInfoObjective = packet.ReadUInt32("CliQuestInfoObjective");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_3_5_25848))
            {
                quest.AllowableRacesWod = packet.ReadUInt64("AllowableRaces");
            }
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_0_3_22248) && ClientVersion.RemovedInVersion(ClientVersionBuild.V7_3_5_25848))
            {
                quest.AllowableRacesWod = (uint)packet.ReadInt32("AllowableRaces");
            }
            quest.QuestRewardID = packet.ReadInt32("QuestRewardID");

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_2_0_23826))
            {
                quest.Expansion = packet.ReadInt32("Expansion");
            }

            packet.ResetBitReader();

            uint logTitleLen             = packet.ReadBits(9);
            uint logDescriptionLen       = packet.ReadBits(12);
            uint questDescriptionLen     = packet.ReadBits(12);
            uint areaDescriptionLen      = packet.ReadBits(9);
            uint questGiverTextWindowLen = packet.ReadBits(10);
            uint questGiverTargetNameLen = packet.ReadBits(8);
            uint questTurnTextWindowLen  = packet.ReadBits(10);
            uint questTurnTargetNameLen  = packet.ReadBits(8);
            uint questCompletionLogLen   = packet.ReadBits(11);

            for (uint i = 0; i < cliQuestInfoObjective; ++i)
            {
                var objectiveId = packet.ReadEntry("Id", i);

                QuestObjective questInfoObjective = new QuestObjective
                {
                    ID      = (uint)objectiveId.Key,
                    QuestID = (uint)id.Key
                };
                questInfoObjective.Type         = packet.ReadByteE <QuestRequirementType>("Quest Requirement Type", i);
                questInfoObjective.StorageIndex = packet.ReadSByte("StorageIndex", i);
                questInfoObjective.Order        = i;
                questInfoObjective.ObjectID     = packet.ReadInt32("ObjectID", i);
                questInfoObjective.Amount       = packet.ReadInt32("Amount", i);
                questInfoObjective.Flags        = packet.ReadUInt32("Flags", i);
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V7_1_0_22900))
                {
                    questInfoObjective.Flags2 = packet.ReadUInt32("Flags2", i);
                }
                questInfoObjective.ProgressBarWeight = packet.ReadSingle("ProgressBarWeight", i);

                int visualEffectsCount = packet.ReadInt32("VisualEffects", i);
                for (uint j = 0; j < visualEffectsCount; ++j)
                {
                    QuestVisualEffect questVisualEffect = new QuestVisualEffect
                    {
                        ID           = questInfoObjective.ID,
                        Index        = j,
                        VisualEffect = packet.ReadInt32("VisualEffectId", i, j)
                    };

                    Storage.QuestVisualEffects.Add(questVisualEffect, packet.TimeSpan);
                }

                packet.ResetBitReader();

                uint bits6 = packet.ReadBits(8);
                questInfoObjective.Description = packet.ReadWoWString("Description", bits6, i);

                if (BinaryPacketReader.GetLocale() != LocaleConstant.enUS && questInfoObjective.Description != string.Empty)
                {
                    QuestObjectivesLocale localesQuestObjectives = new QuestObjectivesLocale
                    {
                        ID           = (uint)objectiveId.Key,
                        QuestId      = (uint)id.Key,
                        StorageIndex = questInfoObjective.StorageIndex,
                        Description  = questInfoObjective.Description
                    };

                    Storage.LocalesQuestObjectives.Add(localesQuestObjectives, packet.TimeSpan);
                }

                Storage.QuestObjectives.Add(questInfoObjective, packet.TimeSpan);
            }

            quest.LogTitle             = packet.ReadWoWString("LogTitle", logTitleLen);
            quest.LogDescription       = packet.ReadWoWString("LogDescription", logDescriptionLen);
            quest.QuestDescription     = packet.ReadWoWString("QuestDescription", questDescriptionLen);
            quest.AreaDescription      = packet.ReadWoWString("AreaDescription", areaDescriptionLen);
            quest.QuestGiverTextWindow = packet.ReadWoWString("PortraitGiverText", questGiverTextWindowLen);
            quest.QuestGiverTargetName = packet.ReadWoWString("PortraitGiverName", questGiverTargetNameLen);
            quest.QuestTurnTextWindow  = packet.ReadWoWString("PortraitTurnInText", questTurnTextWindowLen);
            quest.QuestTurnTargetName  = packet.ReadWoWString("PortraitTurnInName", questTurnTargetNameLen);
            quest.QuestCompletionLog   = packet.ReadWoWString("QuestCompletionLog", questCompletionLogLen);

            if (BinaryPacketReader.GetLocale() != LocaleConstant.enUS)
            {
                LocalesQuest localesQuest = new LocalesQuest
                {
                    ID                 = (uint)id.Key,
                    LogTitle           = quest.LogTitle,
                    LogDescription     = quest.LogDescription,
                    QuestDescription   = quest.QuestDescription,
                    AreaDescription    = quest.AreaDescription,
                    PortraitGiverText  = quest.QuestGiverTextWindow,
                    PortraitGiverName  = quest.QuestGiverTargetName,
                    PortraitTurnInText = quest.QuestTurnTextWindow,
                    PortraitTurnInName = quest.QuestTurnTargetName,
                    QuestCompletionLog = quest.QuestCompletionLog
                };

                Storage.LocalesQuests.Add(localesQuest, packet.TimeSpan);
            }

            Storage.QuestTemplates.Add(quest, packet.TimeSpan);
        }
예제 #13
0
        public static void HandleCreatureQueryResponse(Packet packet)
        {
            var entry = packet.ReadEntry("Entry");

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

            Bit hasData = packet.ReadBit();

            if (!hasData)
            {
                return; // nothing to do
            }
            packet.ResetBitReader();
            uint titleLen      = packet.ReadBits(11);
            uint titleAltLen   = packet.ReadBits(11);
            uint cursorNameLen = packet.ReadBits(6);

            creature.RacialLeader = packet.ReadBit("Leader");

            var stringLens = new int[4][];

            for (int i = 0; i < 4; i++)
            {
                stringLens[i]    = new int[2];
                stringLens[i][0] = (int)packet.ReadBits(11);
                stringLens[i][1] = (int)packet.ReadBits(11);
            }

            for (var i = 0; i < 4; ++i)
            {
                if (stringLens[i][0] > 1)
                {
                    string name = packet.ReadCString("Name");
                    if (i == 0)
                    {
                        creature.Name = name;
                    }
                }
                if (stringLens[i][1] > 1)
                {
                    string nameAlt = packet.ReadCString("NameAlt");
                    if (i == 0)
                    {
                        creature.FemaleName = nameAlt;
                    }
                }
            }

            creature.TypeFlags  = packet.ReadUInt32E <CreatureTypeFlag>("Type Flags");
            creature.TypeFlags2 = packet.ReadUInt32("Creature Type Flags 2");

            creature.Type   = packet.ReadInt32E <CreatureType>("CreatureType");
            creature.Family = packet.ReadInt32E <CreatureFamily>("CreatureFamily");
            creature.Rank   = packet.ReadInt32E <CreatureRank>("Classification");

            creature.KillCredits = new uint?[2];
            for (int i = 0; i < 2; ++i)
            {
                creature.KillCredits[i] = packet.ReadUInt32("ProxyCreatureID", i);
            }

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

            creature.HealthModifier = packet.ReadSingle("HpMulti");
            creature.ManaModifier   = packet.ReadSingle("EnergyMulti");

            uint questItems = packet.ReadUInt32("QuestItems");

            creature.MovementID             = packet.ReadUInt32("CreatureMovementInfoID");
            creature.HealthScalingExpansion = packet.ReadUInt32E <ClientType>("HealthScalingExpansion");
            creature.RequiredExpansion      = packet.ReadUInt32E <ClientType>("RequiredExpansion");
            creature.VignetteID             = packet.ReadUInt32("VignetteID");

            if (titleLen > 1)
            {
                creature.SubName = packet.ReadCString("Title");
            }

            if (titleAltLen > 1)
            {
                creature.TitleAlt = packet.ReadCString("TitleAlt");
            }

            if (cursorNameLen > 1)
            {
                creature.IconName = packet.ReadCString("CursorName");
            }

            for (uint i = 0; i < questItems; ++i)
            {
                CreatureTemplateQuestItem questItem = new CreatureTemplateQuestItem
                {
                    CreatureEntry = (uint)entry.Key,
                    Idx           = i,
                    ItemId        = packet.ReadUInt32 <ItemId>("QuestItem", i)
                };

                Storage.CreatureTemplateQuestItems.Add(questItem, packet.TimeSpan);
            }

            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);
        }
예제 #14
0
        private void onReceive(IAsyncResult iar)
        {
            lock (client)
            {
                try
                {
                    client.client.Client.EndReceive(iar);
                    var bpr = new BinaryPacketReader(buffer);
                    while (bpr.canRead())
                    {
                        Commands command = bpr.readCommand();
                        if (command == Commands.Invalid)
                        {
                            break;
                        }
                        try
                        {
                            switch (command)
                            {
                            case Commands.Client_enableUDPTunnel:
                            {
                                int port = bpr.readInt32();
                                client.udpTunnel = new ClientUDPTunnel(port);
                            }
                            break;

                            case Commands.Client_ping:
                            {
                                Int64 timestamp = bpr.readInt64();
                                write(new BinaryPacketFormatter(Commands.Client_ping, timestamp).getBytes());
                            }
                            break;

                            case Commands.Player_setModel:
                            {
                                string model = MIVSDK.ModelDictionary.getPedModelById(bpr.readUInt32());
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.getPlayer().Model = new Model(model);
                                    }));
                            }
                            break;

                            case Commands.Player_setHeading:
                            {
                                var g = bpr.readSingle();
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.getPlayerPed().Heading = g;
                                    }));
                            }
                            break;


                            case Commands.Player_setVirtualWorld:
                            {
                                uint id     = bpr.readUInt32();
                                uint vworld = bpr.readUInt32();
                                if (client.pedController.Exists(id))
                                {
                                    var instance = client.pedController.GetInstance(id);
                                    instance.VirtualWorld = vworld;
                                }
                            }
                            break;

                            case Commands.Game_setGameTime:
                            {
                                var g = bpr.readInt64();
                                client.enqueueAction(new Action(delegate
                                    {
                                        World.CurrentDayTime = new TimeSpan(g);
                                    }));
                            }
                            break;

                            case Commands.Game_setWeather:
                            {
                                var g = bpr.readByte();
                                client.enqueueAction(new Action(delegate
                                    {
                                        World.Weather = (Weather)(int)g;
                                        GTA.Native.Function.Call("FORCE_WEATHER_NOW", (int)g);
                                    }));
                            }
                            break;

                            case Commands.Game_fadeScreenIn:
                            {
                                var data = bpr.readInt32();
                                client.enqueueAction(new Action(delegate
                                    {
                                        Game.FadeScreenIn(data);
                                    }));
                            }
                            break;

                            case Commands.Game_fadeScreenOut:
                            {
                                var data = bpr.readInt32();
                                client.enqueueAction(new Action(delegate
                                    {
                                        Game.FadeScreenOut(data);
                                    }));
                            }
                            break;

                            case Commands.Game_showLoadingScreen:
                            {
                                var data = bpr.readInt32();
                                client.enqueueAction(new Action(delegate
                                    {
                                        GTA.Native.Function.Call("FORCE_LOADING_SCREEN");
                                    }));
                            }
                            break;

                            case Commands.Game_hideLoadingScreen:
                            {
                                var data = bpr.readInt32();
                                client.enqueueAction(new Action(delegate
                                    {
                                        GTA.Native.Function.Call("DONT_DISPLAY_LOADING_ON_FADE_THIS_FRAME");
                                        Game.FadeScreenIn(1);
                                    }));
                            }
                            break;

                            case Commands.Game_setGravity:
                            {
                                var data = bpr.readSingle();
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.getPlayerPed().GravityMultiplier = data;
                                    }));
                            }
                            break;

                            case Commands.Client_setVirtualWorld:
                            {
                                client.CurrentVirtualWorld = bpr.readUInt32();
                            }
                            break;

                            case Commands.Client_pauseBroadcast:
                            {
                                client.BroadcastingPaused = true;
                            }
                            break;

                            case Commands.Client_resumeBroadcast:
                            {
                                client.BroadcastingPaused = false;
                            }
                            break;

                            case Commands.Client_JSEval:
                            {
                                string script = bpr.readString();
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.jsEngine.Execute(script);
                                    }));
                            }
                            break;

                            case Commands.Vehicle_removePeds:
                            {
                                uint id     = bpr.readUInt32();
                                uint vworld = bpr.readUInt32();
                                if (client.vehicleController.Exists(id))
                                {
                                    var instance = client.vehicleController.GetInstance(id);
                                    if (instance.StreamedIn)
                                    {
                                        instance.gameReference.EveryoneLeaveVehicle();
                                    }
                                }
                            }
                            break;

                            case Commands.Vehicle_repaint:
                            {
                                uint   id    = bpr.readUInt32();
                                ushort color = bpr.readUInt16();
                                if (client.vehicleController.Exists(id))
                                {
                                    var instance = client.vehicleController.GetInstance(id);
                                    if (instance.StreamedIn)
                                    {
                                        instance.gameReference.Color = (ColorIndex)color;
                                    }
                                }
                            }
                            break;

                            case Commands.Vehicle_repair:
                            {
                                uint id = bpr.readUInt32();
                                if (client.vehicleController.Exists(id))
                                {
                                    var instance = client.vehicleController.GetInstance(id);
                                    //instance.health = 100;
                                    if (instance.StreamedIn)
                                    {
                                        instance.gameReference.Repair();
                                    }
                                }
                            }
                            break;

                            case Commands.Vehicle_setModel:
                            {
                                uint   id    = bpr.readUInt32();
                                string model = MIVSDK.ModelDictionary.getVehicleById(bpr.readUInt32());
                                if (client.vehicleController.Exists(id))
                                {
                                    var instance = client.vehicleController.GetInstance(id);
                                    instance.model = model;
                                    if (instance.StreamedIn)
                                    {
                                        instance.gameReference.Delete();
                                    }
                                }
                            }
                            break;

                            case Commands.Vehicle_setOrientation:
                            {
                                uint       id   = bpr.readUInt32();
                                Quaternion quat = fromSharpDX(bpr.readQuaternion());
                                if (client.vehicleController.Exists(id))
                                {
                                    var instance = client.vehicleController.GetInstance(id);
                                    instance.orientation = quat;
                                    if (instance.StreamedIn)
                                    {
                                        instance.gameReference.RotationQuaternion = quat;
                                    }
                                }
                            }
                            break;

                            case Commands.Vehicle_setPosition:
                            {
                                uint    id       = bpr.readUInt32();
                                Vector3 position = fromSharpDX(bpr.readVector3());
                                if (client.vehicleController.Exists(id))
                                {
                                    var instance = client.vehicleController.GetInstance(id);
                                    instance.position = position;
                                    if (instance.StreamedIn)
                                    {
                                        instance.gameReference.Position = position;
                                    }
                                }
                            }
                            break;

                            case Commands.Vehicle_setVelocity:
                            {
                                uint    id       = bpr.readUInt32();
                                Vector3 velocity = fromSharpDX(bpr.readVector3());
                                if (client.vehicleController.Exists(id))
                                {
                                    var instance = client.vehicleController.GetInstance(id);
                                    if (instance.StreamedIn)
                                    {
                                        instance.gameReference.Velocity = velocity;
                                    }
                                }
                            }
                            break;

                            case Commands.Vehicle_setVirtualWorld:
                            {
                                uint id     = bpr.readUInt32();
                                uint vworld = bpr.readUInt32();
                                if (client.vehicleController.Exists(id))
                                {
                                    var instance = client.vehicleController.GetInstance(id);
                                    instance.VirtualWorld = vworld;
                                }
                            }
                            break;

                            case Commands.NPC_setVirtualWorld:
                            {
                                uint id     = bpr.readUInt32();
                                uint vworld = bpr.readUInt32();
                                if (client.npcPedController.Exists(id))
                                {
                                    var instance = client.npcPedController.GetInstance(id);
                                    instance.VirtualWorld = vworld;
                                }
                            }
                            break;

                            case Commands.Player_setHealth:
                            {
                                int h = bpr.readInt32();
                                //client.chatController.writeChat("setting healtcz " + h.ToString());
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.getPlayerPed().Health = h;
                                    }));
                            }
                            break;

                            case Commands.Player_setVehicleHealth:
                            {
                                int h = bpr.readInt32();
                                //client.chatController.writeChat("setting healtcz " + h.ToString());
                                client.enqueueAction(new Action(delegate
                                    {
                                        if (client.getPlayerPed().isInVehicle())
                                        {
                                            if (h <= 0)
                                            {
                                                client.getPlayerPed().CurrentVehicle.Explode();
                                            }
                                            else
                                            {
                                                client.getPlayerPed().CurrentVehicle.Health = h;
                                            }
                                        }
                                    }));
                            }
                            break;

                            case Commands.Chat_writeLine:
                            {
                                client.chatController.writeChat(bpr.readString());
                            }
                            break;

                            case Commands.Player_setPosition:
                            {
                                Vector3 vec = fromSharpDX(bpr.readVector3());
                                //client.chatController.writeChat("OasK");
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.getPlayer().TeleportTo(vec);
                                    }));
                            }
                            break;

                            case Commands.Player_setVelocity:
                            {
                                Vector3 vec = fromSharpDX(bpr.readVector3());
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.getPlayerPed().Velocity = vec;
                                    }));
                            }
                            break;

                            case Commands.InternalClient_finishSpawn:
                            {
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.finishSpawn();
                                    }));
                            }
                            break;

                            case Commands.Camera_setPosition:
                            {
                                var data = fromSharpDX(bpr.readVector3());
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.cameraController.Position = data;
                                    }));
                            }
                            break;

                            case Commands.Camera_setDirection:
                            {
                                var data = fromSharpDX(bpr.readVector3());
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.cameraController.Direction = data;
                                    }));
                            }
                            break;

                            case Commands.Camera_setOrientation:
                            {
                                var data = fromSharpDX(bpr.readVector3());
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.cameraController.Rotation = data;
                                    }));
                            }
                            break;

                            case Commands.Camera_setFOV:
                            {
                                var data = bpr.readSingle();
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.cameraController.FOV = data;
                                    }));
                            }
                            break;

                            case Commands.Camera_lookAt:
                            {
                                var data = fromSharpDX(bpr.readVector3());
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.cameraController.LookAt(data);
                                    }));
                            }
                            break;

                            case Commands.Camera_reset:
                            {
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.cameraController.Reset();
                                    }));
                            }
                            break;

                            case Commands.Player_freeze:
                            {
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.getPlayer().CanControlCharacter = false;
                                    }));
                            }
                            break;

                            case Commands.Player_unfreeze:
                            {
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.getPlayer().CanControlCharacter = true;
                                    }));
                            }
                            break;

                            case Commands.Player_giveWeapon:
                            {
                                Weapon weapon = (Weapon)bpr.readInt32();
                                int    ammo   = bpr.readInt32();
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.getPlayerPed().Weapons.FromType(weapon).Ammo = ammo;
                                    }));
                            }
                            break;

                            case Commands.Global_setPlayerPedText:
                            {
                                uint   playerid = bpr.readUInt32();
                                string text     = bpr.readString();
                                if (client.pedController.Exists(playerid))
                                {
                                    StreamedPed ped = client.pedController.GetInstance(playerid);
                                    ped.CurrentChatMessage = text;
                                }
                            }
                            break;

                            case Commands.Global_setPlayerModel:
                            {
                                uint   playerid = bpr.readUInt32();
                                string model    = MIVSDK.ModelDictionary.getPedModelById(bpr.readUInt32());
                                if (client.playerModels.ContainsKey(playerid))
                                {
                                    client.playerModels[playerid] = model;
                                }
                                else
                                {
                                    client.playerModels.Add(playerid, model);
                                }
                                if (client.pedController.Exists(playerid))
                                {
                                    var player = client.pedController.GetInstance(playerid);
                                    if (player.IsStreamedIn())
                                    {
                                        player.gameReference.Delete();
                                    }
                                }
                            }
                            break;

                            case Commands.Global_setPlayerName:
                            {
                                uint   playerid = bpr.readUInt32();
                                string name     = bpr.readString();
                                if (client.playerNames.ContainsKey(playerid))
                                {
                                    client.playerNames[playerid] = name;
                                }
                                else
                                {
                                    client.playerNames.Add(playerid, name);
                                }
                                if (client.pedController.Exists(playerid))
                                {
                                    var player = client.pedController.GetInstance(playerid);
                                    if (player.IsStreamedIn())
                                    {
                                        player.gameReference.Delete();
                                    }
                                }
                            }
                            break;

                            case Commands.Global_createPlayer:
                            {
                                uint   playerid = bpr.readUInt32();
                                string model    = MIVSDK.ModelDictionary.getPedModelById(bpr.readUInt32());
                                string name     = bpr.readString();

                                if (client.playerNames.ContainsKey(playerid))
                                {
                                    client.playerNames[playerid] = name;
                                }
                                else
                                {
                                    client.playerNames.Add(playerid, name);
                                }

                                if (client.playerModels.ContainsKey(playerid))
                                {
                                    client.playerModels[playerid] = model;
                                }
                                else
                                {
                                    client.playerModels.Add(playerid, model);
                                }

                                client.pedController.Add(playerid, new StreamedPed(client.pedStreamer, model, name, Vector3.Zero, 0, (BlipColor)(playerid % 13)));
                            }
                            break;

                            case Commands.Request_getSelectedPlayer:
                            {
                                uint requestid = bpr.readUInt32();
                                client.enqueueAction(new Action(delegate
                                    {
                                        var peds        = World.GetPeds(client.getPlayerPed().Position, 80.0f);
                                        Ped selectedPed = null;
                                        foreach (var ped in peds)
                                        {
                                            var projected = (Vector2)World.WorldToScreenProject(ped.Position);
                                            if (Math.Abs((projected - new Vector2(Game.Resolution.Width / 2, Game.Resolution.Height / 2)).Length()) < 30.0)
                                            {
                                                selectedPed = ped;
                                                break;
                                            }
                                        }
                                        var bpf = new BinaryPacketFormatter(Commands.Request_getSelectedPlayer);
                                        bpf.Add(requestid);
                                        if (selectedPed != null)
                                        {
                                            bpf.Add(client.pedController.dict.Count(a => a.Value.IsStreamedIn() && a.Value.gameReference == selectedPed) > 0 ? client.pedController.dict.First(a => a.Value.IsStreamedIn() && a.Value.gameReference == selectedPed).Key : 0);
                                        }
                                        else
                                        {
                                            bpf.Add(0);
                                        }
                                        client.serverConnection.write(bpf.getBytes());
                                    }));
                            }
                            break;

                            case Commands.Request_getCameraPosition:
                            {
                                uint requestid = bpr.readUInt32();
                                client.enqueueAction(new Action(delegate
                                    {
                                        var bpf = new BinaryPacketFormatter(Commands.Request_getCameraPosition);
                                        bpf.Add(requestid);
                                        bpf.Add(new SharpDX.Vector3(Game.CurrentCamera.Position.X, Game.CurrentCamera.Position.Y, Game.CurrentCamera.Position.Z));
                                        client.serverConnection.write(bpf.getBytes());
                                    }));
                            }
                            break;

                            case Commands.Request_worldToScreen:
                            {
                                uint requestid = bpr.readUInt32();
                                var  world     = bpr.readVector3();
                                client.enqueueAction(new Action(delegate
                                    {
                                        var bpf = new BinaryPacketFormatter(Commands.Request_worldToScreen);
                                        bpf.Add(requestid);
                                        var screen = (Vector2)World.WorldToScreenProject(new Vector3(world.X, world.Y, world.Z));
                                        bpf.Add(screen.X);
                                        bpf.Add(screen.Y);
                                        client.serverConnection.write(bpf.getBytes());
                                    }));
                            }
                            break;

                            case Commands.Request_isObjectVisible:
                            {
                                uint requestid = bpr.readUInt32();
                                var  position  = bpr.readVector3();
                                client.enqueueAction(new Action(delegate
                                    {
                                        var bpf = new BinaryPacketFormatter(Commands.Request_isObjectVisible);
                                        bpf.Add(requestid);
                                        bpf.Add(new byte[1] {
                                            (byte)(Game.CurrentCamera.isSphereVisible(new Vector3(position.X, position.Y, position.Z), 1.0f) ? 1 : 0)
                                        });
                                        client.serverConnection.write(bpf.getBytes());
                                    }));
                            }
                            break;

                            case Commands.Vehicle_create:
                            {
                                uint       id    = bpr.readUInt32();
                                Vector3    pos   = fromSharpDX(bpr.readVector3());
                                Quaternion rot   = fromSharpDX(bpr.readQuaternion());
                                string     model = MIVSDK.ModelDictionary.getVehicleById(bpr.readUInt32());
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.vehicleController.Add(id, new StreamedVehicle(client.vehicleStreamer, model, pos, rot));
                                    }));
                            }
                            break;

                            case Commands.NPC_create:
                            {
                                //int count = bpr.readInt32();
                                uint    id      = bpr.readUInt32();
                                Vector3 pos     = fromSharpDX(bpr.readVector3());
                                float   heading = bpr.readSingle();
                                string  model   = MIVSDK.ModelDictionary.getPedModelById(bpr.readUInt32());

                                string str = bpr.readString();
                                client.enqueueAction(new Action(delegate
                                    {
                                        client.npcPedController.Add(id, new StreamedPed(client.pedStreamer, model, str, pos, heading, BlipColor.Grey));
                                    }));
                            }
                            break;

                            case Commands.NPC_update:
                            {
                                //int count = bpr.readInt32();
                                uint    id      = bpr.readUInt32();
                                Vector3 pos     = fromSharpDX(bpr.readVector3());
                                float   heading = bpr.readSingle();
                                string  model   = MIVSDK.ModelDictionary.getPedModelById(bpr.readUInt32());

                                string str = bpr.readString();
                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped         = client.npcPedController.GetInstance(id);
                                        ped.position    = pos;
                                        ped.heading     = heading;
                                        ped.model       = model;
                                        ped.networkname = str;
                                    }));
                            }
                            break;

                            case Commands.NPC_setPosition:
                            {
                                uint id = bpr.readUInt32();

                                Vector3 pos = fromSharpDX(bpr.readVector3());

                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped      = client.npcPedController.GetInstance(id);
                                        ped.position = pos;
                                        if (ped.IsStreamedIn())
                                        {
                                            ped.gameReference.Position = pos;
                                        }
                                    }));
                            }
                            break;

                            case Commands.NPC_setHeading:
                            {
                                uint id = bpr.readUInt32();

                                float heading = bpr.readSingle();

                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped     = client.npcPedController.GetInstance(id);
                                        ped.heading = heading;
                                        if (ped.IsStreamedIn())
                                        {
                                            ped.gameReference.Heading = heading;
                                        }
                                    }));
                            }
                            break;

                            case Commands.NPC_runTo:
                            {
                                uint id = bpr.readUInt32();

                                Vector3 pos = fromSharpDX(bpr.readVector3());

                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped      = client.npcPedController.GetInstance(id);
                                        ped.position = pos;
                                        if (ped.IsStreamedIn())
                                        {
                                            ped.animator.refreshAnimationForce();
                                            ped.animator.playAnimation(PedAnimations.RunTo, pos);
                                        }
                                    }));
                            }
                            break;

                            case Commands.NPC_walkTo:
                            {
                                uint id = bpr.readUInt32();

                                Vector3 pos = fromSharpDX(bpr.readVector3());

                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped      = client.npcPedController.GetInstance(id);
                                        ped.position = pos;
                                        if (ped.IsStreamedIn())
                                        {
                                            ped.animator.refreshAnimationForce();
                                            ped.animator.playAnimation(PedAnimations.WalkTo, pos);
                                        }
                                    }));
                            }
                            break;

                            case Commands.NPC_enterVehicle:
                            {
                                uint id = bpr.readUInt32();

                                uint vid = bpr.readUInt32();

                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped        = client.npcPedController.GetInstance(id);
                                        ped.vehicle_id = vid;
                                        var veh        = client.vehicleController.GetInstance(vid);
                                        if (ped.IsStreamedIn() && veh.IsStreamedIn())
                                        {
                                            ped.gameReference.WarpIntoVehicle(veh.gameReference, VehicleSeat.Driver);
                                        }
                                    }));
                            }
                            break;

                            case Commands.NPC_driveTo:
                            {
                                uint id = bpr.readUInt32();

                                Vector3 pos = fromSharpDX(bpr.readVector3());

                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped = client.npcPedController.GetInstance(id);
                                        if (ped.vehicle_id > 0)
                                        {
                                            var veh = client.vehicleController.GetInstance(ped.vehicle_id);
                                            if (ped.IsStreamedIn() && veh.IsStreamedIn())
                                            {
                                                ped.gameReference.Task.DriveTo(veh.gameReference, pos, 999.0f, false, true);
                                            }
                                        }
                                    }));
                            }
                            break;

                            case Commands.NPC_leaveVehicle:
                            {
                                uint id = bpr.readUInt32();

                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped        = client.npcPedController.GetInstance(id);
                                        ped.vehicle_id = 0;
                                        if (ped.IsStreamedIn())
                                        {
                                            ped.gameReference.LeaveVehicle();
                                        }
                                    }));
                            }
                            break;

                            case Commands.NPC_setModel:
                            {
                                uint   id    = bpr.readUInt32();
                                string model = MIVSDK.ModelDictionary.getPedModelById(bpr.readUInt32());

                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped   = client.npcPedController.GetInstance(id);
                                        ped.model = model;
                                        if (ped.IsStreamedIn())
                                        {
                                            ped.gameReference.Delete();
                                        }
                                    }));
                            }
                            break;

                            case Commands.NPC_setImmortal:
                            {
                                uint id     = bpr.readUInt32();
                                byte option = bpr.readByte();

                                client.enqueueAction(new Action(delegate
                                    {
                                        var ped      = client.npcPedController.GetInstance(id);
                                        ped.immortal = option == 1;
                                        if (ped.IsStreamedIn())
                                        {
                                            ped.gameReference.Invincible = option == 1;
                                        }
                                    }));
                            }
                            break;

                            case Commands.NPCDialog_show:
                            {
                                uint     id          = bpr.readUInt32();
                                string   captiontext = bpr.readString();
                                string   texttext    = bpr.readString();
                                string   str         = bpr.readString();
                                string[] split       = str.Split('\x01');
                                client.enqueueAction(new Action(delegate
                                    {
                                        GTA.Forms.Form form = new GTA.Forms.Form();

                                        GTA.Forms.Label caption = new GTA.Forms.Label();
                                        caption.Location        = new System.Drawing.Point(10, 10);
                                        caption.Text            = captiontext;

                                        GTA.Forms.Label text = new GTA.Forms.Label();
                                        text.Location        = new System.Drawing.Point(10, 40);
                                        text.Text            = texttext;

                                        form.Controls.Add(caption);
                                        form.Controls.Add(text);

                                        for (int i = 0; i < split.Length; i++)
                                        {
                                            GTA.Forms.Button button = new GTA.Forms.Button();
                                            button.Location         = new System.Drawing.Point(10, 40 + i * 20);
                                            button.Text             = split[i];

                                            button.MouseDown += (s, o) =>
                                            {
                                                var bpf = new BinaryPacketFormatter(Commands.NPCDialog_sendResponse);
                                                bpf.Add(id);
                                                bpf.Add(new byte[1] {
                                                    (byte)(i - 2)
                                                });
                                                write(bpf.getBytes());

                                                form.Close();
                                            };

                                            form.Controls.Add(button);
                                        }
                                        form.Show();
                                    }));
                            }
                            break;
                            }
                        }
                        catch (Exception e)
                        {
                            Client.log("Failed dispatching command " + command.ToString() + " with " + e.Message + " " + e.StackTrace);
                            client.chatController.writeChat("Failed dispatching command " + command.ToString() + " with " + e.Message + " " + e.StackTrace);
                            client.chatController.writeChat("Disconnected abnormally from server");
                            client.currentState = ClientState.Disconnected;
                        }
                    }

                    client.client.Client.BeginReceive(buffer, 0, buffer.Length, SocketFlags.None, onReceive, null);
                    //}
                }
                catch (Exception e)
                {
                    Client.log("Failed receive with message " + e.Message + " " + e.StackTrace);
                    client.chatController.writeChat("Failed receive with message " + e.Message + " " + e.StackTrace);
                    client.chatController.writeChat("Disconnected abnormally from server");
                    client.currentState = ClientState.Disconnected;
                    //throw e;
                }
            }
        }
        private void onReceive(IAsyncResult iar)
        {
            lock (Connection)
            {
                try
                {
                    int count = Connection.Client.EndReceive(iar);
                }
                catch
                {
                    Console.WriteLine("Client disconnected");
                    return;
                }

                var bpr = new BinaryPacketReader(Buffer);
                while (bpr.canRead())
                {
                    Commands command = bpr.readCommand();
                    if (command == Commands.Invalid)
                    {
                        break;
                    }
                    switch (command)
                    {
                    case Commands.Disconnect:
                    {
                        if (Player != null)
                        {
                            Server.instance.api.invokeOnPlayerDisconnect(Player);
                        }
                    }
                    break;

                    case Commands.Connect:
                    {
                        string nick = bpr.readString();
                        if (OnConnect != null)
                        {
                            OnConnect.Invoke(nick);
                        }
                    }
                    break;

                    case Commands.InternalClient_requestSpawn:
                    {
                        if (Player != null)
                        {
                            Server.instance.api.invokeOnPlayerDie(Player);
                            Server.instance.api.invokeOnPlayerSpawn(Player);
                            var bpf = new BinaryPacketFormatter(Commands.InternalClient_finishSpawn);
                            Player.connection.write(bpf.getBytes());
                        }
                    }
                    break;

                    case Commands.Client_ping:
                    {
                        Int64 timestamp = bpr.readInt64();
                        Int64 current   = DateTime.Now.Ticks;
                        Player.Ping = (int)((current - timestamp) / 10000);
                    }
                    break;

                    case Commands.Request_getSelectedPlayer:
                    {
                        if (Player != null)
                        {
                            uint requestid = bpr.readUInt32();
                            uint playerid  = bpr.readUInt32();
                            Request.dispatch(requestid, playerid);
                        }
                    }
                    break;

                    case Commands.Request_getCameraPosition:
                    {
                        if (Player != null)
                        {
                            uint requestid = bpr.readUInt32();
                            var  vect      = bpr.readVector3();
                            Request.dispatch(requestid, vect);
                        }
                    }
                    break;

                    case Commands.Request_isObjectVisible:
                    {
                        if (Player != null)
                        {
                            uint requestid = bpr.readUInt32();
                            var  vect      = bpr.readByte() == 1;
                            Request.dispatch(requestid, vect);
                        }
                    }
                    break;

                    case Commands.Request_worldToScreen:
                    {
                        if (Player != null)
                        {
                            uint requestid = bpr.readUInt32();
                            var  x         = bpr.readSingle();
                            var  y         = bpr.readSingle();
                            Request.dispatch(requestid, new SharpDX.Vector2(x, y));
                        }
                    }
                    break;

                    case Commands.Chat_sendMessage:
                    {
                        string text = bpr.readString();
                        if (text.StartsWith("/"))
                        {
                            List <string> split = text.Split(' ').ToList();
                            Server.instance.api.invokeOnPlayerSendCommand(Player, split.First().Substring(1), split.Skip(1).ToArray());
                        }
                        else
                        {
                            Server.instance.api.invokeOnPlayerSendText(Player, text);
                        }
                    }
                    break;

                    case Commands.Player_damage:
                    {
                        if (Player != null)
                        {
                            uint playerid = bpr.readUInt32();
                            var  bpf      = new BinaryPacketFormatter(Commands.Player_setHealth);
                            int  newvalue = Server.instance.getPlayerById(playerid).data.ped_health - 10;
                            bpf.Add(newvalue);
                            var damaged_player = Server.instance.getPlayerById(playerid);
                            damaged_player.connection.write(bpf.getBytes());
                            if (newvalue <= 0 && !Player.isDead)
                            {
                                Player.isDead = true;
                                Server.instance.api.invokeOnPlayerDie(damaged_player, Player, (Enums.Weapon)Player.data.weapon);
                            }
                        }
                    }
                    break;

                    case Commands.Vehicle_damage:
                    {
                        if (Player != null)
                        {
                            uint playerid  = bpr.readUInt32();
                            uint vehicleid = bpr.readUInt32();
                            int  delta     = bpr.readInt32();
                            var  bpf       = new BinaryPacketFormatter(Commands.Player_setVehicleHealth);
                            int  newvalue  = Server.instance.vehicleController.getById(vehicleid).health - delta;
                            bpf.Add(newvalue);
                            Server.instance.getPlayerById(playerid).connection.write(bpf.getBytes());
                        }
                    }
                    break;

                    case Commands.Keys_down:
                    {
                        if (Player != null)
                        {
                            int key = bpr.readInt32();
                            Server.instance.api.invokeOnPlayerKeyDown(Player, (System.Windows.Forms.Keys)key);
                        }
                    }
                    break;

                    case Commands.Keys_up:
                    {
                        if (Player != null)
                        {
                            int key = bpr.readInt32();
                            Server.instance.api.invokeOnPlayerKeyUp(Player, (System.Windows.Forms.Keys)key);
                        }
                    }
                    break;

                    case Commands.NPCDialog_sendResponse:
                    {
                        if (Player != null)
                        {
                            uint key    = bpr.readUInt32();
                            byte answer = Buffer[6];
                            ServerNPCDialog.invokeResponse(Player, key, answer);
                        }
                    }
                    break;

                    case Commands.UpdateData:
                    {
                        if (Player != null)
                        {
                            MIVSDK.UpdateDataStruct data = bpr.readUpdateStruct();
                            if (Player.data.ped_health > data.ped_health)
                            {
                                Server.instance.api.invokeOnPlayerTakeDamage(Player, Player.data.ped_health, data.ped_health, Player.data.ped_health - data.ped_health);
                            }
                            Player.updateData(data);
                        }
                    }
                    break;
                    }
                }

                Connection.Client.BeginReceive(Buffer, 0, Buffer.Length, SocketFlags.None, onReceive, null);
            }
        }
예제 #16
0
        public void SerializeStore(HotfixStore <T> store, StringBuilder hotfixBuilder, StringBuilder localeBuilder)
        {
            if (store.Records.Count == 0)
            {
                return;
            }

            var hotfixStructureAttribute = typeof(T).GetCustomAttribute <HotfixStructureAttribute>();

            Debug.Assert(hotfixStructureAttribute != null);

            var propertiesInfos = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public);
            var tableName       = Regex.Replace(hotfixStructureAttribute.Hash.ToString(), @"((?<=.)[A-Z][a-zA-Z]*)|((?<=[a-zA-Z])\d+)",
                                                @"_$1$2", RegexOptions.Compiled).ToLower();

            if (localeBuilder != null && propertiesInfos.Any(
                    propInfo => propInfo.PropertyType == typeof(string) || propInfo.PropertyType == typeof(string[])))
            {
                localeBuilder.AppendLine("SET NAMES 'utf8';");
                localeBuilder.Append($"INSERT INTO `{tableName}_locale` (");
                if (!hotfixStructureAttribute.HasIndexInData)
                {
                    localeBuilder.Append("`ID`, ");
                }
                localeBuilder.Append("`locale`, ");
            }

            hotfixBuilder.AppendLine("SET NAMES 'utf8';");
            hotfixBuilder.Append($"INSERT INTO `{tableName}` (");
            if (!hotfixStructureAttribute.HasIndexInData)
            {
                hotfixBuilder.Append("`ID`, ");
            }

            foreach (var propInfo in propertiesInfos)
            {
                if (propInfo.PropertyType.IsArray)
                {
                    var isString = propInfo.PropertyType.GetElementType() == typeof(string);

                    var arraySizeAttribute = propInfo.GetCustomAttribute <HotfixArrayAttribute>();
                    for (var i = 0; i < arraySizeAttribute.Size; ++i)
                    {
                        hotfixBuilder.Append($"`{propInfo.Name}{i}`, ");
                        if (localeBuilder != null && isString)
                        {
                            localeBuilder.Append($"{propInfo.Name}{i}_lang`, ");
                        }
                    }
                }
                else
                {
                    hotfixBuilder.Append($"`{propInfo.Name}`, ");
                    if (localeBuilder != null && propInfo.PropertyType == typeof(string))
                    {
                        localeBuilder.Append($"`{propInfo.Name}_lang`, ");
                    }
                }
            }

            hotfixBuilder.AppendLine("`VerifiedBuild`) VALUES");
            localeBuilder?.AppendLine("`VerifiedBuild`) VALUES");

            var remainingCount = store.Records.Count - 1;

            foreach (var kv in store.Records)
            {
                hotfixBuilder.Append("(");
                localeBuilder?.Append("(");
                if (!hotfixStructureAttribute.HasIndexInData)
                {
                    hotfixBuilder.Append($"{kv.Key}, ");
                    localeBuilder?.Append($"{kv.Key}, ");
                }

                localeBuilder?.Append($"{BinaryPacketReader.GetLocale()}, ");
                _serializer((T)kv.Value, hotfixBuilder, localeBuilder);

                hotfixBuilder.AppendLine(remainingCount > 0 ? $"{ClientVersion.BuildInt})," : $"{ClientVersion.BuildInt});");
                localeBuilder?.AppendLine(remainingCount > 0 ? $"{ClientVersion.BuildInt})," : $"{ClientVersion.BuildInt});");
                --remainingCount;
            }

            hotfixBuilder.AppendLine();
            localeBuilder?.AppendLine();
        }