public async Task StartAsync() { xmlConfigurationProvider.LoadFromFile("configs/WorldServer.ini"); Console.BackgroundColor = ConsoleColor.Black; Console.Title = $"{((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), inherit: false)[0]).Title} v{Assembly.GetExecutingAssembly().GetName().Version}"; Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("{0}", ((AssemblyProductAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyProductAttribute), inherit: false)[0]).Product); Console.WriteLine(((AssemblyCopyrightAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyCopyrightAttribute), inherit: false)[0]).Copyright); Console.WriteLine(); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine(" __ __ _ _ ___ ___ ___ __ __ ___ "); Console.WriteLine(" | \\/ |__ _| \\| |/ __|/ _ \\/ __| \\ \\ / /| _ ) We Love "); Console.WriteLine(" | |\\/| / _` | .` | (_ | (_) \\__ \\ \\ V / | _ \\ Vanilla Wow"); Console.WriteLine(" |_| |_\\__,_|_|\\_|\\___|\\___/|___/ \\_/ |___/ "); Console.WriteLine(" "); Console.WriteLine(" Website / Forum / Support: https://getmangos.eu/ "); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Magenta; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(((AssemblyTitleAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(AssemblyTitleAttribute), inherit: false)[0]).Title); Console.WriteLine(" version {0}", Assembly.GetExecutingAssembly().GetName().Version); Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Gray; DateTime dateTimeStarted = DateAndTime.Now; Log.WriteLine(LogType.INFORMATION, "[{0}] World Server Starting...", Strings.Format(DateAndTime.TimeOfDay, "hh:mm:ss")); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.UnhandledException += GenericExceptionHandler; LoadConfig(); Console.ForegroundColor = ConsoleColor.Gray; AccountDatabase.SQLMessage += AccountSQLEventHandler; CharacterDatabase.SQLMessage += CharacterSQLEventHandler; WorldDatabase.SQLMessage += WorldSQLEventHandler; int ReturnValues = AccountDatabase.Connect(); if (ReturnValues > 0) { Console.WriteLine("[{0}] An SQL Error has occurred", Strings.Format(DateAndTime.TimeOfDay, "hh:mm:ss")); Console.WriteLine("*************************"); Console.WriteLine("* Press any key to exit *"); Console.WriteLine("*************************"); Console.ReadKey(); ProjectData.EndApp(); } AccountDatabase.Update("SET NAMES 'utf8';"); ReturnValues = CharacterDatabase.Connect(); if (ReturnValues > 0) { Console.WriteLine("[{0}] An SQL Error has occurred", Strings.Format(DateAndTime.TimeOfDay, "hh:mm:ss")); Console.WriteLine("*************************"); Console.WriteLine("* Press any key to exit *"); Console.WriteLine("*************************"); Console.ReadKey(); ProjectData.EndApp(); } CharacterDatabase.Update("SET NAMES 'utf8';"); ReturnValues = WorldDatabase.Connect(); if (ReturnValues > 0) { Console.WriteLine("[{0}] An SQL Error has occurred", Strings.Format(DateAndTime.TimeOfDay, "hh:mm:ss")); Console.WriteLine("*************************"); Console.WriteLine("* Press any key to exit *"); Console.WriteLine("*************************"); Console.ReadKey(); ProjectData.EndApp(); } WorldDatabase.Update("SET NAMES 'utf8';"); bool areDbVersionsOk = true; if (!WorldServiceLocator._CommonGlobalFunctions.CheckRequiredDbVersion(AccountDatabase, ServerDb.Realm)) { areDbVersionsOk = false; } if (!WorldServiceLocator._CommonGlobalFunctions.CheckRequiredDbVersion(CharacterDatabase, ServerDb.Character)) { areDbVersionsOk = false; } if (!WorldServiceLocator._CommonGlobalFunctions.CheckRequiredDbVersion(WorldDatabase, ServerDb.World)) { areDbVersionsOk = false; } if (!areDbVersionsOk) { Console.WriteLine("*************************"); Console.WriteLine("* Press any key to exit *"); Console.WriteLine("*************************"); Console.ReadKey(); ProjectData.EndApp(); } await WorldServiceLocator._WS_DBCDatabase.InitializeInternalDatabaseAsync(); WorldServiceLocator._WS_Handlers.IntializePacketHandlers(); ALLQUESTS.LoadAllQuests(); await AllGraveYards.InitializeGraveyardsAsync(); WorldServiceLocator._WS_Transports.LoadTransports(); ClsWorldServer = new WS_Network.WorldServerClass(WorldServiceLocator._DataStoreProvider); WorldServerConfiguration configuration = WorldServiceLocator._ConfigurationProvider.GetConfiguration(); server = new ProxyServer <WS_Network.WorldServerClass>(Dns.GetHostAddresses(configuration.LocalConnectHost)[0], configuration.LocalConnectPort, ClsWorldServer); ClsWorldServer.ClusterConnect(); Log.WriteLine(LogType.INFORMATION, "Interface UP at: {0}", ClsWorldServer.LocalURI); GC.Collect(); if (Process.GetCurrentProcess().PriorityClass == ProcessPriorityClass.High) { Log.WriteLine(LogType.WARNING, "Setting Process Priority to HIGH..[done]"); } else { Log.WriteLine(LogType.WARNING, "Setting Process Priority to NORMAL..[done]"); } Log.WriteLine(LogType.INFORMATION, " Load Time: {0}", Strings.Format(DateAndTime.DateDiff(DateInterval.Second, dateTimeStarted, DateAndTime.Now), "0 seconds")); Log.WriteLine(LogType.INFORMATION, " Used Memory: {0}", Strings.Format(GC.GetTotalMemory(forceFullCollection: false), "### ### ##0 bytes")); WaitConsoleCommand(); try { } catch (Exception ex2) { ProjectData.SetProjectError(ex2); Exception ex = ex2; WorldServiceLocator._WS_TimerBasedEvents.Regenerator.Dispose(); AreaTriggers.Dispose(); ProjectData.ClearProjectError(); } }
public CreatureInfo(int CreatureID) : this() { Id = CreatureID; WorldServiceLocator._WorldServer.CREATURESDatabase.Add(Id, this); DataTable MySQLQuery = new DataTable(); WorldServiceLocator._WorldServer.WorldDatabase.Query($"SELECT * FROM creature_template LEFT JOIN creature_template_spells ON creature_template.entry = creature_template_spells.`entry` WHERE creature_template.entry = {CreatureID};", ref MySQLQuery); if (MySQLQuery.Rows.Count == 0) { WorldServiceLocator._WorldServer.Log.WriteLine(LogType.FAILED, "CreatureID {0} not found in SQL database.", CreatureID); found_ = false; return; } found_ = true; ModelA1 = MySQLQuery.Rows[0].As <int>("modelid1"); ModelA2 = MySQLQuery.Rows[0].As <int>("Modelid2"); ModelH1 = MySQLQuery.Rows[0].As <int>("modelid3"); ModelH2 = MySQLQuery.Rows[0].As <int>("modelid4"); Name = MySQLQuery.Rows[0].As <string>("name"); try { SubName = MySQLQuery.Rows[0].As <string>("subname"); } catch (Exception projectError) { ProjectData.SetProjectError(projectError); SubName = ""; ProjectData.ClearProjectError(); } Size = MySQLQuery.Rows[0].As <float>("scale"); MinLife = MySQLQuery.Rows[0].As <int>("MinLevelHealth"); MaxLife = MySQLQuery.Rows[0].As <int>("MaxLevelHealth"); MinMana = MySQLQuery.Rows[0].As <int>("MinLevelMana"); MaxMana = MySQLQuery.Rows[0].As <int>("MaxLevelMana"); ManaType = 0; Faction = MySQLQuery.Rows[0].As <short>("factionAlliance"); Elite = MySQLQuery.Rows[0].As <byte>("rank"); Damage.Maximum = MySQLQuery.Rows[0].As <float>("MaxMeleeDmg"); RangedDamage.Maximum = MySQLQuery.Rows[0].As <float>("MaxRangedDmg"); Damage.Minimum = MySQLQuery.Rows[0].As <float>("MinMeleeDmg"); RangedDamage.Minimum = MySQLQuery.Rows[0].As <float>("MinRangedDmg"); AttackPower = MySQLQuery.Rows[0].As <int>("MeleeAttackPower"); RangedAttackPower = MySQLQuery.Rows[0].As <int>("RangedAttackPower"); WalkSpeed = MySQLQuery.Rows[0].As <float>("SpeedWalk"); RunSpeed = MySQLQuery.Rows[0].As <float>("SpeedRun"); BaseAttackTime = MySQLQuery.Rows[0].As <short>("MeleeBaseAttackTime"); BaseRangedAttackTime = MySQLQuery.Rows[0].As <short>("RangedBaseAttackTime"); cNpcFlags = MySQLQuery.Rows[0].As <int>("NpcFlags"); DynFlags = MySQLQuery.Rows[0].As <int>("DynamicFlags"); cFlags = MySQLQuery.Rows[0].As <int>("UnitFlags"); TypeFlags = MySQLQuery.Rows[0].As <uint>("CreatureTypeFlags"); CreatureType = MySQLQuery.Rows[0].As <byte>("CreatureType"); CreatureFamily = MySQLQuery.Rows[0].As <byte>("Family"); LevelMin = MySQLQuery.Rows[0].As <byte>("MinLevel"); LevelMax = MySQLQuery.Rows[0].As <byte>("MaxLevel"); TrainerType = MySQLQuery.Rows[0].As <int>("TrainerType"); TrainerSpell = MySQLQuery.Rows[0].As <int>("TrainerSpell"); Classe = MySQLQuery.Rows[0].As <byte>("TrainerClass"); Race = MySQLQuery.Rows[0].As <byte>("TrainerRace"); Leader = MySQLQuery.Rows[0].As <byte>("RacialLeader"); if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[0]["spell1"]))) { Spells[0] = MySQLQuery.Rows[0].As <int>("spell1"); } else { Spells[0] = 0; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[0]["spell2"]))) { Spells[1] = MySQLQuery.Rows[0].As <int>("spell2"); } else { Spells[1] = 0; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[0]["spell3"]))) { Spells[2] = MySQLQuery.Rows[0].As <int>("spell3"); } else { Spells[2] = 0; } if (!Information.IsDBNull(RuntimeHelpers.GetObjectValue(MySQLQuery.Rows[0]["spell4"]))) { Spells[3] = MySQLQuery.Rows[0].As <int>("spell4"); } else { Spells[3] = 0; } PetSpellDataID = MySQLQuery.Rows[0].As <int>("PetSpellDataId"); LootID = MySQLQuery.Rows[0].As <int>("LootId"); SkinLootID = MySQLQuery.Rows[0].As <int>("SkinningLootId"); PocketLootID = MySQLQuery.Rows[0].As <int>("PickpocketLootId"); MinGold = MySQLQuery.Rows[0].As <uint>("MinLootGold"); MaxGold = MySQLQuery.Rows[0].As <uint>("MaxLootGold"); Resistances[0] = MySQLQuery.Rows[0].As <int>("Armor"); Resistances[1] = MySQLQuery.Rows[0].As <int>("ResistanceHoly"); Resistances[2] = MySQLQuery.Rows[0].As <int>("ResistanceFire"); Resistances[3] = MySQLQuery.Rows[0].As <int>("ResistanceNature"); Resistances[4] = MySQLQuery.Rows[0].As <int>("ResistanceFrost"); Resistances[5] = MySQLQuery.Rows[0].As <int>("ResistanceShadow"); Resistances[6] = MySQLQuery.Rows[0].As <int>("ResistanceArcane"); EquipmentID = MySQLQuery.Rows[0].As <int>("EquipmentTemplateId"); MechanicImmune = MySQLQuery.Rows[0].As <uint>("SchoolImmuneMask"); if (File.Exists("scripts\\gossip\\" + WorldServiceLocator._Functions.FixName(Name) + ".vb")) { ScriptedObject tmpScript = new ScriptedObject("scripts\\gossip\\" + WorldServiceLocator._Functions.FixName(Name) + ".vb", "", InMemory: true); TalkScript = (TBaseTalk)tmpScript.InvokeConstructor("TalkScript"); tmpScript.Dispose(); } else if (((uint)cNpcFlags & 0x10u) != 0) { TalkScript = new WS_NPCs.TDefaultTalk(); } else if (((uint)cNpcFlags & 0x40u) != 0) { TalkScript = new WS_GuardGossip.TGuardTalk(); } else if (cNpcFlags == 0) { TalkScript = null; } else if (cNpcFlags == 1) { TalkScript = new WS_NPCs.TDefaultTalk(); } else { TalkScript = new WS_NPCs.TDefaultTalk(); } }