示例#1
0
        public virtual StoreDictionary Bake(string name, string group, bool owned, bool equipped)
        {
            StoreDictionary values = Bake(name);

            values.Add(groupColumn, group);
            if (owned)
            {
                values.Add(balanceColumn, ownedValue);
                if (equipped)
                {
                    values.Add(equippedColumn, equippedValue);
                }
            }
            return(values);
        }
示例#2
0
        public override IEnumerable <StoreDictionary> Get(string collection, StoreList columns, StoreDictionary where, int limit)
        {
            List <StoreDictionary> records = new List <StoreDictionary>();
            JSON names = GetRecords(collection);

            for (int i = 0; i < names.length; i++)
            {
                if (limit == 0)
                {
                    break;
                }
                string name = names[i].stringValue;
                if (IsRecordIncluded(collection, name, where))
                {
                    StoreDictionary record = new StoreDictionary();
                    foreach (string column in columns)
                    {
                        string value = Get("collections." + collection + "." + name + "." + column);
                        record.Add(column, value);
                    }
                    records.Add(record);
                    limit--;
                }
            }
            return(records);
        }
示例#3
0
        // Non-WDB data but nevertheless data that should be saved to gameobject_template
        public static string GameobjectTemplateNonWDB(Dictionary<Guid, GameObject> gameobjects)
        {
            if (gameobjects.Count == 0)
                return String.Empty;

            var templates = new StoreDictionary<uint, GameObjectTemplateNonWDB>();
            foreach (var goT in gameobjects)
            {
                if (templates.ContainsKey(goT.Key.GetEntry()))
                    continue;

                var go = goT.Value;
                var template = new GameObjectTemplateNonWDB
                {
                    Size = go.Size.GetValueOrDefault(1.0f),
                    Faction = go.Faction.GetValueOrDefault(0),
                    Flags = go.Flags.GetValueOrDefault(GameObjectFlag.None)
                };

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

                template.Flags &= ~GameObjectFlag.Triggered;
                template.Flags &= ~GameObjectFlag.Damaged;
                template.Flags &= ~GameObjectFlag.Destroyed;

                templates.Add(goT.Key.GetEntry(), template, null);
            }

            var templatesDb = SQLDatabase.GetDict<uint, GameObjectTemplateNonWDB>(templates.Keys());
            return SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.GameObject);
        }
示例#4
0
        public virtual StoreDictionary Bake(string name, string group, int level, bool owned, bool equipped)
        {
            StoreDictionary values = Bake(name, group, owned, equipped);

            values.Add(levelColumn, level + "");
            return(values);
        }
示例#5
0
        public StoreDictionary Bake(string name, int balance)
        {
            StoreDictionary values = Bake(name);

            values.Add(balanceColumn, balance + "");
            return(values);
        }
 public bool Set(string name, string value)
 {
     if (Set(name, "value", value) == 0)
     {
         StoreDictionary values = Bake(name);
         values.Add("value", value);
         return(Add(values) == 1);
     }
     return(true);
 }
示例#7
0
        public static string CreatureEquip(Dictionary <Guid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

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

            var equips = new StoreDictionary <ushort, CreatureEquipment>();

            foreach (var unit in units)
            {
                var equip = new CreatureEquipment();
                var npc   = unit.Value;
                var entry = (ushort)unit.Key.GetEntry();

                if (npc.Equipment == null || npc.Equipment.Length != 3)
                {
                    continue;
                }

                if (npc.Equipment[0] == 0 && npc.Equipment[1] == 0 && npc.Equipment[2] == 0)
                {
                    continue;
                }

                if (equips.ContainsKey(entry))
                {
                    var existingEquip = equips[entry].Item1;

                    if (existingEquip.ItemEntry1 != npc.Equipment[0] ||
                        existingEquip.ItemEntry2 != npc.Equipment[1] ||
                        existingEquip.ItemEntry3 != npc.Equipment[2])
                    {
                        equips.Remove(entry); // no conflicts
                    }
                    continue;
                }

                equip.ItemEntry1 = npc.Equipment[0];
                equip.ItemEntry2 = npc.Equipment[1];
                equip.ItemEntry3 = npc.Equipment[2];

                equips.Add(entry, equip);
            }

            var entries  = equips.Keys();
            var equipsDb = SQLDatabase.GetDict <ushort, CreatureEquipment>(entries);

            return(SQLUtil.CompareDicts(equips, equipsDb, StoreNameType.Unit));
        }
        public static string ModelData(Dictionary <Guid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

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

            // Build a dictionary with model data; model is the key
            var models = new StoreDictionary <uint, ModelData>();

            foreach (var npc in units.Select(unit => unit.Value))
            {
                uint modelId;
                if (npc.Model.HasValue)
                {
                    modelId = npc.Model.Value;
                }
                else
                {
                    continue;
                }

                // Do not add duplicate models
                if (models.ContainsKey(modelId))
                {
                    continue;
                }

                float scale = npc.Size.GetValueOrDefault(1.0f);
                var   model = new ModelData
                {
                    BoundingRadius = npc.BoundingRadius.GetValueOrDefault(0.306f) / scale,
                    CombatReach    = npc.CombatReach.GetValueOrDefault(1.5f) / scale,
                    Gender         = npc.Gender.GetValueOrDefault(Gender.Male)
                };

                models.Add(modelId, model, null);
            }

            var entries  = models.Keys();
            var modelsDb = SQLDatabase.GetDict <uint, ModelData>(entries, "modelid");

            return(SQLUtil.CompareDicts(models, modelsDb, StoreNameType.None, "modelid"));
        }
示例#9
0
        // Non-WDB data but nevertheless data that should be saved to gameobject_template
        public static string GameobjectTemplateNonWDB(Dictionary <Guid, GameObject> gameobjects)
        {
            if (gameobjects.Count == 0)
            {
                return(string.Empty);
            }

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

            var templates = new StoreDictionary <uint, GameObjectTemplateNonWDB>();

            foreach (var goT in gameobjects)
            {
                if (templates.ContainsKey(goT.Key.GetEntry()))
                {
                    continue;
                }

                var go       = goT.Value;
                var template = new GameObjectTemplateNonWDB
                {
                    Size    = go.Size.GetValueOrDefault(1.0f),
                    Faction = go.Faction.GetValueOrDefault(0),
                    Flags   = go.Flags.GetValueOrDefault(GameObjectFlag.None)
                };

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

                template.Flags &= ~GameObjectFlag.Triggered;
                template.Flags &= ~GameObjectFlag.Damaged;
                template.Flags &= ~GameObjectFlag.Destroyed;

                templates.Add(goT.Key.GetEntry(), template, null);
            }

            var templatesDb = SQLDatabase.GetDict <uint, GameObjectTemplateNonWDB>(templates.Keys());

            return(SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.GameObject));
        }
示例#10
0
        // Non-WDB data but nevertheless data that should be saved to creature_template
        public static string NpcTemplateNonWDB(Dictionary <Guid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

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

            var levels = GetLevels(units);

            var templates = new StoreDictionary <uint, UnitTemplateNonWDB>();

            foreach (var unit in units)
            {
                if (templates.ContainsKey(unit.Key.GetEntry()))
                {
                    continue;
                }

                var npc      = unit.Value;
                var template = new UnitTemplateNonWDB
                {
                    GossipMenuId     = npc.GossipId,
                    MinLevel         = levels[unit.Key.GetEntry()].Item1,
                    MaxLevel         = levels[unit.Key.GetEntry()].Item2,
                    Faction          = npc.Faction.GetValueOrDefault(35),
                    Faction2         = npc.Faction.GetValueOrDefault(35),
                    NpcFlag          = (uint)npc.NpcFlags.GetValueOrDefault(NPCFlags.None),
                    SpeedRun         = npc.Movement.RunSpeed,
                    SpeedWalk        = npc.Movement.WalkSpeed,
                    BaseAttackTime   = npc.MeleeTime.GetValueOrDefault(2000),
                    RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000),
                    UnitClass        = (uint)npc.Class.GetValueOrDefault(Class.Warrior),
                    UnitFlag         = (uint)npc.UnitFlags.GetValueOrDefault(UnitFlags.None),
                    UnitFlag2        = (uint)npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None),
                    DynamicFlag      = (uint)npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None),
                    VehicleId        = npc.Movement.VehicleId,
                    HoverHeight      = npc.HoverHeight.GetValueOrDefault(1.0f)
                };

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

                template.UnitFlag &= ~(uint)UnitFlags.IsInCombat;
                template.UnitFlag &= ~(uint)UnitFlags.PetIsAttackingTarget;
                template.UnitFlag &= ~(uint)UnitFlags.PlayerControlled;
                template.UnitFlag &= ~(uint)UnitFlags.Silenced;
                template.UnitFlag &= ~(uint)UnitFlags.PossessedByPlayer;

                templates.Add(unit.Key.GetEntry(), template, null);
            }

            var templatesDb = SQLDatabase.GetDict <uint, UnitTemplateNonWDB>(templates.Keys());

            return(SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.Unit));
        }
示例#11
0
        public void GetPGPages(Boolean live)
        {
            int debugged = 0;

            StreamWriter swr;

            if (settings.countries.Contains("All"))
            {
                swr = new StreamWriter(debugpgfilename);
            }
            else
            {
                swr = new StreamWriter(debugpgfilename, true);
            }

            string[] tempbl;
            if (settings.blacklist != "")
            {
                tempbl = settings.blacklist.Split(new char[] { ',', '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
                foreach (string blentry in tempbl)
                {
                    if (!blacklistdic.ContainsKey(blentry))
                    {
                        blacklistdic.Add(blentry, true);
                    }
                }
            }
            SetProgressBar(calcitems.Count);
            storesWithItemsList.Clear(); // Added by CAC, 6/24/15

            foreach (Item item in calcitems)
            {
                if (!calcWorker.CancellationPending)
                {
                    string page;
                    if (!db_blitems[item.id].pgpage.ContainsKey(item.colour))
                    {
                        item.availqty    = 0;
                        item.availstores = 0;
                        AddStatus("Getting Price Guide information for " + db_colours[item.colour].name + " " + db_blitems[item.id].name + Environment.NewLine);
                        swr.Write(DateTime.Now + "downloading http://www.bricklink.com/catalogPG.asp?" + item.type + "=" + item.number + "&colorID=" + item.colour + Environment.NewLine);

                        if (live)
                        {
                            page = GetPage("http://www.bricklink.com/catalogPG.asp?" + item.type + "=" + item.number + "&colorID=" + item.colour, settings.login);
                            // Uncomment these three lines to save prices guide information so that it is used instead of live data.
                            // Comment them when done.
                            //if (!Directory.Exists("PGCache")) { Directory.CreateDirectory("PGCache"); }
                            //System.IO.StreamWriter file = new StreamWriter("PGCache\\" + item.type + "_" + item.number + "_" + item.colour + ".txt");
                            //file.Write(page);
                        }
                        else
                        {
                            try {
                                StreamReader pageReader = new StreamReader("PGCache\\" + item.type + "_" + item.number + "_" + item.colour + ".txt");
                                page = pageReader.ReadToEnd();
                            } catch (Exception e) {
                                page = "";
                            }
                        }
                        if (debugged == 0)
                        {
                            swr.Write(page);
                            debugged = 1;
                        }
                        if (page == null || page == "##PageFail##")
                        {
                            AddStatus("Error downloading price guide" + Environment.NewLine);
                            calcfail = true;
                            swr.Close();
                            break;
                        }

                        db_blitems[item.id].pgpage.Add(item.colour, page);
                    }
                    else
                    {
                        AddStatus("Using cached Price Guide information for " + db_colours[item.colour].name + " " + db_blitems[item.id].name + Environment.NewLine);
                        page = db_blitems[item.id].pgpage[item.colour];
                    }

                    List <string> chunks = page.Split(new string[] { "<B>Currently Available</B>" }, StringSplitOptions.None).ToList();
                    List <string> rawpgitems;
                    if (chunks.Count > 1)
                    {
                        rawpgitems = chunks[1].Split(new string[] { "</TD></TR>" }, StringSplitOptions.None).ToList();
                    }
                    else
                    {
                        AddStatus("Error downloading price guide (got page, but there was nothing on it)" + Environment.NewLine);
                        calcfail = true;
                        swr.Close();
                        break;
                    }
                    rawpgitems.Add("#usedstart#");
                    if (chunks.Count() > 2)
                    {
                        rawpgitems.AddRange(chunks[2].Split(new string[] { "</TD></TR>" }, StringSplitOptions.None).ToList());
                    }

                    int usedmarker = 0;

                    foreach (string raw in rawpgitems)
                    {
                        if (raw == "#usedstart#")
                        {
                            usedmarker = 1;
                            continue;
                        }

                        if ((item.condition == "N") && (usedmarker == 1))
                        {
                            break;
                        }

                        if (raw.Contains("nbsp;(S)</"))
                        {
                            AddStatus("skip ");
                            continue;
                        }

                        Match linematch = Regex.Match(raw, ".*<TR ALIGN=" + "\"" + @"RIGHT" + "\"" + @"><TD NOWRAP>.*?<A HREF=" + "\"" +
                                                      @"/store.asp\?sID=(\d*?)&.*?<IMG SRC=" + "\"" + @"/images/box16(.).png" + "\"" + @".*?TITLE=" + "\"" + @"Store: (.*?)" +
                                                      "\"" + @" ALIGN=" + "\"" + @"ABSMIDDLE" + "\"" + @">.*?</TD><TD>(\d*)</TD><TD.*?&nbsp;\D*([\d,]*)\.(\d+)$");
                        if (linematch.Success)
                        {
                            string id = linematch.Groups[1].ToString();

                            if (blacklistdic.ContainsKey(id))
                            {
                                continue;
                            }

                            string  ship      = linematch.Groups[2].ToString();
                            string  storename = linematch.Groups[3].ToString();
                            int     qty       = System.Convert.ToInt32(linematch.Groups[4].ToString());
                            string  price1    = linematch.Groups[5].ToString().Replace(",", "");
                            decimal price     = ConvertToDecimal(price1 + "." + linematch.Groups[6].ToString());

                            if (ship == "Y")
                            {
                                if (((StoreDictionary.ContainsKey(storename)) || (settings.countries.Contains("All"))) && (true)) // blacklist
                                {
                                    item.availqty = item.availqty + qty;
                                    if (!storeid.ContainsKey(storename))
                                    {
                                        storeid.Add(storename, id);
                                    }
                                    if (!StoreDictionary.ContainsKey(storename))
                                    {
                                        StoreDictionary.Add(storename, new Dictionary <string, StoreItem>());
                                    }
                                    if (!StoreDictionary[storename].ContainsKey(item.extid))
                                    {
                                        StoreDictionary[storename].Add(item.extid, new StoreItem());
                                    }
                                    if (StoreDictionary[storename][item.extid].qty == 0)
                                    {
                                        StoreDictionary[storename][item.extid].qty   = qty;
                                        StoreDictionary[storename][item.extid].price = price;
                                        item.availstores++;
                                    }
                                    else if (StoreDictionary[storename][item.extid].qty > 0)
                                    {
                                        StoreDictionary[storename][item.extid].qty = StoreDictionary[storename][item.extid].qty + qty;
                                        item.availqty = item.availqty + qty;
                                        if (StoreDictionary[storename][item.extid].price < price)
                                        {
                                            StoreDictionary[storename][item.extid].price = price;
                                        }
                                    }
                                    storesWithItemsList.Add(storename); // Added by CAC, 6/24/15
                                }
                            }
                        }
                        else
                        {
                            if (Regex.Match(raw, "<TR ALIGN=" + "\"" + @"RIGHT" + "\"" + @"><TD NOWRAP>").Success)
                            {
                                AddStatus("No Match: " + raw + Environment.NewLine + Environment.NewLine);
                            }
                        }
                    }
                    if (item.availqty < item.qty)
                    {
                        AddStatus("Error: " + db_colours[item.colour].name + " " + db_blitems[item.id].name +
                                  ":Either this is not available from any stores you've selected or you need to log in." + Environment.NewLine);
                        calcfail = true;
                        ResetProgressBar();
                        swr.Close();
                        break;
                    }
                    else
                    {
                        AddStatus("Available from " + item.availstores + " stores" + Environment.NewLine);
                        //Progress();
                    }
                }
            }
            swr.Close();
        }
示例#12
0
        public static string NpcTemplateNonWDB(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

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

            var levels = GetLevels(units);

            var templates = new StoreDictionary <uint, UnitTemplateNonWDB>();

            foreach (var unit in units)
            {
                if (templates.ContainsKey(unit.Key.GetEntry()))
                {
                    continue;
                }

                var npc      = unit.Value;
                var template = new UnitTemplateNonWDB
                {
                    GossipMenuId     = npc.GossipId,
                    MinLevel         = levels[unit.Key.GetEntry()].Item1,
                    MaxLevel         = levels[unit.Key.GetEntry()].Item2,
                    Faction          = npc.Faction.GetValueOrDefault(35),
                    NpcFlag          = (uint)npc.NpcFlags.GetValueOrDefault(NPCFlags.None),
                    SpeedRun         = npc.Movement.RunSpeed,
                    SpeedWalk        = npc.Movement.WalkSpeed,
                    BaseAttackTime   = npc.MeleeTime.GetValueOrDefault(2000),
                    RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000),
                    UnitClass        = (uint)npc.Class.GetValueOrDefault(Class.Warrior),
                    UnitFlag         = (uint)npc.UnitFlags.GetValueOrDefault(UnitFlags.None),
                    UnitFlag2        = (uint)npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None),
                    DynamicFlag      = (uint)npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None),
                    VehicleId        = npc.Movement.VehicleId,
                    HoverHeight      = npc.HoverHeight.GetValueOrDefault(1.0f)
                };

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

                template.UnitFlag    &= ~(uint)UnitFlags.IsInCombat;
                template.UnitFlag    &= ~(uint)UnitFlags.PetIsAttackingTarget;
                template.UnitFlag    &= ~(uint)UnitFlags.PlayerControlled;
                template.UnitFlag    &= ~(uint)UnitFlags.Silenced;
                template.UnitFlag    &= ~(uint)UnitFlags.PossessedByPlayer;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.Lootable;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.Tapped;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByPlayer;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByAllThreatList;

                // has trainer flag but doesn't have prof nor class trainer flag
                if ((template.NpcFlag & (uint)NPCFlags.Trainer) != 0 &&
                    ((template.NpcFlag & (uint)NPCFlags.ProfessionTrainer) == 0 ||
                     (template.NpcFlag & (uint)NPCFlags.ClassTrainer) == 0))
                {
                    var name       = StoreGetters.GetName(StoreNameType.Unit, (int)unit.Key.GetEntry(), false);
                    var firstIndex = name.LastIndexOf('<');
                    var lastIndex  = name.LastIndexOf('>');
                    if (firstIndex != -1 && lastIndex != -1)
                    {
                        var subname = name.Substring(firstIndex + 1, lastIndex - firstIndex - 1);

                        if (_professionTrainers.Contains(subname))
                        {
                            template.NpcFlag |= (uint)NPCFlags.ProfessionTrainer;
                        }
                        else if (_classTrainers.Contains(subname))
                        {
                            template.NpcFlag |= (uint)NPCFlags.ClassTrainer;
                        }
                    }
                }

                templates.Add(unit.Key.GetEntry(), template);
            }

            var templatesDb = SQLDatabase.GetDict <uint, UnitTemplateNonWDB>(templates.Keys());

            return(SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.Unit));
        }
示例#13
0
        public static string NpcTemplateNonWDB(Dictionary<WowGuid, Unit> units)
        {
            if (ClientVersion.AddedInVersion(ClientType.WarlordsOfDraenor))
                return string.Empty;

            if (units.Count == 0)
                return string.Empty;

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

            var levels = GetLevels(units);

            var templates = new StoreDictionary<uint, UnitTemplateNonWDB>();
            foreach (var unit in units)
            {
                if (templates.ContainsKey(unit.Key.GetEntry()))
                    continue;

                var npc = unit.Value;
                var template = new UnitTemplateNonWDB
                {
                    GossipMenuId = npc.GossipId,
                    MinLevel = (int) levels[unit.Key.GetEntry()].Item1,
                    MaxLevel = (int) levels[unit.Key.GetEntry()].Item2,
                    Faction = npc.Faction.GetValueOrDefault(35),
                    NpcFlag = (uint) npc.NpcFlags.GetValueOrDefault(NPCFlags.None),
                    SpeedRun = npc.Movement.RunSpeed,
                    SpeedWalk = npc.Movement.WalkSpeed,
                    BaseAttackTime = npc.MeleeTime.GetValueOrDefault(2000),
                    RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000),
                    UnitClass = (uint) npc.Class.GetValueOrDefault(Class.Warrior),
                    UnitFlag = (uint) npc.UnitFlags.GetValueOrDefault(UnitFlags.None),
                    UnitFlag2 = (uint) npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None),
                    DynamicFlag = (uint) npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None),
                    VehicleId = npc.Movement.VehicleId,
                    HoverHeight = npc.HoverHeight.GetValueOrDefault(1.0f)
                };

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

                template.UnitFlag &= ~(uint)UnitFlags.IsInCombat;
                template.UnitFlag &= ~(uint)UnitFlags.PetIsAttackingTarget;
                template.UnitFlag &= ~(uint)UnitFlags.PlayerControlled;
                template.UnitFlag &= ~(uint)UnitFlags.Silenced;
                template.UnitFlag &= ~(uint)UnitFlags.PossessedByPlayer;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.Lootable;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.Tapped;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByPlayer;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByAllThreatList;

                // has trainer flag but doesn't have prof nor class trainer flag
                if ((template.NpcFlag & (uint) NPCFlags.Trainer) != 0 &&
                    ((template.NpcFlag & (uint) NPCFlags.ProfessionTrainer) == 0 ||
                     (template.NpcFlag & (uint) NPCFlags.ClassTrainer) == 0))
                {
                    UnitTemplate unitData;
                    var subname = GetSubName((int)unit.Key.GetEntry(), false); // Fall back
                    if (Storage.UnitTemplates.TryGetValue(unit.Key.GetEntry(), out unitData))
                    {
                        if (unitData.SubName.Length > 0)
                            template.NpcFlag |= ProcessNpcFlags(unitData.SubName);
                        else // If the SubName doesn't exist or is cached, fall back to DB method
                            template.NpcFlag |= ProcessNpcFlags(subname);
                    }
                    else // In case we have NonWDB data which doesn't have an entry in UnitTemplates
                        template.NpcFlag |= ProcessNpcFlags(subname);
                }

                templates.Add(unit.Key.GetEntry(), template);
            }

            var templatesDb = SQLDatabase.GetDict<uint, UnitTemplateNonWDB>(templates.Keys());
            return SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.Unit);
        }
示例#14
0
        public static string ModelData(Dictionary<WowGuid, Unit> units)
        {
            if (units.Count == 0)
                return string.Empty;

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_model_info))
                return string.Empty;

            // Build a dictionary with model data; model is the key
            var models = new StoreDictionary<uint, ModelData>();
            foreach (var npc in units.Select(unit => unit.Value))
            {
                if (Settings.AreaFilters.Length > 0)
                    if (!(npc.Area.ToString(CultureInfo.InvariantCulture).MatchesFilters(Settings.AreaFilters)))
                        continue;

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

                uint modelId;
                if (npc.Model.HasValue)
                    modelId = npc.Model.Value;
                else
                    continue;

                // Do not add duplicate models
                if (models.ContainsKey(modelId))
                    continue;

                float scale = npc.Size.GetValueOrDefault(1.0f);
                var model = new ModelData
                {
                    BoundingRadius = npc.BoundingRadius.GetValueOrDefault(0.306f) / scale,
                    CombatReach = npc.CombatReach.GetValueOrDefault(1.5f) / scale,
                    Gender = npc.Gender.GetValueOrDefault(Gender.Male)
                };

                models.Add(modelId, model);
            }

            var entries = models.Keys();
            var modelsDb = SQLDatabase.GetDict<uint, ModelData>(entries, "DisplayID");
            return SQLUtil.CompareDicts(models, modelsDb, StoreNameType.None, "DisplayID");
        }
示例#15
0
        public static string NpcTemplateNonWDB(Dictionary<WowGuid, Unit> units)
        {
            /* if (ClientVersion.AddedInVersion(ClientType.WarlordsOfDraenor))
                return string.Empty;*/

            if (units.Count == 0)
                return string.Empty;

            /*if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_template))
                return string.Empty;*/

            var levels = GetLevels(units);

            var result = string.Empty;
            const string tableName = "creature_template";
            var rowsIns = new List<QueryBuilder.SQLUpdateRow>();
            uint count = 0;

            var templates = new StoreDictionary<uint, UnitTemplateNonWDB>();
            foreach (var unit in units)
            {
                if (templates.ContainsKey(unit.Key.GetEntry()))
                    continue;

                var row = new QueryBuilder.SQLUpdateRow();

                var npc = unit.Value;
                var template = new UnitTemplateNonWDB
                {
                    //GossipMenuId = npc.GossipId,
                    MinLevel = (int) levels[unit.Key.GetEntry()].Item1,
                    MaxLevel = (int) levels[unit.Key.GetEntry()].Item2,
                    Faction = npc.Faction.GetValueOrDefault(35),
                    NpcFlag = (uint) npc.NpcFlags.GetValueOrDefault(NPCFlags.None),
                    SpeedRun = npc.Movement.RunSpeed,
                    SpeedWalk = npc.Movement.WalkSpeed
                    /*BaseAttackTime = npc.MeleeTime.GetValueOrDefault(2000),
                    RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000),
                    UnitClass = (uint) npc.Class.GetValueOrDefault(Class.Warrior),
                    UnitFlag = (uint) npc.UnitFlags.GetValueOrDefault(UnitFlags.None),
                    UnitFlag2 = (uint) npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None),
                    DynamicFlag = (uint) npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None),
                    VehicleId = npc.Movement.VehicleId,
                    HoverHeight = npc.HoverHeight.GetValueOrDefault(1.0f)*/
                };

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

               /* template.UnitFlag &= ~(uint)UnitFlags.IsInCombat;
                template.UnitFlag &= ~(uint)UnitFlags.PetIsAttackingTarget;
                template.UnitFlag &= ~(uint)UnitFlags.PlayerControlled;
                template.UnitFlag &= ~(uint)UnitFlags.Silenced;
                template.UnitFlag &= ~(uint)UnitFlags.PossessedByPlayer;

                if (!ClientVersion.AddedInVersion(ClientType.WarlordsOfDraenor))
                {
                    template.DynamicFlag &= ~(uint)UnitDynamicFlags.Lootable;
                    template.DynamicFlag &= ~(uint)UnitDynamicFlags.Tapped;
                    template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByPlayer;
                    template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByAllThreatList;
                }
                else
                {
                    template.DynamicFlag &= ~(uint)UnitDynamicFlagsWOD.Lootable;
                    template.DynamicFlag &= ~(uint)UnitDynamicFlagsWOD.Tapped;
                    template.DynamicFlag &= ~(uint)UnitDynamicFlagsWOD.TappedByPlayer;
                    template.DynamicFlag &= ~(uint)UnitDynamicFlagsWOD.TappedByAllThreatList;
                }*/

                // has trainer flag but doesn't have prof nor class trainer flag
                if ((template.NpcFlag & (uint) NPCFlags.Trainer) != 0 &&
                    ((template.NpcFlag & (uint) NPCFlags.ProfessionTrainer) == 0 ||
                     (template.NpcFlag & (uint) NPCFlags.ClassTrainer) == 0))
                {
                    UnitTemplate unitData;
                    var subname = GetSubName((int)unit.Key.GetEntry(), false); // Fall back
                    if (Storage.UnitTemplates.TryGetValue(unit.Key.GetEntry(), out unitData))
                    {
                        if (unitData.SubName.Length > 0)
                            template.NpcFlag |= ProcessNpcFlags(unitData.SubName);
                        else // If the SubName doesn't exist or is cached, fall back to DB method
                            template.NpcFlag |= ProcessNpcFlags(subname);
                    }
                    else // In case we have NonWDB data which doesn't have an entry in UnitTemplates
                        template.NpcFlag |= ProcessNpcFlags(subname);
                }
                row.AddValue("minlevel", template.MinLevel);
                row.AddValue("maxlevel", template.MaxLevel);
                row.AddValue("faction", template.Faction);
                row.AddValue("npcflag", template.NpcFlag);
                row.AddValue("speed_walk", template.SpeedWalk);
                row.AddValue("speed_run", template.SpeedRun);

                row.AddWhere("entry", unit.Key.GetEntry());

                row.Table = tableName;
                rowsIns.Add(row);
                count++;

                templates.Add(unit.Key.GetEntry(), template);
            }

            //result += new QueryBuilder.SQLDelete(Tuple.Create("@ID+0", "@ID+" + (count - 1)), "entry", tableName).Build();
            result += new QueryBuilder.SQLUpdate(rowsIns).Build();
            return result;

            /*var templatesDb = SQLDatabase.GetDict<uint, UnitTemplateNonWDB>(templates.Keys());
            return SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.Unit);*/
        }
示例#16
0
        public static string CreatureDifficultyMisc(Dictionary<WowGuid, Unit> units)
        {
            if (!ClientVersion.AddedInVersion(ClientType.WarlordsOfDraenor))
                return string.Empty;

            if (units.Count == 0)
                return string.Empty;

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

            var templates = new StoreDictionary<uint, CreatureDifficultyMisc>();
            foreach (var unit in units)
            {
                if (SQLDatabase.CreatureDifficultyStores != null)
                {
                    foreach (var creatureDiff in SQLDatabase.CreatureDifficultyStores)
                    {
                        if (!Utilities.EqualValues(unit.Key.GetEntry(), creatureDiff.Value.CreatureID))
                            continue;

                        if (templates.ContainsKey(creatureDiff.Key))
                            continue;

                        var npc = unit.Value;
                        var template = new CreatureDifficultyMisc
                        {
                            CreatureId = unit.Key.GetEntry(),
                            GossipMenuId = npc.GossipId,
                            NpcFlag = (uint)npc.NpcFlags.GetValueOrDefault(NPCFlags.None),
                            SpeedRun = npc.Movement.RunSpeed,
                            SpeedWalk = npc.Movement.WalkSpeed,
                            BaseAttackTime = npc.MeleeTime.GetValueOrDefault(2000),
                            RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000),
                            UnitClass = (uint)npc.Class.GetValueOrDefault(Class.Warrior),
                            UnitFlag = (uint)npc.UnitFlags.GetValueOrDefault(UnitFlags.None),
                            UnitFlag2 = (uint)npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None),
                            DynamicFlag = (uint)npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None),
                            VehicleId = npc.Movement.VehicleId,
                            HoverHeight = npc.HoverHeight.GetValueOrDefault(1.0f)
                        };

                        template.UnitFlag &= ~(uint)UnitFlags.IsInCombat;
                        template.UnitFlag &= ~(uint)UnitFlags.PetIsAttackingTarget;
                        template.UnitFlag &= ~(uint)UnitFlags.PlayerControlled;
                        template.UnitFlag &= ~(uint)UnitFlags.Silenced;
                        template.UnitFlag &= ~(uint)UnitFlags.PossessedByPlayer;

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

                        // has trainer flag but doesn't have prof nor class trainer flag
                        if ((template.NpcFlag & (uint)NPCFlags.Trainer) != 0 &&
                            ((template.NpcFlag & (uint)NPCFlags.ProfessionTrainer) == 0 ||
                             (template.NpcFlag & (uint)NPCFlags.ClassTrainer) == 0))
                        {
                            var name = StoreGetters.GetName(StoreNameType.Unit, (int)unit.Key.GetEntry(), false);
                            var firstIndex = name.LastIndexOf('<');
                            var lastIndex = name.LastIndexOf('>');
                            if (firstIndex != -1 && lastIndex != -1)
                            {
                                var subname = name.Substring(firstIndex + 1, lastIndex - firstIndex - 1);

                                if (_professionTrainers.Contains(subname))
                                    template.NpcFlag |= (uint)NPCFlags.ProfessionTrainer;
                                else if (_classTrainers.Contains(subname))
                                    template.NpcFlag |= (uint)NPCFlags.ClassTrainer;
                            }
                        }

                        templates.Add(creatureDiff.Key, template);
                    }
                }
            }

            var templatesDb = SQLDatabase.GetDict<uint, CreatureDifficultyMisc>(templates.Keys(), "Id");
            return SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.Unit, "Id");
        }
示例#17
0
        public static string CreatureEquip(Dictionary<WowGuid, Unit> units)
        {
            if (units.Count == 0)
                return string.Empty;

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_equip_template))
                return string.Empty;

            var rows = new List<QueryBuilder.SQLInsertRow>();

            var equips = new StoreDictionary<uint, CreatureEquipment>();
            foreach (var unit in units)
            {
                var equip = new CreatureEquipment();
                var npc = unit.Value;
                var CreatureID = unit.Key.GetEntry();
                var row = new QueryBuilder.SQLInsertRow();

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

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

                if (npc.Equipment == null || npc.Equipment.Length != 3)
                    continue;

                if (npc.Equipment[0] == 0 && npc.Equipment[1] == 0 && npc.Equipment[2] == 0)
                    continue;

                if (equips.ContainsKey(CreatureID))
                {
                    var existingEquip = equips[CreatureID].Item1;

                    if (existingEquip.ItemEntry1 != npc.Equipment[0] ||
                          existingEquip.ItemEntry2 != npc.Equipment[1] ||
                          existingEquip.ItemEntry3 != npc.Equipment[2])
                        equips.Remove(CreatureID); // no conflicts

                    continue;
                }

                /*equip.ID = 1;
                equip.ItemEntry1 = npc.Equipment[0];
                equip.ItemEntry2 = npc.Equipment[1];
                equip.ItemEntry3 = npc.Equipment[2];*/

                row.AddValue("CreatureID", CreatureID);
                row.AddValue("ID", 1);
                row.AddValue("ItemID1", npc.Equipment[0]);
                row.AddValue("ItemID2", npc.Equipment[1]);
                row.AddValue("ItemID3", npc.Equipment[2]);

                equips.Add(CreatureID, equip);
                rows.Add(row);
            }

            var entries = equips.Keys();
            //var equipsDb = SQLDatabase.GetDict<uint, CreatureEquipment>(entries);
            //return SQLUtil.CompareDicts(equips, equipsDb, StoreNameType.Unit);
            return new QueryBuilder.SQLInsert("creature_equip_template", rows, withDelete: true).Build();
        }
示例#18
0
        // Non-WDB data but nevertheless data that should be saved to creature_template
        public static string NpcTemplateNonWDB(Dictionary<Guid, Unit> units)
        {
            if (units.Count == 0)
                return string.Empty;

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

            var levels = GetLevels(units);

            var templates = new StoreDictionary<uint, UnitTemplateNonWDB>();
            foreach (var unit in units)
            {
                if (templates.ContainsKey(unit.Key.GetEntry()))
                    continue;

                var npc = unit.Value;
                var template = new UnitTemplateNonWDB
                {
                    GossipMenuId = npc.GossipId,
                    MinLevel = levels[unit.Key.GetEntry()].Item1,
                    MaxLevel = levels[unit.Key.GetEntry()].Item2,
                    Faction = npc.Faction.GetValueOrDefault(35),
                    Faction2 = npc.Faction.GetValueOrDefault(35),
                    NpcFlag = (uint) npc.NpcFlags.GetValueOrDefault(NPCFlags.None),
                    SpeedRun = npc.Movement.RunSpeed,
                    SpeedWalk = npc.Movement.WalkSpeed,
                    BaseAttackTime = npc.MeleeTime.GetValueOrDefault(2000),
                    RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000),
                    UnitClass = (uint) npc.Class.GetValueOrDefault(Class.Warrior),
                    UnitFlag = (uint) npc.UnitFlags.GetValueOrDefault(UnitFlags.None),
                    UnitFlag2 = (uint) npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None),
                    DynamicFlag = (uint) npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None),
                    VehicleId = npc.Movement.VehicleId,
                    HoverHeight = npc.HoverHeight.GetValueOrDefault(1.0f)
                };

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

                template.UnitFlag &= ~(uint)UnitFlags.IsInCombat;
                template.UnitFlag &= ~(uint)UnitFlags.PetIsAttackingTarget;
                template.UnitFlag &= ~(uint)UnitFlags.PlayerControlled;
                template.UnitFlag &= ~(uint)UnitFlags.Silenced;
                template.UnitFlag &= ~(uint)UnitFlags.PossessedByPlayer;

                templates.Add(unit.Key.GetEntry(), template, null);
            }

            var templatesDb = SQLDatabase.GetDict<uint, UnitTemplateNonWDB>(templates.Keys());
            return SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.Unit);
        }
示例#19
0
        public static string CreatureEquip(Dictionary<Guid, Unit> units)
        {
            if (units.Count == 0)
                return string.Empty;

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_equip_template))
                return string.Empty;

            var equips = new StoreDictionary<ushort, CreatureEquipment>();
            foreach (var unit in units)
            {
                var equip = new CreatureEquipment();
                var npc = unit.Value;
                var entry = (ushort)unit.Key.GetEntry();

                if (npc.Equipment == null || npc.Equipment.Length != 3)
                    continue;

                if (npc.Equipment[0] == 0 && npc.Equipment[1] == 0 && npc.Equipment[2] == 0)
                    continue;

                if (equips.ContainsKey(entry))
                {
                    var existingEquip = equips[entry].Item1;

                    if (existingEquip.ItemEntry1 != npc.Equipment[0] ||
                          existingEquip.ItemEntry2 != npc.Equipment[1] ||
                          existingEquip.ItemEntry3 != npc.Equipment[2])
                        equips.Remove(entry); // no conflicts

                    continue;
                }

                equip.ItemEntry1 = npc.Equipment[0];
                equip.ItemEntry2 = npc.Equipment[1];
                equip.ItemEntry3 = npc.Equipment[2];

                equips.Add(entry, equip);
            }

            var entries = equips.Keys();
            var equipsDb = SQLDatabase.GetDict<ushort, CreatureEquipment>(entries);
            return SQLUtil.CompareDicts(equips, equipsDb, StoreNameType.Unit);
        }
示例#20
0
        public static string ModelData(Dictionary<Guid, Unit> units)
        {
            if (units.Count == 0)
                return string.Empty;

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_model_info))
                return string.Empty;

            // Build a dictionary with model data; model is the key
            var models = new StoreDictionary<uint, ModelData>();
            foreach (var npc in units.Select(unit => unit.Value))
            {
                uint modelId;
                if (npc.Model.HasValue)
                    modelId = npc.Model.Value;
                else
                    continue;

                // Do not add duplicate models
                if (models.ContainsKey(modelId))
                    continue;

                var model = new ModelData
                {
                    BoundingRadius = npc.BoundingRadius.GetValueOrDefault(0.306f),
                    CombatReach = npc.CombatReach.GetValueOrDefault(1.5f),
                    Gender = npc.Gender.GetValueOrDefault(Gender.Male)
                };

                models.Add(modelId, model, null);
            }

            var entries = models.Keys();
            var modelsDb = SQLDatabase.GetDict<uint, ModelData>(entries, "modelid");
            return SQLUtil.CompareDicts(models, modelsDb, StoreNameType.None, "modelid");
        }
示例#21
0
        public static string GameobjectTemplateNonWDB(Dictionary<WowGuid, GameObject> gameobjects)
        {
            if (gameobjects.Count == 0)
                return string.Empty;

            if (!Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.gameobject_template))
                return string.Empty;

            var templates = new StoreDictionary<uint, GameObjectTemplateNonWDB>();
            foreach (var goT in gameobjects)
            {
                if (templates.ContainsKey(goT.Key.GetEntry()))
                    continue;

                var go = goT.Value;

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

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

                var template = new GameObjectTemplateNonWDB
                {
                    Size = go.Size.GetValueOrDefault(1.0f),
                    Faction = go.Faction.GetValueOrDefault(0),
                    Flags = go.Flags.GetValueOrDefault(GameObjectFlag.None)
                };

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

                template.Flags &= ~GameObjectFlag.Triggered;
                template.Flags &= ~GameObjectFlag.Damaged;
                template.Flags &= ~GameObjectFlag.Destroyed;

                templates.Add(goT.Key.GetEntry(), template);
            }

            var templatesDb = SQLDatabase.GetDict<uint, GameObjectTemplateNonWDB>(templates.Keys());
            return SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.GameObject);
        }
示例#22
0
        private void GetValidStores()
        {
            if (settings.countries.Contains("All"))
            {
                return;
            }

            StreamWriter swr = new StreamWriter(debugpgfilename);

            bool pagefail = false;

            foreach (string country in settings.countries)
            {
                if (!calcWorker.CancellationPending)
                {
                    string page;
                    int    tmpstores = 0;
                    if ((country == "North America") || (country == "Europe") || (country == "Asia"))
                    {
                        continue;
                    }

                    if (!db_countrystores.ContainsKey(country))
                    {
                        swr.Write(DateTime.Now + "downloading https://www.bricklink.com/browseStores.asp?countryID=" + db_countries[country] + Environment.NewLine);
                        page = GetPage("https://www.bricklink.com/browseStores.asp?countryID=" + db_countries[country]);
                        db_countrystores.Add(country, page);
                        if (page == "##PageFail##")
                        {
                            pagefail = true;
                            swr.Close();
                            break;
                        }
                    }
                    else
                    {
                        swr.Write(DateTime.Now + "Using cached copy of https://www.bricklink.com/browseStores.asp?countryID=" + db_countries[country] + Environment.NewLine);
                        page = db_countrystores[country];
                    }

                    List <string> chunks    = page.Split(new string[] { "Open Stores" }, StringSplitOptions.None).ToList();
                    List <string> rawstores = new List <string>();
                    try
                    {
                        rawstores = chunks[1].Split(new string[] { "<BR>" }, StringSplitOptions.None).ToList();
                    }
                    catch
                    {
                        rawstores.Add(page);
                    }

                    foreach (string rawstore in rawstores)
                    {
                        Match storenamecheck = Regex.Match(rawstore, @"<A HREF='store.asp\?p=(.*?)'>(.*?)</A>", RegexOptions.IgnoreCase);
                        if (storenamecheck.Success)
                        {
                            //validstores.Add(storenamecheck.Groups[2].ToString());
                            string storename = storenamecheck.Groups[2].ToString();
                            StoreDictionary.Add(storename, new Dictionary <string, StoreItem>());
                            tmpstores++;
                        }
                    }

                    AddStatus(tmpstores + " stores found in " + country + Environment.NewLine);
                }
            }

            swr.Close();

            if (pagefail == true)
            {
                return;
            }

            AddStatus(Environment.NewLine);
        }
示例#23
0
        public static string NpcTemplateNonWDB(Dictionary<WowGuid, Unit> units)
        {
            if (units.Count == 0)
                return string.Empty;

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

            var levels = GetLevels(units);

            var templates = new StoreDictionary<uint, UnitTemplateNonWDB>();
            foreach (var unit in units)
            {
                if (templates.ContainsKey(unit.Key.GetEntry()))
                    continue;

                var npc = unit.Value;
                var template = new UnitTemplateNonWDB
                {
                    GossipMenuId = npc.GossipId,
                    MinLevel = levels[unit.Key.GetEntry()].Item1,
                    MaxLevel = levels[unit.Key.GetEntry()].Item2,
                    Faction = npc.Faction.GetValueOrDefault(35),
                    NpcFlag = (uint) npc.NpcFlags.GetValueOrDefault(NPCFlags.None),
                    SpeedRun = npc.Movement.RunSpeed,
                    SpeedWalk = npc.Movement.WalkSpeed,
                    BaseAttackTime = npc.MeleeTime.GetValueOrDefault(2000),
                    RangedAttackTime = npc.RangedTime.GetValueOrDefault(2000),
                    UnitClass = (uint) npc.Class.GetValueOrDefault(Class.Warrior),
                    UnitFlag = (uint) npc.UnitFlags.GetValueOrDefault(UnitFlags.None),
                    UnitFlag2 = (uint) npc.UnitFlags2.GetValueOrDefault(UnitFlags2.None),
                    DynamicFlag = (uint) npc.DynamicFlags.GetValueOrDefault(UnitDynamicFlags.None),
                    VehicleId = npc.Movement.VehicleId,
                    HoverHeight = npc.HoverHeight.GetValueOrDefault(1.0f)
                };

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

                template.UnitFlag &= ~(uint)UnitFlags.IsInCombat;
                template.UnitFlag &= ~(uint)UnitFlags.PetIsAttackingTarget;
                template.UnitFlag &= ~(uint)UnitFlags.PlayerControlled;
                template.UnitFlag &= ~(uint)UnitFlags.Silenced;
                template.UnitFlag &= ~(uint)UnitFlags.PossessedByPlayer;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.Lootable;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.Tapped;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByPlayer;
                template.DynamicFlag &= ~(uint)UnitDynamicFlags.TappedByAllThreatList;

                // has trainer flag but doesn't have prof nor class trainer flag
                if ((template.NpcFlag & (uint) NPCFlags.Trainer) != 0 &&
                    ((template.NpcFlag & (uint) NPCFlags.ProfessionTrainer) == 0 ||
                     (template.NpcFlag & (uint) NPCFlags.ClassTrainer) == 0))
                {
                    var name = StoreGetters.GetName(StoreNameType.Unit, (int) unit.Key.GetEntry(), false);
                    var firstIndex = name.LastIndexOf('<');
                    var lastIndex = name.LastIndexOf('>');
                    if (firstIndex != -1 && lastIndex != -1)
                    {
                        var subname = name.Substring(firstIndex + 1, lastIndex - firstIndex - 1);

                        if (_professionTrainers.Contains(subname))
                            template.NpcFlag |= (uint) NPCFlags.ProfessionTrainer;
                        else if (_classTrainers.Contains(subname))
                            template.NpcFlag |= (uint) NPCFlags.ClassTrainer;
                    }
                }

                templates.Add(unit.Key.GetEntry(), template);
            }

            var templatesDb = SQLDatabase.GetDict<uint, UnitTemplateNonWDB>(templates.Keys());
            return SQLUtil.CompareDicts(templates, templatesDb, StoreNameType.Unit);
        }
示例#24
0
        public bool ParsePage(string page, Item item, string colour)
        {
            if (page == null)
            {
                return(false);
            }

            List <string> chunks = page.Split(new string[] { "<B>Currently Available</B>" }, StringSplitOptions.None).ToList();
            List <string> rawpgitems;

            if (chunks.Count > 1)
            {
                rawpgitems = chunks[1].Split(new string[] { "</TD></TR>" }, StringSplitOptions.None).ToList();
            }
            else
            {
                AddStatus("Error downloading price guide (got page, but there was nothing on it)" + Environment.NewLine);
                return(false);
            }
            rawpgitems.Add("#usedstart#");
            if (chunks.Count() > 2)
            {
                rawpgitems.AddRange(chunks[2].Split(new string[] { "</TD></TR>" }, StringSplitOptions.None).ToList());
            }

            int usedmarker = 0;

            foreach (string raw in rawpgitems)
            {
                if (raw == "#usedstart#")
                {
                    usedmarker = 1;
                    continue;
                }

                if ((item.condition == "N") && (usedmarker == 1))
                {
                    break;
                }

                if (raw.Contains("nbsp;(S)</"))
                {
                    AddStatus("skip ");
                    continue;
                }

                // what is this madness?
                var pattern = ".*<TR ALIGN=" + "\"" + @"RIGHT" + "\"" + @"><TD NOWRAP>.*?<A HREF=" + "\"" +
                              @"/store.asp\?sID=(\d*?)&.*?<IMG SRC=" + "\"" + @"/images/box16(.).png" + "\"" + @".*?TITLE=" + "\"" + @"Store: (.*?)" +
                              "\"" + @" ALIGN=" + "\"" + @"ABSMIDDLE" + "\"" + @">.*?</TD><TD>(\d*)</TD><TD.*?&nbsp;\D*([\d,]*)\.(\d+)$";
                Match linematch = Regex.Match(raw, pattern);

                if (linematch.Success)
                {
                    string id = linematch.Groups[1].ToString();

                    if (blacklistdic.ContainsKey(id))
                    {
                        continue;
                    }

                    string  ship      = linematch.Groups[2].ToString();
                    string  storename = linematch.Groups[3].ToString();
                    int     qty       = System.Convert.ToInt32(linematch.Groups[4].ToString());
                    string  price1    = linematch.Groups[5].ToString().Replace(",", "");
                    decimal price     = ConvertToDecimal(price1 + "." + linematch.Groups[6].ToString());

                    if (ship == "Y")
                    {
                        if (((StoreDictionary.ContainsKey(storename)) || (settings.countries.Contains("All"))) && (true)) // blacklist
                        {
                            item.availqty += qty;
                            if (!storeid.ContainsKey(storename))
                            {
                                storeid.Add(storename, id);
                            }
                            if (!StoreDictionary.ContainsKey(storename))
                            {
                                StoreDictionary.Add(storename, new Dictionary <string, StoreItem>());
                            }
                            if (!StoreDictionary[storename].ContainsKey(item.extid))
                            {
                                item.availstores++;
                                StoreDictionary[storename].Add(item.extid, new StoreItem());
                            }
                            if (StoreDictionary[storename][item.extid].qty == 0)
                            {
                                StoreDictionary[storename][item.extid].qty    = qty;
                                StoreDictionary[storename][item.extid].price  = price;
                                StoreDictionary[storename][item.extid].colour = colour;
                            }
                            else if (StoreDictionary[storename][item.extid].qty > 0)
                            {
                                StoreDictionary[storename][item.extid].qty = StoreDictionary[storename][item.extid].qty + qty;
                                item.availqty = item.availqty + qty;
                                if (StoreDictionary[storename][item.extid].price > price)
                                {
                                    StoreDictionary[storename][item.extid].price  = price;
                                    StoreDictionary[storename][item.extid].colour = colour;
                                }
                            }
                            storesWithItemsList.Add(storename); // Added by CAC, 2015-06-24
                        }
                    }
                }
                else
                {
                    if (Regex.Match(raw, "<TR ALIGN=" + "\"" + @"RIGHT" + "\"" + @"><TD NOWRAP>").Success)
                    {
                        AddStatus("No Match: " + raw + Environment.NewLine + Environment.NewLine);
                    }
                }
            }
            return(true);
        }