forked from Elfocrash/L2dotNET
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
103 lines (87 loc) · 3.75 KB
/
Copy pathProgram.cs
File metadata and controls
103 lines (87 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Threading;
using System.Threading.Tasks;
using L2dotNET.ConsoleCommand;
using L2dotNET.DataContracts.Shared.Enums;
using L2dotNET.Handlers;
using L2dotNET.Logging.Abstraction;
using L2dotNET.Managers;
using L2dotNET.Managers.bbs;
using L2dotNET.Network;
using L2dotNET.Network.loginauth;
using L2dotNET.Repositories;
using L2dotNET.Services;
using L2dotNET.Tables;
using Microsoft.Extensions.DependencyInjection;
using NLog;
namespace L2dotNET.GameService
{
class Program
{
private static readonly Logger Log = LogManager.GetCurrentClassLogger();
private static ConsoleCommandController consoleCommandController;
private static void Main()
{
ClassLoggerConfigurator.ConfigureClassLogger($"{Assembly.GetExecutingAssembly().Location}.log");
TaskScheduler.UnobservedTaskException += (sender, e) =>
{
Log.ErrorTrace(e.Exception, "UnobservedTaskException");
};
consoleCommandController = new ConsoleCommandController();
consoleCommandController.Start();
try
{
Log.Info("Starting GameService...");
SetConsoleConfigurations();
SetNumberDecimalSeparator();
ServiceCollection serviceCollection = new ServiceCollection();
ConfigureServices(serviceCollection);
IServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
Task.Factory.StartNew(serviceProvider.GetService<GameServer>().Start);
}
catch(Exception ex)
{
Console.WriteLine("EXCEPTION : " + ex.Message + " " + ex.Data + " " + ex.Source + ex.StackTrace);
}
Process.GetCurrentProcess().WaitForExit();
Log.Info("Press ENTER to exit...");
Console.Read();
}
private static void ConfigureServices(IServiceCollection serviceCollection)
{
serviceCollection.AddSingleton<Config.Config>();
ServicesDependencyBinder.Bind(serviceCollection);
RepositoriesDependencyBinder.Bind(serviceCollection);
serviceCollection.AddSingleton<GamePacketHandlerAuth>();
serviceCollection.AddSingleton<AuthThread>();
serviceCollection.AddSingleton<GamePacketHandler>();
serviceCollection.AddSingleton<ClientManager>();
serviceCollection.AddSingleton<PreReqValidation>();
serviceCollection.AddSingleton<AnnouncementManager>();
serviceCollection.AddSingleton<SpawnTable>();
serviceCollection.AddSingleton<IdFactory>();
serviceCollection.AddSingleton<ItemTable>();
serviceCollection.AddSingleton<HtmCache>();
serviceCollection.AddSingleton<BbsManager>();
serviceCollection.AddSingleton<IAdminCommandHandler, AdminCommandHandler>();
serviceCollection.AddSingleton<GameServer>();
}
private static void SetConsoleConfigurations()
{
Console.Title = @"L2dotNET GameServer";
}
//TODO: Temporary fix. Need a better workaround to fix the Culture conversion issues. (Note: parsing error when reading "." in Latin cultures from XML files)
private static void SetNumberDecimalSeparator()
{
CultureInfo customCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
customCulture.NumberFormat.NumberDecimalSeparator = ".";
Thread.CurrentThread.CurrentCulture = customCulture;
}
}
}