added launch args for ip/port and default config loading

- fixed char create issues by adding default values to fields (todo: fix actual query)
- added post build command to copy scripts folder to bin
This commit is contained in:
Tahir Akhlaq
2016-12-04 21:41:34 +00:00
parent f286922974
commit 4a320d7096
13 changed files with 142 additions and 32 deletions

View File

@@ -1,6 +1,8 @@
using FFXIVClassic.Common;
using System;
using System.IO;
using System.Linq;
using System.Net;
namespace FFXIVClassic_Lobby_Server
{
@@ -23,7 +25,7 @@ namespace FFXIVClassic_Lobby_Server
if (!File.Exists("./lobby_config.ini"))
{
Program.Log.Error("FILE NOT FOUND!");
return false;
Program.Log.Error("Loading defaults...");
}
INIFile configIni = new INIFile("./lobby_config.ini");
@@ -40,5 +42,34 @@ namespace FFXIVClassic_Lobby_Server
return true;
}
public static void ApplyLaunchArgs(string[] launchArgs)
{
var args = (from arg in launchArgs select arg.ToLower().Trim().TrimStart('-')).ToList();
for (var i = 0; i + 1 < args.Count; i += 2)
{
var arg = args[i];
var val = args[i + 1];
var legit = false;
if (arg == "ip")
{
IPAddress ip;
if (IPAddress.TryParse(val, out ip) && (legit = true))
OPTIONS_BINDIP = val;
}
else if (arg == "port")
{
UInt16 port;
if (UInt16.TryParse(val, out port) && (legit = true))
OPTIONS_PORT = val;
}
if (!legit)
{
Program.Log.Error("Invalid parameter <{0}> for argument: <--{1}> or argument doesnt exist!", val, arg);
}
}
}
}
}

View File

@@ -133,7 +133,7 @@
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<PropertyGroup>
<PostBuildEvent>copy "$(SolutionDir)data\lobby_config.ini" "$(SolutionDir)$(ProjectName)\$(OutDir)"</PostBuildEvent>
<PostBuildEvent>xcopy "$(SolutionDir)data\lobby_config.ini" "$(SolutionDir)$(ProjectName)\$(OutDir)" /y</PostBuildEvent>
</PropertyGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>

View File

@@ -25,8 +25,8 @@ namespace FFXIVClassic_Lobby_Server
bool startServer = true;
//Load Config
if (!ConfigConstants.Load())
startServer = false;
ConfigConstants.Load();
ConfigConstants.ApplyLaunchArgs(args);
//Test DB Connection
Program.Log.Info("Testing DB connection to \"{0}\"... ", ConfigConstants.DATABASE_HOST);
@@ -51,7 +51,7 @@ namespace FFXIVClassic_Lobby_Server
{
Server server = new Server();
server.StartServer();
while (true) Thread.Sleep(10000);
while (true) Thread.Sleep(10000);
}
Program.Log.Info("Press any key to continue...");