From c04680ea380cee52520f73311d11b571da9fbbbf Mon Sep 17 00:00:00 2001 From: dude22072 Date: Sun, 4 Dec 2016 03:02:15 +0000 Subject: [PATCH 1/4] characters.sql AUTO_INCREMENT --- sql/characters.sql | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/sql/characters.sql b/sql/characters.sql index 2f00e24f..99cf90ba 100644 --- a/sql/characters.sql +++ b/sql/characters.sql @@ -1,16 +1,16 @@ -/* -MySQL Data Transfer -Source Host: localhost -Source Database: ffxiv_server -Target Host: localhost -Target Database: ffxiv_server -Date: 12/3/2016 5:39:10 PM -*/ - -SET FOREIGN_KEY_CHECKS=0; --- ---------------------------- --- Table structure for characters --- ---------------------------- +/* +MySQL Data Transfer +Source Host: localhost +Source Database: ffxiv_server +Target Host: localhost +Target Database: ffxiv_server +Date: 12/3/2016 5:39:10 PM +*/ + +SET FOREIGN_KEY_CHECKS=0; +-- ---------------------------- +-- Table structure for characters +-- ---------------------------- CREATE TABLE `characters` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `userId` int(11) unsigned NOT NULL, @@ -45,4 +45,4 @@ CREATE TABLE `characters` ( `currentPartyGroupId` bigint(20) unsigned DEFAULT '0', `currentRetainerGroupId` bigint(20) unsigned DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB AUTO_INCREMENT=162 DEFAULT CHARSET=utf8; \ No newline at end of file +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; \ No newline at end of file From 7e535a9398a3ca0e1821e2a42d25a80d8c889b38 Mon Sep 17 00:00:00 2001 From: dude22072 Date: Sun, 4 Dec 2016 03:06:04 +0000 Subject: [PATCH 2/4] users.sql AUTO_INCREMENT --- sql/users.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/users.sql b/sql/users.sql index 35266275..73b58438 100644 --- a/sql/users.sql +++ b/sql/users.sql @@ -30,7 +30,7 @@ CREATE TABLE `users` ( `email` varchar(256) NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `name_UNIQUE` (`name`) -) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8; +) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; -- From 4a320d70964c653f12779ae3082d6786f833bc15 Mon Sep 17 00:00:00 2001 From: Tahir Akhlaq Date: Sun, 4 Dec 2016 21:41:34 +0000 Subject: [PATCH 3/4] 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 --- FFXIVClassic Lobby Server/ConfigConstants.cs | 33 +++++++++- .../FFXIVClassic Lobby Server.csproj | 2 +- FFXIVClassic Lobby Server/Program.cs | 6 +- FFXIVClassic Map Server/ConfigConstants.cs | 61 +++++++++++++++---- .../FFXIVClassic Map Server.csproj | 10 ++- FFXIVClassic Map Server/Program.cs | 4 +- FFXIVClassic Map Server/lua/LuaEngine.cs | 2 +- FFXIVClassic World Server/ConfigConstants.cs | 34 ++++++++++- .../FFXIVClassic World Server.csproj | 3 + FFXIVClassic World Server/Program.cs | 4 +- data/lobby_config.ini | 2 +- data/world_config.ini | 2 +- sql/characters.sql | 11 ++-- 13 files changed, 142 insertions(+), 32 deletions(-) diff --git a/FFXIVClassic Lobby Server/ConfigConstants.cs b/FFXIVClassic Lobby Server/ConfigConstants.cs index 358ceb96..501570e1 100644 --- a/FFXIVClassic Lobby Server/ConfigConstants.cs +++ b/FFXIVClassic Lobby Server/ConfigConstants.cs @@ -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); + } + } + } } } diff --git a/FFXIVClassic Lobby Server/FFXIVClassic Lobby Server.csproj b/FFXIVClassic Lobby Server/FFXIVClassic Lobby Server.csproj index a8c4fab3..962c3676 100644 --- a/FFXIVClassic Lobby Server/FFXIVClassic Lobby Server.csproj +++ b/FFXIVClassic Lobby Server/FFXIVClassic Lobby Server.csproj @@ -133,7 +133,7 @@ - copy "$(SolutionDir)data\lobby_config.ini" "$(SolutionDir)$(ProjectName)\$(OutDir)" + xcopy "$(SolutionDir)data\lobby_config.ini" "$(SolutionDir)$(ProjectName)\$(OutDir)" /y diff --git a/FFXIVClassic Lobby Server/Program.cs b/FFXIVClassic Lobby Server/Program.cs index 598397b5..f45ee786 100644 --- a/FFXIVClassic Lobby Server/Program.cs +++ b/FFXIVClassic Lobby Server/Program.cs @@ -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..."); diff --git a/FFXIVClassic Map Server/ConfigConstants.cs b/FFXIVClassic Map Server/ConfigConstants.cs index c3ea8d54..291d8a83 100644 --- a/FFXIVClassic Map Server/ConfigConstants.cs +++ b/FFXIVClassic Map Server/ConfigConstants.cs @@ -1,6 +1,11 @@ using FFXIVClassic.Common; using System; +using System.Collections.Generic; using System.IO; +using System.Net.Sockets; +using MoonSharp.Interpreter.Interop; +using System.Linq; +using System.Net; namespace FFXIVClassic_Map_Server { @@ -8,9 +13,9 @@ namespace FFXIVClassic_Map_Server { public static String OPTIONS_BINDIP; public static String OPTIONS_PORT; - public static bool OPTIONS_TIMESTAMP = false; + public static bool OPTIONS_TIMESTAMP = false; - public static uint DATABASE_WORLDID; + public static uint DATABASE_WORLDID; public static String DATABASE_HOST; public static String DATABASE_PORT; public static String DATABASE_NAME; @@ -24,23 +29,53 @@ namespace FFXIVClassic_Map_Server if (!File.Exists("./map_config.ini")) { Program.Log.Error("FILE NOT FOUND"); - return false; + Program.Log.Error("Loading defaults... "); } INIFile configIni = new INIFile("./map_config.ini"); - ConfigConstants.OPTIONS_BINDIP = configIni.GetValue("General", "server_ip", "127.0.0.1"); - ConfigConstants.OPTIONS_PORT = configIni.GetValue("General", "server_port", "1989"); - ConfigConstants.OPTIONS_TIMESTAMP = configIni.GetValue("General", "showtimestamp", "true").ToLower().Equals("true"); + ConfigConstants.OPTIONS_BINDIP = configIni.GetValue("General", "server_ip", "127.0.0.1"); + ConfigConstants.OPTIONS_PORT = configIni.GetValue("General", "server_port", "1989"); + ConfigConstants.OPTIONS_TIMESTAMP = configIni.GetValue("General", "showtimestamp", "true").ToLower().Equals("true"); + + ConfigConstants.DATABASE_WORLDID = UInt32.Parse(configIni.GetValue("Database", "worldid", "0")); + ConfigConstants.DATABASE_HOST = configIni.GetValue("Database", "host", ""); + ConfigConstants.DATABASE_PORT = configIni.GetValue("Database", "port", ""); + ConfigConstants.DATABASE_NAME = configIni.GetValue("Database", "database", ""); + ConfigConstants.DATABASE_USERNAME = configIni.GetValue("Database", "username", ""); + ConfigConstants.DATABASE_PASSWORD = configIni.GetValue("Database", "password", ""); - ConfigConstants.DATABASE_WORLDID = UInt32.Parse(configIni.GetValue("Database", "worldid", "0")); - ConfigConstants.DATABASE_HOST = configIni.GetValue("Database", "host", ""); - ConfigConstants.DATABASE_PORT = configIni.GetValue("Database", "port", ""); - ConfigConstants.DATABASE_NAME = configIni.GetValue("Database", "database", ""); - ConfigConstants.DATABASE_USERNAME = configIni.GetValue("Database", "username", ""); - ConfigConstants.DATABASE_PASSWORD = configIni.GetValue("Database", "password", ""); - 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); + } + } + } } } diff --git a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj index b6eaeae1..265be4c3 100644 --- a/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj +++ b/FFXIVClassic Map Server/FFXIVClassic Map Server.csproj @@ -35,6 +35,9 @@ 4 true + + Always + ..\packages\Cyotek.CircularBuffer.1.0.0.0\lib\net20\Cyotek.Collections.Generic.CircularBuffer.dll @@ -313,7 +316,12 @@ - copy "$(SolutionDir)data\map_config.ini" "$(SolutionDir)$(ProjectName)\$(OutDir)" + xcopy "$(SolutionDir)data\map_config.ini" "$(SolutionDir)$(ProjectName)\$(OutDir)" /d +xcopy "$(SolutionDir)data\scripts" "$(SolutionDir)$(ProjectName)\$(OutDir)scripts" /e /d /y /s + + + + diff --git a/FFXIVClassic Map Server/Program.cs b/FFXIVClassic Map Server/Program.cs index 921278a1..a06bed51 100644 --- a/FFXIVClassic Map Server/Program.cs +++ b/FFXIVClassic Map Server/Program.cs @@ -31,8 +31,8 @@ namespace FFXIVClassic_Map_Server Program.Log.Info("---------FFXIV 1.0 Map Server---------"); //Load Config - if (!ConfigConstants.Load()) - startServer = false; + ConfigConstants.Load(); + ConfigConstants.ApplyLaunchArgs(args); //Test DB Connection Program.Log.Info("Testing DB connection... "); diff --git a/FFXIVClassic Map Server/lua/LuaEngine.cs b/FFXIVClassic Map Server/lua/LuaEngine.cs index ddbae92a..0099c9dc 100644 --- a/FFXIVClassic Map Server/lua/LuaEngine.cs +++ b/FFXIVClassic Map Server/lua/LuaEngine.cs @@ -207,7 +207,7 @@ namespace FFXIVClassic_Map_Server.lua public static void RunGMCommand(Player player, String cmd, string[] param, bool help = false) { // load from scripts/commands/gm/ directory - var path = String.Format("./scripts/commands/gm/{0}.lua", cmd.ToString().ToLower()); + var path = String.Format("./scripts/commands/gm/{0}.lua", cmd.ToLower()); // check if the file exists if (File.Exists(path)) diff --git a/FFXIVClassic World Server/ConfigConstants.cs b/FFXIVClassic World Server/ConfigConstants.cs index 7f8b29aa..e5d9c5e5 100644 --- a/FFXIVClassic World Server/ConfigConstants.cs +++ b/FFXIVClassic World Server/ConfigConstants.cs @@ -1,6 +1,8 @@ using FFXIVClassic.Common; using System; using System.IO; +using System.Linq; +using System.Net; namespace FFXIVClassic_World_Server { @@ -23,7 +25,7 @@ namespace FFXIVClassic_World_Server if (!File.Exists("./world_config.ini")) { Program.Log.Error("FILE NOT FOUND!"); - return false; + Program.Log.Error("Loading defaults..."); } INIFile configIni = new INIFile("./world_config.ini"); @@ -40,5 +42,35 @@ namespace FFXIVClassic_World_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); + } + } + } } } diff --git a/FFXIVClassic World Server/FFXIVClassic World Server.csproj b/FFXIVClassic World Server/FFXIVClassic World Server.csproj index 75e58178..0cd97caa 100644 --- a/FFXIVClassic World Server/FFXIVClassic World Server.csproj +++ b/FFXIVClassic World Server/FFXIVClassic World Server.csproj @@ -102,6 +102,9 @@ + + xcopy "$(SolutionDir)data\world_config.ini" "$(SolutionDir)$(ProjectName)\$(OutDir)" /d +