2016-12-21 09:27:51 -05:00
|
|
|
|
using FFXIVClassic_World_Server.DataObjects;
|
|
|
|
|
using MySql.Data.MySqlClient;
|
2016-08-22 10:43:04 -04:00
|
|
|
|
using NLog;
|
|
|
|
|
using NLog.Fluent;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace FFXIVClassic_World_Server
|
|
|
|
|
{
|
|
|
|
|
class Program
|
|
|
|
|
{
|
|
|
|
|
public static Logger Log;
|
|
|
|
|
|
|
|
|
|
static void Main(string[] args)
|
|
|
|
|
{
|
|
|
|
|
// set up logging
|
|
|
|
|
Log = LogManager.GetCurrentClassLogger();
|
2017-01-08 21:42:43 -05:00
|
|
|
|
|
|
|
|
|
bool startServer = true;
|
|
|
|
|
|
|
|
|
|
Log.Info("==================================");
|
|
|
|
|
Log.Info("FFXIV Classic World Server");
|
|
|
|
|
Log.Info("Version: 0.0.1");
|
|
|
|
|
Log.Info("==================================");
|
|
|
|
|
|
2016-08-22 10:43:04 -04:00
|
|
|
|
#if DEBUG
|
|
|
|
|
TextWriterTraceListener myWriter = new TextWriterTraceListener(System.Console.Out);
|
|
|
|
|
Debug.Listeners.Add(myWriter);
|
2016-08-29 08:54:37 -04:00
|
|
|
|
|
|
|
|
|
if (System.Diagnostics.Debugger.IsAttached)
|
|
|
|
|
{
|
2017-01-08 21:42:43 -05:00
|
|
|
|
System.Threading.Thread.Sleep(5000);
|
2016-08-29 08:54:37 -04:00
|
|
|
|
}
|
|
|
|
|
|
2016-08-22 10:43:04 -04:00
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
//Load Config
|
2016-12-04 21:41:34 +00:00
|
|
|
|
ConfigConstants.Load();
|
|
|
|
|
ConfigConstants.ApplyLaunchArgs(args);
|
2016-08-22 10:43:04 -04:00
|
|
|
|
|
|
|
|
|
//Test DB Connection
|
|
|
|
|
Log.Info("Testing DB connection... ");
|
|
|
|
|
using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
conn.Open();
|
|
|
|
|
conn.Close();
|
|
|
|
|
|
|
|
|
|
Log.Info("Connection ok.");
|
|
|
|
|
}
|
|
|
|
|
catch (MySqlException e)
|
|
|
|
|
{
|
|
|
|
|
Log.Error(e.ToString());
|
|
|
|
|
startServer = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-12-21 09:27:51 -05:00
|
|
|
|
|
|
|
|
|
//Check World ID
|
|
|
|
|
DBWorld thisWorld = Database.GetServer(ConfigConstants.DATABASE_WORLDID);
|
|
|
|
|
if (thisWorld != null)
|
|
|
|
|
{
|
|
|
|
|
Program.Log.Info("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name);
|
|
|
|
|
ConfigConstants.PREF_SERVERNAME = thisWorld.name;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Program.Log.Info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed.");
|
|
|
|
|
ConfigConstants.PREF_SERVERNAME = "Unknown";
|
|
|
|
|
}
|
2016-08-22 10:43:04 -04:00
|
|
|
|
|
|
|
|
|
//Start server if A-OK
|
|
|
|
|
if (startServer)
|
|
|
|
|
{
|
|
|
|
|
Server server = new Server();
|
|
|
|
|
server.StartServer();
|
|
|
|
|
|
|
|
|
|
while (startServer)
|
|
|
|
|
{
|
|
|
|
|
String input = Console.ReadLine();
|
|
|
|
|
Log.Info("[Console Input] " + input);
|
|
|
|
|
//cp.DoCommand(input, null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Program.Log.Info("Press any key to continue...");
|
|
|
|
|
Console.ReadKey();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|