Exemplo n.º 1
0
        public void ForeachInRange(Rectangle2D area, EDatabaseType type, ForeachInRangeVoidDelegate callback, object[] args)
        {
            List <WorldObject> objects = ObjectsInRange(area, type);

            for (int i = 0; i < objects.Count; i++)
            {
                WorldObject obj = objects[i];
                callback(obj, args);
            }
        }
Exemplo n.º 2
0
		public static void Load() {
			if (Loaded == true || Loading == true) {
				return;
			}

			Loading = true;
			// Trigger events for scripts
			Events.InvokeWorldLoadStart();

			// Our object manager for databsae objects
			Database = new DatabaseObjectManager();
			// Our object manager for world objects (spawned objects)
			Objects = new WorldObjectManager();

			// Delegate for Send() Method
			mForeachInRangeCallback = new ForeachInRangeVoidDelegate(SendSub);

			mAddQueue = new Queue<DatabaseObject>();
			mDelQueue = new Queue<DatabaseObject>();

			// Load globals from config, initialize packets ect
			ServerConsole.InfoLine("Initialize game symantics...");
			Global.Initialize();
			WorldObjectStatus.Initialize();
			ChatHelper.Initialize();
			PlayerCommandHelper.Initialize();
			PathHelper.Initialize();
			SkillTree.Initialize();
			FameListHelper.Initialize();
			CharacterJobBonus.Initialize();
			CharacterJobModifer.Initialize();

			// Real database loading
			ServerConsole.InfoLine("Begin World loading...");

			DataTable table = null;
			Stopwatch watchAll = Stopwatch.StartNew();
			Stopwatch watch = Stopwatch.StartNew();

			//------------- loading start -------------

			#region Mapcache
			ServerConsole.Info("\t# loading Maps from mapcache...");
			watch.Reset();
			watch.Start();
			Mapcache.Initialize();
			watch.Stop();
			ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Mapcache.Maps.Count + " Maps in " + watch.ElapsedMilliseconds + "ms)");
			#endregion


			#region Items
			ServerConsole.Info("\t# loading Items...");
			watch.Reset();
			watch.Start();
			table = Core.Database.Query("SELECT * FROM dbitem");
			table.TableName = "ItemDB Table";


			if (table == null || table.Rows.Count == 0) {
				if (Core.Database.LastError != null) {
					ServerConsole.ErrorLine("failed to load Item Database!");
					ServerConsole.WriteLine(Core.Database.LastError.ToString());
				}
			} else {
				ItemDatabaseData item;
				for (int i = 0; i < table.Rows.Count; i++) {
					item = ItemDatabaseData.Load(table.Rows[i]);
					if (item == null) {
						ServerConsole.WarningLine("Failed to load item {0}: #{1} {2}", i, table.Rows[i].Field<int>("itemID"), table.Rows[i].Field<string>("nameEnglish"));
						continue;
					}
					Database.Add(item);

					//ServerConsole.DebugLine("\tLoad: #{0} {1}", item.NameID.ToString().PadLeft(5), item.Name);
				}
			}
			watch.Stop();
			ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Items.Count + " Items in " + watch.ElapsedMilliseconds + "ms)");
			#endregion


			#region Monster
			ServerConsole.Info("\t# loading Mobs...");
			watch.Reset();
			watch.Start();
			table = Core.Database.Query("SELECT * FROM dbmob");
			table.TableName = "MobDB Table";
			if (table == null || table.Rows.Count == 0) {
				if (Core.Database.LastError != null) {
					ServerConsole.ErrorLine("failed to load Monster Database!");
					ServerConsole.WriteLine(Core.Database.LastError.ToString());
				}
			} else {
				MonsterDatabaseData mob;
				for (int i = 0; i < table.Rows.Count; i++) {
					mob = MonsterDatabaseData.Load(table.Rows[i]);
					if (mob == null) {
						ServerConsole.WarningLine("Failed to load mob {0}: #{1} {2}", i, table.Rows[i].Field<int>("mobID"), table.Rows[i].Field<string>("nameInter"));
						continue;
					}
					Database.Add(mob);

					//ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} drops, {3} skills)", mob.ID.ToString().PadLeft(5), mob.NameInter, mob.Drops.Count, mob.Skills.Count);
				}
			}
			watch.Stop();
			ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Monster.Count + " Mobs in " + watch.ElapsedMilliseconds + "ms)");


			ServerConsole.Info("\t# loading Mob Skills...");
			watch.Reset();
			watch.Start();
			table = Core.Database.Query("SELECT * FROM dbmob_skill ORDER BY mobID ASC");
			table.TableName = "MobDB Skill Table";
			if (table == null || table.Rows.Count == 0) {
				if (Core.Database.LastError != null) {
					ServerConsole.ErrorLine("failed to load Mob Skill Database!");
					ServerConsole.WriteLine(Core.Database.LastError.ToString());
				}
			} else {
				MonsterSkill mobSkill;
				for (int i = 0; i < table.Rows.Count; i++) {
					mobSkill = MonsterSkill.Load(table.Rows[i]);
					if (mobSkill == null) {
						throw new Exception(string.Format("Failed to load mob skill #{0}: {1}", table.Rows[i].Field<int>("mobID"), table.Rows[i].Field<string>("info")));
					}

					(Database[EDatabaseType.Mob, mobSkill.MobID] as MonsterDatabaseData).Skills.Add(mobSkill);

					//ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count);
				}
			}
			watch.Stop();
			ServerConsole.WriteLine(EConsoleColor.Status, " done in " + watch.ElapsedMilliseconds + "ms");


			ServerConsole.Info("\t# loading Mob Drops...");
			watch.Reset();
			watch.Start();
			table = Core.Database.Query("SELECT * FROM dbmob_drop ORDER BY mobID ASC");
			table.TableName = "MobDB Drop Table";
			if (table == null || table.Rows.Count == 0) {
				if (Core.Database.LastError != null) {
					ServerConsole.ErrorLine("failed to load Mob Drop Database!");
					ServerConsole.WriteLine(Core.Database.LastError.ToString());
				}
			} else {
				MonsterDrop drop;
				for (int i = 0; i < table.Rows.Count; i++) {
					drop = MonsterDrop.Load(table.Rows[i]);

					(Database[EDatabaseType.Mob, drop.MobID] as MonsterDatabaseData).Drops.Add(drop);

					//ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count);
				}
			}
			watch.Stop();
			ServerConsole.WriteLine(EConsoleColor.Status, " done in " + watch.ElapsedMilliseconds + "ms");
			#endregion


			#region General Skills
			ServerConsole.Info("\t# loading Skills...");
			watch.Reset();
			watch.Start();
			table = Core.Database.Query("SELECT * FROM dbskill");
			table.TableName = "SkillDB Table";
			if (table == null || table.Rows.Count == 0) {
				if (Core.Database.LastError != null) {
					ServerConsole.ErrorLine("failed to load Skill Database!");
					ServerConsole.WriteLine(Core.Database.LastError.ToString());
				}
			} else {
				SkillDatabaseData skill;
				for (int i = 0; i < table.Rows.Count; i++) {
					skill = SkillDatabaseData.Load(table.Rows[i]);
					if (skill == null) {
						ServerConsole.WarningLine("Failed to load skill {0}: #{1} {2}", i, table.Rows[i].Field<int>("skillID"), table.Rows[i].Field<string>("name"));
						continue;
					}
					Database.Add(skill.Index, skill);

					//ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count);
				}
			}
			watch.Stop();
			ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Skill.Count + " Skills in " + watch.ElapsedMilliseconds + "ms)");
			#endregion


			// Loading other shit
			// o.o

			//------------- loading end -------------

			// Trigger event for scripts
			Events.InvokeWorldLoadFinish();

			Loading = false;
			Loaded = true;

			ProcessSafetyQueues();

			// TODO: Initialize save timer

			ServerConsole.InfoLine("Finished World loading! Needed {0:F2} sec", watchAll.Elapsed.TotalSeconds);

			watch.Stop();
			watch = null;
			watchAll.Stop();
			watchAll = null;
		}
Exemplo n.º 3
0
 public void ForeachInRange(Rectangle2D area, ForeachInRangeVoidDelegate callback, object[] args)
 {
     ForeachInRange(area, EDatabaseType.Char, callback, args);
 }
Exemplo n.º 4
0
        public static void Load()
        {
            if (Loaded == true || Loading == true)
            {
                return;
            }

            Loading = true;
            // Trigger events for scripts
            Events.InvokeWorldLoadStart();

            // Our object manager for databsae objects
            Database = new DatabaseObjectManager();
            // Our object manager for world objects (spawned objects)
            Objects = new WorldObjectManager();

            // Delegate for Send() Method
            mForeachInRangeCallback = new ForeachInRangeVoidDelegate(SendSub);

            mAddQueue = new Queue <DatabaseObject>();
            mDelQueue = new Queue <DatabaseObject>();

            // Load globals from config, initialize packets ect
            ServerConsole.InfoLine("Initialize game symantics...");
            Global.Initialize();
            WorldObjectStatus.Initialize();
            ChatHelper.Initialize();
            PlayerCommandHelper.Initialize();
            PathHelper.Initialize();
            SkillTree.Initialize();
            FameListHelper.Initialize();
            CharacterJobBonus.Initialize();
            CharacterJobModifer.Initialize();

            // Real database loading
            ServerConsole.InfoLine("Begin World loading...");

            DataTable table    = null;
            Stopwatch watchAll = Stopwatch.StartNew();
            Stopwatch watch    = Stopwatch.StartNew();

            //------------- loading start -------------

            #region Mapcache
            ServerConsole.Info("\t# loading Maps from mapcache...");
            watch.Reset();
            watch.Start();
            Mapcache.Initialize();
            watch.Stop();
            ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Mapcache.Maps.Count + " Maps in " + watch.ElapsedMilliseconds + "ms)");
            #endregion


            #region Items
            ServerConsole.Info("\t# loading Items...");
            watch.Reset();
            watch.Start();
            table           = Core.Database.Query("SELECT * FROM dbitem");
            table.TableName = "ItemDB Table";


            if (table == null || table.Rows.Count == 0)
            {
                if (Core.Database.LastError != null)
                {
                    ServerConsole.ErrorLine("failed to load Item Database!");
                    ServerConsole.WriteLine(Core.Database.LastError.ToString());
                }
            }
            else
            {
                ItemDatabaseData item;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    item = ItemDatabaseData.Load(table.Rows[i]);
                    if (item == null)
                    {
                        ServerConsole.WarningLine("Failed to load item {0}: #{1} {2}", i, table.Rows[i].Field <int>("itemID"), table.Rows[i].Field <string>("nameEnglish"));
                        continue;
                    }
                    Database.Add(item);

                    //ServerConsole.DebugLine("\tLoad: #{0} {1}", item.NameID.ToString().PadLeft(5), item.Name);
                }
            }
            watch.Stop();
            ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Items.Count + " Items in " + watch.ElapsedMilliseconds + "ms)");
            #endregion


            #region Monster
            ServerConsole.Info("\t# loading Mobs...");
            watch.Reset();
            watch.Start();
            table           = Core.Database.Query("SELECT * FROM dbmob");
            table.TableName = "MobDB Table";
            if (table == null || table.Rows.Count == 0)
            {
                if (Core.Database.LastError != null)
                {
                    ServerConsole.ErrorLine("failed to load Monster Database!");
                    ServerConsole.WriteLine(Core.Database.LastError.ToString());
                }
            }
            else
            {
                MonsterDatabaseData mob;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    mob = MonsterDatabaseData.Load(table.Rows[i]);
                    if (mob == null)
                    {
                        ServerConsole.WarningLine("Failed to load mob {0}: #{1} {2}", i, table.Rows[i].Field <int>("mobID"), table.Rows[i].Field <string>("nameInter"));
                        continue;
                    }
                    Database.Add(mob);

                    //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} drops, {3} skills)", mob.ID.ToString().PadLeft(5), mob.NameInter, mob.Drops.Count, mob.Skills.Count);
                }
            }
            watch.Stop();
            ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Monster.Count + " Mobs in " + watch.ElapsedMilliseconds + "ms)");


            ServerConsole.Info("\t# loading Mob Skills...");
            watch.Reset();
            watch.Start();
            table           = Core.Database.Query("SELECT * FROM dbmob_skill ORDER BY mobID ASC");
            table.TableName = "MobDB Skill Table";
            if (table == null || table.Rows.Count == 0)
            {
                if (Core.Database.LastError != null)
                {
                    ServerConsole.ErrorLine("failed to load Mob Skill Database!");
                    ServerConsole.WriteLine(Core.Database.LastError.ToString());
                }
            }
            else
            {
                MonsterSkill mobSkill;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    mobSkill = MonsterSkill.Load(table.Rows[i]);
                    if (mobSkill == null)
                    {
                        throw new Exception(string.Format("Failed to load mob skill #{0}: {1}", table.Rows[i].Field <int>("mobID"), table.Rows[i].Field <string>("info")));
                    }

                    (Database[EDatabaseType.Mob, mobSkill.MobID] as MonsterDatabaseData).Skills.Add(mobSkill);

                    //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count);
                }
            }
            watch.Stop();
            ServerConsole.WriteLine(EConsoleColor.Status, " done in " + watch.ElapsedMilliseconds + "ms");


            ServerConsole.Info("\t# loading Mob Drops...");
            watch.Reset();
            watch.Start();
            table           = Core.Database.Query("SELECT * FROM dbmob_drop ORDER BY mobID ASC");
            table.TableName = "MobDB Drop Table";
            if (table == null || table.Rows.Count == 0)
            {
                if (Core.Database.LastError != null)
                {
                    ServerConsole.ErrorLine("failed to load Mob Drop Database!");
                    ServerConsole.WriteLine(Core.Database.LastError.ToString());
                }
            }
            else
            {
                MonsterDrop drop;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    drop = MonsterDrop.Load(table.Rows[i]);

                    (Database[EDatabaseType.Mob, drop.MobID] as MonsterDatabaseData).Drops.Add(drop);

                    //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count);
                }
            }
            watch.Stop();
            ServerConsole.WriteLine(EConsoleColor.Status, " done in " + watch.ElapsedMilliseconds + "ms");
            #endregion


            #region General Skills
            ServerConsole.Info("\t# loading Skills...");
            watch.Reset();
            watch.Start();
            table           = Core.Database.Query("SELECT * FROM dbskill");
            table.TableName = "SkillDB Table";
            if (table == null || table.Rows.Count == 0)
            {
                if (Core.Database.LastError != null)
                {
                    ServerConsole.ErrorLine("failed to load Skill Database!");
                    ServerConsole.WriteLine(Core.Database.LastError.ToString());
                }
            }
            else
            {
                SkillDatabaseData skill;
                for (int i = 0; i < table.Rows.Count; i++)
                {
                    skill = SkillDatabaseData.Load(table.Rows[i]);
                    if (skill == null)
                    {
                        ServerConsole.WarningLine("Failed to load skill {0}: #{1} {2}", i, table.Rows[i].Field <int>("skillID"), table.Rows[i].Field <string>("name"));
                        continue;
                    }
                    Database.Add(skill.Index, skill);

                    //ServerConsole.DebugLine("\tLoad: #{0} {1} ({2} level)", skill.ID.ToString().PadLeft(5), skill.Name, skill.Level.Count);
                }
            }
            watch.Stop();
            ServerConsole.WriteLine(EConsoleColor.Status, " done (" + Database.Skill.Count + " Skills in " + watch.ElapsedMilliseconds + "ms)");
            #endregion


            // Loading other shit
            // o.o

            //------------- loading end -------------

            // Trigger event for scripts
            Events.InvokeWorldLoadFinish();

            Loading = false;
            Loaded  = true;

            ProcessSafetyQueues();

            // TODO: Initialize save timer

            ServerConsole.InfoLine("Finished World loading! Needed {0:F2} sec", watchAll.Elapsed.TotalSeconds);

            watch.Stop();
            watch = null;
            watchAll.Stop();
            watchAll = null;
        }
Exemplo n.º 5
0
		public void ForeachInRange(Rectangle2D area, EDatabaseType type, ForeachInRangeVoidDelegate callback, object[] args) {
			List<WorldObject> objects = ObjectsInRange(area, type);

			for (int i = 0; i < objects.Count; i++) {
				WorldObject obj = objects[i];
				callback(obj, args);
			}

		}
Exemplo n.º 6
0
		public void ForeachInRange(Rectangle2D area, ForeachInRangeVoidDelegate callback, object[] args) {
			ForeachInRange(area, EDatabaseType.Char, callback, args);
		}