2017-05-26 18:49:27 -04:00
|
|
|
|
|
2015-05-09 12:46:25 -04:00
|
|
|
|
using System;
|
2015-08-17 16:38:42 -04:00
|
|
|
|
using System.Runtime.InteropServices;
|
2015-08-20 01:06:44 -04:00
|
|
|
|
using SharedLibrary;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.IO;
|
2018-02-07 00:19:06 -05:00
|
|
|
|
using SharedLibrary.Objects;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
using System.Reflection;
|
2018-03-06 02:22:19 -05:00
|
|
|
|
using System.Linq;
|
2018-02-21 20:29:23 -05:00
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
namespace IW4MAdmin
|
|
|
|
|
{
|
2018-02-21 20:29:23 -05:00
|
|
|
|
public class Program
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2015-08-20 17:54:38 -04:00
|
|
|
|
static public double Version { get; private set; }
|
2018-02-21 20:29:23 -05:00
|
|
|
|
static public ApplicationManager ServerManager = ApplicationManager.GetInstance();
|
2018-03-06 02:22:19 -05:00
|
|
|
|
public static string OperatingDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar;
|
2015-03-09 00:28:57 -04:00
|
|
|
|
|
2018-03-18 22:25:11 -04:00
|
|
|
|
public static bool Start()
|
2015-03-08 17:20:10 -04:00
|
|
|
|
{
|
2018-02-21 20:29:23 -05:00
|
|
|
|
AppDomain.CurrentDomain.SetData("DataDirectory", OperatingDirectory);
|
2017-11-19 01:44:11 -05:00
|
|
|
|
System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal;
|
|
|
|
|
|
2017-11-16 18:09:19 -05:00
|
|
|
|
Version = 1.6;
|
2015-08-17 16:38:42 -04:00
|
|
|
|
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine("=====================================================");
|
2015-03-09 16:11:09 -04:00
|
|
|
|
Console.WriteLine(" IW4M ADMIN");
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine(" by RaidMax ");
|
2017-08-08 22:44:52 -04:00
|
|
|
|
Console.WriteLine($" Version {Version}");
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine("=====================================================");
|
2015-07-06 15:51:08 -04:00
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
try
|
2015-07-06 15:51:08 -04:00
|
|
|
|
{
|
2018-03-13 17:30:22 -04:00
|
|
|
|
/*var v1 = SharedLibrary.Helpers.Vector3.Parse("(737, 1117, 268)");
|
|
|
|
|
var v2 = SharedLibrary.Helpers.Vector3.Parse("(1510, 672.98, -228.66)");
|
|
|
|
|
double angleBetween = v1.AngleBetween(v2);*/
|
2017-05-26 18:49:27 -04:00
|
|
|
|
CheckDirectories();
|
2015-03-09 00:28:57 -04:00
|
|
|
|
|
2018-03-13 17:30:22 -04:00
|
|
|
|
ServerManager = ApplicationManager.GetInstance();
|
|
|
|
|
SharedLibrary.Database.Repair.Run(ServerManager.Logger);
|
|
|
|
|
ServerManager.Init().Wait();
|
|
|
|
|
Task.Run(() => ServerManager.Start());
|
2018-02-21 20:29:23 -05:00
|
|
|
|
|
2017-06-01 13:42:28 -04:00
|
|
|
|
Task.Run(() =>
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
|
|
|
|
String userInput;
|
2017-11-25 20:29:58 -05:00
|
|
|
|
Player Origin = ServerManager.GetClientService().Get(1).Result.AsPlayer();
|
2015-08-22 02:04:30 -04:00
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
do
|
|
|
|
|
{
|
|
|
|
|
userInput = Console.ReadLine();
|
2017-06-12 13:50:00 -04:00
|
|
|
|
|
2017-08-08 22:44:52 -04:00
|
|
|
|
if (userInput?.ToLower() == "quit")
|
2017-05-26 18:49:27 -04:00
|
|
|
|
ServerManager.Stop();
|
|
|
|
|
|
|
|
|
|
if (ServerManager.Servers.Count == 0)
|
|
|
|
|
return;
|
2015-08-22 02:04:30 -04:00
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
Origin.CurrentServer = ServerManager.Servers[0];
|
2017-05-26 18:49:27 -04:00
|
|
|
|
Event E = new Event(Event.GType.Say, userInput, Origin, null, ServerManager.Servers[0]);
|
|
|
|
|
ServerManager.Servers[0].ExecuteEvent(E);
|
|
|
|
|
Console.Write('>');
|
|
|
|
|
|
2018-02-27 22:27:23 -05:00
|
|
|
|
} while (ServerManager.Running);
|
2018-03-06 02:22:19 -05:00
|
|
|
|
|
|
|
|
|
Console.WriteLine("Shutdown complete");
|
2017-06-01 13:42:28 -04:00
|
|
|
|
});
|
2017-05-26 18:49:27 -04:00
|
|
|
|
|
2018-03-18 22:25:11 -04:00
|
|
|
|
return true;
|
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
}
|
|
|
|
|
|
2017-11-25 20:29:58 -05:00
|
|
|
|
catch (Exception e)
|
2017-05-26 18:49:27 -04:00
|
|
|
|
{
|
|
|
|
|
Console.WriteLine($"Fatal Error during initialization: {e.Message}");
|
2018-03-13 20:12:24 -04:00
|
|
|
|
while(e.InnerException != null)
|
|
|
|
|
{
|
|
|
|
|
e = e.InnerException;
|
|
|
|
|
Console.WriteLine($"Inner exception: {e.Message}");
|
|
|
|
|
}
|
2017-05-26 18:49:27 -04:00
|
|
|
|
Console.WriteLine("Press any key to exit...");
|
|
|
|
|
Console.ReadKey();
|
2018-03-18 22:25:11 -04:00
|
|
|
|
return false;
|
2017-05-26 18:49:27 -04:00
|
|
|
|
}
|
2015-03-09 00:28:57 -04:00
|
|
|
|
}
|
2015-03-09 16:11:09 -04:00
|
|
|
|
|
2017-05-26 18:49:27 -04:00
|
|
|
|
static void CheckDirectories()
|
2015-07-06 13:13:42 -04:00
|
|
|
|
{
|
2018-02-21 20:29:23 -05:00
|
|
|
|
string curDirectory = Path.GetDirectoryName(Assembly.GetEntryAssembly().Location) + Path.DirectorySeparatorChar;
|
2015-07-06 13:13:42 -04:00
|
|
|
|
|
2018-02-21 20:29:23 -05:00
|
|
|
|
if (!Directory.Exists($"{curDirectory}Plugins"))
|
|
|
|
|
Directory.CreateDirectory($"{curDirectory}Plugins");
|
2015-08-17 16:38:42 -04:00
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|