ace/Source/ACE.Server/Program.cs

382 lines
17 KiB
C#
Raw Permalink Normal View History

Major migration from .net framework 4.6.1 to .net standard/core 2.0 (#573) * Remove files not referenced by their project (rogue files) These existed in the repo but weren't included in the ACE.Entity project: ACE.Entity\ILandBlock.cs ACE.Entity\WeenieAnimationOverride.cs ACE.Entity\WeeniePalletOverride.cs ACE.Entity\WeenieTextureMapOverride.cs When converting to .net standard, these files will be included in the projects again due to the way .net core/standard project files behave. They include all files in the local paths. Unlike .net framework csproj files, there is no list of files the project maintains. * Remove Settings.StyleCop from child folders I believe only the Settings.StyleCop in the root folder is needed, and will take effect for all child projects in the solution. * ACE.Common and ACE.Entity converted to .net standard 2.0 * ACE.DatLoader switched to .net standard 2.0 This includes the removal of: ACE.DatLoader\default.ruleset which I believe to be a rogue file. * ACE.CmdLineLauncher now .net core 2.0 To launch it from a command line use: dotnet ACE.CmdLineLauncher.dll This commit also removes AnyCPU from ACE.Common, ACE.DatLoader and ACE.Entity * ACE.DatLoader.Tests converted to .net standard 2.0 The project icon for ACE.DatLoader.Tests is no longer a C# icon with a half full flask. Not sure if there is any significance with that. * ACE.Tests converted to .net standard 2.0 Just like the other test project I converted, the C# Flask icon for the project is gone and now it's just a C# icon. * ACE.Database.Tests converted to .net standard 2 Same project icon issue as noted in the previous test conversions. * ACE.Database converted to .net standard 2.0 ACE.Database\Redeploy.cs -> CheckLocalDataPath() File permission checking has been commented out as it's not supported in .net standard/core. ACE: MySql.Data package updated to 6.10.4 * ACE: Remove GameMessageMotion.cs (rogue file) * ACE: Remove ACE.Diagnostics reference ACE.Diagnostics is a winforms app and not available to .net core 2.0 We need a better way to expose diagnostic information anyway. ACE should not be referencing ACE.Diagnostics * ACE.Tests changed to a .net core 2.0 project When ACE is changed to .net core 2.0, it's test must also be .net core 2.0. * ACE.Database: Remove MySqlResult MySqlResult inherited from DataTable and added a property and a couple functions, but they were never used, thus, MySqlResult isn't needed. * Update remaining MySql.Data references to 6.10.1 * Force appveyor to use VS 2017 * Remove unused System.Net.Http reference from projects. ACE.Api.Common ACE.Api.Host ACE.Api ACE.AuthApi.Host ACE.AuthApi Ace * Fix appveyor test paths. * ACE: DataTableExtensions added with Load fix for .net core 2.0 * Changelog * AppVeyor test fix maybe * Change ACE.Database.Tests and ACE.DatLoader.Tests to .net core 2.0 + test NuGet dependancies * ACE.Database: DataTableExtensions improved Rawaho method is better than Mag-nus method. * AppVeyor fix that's just cosmetic. Tests still don't actually exec. * AppVeyor test * Appveyor test * AppVeyor test * Switch AppVeyor from vstest.console to dotnet test * AppVeyor another test * AppVeyor test * AppVeyor final fix maybe? * AppVeyor: Went wrong way with directories... * AppVeyor almost there... * AppVeyor fatt fingers maybe? * ACE.CmdLineLauncher -> ACE.ACClientLauncher
2017-12-04 18:10:33 -06:00
using System;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime;
Usage of DateTime/PhysicsTimer cleaned up across the board (#1016) * Remove duplicate Timer from Physics.Common * Clean up ACE.Common.Time and its usages * WorldObject: Fix CreationTimestamp * Remove PhysicsTimer which was just a class wrapping a double * WorldManager.UpdateWorld Stopwatch Usage change Before we were calculating the elapsed seconds manually with this: (double)worldTickTimer.ElapsedTicks / Stopwatch.Frequency The stopwatch can already do this for us via this: worldTickTimer.Elapsed.TotalSeconds * WorldManager UpdateWorld Summary improvement * DateTime based tick removed from Tick() arguments * No need to pass DateTime.UtcNow.Ticks to Session.Tick * LastMovementBroadcastTicks was obsolete Probably souldn't be referencing WorldManager.PortalYearTicks as well. If we need this in the future, it's probably better to reference DateTime.UtcNow or Time.GetUnixTime() * Fix WorldObject.Tick() overhead * Revert "WorldObject: Fix CreationTimestamp" This reverts commit 457bebc48ea411d771864f4939acd8c15d9af482. * PhysicsTimer stuff Move the Timer back to the Physics namespace and rename it PhysicsTimer Change some references from PhysicsTimer to DateTime.UtcNow * timeBeginPeriod and timeEndPeriod added for Windows to improve timer resolution * ServerManager Shutdown was using 100% cpu * Fix the usage of CreationTimestamp * CharacterHandler should not be setting default values. Player ctor should. * EmoteManager switched from PhysicsTimer to DateTime.UtcNow * Use PropertyInt and not PropertyFloat for LoginTimestamp * Fix Session GetAll() to also include sessions that are at the character selections creen
2018-09-15 15:26:10 -05:00
using System.Runtime.InteropServices;
using System.Threading;
using log4net;
using log4net.Config;
using ACE.Common;
using ACE.Common.Extensions;
using ACE.Database;
using ACE.DatLoader;
using ACE.Server.Command;
using ACE.Server.Managers;
using ACE.Server.Mods;
using ACE.Server.Network.Managers;
namespace ACE.Server
{
partial class Program
{
Usage of DateTime/PhysicsTimer cleaned up across the board (#1016) * Remove duplicate Timer from Physics.Common * Clean up ACE.Common.Time and its usages * WorldObject: Fix CreationTimestamp * Remove PhysicsTimer which was just a class wrapping a double * WorldManager.UpdateWorld Stopwatch Usage change Before we were calculating the elapsed seconds manually with this: (double)worldTickTimer.ElapsedTicks / Stopwatch.Frequency The stopwatch can already do this for us via this: worldTickTimer.Elapsed.TotalSeconds * WorldManager UpdateWorld Summary improvement * DateTime based tick removed from Tick() arguments * No need to pass DateTime.UtcNow.Ticks to Session.Tick * LastMovementBroadcastTicks was obsolete Probably souldn't be referencing WorldManager.PortalYearTicks as well. If we need this in the future, it's probably better to reference DateTime.UtcNow or Time.GetUnixTime() * Fix WorldObject.Tick() overhead * Revert "WorldObject: Fix CreationTimestamp" This reverts commit 457bebc48ea411d771864f4939acd8c15d9af482. * PhysicsTimer stuff Move the Timer back to the Physics namespace and rename it PhysicsTimer Change some references from PhysicsTimer to DateTime.UtcNow * timeBeginPeriod and timeEndPeriod added for Windows to improve timer resolution * ServerManager Shutdown was using 100% cpu * Fix the usage of CreationTimestamp * CharacterHandler should not be setting default values. Player ctor should. * EmoteManager switched from PhysicsTimer to DateTime.UtcNow * Use PropertyInt and not PropertyFloat for LoginTimestamp * Fix Session GetAll() to also include sessions that are at the character selections creen
2018-09-15 15:26:10 -05:00
/// <summary>
/// The timeBeginPeriod function sets the minimum timer resolution for an application or device driver. Used to manipulate the timer frequency.
/// https://docs.microsoft.com/en-us/windows/desktop/api/timeapi/nf-timeapi-timebeginperiod
/// Important note: This function affects a global Windows setting. Windows uses the lowest value (that is, highest resolution) requested by any process.
/// </summary>
[DllImport("winmm.dll", EntryPoint = "timeBeginPeriod")]
Usage of DateTime/PhysicsTimer cleaned up across the board (#1016) * Remove duplicate Timer from Physics.Common * Clean up ACE.Common.Time and its usages * WorldObject: Fix CreationTimestamp * Remove PhysicsTimer which was just a class wrapping a double * WorldManager.UpdateWorld Stopwatch Usage change Before we were calculating the elapsed seconds manually with this: (double)worldTickTimer.ElapsedTicks / Stopwatch.Frequency The stopwatch can already do this for us via this: worldTickTimer.Elapsed.TotalSeconds * WorldManager UpdateWorld Summary improvement * DateTime based tick removed from Tick() arguments * No need to pass DateTime.UtcNow.Ticks to Session.Tick * LastMovementBroadcastTicks was obsolete Probably souldn't be referencing WorldManager.PortalYearTicks as well. If we need this in the future, it's probably better to reference DateTime.UtcNow or Time.GetUnixTime() * Fix WorldObject.Tick() overhead * Revert "WorldObject: Fix CreationTimestamp" This reverts commit 457bebc48ea411d771864f4939acd8c15d9af482. * PhysicsTimer stuff Move the Timer back to the Physics namespace and rename it PhysicsTimer Change some references from PhysicsTimer to DateTime.UtcNow * timeBeginPeriod and timeEndPeriod added for Windows to improve timer resolution * ServerManager Shutdown was using 100% cpu * Fix the usage of CreationTimestamp * CharacterHandler should not be setting default values. Player ctor should. * EmoteManager switched from PhysicsTimer to DateTime.UtcNow * Use PropertyInt and not PropertyFloat for LoginTimestamp * Fix Session GetAll() to also include sessions that are at the character selections creen
2018-09-15 15:26:10 -05:00
public static extern uint MM_BeginPeriod(uint uMilliseconds);
/// <summary>
/// The timeEndPeriod function clears a previously set minimum timer resolution
/// https://docs.microsoft.com/en-us/windows/desktop/api/timeapi/nf-timeapi-timeendperiod
/// </summary>
[DllImport("winmm.dll", EntryPoint = "timeEndPeriod")]
public static extern uint MM_EndPeriod(uint uMilliseconds);
private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static readonly bool IsRunningInContainer = Convert.ToBoolean(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"));
public static void Main(string[] args)
{
var consoleTitle = $"ACEmulator - v{ServerBuildInfo.FullVersion}";
Console.Title = consoleTitle;
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
// Typically, you wouldn't force the current culture on an entire application unless you know sure your application is used in a specific region (which ACE is not)
// We do this because almost all of the client/user input/output code does not take culture into account, and assumes en-US formatting.
// Without this, many commands that require special characters like , and . will break
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
// Init our text encoding options. This will allow us to use more than standard ANSI text, which the client also supports.
System.Text.Encoding.RegisterProvider(System.Text.CodePagesEncodingProvider.Instance);
// Look for the log4net.config first in the current environment directory, then in the ExecutingAssembly location
var exeLocation = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
var containerConfigDirectory = "/ace/Config";
var log4netConfig = Path.Combine(exeLocation, "log4net.config");
var log4netConfigExample = Path.Combine(exeLocation, "log4net.config.example");
var log4netConfigContainer = Path.Combine(containerConfigDirectory, "log4net.config");
if (IsRunningInContainer && File.Exists(log4netConfigContainer))
File.Copy(log4netConfigContainer, log4netConfig, true);
var log4netFileInfo = new FileInfo("log4net.config");
if (!log4netFileInfo.Exists)
log4netFileInfo = new FileInfo(log4netConfig);
if (!log4netFileInfo.Exists)
{
var exampleFile = new FileInfo(log4netConfigExample);
if (!exampleFile.Exists)
{
Console.WriteLine("log4net Configuration file is missing. Please copy the file log4net.config.example to log4net.config and edit it to match your needs before running ACE.");
throw new Exception("missing log4net configuration file");
}
else
{
if (!IsRunningInContainer)
{
Console.WriteLine("log4net Configuration file is missing, cloning from example file.");
File.Copy(log4netConfigExample, log4netConfig);
}
else
{
if (!File.Exists(log4netConfigContainer))
{
Console.WriteLine("log4net Configuration file is missing, ACEmulator is running in a container, cloning from docker file.");
var log4netConfigDocker = Path.Combine(exeLocation, "log4net.config.docker");
File.Copy(log4netConfigDocker, log4netConfig);
File.Copy(log4netConfigDocker, log4netConfigContainer);
}
else
{
File.Copy(log4netConfigContainer, log4netConfig);
}
}
}
}
var logRepository = LogManager.GetRepository(Assembly.GetEntryAssembly());
XmlConfigurator.ConfigureAndWatch(logRepository, log4netFileInfo);
if (Environment.ProcessorCount < 2)
log.Warn("Only one vCPU was detected. ACE may run with limited performance. You should increase your vCPU count for anything more than a single player server.");
Usage of DateTime/PhysicsTimer cleaned up across the board (#1016) * Remove duplicate Timer from Physics.Common * Clean up ACE.Common.Time and its usages * WorldObject: Fix CreationTimestamp * Remove PhysicsTimer which was just a class wrapping a double * WorldManager.UpdateWorld Stopwatch Usage change Before we were calculating the elapsed seconds manually with this: (double)worldTickTimer.ElapsedTicks / Stopwatch.Frequency The stopwatch can already do this for us via this: worldTickTimer.Elapsed.TotalSeconds * WorldManager UpdateWorld Summary improvement * DateTime based tick removed from Tick() arguments * No need to pass DateTime.UtcNow.Ticks to Session.Tick * LastMovementBroadcastTicks was obsolete Probably souldn't be referencing WorldManager.PortalYearTicks as well. If we need this in the future, it's probably better to reference DateTime.UtcNow or Time.GetUnixTime() * Fix WorldObject.Tick() overhead * Revert "WorldObject: Fix CreationTimestamp" This reverts commit 457bebc48ea411d771864f4939acd8c15d9af482. * PhysicsTimer stuff Move the Timer back to the Physics namespace and rename it PhysicsTimer Change some references from PhysicsTimer to DateTime.UtcNow * timeBeginPeriod and timeEndPeriod added for Windows to improve timer resolution * ServerManager Shutdown was using 100% cpu * Fix the usage of CreationTimestamp * CharacterHandler should not be setting default values. Player ctor should. * EmoteManager switched from PhysicsTimer to DateTime.UtcNow * Use PropertyInt and not PropertyFloat for LoginTimestamp * Fix Session GetAll() to also include sessions that are at the character selections creen
2018-09-15 15:26:10 -05:00
// Do system specific initializations here
try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
// On many windows systems, the default resolution for Thread.Sleep is 15.6ms. This allows us to command a tighter resolution
MM_BeginPeriod(1);
}
}
catch (Exception ex)
{
log.Error(ex.ToString());
}
log.Info("Starting ACEmulator...");
if (IsRunningInContainer)
log.Info("ACEmulator is running in a container...");
var configFile = Path.Combine(exeLocation, "Config.js");
var configConfigContainer = Path.Combine(containerConfigDirectory, "Config.js");
if (IsRunningInContainer && File.Exists(configConfigContainer))
File.Copy(configConfigContainer, configFile, true);
if (!File.Exists(configFile))
{
if (!IsRunningInContainer)
DoOutOfBoxSetup(configFile);
else
{
if (!File.Exists(configConfigContainer))
{
DoOutOfBoxSetup(configFile);
File.Copy(configFile, configConfigContainer);
}
else
File.Copy(configConfigContainer, configFile);
}
}
log.Info("Initializing ConfigManager...");
ConfigManager.Initialize();
log.Info("Initializing ModManager...");
ModManager.Initialize();
if (ConfigManager.Config.Server.WorldName != "ACEmulator")
{
consoleTitle = $"{ConfigManager.Config.Server.WorldName} | {consoleTitle}";
Console.Title = consoleTitle;
}
if (ConfigManager.Config.Offline.PurgeDeletedCharacters)
{
log.Info($"Purging deleted characters, and their possessions, older than {ConfigManager.Config.Offline.PurgeDeletedCharactersDays} days ({DateTime.Now.AddDays(-ConfigManager.Config.Offline.PurgeDeletedCharactersDays).ToCommonString()})...");
2019-11-24 16:50:50 -06:00
ShardDatabaseOfflineTools.PurgeCharactersInParallel(ConfigManager.Config.Offline.PurgeDeletedCharactersDays, out var charactersPurged, out var playerBiotasPurged, out var possessionsPurged);
log.Info($"Purged {charactersPurged:N0} characters, {playerBiotasPurged:N0} player biotas and {possessionsPurged:N0} possessions.");
}
2019-11-24 16:50:50 -06:00
if (ConfigManager.Config.Offline.PurgeOrphanedBiotas)
{
log.Info($"Purging orphaned biotas...");
ShardDatabaseOfflineTools.PurgeOrphanedBiotasInParallel(out var numberOfBiotasPurged);
log.Info($"Purged {numberOfBiotasPurged:N0} biotas.");
}
if (ConfigManager.Config.Offline.PruneDeletedCharactersFromFriendLists)
{
log.Info($"Pruning invalid friends from all friend lists...");
ShardDatabaseOfflineTools.PruneDeletedCharactersFromFriendLists(out var numberOfFriendsPruned);
log.Info($"Pruned {numberOfFriendsPruned:N0} invalid friends found on friend lists.");
}
if (ConfigManager.Config.Offline.PruneDeletedObjectsFromShortcutBars)
{
log.Info($"Pruning invalid shortcuts from all shortcut bars...");
ShardDatabaseOfflineTools.PruneDeletedObjectsFromShortcutBars(out var numberOfShortcutsPruned);
log.Info($"Pruned {numberOfShortcutsPruned:N0} deleted objects found on shortcut bars.");
}
if (ConfigManager.Config.Offline.PruneDeletedCharactersFromSquelchLists)
{
log.Info($"Pruning invalid squelches from all squelch lists...");
ShardDatabaseOfflineTools.PruneDeletedCharactersFromSquelchLists(out var numberOfSquelchesPruned);
log.Info($"Pruned {numberOfSquelchesPruned:N0} invalid squelched characters found on squelch lists.");
}
if (ConfigManager.Config.Offline.AutoServerUpdateCheck)
CheckForServerUpdate();
else
log.Info($"AutoServerVersionCheck is disabled...");
if (ConfigManager.Config.Offline.AutoUpdateWorldDatabase)
{
CheckForWorldDatabaseUpdate();
if (ConfigManager.Config.Offline.AutoApplyWorldCustomizations)
AutoApplyWorldCustomizations();
}
else
log.Info($"AutoUpdateWorldDatabase is disabled...");
if (ConfigManager.Config.Offline.AutoApplyDatabaseUpdates)
AutoApplyDatabaseUpdates();
else
log.Info($"AutoApplyDatabaseUpdates is disabled...");
// This should only be enabled manually. To enable it, simply uncomment this line
//ACE.Database.OfflineTools.Shard.BiotaGuidConsolidator.ConsolidateBiotaGuids(0xA0000000, true, false, out int numberOfBiotasConsolidated, out int numberOfBiotasSkipped, out int numberOfErrors);
//ACE.Database.OfflineTools.Shard.BiotaGuidConsolidator.ConsolidateBiotaGuids(0xD0000000, false, true, out int numberOfBiotasConsolidated2, out int numberOfBiotasSkipped2, out int numberOfErrors2);
ShardDatabaseOfflineTools.CheckForBiotaPropertiesPaletteOrderColumnInShard();
// pre-load starterGear.json, abort startup if file is not found as it is required to create new characters.
if (Factories.StarterGearFactory.GetStarterGearConfiguration() == null)
{
log.Fatal("Unable to load or parse starterGear.json. ACEmulator will now abort startup.");
ServerManager.StartupAbort();
Environment.Exit(0);
}
log.Info("Initializing ServerManager...");
2017-06-23 07:49:51 -05:00
ServerManager.Initialize();
log.Info("Initializing DatManager...");
DatManager.Initialize(ConfigManager.Config.Server.DatFilesDirectory, true);
Add support for client DAT patching from server (#3979) * Update DatFile.cs * Update DatFileType.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Create DDDManager.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Create GameMessageDDDBeginDDD.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Create GameMessageDDDDataMessage.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Update DDDHandler.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Update WorldManager.cs * Update Program.cs * committing changes provided Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * more wip changes * Update DDDManager.cs * Update DDDManager.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Update CMostlyConsecutiveIntSet.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Update WorldManager.cs * Update DDDHandler.cs * Update Session.cs * Update DDDManager.cs * Update Session.cs * Update DDDManager.cs * Update DDDManager.cs * Update GameMessageDDDDataMessage.cs * Update DDDHandler.cs * Update Session.cs * Update CAllIterationList.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Update CMostlyConsecutiveIntSet.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Create PTaggedIterationList.cs Co-Authored-By: OptimShi <OptimShi@users.noreply.github.com> * Update Session.cs * Update ConnectionListener.cs * Create DDDConfiguration.cs * Update MasterConfiguration.cs * Update Config.js.example * Update DDDManager.cs * Update DDDHandler.cs * Update Program.cs * Update PropertyManager.cs * Update WorldManager.cs * Update SessionTerminationReason.cs * Update DDDHandler.cs * Update DDDManager.cs * Update ConnectionListener.cs * Update SessionTerminationReason.cs * Update GameMessageDDDDataMessage.cs * Update AuthenticationHandler.cs * Update CharacterHandler.cs * Update PacketInboundLoginRequest.cs * Update Session.cs * Update DatFileType.cs --------- Co-authored-by: OptimShi <OptimShi@users.noreply.github.com>
2023-06-09 13:15:10 -04:00
if (ConfigManager.Config.DDD.EnableDATPatching)
{
log.Info("Initializing DDDManager...");
DDDManager.Initialize();
}
else
log.Info("DAT Patching Disabled...");
log.Info("Initializing DatabaseManager...");
DatabaseManager.Initialize();
if (DatabaseManager.InitializationFailure)
{
log.Fatal("DatabaseManager initialization failed. ACEmulator will now abort startup.");
ServerManager.StartupAbort();
Environment.Exit(0);
}
log.Info("Starting DatabaseManager...");
DatabaseManager.Start();
log.Info("Starting PropertyManager...");
PropertyManager.Initialize();
log.Info("Initializing GuidManager...");
GuidManager.Initialize();
if (ConfigManager.Config.Server.ServerPerformanceMonitorAutoStart)
{
log.Info("Server Performance Monitor auto starting...");
ServerPerformanceMonitor.Start();
}
if (ConfigManager.Config.Server.WorldDatabasePrecaching)
{
log.Info("Precaching Weenies...");
DatabaseManager.World.CacheAllWeenies();
log.Info("Precaching Cookbooks...");
DatabaseManager.World.CacheAllCookbooks();
log.Info("Precaching Events...");
DatabaseManager.World.GetAllEvents();
log.Info("Precaching House Portals...");
DatabaseManager.World.CacheAllHousePortals();
log.Info("Precaching Points Of Interest...");
DatabaseManager.World.CacheAllPointsOfInterest();
log.Info("Precaching Spells...");
DatabaseManager.World.CacheAllSpells();
log.Info("Precaching Treasures - Death...");
DatabaseManager.World.CacheAllTreasuresDeath();
log.Info("Precaching Treasures - Material Base...");
DatabaseManager.World.CacheAllTreasureMaterialBase();
log.Info("Precaching Treasures - Material Groups...");
DatabaseManager.World.CacheAllTreasureMaterialGroups();
log.Info("Precaching Treasures - Material Colors...");
DatabaseManager.World.CacheAllTreasureMaterialColor();
log.Info("Precaching Treasures - Wielded...");
DatabaseManager.World.CacheAllTreasureWielded();
}
else
log.Info("Precaching World Database Disabled...");
PlayerManager (#1103) * PlayerManager initial checkin * OfflinePlayer initial checkin * More progress * Comment out Console.WriteLine debug messages * Add property dictionaries to OfflinePlayer * IPlayer initial checkin * Add allegiance vars to IPlayer * Couple comments * More progress * Add more to IPlayer * line endings fix * More progress. Compiles. Friends list works again. * Friend status updates now work (again) * PlayerManager save OfflinePlayers every 1hr * Bye bye legacy AllPlayers * using cleanup * Allegience switch to PlayerManager progress * More Allegiance progress * More progress * More allegiance progress * IPlayer adds * Migrate inversefriends to PlayerManager * Switch WorldManager GetPlayerByGuid over to PlayerManager * WorldManager Find(ObjectGuid characterGuid) removed. Use PlayerManager instead * WorldManager FindByPlayerName(string name) removed. Use PlayerManager instead * PlayerManager thread safety switched to ReaderWriterLockSlim * More progress * ServerStatus added TotalAccountsCreated, TotalCharactersCreated * No more Player access/management stuff in WorldManager. It's all in PlayerManager now * Player.IsOnline is no more. * Friends AppearOnline fix * Handle dead session better to switch player from online to offline * Remove adding the + to names in ChatChannels. Name property should be changed to not include + * serverstatus total accounts and characters on same line * Allegience initial fix, still more bugs though * PlayerManager minor cleanup uint should be faster key than ObjectGuid Changed the dictionaries to private. We don't want anyone outside of this class referencing them. * Thread safety added to LScape.get_landcell
2018-12-02 13:41:16 -06:00
log.Info("Initializing PlayerManager...");
PlayerManager.Initialize();
2019-02-13 18:15:28 -05:00
log.Info("Initializing HouseManager...");
HouseManager.Initialize();
log.Info("Initializing InboundMessageManager...");
InboundMessageManager.Initialize();
log.Info("Initializing SocketManager...");
SocketManager.Initialize();
log.Info("Initializing WorldManager...");
WorldManager.Initialize();
log.Info("Initializing EventManager...");
EventManager.Initialize();
// Free up memory before the server goes online. This can free up 6 GB+ on larger servers.
log.Info("Forcing .net garbage collection...");
for (int i = 0; i < 10; i++)
{
// https://learn.microsoft.com/en-us/dotnet/standard/garbage-collection/fundamentals
// https://learn.microsoft.com/en-us/dotnet/api/system.runtime.gcsettings.largeobjectheapcompactionmode
GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce;
GC.Collect();
}
// This should be last
log.Info("Initializing CommandManager...");
CommandManager.Initialize();
//Register mod commands
log.Info("Registering ModManager commands...");
ModManager.RegisterCommands();
ModManager.ListMods();
if (!PropertyManager.GetBool("world_closed", false).Item)
{
WorldManager.Open(null);
}
}
private static void CurrentDomain_UnhandledException(object sender, UnhandledExceptionEventArgs e)
{
log.Error(e.ExceptionObject);
}
private static void OnProcessExit(object sender, EventArgs e)
{
if (!IsRunningInContainer)
{
if (!ServerManager.ShutdownInitiated)
log.Warn("Unsafe server shutdown detected! Data loss is possible!");
Landblock item saving + Much more (#1071) * Landblock EnqueueBroadcast cleanup Avoid double cast by using OfType Change excludeList from IEnumerable to ICollection because it was being enumerated more than once. * SerializedShard handle OperationCancledException * SerializedShard break on the exceptions * Landblock save progress * Landblock merge fix * Decayable -> Dynamic * Improved ShutdownServer to include landblock unload and db queue wait * Sleep during shutdown instead of using up all the CPU * Shard GetDynamic was comparing against the wrong id... woops * Fix shard biota caching * Improve shutdown logging and actions * cosmetic code order * Fix crash when trying to add a bad wo to a landblock * This fixes reloading dynamic objects * Don't save item on pickup * Don't save item on pickup from chest * Don't save items on drop * Set Home Position only for creatures (Used for navigation) * Improve the landblock SaveDB code * Don't save player corpse on death. Landblock will do that for us in bulk. * Add the housing objects to statics that persist to the shard * WorldObjectFactory dont overwrite location if object came from database * Improved IsStaticThatShouldPersistToShard * This should fix player dropped missiles * Move PositionType into ACE.Entity.Enum.Properties * Ephemeral support for Positions * Decay code/saving works much better * Filter out contained and wielded items from shard GetDynamicsByLandblock * TimeToRot provision for -1 (No rot) * Corpse decay is now controlled by landblock and uses the same decay code * ShardDatabase: Fix add/remove biota bug * WorldObject.Destroy now destroys contained and equipped items as well * TryRemoveFromInventoryWithNetworking no longer removes the object from the db * Player corpse items now remain when the corpse decays * Cleaned up SetPropertiesForWorld
2018-10-23 15:52:09 -05:00
PropertyManager.StopUpdating();
DatabaseManager.Stop();
Usage of DateTime/PhysicsTimer cleaned up across the board (#1016) * Remove duplicate Timer from Physics.Common * Clean up ACE.Common.Time and its usages * WorldObject: Fix CreationTimestamp * Remove PhysicsTimer which was just a class wrapping a double * WorldManager.UpdateWorld Stopwatch Usage change Before we were calculating the elapsed seconds manually with this: (double)worldTickTimer.ElapsedTicks / Stopwatch.Frequency The stopwatch can already do this for us via this: worldTickTimer.Elapsed.TotalSeconds * WorldManager UpdateWorld Summary improvement * DateTime based tick removed from Tick() arguments * No need to pass DateTime.UtcNow.Ticks to Session.Tick * LastMovementBroadcastTicks was obsolete Probably souldn't be referencing WorldManager.PortalYearTicks as well. If we need this in the future, it's probably better to reference DateTime.UtcNow or Time.GetUnixTime() * Fix WorldObject.Tick() overhead * Revert "WorldObject: Fix CreationTimestamp" This reverts commit 457bebc48ea411d771864f4939acd8c15d9af482. * PhysicsTimer stuff Move the Timer back to the Physics namespace and rename it PhysicsTimer Change some references from PhysicsTimer to DateTime.UtcNow * timeBeginPeriod and timeEndPeriod added for Windows to improve timer resolution * ServerManager Shutdown was using 100% cpu * Fix the usage of CreationTimestamp * CharacterHandler should not be setting default values. Player ctor should. * EmoteManager switched from PhysicsTimer to DateTime.UtcNow * Use PropertyInt and not PropertyFloat for LoginTimestamp * Fix Session GetAll() to also include sessions that are at the character selections creen
2018-09-15 15:26:10 -05:00
// Do system specific cleanup here
try
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
MM_EndPeriod(1);
}
}
catch (Exception ex)
Usage of DateTime/PhysicsTimer cleaned up across the board (#1016) * Remove duplicate Timer from Physics.Common * Clean up ACE.Common.Time and its usages * WorldObject: Fix CreationTimestamp * Remove PhysicsTimer which was just a class wrapping a double * WorldManager.UpdateWorld Stopwatch Usage change Before we were calculating the elapsed seconds manually with this: (double)worldTickTimer.ElapsedTicks / Stopwatch.Frequency The stopwatch can already do this for us via this: worldTickTimer.Elapsed.TotalSeconds * WorldManager UpdateWorld Summary improvement * DateTime based tick removed from Tick() arguments * No need to pass DateTime.UtcNow.Ticks to Session.Tick * LastMovementBroadcastTicks was obsolete Probably souldn't be referencing WorldManager.PortalYearTicks as well. If we need this in the future, it's probably better to reference DateTime.UtcNow or Time.GetUnixTime() * Fix WorldObject.Tick() overhead * Revert "WorldObject: Fix CreationTimestamp" This reverts commit 457bebc48ea411d771864f4939acd8c15d9af482. * PhysicsTimer stuff Move the Timer back to the Physics namespace and rename it PhysicsTimer Change some references from PhysicsTimer to DateTime.UtcNow * timeBeginPeriod and timeEndPeriod added for Windows to improve timer resolution * ServerManager Shutdown was using 100% cpu * Fix the usage of CreationTimestamp * CharacterHandler should not be setting default values. Player ctor should. * EmoteManager switched from PhysicsTimer to DateTime.UtcNow * Use PropertyInt and not PropertyFloat for LoginTimestamp * Fix Session GetAll() to also include sessions that are at the character selections creen
2018-09-15 15:26:10 -05:00
{
log.Error(ex.ToString());
Usage of DateTime/PhysicsTimer cleaned up across the board (#1016) * Remove duplicate Timer from Physics.Common * Clean up ACE.Common.Time and its usages * WorldObject: Fix CreationTimestamp * Remove PhysicsTimer which was just a class wrapping a double * WorldManager.UpdateWorld Stopwatch Usage change Before we were calculating the elapsed seconds manually with this: (double)worldTickTimer.ElapsedTicks / Stopwatch.Frequency The stopwatch can already do this for us via this: worldTickTimer.Elapsed.TotalSeconds * WorldManager UpdateWorld Summary improvement * DateTime based tick removed from Tick() arguments * No need to pass DateTime.UtcNow.Ticks to Session.Tick * LastMovementBroadcastTicks was obsolete Probably souldn't be referencing WorldManager.PortalYearTicks as well. If we need this in the future, it's probably better to reference DateTime.UtcNow or Time.GetUnixTime() * Fix WorldObject.Tick() overhead * Revert "WorldObject: Fix CreationTimestamp" This reverts commit 457bebc48ea411d771864f4939acd8c15d9af482. * PhysicsTimer stuff Move the Timer back to the Physics namespace and rename it PhysicsTimer Change some references from PhysicsTimer to DateTime.UtcNow * timeBeginPeriod and timeEndPeriod added for Windows to improve timer resolution * ServerManager Shutdown was using 100% cpu * Fix the usage of CreationTimestamp * CharacterHandler should not be setting default values. Player ctor should. * EmoteManager switched from PhysicsTimer to DateTime.UtcNow * Use PropertyInt and not PropertyFloat for LoginTimestamp * Fix Session GetAll() to also include sessions that are at the character selections creen
2018-09-15 15:26:10 -05:00
}
}
else
Usage of DateTime/PhysicsTimer cleaned up across the board (#1016) * Remove duplicate Timer from Physics.Common * Clean up ACE.Common.Time and its usages * WorldObject: Fix CreationTimestamp * Remove PhysicsTimer which was just a class wrapping a double * WorldManager.UpdateWorld Stopwatch Usage change Before we were calculating the elapsed seconds manually with this: (double)worldTickTimer.ElapsedTicks / Stopwatch.Frequency The stopwatch can already do this for us via this: worldTickTimer.Elapsed.TotalSeconds * WorldManager UpdateWorld Summary improvement * DateTime based tick removed from Tick() arguments * No need to pass DateTime.UtcNow.Ticks to Session.Tick * LastMovementBroadcastTicks was obsolete Probably souldn't be referencing WorldManager.PortalYearTicks as well. If we need this in the future, it's probably better to reference DateTime.UtcNow or Time.GetUnixTime() * Fix WorldObject.Tick() overhead * Revert "WorldObject: Fix CreationTimestamp" This reverts commit 457bebc48ea411d771864f4939acd8c15d9af482. * PhysicsTimer stuff Move the Timer back to the Physics namespace and rename it PhysicsTimer Change some references from PhysicsTimer to DateTime.UtcNow * timeBeginPeriod and timeEndPeriod added for Windows to improve timer resolution * ServerManager Shutdown was using 100% cpu * Fix the usage of CreationTimestamp * CharacterHandler should not be setting default values. Player ctor should. * EmoteManager switched from PhysicsTimer to DateTime.UtcNow * Use PropertyInt and not PropertyFloat for LoginTimestamp * Fix Session GetAll() to also include sessions that are at the character selections creen
2018-09-15 15:26:10 -05:00
{
ServerManager.DoShutdownNow();
DatabaseManager.Stop();
Usage of DateTime/PhysicsTimer cleaned up across the board (#1016) * Remove duplicate Timer from Physics.Common * Clean up ACE.Common.Time and its usages * WorldObject: Fix CreationTimestamp * Remove PhysicsTimer which was just a class wrapping a double * WorldManager.UpdateWorld Stopwatch Usage change Before we were calculating the elapsed seconds manually with this: (double)worldTickTimer.ElapsedTicks / Stopwatch.Frequency The stopwatch can already do this for us via this: worldTickTimer.Elapsed.TotalSeconds * WorldManager UpdateWorld Summary improvement * DateTime based tick removed from Tick() arguments * No need to pass DateTime.UtcNow.Ticks to Session.Tick * LastMovementBroadcastTicks was obsolete Probably souldn't be referencing WorldManager.PortalYearTicks as well. If we need this in the future, it's probably better to reference DateTime.UtcNow or Time.GetUnixTime() * Fix WorldObject.Tick() overhead * Revert "WorldObject: Fix CreationTimestamp" This reverts commit 457bebc48ea411d771864f4939acd8c15d9af482. * PhysicsTimer stuff Move the Timer back to the Physics namespace and rename it PhysicsTimer Change some references from PhysicsTimer to DateTime.UtcNow * timeBeginPeriod and timeEndPeriod added for Windows to improve timer resolution * ServerManager Shutdown was using 100% cpu * Fix the usage of CreationTimestamp * CharacterHandler should not be setting default values. Player ctor should. * EmoteManager switched from PhysicsTimer to DateTime.UtcNow * Use PropertyInt and not PropertyFloat for LoginTimestamp * Fix Session GetAll() to also include sessions that are at the character selections creen
2018-09-15 15:26:10 -05:00
}
}
}
}