2018-04-09 14:17:10 -05:00
|
|
|
|
using System;
|
2017-05-26 17:49:27 -05:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.IO;
|
2018-02-21 19:29:23 -06:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
2018-04-09 14:17:10 -05:00
|
|
|
|
using SharedLibraryCore;
|
|
|
|
|
using SharedLibraryCore.Objects;
|
|
|
|
|
using SharedLibraryCore.Database;
|
|
|
|
|
|
2018-04-08 13:48:40 -05:00
|
|
|
|
namespace IW4MAdmin.Application
|
2015-03-08 16:20:10 -05:00
|
|
|
|
{
|
2018-02-21 19:29:23 -06:00
|
|
|
|
public class Program
|
2015-03-08 16:20:10 -05:00
|
|
|
|
{
|
2015-08-20 16:54:38 -05:00
|
|
|
|
static public double Version { get; private set; }
|
2018-02-21 19:29:23 -06:00
|
|
|
|
static public ApplicationManager ServerManager = ApplicationManager.GetInstance();
|
2018-03-06 01:22:19 -06:00
|
|
|
|
public static string OperatingDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar;
|
2015-03-08 23:28:57 -05:00
|
|
|
|
|
2018-04-08 13:48:40 -05:00
|
|
|
|
public static void Main(string[] args)
|
2015-03-08 16:20:10 -05:00
|
|
|
|
{
|
2018-02-21 19:29:23 -06:00
|
|
|
|
AppDomain.CurrentDomain.SetData("DataDirectory", OperatingDirectory);
|
2017-11-19 00:44:11 -06:00
|
|
|
|
System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
|
|
|
|
|
|
2018-04-08 16:50:58 -05:00
|
|
|
|
Version = Assembly.GetExecutingAssembly().GetName().Version.Major + Assembly.GetExecutingAssembly().GetName().Version.Minor / 10.0f;
|
2015-08-17 15:38:42 -05:00
|
|
|
|
|
2015-03-08 23:28:57 -05:00
|
|
|
|
Console.WriteLine("=====================================================");
|
2015-03-09 15:11:09 -05:00
|
|
|
|
Console.WriteLine(" IW4M ADMIN");
|
2015-03-08 23:28:57 -05:00
|
|
|
|
Console.WriteLine(" by RaidMax ");
|
2017-08-08 21:44:52 -05:00
|
|
|
|
Console.WriteLine($" Version {Version}");
|
2015-03-08 23:28:57 -05:00
|
|
|
|
Console.WriteLine("=====================================================");
|
2015-07-06 14:51:08 -05:00
|
|
|
|
|
2017-05-26 17:49:27 -05:00
|
|
|
|
try
|
2015-07-06 14:51:08 -05:00
|
|
|
|
{
|
2018-04-09 14:17:10 -05:00
|
|
|
|
using (var db = new DatabaseContext())
|
|
|
|
|
new ContextSeed(db).Seed().Wait();
|
|
|
|
|
|
2017-05-26 17:49:27 -05:00
|
|
|
|
CheckDirectories();
|
2015-03-08 23:28:57 -05:00
|
|
|
|
|
2018-03-13 16:30:22 -05:00
|
|
|
|
ServerManager = ApplicationManager.GetInstance();
|
|
|
|
|
ServerManager.Init().Wait();
|
2018-02-21 19:29:23 -06:00
|
|
|
|
|
2017-06-01 12:42:28 -05:00
|
|
|
|
Task.Run(() =>
|
2017-05-26 17:49:27 -05:00
|
|
|
|
{
|
|
|
|
|
String userInput;
|
2017-11-25 19:29:58 -06:00
|
|
|
|
Player Origin = ServerManager.GetClientService().Get(1).Result.AsPlayer();
|
2015-08-22 01:04:30 -05:00
|
|
|
|
|
2017-05-26 17:49:27 -05:00
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
userInput = Console.ReadLine();
|
2017-06-12 13:50:00 -04:00
|
|
|
|
|
2017-08-08 21:44:52 -05:00
|
|
|
|
if (userInput?.ToLower() == "quit")
|
2017-05-26 17:49:27 -05:00
|
|
|
|
ServerManager.Stop();
|
|
|
|
|
|
|
|
|
|
if (ServerManager.Servers.Count == 0)
|
|
|
|
|
return;
|
2015-08-22 01:04:30 -05:00
|
|
|
|
|
2017-11-25 19:29:58 -06:00
|
|
|
|
Origin.CurrentServer = ServerManager.Servers[0];
|
2017-05-26 17:49:27 -05:00
|
|
|
|
Event E = new Event(Event.GType.Say, userInput, Origin, null, ServerManager.Servers[0]);
|
|
|
|
|
ServerManager.Servers[0].ExecuteEvent(E);
|
|
|
|
|
Console.Write('>');
|
|
|
|
|
|
2018-02-27 21:27:23 -06:00
|
|
|
|
} while (ServerManager.Running);
|
2017-06-01 12:42:28 -05:00
|
|
|
|
});
|
2017-05-26 17:49:27 -05:00
|
|
|
|
|
2018-04-10 19:25:44 -05:00
|
|
|
|
Task.Run(() => WebfrontCore.Program.Init(ServerManager));
|
|
|
|
|
ServerManager.Start();
|
|
|
|
|
ServerManager.Logger.WriteVerbose("Shutdown complete");
|
|
|
|
|
|
2017-05-26 17:49:27 -05:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-25 19:29:58 -06:00
|
|
|
|
catch (Exception e)
|
2017-05-26 17:49:27 -05:00
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Fatal Error during initialization: {e.Message}");
|
2018-04-09 14:17:10 -05:00
|
|
|
|
while (e.InnerException != null)
|
2018-03-13 19:12:24 -05:00
|
|
|
|
{
|
|
|
|
|
e = e.InnerException;
|
|
|
|
|
Console.WriteLine($"Inner exception: {e.Message}");
|
|
|
|
|
}
|
2017-05-26 17:49:27 -05:00
|
|
|
|
Console.WriteLine("Press any key to exit...");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
}
|
2015-03-08 23:28:57 -05:00
|
|
|
|
}
|
2015-03-09 15:11:09 -05:00
|
|
|
|
|
2017-05-26 17:49:27 -05:00
|
|
|
|
static void CheckDirectories()
|
2015-07-06 12:13:42 -05:00
|
|
|
|
{
|
2018-02-21 19:29:23 -06:00
|
|
|
|
string curDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar;
|
2015-07-06 12:13:42 -05:00
|
|
|
|
|
2018-02-21 19:29:23 -06:00
|
|
|
|
if (!Directory.Exists($"{curDirectory}Plugins"))
|
|
|
|
|
Directory.CreateDirectory($"{curDirectory}Plugins");
|
2015-08-17 15:38:42 -05:00
|
|
|
|
}
|
2015-03-08 16:20:10 -05:00
|
|
|
|
}
|
|
|
|
|
}
|