From d3872ef0952f773dbcfcf69f68476a940214b839 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Thu, 25 Oct 2018 17:48:22 +1100 Subject: [PATCH] merge config files and update config calls --- bin/config/config.ini | 58 +++++++++++++++++++ bin/config/config.ini.default | 58 +++++++++++++++++++ bin/config/global.ini.default | 23 -------- bin/config/lobby.ini.default | 8 --- bin/config/rest.ini.default | 6 -- bin/config/zone.ini.default | 18 ------ src/common/Config/ConfigMgr.cpp | 55 +++++++++--------- src/common/Config/ConfigMgr.h | 24 ++++---- src/servers/sapphire_api/main.cpp | 52 ++++++++--------- src/servers/sapphire_lobby/GameConnection.cpp | 26 ++++----- src/servers/sapphire_lobby/ServerLobby.cpp | 14 ++--- .../sapphire_lobby/mainLobbyServer.cpp | 2 +- .../sapphire_zone/Actor/PlayerEvent.cpp | 2 +- .../sapphire_zone/Script/ScriptLoader.cpp | 2 +- .../sapphire_zone/Script/ScriptMgr.cpp | 6 +- src/servers/sapphire_zone/ServerZone.cpp | 20 +++---- src/servers/sapphire_zone/mainGameServer.cpp | 2 +- 17 files changed, 219 insertions(+), 157 deletions(-) create mode 100644 bin/config/config.ini create mode 100644 bin/config/config.ini.default delete mode 100644 bin/config/global.ini.default delete mode 100644 bin/config/lobby.ini.default delete mode 100644 bin/config/rest.ini.default delete mode 100644 bin/config/zone.ini.default diff --git a/bin/config/config.ini b/bin/config/config.ini new file mode 100644 index 00000000..3427d150 --- /dev/null +++ b/bin/config/config.ini @@ -0,0 +1,58 @@ +[Database] +Host = 127.0.0.1 +Port = 3306 +Database = sapphire +Username = root +Password = +SyncThreads = 2 +AsyncThreads = 2 + +[GlobalParameters] +ServerSecret = default +DataPath = /mnt/c/Program Files (x86)/Steam/steamapps/common/FINAL FANTASY XIV Online/game/sqpack + +[GlobalNetwork] +; Values definining how Users and other servers will access - these have to be set to your public IP when running a public server +ZoneHost = 127.0.0.1 +ZonePort = 54992 + +LobbyHost = 127.0.0.1 +LobbyPort = 54994 + +RestHost = 127.0.0.1 +RestPort = 80 + +[Lobby] +WorldID = 67 +AllowNoSessionConnect = false +WorldName = Sapphire + +[LobbyNetwork] +ListenIp = 0.0.0.0 +ListenPort = 54994 + +[CharacterCreation] +DefaultGMRank = 255 + +[RestNetwork] +ListenIp = 0.0.0.0 +ListenPort = 80 + +[Scripts] +; where compiled script modules are located +Path = ./compiledscripts/ +; relative to Path, where we copy and load modules from +CachePath = ./cache/ +; whether we should detect changes to script modules and reload them +HotSwap = true + +[Network] +DisconnectTimeout = 20 + +[ZoneNetwork] +ListenIp = 0.0.0.0 +ListenPort = 54992 + +[General] +; Sent on login - each line must be shorter than 307 characters, split lines with ';' +MotD = Welcome to Sapphire!;This is a very good server;You can change these messages by editing General.MotD in config/zone.ini \ No newline at end of file diff --git a/bin/config/config.ini.default b/bin/config/config.ini.default new file mode 100644 index 00000000..4c11b849 --- /dev/null +++ b/bin/config/config.ini.default @@ -0,0 +1,58 @@ +[Database] +Host = 127.0.0.1 +Port = 3306 +Database = sapphire +Username = sapphire +Password = +SyncThreads = 2 +AsyncThreads = 2 + +[GlobalParameters] +ServerSecret = default +DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack + +[GlobalNetwork] +; Values definining how Users and other servers will access - these have to be set to your public IP when running a public server +ZoneHost = 127.0.0.1 +ZonePort = 54992 + +LobbyHost = 127.0.0.1 +LobbyPort = 54994 + +RestHost = 127.0.0.1 +RestPort = 80 + +[Lobby] +WorldID = 67 +AllowNoSessionConnect = false +WorldName = Sapphire + +[LobbyNetwork] +ListenIp = 0.0.0.0 +ListenPort = 54994 + +[CharacterCreation] +DefaultGMRank = 255 + +[RestNetwork] +ListenIp = 0.0.0.0 +ListenPort = 80 + +[Scripts] +; where compiled script modules are located +Path = ./compiledscripts/ +; relative to Path, where we copy and load modules from +CachePath = ./cache/ +; whether we should detect changes to script modules and reload them +HotSwap = true + +[Network] +DisconnectTimeout = 20 + +[ZoneNetwork] +ListenIp = 0.0.0.0 +ListenPort = 54992 + +[General] +; Sent on login - each line must be shorter than 307 characters, split lines with ';' +MotD = Welcome to Sapphire!;This is a very good server;You can change these messages by editing General.MotD in config/zone.ini \ No newline at end of file diff --git a/bin/config/global.ini.default b/bin/config/global.ini.default deleted file mode 100644 index 072d3f7c..00000000 --- a/bin/config/global.ini.default +++ /dev/null @@ -1,23 +0,0 @@ -[Database] -Host = 127.0.0.1 -Port = 3306 -Database = sapphire -Username = root -Password = -SyncThreads = 2 -AsyncThreads = 2 - -[GlobalParameters] -ServerSecret = default -DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack - -[GlobalNetwork] -; Values definining how Users and other servers will access - these have to be set to your public IP when running a public server -ZoneHost = 127.0.0.1 -ZonePort = 54992 - -LobbyHost = 127.0.0.1 -LobbyPort = 54994 - -RestHost = 127.0.0.1 -RestPort = 80 \ No newline at end of file diff --git a/bin/config/lobby.ini.default b/bin/config/lobby.ini.default deleted file mode 100644 index 077e947c..00000000 --- a/bin/config/lobby.ini.default +++ /dev/null @@ -1,8 +0,0 @@ -[Lobby] -WorldID = 67 -AllowNoSessionConnect = false -WorldName = Sapphire - -[LobbyNetwork] -ListenIp = 0.0.0.0 -ListenPort = 54994 \ No newline at end of file diff --git a/bin/config/rest.ini.default b/bin/config/rest.ini.default deleted file mode 100644 index d51b4967..00000000 --- a/bin/config/rest.ini.default +++ /dev/null @@ -1,6 +0,0 @@ -[CharacterCreation] -DefaultGMRank = 255 - -[RestNetwork] -ListenIp = 0.0.0.0 -ListenPort = 80 \ No newline at end of file diff --git a/bin/config/zone.ini.default b/bin/config/zone.ini.default deleted file mode 100644 index 7631e9eb..00000000 --- a/bin/config/zone.ini.default +++ /dev/null @@ -1,18 +0,0 @@ -[Scripts] -; where compiled script modules are located -Path = ./compiledscripts/ -; relative to Path, where we copy and load modules from -CachePath = ./cache/ -; whether we should detect changes to script modules and reload them -HotSwap = true - -[Network] -DisconnectTimeout = 20 - -[ZoneNetwork] -ListenIp = 0.0.0.0 -ListenPort = 54992 - -[General] -; Sent on login - each line must be shorter than 307 characters, split lines with ';' -MotD = Welcome to Sapphire!;This is a very good server;You can change these messages by editing General.MotD in config/zone.ini \ No newline at end of file diff --git a/src/common/Config/ConfigMgr.cpp b/src/common/Config/ConfigMgr.cpp index c60c226e..437ee943 100644 --- a/src/common/Config/ConfigMgr.cpp +++ b/src/common/Config/ConfigMgr.cpp @@ -10,43 +10,44 @@ */ bool Core::ConfigMgr::loadConfig( const std::string& configName ) { - std::stringstream configStream; + // std::stringstream configStream; // get global config auto configDir = std::experimental::filesystem::path( m_configFolderRoot ); - if( !std::experimental::filesystem::exists( configDir ) ) - { - return false; - } + // if( !std::experimental::filesystem::exists( configDir ) ) + // { + // return false; + // } - auto globalConfig = std::experimental::filesystem::path( configDir / m_globalConfigFile ); - if( !std::experimental::filesystem::exists( globalConfig ) ) - { - if( !copyDefaultConfig( globalConfig.filename().string() ) ) - return false; - } + // auto globalConfig = std::experimental::filesystem::path( configDir / m_globalConfigFile ); + // if( !std::experimental::filesystem::exists( globalConfig ) ) + // { + // if( !copyDefaultConfig( globalConfig.filename().string() ) ) + // return false; + // } - std::ifstream globalConfigFile( globalConfig.c_str() ); - configStream << globalConfigFile.rdbuf(); + // std::ifstream globalConfigFile( globalConfig.c_str() ); + // configStream << globalConfigFile.rdbuf(); - // add some newlines just in case there's no newline at the end of the global file - configStream << "\n\n"; + // // add some newlines just in case there's no newline at the end of the global file + // configStream << "\n\n"; - // get local config - auto localConfig = std::experimental::filesystem::path( configDir / configName ); - if( !std::experimental::filesystem::exists( localConfig ) ) - { - if( !copyDefaultConfig( localConfig.filename().string() ) ) - return false; - } - std::ifstream configFile( localConfig.c_str() ); - configStream << configFile.rdbuf(); + // // get local config + // auto localConfig = ; + // if( !std::experimental::filesystem::exists( localConfig ) ) + // { + // if( !copyDefaultConfig( localConfig.filename().string() ) ) + // return false; + // } + // std::ifstream configFile( localConfig.c_str() ); + // configStream << configFile.rdbuf(); - // parse the trxee and we're fuckin done - //boost::property_tree::read_ini( configStream, m_propTree ); + // // parse the trxee and we're fuckin done + // //boost::property_tree::read_ini( configStream, m_propTree ); - m_pInih = std::unique_ptr< INIReader >( new INIReader( localConfig ) ); + m_pInih = std::unique_ptr< INIReader >( new INIReader( + std::experimental::filesystem::path( configDir / configName ) ) ); if( m_pInih->ParseError() < 0 ) return false; diff --git a/src/common/Config/ConfigMgr.h b/src/common/Config/ConfigMgr.h index c0561126..eec0625a 100644 --- a/src/common/Config/ConfigMgr.h +++ b/src/common/Config/ConfigMgr.h @@ -20,30 +20,30 @@ public: template struct always_false : std::false_type {}; template< class T > - T getValue( const std::string& name, T defaultValue = T() ) + T getValue( const std::string& section, const std::string& name, T defaultValue = T() ) { if constexpr (std::is_same_v) - return m_pInih->GetInteger( "", name, defaultValue ); + return m_pInih->GetInteger( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->GetInteger( "", name, defaultValue ); + return m_pInih->GetInteger( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->GetInteger( "", name, defaultValue ); + return m_pInih->GetInteger( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->GetInteger( "", name, defaultValue ); + return m_pInih->GetInteger( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->GetInteger( "", name, defaultValue ); + return m_pInih->GetInteger( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->GetInteger( "", name, defaultValue ); + return m_pInih->GetInteger( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->GetInteger( "", name, defaultValue ); + return m_pInih->GetInteger( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->GetReal( "", name, defaultValue ); + return m_pInih->GetReal( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->GetReal( "", name, defaultValue ); + return m_pInih->GetReal( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->Get( "", name, defaultValue ); + return m_pInih->Get( section, name, defaultValue ); else if constexpr (std::is_same_v) - return m_pInih->GetBoolean( "", name, defaultValue ); + return m_pInih->GetBoolean( section, name, defaultValue ); else static_assert(always_false::value, "non-exhaustive getter!"); } diff --git a/src/servers/sapphire_api/main.cpp b/src/servers/sapphire_api/main.cpp index 1d552f58..ea06f167 100644 --- a/src/servers/sapphire_api/main.cpp +++ b/src/servers/sapphire_api/main.cpp @@ -55,7 +55,7 @@ void default_resource_send( const HttpServer& server, const shared_ptr< HttpServ auto m_pConfig = std::make_shared< Core::ConfigMgr >(); HttpServer server; -std::string configPath( "rest.ini" ); +std::string configPath( "config.ini" ); void reloadConfig() { @@ -143,7 +143,7 @@ bool loadSettings( int32_t argc, char* argv[] ) } g_log.info( "Setting up generated EXD data" ); - if( !g_exdDataGen.init( m_pConfig->getValue< std::string >( "GlobalParameters.DataPath", "" ) ) ) + if( !g_exdDataGen.init( m_pConfig->getValue< std::string >( "GlobalParameters", "DataPath", "" ) ) ) { g_log.fatal( "Error setting up generated EXD data " ); return false; @@ -152,21 +152,21 @@ bool loadSettings( int32_t argc, char* argv[] ) Core::Db::DbLoader loader; Core::Db::ConnectionInfo info; - info.password = m_pConfig->getValue< std::string >( "Database.Password", "" ); - info.host = m_pConfig->getValue< std::string >( "Database.Host", "127.0.0.1" ); - info.database = m_pConfig->getValue< std::string >( "Database.Database", "sapphire" ); - info.port = m_pConfig->getValue< uint16_t >( "Database.Port", 3306 ); - info.user = m_pConfig->getValue< std::string >( "Database.Username", "root" ); - info.syncThreads = m_pConfig->getValue< uint8_t >( "Database.SyncThreads", 2 ); - info.asyncThreads = m_pConfig->getValue< uint8_t >( "Database.AsyncThreads", 2 ); + info.password = m_pConfig->getValue< std::string >( "Database", "Password", "" ); + info.host = m_pConfig->getValue< std::string >( "Database", "Host", "127.0.0.1" ); + info.database = m_pConfig->getValue< std::string >( "Database", "Database", "sapphire" ); + info.port = m_pConfig->getValue< uint16_t >( "Database", "Port", 3306 ); + info.user = m_pConfig->getValue< std::string >( "Database", "Username", "root" ); + info.syncThreads = m_pConfig->getValue< uint8_t >( "Database", "SyncThreads", 2 ); + info.asyncThreads = m_pConfig->getValue< uint8_t >( "Database", "AsyncThreads", 2 ); loader.addDb( g_charaDb, info ); if( !loader.initDbs() ) return false; server.config.port = static_cast< uint16_t >( std::stoul( - m_pConfig->getValue< std::string >( "RestNetwork.ListenPort", "80" ) ) ); - server.config.address = m_pConfig->getValue< std::string >( "RestNetwork.ListenIp", "0.0.0.0" ); + m_pConfig->getValue< std::string >( "RestNetwork", "ListenPort", "80" ) ) ); + server.config.address = m_pConfig->getValue< std::string >( "RestNetwork", "ListenIp", "0.0.0.0" ); g_log.info( "Database: Connected to " + info.host + ":" + std::to_string( info.port ) ); @@ -270,9 +270,9 @@ void createAccount( shared_ptr< HttpServer::Response > response, shared_ptr< Htt { std::string json_string = "{\"sId\":\"" + sId + "\", \"lobbyHost\":\"" + - m_pConfig->getValue< std::string >( "GlobalNetwork.LobbyHost" ) + + m_pConfig->getValue< std::string >( "GlobalNetwork", "LobbyHost" ) + "\", \"frontierHost\":\"" + - m_pConfig->getValue< std::string >( "GlobalNetwork.RestHost" ) + "\"}"; + m_pConfig->getValue< std::string >( "GlobalNetwork", "RestHost" ) + "\"}"; *response << buildHttpResponse( 200, json_string, JSON ); } else @@ -304,9 +304,9 @@ void login( shared_ptr< HttpServer::Response > response, shared_ptr< HttpServer: { std::string json_string = "{\"sId\":\"" + sId + "\", \"lobbyHost\":\"" + - m_pConfig->getValue< std::string >( "GlobalNetwork.LobbyHost" ) + + m_pConfig->getValue< std::string >( "GlobalNetwork", "LobbyHost" ) + "\", \"frontierHost\":\"" + - m_pConfig->getValue< std::string >( "GlobalNetwork.RestHost" ) + "\"}"; + m_pConfig->getValue< std::string >( "GlobalNetwork", "RestHost" ) + "\"}"; *response << buildHttpResponse( 200, json_string, JSON ); } else @@ -337,7 +337,7 @@ void deleteCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H int32_t accountId = g_sapphireAPI.checkSession( sId ); - if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret ) + if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << buildHttpResponse( 403, json_string, JSON ); @@ -378,7 +378,7 @@ void createCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H if( result != -1 ) { - if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret ) + if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << buildHttpResponse( 403, json_string, JSON ); @@ -386,7 +386,7 @@ void createCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H else { int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson, m_pConfig->getValue< uint8_t >( - "CharacterCreation.DefaultGMRank", 255 ) ); + "CharacterCreation", "DefaultGMRank", 255 ) ); std::string json_string = "{\"result\":\"" + std::to_string( charId ) + "\"}"; *response << buildHttpResponse( 200, json_string, JSON ); @@ -419,7 +419,7 @@ void insertSession( shared_ptr< HttpServer::Response > response, shared_ptr< Htt uint32_t accountId = pt.get< uint32_t >( "accountId" ); std::string secret = pt.get< string >( "secret" ); // reloadConfig(); - if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret ) + if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << buildHttpResponse( 403, json_string, JSON ); @@ -453,7 +453,7 @@ void checkNameTaken( shared_ptr< HttpServer::Response > response, shared_ptr< Ht // reloadConfig(); - if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret ) + if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << buildHttpResponse( 403, json_string, JSON ); @@ -491,7 +491,7 @@ void checkSession( shared_ptr< HttpServer::Response > response, shared_ptr< Http if( result != -1 ) { - if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret ) + if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << buildHttpResponse( 403, json_string, JSON ); @@ -528,7 +528,7 @@ void getNextCharId( shared_ptr< HttpServer::Response > response, shared_ptr< Htt // reloadConfig(); - if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret ) + if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << buildHttpResponse( 403, json_string, JSON ); @@ -560,7 +560,7 @@ void getNextContentId( shared_ptr< HttpServer::Response > response, shared_ptr< // reloadConfig(); - if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret ) + if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << buildHttpResponse( 403, json_string, JSON ); @@ -596,7 +596,7 @@ void getCharacterList( shared_ptr< HttpServer::Response > response, shared_ptr< if( result != -1 ) { - if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret ) + if( m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ) != secret ) { std::string json_string = "{\"result\":\"invalid_secret\"}"; *response << buildHttpResponse( 403, json_string, JSON ); @@ -783,8 +783,8 @@ int main( int argc, char* argv[] ) server.start(); } ); - g_log.info( "API server running on " + m_pConfig->getValue< std::string >( "RestNetwork.ListenIp", "0.0.0.0" ) + ":" + - m_pConfig->getValue< std::string >( "RestNetwork.ListenPort", "80" ) ); + g_log.info( "API server running on " + m_pConfig->getValue< std::string >( "RestNetwork", "ListenIp", "0.0.0.0" ) + ":" + + m_pConfig->getValue< std::string >( "RestNetwork", "ListenPort", "80" ) ); //Wait for server to start so that the client can connect this_thread::sleep_for( chrono::seconds( 1 ) ); diff --git a/src/servers/sapphire_lobby/GameConnection.cpp b/src/servers/sapphire_lobby/GameConnection.cpp index e3f183d6..e143b3dc 100644 --- a/src/servers/sapphire_lobby/GameConnection.cpp +++ b/src/servers/sapphire_lobby/GameConnection.cpp @@ -126,11 +126,11 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui serverListPacket->data().seq = 1; serverListPacket->data().offset = 0; serverListPacket->data().numServers = 1; - serverListPacket->data().server[ 0 ].id = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby.WorldID", 1 ); + serverListPacket->data().server[ 0 ].id = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby", "WorldID", 1 ); serverListPacket->data().server[ 0 ].index = 0; serverListPacket->data().final = 1; strcpy( serverListPacket->data().server[ 0 ].name, - g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() ); + g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() ); pRP.addPacket( serverListPacket ); auto retainerListPacket = makeLobbyPacket< FFXIVIpcRetainerList >( tmpId ); @@ -160,15 +160,15 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui auto& charEntry = charList[ charIndex ]; details.uniqueId = std::get< 1 >( charEntry ); details.contentId = std::get< 2 >( charEntry ); - details.serverId = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby.WorldID", 1 ); - details.serverId1 = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby.WorldID", 1 ); + details.serverId = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby", "WorldID", 1 ); + details.serverId1 = g_serverLobby.getConfig()->getValue< uint16_t >( "Lobby", "WorldID", 1 ); details.index = charIndex; strcpy( details.charDetailJson, std::get< 3 >( charEntry ).c_str() ); strcpy( details.nameChara, std::get< 0 >( charEntry ).c_str() ); strcpy( details.nameServer, - g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() ); + g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() ); strcpy( details.nameServer1, - g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() ); + g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() ); charListPacket->data().charaDetails[ j ] = details; @@ -235,8 +235,8 @@ void Core::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet, uin enterWorldPacket->data().contentId = lookupId; enterWorldPacket->data().seq = sequence; strcpy( enterWorldPacket->data().host, - g_serverLobby.getConfig()->getValue< std::string >( "GlobalNetwork.ZoneHost" ).c_str() ); - enterWorldPacket->data().port = g_serverLobby.getConfig()->getValue< uint16_t >( "GlobalNetwork.ZonePort" ); + g_serverLobby.getConfig()->getValue< std::string >( "GlobalNetwork", "ZoneHost" ).c_str() ); + enterWorldPacket->data().port = g_serverLobby.getConfig()->getValue< uint16_t >( "GlobalNetwork", "ZonePort" ); enterWorldPacket->data().charId = logInCharId; memcpy( enterWorldPacket->data().sid, m_pSession->getSessionId(), 66 ); pRP.addPacket( enterWorldPacket ); @@ -247,7 +247,7 @@ bool Core::Network::GameConnection::sendServiceAccountList( FFXIVARR_PACKET_RAW& { LobbySessionPtr pSession = g_serverLobby.getSession( ( char* ) &packet.data[ 0 ] + 0x20 ); - if( g_serverLobby.getConfig()->getValue< bool >( "Lobby.AllowNoSessionConnect" ) && pSession == nullptr ) + if( g_serverLobby.getConfig()->getValue< bool >( "Lobby", "AllowNoSessionConnect" ) && pSession == nullptr ) { auto session = make_LobbySession(); session->setAccountID( 0 ); @@ -318,7 +318,7 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac charCreatePacket->data().content_id = newContentId; strcpy( charCreatePacket->data().name, name.c_str() ); strcpy( charCreatePacket->data().world, - g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() ); + g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() ); charCreatePacket->data().type = 1; charCreatePacket->data().seq = sequence; charCreatePacket->data().unknown = 1; @@ -342,9 +342,9 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac charCreatePacket->data().content_id = newContentId; strcpy( charCreatePacket->data().name, name.c_str() ); strcpy( charCreatePacket->data().world, - g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() ); + g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() ); strcpy( charCreatePacket->data().world2, - g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() ); + g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() ); charCreatePacket->data().type = 2; charCreatePacket->data().seq = sequence; charCreatePacket->data().unknown = 1; @@ -373,7 +373,7 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac charCreatePacket->data().content_id = 0; strcpy( charCreatePacket->data().name, name.c_str() ); strcpy( charCreatePacket->data().world, - g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() ); + g_serverLobby.getConfig()->getValue< std::string >( "Lobby", "WorldName", "Sapphire" ).c_str() ); charCreatePacket->data().type = 4; charCreatePacket->data().seq = sequence; charCreatePacket->data().unknown = 1; diff --git a/src/servers/sapphire_lobby/ServerLobby.cpp b/src/servers/sapphire_lobby/ServerLobby.cpp index 119c99d9..6eb2979d 100644 --- a/src/servers/sapphire_lobby/ServerLobby.cpp +++ b/src/servers/sapphire_lobby/ServerLobby.cpp @@ -73,8 +73,8 @@ void ServerLobby::run( int32_t argc, char* argv[] ) Network::addServerToHive< Network::GameConnection >( m_ip, m_port, hive ); g_log.info( - "Lobby server running on " + m_pConfig->getValue< std::string >( "LobbyNetwork.ListenIp", "0.0.0.0" ) + ":" + - m_pConfig->getValue< std::string >( "LobbyNetwork.ListenPort", "80" ) ); + "Lobby server running on " + m_pConfig->getValue< std::string >( "LobbyNetwork", "ListenIp", "0.0.0.0" ) + ":" + + m_pConfig->getValue< std::string >( "LobbyNetwork", "ListenPort", "80" ) ); boost::thread_group worker_threads; worker_threads.create_thread( boost::bind( &Network::Hive::Run, hive.get() ) ); @@ -130,12 +130,12 @@ bool ServerLobby::loadSettings( int32_t argc, char* argv[] ) } } - m_port = m_pConfig->getValue< uint16_t >( "LobbyNetwork.ListenPort", 54994 ); - m_ip = m_pConfig->getValue< std::string >( "LobbyNetwork.ListenIp", "0.0.0.0" ); + m_port = m_pConfig->getValue< uint16_t >( "LobbyNetwork", "ListenPort", 54994 ); + m_ip = m_pConfig->getValue< std::string >( "LobbyNetwork", "ListenIp", "0.0.0.0" ); - g_restConnector.restHost = m_pConfig->getValue< std::string >( "GlobalNetwork.RestHost" ) + ":" + - m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort" ); - g_restConnector.serverSecret = m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ); + g_restConnector.restHost = m_pConfig->getValue< std::string >( "GlobalNetwork", "RestHost" ) + ":" + + m_pConfig->getValue< std::string >( "GlobalNetwork", "RestPort" ); + g_restConnector.serverSecret = m_pConfig->getValue< std::string >( "GlobalParameters", "ServerSecret" ); return true; } diff --git a/src/servers/sapphire_lobby/mainLobbyServer.cpp b/src/servers/sapphire_lobby/mainLobbyServer.cpp index 07997917..16abe4d6 100644 --- a/src/servers/sapphire_lobby/mainLobbyServer.cpp +++ b/src/servers/sapphire_lobby/mainLobbyServer.cpp @@ -1,6 +1,6 @@ #include "ServerLobby.h" -Core::ServerLobby g_serverLobby( "lobby.ini" ); +Core::ServerLobby g_serverLobby( "config.ini" ); int main( int32_t argc, char* argv[] ) { diff --git a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp index d113fe5d..6ce9dd2d 100644 --- a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp @@ -333,7 +333,7 @@ void Core::Entity::Player::eventItemActionStart( uint32_t eventId, void Core::Entity::Player::onLogin() { auto pConfig = g_fw.get< ConfigMgr >(); - auto motd = pConfig->getValue< std::string >( "General.MotD", "" ); + auto motd = pConfig->getValue< std::string >( "General", "MotD", "" ); std::istringstream ss( motd ); std::string msg; diff --git a/src/servers/sapphire_zone/Script/ScriptLoader.cpp b/src/servers/sapphire_zone/Script/ScriptLoader.cpp index 35cc7fb9..68799d5a 100644 --- a/src/servers/sapphire_zone/Script/ScriptLoader.cpp +++ b/src/servers/sapphire_zone/Script/ScriptLoader.cpp @@ -61,7 +61,7 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st } // copy to temp dir - fs::path cacheDir( f.parent_path() /= pConfig->getValue< std::string >( "Scripts.CachePath", "./cache/" ) ); + fs::path cacheDir( f.parent_path() /= pConfig->getValue< std::string >( "Scripts", "CachePath", "./cache/" ) ); fs::create_directories( cacheDir ); fs::path dest( cacheDir /= f.filename().string() ); diff --git a/src/servers/sapphire_zone/Script/ScriptMgr.cpp b/src/servers/sapphire_zone/Script/ScriptMgr.cpp index e46160cb..cf72171d 100644 --- a/src/servers/sapphire_zone/Script/ScriptMgr.cpp +++ b/src/servers/sapphire_zone/Script/ScriptMgr.cpp @@ -56,7 +56,7 @@ bool Core::Scripting::ScriptMgr::init() auto pConfig = g_fw.get< ConfigMgr >(); auto pLog = g_fw.get< Logger >(); - auto status = loadDir( pConfig->getValue< std::string >( "Scripts.Path", "./compiledscripts/" ), + auto status = loadDir( pConfig->getValue< std::string >( "Scripts", "Path", "./compiledscripts/" ), files, m_nativeScriptMgr->getModuleExtension() ); if( !status ) @@ -90,11 +90,11 @@ bool Core::Scripting::ScriptMgr::init() void Core::Scripting::ScriptMgr::watchDirectories() { auto pConfig = g_fw.get< ConfigMgr >(); - auto shouldWatch = pConfig->getValue< bool >( "Scripts.HotSwap", true ); + auto shouldWatch = pConfig->getValue< bool >( "Scripts", "HotSwap", true ); if( !shouldWatch ) return; - Watchdog::watchMany( pConfig->getValue< std::string >( "Scripts.Path", "./compiledscripts/" ) + "*" + + Watchdog::watchMany( pConfig->getValue< std::string >( "Scripts", "Path", "./compiledscripts/" ) + "*" + m_nativeScriptMgr->getModuleExtension(), [ this ]( const std::vector< ci::fs::path >& paths ) { diff --git a/src/servers/sapphire_zone/ServerZone.cpp b/src/servers/sapphire_zone/ServerZone.cpp index 37443b39..fcb60c51 100644 --- a/src/servers/sapphire_zone/ServerZone.cpp +++ b/src/servers/sapphire_zone/ServerZone.cpp @@ -124,7 +124,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] ) } pLog->info( "Setting up generated EXD data" ); - if( !pExd->init( pConfig->getValue< std::string >( "GlobalParameters.DataPath", "" ) ) ) + if( !pExd->init( pConfig->getValue< std::string >( "GlobalParameters", "DataPath", "" ) ) ) { pLog->fatal( "Error setting up generated EXD data " ); return false; @@ -133,20 +133,20 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] ) Core::Db::DbLoader loader; Core::Db::ConnectionInfo info; - info.password = pConfig->getValue< std::string >( "Database.Password", "" ); - info.host = pConfig->getValue< std::string >( "Database.Host", "127.0.0.1" ); - info.database = pConfig->getValue< std::string >( "Database.Database", "sapphire" ); - info.port = pConfig->getValue< uint16_t >( "Database.Port", 3306 ); - info.user = pConfig->getValue< std::string >( "Database.Username", "root" ); - info.syncThreads = pConfig->getValue< uint8_t >( "Database.SyncThreads", 2 ); - info.asyncThreads = pConfig->getValue< uint8_t >( "Database.AsyncThreads", 2 ); + info.password = pConfig->getValue< std::string >( "Database", "Password", "" ); + info.host = pConfig->getValue< std::string >( "Database", "Host", "127.0.0.1" ); + info.database = pConfig->getValue< std::string >( "Database", "Database", "sapphire" ); + info.port = pConfig->getValue< uint16_t >( "Database", "Port", 3306 ); + info.user = pConfig->getValue< std::string >( "Database", "Username", "root" ); + info.syncThreads = pConfig->getValue< uint8_t >( "Database", "SyncThreads", 2 ); + info.asyncThreads = pConfig->getValue< uint8_t >( "Database", "AsyncThreads", 2 ); loader.addDb( *pDb, info ); if( !loader.initDbs() ) return false; - m_port = pConfig->getValue< uint16_t >( "ZoneNetwork.ListenPort", 54992 ); - m_ip = pConfig->getValue< std::string >( "ZoneNetwork.ListenIp", "0.0.0.0" ); + m_port = pConfig->getValue< uint16_t >( "ZoneNetwork", "ListenPort", 54992 ); + m_ip = pConfig->getValue< std::string >( "ZoneNetwork", "ListenIp", "0.0.0.0" ); return true; } diff --git a/src/servers/sapphire_zone/mainGameServer.cpp b/src/servers/sapphire_zone/mainGameServer.cpp index a06a801f..b45e71b0 100644 --- a/src/servers/sapphire_zone/mainGameServer.cpp +++ b/src/servers/sapphire_zone/mainGameServer.cpp @@ -19,7 +19,7 @@ using namespace Core; bool setupFramework() { - auto pServer = std::make_shared< ServerZone >( "zone.ini" ); + auto pServer = std::make_shared< ServerZone >( "config.ini" ); auto pLogger = std::make_shared< Logger >(); auto pExdData = std::make_shared< Data::ExdDataGenerated >(); auto pScript = std::make_shared< Scripting::ScriptMgr >();