2015-03-08 17:20:10 -04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Text;
|
2015-03-09 16:11:09 -04:00
|
|
|
|
using System.Threading;
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
|
|
|
|
namespace IW4MAdmin
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
2015-03-09 00:28:57 -04:00
|
|
|
|
static String IP;
|
|
|
|
|
static int Port;
|
|
|
|
|
static String RCON;
|
2015-03-09 16:11:09 -04:00
|
|
|
|
static double Version = 0.2;
|
2015-03-09 00:28:57 -04:00
|
|
|
|
|
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
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 ");
|
2015-03-09 16:11:09 -04:00
|
|
|
|
String latestVer = checkUpdate();
|
|
|
|
|
if (latestVer != null)
|
|
|
|
|
Console.WriteLine(" Version " + Version + " (latest " + latestVer + ")");
|
|
|
|
|
else
|
|
|
|
|
Console.WriteLine(" Version " + Version + " (unable to retrieve latest)");
|
2015-03-09 00:28:57 -04:00
|
|
|
|
Console.WriteLine("=====================================================");
|
2015-03-09 16:11:09 -04:00
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
|
|
|
|
file Config = new file("config\\servers.cfg");
|
2015-03-09 16:11:09 -04:00
|
|
|
|
String[] SV_CONF = Config.readAll();
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2015-03-09 16:11:09 -04:00
|
|
|
|
if (SV_CONF == null || SV_CONF.Length < 1)
|
2015-03-09 00:28:57 -04:00
|
|
|
|
{
|
|
|
|
|
setupConfig();
|
|
|
|
|
SV_CONF = new file("config\\servers.cfg").getParameters(3);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
if (Config.getSize() > 0 && SV_CONF != null)
|
|
|
|
|
{
|
2015-03-09 16:11:09 -04:00
|
|
|
|
foreach (String S in SV_CONF)
|
|
|
|
|
{
|
|
|
|
|
if (S.Length < 1)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
String[] sv = S.Split(':');
|
|
|
|
|
|
|
|
|
|
Console.WriteLine("Starting admin on port " + sv[1]);
|
|
|
|
|
|
|
|
|
|
Server IW4M;
|
|
|
|
|
IW4M = new Server(sv[0], Convert.ToInt32(sv[1]), sv[2]);
|
2015-03-08 17:20:10 -04:00
|
|
|
|
|
2015-03-09 16:11:09 -04:00
|
|
|
|
//Threading seems best here
|
|
|
|
|
Thread monitorThread = new Thread(new ThreadStart(IW4M.Monitor));
|
|
|
|
|
monitorThread.Start();
|
|
|
|
|
}
|
|
|
|
|
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("[FATAL] CONFIG FILE DOES NOT EXIST OR IS INCORRECT!");
|
|
|
|
|
Utilities.Wait(5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2015-03-09 00:28:57 -04:00
|
|
|
|
|
|
|
|
|
static void setupConfig()
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Hey there, it looks like you haven't set up a server yet. Let's get started!");
|
|
|
|
|
Console.Write("Please enter the IP: ");
|
|
|
|
|
IP = Console.ReadLine();
|
|
|
|
|
Console.Write("Please enter the Port: ");
|
|
|
|
|
Port = Convert.ToInt32(Console.ReadLine());
|
|
|
|
|
Console.Write("Please enter the RCON password: ");
|
|
|
|
|
RCON = Console.ReadLine();
|
|
|
|
|
file Config = new file("config\\servers.cfg", true);
|
|
|
|
|
Config.Write(IP + ":" + Port + ":" + RCON);
|
|
|
|
|
Console.WriteLine("Great! Let's go ahead and start 'er up.");
|
|
|
|
|
}
|
2015-03-09 16:11:09 -04:00
|
|
|
|
|
|
|
|
|
static String checkUpdate()
|
|
|
|
|
{
|
|
|
|
|
Connection Ver = new Connection("http://raidmax.org/IW4M/Admin/version.txt");
|
|
|
|
|
return Ver.Read();
|
|
|
|
|
}
|
2015-03-08 17:20:10 -04:00
|
|
|
|
}
|
|
|
|
|
}
|