public CreatureInfo GetCreatureInfo(string creatureEntry)
        {
            DataSet unitFlagsDs;
            DataSet creatureNameDs;
            string  unitFlagsSqlQuery = "SELECT `npcflag`, `npcflag2`, `unit_flags`, `unit_flags2`, `unit_flags3`, `mechanic_immune_mask`, `flags_extra` FROM `creature_template` WHERE `entry` = " + creatureEntry + ";";
            string  creatureNameQuery = "SELECT `Name1` FROM `creature_template_wdb` WHERE `entry` = " + creatureEntry + ";";

            unitFlagsDs    = SQLModule.DatabaseSelectQuery(unitFlagsSqlQuery);
            creatureNameDs = SQLModule.DatabaseSelectQuery(creatureNameQuery);

            if (unitFlagsDs.Tables["table"].Rows.Count == 0 || creatureNameDs.Tables["table"].Rows.Count == 0)
            {
                MessageBox.Show("Creature doesn't exists in your database!");
                return(new CreatureInfo(-1));
            }

            long   npcFlags     = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][0].ToString());
            long   npcFlags2    = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][1].ToString());
            long   unitFlags    = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][2].ToString());
            long   unitFlags2   = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][3].ToString());
            long   unitFlags3   = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][4].ToString());
            long   mechanicMask = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][5].ToString());
            long   extraFlags   = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][6].ToString());
            string npcName      = creatureNameDs.Tables["table"].Rows[0][0].ToString();

            CreatureInfo creatureInfo = new CreatureInfo(long.Parse(creatureEntry), unitFlags, unitFlags2, unitFlags3, npcFlags, npcFlags2, extraFlags, mechanicMask, npcName);

            return(creatureInfo);
        }
Ejemplo n.º 2
0
        static public string CreateCombatEntryValues(CombatAIEventDataEntry combatData, uint id)
        {
            string npcName = "";

            string creatureNameQuery = "SELECT `Name1` FROM `creature_template_wdb` WHERE `entry` = " + combatData.NpcEntry + ";";
            var    creatureNameDs    = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery(creatureNameQuery) : null;

            if (creatureNameDs != null)
            {
                foreach (DataRow row in creatureNameDs.Tables["table"].Rows)
                {
                    npcName = row[0].ToString();
                }
            }

            if (npcName == "")
            {
                return("");
            }

            string spellName = SpellInfoOverrideCreator.GetSpellName(combatData.SpellId);

            string comment = "\"" + npcName + " -- " + spellName + "\"";
            string query   = "(" + combatData.NpcEntry + ", " + id + ", " + combatData.StartMin + ", " + combatData.StartMax +
                             ", " + combatData.RepeatMin + ", " + combatData.RepeatMax + ", " + combatData.RepeatFail + ", " + combatData.SpellId + ", " +
                             combatData.EventCheck + ", " + combatData.EventFlags + ", " + combatData.AttackDist + ", " + combatData.DifficultyMask + ", "
                             + comment + ")";

            return(query);
        }
Ejemplo n.º 3
0
        public void SearchCreatureScript()
        {
            DataSet combatAiDs;
            string  creatureEntry = this.mainForm.CombatAI_NpcEntry_TextBox.Text;
            string  combatAIQuery = "SELECT `entry`, `start_min`, `start_max`, `repeat_min`, `repeat_max`, `repeat_fail`, `spell_id`, `event_check`, `event_flags`, `attack_dist` FROM `combat_ai_events` WHERE `entry` = " + creatureEntry + ";";

            combatAiDs = SQLModule.DatabaseSelectQuery(combatAIQuery);

            if (combatAiDs == null || combatAiDs.Tables["table"].Rows.Count == 0)
            {
                MessageBox.Show("Creature doens't have script in Combat AI Table");
                return;
            }

            this.mainForm.CombatAI_SpellGrid_DataGrid.Enabled = true;
            this.mainForm.CombatAI_SpellGrid_DataGrid.Rows.Clear();

            uint NpcEntry = Convert.ToUInt32(creatureEntry);

            foreach (DataRow row in combatAiDs.Tables["table"].Rows)
            {
                if (!combatAIEntries.ContainsKey(NpcEntry))
                {
                    combatAIEntries[NpcEntry] = new ArrayList();
                }

                this.mainForm.CombatAI_SpellGrid_DataGrid.Rows.Add(row.ItemArray);
                combatAIEntries[NpcEntry].Add(new CombatAIEventDataEntry(row.ItemArray));
            }
        }
Ejemplo n.º 4
0
            public static bool UpdateRecord(string tableName, string updateColumnValues)
            {
                string sqlCommand = "update " + tableName + " SET " + updateColumnValues;

                SQLModule.ExcuteCommand(sqlCommand);
                return(true);
            }
Ejemplo n.º 5
0
            public static DataTable GetListOfRecords(string tableName)
            {
                string records = tableName;

                return(SQLModule.GetTableData(records));
                //return this.Content(returntext, "application/json");
            }
Ejemplo n.º 6
0
            public static Dictionary <string, string> GetColumns(string tableName)
            {
                var ds = SQLModule.GetTableData("select COLUMN_NAME,DATA_TYPE from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='" + tableName + "'");

                string primaryKeyName = GetPrimaryKey(tableName);

                //first element will always be primary key
                Dictionary <string, string> ColumnsList = new Dictionary <string, string>();

                ColumnsList.Add(primaryKeyName, "System.Int32");


                if (ds != null && ds.Rows.Count > 0)
                {
                    //prepare primary key; keeping it in a separate loop , not sure what can be the position
                    for (int i = 0; i < ds.Rows.Count; i++)
                    {
                        var ColumnName = ds.Rows[i]["COLUMN_NAME"].ToString();
                        var dataType   = ds.Rows[i]["DATA_TYPE"].ToString();
                        if (ColumnName != primaryKeyName)
                        {
                            ColumnsList.Add(ColumnName, dataType);
                        }
                    }
                }

                return(ColumnsList);
            }
Ejemplo n.º 7
0
        public static void CreateTemplate(uint objectEntry, ListBox hooksListBox, TreeView hookBodiesTreeView)
        {
            string scriptBody  = "";
            string defaultName = "";
            string scriptName  = "";

            string creatureNameQuery = "SELECT `Name` FROM `creature_template` WHERE `entry` = " + objectEntry + ";";
            var    creatureNameDs    = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery(creatureNameQuery) : null;

            if (creatureNameDs != null)
            {
                foreach (DataRow row in creatureNameDs.Tables["table"].Rows)
                {
                    defaultName = row[0].ToString();
                }
            }

            if (defaultName == "")
            {
                return;
            }

            scriptName  = "npc_" + NormilizeScriptName(defaultName) + "_" + objectEntry;
            scriptBody  = "/// " + defaultName + " - " + objectEntry + "\r\n";
            scriptBody += "struct " + scriptName + " : public " + (IsVehicleScript(hooksListBox) ? "VehicleAI" : "ScriptedAI") + "\r\n";
            scriptBody += "{" + "\r\n";
            scriptBody += Utils.AddSpacesCount(4) + "explicit " + scriptName + "(Creature* p_Creature) : " + (IsVehicleScript(hooksListBox) ? "VehicleAI" : "ScriptedAI") + "(p_Creature) { }";
            scriptBody += GetEnumsBody(hookBodiesTreeView);
            scriptBody += GetHooksBody(hooksListBox, hookBodiesTreeView);
            scriptBody += "\r\n" + "};" + "\r\n";

            Clipboard.SetText(scriptBody);
            MessageBox.Show("Template has been successfully builded and copied on your clipboard!");
        }
Ejemplo n.º 8
0
        private void CheckIfConditionAlreadyExistedInDb()
        {
            uint   sourceType  = (uint)Enum.Parse(typeof(Conditions.ConditionSourceTypes), mainForm.comboBox_ConditionSourceType.SelectedItem.ToString());
            string sourceGroup = mainForm.textBox_SourceGroup.Text;
            string sourceEntry = mainForm.textBox_SourceEntry.Text;

            string checkConditionInDbQuery = "SELECT * FROM `conditions` WHERE `SourceTypeOrReferenceId` = " + sourceType + " AND ";

            checkConditionInDbQuery += sourceGroup != "" ? "`SourceGroup` = " + sourceGroup : "`SourceEntry` = " + sourceEntry;
            checkConditionInDbQuery += ";";

            var conditionsDs = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery(checkConditionInDbQuery) : null;

            if (conditionsDs != null && conditionsDs.Tables["table"].Rows.Count != 0)
            {
                if (existedConditionsInDbList.Count == 0)
                {
                    existedConditionsInDbList.Add("Conditions that already existed in database with the same Source Type and Group or Entry:");
                }

                mainForm.textBox_ConditionsOutput.Text = "Conditions that already existed in database with the same Source Type and Group or Entry:";

                foreach (DataRow row in conditionsDs.Tables["table"].Rows)
                {
                    string conditionString = "";

                    for (uint i = 0; i < row.ItemArray.Length; i++)
                    {
                        if (i + 1 < row.ItemArray.Length)
                        {
                            if (row.ItemArray[i].ToString() != "")
                            {
                                conditionString += row.ItemArray[i].ToString() + ", ";
                            }
                            else
                            {
                                conditionString += "\"\"" + ", ";
                            }
                        }
                        else
                        {
                            if (row.ItemArray[i].ToString() != "")
                            {
                                conditionString += row.ItemArray[i].ToString() + ")";
                            }
                            else
                            {
                                conditionString += "\"\"" + ")";
                            }
                        }
                    }

                    if (!existedConditionsInDbList.Contains(conditionString))
                    {
                        existedConditionsInDbList.Add(conditionString);
                    }
                }
            }
        }
Ejemplo n.º 9
0
            public static bool DeleteRecord(string tableName, string primaryKey, string primaryKeyValue)
            {
                string sqlCommand = "delete " + tableName + " WHERE " + primaryKey + " = " + primaryKeyValue;

                SQLModule.ExcuteCommand(sqlCommand);

                return(true);
            }
Ejemplo n.º 10
0
 public GraphController(
     SQLModule sqlModule,
     DashboardModule dashboardModule,
     IOptions <OpserverSettings> settings) : base(settings)
 {
     Sql       = sqlModule;
     Dashboard = dashboardModule;
 }
Ejemplo n.º 11
0
        public static uint GetMapIdForTransport(uint transportEntry)
        {
            var mapIdDs = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery($"SELECT `data6` FROM `gameobject_template` WHERE `entry` = {transportEntry};") : null;

            if (mapIdDs != null)
            {
                return(Convert.ToUInt16(mapIdDs.Tables["table"].Rows[0][0].ToString()));
            }

            return(0);
        }
Ejemplo n.º 12
0
            public static string GetJsonFields(String querydata, string tableName)
            {
                string sqlCommand     = querydata;
                string primaryKeyName = GetPrimaryKey(tableName);
                var    ds             = SQLModule.GetTableData("select COLUMN_NAME,DATA_TYPE from INFORMATION_SCHEMA.COLUMNS where TABLE_NAME='" + tableName + "'");

                if (ds != null && ds.Rows.Count > 0)
                {
                    //prepare structure for jtable

                    var ListObj = new List <columns>();
                    ListObj.Add(new columns
                    {
                        caption      = primaryKeyName + "(KEY)",
                        dataField    = primaryKeyName,
                        allowEditing = false,
                    });
                    for (int i = 0; i < ds.Rows.Count; i++)
                    {
                        var ColumnName = ds.Rows[i]["COLUMN_NAME"].ToString();
                        var dataType   = ds.Rows[i]["DATA_TYPE"].ToString();
                        if (ColumnName != primaryKeyName)
                        {
                            dataType = GetDataType(dataType);
                            ListObj.Add(new columns
                            {
                                caption      = ColumnName + "(" + dataType + ")",
                                dataField    = ColumnName,
                                allowEditing = true,
                                dataType     = dataType
                            });
                        }
                    }
                    //foreach (DataColumn col in ds.Columns)
                    //{
                    //    if (col.ColumnName != primaryKeyName)
                    //    {
                    //        string dataType = GetDataType(col);
                    //        ListObj.Add(new columns
                    //        {
                    //            caption = col.ColumnName + "(" + dataType + ")",
                    //            dataField = col.ColumnName,
                    //            allowEditing = true,
                    //            dataType = dataType
                    //        });
                    //    }
                    //}

                    return(JsonConvert.SerializeObject(ListObj));
                }

                return(string.Empty);
            }
Ejemplo n.º 13
0
        public ActionResult DataViewer(int ID)
        {
            using (Models.Planner2Entities db = new Models.Planner2Entities())
            {
                var       item = db.DataViewers.Where(v => v.ID == ID).FirstOrDefault();
                DataTable data = new DataTable();

                data = SQLModule.GetTableData(item.QueryData);

                var json = ToJson(data);
                return(JsonMax(json));
            }
        }
Ejemplo n.º 14
0
            public static string AddRecord(string tableName, string fieldList, string fieldValues)
            {
                string sqlCommand = "insert into " + tableName + "(" + fieldList + ") Values (" + fieldValues + "); ";

                SQLModule.ExcuteCommand(sqlCommand);

                //get primary key
                string primaryKey = GetPrimaryKey(tableName);

                //assuming that we will get a table and a row everytime
                string newRecSuccess = "{\"Result\":\"OK\"}";

                return(newRecSuccess);
            }
        private static string GetCreatureData(string linkedId, Dictionary <string, object[]> creatureDatas)
        {
            string creatureData = "";

            try
            {
                uint   creatureEntry = (uint)creatureDatas[linkedId][1];
                string creatureName  = (string)SQLModule.DatabaseSelectQuery($"SELECT `Name` FROM `creature_template` WHERE `entry` = {creatureEntry}").Tables["table"].Rows[0].ItemArray[0];
                return(creatureData += $"Entry: {creatureEntry}, Name: {creatureName}");
            }
            catch
            {
                return(creatureData += "Can't get creature data!");
            }
        }
Ejemplo n.º 16
0
        public bool IsCritter()
        {
            if (!Properties.Settings.Default.UsingDB)
            {
                return(false);
            }

            var creatureTemplateWdbDs = SQLModule.DatabaseSelectQuery("SELECT `Type` FROM `creature_template_wdb` WHERE `entry` = " + entry + ";");

            if (creatureTemplateWdbDs != null && creatureTemplateWdbDs.Tables["table"].Rows.Count > 0)
            {
                return(creatureTemplateWdbDs.Tables["table"].Rows[0].ItemArray[0].ToString() == "8");
            }

            return(false);
        }
Ejemplo n.º 17
0
        public static Dictionary <uint, string> GetQuestNamesFromDB()
        {
            Dictionary <uint, string> namesDict = new Dictionary <uint, string>();

            var creatureNameDs = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery("SELECT `ID`, `LogTitle` FROM `quest_template`;") : null;

            if (creatureNameDs != null)
            {
                foreach (DataRow row in creatureNameDs.Tables["table"].Rows)
                {
                    namesDict.Add((uint)row[0], row[1].ToString());
                }
            }

            return(namesDict);
        }
        private string GetCreatureName(int npcEntry)
        {
            string npcName           = "";
            string creatureNameQuery = "SELECT `Name1` FROM `creature_template_wdb` WHERE `entry` = " + npcEntry + ";";
            var    creatureNameDs    = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery(creatureNameQuery) : null;

            if (creatureNameDs != null)
            {
                foreach (DataRow row in creatureNameDs.Tables["table"].Rows)
                {
                    npcName = row[0].ToString();
                }
            }

            return(npcName);
        }
Ejemplo n.º 19
0
        public static void CreateTemplate(uint objectEntry, ListBox hooksListBox, TreeView hookBodiesTreeView)
        {
            string scriptBody  = "";
            string defaultName = "";
            string scriptName  = "";

            string creatureNameQuery = "SELECT `Name1` FROM `creature_template_wdb` WHERE `entry` = " + objectEntry + ";";
            var    creatureNameDs    = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery(creatureNameQuery) : null;

            if (creatureNameDs != null)
            {
                foreach (DataRow row in creatureNameDs.Tables["table"].Rows)
                {
                    defaultName = row[0].ToString();
                }
            }

            if (defaultName == "")
            {
                return;
            }

            scriptName  = "npc_" + defaultName.Replace(" ", "_").ToLower().Replace("'", "") + "_" + objectEntry;
            scriptBody  = "/// " + defaultName + " - " + objectEntry + "\r\n";
            scriptBody += "class " + scriptName + " : public CreatureScript" + "\r\n";
            scriptBody += "{" + "\r\n";
            scriptBody += Utils.AddSpacesCount(4) + "public:" + "\r\n";
            scriptBody += Utils.AddSpacesCount(8) + scriptName + "()" + " : CreatureScript(\"" + scriptName + "\")" + " { }" + "\r\n\r\n";
            scriptBody += Utils.AddSpacesCount(8) + "struct " + scriptName + "AI" + " : public " + (IsVehicleScript(hooksListBox) ? "VehicleAI" : "ScriptedAI") + "\r\n";
            scriptBody += Utils.AddSpacesCount(8) + "{" + "\r\n";
            scriptBody += Utils.AddSpacesCount(12) + "explicit " + scriptName + "AI" + "(Creature* p_Creature) : " + (IsVehicleScript(hooksListBox) ? "VehicleAI" : "ScriptedAI") + "(p_Creature) { }";
            scriptBody += GetEnumsBody(hookBodiesTreeView);
            scriptBody += GetVariablesBody(hookBodiesTreeView);
            scriptBody += GetHooksBody(hooksListBox, hookBodiesTreeView);
            scriptBody += "\r\n" + Utils.AddSpacesCount(8) + "};" + "\r\n\r\n";
            scriptBody += Utils.AddSpacesCount(8) + "CreatureAI* GetAI(Creature* p_Creature) const override" + "\r\n";
            scriptBody += Utils.AddSpacesCount(8) + "{" + "\r\n";
            scriptBody += Utils.AddSpacesCount(12) + "return new " + scriptName + "AI(p_Creature);" + "\r\n";
            scriptBody += Utils.AddSpacesCount(8) + "}" + "\r\n";
            scriptBody += "};";

            Clipboard.SetText(scriptBody);
            MessageBox.Show("Template has been successfully builded and copied on your clipboard!");
        }
Ejemplo n.º 20
0
 public HomeController(
     IOptions <OpserverSettings> _settings,
     IEnumerable <StatusModule> modules,
     DashboardModule dashboard,
     SQLModule sql,
     RedisModule redis,
     ElasticModule elastic,
     ExceptionsModule exceptions,
     HAProxyModule haproxy
     ) : base(_settings)
 {
     Modules    = modules;
     Dashboard  = dashboard;
     Sql        = sql;
     Redis      = redis;
     Elastic    = elastic;
     Exceptions = exceptions;
     HAProxy    = haproxy;
 }
Ejemplo n.º 21
0
            public static string GetPrimaryKey(string tableName)
            {
                tableName = tableName.Replace("[", "");
                tableName = tableName.Replace("]", "");
                string primaryKeyQuery = "SELECT  column_name as primarykeycolumn FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS AS TC " +
                                         "INNER JOIN INFORMATION_SCHEMA.KEY_COLUMN_USAGE AS KU ON TC.CONSTRAINT_TYPE = 'PRIMARY KEY' AND TC.CONSTRAINT_NAME = KU.CONSTRAINT_NAME and ku.table_name='{0}' " +
                                         "ORDER BY KU.TABLE_NAME, KU.ORDINAL_POSITION;";

                primaryKeyQuery = String.Format(primaryKeyQuery, tableName);

                var    data           = SQLModule.GetTableData(primaryKeyQuery);
                string primaryKeyName = "";

                if (data != null && data.Rows.Count > 0)
                {
                    primaryKeyName = data.Rows[0][0].ToString();
                }
                return(primaryKeyName);
            }
Ejemplo n.º 22
0
        public AreaTriggerTemplateInfo GetAreaTriggerTemplateInfo(uint spellId)
        {
            DataSet areaTriggerInfo;
            string  areaTriggerTemplateInfoQuery = "SELECT `entry`, `spellId`, `customEntry` FROM `areatrigger_template` where `spellId` = " + spellId + ";";

            areaTriggerInfo = SQLModule.DatabaseSelectQuery(areaTriggerTemplateInfoQuery);

            if (areaTriggerInfo.Tables["table"].Rows.Count == 0 || areaTriggerInfo.Tables["table"].Rows.Count == 0)
            {
                MessageBox.Show("AreaTrigger Template doesn't exists in your database!");
                return(new AreaTriggerTemplateInfo(-1));
            }

            AreaTriggerTemplateInfo template = new AreaTriggerTemplateInfo();

            template.Entry       = Convert.ToInt32(areaTriggerInfo.Tables["table"].Rows[0][0].ToString());
            template.SpellId     = Convert.ToInt32(areaTriggerInfo.Tables["table"].Rows[0][1].ToString());
            template.CustomEntry = Convert.ToInt32(areaTriggerInfo.Tables["table"].Rows[0][2].ToString());

            return(template);
        }
        public void CreateCoreScript()
        {
            if (mainForm.dataGridView_CreatureScriptsCreator_Spells.RowCount == 0)
            {
                return;
            }

            Creature creature = creaturesDict[mainForm.listBox_CreatureScriptCreator_CreatureGuids.SelectedItem.ToString()];

            string scriptBody  = "";
            string defaultName = "";
            string scriptName  = "";

            string creatureNameQuery = $"SELECT `Name1` FROM `creature_template_wdb` WHERE `entry` = {creature.entry};";
            var    creatureNameDs    = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery(creatureNameQuery) : null;

            if (creatureNameDs != null)
            {
                foreach (DataRow row in creatureNameDs.Tables["table"].Rows)
                {
                    defaultName = row[0].ToString();
                }
            }

            if (defaultName == "")
            {
                return;
            }

            scriptName  = $"npc_{CreatureScriptTemplate.NormilizeScriptName(defaultName)}_{creature.entry}";
            scriptBody  = $"/// {defaultName} - {creature.entry}" + "\r\n";
            scriptBody += $"struct {scriptName} : public ScriptedAI" + "\r\n";
            scriptBody += "{" + "\r\n";
            scriptBody += $"{AddSpacesCount(4)}explicit {scriptName}(Creature* p_Creature) : ScriptedAI(p_Creature) {{ }}";
            scriptBody += GetEnumsBody();
            scriptBody += GetHooksBody(creature);
            scriptBody += "\r\n" + "};" + "\r\n";

            Clipboard.SetText(scriptBody);
        }
Ejemplo n.º 24
0
        public static void GetCreatureFlags(string creatureEntry)
        {
            DataSet unitFlagsDs       = new DataSet();
            DataSet typeFlagsDs       = new DataSet();
            string  unitFlagsSqlQuery = "SELECT `npcflag`, `npcflag2`, `unit_flags`, `unit_flags2`, `unit_flags3`, `dynamicflags`, `flags_extra` FROM `creature_template` WHERE `entry` = " + creatureEntry + ";";
            string  typeFlagsSqlQuery = "SELECT `TypeFlags`, `TypeFlags2` FROM `creature_template_wdb` WHERE `entry` = " + creatureEntry + ";";

            unitFlagsDs = SQLModule.DatabaseSelectQuery(unitFlagsSqlQuery);
            typeFlagsDs = SQLModule.DatabaseSelectQuery(typeFlagsSqlQuery);
            if (unitFlagsDs == null || typeFlagsDs == null)
            {
                return;
            }

            if (unitFlagsDs.Tables["table"].Rows.Count == 0 || typeFlagsDs.Tables["table"].Rows.Count == 0)
            {
                MessageBox.Show("Creature doesn't exists in your database!");
                return;
            }

            long npcFlags     = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][0].ToString());
            long npcFlags2    = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][1].ToString());
            long unitFlags    = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][2].ToString());
            long unitFlags2   = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][3].ToString());
            long unitFlags3   = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][4].ToString());
            long dynamicFlags = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][5].ToString());
            long extraFlags   = Convert.ToInt64(unitFlagsDs.Tables["table"].Rows[0][6].ToString());
            long typeFlags    = Convert.ToInt64(typeFlagsDs.Tables["table"].Rows[0][0].ToString());
            long typeFlags2   = Convert.ToInt64(typeFlagsDs.Tables["table"].Rows[0][1].ToString());

            List <long> npcFlagsList     = new List <long>();
            List <long> npcFlags2List    = new List <long>();
            List <long> unitFlagsList    = new List <long>();
            List <long> unitFlags2List   = new List <long>();
            List <long> unitFlags3List   = new List <long>();
            List <long> dynamicFlagsList = new List <long>();
            List <long> extraFlagsList   = new List <long>();
            List <long> typeFlagsList    = new List <long>();
            List <long> typeFlags2List   = new List <long>();

            if (npcFlags != 0)
            {
                var flagsArray = Enum.GetValues(typeof(NpcFlags));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (npcFlags - flag >= 0)
                    {
                        npcFlagsList.Add(flag);
                        npcFlags -= flag;
                    }
                }
            }

            if (npcFlags2 != 0)
            {
                var flagsArray = Enum.GetValues(typeof(NpcFlags2));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (npcFlags2 - flag >= 0)
                    {
                        npcFlags2List.Add(flag);
                        npcFlags2 -= flag;
                    }
                }
            }

            if (unitFlags != 0)
            {
                var flagsArray = Enum.GetValues(typeof(UnitFlags));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (unitFlags - flag >= 0)
                    {
                        unitFlagsList.Add(flag);
                        unitFlags -= flag;
                    }
                }
            }

            if (unitFlags2 != 0)
            {
                var flagsArray = Enum.GetValues(typeof(UnitFlags2));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (unitFlags2 - flag >= 0)
                    {
                        unitFlags2List.Add(flag);
                        unitFlags2 -= flag;
                    }
                }
            }

            if (unitFlags3 != 0)
            {
                var flagsArray = Enum.GetValues(typeof(UnitFlags3));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (unitFlags3 - flag >= 0)
                    {
                        unitFlags3List.Add(flag);
                        unitFlags3 -= flag;
                    }
                }
            }

            if (dynamicFlags != 0)
            {
                var flagsArray = Enum.GetValues(typeof(DynamicFlags));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (dynamicFlags - flag >= 0)
                    {
                        dynamicFlagsList.Add(flag);
                        dynamicFlags -= flag;
                    }
                }
            }

            if (extraFlags != 0)
            {
                var flagsArray = Enum.GetValues(typeof(FlagsExtra));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (extraFlags - flag >= 0)
                    {
                        extraFlagsList.Add(flag);
                        extraFlags -= flag;
                    }
                }
            }

            if (typeFlags != 0)
            {
                var flagsArray = Enum.GetValues(typeof(TypeFlags));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (typeFlags - flag >= 0)
                    {
                        typeFlagsList.Add(flag);
                        typeFlags -= flag;
                    }
                }
            }

            if (typeFlags2 != 0)
            {
                var flagsArray = Enum.GetValues(typeof(TypeFlags2));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (typeFlags2 - flag >= 0)
                    {
                        typeFlags2List.Add(flag);
                        typeFlags2 -= flag;
                    }
                }
            }

            npcFlagsList.Sort();
            npcFlags2List.Sort();
            unitFlagsList.Sort();
            unitFlags2List.Sort();
            unitFlags3List.Sort();
            dynamicFlagsList.Sort();
            extraFlagsList.Sort();
            typeFlagsList.Sort();
            typeFlags2List.Sort();

            string outputText = "";

            if (npcFlagsList.Count > 0)
            {
                outputText += "Creature has the following NpcFlags: \r\n";

                outputText = npcFlagsList.Aggregate(outputText, (current, itr) => current + ((NpcFlags)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Creature doesn't have any NpcFlags!\r\n";
            }

            if (npcFlags2List.Count > 0)
            {
                outputText += "Creature has the following NpcFlags2: \r\n";

                outputText = npcFlags2List.Aggregate(outputText, (current, itr) => current + ((NpcFlags2)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Creature doesn't have any NpcFlags2!\r\n";
            }

            if (unitFlagsList.Count > 0)
            {
                outputText += "Creature has the following UnitFlags: \r\n";

                outputText = unitFlagsList.Aggregate(outputText, (current, itr) => current + ((UnitFlags)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Creature doesn't have any UnitFlags!\r\n";
            }

            if (unitFlags2List.Count > 0)
            {
                outputText += "Creature has the following UnitFlags2: \r\n";

                outputText = unitFlags2List.Aggregate(outputText, (current, itr) => current + ((UnitFlags2)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Creature doesn't have any UnitFlags2!\r\n";
            }

            if (unitFlags3List.Count > 0)
            {
                outputText += "Creature has the following UnitFlags3: \r\n";

                outputText = unitFlags3List.Aggregate(outputText, (current, itr) => current + ((UnitFlags3)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Creature doesn't have any UnitFlags3!\r\n";
            }

            if (dynamicFlagsList.Count > 0)
            {
                outputText += "Creature has the following DynamicFlags: \r\n";

                outputText = dynamicFlagsList.Aggregate(outputText, (current, itr) => current + ((DynamicFlags)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Creature doesn't have any DynamicFlags!\r\n";
            }

            if (extraFlagsList.Count > 0)
            {
                outputText += "Creature has the following ExtraFlags: \r\n";

                outputText = extraFlagsList.Aggregate(outputText, (current, itr) => current + ((FlagsExtra)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Creature doesn't have any ExtraFlags!\r\n";
            }

            if (typeFlagsList.Count > 0)
            {
                outputText += "Creature has the following TypeFlags: \r\n";

                outputText = typeFlagsList.Aggregate(outputText, (current, itr) => current + ((TypeFlags)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Creature doesn't have any TypeFlags!\r\n";
            }

            if (typeFlags2List.Count > 0)
            {
                outputText += "Creature has the following TypeFlags2: \r\n";

                outputText = typeFlags2List.Aggregate(outputText, (current, itr) => current + ((TypeFlags2)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Creature doesn't have any TypeFlags2!\r\n";
            }

            MessageBox.Show(outputText);
        }
        public static string GetTextForGossipMenu(string menuId)
        {
            string output = "";

            DataSet gossipMenuTextIdDs = SQLModule.DatabaseSelectQuery("SELECT `text_id` FROM `gossip_menu` WHERE `entry` = " + menuId + ";");

            if (gossipMenuTextIdDs == null || gossipMenuTextIdDs.Tables["table"].Rows.Count == 0)
            {
                MessageBox.Show("There is no gossip menu with this Id in your database!");
                return(output);
            }

            if (gossipMenuTextIdDs.Tables["table"].Rows.Count > 1)
            {
                foreach (DataRow gossipMenuRow in gossipMenuTextIdDs.Tables["table"].Rows)
                {
                    output += "Text Id: " + gossipMenuRow[0].ToString() + "\r\n";

                    DataSet npcTextBroadcastIdDs = SQLModule.DatabaseSelectQuery("SELECT `BroadcastTextID0`, `BroadcastTextID1`, `BroadcastTextID2`, `BroadcastTextID3`, `BroadcastTextID4`, `BroadcastTextID5`, `BroadcastTextID6`, `BroadcastTextID7` FROM `npc_text` WHERE `ID` = " + gossipMenuRow[0].ToString() + ";");
                    if (npcTextBroadcastIdDs == null || npcTextBroadcastIdDs.Tables["table"].Rows.Count == 0)
                    {
                        output += "There is no npc text with this TextId in your database!";
                        continue;
                    }

                    foreach (var itr in npcTextBroadcastIdDs.Tables["table"].Rows[0].ItemArray.Where(x => x.ToString() != "0"))
                    {
                        DataSet broadcastTextDs = SQLModule.HotfixSelectQuery("SELECT `Text`, `Text1` FROM `broadcasttext` WHERE `ROW_ID` = " + itr.ToString() + ";");
                        if (broadcastTextDs == null || broadcastTextDs.Tables["table"].Rows.Count == 0)
                        {
                            output += "There is no broadcast text with this BroadcastId in your database!";
                            continue;
                        }

                        foreach (string stringRow in broadcastTextDs.Tables["table"].Rows[0].ItemArray)
                        {
                            if (stringRow != "")
                            {
                                output += "- " + stringRow + "\r\n";
                            }
                        }
                    }
                }
            }
            else
            {
                output += "Text Id: " + gossipMenuTextIdDs.Tables["table"].Rows[0][0].ToString() + "\r\n";

                DataSet npcTextBroadcastIdDs = SQLModule.DatabaseSelectQuery("SELECT `BroadcastTextID0`, `BroadcastTextID1`, `BroadcastTextID2`, `BroadcastTextID3`, `BroadcastTextID4`, `BroadcastTextID5`, `BroadcastTextID6`, `BroadcastTextID7` FROM `npc_text` WHERE `ID` = " + gossipMenuTextIdDs.Tables["table"].Rows[0][0].ToString() + ";");
                if (npcTextBroadcastIdDs == null || npcTextBroadcastIdDs.Tables["table"].Rows.Count == 0)
                {
                    MessageBox.Show("There is no npc text with this TextId in your database!");
                    return(output);
                }

                foreach (var itr in npcTextBroadcastIdDs.Tables["table"].Rows[0].ItemArray.Where(x => x.ToString() != "0"))
                {
                    DataSet broadcastTextDs = SQLModule.HotfixSelectQuery("SELECT `Text`, `Text1` FROM `broadcasttext` WHERE `ROW_ID` = " + itr.ToString() + ";");
                    if (broadcastTextDs == null || broadcastTextDs.Tables["table"].Rows.Count == 0)
                    {
                        output += "There is no broadcast text with this BroadcastId in your database!";
                        continue;
                    }

                    foreach (string stringRow in broadcastTextDs.Tables["table"].Rows[0].ItemArray)
                    {
                        if (stringRow != "")
                        {
                            output += "- " + stringRow + "\r\n";
                        }
                    }
                }
            }

            return(output);
        }
        public void CreateSQL()
        {
            Creature creature = creaturesDict[mainForm.listBox_WC_CreatureGuids.SelectedItem.ToString()];
            string   sqlQuery = "SELECT * FROM `creature_addon` WHERE `linked_id` = '" + creature.GetLinkedId() + "';";
            string   creatureAddon;
            bool     addonFound      = false;
            var      creatureAddonDs = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery(sqlQuery) : null;

            if (creatureAddonDs != null && creatureAddonDs.Tables["table"].Rows.Count > 0)
            {
                creatureAddon = "UPDATE `creature_addon` SET `path_id` = @PATH WHERE `linked_id` = '" + creature.GetLinkedId() + "';" + "\r\n";
                addonFound    = true;
            }
            else
            {
                creatureAddon = "('" + creature.GetLinkedId() + "', @PATH, 0, 0, 1, 0, 0, 0, 0, '', -1); " + "\r\n";
            }

            List <Waypoint> waypoints = (from DataGridViewRow row in mainForm.grid_WC_Waypoints.Rows select(Waypoint) row.Cells[8].Value).ToList();

            if (Properties.Settings.Default.Scripts && waypoints.GetScriptsCount() != 0)
            {
                if (creature.waypoints.Count != waypoints.Count)
                {
                    waypoints.RecalculateIdsAndGuids(creature.entry);
                }
            }

            string SQLtext = "-- Pathing for " + creature.name + " Entry: " + creature.entry + "\r\n";

            SQLtext = SQLtext + "SET @GUID := (SELECT `guid` FROM `creature` WHERE `linked_id` = " + "'" + creature.GetLinkedId() + "'" + ");" + "\r\n";
            SQLtext = SQLtext + "SET @PATH := @GUID * 10;" + "\r\n";
            SQLtext = SQLtext + "UPDATE `creature` SET `spawndist` = 0, `MovementType` = 2 WHERE `linked_id` = '" + creature.GetLinkedId() + "'; " + "\r\n";

            if (addonFound)
            {
                SQLtext += creatureAddon;
            }
            else
            {
                SQLtext += "DELETE FROM `creature_addon` WHERE `linked_id` = '" + creature.GetLinkedId() + "';" + "\r\n";
                SQLtext += "INSERT INTO `creature_addon` (`linked_id`, `path_id`, `mount`, `bytes1`, `bytes2`, `emote`, `AiAnimKit`, `MovementAnimKit`, `MeleeAnimKit`, `auras`, `VerifiedBuild`) VALUES" + "\r\n";
                SQLtext += creatureAddon;
            }

            SQLtext = SQLtext + "DELETE FROM `waypoint_data` WHERE `id` = @PATH;" + "\r\n";
            SQLtext = SQLtext + "INSERT INTO `waypoint_data` (`id`, `point`, `position_x`, `position_y`, `position_z`, `orientation`, `delay`, `move_type`, `action`, `action_chance`, `speed`) VALUES" + "\r\n";

            for (int i = 0; i < waypoints.Count; i++)
            {
                Waypoint waypoint    = waypoints[i];
                float    orientation = waypoint.HasOrientation() ? waypoint.orientation : float.Parse(mainForm.grid_WC_Waypoints[4, i].Value.ToString());
                uint     delay       = waypoint.delay > 0 ? waypoint.delay : Convert.ToUInt32(mainForm.grid_WC_Waypoints[6, i].Value.ToString());

                if (i < (waypoints.Count - 1))
                {
                    SQLtext = SQLtext + "(@PATH, " + (i + 1) + ", " + waypoint.movePosition.x.GetValueWithoutComma() + ", " + waypoint.movePosition.y.GetValueWithoutComma() + ", " + waypoint.movePosition.z.GetValueWithoutComma() + ", " + orientation.GetValueWithoutComma() + ", " + delay + ", " + Convert.ToString(creature.IsFlying ? 2 : 0) + ", " + waypoint.GetScriptId() + ", 100" + ", 0" + "),\r\n";
                }
                else
                {
                    SQLtext = SQLtext + "(@PATH, " + (i + 1) + ", " + waypoint.movePosition.x.GetValueWithoutComma() + ", " + waypoint.movePosition.y.GetValueWithoutComma() + ", " + waypoint.movePosition.z.GetValueWithoutComma() + ", " + orientation.GetValueWithoutComma() + ", " + delay + ", " + Convert.ToString(creature.IsFlying ? 2 : 0) + ", " + waypoint.GetScriptId() + ", 100" + ", 0" + ");\r\n";
                }
            }

            SQLtext = SQLtext + "-- " + creature.guid + " .go " + creature.spawnPosition.x.GetValueWithoutComma() + " " + creature.spawnPosition.y.GetValueWithoutComma() + " " + creature.spawnPosition.z.GetValueWithoutComma() + "\r\n";

            if (Properties.Settings.Default.Scripts && creature.waypoints.GetScriptsCount() != 0)
            {
                if (creature.waypoints.Count != waypoints.Count)
                {
                    waypoints.RecalculateIdsAndGuids(creature.entry);
                }

                SQLtext += "\r\n";
                SQLtext += "-- Waypoint scripts for " + creature.name + " Entry: " + creature.entry + "\r\n";
                SQLtext  = SQLtext + "DELETE FROM `waypoint_scripts` WHERE `id` IN (" + waypoints.GetScriptIds() + ");\r\n";
                SQLtext  = SQLtext + "INSERT INTO `waypoint_scripts` (`id`, `delay`, `command`, `datalong`, `datalong2`, `dataint`, `x`, `y`, `z`, `o`, `guid`) VALUES" + "\r\n";

                uint scriptsCount = waypoints.GetScriptsCount() - 1;

                foreach (var script in waypoints.SelectMany(waypoint => waypoint.scripts))
                {
                    if (scriptsCount != 0)
                    {
                        SQLtext = SQLtext + "(" + script.id + ", " + script.delay + ", " + (uint)script.type + ", " + script.dataLong + ", " + script.dataLongSecond + ", " + script.dataInt + ", " + script.x.GetValueWithoutComma() + ", " + script.y.GetValueWithoutComma() + ", " + script.z.GetValueWithoutComma() + ", " + script.o.GetValueWithoutComma() + ", " + script.guid + ")," + " -- " + "Script Type: " + script.type + "\r\n";
                        scriptsCount--;
                    }
                    else
                    {
                        SQLtext = SQLtext + "(" + script.id + ", " + script.delay + ", " + (uint)script.type + ", " + script.dataLong + ", " + script.dataLongSecond + ", " + script.dataInt + ", " + script.x.GetValueWithoutComma() + ", " + script.y.GetValueWithoutComma() + ", " + script.z.GetValueWithoutComma() + ", " + script.o.GetValueWithoutComma() + ", " + script.guid + ");" + " -- " + "Script Type: " + script.type + "\r\n";
                    }
                }
            }

            if (Properties.Settings.Default.Vector)
            {
                SQLtext += "\r\n";
                SQLtext += "-- Vector3 for movement in core for " + creature.name + " Entry: " + creature.entry + "\r\n";
                SQLtext  = SQLtext + "std::vector<G3D::Vector3> const g_Path" + creature.name + " =" + "\r\n";
                SQLtext  = SQLtext + "{" + "\r\n";

                for (int i = 0; i < waypoints.Count; i++)
                {
                    Waypoint waypoint = waypoints[i];

                    if (i < (waypoints.Count - 1))
                    {
                        SQLtext = SQLtext + "{ " + waypoint.movePosition.x.GetValueWithoutComma() + "f, " + waypoint.movePosition.y.GetValueWithoutComma() + "f, " + waypoint.movePosition.z.GetValueWithoutComma() + "f },\r\n";
                    }
                    else
                    {
                        SQLtext = SQLtext + "{ " + waypoint.movePosition.x.GetValueWithoutComma() + "f, " + waypoint.movePosition.y.GetValueWithoutComma() + "f, " + waypoint.movePosition.z.GetValueWithoutComma() + "f }\r\n";
                    }
                }

                SQLtext = SQLtext + "};" + "\r\n";

                mainForm.textBox_SQLOutput.Text = SQLtext;
            }
        }
        public void FillListBoxWithGuids()
        {
            mainForm.listBox_WC_CreatureGuids.Items.Clear();
            mainForm.grid_WC_Waypoints.Rows.Clear();

            foreach (Creature creature in creaturesDict.Values)
            {
                if (!creature.HasWaypoints())
                {
                    continue;
                }

                string sqlQuery = "SELECT * FROM `creature_addon` WHERE `linked_id` = '" + creature.GetLinkedId() + "';";
                bool   alreadyHaveWaypointsInDb = false;
                var    creatureAddonDs          = Properties.Settings.Default.UsingDB ? SQLModule.DatabaseSelectQuery(sqlQuery) : null;

                if (creatureAddonDs != null && creatureAddonDs.Tables["table"].Rows.Count > 0)
                {
                    foreach (DataRow row in creatureAddonDs.Tables["table"].Rows)
                    {
                        if (Convert.ToInt32(row.ItemArray[1]) > 0)
                        {
                            alreadyHaveWaypointsInDb = true;
                        }
                    }
                }

                if (alreadyHaveWaypointsInDb)
                {
                    continue;
                }

                if (mainForm.toolStripTextBox_WC_Entry.Text != "" && mainForm.toolStripTextBox_WC_Entry.Text != "0")
                {
                    if (mainForm.toolStripTextBox_WC_Entry.Text == creature.entry.ToString() ||
                        mainForm.toolStripTextBox_WC_Entry.Text == creature.guid ||
                        mainForm.toolStripTextBox_WC_Entry.Text == creature.GetLinkedId())
                    {
                        mainForm.listBox_WC_CreatureGuids.Items.Add(creature.guid);
                    }
                }
                else
                {
                    mainForm.listBox_WC_CreatureGuids.Items.Add(creature.guid);
                }
            }

            mainForm.listBox_WC_CreatureGuids.Refresh();
            mainForm.listBox_WC_CreatureGuids.Enabled = true;
        }
        public static void GetQuestFlags(string questEntry)
        {
            string questFlagsSqlQuery = "SELECT `Flags`, `FlagsEx` FROM `quest_template` WHERE `Id` = " + questEntry + ";";
            var    questFlagsDs       = SQLModule.DatabaseSelectQuery(questFlagsSqlQuery);

            if (questFlagsDs == null)
            {
                return;
            }

            questFlagsSqlQuery = "SELECT `SpecialFlags` FROM `quest_template_addon` WHERE `Id` = " + questEntry + ";";
            DataSet AddonQuestFlagsDs = SQLModule.DatabaseSelectQuery(questFlagsSqlQuery);

            if (AddonQuestFlagsDs == null)
            {
                return;
            }

            if (questFlagsDs.Tables["table"].Rows.Count == 0)
            {
                MessageBox.Show("Quest doesn't exists in your database!");
                return;
            }

            long specialFlags = 0;

            if (questFlagsDs.Tables["table"].Rows.Count == 0)
            {
                specialFlags = Convert.ToInt64(AddonQuestFlagsDs.Tables["table"].Rows[0][0].ToString());
            }

            long questFlags  = Convert.ToInt64(questFlagsDs.Tables["table"].Rows[0][0].ToString());
            long questFlags2 = Convert.ToInt64(questFlagsDs.Tables["table"].Rows[0][1].ToString());

            List <long> questFlagsList   = new List <long>();
            List <long> questFlags2List  = new List <long>();
            List <long> specialFlagsList = new List <long>();

            if (questFlags != 0)
            {
                var flagsArray = Enum.GetValues(typeof(QuestFlags));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (questFlags - flag >= 0)
                    {
                        questFlagsList.Add(flag);
                        questFlags -= flag;
                    }
                }
            }

            if (questFlags2 != 0)
            {
                var flagsArray = Enum.GetValues(typeof(QuestFlagsEx));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (questFlags2 - flag >= 0)
                    {
                        questFlags2List.Add(flag);
                        questFlags2 -= flag;
                    }
                }
            }

            if (specialFlags != 0)
            {
                var flagsArray = Enum.GetValues(typeof(QuestSpecialFlags));
                Array.Reverse(flagsArray);

                foreach (long flag in flagsArray)
                {
                    if (specialFlags - flag >= 0)
                    {
                        specialFlagsList.Add(flag);
                        specialFlags -= flag;
                    }
                }
            }

            questFlagsList.Sort();
            questFlags2List.Sort();
            specialFlagsList.Sort();

            string outputText = "";

            if (questFlagsList.Count > 0)
            {
                outputText += "Quest has the following QuestFlags: \r\n";

                outputText = questFlagsList.Aggregate(outputText, (current, itr) => current + ((QuestFlags)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Quest doesn't have any QuestFlags!\r\n";
            }

            if (questFlags2List.Count > 0)
            {
                outputText += "Quest has the following QuestFlags2: \r\n";

                outputText = questFlags2List.Aggregate(outputText, (current, itr) => current + ((QuestFlagsEx)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Quest doesn't have any QuestFlags2!\r\n";
            }

            if (specialFlagsList.Count > 0)
            {
                outputText += "Quest has the following SpecialFlags: \r\n";

                outputText = specialFlagsList.Aggregate(outputText, (current, itr) => current + ((QuestSpecialFlags)itr + ": " + itr + "\r\n"));
            }
            else
            {
                outputText += "Quest doesn't have any SpecialFlags!\r\n";
            }

            MessageBox.Show(outputText);
        }
        public static void FindDoublePaths(TextBox textBox, string zoneId)
        {
            string output = "";

            Dictionary <string, uint> creatureAddonDictionary = new Dictionary <string, uint>();

            if (Properties.Settings.Default.UsingDB)
            {
                DataSet creatureAddonDs = SQLModule.DatabaseSelectQuery($"SELECT `linked_id`, `path_id` FROM `creature_addon` WHERE `path_id` > 0 AND `linked_id` IN (SELECT `linked_id` FROM `creature` WHERE `linked_id` != 0 AND `zoneId` = {zoneId});");

                if (creatureAddonDs != null && creatureAddonDs.Tables["table"].Rows.Count > 0)
                {
                    foreach (DataRow row in creatureAddonDs.Tables["table"].Rows)
                    {
                        if (!creatureAddonDictionary.ContainsKey((string)row.ItemArray[0]))
                        {
                            creatureAddonDictionary.Add((string)row.ItemArray[0], (uint)row.ItemArray[1]);
                        }
                    }
                }
            }
            else
            {
                textBox.Text = "Can't find any double path for this zone!";
                return;
            }

            Dictionary <uint, List <Position> > pathDictionary = new Dictionary <uint, List <Position> >();

            string pahtIds = "";

            for (int i = 0; i < creatureAddonDictionary.Values.Count; i++)
            {
                if (i + 1 < creatureAddonDictionary.Values.Count)
                {
                    pahtIds += creatureAddonDictionary.Values.ElementAt(i) + ", ";
                }
                else
                {
                    pahtIds += creatureAddonDictionary.Values.ElementAt(i);
                }
            }

            DataSet waypointDataDs = SQLModule.DatabaseSelectQuery($"SELECT `id`, `position_x`, `position_y`, `position_z` FROM `waypoint_data` WHERE `id` IN ({pahtIds});");

            pahtIds = "";

            if (waypointDataDs != null && waypointDataDs.Tables["table"].Rows.Count > 0)
            {
                foreach (DataRow row in waypointDataDs.Tables["table"].Rows)
                {
                    if (!pathDictionary.ContainsKey((uint)row.ItemArray[0]))
                    {
                        pathDictionary.Add((uint)row.ItemArray[0], new List <Position>()
                        {
                            new Position((float)row.ItemArray[1], (float)row.ItemArray[2], (float)row.ItemArray[3])
                        });
                    }
                    else
                    {
                        pathDictionary[(uint)row.ItemArray[0]].Add(new Position((float)row.ItemArray[1], (float)row.ItemArray[2], (float)row.ItemArray[3]));
                    }
                }
            }

            waypointDataDs.Clear();

            string linkedIds = "";

            for (int i = 0; i < creatureAddonDictionary.Keys.Count; i++)
            {
                if (i + 1 < creatureAddonDictionary.Keys.Count)
                {
                    linkedIds += $"'{creatureAddonDictionary.Keys.ElementAt(i)}', ";
                }
                else
                {
                    linkedIds += $"'{creatureAddonDictionary.Keys.ElementAt(i)}'";
                }
            }

            DataSet creatureDatasDs = SQLModule.DatabaseSelectQuery($"SELECT `linked_id`, `id`, `map`, `phaseId`, `phaseMask` FROM `creature` WHERE `linked_id` IN ({linkedIds});");

            Dictionary <string, object[]> creatureDatasDict = new Dictionary <string, object[]>();

            foreach (DataRow row in creatureDatasDs.Tables["table"].Rows)
            {
                creatureDatasDict.Add(row.ItemArray[0].ToString(), row.ItemArray);
            }

            creatureDatasDs.Clear();

            linkedIds = "";

            List <string> linkedIdsWithDoublePaths = new List <string>();
            uint          doublePathsCount         = 0;

            Parallel.ForEach(pathDictionary.AsEnumerable(), originalPath =>
            {
                foreach (var computePath in pathDictionary)
                {
                    if (originalPath.Key != computePath.Key)
                    {
                        string originalLinkedId = creatureAddonDictionary.First(x => x.Value == originalPath.Key).Key;
                        string computeLinkedId  = creatureAddonDictionary.First(x => x.Value == computePath.Key).Key;

                        if (!IsCreaturesWithinLos(originalLinkedId, computeLinkedId, creatureDatasDict))
                        {
                            continue;
                        }

                        uint matchesCount = 0;

                        foreach (Position movePos in computePath.Value)
                        {
                            if (originalPath.Value.Count(x => x == movePos) != 0)
                            {
                                matchesCount++;
                            }
                        }

                        lock (linkedIdsWithDoublePaths)
                        {
                            if ((originalPath.Value.Count == matchesCount || matchesCount > 0) && (!linkedIdsWithDoublePaths.Contains(originalLinkedId) ||
                                                                                                   !linkedIdsWithDoublePaths.Contains(computeLinkedId)))
                            {
                                doublePathsCount++;
                                linkedIdsWithDoublePaths.Add(originalLinkedId);
                                linkedIdsWithDoublePaths.Add(computeLinkedId);

                                if (originalPath.Value.Count == matchesCount)
                                {
                                    output += $"Creature with linked id: {originalLinkedId} ({GetCreatureData(originalLinkedId, creatureDatasDict)},  {GetMapData(originalLinkedId, creatureDatasDict)}) have same path as creature with linked id: {computeLinkedId} ({GetCreatureData(computeLinkedId, creatureDatasDict)},  {GetMapData(computeLinkedId, creatureDatasDict)}) ({matchesCount} familiar waypoints)" + "\r\n";
                                }
                                else
                                {
                                    output += $"Creature with linked id: {originalLinkedId} ({GetCreatureData(originalLinkedId, creatureDatasDict)},  {GetMapData(originalLinkedId, creatureDatasDict)}) probably have same path as creature with linked id: {computeLinkedId} ({GetCreatureData(computeLinkedId, creatureDatasDict)},  {GetMapData(computeLinkedId, creatureDatasDict)}) ({matchesCount} familiar waypoints)" + "\r\n";
                                }
                            }
                        }
                    }
                }
            });

            if (linkedIdsWithDoublePaths.Count > 0)
            {
                output += "\r\n";
            }

            if (doublePathsCount > 0)
            {
                output += $"Total count of double paths: {doublePathsCount}" + "\r\n";
            }
            else
            {
                output += "Can't find any double path for this zone!";
            }

            textBox.Text = output;
        }