public string StartInformation()
        {
            var result = string.Empty;

            if (!_stuffing.StartActions.IsEmpty)
            {
                // Can't cast the collection directly
                ICollection<Tuple<uint, uint>> keys = new Collection<Tuple<uint, uint>>();
                foreach (var key in _stuffing.StartActions.Keys)
                    keys.Add(new Tuple<uint, uint>((uint) key.Item1, (uint)key.Item2));

                var rows = new List<QueryBuilder.SQLInsertRow>();
                foreach (var startActions in _stuffing.StartActions)
                {
                    var comment = new QueryBuilder.SQLInsertRow();
                    comment.HeaderComment = startActions.Key.Item1 + " - " + startActions.Key.Item2;
                    rows.Add(comment);

                    foreach (var action in startActions.Value.Actions)
                    {
                        var row = new QueryBuilder.SQLInsertRow();

                        row.AddValue("race", startActions.Key.Item1);
                        row.AddValue("class", startActions.Key.Item2);
                        row.AddValue("button", action.Button);
                        row.AddValue("action", action.Id);
                        row.AddValue("type", action.Type);
                        if (action.Type == ActionButtonType.Spell)
                            row.Comment = StoreGetters.GetName(StoreNameType.Spell, (int) action.Id, false);
                        if (action.Type == ActionButtonType.Item)
                            row.Comment = StoreGetters.GetName(StoreNameType.Item, (int) action.Id, false);

                        rows.Add(row);
                    }
                }

                result = new QueryBuilder.SQLInsert("playercreateinfo_action", keys, new[] { "race", "class" }, rows).Build();
            }

            if (!_stuffing.StartPositions.IsEmpty)
            {
                // Can't cast the collection directly
                ICollection<Tuple<uint, uint>> keys = new Collection<Tuple<uint, uint>>();
                foreach (var key in _stuffing.StartPositions.Keys)
                    keys.Add(new Tuple<uint, uint>((uint)key.Item1, (uint)key.Item2));

                var rows = new List<QueryBuilder.SQLInsertRow>();
                foreach (var startPosition in _stuffing.StartPositions)
                {
                    var comment = new QueryBuilder.SQLInsertRow();
                    comment.HeaderComment = startPosition.Key.Item1 + " - " + startPosition.Key.Item2;
                    rows.Add(comment);

                    var row = new QueryBuilder.SQLInsertRow();

                    row.AddValue("race", startPosition.Key.Item1);
                    row.AddValue("class", startPosition.Key.Item2);
                    row.AddValue("map", startPosition.Value.Map);
                    row.AddValue("zone", startPosition.Value.Zone);
                    row.AddValue("position_x", startPosition.Value.Position.X);
                    row.AddValue("position_x", startPosition.Value.Position.Y);
                    row.AddValue("position_x", startPosition.Value.Position.Z);

                    row.Comment = StoreGetters.GetName(StoreNameType.Map, startPosition.Value.Map, false) + " - " +
                                  StoreGetters.GetName(StoreNameType.Zone, startPosition.Value.Zone, false);

                    rows.Add(row);
                }

                result += new QueryBuilder.SQLInsert("playercreateinfo", keys, new[] { "race", "class" }, rows).Build();
            }

            if (!_stuffing.StartSpells.IsEmpty)
            {
                // Can't cast the collection directly
                ICollection<Tuple<uint, uint>> keys = new Collection<Tuple<uint, uint>>();
                foreach (var key in _stuffing.StartSpells.Keys)
                    keys.Add(new Tuple<uint, uint>((uint)key.Item1, (uint)key.Item2));

                var rows = new List<QueryBuilder.SQLInsertRow>();
                foreach (var startSpells in _stuffing.StartSpells)
                {
                    var comment = new QueryBuilder.SQLInsertRow();
                    comment.HeaderComment = startSpells.Key.Item1 + " - " + startSpells.Key.Item2;
                    rows.Add(comment);

                    foreach (var spell in startSpells.Value.Spells)
                    {
                        var row = new QueryBuilder.SQLInsertRow();

                        row.AddValue("race", startSpells.Key.Item1);
                        row.AddValue("class", startSpells.Key.Item2);
                        row.AddValue("Spell", spell);
                        row.AddValue("Note",  StoreGetters.GetName(StoreNameType.Spell, (int)spell, false));

                        rows.Add(row);
                    }
                }

                result = new QueryBuilder.SQLInsert("playercreateinfo_spell", keys, new[] { "race", "class" }, rows).Build();
            }

            return result;
        }
        public string QuestPOI()
        {
            if (_stuffing.QuestPOIs.IsEmpty)
                return string.Empty;

            const string tableName1 = "quest_poi";
            const string tableName2 = "quest_poi_points";

            // Trying something..
            var orderedDict = _stuffing.QuestPOIs.OrderBy(key => key.Key.Item1);

            // `quest_poi`
            var rows = new List<QueryBuilder.SQLInsertRow>();
            foreach (var quest in orderedDict)
            {
                var row = new QueryBuilder.SQLInsertRow();

                row.AddValue("questId", quest.Key.Item1);
                row.AddValue("id", quest.Key.Item2);
                row.AddValue("objIndex", quest.Value.ObjectiveIndex);
                row.AddValue("mapid", quest.Value.Map);
                row.AddValue("WorldMapAreaId", quest.Value.WorldMapAreaId);
                row.AddValue("FloorId", quest.Value.FloorId);
                row.AddValue("unk3", quest.Value.UnkInt1);
                row.AddValue("unk4", quest.Value.UnkInt2);
                row.Comment = StoreGetters.GetName(StoreNameType.Quest, (int) quest.Key.Item1, false);

                rows.Add(row);
            }

            var result = new QueryBuilder.SQLInsert(tableName1, _stuffing.QuestPOIs.Keys, new[] { "questId", "id" }, rows).Build();

            // `quest_poi_points`
            rows = new List<QueryBuilder.SQLInsertRow>();
            foreach (var quest in orderedDict)
            {
                if (quest.Value.Points != null) // Needed?
                    foreach (var point in quest.Value.Points)
                    {
                        var row = new QueryBuilder.SQLInsertRow();

                        row.AddValue("questId", quest.Key.Item1);
                        row.AddValue("id", quest.Key.Item2);
                        row.AddValue("idx", point.Index); // Not on sniffs
                        row.AddValue("x", point.X);
                        row.AddValue("y", point.Y);
                        row.Comment = StoreGetters.GetName(StoreNameType.Quest, (int)quest.Key.Item1, false);

                        rows.Add(row);
                    }
            }

            result += new QueryBuilder.SQLInsert(tableName2, _stuffing.QuestPOIs.Keys, new[] { "questId", "id" }, rows).Build();

            return result;
        }
예제 #3
0
        public string CreatureSpawns()
        {
            if (!_storage.Objects.Any(wowObject => wowObject.Value.Type == ObjectType.Unit && wowObject.Key.GetHighType() != HighGuidType.Pet))
                return string.Empty;

            var units = _storage.Objects.Where(wowObject => wowObject.Value.Type == ObjectType.Unit && wowObject.Key.GetHighType() != HighGuidType.Pet);

            const string tableName = "creature";
            uint count = 0;

            units = units.OrderBy(unit => unit.Key.GetEntry());

            var rows = new List<QueryBuilder.SQLInsertRow>();
            foreach (var unit in units)
            {
                var row = new QueryBuilder.SQLInsertRow();

                var creature = unit.Value;

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

                row.CommentOut = creature.IsTemporarySpawn();

                var spawnTimeSecs = creature.GetDefaultSpawnTime();
                var movementType = 0; // TODO: Find a way to check if our unit got random movement
                var spawnDist = (movementType == 1) ? 5 : 0;

                row.AddValue("guid", "@GUID+" + count, noQuotes: true);
                row.AddValue("id", unit.Key.GetEntry());
                row.AddValue("map", creature.Map);
                row.AddValue("spawnMask", 1);
                row.AddValue("phaseMask", creature.PhaseMask);
                row.AddValue("position_x", creature.Movement.Position.X);
                row.AddValue("position_y", creature.Movement.Position.Y);
                row.AddValue("position_z", creature.Movement.Position.Z);
                row.AddValue("orientation", creature.Movement.Orientation);
                row.AddValue("spawntimesecs", spawnTimeSecs);
                row.AddValue("spawndist", spawnDist);
                row.AddValue("MovementType", movementType);
                row.Comment = StoreGetters.GetName(StoreNameType.Unit, (int) unit.Key.GetEntry(), false);
                row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, creature.Area, false) + ")";
                if (row.CommentOut)
                    row.Comment += " - !!! might be temporary spawn !!!";
                else
                    ++count;

                rows.Add(row);
            }

            var result = new StringBuilder();
            // delete query for GUIDs
            var delete = new QueryBuilder.SQLDelete(new Tuple<uint, uint>(0, count), "guid", tableName, "@GUID+");
            result.Append(delete.Build());
            result.Append(Environment.NewLine);

            var sql = new QueryBuilder.SQLInsert(tableName, rows);
            result.Append(sql.Build());
            return result.ToString();
        }
        public string Gossip()
        {
            if (_stuffing.Gossips.IsEmpty)
                return string.Empty;

            const string tableName1 = "gossip_menu";
            const string tableName2 = "gossip_menu_option";

            // TODO: Add creature_template gossip_menu_id update query or similar

            // `gossip`
            var rows = new List<QueryBuilder.SQLInsertRow>();
            foreach (var gossip in _stuffing.Gossips)
            {
                var row = new QueryBuilder.SQLInsertRow();

                row.AddValue("entry", gossip.Key.Item1);
                row.AddValue("text_id", gossip.Key.Item2);
                row.Comment = StoreGetters.GetName(Utilities.ObjectTypeToStore(gossip.Value.ObjectType),
                                                   (int) gossip.Value.ObjectEntry, false);

                rows.Add(row);
            }

            var result = new QueryBuilder.SQLInsert(tableName1, _stuffing.Gossips.Keys, new[] { "entry", "text_id" }, rows).Build();

            // `gossip_menu_option`
            rows = new List<QueryBuilder.SQLInsertRow>();
            ICollection<Tuple<uint, uint>> keys = new Collection<Tuple<uint, uint>>();
            foreach (var gossip in _stuffing.Gossips)
            {
                if (gossip.Value.GossipOptions != null) // Needed?
                    foreach (var gossipOption in gossip.Value.GossipOptions)
                    {
                        var row = new QueryBuilder.SQLInsertRow();

                        row.AddValue("menu_id", gossip.Key.Item1);
                        row.AddValue("id", gossipOption.Index);
                        row.AddValue("option_icon", gossipOption.OptionIcon);
                        row.AddValue("option_text", gossipOption.OptionText);
                        row.AddValue("box_coded", gossipOption.Box);
                        row.AddValue("box_money", gossipOption.RequiredMoney);
                        row.AddValue("box_text", gossipOption.BoxText);

                        rows.Add(row);

                        keys.Add(new Tuple<uint, uint>(gossip.Key.Item1, gossipOption.Index));
                    }
            }

            result += new QueryBuilder.SQLInsert(tableName2, keys, new[] { "menu_id", "id" }, rows).Build();

            return result;
        }
예제 #5
0
        public string GameObjectSpawns()
        {
            if (!_storage.Objects.Any(wowObject => wowObject.Value.Type == ObjectType.GameObject))
                return string.Empty;

            var gameobjects = _storage.Objects.Where(x => x.Value.Type == ObjectType.GameObject);

            const string tableName = "gameobject";
            uint count = 0;

            gameobjects = gameobjects.OrderBy(go => go.Key.GetEntry());

            var rows = new List<QueryBuilder.SQLInsertRow>();
            foreach (var gameobject in gameobjects)
            {
                var row = new QueryBuilder.SQLInsertRow();

                var go = gameobject.Value;

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

                row.CommentOut = go.IsTemporarySpawn();

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

                var spawnTimeSecs = go.GetDefaultSpawnTime();

                row.AddValue("guid", "@GUID+" + count, noQuotes: true);
                row.AddValue("id", gameobject.Key.GetEntry());
                row.AddValue("map", go.Map);
                row.AddValue("spawnMask", 1);
                row.AddValue("phaseMask", go.PhaseMask);
                row.AddValue("position_x", go.Movement.Position.X);
                row.AddValue("position_y", go.Movement.Position.Y);
                row.AddValue("position_z", go.Movement.Position.Z);
                row.AddValue("orientation", go.Movement.Orientation);
                row.AddValue("rotation0", go.Movement.Rotation.X);
                row.AddValue("rotation1", go.Movement.Rotation.Y);
                row.AddValue("rotation2", go.Movement.Rotation.Z);
                row.AddValue("rotation3", go.Movement.Rotation.W);
                row.AddValue("spawntimesecs", spawnTimeSecs);
                row.AddValue("animprogress", animprogress);
                row.AddValue("state", state);
                row.Comment = StoreGetters.GetName(StoreNameType.GameObject, (int) gameobject.Key.GetEntry(), false);
                row.Comment += " (Area: " + StoreGetters.GetName(StoreNameType.Area, go.Area, false) + ")";
                if (row.CommentOut)
                    row.Comment += " - !!! might be temporary spawn !!!";
                else
                    ++count;

                rows.Add(row);
            }

            var result = new StringBuilder();

            // delete query for GUIDs
            var delete = new QueryBuilder.SQLDelete(new Tuple<uint, uint>(0, count), "guid", tableName, "@GUID+");
            result.Append(delete.Build());
            result.Append(Environment.NewLine);

            var sql = new QueryBuilder.SQLInsert(tableName, rows);
            result.Append(sql.Build());
            return result.ToString();
        }