mirror of
https://github.com/ACEmulator/ACE
synced 2026-08-17 12:26:06 -04:00
* Landblock Preloading PoC * Add TODO comment * Reformat RawLandblockId array * Requested changes * Third change
128 lines
4.5 KiB
C#
128 lines
4.5 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
|
|
using log4net;
|
|
using log4net.Config;
|
|
|
|
using ACE.Common;
|
|
using ACE.Database;
|
|
using ACE.DatLoader;
|
|
using ACE.Server.Command;
|
|
using ACE.Server.Managers;
|
|
using ACE.Server.Network.Managers;
|
|
|
|
namespace ACE.Server
|
|
{
|
|
class Program
|
|
{
|
|
/// <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")]
|
|
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(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
|
|
|
|
public static void Main(string[] args)
|
|
{
|
|
AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);
|
|
|
|
// 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);
|
|
|
|
var logRepository = LogManager.GetRepository(System.Reflection.Assembly.GetEntryAssembly());
|
|
XmlConfigurator.Configure(logRepository, new FileInfo("log4net.config"));
|
|
|
|
// 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...");
|
|
Console.Title = @"ACEmulator";
|
|
|
|
log.Info("Initializing ConfigManager...");
|
|
ConfigManager.Initialize();
|
|
|
|
log.Info("Initializing ServerManager...");
|
|
ServerManager.Initialize();
|
|
|
|
log.Info("Initializing DatManager...");
|
|
DatManager.Initialize(ConfigManager.Config.Server.DatFilesDirectory);
|
|
|
|
log.Info("Initializing DatabaseManager...");
|
|
DatabaseManager.Initialize();
|
|
|
|
log.Info("Starting DatabaseManager...");
|
|
DatabaseManager.Start();
|
|
|
|
log.Info("Starting PropertyManager...");
|
|
PropertyManager.Initialize();
|
|
|
|
log.Info("Initializing GuidManager...");
|
|
GuidManager.Initialize();
|
|
|
|
log.Info("Initializing InboundMessageManager...");
|
|
InboundMessageManager.Initialize();
|
|
|
|
log.Info("Initializing SocketManager...");
|
|
SocketManager.Initialize();
|
|
|
|
log.Info("Initializing WorldManager...");
|
|
WorldManager.Initialize();
|
|
|
|
if (ConfigManager.Config.Server.LandblockPreloading == true)
|
|
{
|
|
log.Info("Preloading Landblocks...");
|
|
LandblockManager.Initialize();
|
|
}
|
|
else
|
|
log.Info("No Landblock Preloading Performed...");
|
|
|
|
log.Info("Initializing EventManager...");
|
|
EventManager.Initialize();
|
|
|
|
// This should be last
|
|
log.Info("Initializing CommandManager...");
|
|
CommandManager.Initialize();
|
|
}
|
|
|
|
private static void OnProcessExit(object sender, EventArgs e)
|
|
{
|
|
PropertyManager.StopUpdating();
|
|
DatabaseManager.Stop();
|
|
|
|
// Do system specific cleanup here
|
|
try
|
|
{
|
|
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
|
{
|
|
MM_EndPeriod(1);
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
log.Error(ex.ToString());
|
|
}
|
|
}
|
|
}
|
|
}
|