Beispiel #1
0
        private void LoadMobs()
        {
            try
            {
                MobsByID   = new Dictionary <ushort, MobInfo>();
                MobsByName = new Dictionary <string, MobInfo>();
                DataTable data_mobinfo       = null;
                DataTable data_MobInfoServer = null;
                using (DatabaseClient dbClient = Program.DatabaseManager.GetClient())
                {
                    data_mobinfo       = dbClient.ReadDataTable("SELECT  *FROM data_mobinfo");
                    data_MobInfoServer = dbClient.ReadDataTable("SELECT  *FROM data_MobInfoServer");
                }
                if (data_mobinfo != null)
                {
                    foreach (DataRow row in data_mobinfo.Rows)
                    {
                        MobInfo info = MobInfo.Load(row);
                        if (MobsByID.ContainsKey(info.ID) || MobsByName.ContainsKey(info.Name))
                        {
                            Log.WriteLine(LogLevel.Warn, "Duplicate mob ID found in MobInfo.shn: {0}.", info.ID);
                            continue;
                        }
                        MobsByID.Add(info.ID, info);

                        MobsByName.Add(info.Name, info);
                    }
                }
                MobData = new Dictionary <string, MobInfoServer>();
                if (data_MobInfoServer != null)
                {
                    foreach (DataRow row in data_MobInfoServer.Rows)
                    {
                        MobInfoServer info = MobInfoServer.Load(row);
                        if (MobData.ContainsKey(info.InxName))
                        {
                            Log.WriteLine(LogLevel.Warn, "Duplicate mob ID found in MobInfoServer.shn: {0}.", info.InxName);
                            continue;
                        }
                        //  Program.DatabaseManager.GetClient().ExecuteQuery("UPDATE Vendors SET NPCID='" + info.ID + "' WHERE NPCID='" + info.InxName + "'");
                        MobData.Add(info.InxName, info);
                    }

                    /* foreach (string mobs in MobsByName.Keys)//check mobdata this is for database devs
                     *   {
                     *           if(!MobData.ContainsKey(mobs))
                     *                   {
                     *                           Console.WriteLine(mobs);
                     *                   }
                     *   }*/
                }
                Log.WriteLine(LogLevel.Info, "Loaded {0} mobs.", MobsByID.Count);
            }
            catch (Exception ex)
            {
                Log.WriteLine(LogLevel.Exception, "Error loading MobInfo {0}", ex.Message);
            }
        }
Beispiel #2
0
        public ushort GetMobIDFromName(string name)
        {
            MobInfoServer mis = null;

            if (MobData.TryGetValue(name, out mis))
            {
                return((ushort)mis.ID);
            }
            return(0);
        }
Beispiel #3
0
        private void LoadMobs()
        {
            MobsByID   = new Dictionary <ushort, MobInfo>();
            MobsByName = new Dictionary <string, MobInfo>();
            using (var file = new SHNFile(folder + @"\MobInfo.shn"))
            {
                using (DataTableReaderEx reader = new DataTableReaderEx(file))
                {
                    while (reader.Read())
                    {
                        MobInfo info = MobInfo.Load(reader);
                        if (MobsByID.ContainsKey(info.ID) || MobsByName.ContainsKey(info.Name))
                        {
                            Log.WriteLine(LogLevel.Warn, "Duplicate mob ID found in MobInfo.shn: {0}.", info.ID);
                            continue;
                        }
                        MobsByID.Add(info.ID, info);
                        MobsByName.Add(info.Name, info);
                    }
                }
            }
            Log.WriteLine(LogLevel.Info, "Loaded {0} mobs.", MobsByID.Count);

            MobData = new Dictionary <string, MobInfoServer>();
            using (var file = new SHNFile(folder + @"\MobInfoServer.shn"))
            {
                using (DataTableReaderEx reader = new DataTableReaderEx(file))
                {
                    while (reader.Read())
                    {
                        MobInfoServer info = MobInfoServer.Load(reader);
                        if (MobData.ContainsKey(info.InxName))
                        {
                            Log.WriteLine(LogLevel.Warn, "Duplicate mob ID found in MobInfoServer.shn: {0}.", info.InxName);
                            continue;
                        }
                        MobData.Add(info.InxName, info);
                    }
                }
            }
            Log.WriteLine(LogLevel.Info, "Loaded {0} mob infos.", MobsByID.Count);
        }