Exemplo n.º 1
0
        public static string HotfixOptionalData()
        {
            if (Storage.HotfixOptionalDatas.IsEmpty())
            {
                return(string.Empty);
            }

            var rows = new RowList <HotfixOptionalData>();

            foreach (var hotfixOptionalData in Storage.HotfixOptionalDatas)
            {
                if (HotfixSettings.Instance.ShouldLog(hotfixOptionalData.Item1.TableHash))
                {
                    var row = new Row <HotfixOptionalData>
                    {
                        Data    = hotfixOptionalData.Item1,
                        Comment = hotfixOptionalData.Item1.TableHash.ToString()
                    };

                    rows.Add(row);
                }
            }
            if (rows.Count != 0)
            {
                return($"DELETE FROM `hotfix_optional_data` WHERE `locale` = '{ClientLocale.PacketLocale}' AND `VerifiedBuild`>0;" + Environment.NewLine + new SQLInsert <HotfixOptionalData>(rows, false).Build());
            }
            else
            {
                return(string.Empty);
            }
        }
Exemplo n.º 2
0
        public static string WeatherUpdates()
        {
            if (Storage.WeatherUpdates.IsEmpty())
            {
                return(string.Empty);
            }

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

            var rows = new RowList <WeatherUpdate>();

            foreach (var row in Storage.WeatherUpdates.Select(weatherUpdate => new Row <WeatherUpdate>
            {
                Data = weatherUpdate.Item1,
                Comment = StoreGetters.GetName(StoreNameType.Map, (int)weatherUpdate.Item1.MapId.GetValueOrDefault(), false) +
                          " - " + weatherUpdate.Item1.State + " - " + weatherUpdate.Item1.Grade
            }))
            {
                rows.Add(row);
            }

            return(new SQLInsert <WeatherUpdate>(rows, ignore: true, withDelete: false).Build());
        }
Exemplo n.º 3
0
        public static string HotfixBlob()
        {
            if (Storage.HotfixBlobs.IsEmpty())
            {
                return(string.Empty);
            }

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

            var rows = new RowList <HotfixBlob>();

            foreach (var hotfix in Storage.HotfixBlobs)
            {
                var row = new Row <HotfixBlob>
                {
                    Data    = hotfix.Item1,
                    Comment = hotfix.Item1.TableHash.ToString()
                };

                rows.Add(row);
            }

            return($"DELETE FROM `hotfix_blob` WHERE `locale` = '{ClientLocale.PacketLocale}' AND `VerifiedBuild`>0;" + Environment.NewLine + new SQLInsert <HotfixBlob>(rows, false).Build());
        }
Exemplo n.º 4
0
        public static string HotfixData()
        {
            if (Storage.HotfixDatas.IsEmpty())
            {
                return(string.Empty);
            }

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

            var rows = new RowList <HotfixData>();

            foreach (var hotfix in Storage.HotfixDatas)
            {
                var row = new Row <HotfixData>
                {
                    Data    = hotfix.Item1,
                    Comment = hotfix.Item1.TableHash.ToString()
                };

                rows.Add(row);
            }

            return("DELETE FROM `hotfix_data` WHERE `VerifiedBuild`>0;" + Environment.NewLine + new SQLInsert <HotfixData>(rows, false).Build());
        }
Exemplo n.º 5
0
        public static string PointsOfInterest()
        {
            if (Storage.GossipPOIs.IsEmpty())
            {
                return(string.Empty);
            }

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

            if (Settings.DBEnabled)
            {
                return(SQLUtil.Compare(Storage.GossipPOIs, SQLDatabase.Get(Storage.GossipPOIs), StoreNameType.None));
            }
            else
            {
                uint count = 0;
                var  rows  = new RowList <PointsOfInterest>();

                foreach (var pointOfInterest in Storage.GossipPOIs)
                {
                    Row <PointsOfInterest> row = new Row <PointsOfInterest>();

                    Type t = pointOfInterest.Item1.ID.GetType();
                    if (t.Equals(typeof(int)))
                    {
                        row.Data.ID = pointOfInterest.Item1.ID;
                    }
                    else
                    {
                        row.Data.ID = "@PID+" + count;
                    }

                    row.Data.PositionX     = pointOfInterest.Item1.PositionX;
                    row.Data.PositionY     = pointOfInterest.Item1.PositionY;
                    row.Data.PositionZ     = pointOfInterest.Item1.PositionZ;
                    row.Data.Icon          = pointOfInterest.Item1.Icon;
                    row.Data.Flags         = pointOfInterest.Item1.Flags;
                    row.Data.Importance    = pointOfInterest.Item1.Importance;
                    row.Data.Name          = pointOfInterest.Item1.Name;
                    row.Data.VerifiedBuild = pointOfInterest.Item1.VerifiedBuild;

                    ++count;

                    rows.Add(row);
                }

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

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

                return(result.ToString());
            }
        }
Exemplo n.º 6
0
        public static string HotfixBlob()
        {
            if (Storage.HotfixBlobs.IsEmpty())
            {
                return(string.Empty);
            }

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

            var rows = new RowList <HotfixBlob>();

            foreach (var hotfix in Storage.HotfixBlobs)
            {
                var row = new Row <HotfixBlob>
                {
                    Data    = hotfix.Item1,
                    Comment = hotfix.Item1.TableHash.ToString()
                };

                rows.Add(row);
            }

            return("TRUNCATE `hotfix_blob`;" + Environment.NewLine + new SQLInsert <HotfixBlob>(rows, false).Build());
        }
Exemplo n.º 7
0
        public static string VehicleAccessory()
        {
            if (Storage.VehicleTemplateAccessories.IsEmpty() || !Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.vehicle_template_accessory))
            {
                return(string.Empty);
            }

            var rows = new RowList <VehicleTemplateAccessory>();

            foreach (var accessory in Storage.VehicleTemplateAccessories)
            {
                if (accessory.Item1.SeatId < 0 || accessory.Item1.SeatId > 7)
                {
                    continue;
                }

                // ReSharper disable once UseObjectOrCollectionInitializer
                var row = new Row <VehicleTemplateAccessory>();
                row.Comment  = StoreGetters.GetName(StoreNameType.Unit, (int)accessory.Item1.Entry.GetValueOrDefault(), false) + " - ";
                row.Comment += StoreGetters.GetName(StoreNameType.Unit, (int)accessory.Item1.AccessoryEntry.GetValueOrDefault(), false);
                accessory.Item1.Description = row.Comment;
                row.Data = accessory.Item1;

                rows.Add(row);
            }

            return(new SQLInsert <VehicleTemplateAccessory>(rows, false).Build());
        }
Exemplo n.º 8
0
        /// <summary>
        /// Sets the Rows List
        /// </summary>
        public override void SetRowLists()
        {
            base.SetRowLists();
            int rowIndex = 0;

            for (int i = 0; i < WebElementRows.Count; i++)
            {
                Report.Write("GridRow by index: " + rowIndex);
                //GridRowType rowType = GetGridRowType(rowIndex);
                GridRowType rowType = GridRowType.Data;
                if (i == 0)
                {
                    rowType = GridRowType.Header;
                }

                bool lastRow = false;
                if (i == WebElementRows.Count - 1)
                {
                    lastRow = true;
                }

                Report.Write("GridRowType: " + rowType);
                var lineItem = new BenchmarkTestsTabOneTestViewRow(gridCssSelector, WebElementRows[i], rowIndex, rowType, lastRow, ColumnList, ControlPrefix);
                RowList.Add(lineItem);
                rowIndex++;
            }
        }
Exemplo n.º 9
0
        public void TestAdd()
        {
            _condList.Add(new TestDataModel());
            Assert.AreEqual(2, _condList.Count);

            _condList.Add(new TestDataModel {
                ID = 3, TestInt1 = 5
            });
            _condList.Add(new TestDataModel {
                ID = 4, TestInt1 = 6
            });
            Assert.AreEqual(4, _condList.Count);

            _condList.Add(new TestDataModel {
                ID = 3, TestInt1 = 5
            });
            Assert.AreEqual(4, _condList.Count);
        }
Exemplo n.º 10
0
        public static string CreatureTextLocale()
        {
            if (Storage.CreatureTexts.IsEmpty() || !Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_text_locale))
            {
                return(string.Empty);
            }



            /* can't use compare DB without knowing values of groupid or id
             * var entries = Storage.CreatureTexts.Keys.ToList();
             * var creatureTextDb = SQLDatabase.GetDict<uint, CreatureText>(entries);
             */

            var rows       = new RowList <CreatureText>();
            var rowLocales = new RowList <CreatureTextLocale>();
            Dictionary <uint, uint> entryCount = new Dictionary <uint, uint>();

            foreach (var text in Storage.CreatureTexts.OrderBy(t => t.Key))
            {
                foreach (var textValue in text.Value)
                {
                    var count = entryCount.ContainsKey(text.Key) ? entryCount[text.Key] : 0;

                    if (rows.Where(text2 => text2.Data.Text == textValue.Item1.Text).Count() != 0)
                    {
                        continue;
                    }

                    var row = new Row <CreatureTextLocale>
                    {
                        Data = new CreatureTextLocale
                        {
                            Entry   = text.Key,
                            GroupId = "" + count, ///@GROUP_ID+
                            ID      = "0",        ///@ID+
                            Text    = textValue.Item1.Text
                        },
                    };

                    if (!entryCount.ContainsKey(text.Key))
                    {
                        entryCount.Add(text.Key, count + 1);
                    }
                    else
                    {
                        entryCount[text.Key] = count + 1;
                    }

                    rowLocales.Add(row);
                }
            }

            return(new SQLInsert <CreatureTextLocale>(rowLocales, true).Build());
        }
        /// <summary>
        /// Sets the Rows List
        /// </summary>
        public override void SetRowLists()
        {
            base.SetRowLists();
            int rowIndex = 0;

            foreach (var webElement in WebElementRows)
            {
                GridRowType rowType  = GetGridRowType(rowIndex);
                var         lineItem = new TestCentralHomeRow(gridCssSelector, webElement, rowIndex, rowType, ColumnList, ControlPrefix);
                RowList.Add(lineItem);
                rowIndex++;
            }
        }
Exemplo n.º 12
0
        public static string NpcSpellClick()
        {
            if (Storage.NpcSpellClicks.IsEmpty())
            {
                return(string.Empty);
            }

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

            var rows = new RowList <NpcSpellClick>();

            foreach (var npcSpellClick in Storage.NpcSpellClicks)
            {
                foreach (var spellClick in Storage.SpellClicks)
                {
                    var row = new Row <NpcSpellClick>();

                    if (spellClick.Item1.CasterGUID.GetObjectType() == ObjectType.Unit && spellClick.Item1.TargetGUID.GetObjectType() == ObjectType.Unit)
                    {
                        spellClick.Item1.CastFlags = 0x0;
                    }
                    if (spellClick.Item1.CasterGUID.GetObjectType() == ObjectType.Player && spellClick.Item1.TargetGUID.GetObjectType() == ObjectType.Unit)
                    {
                        spellClick.Item1.CastFlags = 0x1;
                    }
                    if (spellClick.Item1.CasterGUID.GetObjectType() == ObjectType.Unit && spellClick.Item1.TargetGUID.GetObjectType() == ObjectType.Player)
                    {
                        spellClick.Item1.CastFlags = 0x2;
                    }
                    if (spellClick.Item1.CasterGUID.GetObjectType() == ObjectType.Player && spellClick.Item1.TargetGUID.GetObjectType() == ObjectType.Player)
                    {
                        spellClick.Item1.CastFlags = 0x3;
                    }

                    spellClick.Item1.Entry = npcSpellClick.Item1.GetEntry();
                    row.Data = spellClick.Item1;

                    var timeSpan = spellClick.Item2 - npcSpellClick.Item2;
                    if (timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1))
                    {
                        rows.Add(row);
                    }
                }
            }

            return(new SQLInsert <NpcSpellClick>(rows, false).Build());
        }
Exemplo n.º 13
0
 public override void SetRowLists()
 {
     base.SetRowLists();
     int rowIndex = 0;
     foreach (var webElement in WebElementRows)
     {
         Report.Write("GridRow by index: " + rowIndex);
         GridRowType rowType = GetGridRowType(rowIndex);
         Report.Write("GridRowType: " + rowType);
         var lineItem = new ProfileHomeTabRow(gridCssSelector, webElement, rowIndex, rowType, ColumnList, ControlPrefix);
         RowList.Add(lineItem);
         rowIndex++;
     }
 }
        public void AddRow(Color ValCol)
        {
            DataGridViewRow Row = null;

            Row = AddRow();

            UpdateRow(Row, RowHeight, false, false);
            UpdateCells(Row, false, ValCol, ValueFont, DataGridViewContentAlignment.MiddleRight);

            if (!Expanded)
            {
                Rows.RemoveAt(1);
                RowList.Add(Row);
            }
        }
Exemplo n.º 15
0
        public static string NpcSpellClickMop(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

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

            var rows = new RowList <NpcSpellClick>();

            foreach (var unit in units)
            {
                var row = new Row <NpcSpellClick>();

                Unit npc = unit.Value;
                if (npc.InteractSpellID == null)
                {
                    continue;
                }

                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;
                    }
                }

                row.Data.Entry   = unit.Key.GetEntry();
                row.Data.SpellID = npc.InteractSpellID.GetValueOrDefault();

                rows.Add(row);
            }

            return(new SQLInsert <NpcSpellClick>(rows, false).Build());
        }
Exemplo n.º 16
0
        /// <summary>
        /// Sets the Rows List
        /// </summary>
        public override void SetRowLists()
        {
            base.SetRowLists();
            int rowIndex = 0;

            //last row is not part of the grid. so use count - 1 to disclude it.
            for (int i = 0; i < WebElementRows.Count - 1; i++)
            {
                Report.Write("GridRow by index: " + rowIndex);
                GridRowType rowType = GetGridRowType(rowIndex);
                Report.Write("GridRowType: " + rowType);
                var lineItem = new BenchmarkELARow(gridCssSelector, WebElementRows[i], _gridIndex, rowIndex, rowType, ColumnList, ControlPrefix);
                RowList.Add(lineItem);
                rowIndex++;
            }
        }
Exemplo n.º 17
0
        public LoadRowsResult LoadRows(string relex, bool totalcount)
        {
            var res         = new LoadRowsResult();
            var relexParser = new RelExParser();
            var q           = relexParser.Parse(relex);

            var fldMapping = new FieldMapping(q.Fields);

            q.Fields = fldMapping.GetCompactFields();

            if (totalcount)
            {
                res.TotalCount = StorageDalc.RecordsCount(q);
            }

            var data = new RowList();

            StorageDalc.ExecuteReader(q, (reader) => {
                for (int i = 0; i < q.StartRecord; i++)
                {
                    reader.Read();                     // skip first N records
                }
                var cols = new List <string>();
                for (int i = 0; i < reader.FieldCount; i++)
                {
                    var fName = reader.GetName(i);
                    cols.Add(fldMapping.GetOriginalFieldName(fName));
                }

                while (reader.Read() && data.Count < q.RecordCount)
                {
                    var values = new object[reader.FieldCount];
                    reader.GetValues(values);
                    var row = new Dictionary <string, object>(values.Length);
                    for (int i = 0; i < reader.FieldCount; i++)
                    {
                        row[cols[i]] = DBNull.Value.Equals(values[i]) ? null : values[i];
                    }
                    data.Add(new DictionaryItem(row));
                }
            });

            res.Data = data;
            return(res);
        }
Exemplo n.º 18
0
        public static RowList ParseToRowList(string path, params char[] separator)
        {
            RowList rows = new RowList();

            try
            {
                using (System.IO.TextReader r = new StreamReader(path))
                {
                    while (true)
                    {
                        var s = r.ReadLine();
                        if (s == null)
                        {
                            break;
                        }

                        var col = s.Split(separator);
                        Row row = new Row();
                        foreach (var c in col)
                        {
                            row.Add(new Column()
                            {
                                Value = c
                            });
                        }

                        rows.Add(row);
                    }
                }
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.Print(ex.Message);
                return(null);
            }

            return(rows);
        }
        public void DebugSetGridLists()
        {
            int columnIndex = 0;

            foreach (var webElement in WebElementColumns)
            {
                //Debug.WriteLine("GridColumn by index: '{0}'.", columnIndex);
                var lineItem = new SNGridColumn(gridCssSelector, webElement, columnIndex, ControlPrefix);
                ColumnList.Add(lineItem);
                columnIndex++;
            }

            int rowIndex = 0;

            foreach (var webElement in WebElementRows)
            {
                //Debug.WriteLine("GridRow by index: '{0}'.", rowIndex);
                GridRowType rowType = GetGridRowType(rowIndex);
                //Debug.WriteLine("GridRowType: '{0}'.", rowType);
                var lineItem = new SNGridRow(gridCssSelector, webElement, rowIndex, rowType, ColumnList, ControlPrefix);
                RowList.Add(lineItem);
                rowIndex++;
            }
        }
Exemplo n.º 20
0
        public static string NpcSpellClick()
        {
            if (Storage.NpcSpellClicks.IsEmpty() || !Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.npc_spellclick_spells))
                return string.Empty;

            var rows = new RowList<NpcSpellClick>();

            foreach (var npcSpellClick in Storage.NpcSpellClicks)
            {
                foreach (var spellClick in Storage.SpellClicks)
                {
                    var row = new Row<NpcSpellClick>();

                    if (spellClick.Item1.CasterGUID.GetObjectType() == ObjectType.Unit && spellClick.Item1.TargetGUID.GetObjectType() == ObjectType.Unit)
                        spellClick.Item1.CastFlags = 0x0;
                    if (spellClick.Item1.CasterGUID.GetObjectType() == ObjectType.Player && spellClick.Item1.TargetGUID.GetObjectType() == ObjectType.Unit)
                        spellClick.Item1.CastFlags = 0x1;
                    if (spellClick.Item1.CasterGUID.GetObjectType() == ObjectType.Unit && spellClick.Item1.TargetGUID.GetObjectType() == ObjectType.Player)
                        spellClick.Item1.CastFlags = 0x2;
                    if (spellClick.Item1.CasterGUID.GetObjectType() == ObjectType.Player && spellClick.Item1.TargetGUID.GetObjectType() == ObjectType.Player)
                        spellClick.Item1.CastFlags = 0x3;

                    spellClick.Item1.Entry = npcSpellClick.Item1.GetEntry();
                    row.Data = spellClick.Item1;

                    var timeSpan = spellClick.Item2 - npcSpellClick.Item2;
                    if (timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1))
                        rows.Add(row);
                }
            }

            return new SQLInsert<NpcSpellClick>(rows, false).Build();
        }
Exemplo n.º 21
0
        public static string GameObject(Dictionary<WowGuid, GameObject> gameObjects)
        {
            if (gameObjects.Count == 0)
                return string.Empty;

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

            uint count = 0;
            var rows = new RowList<GameObjectModel>();
            var addonRows = new RowList<GameObjectAddon>();
            foreach (var gameobject in gameObjects)
            {
                Row<GameObjectModel> row = new Row<GameObjectModel>();

                GameObject go = gameobject.Value;

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

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

                uint animprogress = 0;
                uint state = 0;
                UpdateField uf;
                if (!go.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(ObjectField.OBJECT_FIELD_ENTRY), out uf))
                    continue;   // broken entry, nothing to spawn

                uint entry = uf.UInt32Value;
                bool badTransport = false;

                if (go.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(GameObjectField.GAMEOBJECT_BYTES_1), out uf))
                {
                    uint bytes = uf.UInt32Value;
                    state = (bytes & 0x000000FF);
                    animprogress = Convert.ToUInt32((bytes & 0xFF000000) >> 24);
                }

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

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

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

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

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

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

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

                    var parentRotation = go.GetParentRotation();

                    if (parentRotation != null)
                    {
                        addonRow.Data.parentRot0 = parentRotation[0].GetValueOrDefault(0.0f);
                        addonRow.Data.parentRot1 = parentRotation[1].GetValueOrDefault(0.0f);
                        addonRow.Data.parentRot2 = parentRotation[2].GetValueOrDefault(0.0f);
                        addonRow.Data.parentRot3 = parentRotation[3].GetValueOrDefault(1.0f);

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

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

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

                row.Data.SpawnTimeSecs = (int)go.GetDefaultSpawnTime();
                row.Data.AnimProgress = animprogress;
                row.Data.State = state;

                // set some defaults
                row.Data.ZoneID = 0;
                row.Data.AreaID = 0;
                row.Data.PhaseGroup = 0;

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

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

                rows.Add(row);
            }

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

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

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

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

            return result.ToString();
        }
Exemplo n.º 22
0
        public static string CreatureText()
        {
            if (Storage.CreatureTexts.IsEmpty() || !Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_text))
                return string.Empty;

            // For each sound and emote, if the time they were send is in the +1/-1 seconds range of
            // our texts, add that sound and emote to our Storage.CreatureTexts

            foreach (var text in Storage.CreatureTexts)
            {
                // For each text
                foreach (var textValue in text.Value)
                {
                    // For each emote
                    var text1 = text;
                    var value1 = textValue;
                    foreach (var emoteValue in from emote in Storage.Emotes where emote.Key.GetEntry() == text1.Key from emoteValue in emote.Value let timeSpan = value1.Item2 - emoteValue.Item2 where timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1) select emoteValue)
                        textValue.Item1.Emote = emoteValue.Item1;

                    // For each sound
                    var value = textValue;
                    foreach (var sound in from sound in Storage.Sounds let timeSpan = value.Item2 - sound.Item2 where timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1) select sound)
                        textValue.Item1.Sound = sound.Item1;

                    List<int> textList;
                    if (SQLDatabase.BroadcastMaleTexts.TryGetValue(textValue.Item1.Text, out textList) ||
                        SQLDatabase.BroadcastFemaleTexts.TryGetValue(textValue.Item1.Text, out textList))
                        textValue.Item1.BroadcastTextID = string.Join(" - ", textList);

                    // Set comment
                    string from = null, to = null;
                    if (!textValue.Item1.SenderGUID.IsEmpty())
                    {
                        if (textValue.Item1.SenderGUID.GetObjectType() == ObjectType.Player)
                            from = "Player";
                        else
                            from = !string.IsNullOrEmpty(textValue.Item1.SenderName) ? textValue.Item1.SenderName : StoreGetters.GetName(StoreNameType.Unit, (int)textValue.Item1.SenderGUID.GetEntry(), false);
                    }

                    if (!textValue.Item1.ReceiverGUID.IsEmpty())
                    {
                        if (textValue.Item1.ReceiverGUID.GetObjectType() == ObjectType.Player)
                            to = "Player";
                        else
                            to = !string.IsNullOrEmpty(textValue.Item1.ReceiverName) ? textValue.Item1.ReceiverName : StoreGetters.GetName(StoreNameType.Unit, (int)textValue.Item1.ReceiverGUID.GetEntry(), false);
                    }

                    Trace.Assert(text.Key == textValue.Item1.SenderGUID.GetEntry() ||
                        text.Key == textValue.Item1.ReceiverGUID.GetEntry());

                    if (from != null && to != null)
                        textValue.Item1.Comment = from + " to " + to;
                    else if (from != null)
                        textValue.Item1.Comment = from;
                    else
                        Trace.Assert(false);
                }
            }

            /* can't use compare DB without knowing values of groupid or id
            var entries = Storage.CreatureTexts.Keys.ToList();
            var creatureTextDb = SQLDatabase.GetDict<uint, CreatureText>(entries);
            */

            var rows = new RowList<CreatureText>();
            foreach (var text in Storage.CreatureTexts)
            {
                foreach (var textValue in text.Value)
                {
                    var row = new Row<CreatureText>
                    {
                        Data = new CreatureText
                        {
                            Entry = text.Key,
                            GroupId = null,
                            ID = null,
                            Text = textValue.Item1.Text,
                            Type = textValue.Item1.Type,
                            Language = textValue.Item1.Language,
                            Probability = 100.0f,
                            Emote = textValue.Item1.Emote,
                            Duration = 0,
                            Sound = textValue.Item1.Sound,
                            BroadcastTextID = textValue.Item1.BroadcastTextID,
                            Comment = textValue.Item1.Comment
                        }
                    };

                    rows.Add(row);
                }
            }

            return new SQLInsert<CreatureText>(rows, false).Build();
        }
Exemplo n.º 23
0
        public static string GameObject(Dictionary <WowGuid, GameObject> gameObjects)
        {
            if (gameObjects.Count == 0)
            {
                return(string.Empty);
            }

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

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

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

                GameObject go = gameobject.Value;

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

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

                uint        animprogress = 0;
                uint        state        = 0;
                UpdateField uf;
                if (!go.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(ObjectField.OBJECT_FIELD_ENTRY), out uf))
                {
                    continue;   // broken entry, nothing to spawn
                }
                uint entry        = uf.UInt32Value;
                bool badTransport = false;

                if (go.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(GameObjectField.GAMEOBJECT_BYTES_1), out uf))
                {
                    uint bytes = uf.UInt32Value;
                    state        = (bytes & 0x000000FF);
                    animprogress = Convert.ToUInt32((bytes & 0xFF000000) >> 24);
                }

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

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

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

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

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

                var rotation = go.GetRotation();
                if (rotation != null && rotation.Length == 4)
                {
                    row.Data.Rotation = rotation.Cast <float?>().ToArray();
                }
                else
                {
                    row.Data.Rotation = new float?[] { 0, 0, 0, 0 }
                };

                row.Data.SpawnTimeSecs = (int)go.GetDefaultSpawnTime();
                row.Data.AnimProgress  = animprogress;
                row.Data.State         = state;

                // set some defaults
                row.Data.ZoneID     = 0;
                row.Data.AreaID     = 0;
                row.Data.PhaseGroup = 0;

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

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

                rows.Add(row);
            }

            StringBuilder result = new StringBuilder();

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

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

            result.Append(sql.Build());
            return(result.ToString());
        }
    }
        //private int CellsColumnIndex = 0;
        private void CGridItemsSource_ExtendedItemsChanged(object item, bool AddOrRemove)
        {
            if (!(item is DeviceModel))
            {
                return;
            }
            DeviceModel device = item as DeviceModel;

            if (AddOrRemove)
            {
                InnerDeviceList.Add(device);
                ConstructionHelper.Add(device);
                foreach (DeviceInterface element in device.InterfaceList)
                {
                    ConstructionHelper.Add(element);
                }
                foreach (List <CellState> RowList in ViewModel.cellsState)
                {
                    for (int i = 0; i < device.InterfaceCount + 1; i++)
                    {
                        RowList.Add(new Model.CellState()
                        {
                            RowState = false, ColumnState = false
                        });
                    }
                }
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    RowCreateHelper.Add(new Model.CellState()
                    {
                        RowState = false, ColumnState = false
                    });
                    PositionHelper.Add(PositionHelperIndex++);
                }
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    ViewModel.cellsState.Add(new List <Model.CellState>(RowCreateHelper));
                }
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    this.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(20, GridUnitType.Auto)
                    });
                    this.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(20, GridUnitType.Auto)
                    });
                }
                foreach (List <Control> RowList in CellsControl)
                {
                    int RowIndex = CellsControl.IndexOf(RowList);
                    for (int i = 0; i < device.InterfaceCount + 1; i++)
                    {
                        object TempDev = ConstructionHelper[RowIndex] as object;
                        if (i == 0)
                        {
                            int     ColumnIndex = ConstructionHelper.IndexOf(device);
                            Control CellControl = CellFactory.CreateCell(TempDev, device, RowIndex, ColumnIndex);
                            this.Children.Add(CellControl);
                            RowList.Add(CellControl);
                            Grid.SetColumn(CellControl, this.ColumnDefinitions.Count + i - device.InterfaceCount - 1);
                            Grid.SetRow(CellControl, PositionHelper[RowIndex]);
                        }
                        else
                        {
                            int     ColumnIndex = ConstructionHelper.IndexOf(device.InterfaceList[i - 1]);
                            Control CellControl = CellFactory.CreateCell(TempDev, device.InterfaceList[i - 1], RowIndex, ColumnIndex);
                            this.Children.Add(CellControl);
                            RowList.Add(CellControl);
                            Grid.SetColumn(CellControl, this.ColumnDefinitions.Count + i - device.InterfaceCount - 1);
                            Grid.SetRow(CellControl, PositionHelper[RowIndex]);
                        }
                    }
                }

                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    List <Control> tempRow = new List <Control>();
                    if (i == 0)
                    {
                        for (int ColumnIndex = 0; ColumnIndex < ConstructionHelper.Count; ColumnIndex++)
                        {
                            Control CellControl = CellFactory.CreateCell(device, ConstructionHelper[ColumnIndex], CellsControl.Count, ColumnIndex);
                            tempRow.Add(CellControl);
                            this.Children.Add(CellControl);
                            Grid.SetColumn(CellControl, PositionHelper[ColumnIndex]);
                            Grid.SetRow(CellControl, RowDefinitions.Count - device.InterfaceCount - 1 + i);
                        }
                    }
                    else
                    {
                        for (int ColumnIndex = 0; ColumnIndex < ConstructionHelper.Count; ColumnIndex++)
                        {
                            Control CellControl = CellFactory.CreateCell(device.InterfaceList[i - 1], ConstructionHelper[ColumnIndex], CellsControl.Count, ColumnIndex);
                            tempRow.Add(CellControl);
                            this.Children.Add(CellControl);
                            Grid.SetColumn(CellControl, PositionHelper[ColumnIndex]);
                            Grid.SetRow(CellControl, RowDefinitions.Count - device.InterfaceCount - 1 + i);
                        }
                    }
                    CellsControl.Add(tempRow);
                }
                Debug.WriteLine("CellsState measure " + ViewModel.cellsState.Count + " " + ViewModel.cellsState.First().Count);
                Debug.WriteLine("CellsControl measure " + CellsControl.Count + " " + CellsControl.First().Count);
                Debug.WriteLine("grid children count " + this.Children.Count);
                int r = 0;
                foreach (Control cell in this.Children)
                {
                    cell.Visibility = Visibility.Visible;
                    if (cell is CToggleBtn)
                    {
                        Debug.Write("one ctoggleBtn" + (++r));
                    }
                }
            }
            else
            {
                int Index       = InnerDeviceList.IndexOf(device);
                int RemoveIndex = ConstructionHelper.IndexOf(device);
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    ViewModel.cellsState.RemoveAt(RemoveIndex);
                }
                foreach (List <CellState> RowList in ViewModel.cellsState)
                {
                    for (int i = 0; i < device.InterfaceCount + 1; i++)
                    {
                        RowList.RemoveAt(RemoveIndex);
                    }
                }
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    ConstructionHelper.RemoveAt(RemoveIndex);
                    RowCreateHelper.RemoveAt(RemoveIndex);
                    PositionHelper.RemoveAt(RemoveIndex);
                }
                InnerDeviceList.Remove((DeviceModel)item);
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    foreach (Control Cell in CellsControl[RemoveIndex])
                    {
                        this.Children.Remove(Cell);
                    }
                    CellsControl.RemoveAt(RemoveIndex);
                }
                foreach (List <Control> rowlist in CellsControl)
                {
                    for (int i = 0; i < device.InterfaceCount + 1; i++)
                    {
                        this.Children.Remove(rowlist[RemoveIndex]);
                        rowlist.RemoveAt(RemoveIndex);
                    }
                }
                if (ViewModel.cellsState.Count == 0)
                {
                    return;
                }
                Debug.WriteLine("CellsState measure " + ViewModel.cellsState.Count + " " + ViewModel.cellsState.First().Count);
                Debug.WriteLine("CellsControl measure " + CellsControl.Count + " " + CellsControl.First().Count);
                Debug.WriteLine("grid children count " + this.Children.Count);
                int r = 0;
                foreach (Control cell in this.Children)
                {
                    cell.Visibility = Visibility.Visible;
                    if (cell is CToggleBtn)
                    {
                        Debug.Write("one ctoggleBtn" + (++r));
                    }
                }
            }
        }
Exemplo n.º 25
0
        //Override the OnPrintPage to provide the printing logic for the document
        protected override void OnPrintPage(PrintPageEventArgs ev)
        {
            int   count       = 0;
            float leftMargin  = ev.MarginBounds.Left;
            float rightMargin = ev.MarginBounds.Right;
            float topMargin   = ev.MarginBounds.Top;

            //ev.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            if (rc == null)
            {
                Document.ParseAll();
                Document.ParseAll(true);


                rc = new RowList();
                foreach (Row r in Document)
                {
                    bool  hasbreak = false;
                    float x        = leftMargin;
                    var   newRow   = new Row();
                    rc.Add(newRow);
                    foreach (Word w in r)
                    {
                        Font f = fontNormal;
                        if (w.Style != null)
                        {
                            FontStyle fs = 0;

                            if (w.Style.Bold)
                            {
                                fs |= FontStyle.Bold;
                            }

                            if (w.Style.Italic)
                            {
                                fs |= FontStyle.Italic;
                            }

                            if (w.Style.Underline)
                            {
                                fs |= FontStyle.Underline;
                            }

                            f = new Font("Courier new", 8, fs);
                        }
                        SizeF sf = ev.Graphics.MeasureString(w.Text, f);
                        if (x + sf.Width > rightMargin)
                        {
                            var chr = (char)0xbf;
                            var br  = new Word {
                                Text = (chr + ""), InfoTip = "break char"
                            };
                            newRow.Add(br);
                            hasbreak = true;


                            newRow = new Row();
                            rc.Add(newRow);
                            x = leftMargin;
                        }
                        x += sf.Width;
                        newRow.Add(w);
                    }
                    if (hasbreak)
                    {
                        rc.Add(new Row());
                    }
                }
            }
            //------------------------------------------------------

            base.OnPrintPage(ev);


            float lpp = ev.MarginBounds.Height / fontNormal.GetHeight(ev.Graphics);


            while (count < lpp && (RowIndex < rc.Count))
            {
                float x    = leftMargin;
                float yPos = topMargin + (count * fontNormal.GetHeight(ev.Graphics));

                Row r = rc[RowIndex];

                foreach (Word w in r)
                {
                    if (w.InfoTip != null && w.InfoTip == "break char")
                    {
                        ev.Graphics.DrawString(w.Text, fontBreak, Brushes.Black, x, yPos, new StringFormat());
                    }
                    else
                    {
                        SizeF sf = ev.Graphics.MeasureString(w.Text, fontNormal);

                        if (w.Text != null && (".,:;".IndexOf(w.Text) >= 0))
                        {
                            sf.Width = 6;
                            x       -= 4;
                        }
                        if (w.Text == "\t")
                        {
                            sf.Width = ev.Graphics.MeasureString("...", fontNormal).Width;
                        }


                        Color c = Color.Black;
                        Font  f = fontNormal;
                        if (w.Style != null)
                        {
                            c = w.Style.ForeColor;
                            FontStyle fs = 0;

                            if (w.Style.Bold)
                            {
                                fs |= FontStyle.Bold;
                            }

                            if (w.Style.Italic)
                            {
                                fs |= FontStyle.Italic;
                            }

                            if (w.Style.Underline)
                            {
                                fs |= FontStyle.Underline;
                            }

                            f = new Font("Courier new", 8, fs);

                            if (!w.Style.Transparent)
                            {
                                Color bg = w.Style.BackColor;
                                ev.Graphics.FillRectangle(new SolidBrush(bg), x, yPos, sf.Width,
                                                          fontNormal.GetHeight(ev.Graphics));
                            }
                        }

                        c = Color.FromArgb(c.R, c.G, c.B);


                        ev.Graphics.DrawString(w.Text, f, new SolidBrush(c), x, yPos, new StringFormat());
                        x += sf.Width;
                    }
                }

                count++;
                RowIndex++;
            }

            //If we have more lines then print another page
            ev.HasMorePages = RowIndex < rc.Count;
        }
Exemplo n.º 26
0
        public static string CreatureText()
        {
            if (Storage.CreatureTexts.IsEmpty() || !Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.creature_text))
            {
                return(string.Empty);
            }

            // For each sound and emote, if the time they were send is in the +1/-1 seconds range of
            // our texts, add that sound and emote to our Storage.CreatureTexts

            foreach (var text in Storage.CreatureTexts)
            {
                // For each text
                foreach (var textValue in text.Value)
                {
                    // For each emote
                    var text1  = text;
                    var value1 = textValue;
                    foreach (var emoteValue in from emote in Storage.Emotes where emote.Key.GetEntry() == text1.Key from emoteValue in emote.Value let timeSpan = value1.Item2 - emoteValue.Item2 where timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1) select emoteValue)
                    {
                        textValue.Item1.Emote = emoteValue.Item1;
                    }

                    // For each sound
                    var value = textValue;
                    foreach (var sound in from sound in Storage.Sounds let timeSpan = value.Item2 - sound.Item2 where timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1) select sound)
                    {
                        textValue.Item1.Sound = sound.Item1;
                    }

                    List <int> textList;
                    if (SQLDatabase.BroadcastTexts.TryGetValue(textValue.Item1.Text, out textList) ||
                        SQLDatabase.BroadcastText1s.TryGetValue(textValue.Item1.Text, out textList))
                    {
                        if (textList.Count == 1)
                        {
                            textValue.Item1.BroadcastTextID = (uint)textList.First();
                        }
                        else
                        {
                            textValue.Item1.BroadcastTextID        = "PLEASE_SET_A_BROADCASTTEXT_ID";
                            textValue.Item1.BroadcastTextIDHelper  = "BroadcastTextID: ";
                            textValue.Item1.BroadcastTextIDHelper += string.Join(" - ", textList);
                        }
                    }

                    // Set comment
                    string from = null, to = null;
                    if (!textValue.Item1.SenderGUID.IsEmpty())
                    {
                        if (textValue.Item1.SenderGUID.GetObjectType() == ObjectType.Player)
                        {
                            from = "Player";
                        }
                        else
                        {
                            from = !string.IsNullOrEmpty(textValue.Item1.SenderName) ? textValue.Item1.SenderName : StoreGetters.GetName(StoreNameType.Unit, (int)textValue.Item1.SenderGUID.GetEntry(), false);
                        }
                    }

                    if (!textValue.Item1.ReceiverGUID.IsEmpty())
                    {
                        if (textValue.Item1.ReceiverGUID.GetObjectType() == ObjectType.Player)
                        {
                            to = "Player";
                        }
                        else
                        {
                            to = !string.IsNullOrEmpty(textValue.Item1.ReceiverName) ? textValue.Item1.ReceiverName : StoreGetters.GetName(StoreNameType.Unit, (int)textValue.Item1.ReceiverGUID.GetEntry(), false);
                        }
                    }

                    Trace.Assert(text.Key == textValue.Item1.SenderGUID.GetEntry() ||
                                 text.Key == textValue.Item1.ReceiverGUID.GetEntry());

                    if (from != null && to != null)
                    {
                        textValue.Item1.Comment = from + " to " + to;
                    }
                    else if (from != null)
                    {
                        textValue.Item1.Comment = from;
                    }
                    else
                    {
                        Trace.Assert(false);
                    }
                }
            }

            /* can't use compare DB without knowing values of groupid or id
             * var entries = Storage.CreatureTexts.Keys.ToList();
             * var creatureTextDb = SQLDatabase.GetDict<uint, CreatureText>(entries);
             */

            var rows = new RowList <CreatureText>();
            Dictionary <uint, uint> entryCount = new Dictionary <uint, uint>();

            foreach (var text in Storage.CreatureTexts.OrderBy(t => t.Key))
            {
                foreach (var textValue in text.Value)
                {
                    var count = entryCount.ContainsKey(text.Key) ? entryCount[text.Key] : 0;

                    if (rows.Where(text2 => text2.Data.Entry == text.Key && text2.Data.Text == textValue.Item1.Text).Count() != 0)
                    {
                        continue;
                    }

                    var row = new Row <CreatureText>
                    {
                        Data = new CreatureText
                        {
                            Entry           = text.Key,
                            GroupId         = "@GROUP_ID+" + count,
                            ID              = "@ID+",
                            Text            = textValue.Item1.Text,
                            Type            = textValue.Item1.Type,
                            Language        = textValue.Item1.Language,
                            Probability     = 100.0f,
                            Emote           = (textValue.Item1.Emote != null ? textValue.Item1.Emote : 0),
                            Duration        = 0,
                            Sound           = (textValue.Item1.Sound != null ? textValue.Item1.Sound : 0),
                            BroadcastTextID = textValue.Item1.BroadcastTextID,
                            Comment         = textValue.Item1.Comment
                        },

                        Comment = textValue.Item1.BroadcastTextIDHelper
                    };

                    if (!entryCount.ContainsKey(text.Key))
                    {
                        entryCount.Add(text.Key, count + 1);
                    }
                    else
                    {
                        entryCount[text.Key] = count + 1;
                    }

                    rows.Add(row);
                }
            }

            return(new SQLInsert <CreatureText>(rows, false).Build());
        }
Exemplo n.º 27
0
        //Override the OnPrintPage to provide the printing logic for the document
        protected override void OnPrintPage(PrintPageEventArgs ev)
        {
            int count = 0;
            float leftMargin = ev.MarginBounds.Left;
            float rightMargin = ev.MarginBounds.Right;
            float topMargin = ev.MarginBounds.Top;
            //ev.Graphics.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;

            if (rc == null)
            {
                Document.ParseAll();
                Document.ParseAll(true);


                rc = new RowList();
                foreach (Row r in Document)
                {
                    bool hasbreak = false;
                    float x = leftMargin;
                    var newRow = new Row();
                    rc.Add(newRow);
                    foreach (Word w in r)
                    {
                        Font f = fontNormal;
                        if (w.Style != null)
                        {
                            FontStyle fs = 0;

                            if (w.Style.Bold)
                                fs |= FontStyle.Bold;

                            if (w.Style.Italic)
                                fs |= FontStyle.Italic;

                            if (w.Style.Underline)
                                fs |= FontStyle.Underline;

                            f = new Font("Courier new", 8, fs);
                        }
                        SizeF sf = ev.Graphics.MeasureString(w.Text, f);
                        if (x + sf.Width > rightMargin)
                        {
                            var chr = (char) 0xbf;
                            var br = new Word {Text = (chr + ""), InfoTip = "break char"};
                            newRow.Add(br);
                            hasbreak = true;


                            newRow = new Row();
                            rc.Add(newRow);
                            x = leftMargin;
                        }
                        x += sf.Width;
                        newRow.Add(w);
                    }
                    if (hasbreak)
                    {
                        rc.Add(new Row());
                    }
                }
            }
            //------------------------------------------------------

            base.OnPrintPage(ev);


            float lpp = ev.MarginBounds.Height/fontNormal.GetHeight(ev.Graphics);


            while (count < lpp && (RowIndex < rc.Count))
            {
                float x = leftMargin;
                float yPos = topMargin + (count*fontNormal.GetHeight(ev.Graphics));

                Row r = rc[RowIndex];

                foreach (Word w in r)
                {
                    if (w.InfoTip != null && w.InfoTip == "break char")
                    {
                        ev.Graphics.DrawString(w.Text, fontBreak, Brushes.Black, x, yPos,
                                               new StringFormat());
                    }
                    else
                    {
                        SizeF sf = ev.Graphics.MeasureString(w.Text, fontNormal);

                        if (w.Text != null && (".,:;".IndexOf(w.Text) >= 0))
                        {
                            sf.Width = 6;
                            x -= 4;
                        }
                        if (w.Text == "\t")
                        {
                            sf.Width = ev.Graphics.MeasureString("...", fontNormal).Width;
                        }


                        Color c = Color.Black;
                        Font f = fontNormal;
                        if (w.Style != null)
                        {
                            c = w.Style.ForeColor;
                            FontStyle fs = 0;

                            if (w.Style.Bold)
                                fs |= FontStyle.Bold;

                            if (w.Style.Italic)
                                fs |= FontStyle.Italic;

                            if (w.Style.Underline)
                                fs |= FontStyle.Underline;

                            f = new Font("Courier new", 8, fs);

                            if (!w.Style.Transparent)
                            {
                                Color bg = w.Style.BackColor;
                                ev.Graphics.FillRectangle(new SolidBrush(bg), x, yPos, sf.Width,
                                                          fontNormal.GetHeight(ev.Graphics));
                            }
                        }

                        c = Color.FromArgb(c.R, c.G, c.B);


                        ev.Graphics.DrawString(w.Text, f, new SolidBrush(c), x, yPos, new
                                                                                          StringFormat());
                        x += sf.Width;
                    }
                }

                count++;
                RowIndex++;
            }

            //If we have more lines then print another page
            ev.HasMorePages = RowIndex < rc.Count;
        }
Exemplo n.º 28
0
        public static string NpcSpellClickMop(Dictionary<WowGuid, Unit> units)
        {
            if (units.Count == 0 || !Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.npc_spellclick_spells))
                return string.Empty;

            var rows = new RowList<NpcSpellClick>();

            foreach (var unit in units)
            {
                var row = new Row<NpcSpellClick>();

                var npc = unit.Value;
                if (npc.InteractSpellID == null)
                    continue;

                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;

                row.Data.Entry = unit.Key.GetEntry();
                row.Data.SpellID = npc.InteractSpellID.GetValueOrDefault();

                rows.Add(row);
            }

            return new SQLInsert<NpcSpellClick>(rows, false).Build();
        }
Exemplo n.º 29
0
        public static string Creature(Dictionary<WowGuid, Unit> units)
        {
            if (units.Count == 0)
                return string.Empty;

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

            uint count = 0;
            var rows = new RowList<Creature>();
            var addonRows = new RowList<CreatureAddon>();
            foreach (var unit in units)
            {
                Row<Creature> row = new Row<Creature>();
                bool badTransport = false;

                Unit creature = unit.Value;

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

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

                UpdateField uf;
                if (!creature.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(ObjectField.OBJECT_FIELD_ENTRY), out uf))
                    continue;   // broken entry, nothing to spawn

                uint entry = uf.UInt32Value;

                uint movementType = 0;
                int spawnDist = 0;

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

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

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

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

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

                    row.Data.PhaseID = data;
                }

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

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

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

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

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

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

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

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

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

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

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

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

                rows.Add(row);
            }

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

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

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

            return result.ToString();
        }
Exemplo n.º 30
0
        public static string CreatureText()
        {
            if (Storage.CreatureTexts.IsEmpty())
            {
                return(string.Empty);
            }

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

            // For each sound and emote, if the time they were send is in the +1/-1 seconds range of
            // our texts, add that sound and emote to our Storage.CreatureTexts

            var broadcastTextStoresMale   = SQLDatabase.BroadcastTextStores.GroupBy(blub => blub.Item2.MaleText).ToDictionary(group => group.Key, group => group.ToList());
            var broadcastTextStoresFemale = SQLDatabase.BroadcastTextStores.GroupBy(blub => blub.Item2.FemaleText).ToDictionary(group => group.Key, group => group.ToList());

            foreach (var text in Storage.CreatureTexts)
            {
                // For each text
                foreach (var textValue in text.Value)
                {
                    // For each emote
                    var text1  = text;
                    var value1 = textValue;
                    foreach (var emoteValue in from emote in Storage.Emotes where emote.Key.GetEntry() == text1.Key from emoteValue in emote.Value let timeSpan = value1.Item2 - emoteValue.Item2 where timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1) select emoteValue)
                    {
                        textValue.Item1.Emote = emoteValue.Item1;
                    }

                    // For each sound
                    var value = textValue;
                    foreach (var sound in from sound in Storage.Sounds let timeSpan = value.Item2 - sound.Item2 where timeSpan != null && timeSpan.Value.Duration() <= TimeSpan.FromSeconds(1) select sound)
                    {
                        textValue.Item1.Sound = sound.Item1;
                    }

                    if (SQLDatabase.BroadcastTextStores != null)
                    {
                        List <Tuple <uint, BroadcastText> > textList;
                        if (broadcastTextStoresMale.TryGetValue(textValue.Item1.Text, out textList) ||
                            broadcastTextStoresFemale.TryGetValue(textValue.Item1.Text, out textList))
                        {
                            foreach (var broadcastTextId in textList)
                            {
                                if (!string.IsNullOrWhiteSpace(textValue.Item1.BroadcastTextID))
                                {
                                    textValue.Item1.BroadcastTextID += " - " + broadcastTextId.Item1;
                                }
                                else
                                {
                                    textValue.Item1.BroadcastTextID = broadcastTextId.Item1.ToString();
                                }
                            }
                        }
                    }

                    // Set comment
                    string from = null, to = null;
                    if (!textValue.Item1.SenderGUID.IsEmpty())
                    {
                        if (textValue.Item1.SenderGUID.GetObjectType() == ObjectType.Player)
                        {
                            from = "Player";
                        }
                        else
                        {
                            @from = !string.IsNullOrEmpty(textValue.Item1.SenderName) ? textValue.Item1.SenderName : StoreGetters.GetName(StoreNameType.Unit, (int)textValue.Item1.SenderGUID.GetEntry(), false);
                        }
                    }

                    if (!textValue.Item1.ReceiverGUID.IsEmpty())
                    {
                        if (textValue.Item1.ReceiverGUID.GetObjectType() == ObjectType.Player)
                        {
                            to = "Player";
                        }
                        else
                        {
                            to = !string.IsNullOrEmpty(textValue.Item1.ReceiverName) ? textValue.Item1.ReceiverName : StoreGetters.GetName(StoreNameType.Unit, (int)textValue.Item1.ReceiverGUID.GetEntry(), false);
                        }
                    }

                    Trace.Assert(text.Key == textValue.Item1.SenderGUID.GetEntry() ||
                                 text.Key == textValue.Item1.ReceiverGUID.GetEntry());

                    if (from != null && to != null)
                    {
                        textValue.Item1.Comment = from + " to " + to;
                    }
                    else if (from != null)
                    {
                        textValue.Item1.Comment = from;
                    }
                    else
                    {
                        Trace.Assert(false);
                    }
                }
            }

            /* can't use compare DB without knowing values of groupid or id
             * var entries = Storage.CreatureTexts.Keys.ToList();
             * var creatureTextDb = SQLDatabase.GetDict<uint, CreatureText>(entries);
             */

            var rows = new RowList <CreatureText>();

            foreach (var text in Storage.CreatureTexts)
            {
                foreach (var textValue in text.Value)
                {
                    var row = new Row <CreatureText>
                    {
                        Data = new CreatureText
                        {
                            Entry           = text.Key,
                            GroupId         = null,
                            ID              = null,
                            Text            = textValue.Item1.Text,
                            Type            = textValue.Item1.Type,
                            Language        = textValue.Item1.Language,
                            Probability     = 100.0f,
                            Emote           = textValue.Item1.Emote,
                            Duration        = 0,
                            Sound           = textValue.Item1.Sound,
                            BroadcastTextID = textValue.Item1.BroadcastTextID,
                            Comment         = textValue.Item1.Comment
                        }
                    };

                    rows.Add(row);
                }
            }

            return(new SQLInsert <CreatureText>(rows, false).Build());
        }
Exemplo n.º 31
0
        public static string Creature(Dictionary <WowGuid, Unit> units)
        {
            if (units.Count == 0)
            {
                return(string.Empty);
            }

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

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

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

                Unit creature = unit.Value;

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

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

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

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

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

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

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

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

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

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

                    row.Data.spawnDifficulties = data;
                }

                row.Data.PhaseMask = creature.PhaseMask;

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

                    row.Data.PhaseID = data;
                }

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

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

                // set some defaults
                row.Data.PhaseGroup      = 0;
                row.Data.ModelID         = 0;
                row.Data.CurrentWaypoint = 0;
                row.Data.CurHealth       = (uint)creature.UnitData.MaxHealth;
                row.Data.CurMana         = (uint)creature.UnitData.MaxPower[0];
                row.Data.NpcFlag         = 0;
                row.Data.UnitFlag        = 0;
                row.Data.DynamicFlag     = 0;

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

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

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

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

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

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

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

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

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

                rows.Add(row);
            }

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

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

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

            result.Append(sql.Build());

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

            return(result.ToString());
        }
Exemplo n.º 32
0
        public static string VehicleAccessory()
        {
            if (Storage.VehicleTemplateAccessories.IsEmpty() || !Settings.SQLOutputFlag.HasAnyFlagBit(SQLOutput.vehicle_template_accessory))
                return string.Empty;

            var rows = new RowList<VehicleTemplateAccessory>();
            foreach (var accessory in Storage.VehicleTemplateAccessories)
            {
                if (accessory.Item1.SeatId < 0 || accessory.Item1.SeatId > 7)
                    continue;

                // ReSharper disable once UseObjectOrCollectionInitializer
                var row = new Row<VehicleTemplateAccessory>();
                row.Comment = StoreGetters.GetName(StoreNameType.Unit, (int)accessory.Item1.Entry.GetValueOrDefault(), false) + " - ";
                row.Comment += StoreGetters.GetName(StoreNameType.Unit, (int)accessory.Item1.AccessoryEntry.GetValueOrDefault(), false);
                accessory.Item1.Description = row.Comment;
                row.Data = accessory.Item1;

                rows.Add(row);
            }

            return new SQLInsert<VehicleTemplateAccessory>(rows, false).Build();
        }
Exemplo n.º 33
0
        // [BuilderMethod(Units = true)] // this method has to be run before generating creature spawns, with this attribute the order isn't ensured
        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 equips         = new DataBag <CreatureEquipment>();
            var equipsDb       = new RowList <CreatureEquipment>();
            var newEntriesDict = new Dictionary <uint? /*CreatureID*/, List <CreatureEquipment> >();

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

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

                var equip = npc.Value.GetEquipment();
                if (equip == null)
                {
                    continue;
                }

                if (SQLDatabase.CreatureEquipments.TryGetValue(npc.Key.GetEntry(), out var equipListDB))
                {
                    var equipDB = GetDuplicateEquipFromList(equip, equipListDB);
                    if (equipDB != null)
                    {
                        if (equipDB.VerifiedBuild >= equip.VerifiedBuild)
                        {
                            continue;
                        }

                        equip.ID = equipDB.ID;
                        equipsDb.Add(equipDB); // add to entries to compare to
                    }
                    else
                    {
                        equip.ID = (uint)equipListDB.Count + 1;
                        equipListDB.Add(equip);
                    }
                }
                else
                {
                    if (newEntriesDict.TryGetValue(equip.CreatureID, out var equipList))
                    {
                        if (GetDuplicateEquipFromList(equip, equipList) != null)
                        {
                            continue;
                        }

                        equip.ID = (uint)equipList.Count + 1;
                        equipList.Add(equip);
                    }
                    else
                    {
                        equip.ID = 1;
                        newEntriesDict.Add(equip.CreatureID, new List <CreatureEquipment>()
                        {
                            equip
                        });
                    }
                }

                equips.Add(equip);
            }

            return(SQLUtil.Compare(Settings.SQLOrderByKey ? equips.OrderBy(x => x.Item1.CreatureID).ThenBy(y => y.Item1.ID) : equips, equipsDb, StoreNameType.Unit));
        }
Exemplo n.º 34
0
        public static string WeatherUpdates()
        {
            if (Storage.WeatherUpdates.IsEmpty())
                return string.Empty;

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

            var rows = new RowList<WeatherUpdate>();
            foreach (var row in Storage.WeatherUpdates.Select(weatherUpdate => new Row<WeatherUpdate>
            {
                Data = weatherUpdate.Item1,
                Comment = StoreGetters.GetName(StoreNameType.Map, (int)weatherUpdate.Item1.MapId.GetValueOrDefault(), false) +
                          " - " + weatherUpdate.Item1.State + " - " + weatherUpdate.Item1.Grade
            }))
            {
                rows.Add(row);
            }

            return new SQLInsert<WeatherUpdate>(rows, ignore: true, withDelete: false).Build();
        }
Exemplo n.º 35
0
        public static string GameObject(Dictionary <WowGuid, GameObject> gameObjects)
        {
            if (gameObjects.Count == 0)
            {
                return(string.Empty);
            }

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

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

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

                GameObject go = gameobject.Value;

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

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

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

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

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

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

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

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

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


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

                    row.Data.spawnDifficulties = data;
                }

                row.Data.PhaseMask = go.PhaseMask;

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

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

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

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

                    var parentRotation = go.GetParentRotation();

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

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

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

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

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

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

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

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

                rows.Add(row);
            }

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

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

            result.Append(delete.Build());

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

            result.Append(sql.Build());

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

            return(result.ToString());
        }
Exemplo n.º 36
0
        private void InternalResetVisibleRows()
        {
//			if (System.DateTime.Now > new DateTime (2002,12,31))
//			{
//				
//				this.rows = new RowList ();
//				this.Add ("BETA VERSION EXPIRED");
//				VisibleRows = this.rows;
//				return;
//			}

            if (!folding)
            {
                VisibleRows = rows;
                NeedResetRows = false;
            }
            else
            {
                NeedResetRows = false;
                VisibleRows = new RowList(); //.Clear ();			
                int RealRow = 0;
                for (int i = 0; i < Count; i++)
                {
                    Row r = this[RealRow];
                    VisibleRows.Add(r);
                    bool collapsed = false;
                    if (r.CanFold)
                        if (r.expansion_StartSpan.Expanded == false)
                        {
                            if (r.expansion_StartSpan.EndWord == null) {}
                            else
                            {
                                r = r.Expansion_EndRow; // .expansion_StartSpan.EndRow;
                                collapsed = true;
                            }
                        }

                    if (!collapsed)
                        RealRow++;
                    else
                        RealRow = IndexOf(r) + 1;

                    if (RealRow >= Count)
                        break;
                }
            }
        }
Exemplo n.º 37
0
        private void CGridItemsSource_ExtendedItemsChanged(object item, bool AddOrRemove)
        {
            if (!(item is DeviceModel))
            {
                return;
            }
            if (AddOrRemove)
            {
                DeviceModel device = item as DeviceModel;
                InnerDeviceList.Add(device);
                ConstructionHelper.Add(device);
                foreach (DeviceInterface element in device.InterfaceList)
                {
                    ConstructionHelper.Add(element);
                }
                foreach (List <CellState> RowList in ViewModel.cellsState)
                {
                    for (int i = 0; i < device.InterfaceCount + 1; i++)
                    {
                        RowList.Add(new Model.CellState()
                        {
                            RowState = false, ColumnState = false
                        });
                    }
                }
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    RowCreateHelper.Add(new Model.CellState()
                    {
                        RowState = false, ColumnState = false
                    });
                }
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    ViewModel.cellsState.Add(new List <Model.CellState>(RowCreateHelper));
                }
                foreach (List <CellState> RowList in ViewModel.cellsState)
                {
                    foreach (var e in RowList)
                    {
                        Debug.Write("1--");
                    }
                    Debug.Write("\n");
                }

                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    this.ColumnDefinitions.Add(new ColumnDefinition()
                    {
                        Width = new GridLength(0, GridUnitType.Auto)
                    });
                    this.RowDefinitions.Add(new RowDefinition()
                    {
                        Height = new GridLength(0, GridUnitType.Auto)
                    });
                }

                foreach (List <Control> RowList in CellsControl)
                {
                    int RowIndex = CellsControl.IndexOf(RowList);
                    for (int i = 0; i < device.InterfaceCount + 1; i++)
                    {
                        if (ConstructionHelper[RowIndex] is DeviceModel)
                        {
                            DeviceModel TempDev = ConstructionHelper[RowIndex] as DeviceModel;
                            if (i == 0)
                            {
                                CToggleBtn TempBtn = new CToggleBtn()
                                {
                                };
                                TempBtn.ToolTip = string.Format(TempDev.DeviceName + "&&" + device.DeviceName);

                                int ColumnIndex = ConstructionHelper.IndexOf(device);
                                Grid.SetColumn(TempBtn, ColumnIndex);
                                Grid.SetRow(TempBtn, RowIndex);
                                Binding B1 = new Binding("RowState")
                                {
                                    Source = cellsState[RowIndex][ColumnIndex]
                                };
                                Binding B2 = new Binding("Column")
                                {
                                    Source = cellsState[RowIndex][ColumnIndex]
                                };

                                MultiBinding MBinding = new MultiBinding()
                                {
                                    Mode = BindingMode.OneWay
                                };
                                MBinding.Bindings.Add(B1);
                                MBinding.Bindings.Add(B2);
                                MBinding.Converter = Converter.CellStateConverter;

                                TempBtn.SetBinding(CToggleBtn.ChangedIconProperty, MBinding);
                            }
                            else
                            {
                                CLabel TempCLabel = new CLabel()
                                {
                                    IsCommon = false
                                };
                                TempCLabel.ToolTip = string.Format(TempDev.DeviceName);
                                int ColumnIndex = ConstructionHelper.IndexOf(device.InterfaceList[i - 1]);
                                Grid.SetColumn(TempCLabel, ColumnIndex);
                                Grid.SetRow(TempCLabel, RowIndex);

                                Binding B1 = new Binding("RowState")
                                {
                                    Source = cellsState[RowIndex][ColumnIndex]
                                };
                                Binding B2 = new Binding("Column")
                                {
                                    Source = cellsState[RowIndex][ColumnIndex]
                                };

                                MultiBinding MBinding = new MultiBinding()
                                {
                                    Mode = BindingMode.OneWay
                                };
                                MBinding.Bindings.Add(B1);
                                MBinding.Bindings.Add(B2);
                                MBinding.Converter = Converter.CellStateConverter;
                                TempCLabel.SetBinding(CLabel.IsSelectedProperty, MBinding);
                            }
                        }
                        else
                        {
                            DeviceInterface TempInterface = ConstructionHelper[RowIndex] as DeviceInterface;
                            if (i == 0)
                            {
                                CLabel TempCLabel = new CLabel()
                                {
                                    IsCommon = false
                                };
                                TempCLabel.ToolTip = string.Format(device.DeviceName);
                                int ColumnIndex = ConstructionHelper.IndexOf(device);

                                Grid.SetColumn(TempCLabel, ColumnIndex);
                                Grid.SetRow(TempCLabel, RowIndex);

                                Binding B1 = new Binding("RowState")
                                {
                                    Source = cellsState[RowIndex][ColumnIndex]
                                };
                                Binding B2 = new Binding("Column")
                                {
                                    Source = cellsState[RowIndex][ColumnIndex]
                                };

                                MultiBinding MBinding = new MultiBinding()
                                {
                                    Mode = BindingMode.OneWay
                                };
                                MBinding.Bindings.Add(B1);
                                MBinding.Bindings.Add(B2);
                                MBinding.Converter = Converter.CellStateConverter;

                                TempCLabel.SetBinding(CToggleBtn.ChangedIconProperty, MBinding);
                            }
                            else
                            {
                                CLabel TempCLabel = new CLabel()
                                {
                                    IsCommon = true
                                };
                                TempCLabel.ToolTip = string.Format(TempInterface.InterfaceName + "=>" + device.InterfaceList[i - 1].InterfaceName);
                                int ColumnIndex = ConstructionHelper.IndexOf(device.InterfaceList[i - 1]);
                                Grid.SetColumn(TempCLabel, ColumnIndex);
                                Grid.SetRow(TempCLabel, RowIndex);
                                Binding B1 = new Binding("RowState")
                                {
                                    Source = cellsState[RowIndex][ColumnIndex]
                                };
                                Binding B2 = new Binding("Column")
                                {
                                    Source = cellsState[RowIndex][ColumnIndex]
                                };

                                MultiBinding MBinding = new MultiBinding()
                                {
                                    Mode = BindingMode.OneWay
                                };
                                MBinding.Bindings.Add(B1);
                                MBinding.Bindings.Add(B2);
                                MBinding.Converter = Converter.CellStateConverter;
                                TempCLabel.SetBinding(CLabel.IsSelectedProperty, MBinding);
                            }
                        }
                    }
                }

                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    if (i == 0)
                    {
                        foreach (var e in ConstructionHelper)
                        {
                            CToggleBtn TempBtn = new CToggleBtn()
                            {
                            };
                        }
                    }
                    else
                    {
                    }
                }
            }
            else
            {
                DeviceModel device      = item as DeviceModel;
                int         Index       = InnerDeviceList.IndexOf(device);
                int         RemoveIndex = ConstructionHelper.IndexOf(device);
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    ViewModel.cellsState.RemoveAt(RemoveIndex);
                }
                foreach (List <CellState> RowList in ViewModel.cellsState)
                {
                    for (int i = 0; i < device.InterfaceCount + 1; i++)
                    {
                        RowList.RemoveAt(RemoveIndex);
                    }
                }
                for (int i = 0; i < device.InterfaceCount + 1; i++)
                {
                    ConstructionHelper.RemoveAt(RemoveIndex);
                    RowCreateHelper.RemoveAt(RemoveIndex);
                }
                InnerDeviceList.Remove((DeviceModel)item);
                foreach (List <CellState> RowList in ViewModel.cellsState)
                {
                    foreach (var e in RowList)
                    {
                        Debug.Write("1--");
                    }
                    Debug.Write("\n");
                }
            }
        }