mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-26 06:27:45 +00:00
remove old XMLConfig completely and implement new ConfigMgr
This commit is contained in:
parent
86cdd21d6f
commit
463d56e76e
17 changed files with 116 additions and 233 deletions
|
@ -1,34 +0,0 @@
|
||||||
<Settings>
|
|
||||||
<General>
|
|
||||||
<!-- Port the lobby server accepts client connections on -->
|
|
||||||
<ListenPort>54994</ListenPort>
|
|
||||||
<AuthPort>54998</AuthPort>
|
|
||||||
<!-- Ip the lobby server listens on -->
|
|
||||||
<ListenIp>127.0.0.1</ListenIp>
|
|
||||||
<!-- IP of the world server -->
|
|
||||||
<ZoneIp>127.0.0.1</ZoneIp>
|
|
||||||
<!-- Port the world server listens for clients -->
|
|
||||||
<ZonePort>54992</ZonePort>
|
|
||||||
<!-- Address to connect to the rest server -->
|
|
||||||
<RestHost>127.0.0.1:80</RestHost>
|
|
||||||
<!-- Secret for server authentication -->
|
|
||||||
<ServerSecret>default</ServerSecret>
|
|
||||||
<!-- Connection settings for the mysql db -->
|
|
||||||
<Mysql>
|
|
||||||
<Host>127.0.0.1</Host>
|
|
||||||
<Port>3306</Port>
|
|
||||||
<Username>root</Username>
|
|
||||||
<Pass></Pass>
|
|
||||||
<Database>sapphire</Database>
|
|
||||||
</Mysql>
|
|
||||||
</General>
|
|
||||||
<Parameters>
|
|
||||||
<!-- Do not disconnect players without a session - this should be definitely disabled unless you are testing on a PS4 -->
|
|
||||||
<AllowNoSessionConnect>false</AllowNoSessionConnect>
|
|
||||||
<!-- The ID of the Sapphire world - this is what the game determines your datacenter with, check world.exh -->
|
|
||||||
<WorldID>67</WorldID>
|
|
||||||
<!-- The name of the world -->
|
|
||||||
<!-- TODO: Allow multiple world servers -->
|
|
||||||
<WorldName>Sapphire</WorldName>
|
|
||||||
</Parameters>
|
|
||||||
</Settings>
|
|
|
@ -1,32 +0,0 @@
|
||||||
<Settings>
|
|
||||||
<General>
|
|
||||||
<!-- Port the lobby server accepts client connections on -->
|
|
||||||
<ListenPort>54994</ListenPort>
|
|
||||||
<AuthPort>54998</AuthPort>
|
|
||||||
<!-- Ip the lobby server listens on -->
|
|
||||||
<ListenIp>127.0.0.1</ListenIp>
|
|
||||||
<!-- Path of FFXIV dat files -->
|
|
||||||
<DataPath>C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack</DataPath>
|
|
||||||
<!-- <DataPath>/opt/sapphire_3_15_0/bin/sqpack</DataPath> -->
|
|
||||||
<!-- IP of the lobby server -->
|
|
||||||
<LobbyHost>127.0.0.1</LobbyHost>
|
|
||||||
<!-- IP of the frontier server -->
|
|
||||||
<FrontierHost>127.0.0.1</FrontierHost>
|
|
||||||
<!-- Secret used for server auth - you *must* change this for public servers -->
|
|
||||||
<ServerSecret>default</ServerSecret>
|
|
||||||
<!-- Web server port -->
|
|
||||||
<HttpPort>80</HttpPort>
|
|
||||||
<Mysql>
|
|
||||||
<Host>127.0.0.1</Host>
|
|
||||||
<Port>3306</Port>
|
|
||||||
<Username>root</Username>
|
|
||||||
<Pass></Pass>
|
|
||||||
<Database>sapphire</Database>
|
|
||||||
</Mysql>
|
|
||||||
</General>
|
|
||||||
|
|
||||||
<Parameters>
|
|
||||||
<!-- GM Rank for newly created characters - should be changed to 0 for public servers -->
|
|
||||||
<DefaultGMRank>255</DefaultGMRank>
|
|
||||||
</Parameters>
|
|
||||||
</Settings>
|
|
|
@ -1,45 +0,0 @@
|
||||||
<Settings>
|
|
||||||
<General>
|
|
||||||
<!-- Port the zone server accepts game conenctions on -->
|
|
||||||
<ListenPort>54992</ListenPort>
|
|
||||||
<!-- Ip the zone server conenctions on -->
|
|
||||||
<ListenIp>127.0.0.1</ListenIp>
|
|
||||||
<!-- Path of FFXIV dat files -->
|
|
||||||
<DataPath>C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack</DataPath>
|
|
||||||
|
|
||||||
<Scripts>
|
|
||||||
<!-- where compiled scripts are placed -->
|
|
||||||
<Path>./compiledscripts/</Path>
|
|
||||||
<CachePath>./cache/</CachePath>
|
|
||||||
|
|
||||||
<HotSwap>
|
|
||||||
<Enabled>true</Enabled>
|
|
||||||
<ScriptsDir>../scripts/native/</ScriptsDir>
|
|
||||||
<BuildDir>../cmake-build-debug/</BuildDir>
|
|
||||||
<BuildCmd>cmake --build %1% --target %2%</BuildCmd>
|
|
||||||
</HotSwap>
|
|
||||||
</Scripts>
|
|
||||||
|
|
||||||
<!-- Path of Chai script files -->
|
|
||||||
<ScriptPath>./compiledscripts/</ScriptPath>
|
|
||||||
<!-- Connection settings for the mysql db -->
|
|
||||||
<Mysql>
|
|
||||||
<Host>127.0.0.1</Host>
|
|
||||||
<Port>3306</Port>
|
|
||||||
<Username>root</Username>
|
|
||||||
<Pass></Pass>
|
|
||||||
<Database>sapphire</Database>
|
|
||||||
<SyncThreads>2</SyncThreads>
|
|
||||||
<AsyncThreads>2</AsyncThreads>
|
|
||||||
</Mysql>
|
|
||||||
</General>
|
|
||||||
|
|
||||||
<Parameters>
|
|
||||||
<!-- Messages players see upon logging in - These *must* be smaller than 307 characters -->
|
|
||||||
<MotDArray>
|
|
||||||
<MotD><<<Welcome to Sapphire>>></MotD>
|
|
||||||
<MotD>This is a very good server</MotD>
|
|
||||||
<MotD>You can change these messages by editing MotDArray in config/settings_zone.xml</MotD>
|
|
||||||
</MotDArray>
|
|
||||||
</Parameters>
|
|
||||||
</Settings>
|
|
|
@ -6,9 +6,9 @@
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
|
||||||
class XMLConfig;
|
class ConfigMgr;
|
||||||
|
|
||||||
typedef boost::shared_ptr<XMLConfig> XMLConfigPtr;
|
typedef boost::shared_ptr<ConfigMgr> ConfigMgrPtr;
|
||||||
|
|
||||||
|
|
||||||
namespace Network
|
namespace Network
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
|
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
#include <Config/XMLConfig.h>
|
#include <Config/ConfigMgr.h>
|
||||||
|
|
||||||
#include <Network/Connection.h>
|
#include <Network/Connection.h>
|
||||||
#include <Network/Hive.h>
|
#include <Network/Hive.h>
|
||||||
|
@ -52,13 +52,13 @@ void default_resource_send( const HttpServer &server, const shared_ptr< HttpServ
|
||||||
const shared_ptr< ifstream > &ifs );
|
const shared_ptr< ifstream > &ifs );
|
||||||
|
|
||||||
|
|
||||||
auto m_pConfig = boost::make_shared< Core::XMLConfig >();
|
auto m_pConfig = boost::make_shared< Core::ConfigMgr >();
|
||||||
HttpServer server;
|
HttpServer server;
|
||||||
std::string configPath( "config/settings_rest.xml" );
|
std::string configPath( "rest.ini" );
|
||||||
|
|
||||||
void reloadConfig()
|
void reloadConfig()
|
||||||
{
|
{
|
||||||
m_pConfig = boost::make_shared< Core::XMLConfig >();
|
m_pConfig = boost::make_shared< Core::ConfigMgr >();
|
||||||
|
|
||||||
if( !m_pConfig->loadConfig( configPath ) )
|
if( !m_pConfig->loadConfig( configPath ) )
|
||||||
throw "Error loading config ";
|
throw "Error loading config ";
|
||||||
|
@ -96,43 +96,43 @@ bool loadSettings( int32_t argc, char* argv[] )
|
||||||
if( arg == "ip" )
|
if( arg == "ip" )
|
||||||
{
|
{
|
||||||
// todo: ip addr in config
|
// todo: ip addr in config
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.ListenIP", val );
|
m_pConfig->setValue< std::string >( "GlobalNetwork.RestHost", val );
|
||||||
}
|
}
|
||||||
else if( arg == "p" || arg == "port" )
|
else if( arg == "p" || arg == "port" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.ListenPort", val );
|
m_pConfig->setValue< std::string >( "GlobalNetwork.RestPort", val );
|
||||||
}
|
}
|
||||||
else if( arg == "exdpath" || arg == "datapath" )
|
else if( arg == "exdpath" || arg == "datapath" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.DataPath", val );
|
m_pConfig->setValue< std::string >( "GlobalParameters.DataPath", val );
|
||||||
}
|
}
|
||||||
else if( arg == "h" || arg == "dbhost" )
|
else if( arg == "h" || arg == "dbhost" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Host", val );
|
m_pConfig->setValue< std::string >( "Database.Host", val );
|
||||||
}
|
}
|
||||||
else if( arg == "dbport" )
|
else if( arg == "dbport" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Port", val );
|
m_pConfig->setValue< std::string >( "Database.Port", val );
|
||||||
}
|
}
|
||||||
else if( arg == "u" || arg == "user" || arg == "dbuser" )
|
else if( arg == "u" || arg == "user" || arg == "dbuser" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Username", val );
|
m_pConfig->setValue< std::string >( "Database.Username", val );
|
||||||
}
|
}
|
||||||
else if( arg == "pass" || arg == "dbpass" )
|
else if( arg == "pass" || arg == "dbpass" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Pass", val );
|
m_pConfig->setValue< std::string >( "Database.Password", val );
|
||||||
}
|
}
|
||||||
else if( arg == "d" || arg == "db" || arg == "database" )
|
else if( arg == "d" || arg == "db" || arg == "database" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.Mysql.Database", val );
|
m_pConfig->setValue< std::string >( "Database.Database", val );
|
||||||
}
|
}
|
||||||
else if ( arg == "lobbyip" || arg == "lobbyhost" )
|
else if ( arg == "lobbyip" || arg == "lobbyhost" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.LobbyHost", val );
|
m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyHost", val );
|
||||||
}
|
}
|
||||||
else if ( arg == "lobbyport" )
|
else if ( arg == "lobbyport" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.LobbyPort", val );
|
m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyPort", val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
|
@ -143,7 +143,7 @@ bool loadSettings( int32_t argc, char* argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
g_log.info( "Setting up generated EXD data" );
|
g_log.info( "Setting up generated EXD data" );
|
||||||
if( !g_exdDataGen.init( m_pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) )
|
if( !g_exdDataGen.init( m_pConfig->getValue< std::string >( "GlobalParameters.DataPath", "" ) ) )
|
||||||
{
|
{
|
||||||
g_log.fatal( "Error setting up generated EXD data " );
|
g_log.fatal( "Error setting up generated EXD data " );
|
||||||
return false;
|
return false;
|
||||||
|
@ -152,19 +152,19 @@ bool loadSettings( int32_t argc, char* argv[] )
|
||||||
Core::Db::DbLoader loader;
|
Core::Db::DbLoader loader;
|
||||||
|
|
||||||
Core::Db::ConnectionInfo info;
|
Core::Db::ConnectionInfo info;
|
||||||
info.password = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Pass", "" );
|
info.password = m_pConfig->getValue< std::string >( "Database.Password", "" );
|
||||||
info.host = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Host", "127.0.0.1" );
|
info.host = m_pConfig->getValue< std::string >( "Database.Host", "127.0.0.1" );
|
||||||
info.database = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Database", "sapphire" );
|
info.database = m_pConfig->getValue< std::string >( "Database.Database", "sapphire" );
|
||||||
info.port = m_pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 );
|
info.port = m_pConfig->getValue< uint16_t >( "Database.Port", 3306 );
|
||||||
info.user = m_pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" );
|
info.user = m_pConfig->getValue< std::string >( "Database.Username", "root" );
|
||||||
info.syncThreads = m_pConfig->getValue< uint8_t >( "Settings.General.Mysql.SyncThreads", 2 );
|
info.syncThreads = m_pConfig->getValue< uint8_t >( "Database.SyncThreads", 2 );
|
||||||
info.asyncThreads = m_pConfig->getValue< uint8_t >( "Settings.General.Mysql.AsyncThreads", 2 );
|
info.asyncThreads = m_pConfig->getValue< uint8_t >( "Database.AsyncThreads", 2 );
|
||||||
|
|
||||||
loader.addDb( g_charaDb, info );
|
loader.addDb( g_charaDb, info );
|
||||||
if( !loader.initDbs() )
|
if( !loader.initDbs() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
server.config.port = static_cast< uint16_t >( std::stoul( m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) ) );
|
server.config.port = static_cast< uint16_t >( std::stoul( m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort", "80" ) ) );
|
||||||
|
|
||||||
g_log.info( "Database: Connected to " + info.host + ":" + std::to_string( info.port ) );
|
g_log.info( "Database: Connected to " + info.host + ":" + std::to_string( info.port ) );
|
||||||
|
|
||||||
|
@ -269,8 +269,8 @@ void createAccount( shared_ptr<HttpServer::Response> response, shared_ptr<HttpSe
|
||||||
if( g_sapphireAPI.createAccount( user, pass, sId ) )
|
if( g_sapphireAPI.createAccount( user, pass, sId ) )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"sId\":\"" + sId +
|
std::string json_string = "{\"sId\":\"" + sId +
|
||||||
"\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.LobbyHost" ) +
|
"\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >( "GlobalNetwork.LobbyHost" ) +
|
||||||
"\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.FrontierHost" ) + "\"}";
|
"\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "GlobalNetwork.RestHost" ) + "\"}";
|
||||||
*response << buildHttpResponse( 200, json_string, JSON );
|
*response << buildHttpResponse( 200, json_string, JSON );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -301,8 +301,8 @@ void login( shared_ptr<HttpServer::Response> response, shared_ptr<HttpServer::Re
|
||||||
if( g_sapphireAPI.login( user, pass, sId ) )
|
if( g_sapphireAPI.login( user, pass, sId ) )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"sId\":\"" + sId +
|
std::string json_string = "{\"sId\":\"" + sId +
|
||||||
"\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >("Settings.General.LobbyHost") +
|
"\", \"lobbyHost\":\"" + m_pConfig->getValue< std::string >( "GlobalNetwork.LobbyHost" ) +
|
||||||
"\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "Settings.General.FrontierHost" ) + "\"}";
|
"\", \"frontierHost\":\"" + m_pConfig->getValue< std::string >( "GlobalNetwork.RestHost" ) + "\"}";
|
||||||
*response << buildHttpResponse( 200, json_string, JSON );
|
*response << buildHttpResponse( 200, json_string, JSON );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -333,7 +333,7 @@ void deleteCharacter( shared_ptr<HttpServer::Response> response, shared_ptr<Http
|
||||||
|
|
||||||
int32_t accountId = g_sapphireAPI.checkSession( sId );
|
int32_t accountId = g_sapphireAPI.checkSession( sId );
|
||||||
|
|
||||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret )
|
if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||||
*response << buildHttpResponse( 403, json_string, JSON );
|
*response << buildHttpResponse( 403, json_string, JSON );
|
||||||
|
@ -374,14 +374,14 @@ void createCharacter( shared_ptr<HttpServer::Response> response, shared_ptr<Http
|
||||||
|
|
||||||
if( result != -1 )
|
if( result != -1 )
|
||||||
{
|
{
|
||||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret )
|
if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||||
*response << buildHttpResponse( 403, json_string, JSON );
|
*response << buildHttpResponse( 403, json_string, JSON );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson, m_pConfig->getValue< uint8_t >( "Settings.Parameters.DefaultGMRank", 255 ) );
|
int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson, m_pConfig->getValue< uint8_t >( "CharacterCreation.DefaultGMRank", 255 ) );
|
||||||
|
|
||||||
std::string json_string = "{\"result\":\"" + std::to_string( charId ) + "\"}";
|
std::string json_string = "{\"result\":\"" + std::to_string( charId ) + "\"}";
|
||||||
*response << buildHttpResponse( 200, json_string, JSON );
|
*response << buildHttpResponse( 200, json_string, JSON );
|
||||||
|
@ -414,7 +414,7 @@ void insertSession( shared_ptr<HttpServer::Response> response, shared_ptr<HttpSe
|
||||||
uint32_t accountId = pt.get<uint32_t>( "accountId" );
|
uint32_t accountId = pt.get<uint32_t>( "accountId" );
|
||||||
std::string secret = pt.get<string>( "secret" );
|
std::string secret = pt.get<string>( "secret" );
|
||||||
// reloadConfig();
|
// reloadConfig();
|
||||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret )
|
if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||||
*response << buildHttpResponse( 403, json_string, JSON );
|
*response << buildHttpResponse( 403, json_string, JSON );
|
||||||
|
@ -448,7 +448,7 @@ void checkNameTaken( shared_ptr<HttpServer::Response> response, shared_ptr<HttpS
|
||||||
|
|
||||||
// reloadConfig();
|
// reloadConfig();
|
||||||
|
|
||||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret )
|
if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||||
*response << buildHttpResponse( 403, json_string, JSON );
|
*response << buildHttpResponse( 403, json_string, JSON );
|
||||||
|
@ -486,7 +486,7 @@ void checkSession( shared_ptr<HttpServer::Response> response, shared_ptr<HttpSer
|
||||||
|
|
||||||
if( result != -1 )
|
if( result != -1 )
|
||||||
{
|
{
|
||||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret )
|
if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||||
*response << buildHttpResponse( 403, json_string, JSON );
|
*response << buildHttpResponse( 403, json_string, JSON );
|
||||||
|
@ -523,7 +523,7 @@ void getNextCharId( shared_ptr<HttpServer::Response> response, shared_ptr<HttpSe
|
||||||
|
|
||||||
// reloadConfig();
|
// reloadConfig();
|
||||||
|
|
||||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret )
|
if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||||
*response << buildHttpResponse( 403, json_string, JSON );
|
*response << buildHttpResponse( 403, json_string, JSON );
|
||||||
|
@ -555,7 +555,7 @@ void getNextContentId( shared_ptr<HttpServer::Response> response, shared_ptr<Htt
|
||||||
|
|
||||||
// reloadConfig();
|
// reloadConfig();
|
||||||
|
|
||||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret )
|
if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||||
*response << buildHttpResponse( 403, json_string, JSON );
|
*response << buildHttpResponse( 403, json_string, JSON );
|
||||||
|
@ -591,7 +591,7 @@ void getCharacterList( shared_ptr<HttpServer::Response> response, shared_ptr<Htt
|
||||||
|
|
||||||
if( result != -1 )
|
if( result != -1 )
|
||||||
{
|
{
|
||||||
if( m_pConfig->getValue< std::string >( "Settings.General.ServerSecret" ) != secret )
|
if( m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" ) != secret )
|
||||||
{
|
{
|
||||||
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
std::string json_string = "{\"result\":\"invalid_secret\"}";
|
||||||
*response << buildHttpResponse( 403, json_string, JSON );
|
*response << buildHttpResponse( 403, json_string, JSON );
|
||||||
|
@ -756,8 +756,8 @@ int main( int argc, char* argv[] )
|
||||||
if( !loadSettings( argc, argv ) )
|
if( !loadSettings( argc, argv ) )
|
||||||
throw std::exception();
|
throw std::exception();
|
||||||
|
|
||||||
server.config.port = stoi( m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) );
|
server.config.port = stoi( m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort", "80" ) );
|
||||||
g_log.info( "Starting API server at port " + m_pConfig->getValue< std::string >( "Settings.General.HttpPort", "80" ) + "..." );
|
g_log.info( "Starting API server at port " + m_pConfig->getValue< std::string >( "GlobalNetwork.RestPort", "80" ) + "..." );
|
||||||
|
|
||||||
server.resource["^/ZoneName/([0-9]+)$"]["GET"] = &getZoneName;
|
server.resource["^/ZoneName/([0-9]+)$"]["GET"] = &getZoneName;
|
||||||
server.resource["^/sapphire-api/lobby/createAccount"]["POST"] = &createAccount;
|
server.resource["^/sapphire-api/lobby/createAccount"]["POST"] = &createAccount;
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <Network/GamePacketParser.h>
|
#include <Network/GamePacketParser.h>
|
||||||
#include <Crypt/md5.h>
|
#include <Crypt/md5.h>
|
||||||
#include <Crypt/blowfish.h>
|
#include <Crypt/blowfish.h>
|
||||||
|
#include <Config/ConfigMgr.h>
|
||||||
|
|
||||||
#include <boost/property_tree/json_parser.hpp>
|
#include <boost/property_tree/json_parser.hpp>
|
||||||
|
|
||||||
|
@ -129,10 +130,10 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
|
||||||
serverListPacket.data().seq = 1;
|
serverListPacket.data().seq = 1;
|
||||||
serverListPacket.data().offset = 0;
|
serverListPacket.data().offset = 0;
|
||||||
serverListPacket.data().numServers = 1;
|
serverListPacket.data().numServers = 1;
|
||||||
serverListPacket.data().server[0].id = g_serverLobby.getConfig()->getValue<uint16_t>( "Settings.Parameters.WorldID", 1 );
|
serverListPacket.data().server[0].id = g_serverLobby.getConfig()->getValue<uint16_t>( "Lobby.WorldID", 1 );
|
||||||
serverListPacket.data().server[0].index = 0;
|
serverListPacket.data().server[0].index = 0;
|
||||||
serverListPacket.data().final = 1;
|
serverListPacket.data().final = 1;
|
||||||
strcpy( serverListPacket.data().server[0].name, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() );
|
strcpy( serverListPacket.data().server[0].name, g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
|
||||||
|
|
||||||
pRP.addPacket( serverListPacket );
|
pRP.addPacket( serverListPacket );
|
||||||
|
|
||||||
|
@ -166,11 +167,11 @@ void Core::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet, ui
|
||||||
auto& charEntry = charList[charIndex];
|
auto& charEntry = charList[charIndex];
|
||||||
details.uniqueId = get< 1 >( charEntry );
|
details.uniqueId = get< 1 >( charEntry );
|
||||||
details.contentId = get< 2 >( charEntry );
|
details.contentId = get< 2 >( charEntry );
|
||||||
details.serverId = g_serverLobby.getConfig()->getValue<uint16_t>( "Settings.Parameters.WorldID", 1 );
|
details.serverId = g_serverLobby.getConfig()->getValue<uint16_t>( "Lobby.WorldID", 1 );
|
||||||
details.index = charIndex;
|
details.index = charIndex;
|
||||||
strcpy( details.charDetailJson, get< 3 >( charEntry ).c_str() );
|
strcpy( details.charDetailJson, get< 3 >( charEntry ).c_str() );
|
||||||
strcpy( details.nameChara, get< 0 >( charEntry ).c_str() );
|
strcpy( details.nameChara, get< 0 >( charEntry ).c_str() );
|
||||||
strcpy( details.nameServer, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() );
|
strcpy( details.nameServer, g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
|
||||||
|
|
||||||
charListPacket.data().charaDetails[j] = details;
|
charListPacket.data().charaDetails[j] = details;
|
||||||
|
|
||||||
|
@ -238,8 +239,8 @@ void Core::Network::GameConnection::enterWorld( FFXIVARR_PACKET_RAW& packet, uin
|
||||||
enterWorldPacket.data().contentId = lookupId;
|
enterWorldPacket.data().contentId = lookupId;
|
||||||
|
|
||||||
enterWorldPacket.data().seq = sequence;
|
enterWorldPacket.data().seq = sequence;
|
||||||
strcpy( enterWorldPacket.data().host, g_serverLobby.getConfig()->getValue< std::string >( "Settings.General.ZoneIp" ).c_str() );
|
strcpy( enterWorldPacket.data().host, g_serverLobby.getConfig()->getValue< std::string >( "GlobalNetwork.ZoneHost" ).c_str() );
|
||||||
enterWorldPacket.data().port = g_serverLobby.getConfig()->getValue< uint16_t >( "Settings.General.ZonePort" );
|
enterWorldPacket.data().port = g_serverLobby.getConfig()->getValue< uint16_t >( "GlobalNetwork.ZonePort" );
|
||||||
enterWorldPacket.data().charId = logInCharId;
|
enterWorldPacket.data().charId = logInCharId;
|
||||||
memcpy( enterWorldPacket.data().sid, m_pSession->getSessionId(), 66 );
|
memcpy( enterWorldPacket.data().sid, m_pSession->getSessionId(), 66 );
|
||||||
|
|
||||||
|
@ -251,7 +252,7 @@ bool Core::Network::GameConnection::sendServiceAccountList( FFXIVARR_PACKET_RAW&
|
||||||
{
|
{
|
||||||
LobbySessionPtr pSession = g_serverLobby.getSession( ( char* )&packet.data[0] + 0x20 );
|
LobbySessionPtr pSession = g_serverLobby.getSession( ( char* )&packet.data[0] + 0x20 );
|
||||||
|
|
||||||
if( g_serverLobby.getConfig()->getValue< bool >( "Settings.Parameters.AllowNoSessionConnect" ) && pSession == nullptr )
|
if( g_serverLobby.getConfig()->getValue< bool >( "Lobby.AllowNoSessionConnect" ) && pSession == nullptr )
|
||||||
{
|
{
|
||||||
auto session = make_LobbySession();
|
auto session = make_LobbySession();
|
||||||
session->setAccountID( 0 );
|
session->setAccountID( 0 );
|
||||||
|
@ -319,7 +320,7 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac
|
||||||
|
|
||||||
charCreatePacket.data().content_id = newContentId;
|
charCreatePacket.data().content_id = newContentId;
|
||||||
strcpy( charCreatePacket.data().name, name.c_str() );
|
strcpy( charCreatePacket.data().name, name.c_str() );
|
||||||
strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() );
|
strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
|
||||||
charCreatePacket.data().type = 1;
|
charCreatePacket.data().type = 1;
|
||||||
charCreatePacket.data().seq = sequence;
|
charCreatePacket.data().seq = sequence;
|
||||||
charCreatePacket.data().unknown = 1;
|
charCreatePacket.data().unknown = 1;
|
||||||
|
@ -343,7 +344,7 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac
|
||||||
|
|
||||||
charCreatePacket.data().content_id = newContentId;
|
charCreatePacket.data().content_id = newContentId;
|
||||||
strcpy( charCreatePacket.data().name, name.c_str() );
|
strcpy( charCreatePacket.data().name, name.c_str() );
|
||||||
strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() );
|
strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
|
||||||
charCreatePacket.data().type = 2;
|
charCreatePacket.data().type = 2;
|
||||||
charCreatePacket.data().seq = sequence;
|
charCreatePacket.data().seq = sequence;
|
||||||
charCreatePacket.data().unknown = 1;
|
charCreatePacket.data().unknown = 1;
|
||||||
|
@ -374,7 +375,7 @@ bool Core::Network::GameConnection::createOrModifyChar( FFXIVARR_PACKET_RAW& pac
|
||||||
//charCreatePacket.data().content_id = deletePlayer.getContentId();
|
//charCreatePacket.data().content_id = deletePlayer.getContentId();
|
||||||
charCreatePacket.data().content_id = 0;
|
charCreatePacket.data().content_id = 0;
|
||||||
strcpy( charCreatePacket.data().name, name.c_str() );
|
strcpy( charCreatePacket.data().name, name.c_str() );
|
||||||
strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Settings.Parameters.WorldName", "Sapphire" ).c_str() );
|
strcpy( charCreatePacket.data().world, g_serverLobby.getConfig()->getValue< std::string >( "Lobby.WorldName", "Sapphire" ).c_str() );
|
||||||
charCreatePacket.data().type = 4;
|
charCreatePacket.data().type = 4;
|
||||||
charCreatePacket.data().seq = sequence;
|
charCreatePacket.data().seq = sequence;
|
||||||
charCreatePacket.data().unknown = 1;
|
charCreatePacket.data().unknown = 1;
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
#include <Version.h>
|
#include <Version.h>
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
#include <Config/XMLConfig.h>
|
#include <Config/ConfigMgr.h>
|
||||||
|
|
||||||
//#include "LobbySession.h"
|
//#include "LobbySession.h"
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ namespace Core {
|
||||||
m_configPath( configPath ),
|
m_configPath( configPath ),
|
||||||
m_numConnections( 0 )
|
m_numConnections( 0 )
|
||||||
{
|
{
|
||||||
m_pConfig = boost::shared_ptr<XMLConfig>( new XMLConfig );
|
m_pConfig = boost::shared_ptr< ConfigMgr >( new ConfigMgr );
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerLobby::~ServerLobby( void )
|
ServerLobby::~ServerLobby( void )
|
||||||
|
@ -49,7 +49,7 @@ namespace Core {
|
||||||
return g_restConnector.getSession( sessionId );
|
return g_restConnector.getSession( sessionId );
|
||||||
}
|
}
|
||||||
|
|
||||||
XMLConfigPtr ServerLobby::getConfig() const
|
ConfigMgrPtr ServerLobby::getConfig() const
|
||||||
{
|
{
|
||||||
return m_pConfig;
|
return m_pConfig;
|
||||||
}
|
}
|
||||||
|
@ -109,23 +109,19 @@ namespace Core {
|
||||||
if( arg == "ip" )
|
if( arg == "ip" )
|
||||||
{
|
{
|
||||||
// todo: ip addr in config
|
// todo: ip addr in config
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.ListenIp", val );
|
m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyHost", val );
|
||||||
}
|
}
|
||||||
else if( arg == "p" || arg == "port" )
|
else if( arg == "p" || arg == "port" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.ListenPort", val );
|
m_pConfig->setValue< std::string >( "GlobalNetwork.LobbyPort", val );
|
||||||
}
|
|
||||||
else if( arg == "ap" || arg == "auth" || arg == "authport" )
|
|
||||||
{
|
|
||||||
m_pConfig->setValue< std::string>( "Settings.General.AuthPort", val );
|
|
||||||
}
|
}
|
||||||
else if( arg == "worldip" || arg == "worldip" )
|
else if( arg == "worldip" || arg == "worldip" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue < std::string >( "Settings.General.WorldIp", val );
|
m_pConfig->setValue < std::string >( "GlobalNetwork.ZoneHost", val );
|
||||||
}
|
}
|
||||||
else if( arg == "worldport" )
|
else if( arg == "worldport" )
|
||||||
{
|
{
|
||||||
m_pConfig->setValue< std::string >( "Settings.General.WorldPort", val );
|
m_pConfig->setValue< std::string >( "GlobalNetwork.ZonePort", val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
|
@ -135,11 +131,11 @@ namespace Core {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_port = m_pConfig->getValue< uint16_t >( "Settings.General.ListenPort", 54994 );
|
m_port = m_pConfig->getValue< uint16_t >( "GlobalNetwork.LobbyPort", 54994 );
|
||||||
m_ip = m_pConfig->getValue< std::string >( "Settings.General.ListenIp", "0.0.0.0" );
|
m_ip = m_pConfig->getValue< std::string >( "GlobalNetwork.LobbyHost", "0.0.0.0" );
|
||||||
|
|
||||||
g_restConnector.restHost = m_pConfig->getValue< std::string >( "Settings.General.RestHost" );
|
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 >( "Settings.General.ServerSecret" );
|
g_restConnector.serverSecret = m_pConfig->getValue< std::string >( "GlobalParameters.ServerSecret" );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,7 +6,6 @@
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include <boost/shared_ptr.hpp>
|
#include <boost/shared_ptr.hpp>
|
||||||
#include <Config/XMLConfig.h>
|
|
||||||
|
|
||||||
#include "Forwards.h"
|
#include "Forwards.h"
|
||||||
|
|
||||||
|
@ -15,7 +14,7 @@ const std::string LOBBY_VERSION = "0.0.5";
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
class LobbySession;
|
class LobbySession;
|
||||||
class XMLConfig;
|
class ConfigMgr;
|
||||||
typedef std::map< std::string, LobbySessionPtr > LobbySessionMap;
|
typedef std::map< std::string, LobbySessionPtr > LobbySessionMap;
|
||||||
|
|
||||||
class ServerLobby
|
class ServerLobby
|
||||||
|
@ -30,7 +29,7 @@ namespace Core
|
||||||
uint16_t m_port;
|
uint16_t m_port;
|
||||||
std::string m_ip;
|
std::string m_ip;
|
||||||
|
|
||||||
boost::shared_ptr<XMLConfig> m_pConfig;
|
boost::shared_ptr< ConfigMgr > m_pConfig;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ServerLobby( const std::string& configPath );
|
ServerLobby( const std::string& configPath );
|
||||||
|
@ -45,7 +44,7 @@ namespace Core
|
||||||
m_sessionMap[std::string( sessionId )] = pSession;
|
m_sessionMap[std::string( sessionId )] = pSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<XMLConfig> getConfig() const;
|
boost::shared_ptr< ConfigMgr > getConfig() const;
|
||||||
|
|
||||||
LobbySessionPtr getSession( char* sessionId );
|
LobbySessionPtr getSession( char* sessionId );
|
||||||
uint32_t m_numConnections;
|
uint32_t m_numConnections;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#include "ServerLobby.h"
|
#include "ServerLobby.h"
|
||||||
|
|
||||||
Core::ServerLobby g_serverLobby( "config/settings_lobby.xml" );
|
Core::ServerLobby g_serverLobby( "lobby.ini" );
|
||||||
|
|
||||||
int main( int32_t argc, char* argv[] )
|
int main( int32_t argc, char* argv[] )
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include <Common.h>
|
#include <Common.h>
|
||||||
#include <Util/Util.h>
|
#include <Util/Util.h>
|
||||||
#include <Util/UtilMath.h>
|
#include <Util/UtilMath.h>
|
||||||
#include <Config/XMLConfig.h>
|
|
||||||
#include <Network/GamePacket.h>
|
#include <Network/GamePacket.h>
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
#include <Exd/ExdDataGenerated.h>
|
#include <Exd/ExdDataGenerated.h>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include <Network/GamePacket.h>
|
#include <Network/GamePacket.h>
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
#include <Network/PacketContainer.h>
|
#include <Network/PacketContainer.h>
|
||||||
#include <Config/XMLConfig.h>
|
#include <Config/ConfigMgr.h>
|
||||||
|
|
||||||
#include "Network/GameConnection.h"
|
#include "Network/GameConnection.h"
|
||||||
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
#include "Network/PacketWrappers/ActorControlPacket142.h"
|
||||||
|
@ -307,10 +307,14 @@ void Core::Entity::Player::eventItemActionStart( uint32_t eventId,
|
||||||
|
|
||||||
void Core::Entity::Player::onLogin()
|
void Core::Entity::Player::onLogin()
|
||||||
{
|
{
|
||||||
auto pConfig = g_fw.get< XMLConfig >();
|
auto pConfig = g_fw.get< ConfigMgr >();
|
||||||
for( auto& child : pConfig->getChild( "Settings.Parameters.MotDArray" ) )
|
auto motd = pConfig->getValue< std::string >( "General.MotD", "" );
|
||||||
|
|
||||||
|
std::istringstream ss( motd );
|
||||||
|
std::string msg;
|
||||||
|
while( std::getline( ss, msg, ';' ) )
|
||||||
{
|
{
|
||||||
sendNotice( child.second.data() );
|
sendNotice( msg );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <Network/GamePacket.h>
|
#include <Network/GamePacket.h>
|
||||||
#include <Util/Util.h>
|
#include <Util/Util.h>
|
||||||
#include <Util/UtilMath.h>
|
#include <Util/UtilMath.h>
|
||||||
#include <Config/XMLConfig.h>
|
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
#include <Exd/ExdDataGenerated.h>
|
#include <Exd/ExdDataGenerated.h>
|
||||||
#include <Network/PacketContainer.h>
|
#include <Network/PacketContainer.h>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#include "ScriptLoader.h"
|
#include "ScriptLoader.h"
|
||||||
|
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
#include <Config/XMLConfig.h>
|
#include <Config/ConfigMgr.h>
|
||||||
|
|
||||||
#include "ServerZone.h"
|
#include "ServerZone.h"
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ bool Core::Scripting::ScriptLoader::unloadModule( ModuleHandle handle )
|
||||||
Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const std::string& path )
|
Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const std::string& path )
|
||||||
{
|
{
|
||||||
auto pLog = g_fw.get< Logger >();
|
auto pLog = g_fw.get< Logger >();
|
||||||
auto pConfig = g_fw.get< XMLConfig >();
|
auto pConfig = g_fw.get< ConfigMgr >();
|
||||||
fs::path f( path );
|
fs::path f( path );
|
||||||
|
|
||||||
if( isModuleLoaded( f.stem().string() ) )
|
if( isModuleLoaded( f.stem().string() ) )
|
||||||
|
@ -63,7 +63,7 @@ Core::Scripting::ScriptInfo* Core::Scripting::ScriptLoader::loadModule( const st
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy to temp dir
|
// copy to temp dir
|
||||||
fs::path cacheDir( f.parent_path() /= pConfig->getValue< std::string >( "Settings.General.Scripts.CachePath", "./cache/" ) );
|
fs::path cacheDir( f.parent_path() /= pConfig->getValue< std::string >( "Scripts.CachePath", "./cache/" ) );
|
||||||
fs::create_directories( cacheDir );
|
fs::create_directories( cacheDir );
|
||||||
fs::path dest( cacheDir /= f.filename().string() );
|
fs::path dest( cacheDir /= f.filename().string() );
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
#include <Exd/ExdDataGenerated.h>
|
#include <Exd/ExdDataGenerated.h>
|
||||||
#include <Config/XMLConfig.h>
|
#include <Config/ConfigMgr.h>
|
||||||
|
|
||||||
#include "watchdog/Watchdog.h"
|
#include "watchdog/Watchdog.h"
|
||||||
|
|
||||||
|
@ -51,10 +51,10 @@ void Core::Scripting::ScriptMgr::update()
|
||||||
bool Core::Scripting::ScriptMgr::init()
|
bool Core::Scripting::ScriptMgr::init()
|
||||||
{
|
{
|
||||||
std::set< std::string > files;
|
std::set< std::string > files;
|
||||||
auto pConfig = g_fw.get< XMLConfig >();
|
auto pConfig = g_fw.get< ConfigMgr >();
|
||||||
auto pLog = g_fw.get< Logger >();
|
auto pLog = g_fw.get< Logger >();
|
||||||
|
|
||||||
auto status = loadDir( pConfig->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ),
|
auto status = loadDir( pConfig->getValue< std::string >( "Scripts.Path", "./compiledscripts/" ),
|
||||||
files, m_nativeScriptMgr->getModuleExtension() );
|
files, m_nativeScriptMgr->getModuleExtension() );
|
||||||
|
|
||||||
if( !status )
|
if( !status )
|
||||||
|
@ -85,12 +85,12 @@ bool Core::Scripting::ScriptMgr::init()
|
||||||
|
|
||||||
void Core::Scripting::ScriptMgr::watchDirectories()
|
void Core::Scripting::ScriptMgr::watchDirectories()
|
||||||
{
|
{
|
||||||
auto pConfig = g_fw.get< XMLConfig >();
|
auto pConfig = g_fw.get< ConfigMgr >();
|
||||||
auto shouldWatch = pConfig->getValue< bool >( "Settings.General.Scripts.HotSwap.Enabled", true );
|
auto shouldWatch = pConfig->getValue< bool >( "Scripts.HotSwap", true );
|
||||||
if( !shouldWatch )
|
if( !shouldWatch )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Watchdog::watchMany( pConfig->getValue< std::string >( "Settings.General.Scripts.Path", "./compiledscripts/" ) + "*" + m_nativeScriptMgr->getModuleExtension(),
|
Watchdog::watchMany( pConfig->getValue< std::string >( "Scripts.Path", "./compiledscripts/" ) + "*" + m_nativeScriptMgr->getModuleExtension(),
|
||||||
[ this ]( const std::vector< ci::fs::path >& paths )
|
[ this ]( const std::vector< ci::fs::path >& paths )
|
||||||
{
|
{
|
||||||
if( !m_firstScriptChangeNotificiation )
|
if( !m_firstScriptChangeNotificiation )
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include <Version.h>
|
#include <Version.h>
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
#include <Config/XMLConfig.h>
|
#include <Config/ConfigMgr.h>
|
||||||
|
|
||||||
#include <MySqlBase.h>
|
#include <MySqlBase.h>
|
||||||
#include <Connection.h>
|
#include <Connection.h>
|
||||||
|
@ -37,8 +37,8 @@
|
||||||
|
|
||||||
extern Core::Framework g_fw;
|
extern Core::Framework g_fw;
|
||||||
|
|
||||||
Core::ServerZone::ServerZone( const std::string& configPath ) :
|
Core::ServerZone::ServerZone( const std::string& configName ) :
|
||||||
m_configPath( configPath ),
|
m_configName( configName ),
|
||||||
m_bRunning( true ),
|
m_bRunning( true ),
|
||||||
m_lastDBPingTime( 0 )
|
m_lastDBPingTime( 0 )
|
||||||
{
|
{
|
||||||
|
@ -56,15 +56,15 @@ size_t Core::ServerZone::getSessionCount() const
|
||||||
bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
||||||
{
|
{
|
||||||
auto pLog = g_fw.get< Core::Logger >();
|
auto pLog = g_fw.get< Core::Logger >();
|
||||||
auto pConfig = g_fw.get< Core::XMLConfig >();
|
auto pConfig = g_fw.get< Core::ConfigMgr >();
|
||||||
auto pExd = g_fw.get< Data::ExdDataGenerated >();
|
auto pExd = g_fw.get< Data::ExdDataGenerated >();
|
||||||
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
|
auto pDb = g_fw.get< Db::DbWorkerPool< Db::CharaDbConnection > >();
|
||||||
|
|
||||||
pLog->info( "Loading config " + m_configPath );
|
pLog->info( "Loading config " + m_configName );
|
||||||
|
|
||||||
if( !pConfig->loadConfig( m_configPath ) )
|
if( !pConfig->loadConfig( m_configName ) )
|
||||||
{
|
{
|
||||||
pLog->fatal( "Error loading config " + m_configPath );
|
pLog->fatal( "Error loading config " + m_configName );
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,39 +85,35 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
||||||
if( arg == "ip" )
|
if( arg == "ip" )
|
||||||
{
|
{
|
||||||
// todo: ip addr in config
|
// todo: ip addr in config
|
||||||
pConfig->setValue< std::string >( "Settings.General.ListenIP", val );
|
pConfig->setValue< std::string >( "GlobalNetwork.ZoneIP", val );
|
||||||
}
|
}
|
||||||
else if( arg == "p" || arg == "port" )
|
else if( arg == "p" || arg == "port" )
|
||||||
{
|
{
|
||||||
pConfig->setValue< std::string >( "Settings.General.ListenPort", val );
|
pConfig->setValue< std::string >( "GlobalNetwork.ZonePort", val );
|
||||||
}
|
}
|
||||||
else if( arg == "exdpath" || arg == "datapath" )
|
else if( arg == "exdpath" || arg == "datapath" )
|
||||||
{
|
{
|
||||||
pConfig->setValue< std::string >( "Settings.General.DataPath", val );
|
pConfig->setValue< std::string >( "GlobalParameters.DataPath", val );
|
||||||
}
|
|
||||||
else if( arg == "s" || arg == "scriptpath" )
|
|
||||||
{
|
|
||||||
pConfig->setValue< std::string >( "Settings.General.ScriptPath", val );
|
|
||||||
}
|
}
|
||||||
else if( arg == "h" || arg == "dbhost" )
|
else if( arg == "h" || arg == "dbhost" )
|
||||||
{
|
{
|
||||||
pConfig->setValue< std::string >( "Settings.General.Mysql.Host", val );
|
pConfig->setValue< std::string >( "Database.Host", val );
|
||||||
}
|
}
|
||||||
else if( arg == "dbport" )
|
else if( arg == "dbport" )
|
||||||
{
|
{
|
||||||
pConfig->setValue< std::string >( "Settings.General.Mysql.Port", val );
|
pConfig->setValue< std::string >( "Database.Port", val );
|
||||||
}
|
}
|
||||||
else if( arg == "u" || arg == "user" || arg == "dbuser" )
|
else if( arg == "u" || arg == "user" || arg == "dbuser" )
|
||||||
{
|
{
|
||||||
pConfig->setValue< std::string >( "Settings.General.Mysql.Username", val );
|
pConfig->setValue< std::string >( "Database.Username", val );
|
||||||
}
|
}
|
||||||
else if( arg == "pass" || arg == "dbpass" )
|
else if( arg == "pass" || arg == "dbpass" )
|
||||||
{
|
{
|
||||||
pConfig->setValue< std::string >( "Settings.General.Mysql.Pass", val );
|
pConfig->setValue< std::string >( "Database.Password", val );
|
||||||
}
|
}
|
||||||
else if( arg == "d" || arg == "db" || arg == "database" )
|
else if( arg == "d" || arg == "db" || arg == "database" )
|
||||||
{
|
{
|
||||||
pConfig->setValue< std::string >( "Settings.General.Mysql.Database", val );
|
pConfig->setValue< std::string >( "Database.Database", val );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( ... )
|
catch( ... )
|
||||||
|
@ -128,7 +124,7 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
||||||
}
|
}
|
||||||
|
|
||||||
pLog->info( "Setting up generated EXD data" );
|
pLog->info( "Setting up generated EXD data" );
|
||||||
if( !pExd->init( pConfig->getValue< std::string >( "Settings.General.DataPath", "" ) ) )
|
if( !pExd->init( pConfig->getValue< std::string >( "GlobalParameters.DataPath", "" ) ) )
|
||||||
{
|
{
|
||||||
pLog->fatal( "Error setting up generated EXD data " );
|
pLog->fatal( "Error setting up generated EXD data " );
|
||||||
return false;
|
return false;
|
||||||
|
@ -137,20 +133,20 @@ bool Core::ServerZone::loadSettings( int32_t argc, char* argv[] )
|
||||||
Core::Db::DbLoader loader;
|
Core::Db::DbLoader loader;
|
||||||
|
|
||||||
Core::Db::ConnectionInfo info;
|
Core::Db::ConnectionInfo info;
|
||||||
info.password = pConfig->getValue< std::string >( "Settings.General.Mysql.Pass", "" );
|
info.password = pConfig->getValue< std::string >( "Database.Password", "" );
|
||||||
info.host = pConfig->getValue< std::string >( "Settings.General.Mysql.Host", "127.0.0.1" );
|
info.host = pConfig->getValue< std::string >( "Database.Host", "127.0.0.1" );
|
||||||
info.database = pConfig->getValue< std::string >( "Settings.General.Mysql.Database", "sapphire" );
|
info.database = pConfig->getValue< std::string >( "Database.Database", "sapphire" );
|
||||||
info.port = pConfig->getValue< uint16_t >( "Settings.General.Mysql.Port", 3306 );
|
info.port = pConfig->getValue< uint16_t >( "Database.Port", 3306 );
|
||||||
info.user = pConfig->getValue< std::string >( "Settings.General.Mysql.Username", "root" );
|
info.user = pConfig->getValue< std::string >( "Database.Username", "root" );
|
||||||
info.syncThreads = pConfig->getValue< uint8_t >( "Settings.General.Mysql.SyncThreads", 2 );
|
info.syncThreads = pConfig->getValue< uint8_t >( "Database.SyncThreads", 2 );
|
||||||
info.asyncThreads = pConfig->getValue< uint8_t >( "Settings.General.Mysql.AsyncThreads", 2 );
|
info.asyncThreads = pConfig->getValue< uint8_t >( "Database.AsyncThreads", 2 );
|
||||||
|
|
||||||
loader.addDb( *pDb, info );
|
loader.addDb( *pDb, info );
|
||||||
if( !loader.initDbs() )
|
if( !loader.initDbs() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
m_port = pConfig->getValue< uint16_t >( "Settings.General.ListenPort", 54992 );
|
m_port = pConfig->getValue< uint16_t >( "GlobalNetwork.ZonePort", 54992 );
|
||||||
m_ip = pConfig->getValue< std::string >( "Settings.General.ListenIp", "0.0.0.0" );
|
m_ip = pConfig->getValue< std::string >( "GlobalNetwork.ZoneIP", "0.0.0.0" );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ namespace Core {
|
||||||
class ServerZone
|
class ServerZone
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ServerZone( const std::string& configPath );
|
ServerZone( const std::string& configName );
|
||||||
~ServerZone();
|
~ServerZone();
|
||||||
|
|
||||||
void run( int32_t argc, char* argv[] );
|
void run( int32_t argc, char* argv[] );
|
||||||
|
@ -44,7 +44,7 @@ namespace Core {
|
||||||
|
|
||||||
bool m_bRunning;
|
bool m_bRunning;
|
||||||
|
|
||||||
std::string m_configPath;
|
std::string m_configName;
|
||||||
|
|
||||||
std::mutex m_sessionMutex;
|
std::mutex m_sessionMutex;
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
#include <Framework.h>
|
#include <Framework.h>
|
||||||
#include <Logging/Logger.h>
|
#include <Logging/Logger.h>
|
||||||
#include <Config/XMLConfig.h>
|
|
||||||
#include <Exd/ExdDataGenerated.h>
|
#include <Exd/ExdDataGenerated.h>
|
||||||
#include "Script/ScriptMgr.h"
|
#include "Script/ScriptMgr.h"
|
||||||
#include <Database/CharaDbConnection.h>
|
#include <Database/CharaDbConnection.h>
|
||||||
|
@ -13,34 +12,36 @@
|
||||||
#include "Zone/TerritoryMgr.h"
|
#include "Zone/TerritoryMgr.h"
|
||||||
#include "DebugCommand/DebugCommandHandler.h"
|
#include "DebugCommand/DebugCommandHandler.h"
|
||||||
|
|
||||||
|
#include <Config/ConfigMgr.h>
|
||||||
|
|
||||||
Core::Framework g_fw;
|
Core::Framework g_fw;
|
||||||
|
|
||||||
using namespace Core;
|
using namespace Core;
|
||||||
|
|
||||||
bool setupFramework()
|
bool setupFramework()
|
||||||
{
|
{
|
||||||
auto pServer = boost::make_shared< ServerZone >( "config/settings_zone.xml" );
|
auto pServer = boost::make_shared< ServerZone >( "zone.ini" );
|
||||||
auto pLogger = boost::make_shared< Logger >();
|
auto pLogger = boost::make_shared< Logger >();
|
||||||
auto pConfig = boost::make_shared< XMLConfig >();
|
|
||||||
auto pExdData = boost::make_shared< Data::ExdDataGenerated >();
|
auto pExdData = boost::make_shared< Data::ExdDataGenerated >();
|
||||||
auto pScript = boost::make_shared< Scripting::ScriptMgr >();
|
auto pScript = boost::make_shared< Scripting::ScriptMgr >();
|
||||||
auto pDb = boost::make_shared< Db::DbWorkerPool< Db::CharaDbConnection > >();
|
auto pDb = boost::make_shared< Db::DbWorkerPool< Db::CharaDbConnection > >();
|
||||||
auto pLsMgr = boost::make_shared< LinkshellMgr >();
|
auto pLsMgr = boost::make_shared< LinkshellMgr >();
|
||||||
auto pTeriMgr = boost::make_shared< TerritoryMgr >();
|
auto pTeriMgr = boost::make_shared< TerritoryMgr >();
|
||||||
auto pDebugCom = boost::make_shared< DebugCommandHandler >();
|
auto pDebugCom = boost::make_shared< DebugCommandHandler >();
|
||||||
|
auto pConfig = boost::make_shared< ConfigMgr >();
|
||||||
|
|
||||||
pLogger->setLogPath( "log/SapphireZone_" );
|
pLogger->setLogPath( "log/SapphireZone_" );
|
||||||
pLogger->init();
|
pLogger->init();
|
||||||
|
|
||||||
g_fw.set< ServerZone >( pServer );
|
g_fw.set< ServerZone >( pServer );
|
||||||
g_fw.set< Logger >( pLogger );
|
g_fw.set< Logger >( pLogger );
|
||||||
g_fw.set< XMLConfig >( pConfig );
|
|
||||||
g_fw.set< Data::ExdDataGenerated >( pExdData );
|
g_fw.set< Data::ExdDataGenerated >( pExdData );
|
||||||
g_fw.set< Scripting::ScriptMgr >( pScript );
|
g_fw.set< Scripting::ScriptMgr >( pScript );
|
||||||
g_fw.set< Db::DbWorkerPool< Db::CharaDbConnection > >( pDb );
|
g_fw.set< Db::DbWorkerPool< Db::CharaDbConnection > >( pDb );
|
||||||
g_fw.set< LinkshellMgr >( pLsMgr );
|
g_fw.set< LinkshellMgr >( pLsMgr );
|
||||||
g_fw.set< TerritoryMgr >( pTeriMgr );
|
g_fw.set< TerritoryMgr >( pTeriMgr );
|
||||||
g_fw.set< DebugCommandHandler >( pDebugCom );
|
g_fw.set< DebugCommandHandler >( pDebugCom );
|
||||||
|
g_fw.set< ConfigMgr >( pConfig );
|
||||||
|
|
||||||
// actuall catch errors here...
|
// actuall catch errors here...
|
||||||
return true;
|
return true;
|
||||||
|
@ -48,7 +49,6 @@ bool setupFramework()
|
||||||
|
|
||||||
int main( int32_t argc, char* argv[] )
|
int main( int32_t argc, char* argv[] )
|
||||||
{
|
{
|
||||||
|
|
||||||
if( !setupFramework() )
|
if( !setupFramework() )
|
||||||
return 0; // too fucking bad...
|
return 0; // too fucking bad...
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue