1
Fork 0
mirror of https://bitbucket.org/Ioncannon/project-meteor-server.git synced 2025-04-24 21:57:45 +00:00
project-meteor-server/FFXIVClassic Map Server/Program.cs

76 lines
2.5 KiB
C#
Raw Normal View History

using System;
2015-09-25 18:52:25 -04:00
using System.Diagnostics;
using MySql.Data.MySqlClient;
using System.Reflection;
using FFXIVClassic_Map_Server.dataobjects;
using FFXIVClassic_Map_Server.common;
2015-09-25 18:52:25 -04:00
namespace FFXIVClassic_Map_Server
2015-09-25 18:52:25 -04:00
{
class Program
{
static void Main(string[] args)
{
2015-09-25 18:52:25 -04:00
#if DEBUG
TextWriterTraceListener myWriter = new TextWriterTraceListener(System.Console.Out);
Debug.Listeners.Add(myWriter);
#endif
bool startServer = true;
//Load Config
if (!ConfigConstants.load())
startServer = false;
2015-09-25 18:52:25 -04:00
Log.Info("---------FFXIV 1.0 Map Server---------");
2015-09-25 18:52:25 -04:00
Assembly assem = Assembly.GetExecutingAssembly();
Version vers = assem.GetName().Version;
Log.Info("Version: " + vers.ToString());
2015-09-25 18:52:25 -04:00
//Test DB Connection
Log.Info("Testing DB connection... ");
2015-09-25 18:52:25 -04:00
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.Status("[OK]");
2015-09-25 18:52:25 -04:00
}
catch (MySqlException e)
{
Log.Error(e.ToString());
2015-09-25 18:52:25 -04:00
startServer = false;
}
}
//Check World ID
DBWorld thisWorld = Database.getServer(ConfigConstants.DATABASE_WORLDID);
2015-09-25 18:52:25 -04:00
if (thisWorld != null)
Log.Info(String.Format("Successfully pulled world info from DB. Server name is {0}.", thisWorld.name));
2015-09-25 18:52:25 -04:00
else
Log.Info("World info could not be retrieved from the DB. Welcome and MOTD will not be displayed.");
2015-09-25 18:52:25 -04:00
//Start server if A-OK
if (startServer)
{
Server server = new Server();
2016-04-06 15:29:24 -07:00
CommandProcessor cp = new CommandProcessor(server.getConnectedPlayerList());
2015-09-25 18:52:25 -04:00
server.startServer();
while (true)
{
String input = Console.ReadLine();
2016-04-06 15:22:26 -07:00
cp.doCommand(input, null);
}
2015-09-25 18:52:25 -04:00
}
Log.Info("Press any key to continue...");
2015-09-25 18:52:25 -04:00
Console.ReadKey();
}
}
}