1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-05 10:17:46 +00:00

refactor parameters to general, fix build error

This commit is contained in:
NotAdam 2019-01-07 23:26:34 +11:00
parent 3cfc79e842
commit 4397c86dae
7 changed files with 22 additions and 24 deletions

View file

@ -7,7 +7,7 @@ Password =
SyncThreads = 2 SyncThreads = 2
AsyncThreads = 2 AsyncThreads = 2
[Parameters] [General]
ServerSecret = default ServerSecret = default
DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack
WorldID = 67 WorldID = 67

View file

@ -118,7 +118,7 @@ bool loadSettings( int32_t argc, char* argv[] )
} }
Logger::info( "Setting up generated EXD data" ); Logger::info( "Setting up generated EXD data" );
auto dataPath = m_config.global.parameters.dataPath; auto dataPath = m_config.global.general.dataPath;
if( !g_exdDataGen.init( dataPath ) ) if( !g_exdDataGen.init( dataPath ) )
{ {
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" ); Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" );
@ -300,7 +300,7 @@ void deleteCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H
int32_t accountId = g_sapphireAPI.checkSession( sId ); int32_t accountId = g_sapphireAPI.checkSession( sId );
if( m_config.global.parameters.serverSecret != secret ) if( m_config.global.general.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 );
@ -340,7 +340,7 @@ void createCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H
if( result != -1 ) if( result != -1 )
{ {
if( m_config.global.parameters.serverSecret != secret ) if( m_config.global.general.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 );
@ -348,7 +348,7 @@ void createCharacter( shared_ptr< HttpServer::Response > response, shared_ptr< H
else else
{ {
int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson, int32_t charId = g_sapphireAPI.createCharacter( result, name, finalJson,
m_config.global.parameters.defaultGMRank ); m_config.global.general.defaultGMRank );
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 );
@ -381,7 +381,7 @@ void insertSession( shared_ptr< HttpServer::Response > response, shared_ptr< Htt
std::string secret = json["secret"]; std::string secret = json["secret"];
// reloadConfig(); // reloadConfig();
if( m_config.global.parameters.serverSecret != secret ) if( m_config.global.general.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 );
@ -413,7 +413,7 @@ void checkNameTaken( shared_ptr< HttpServer::Response > response, shared_ptr< Ht
// reloadConfig(); // reloadConfig();
if( m_config.global.parameters.serverSecret != secret ) if( m_config.global.general.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 );
@ -450,7 +450,7 @@ void checkSession( shared_ptr< HttpServer::Response > response, shared_ptr< Http
if( result != -1 ) if( result != -1 )
{ {
if( m_config.global.parameters.serverSecret != secret ) if( m_config.global.general.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 );
@ -489,7 +489,7 @@ void getNextCharId( shared_ptr< HttpServer::Response > response, shared_ptr< Htt
// reloadConfig(); // reloadConfig();
if( m_config.global.parameters.serverSecret != secret ) if( m_config.global.general.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 );
@ -520,7 +520,7 @@ void getNextContentId( shared_ptr< HttpServer::Response > response, shared_ptr<
// reloadConfig(); // reloadConfig();
if( m_config.global.parameters.serverSecret != secret ) if( m_config.global.general.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 getCharacterList( shared_ptr< HttpServer::Response > response, shared_ptr<
if( result != -1 ) if( result != -1 )
{ {
if( m_config.global.parameters.serverSecret != secret ) if( m_config.global.general.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 );

View file

@ -9,14 +9,14 @@ namespace Sapphire::Common::Config
{ {
Sapphire::Db::ConnectionInfo database; Sapphire::Db::ConnectionInfo database;
struct Parameters struct General
{ {
std::string serverSecret; std::string serverSecret;
std::string dataPath; std::string dataPath;
uint16_t worldID; uint16_t worldID;
uint8_t defaultGMRank; uint8_t defaultGMRank;
} parameters; } general;
struct Network struct Network
{ {

View file

@ -26,8 +26,6 @@ bool Sapphire::ConfigMgr::loadConfig( const std::string& configName )
if( m_pInih->ParseError() < 0 ) if( m_pInih->ParseError() < 0 )
return false; return false;
initConfigData();
return true; return true;
} }
@ -55,10 +53,10 @@ bool Sapphire::ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config
config.database.asyncThreads = getValue< uint8_t >( "Database", "AsyncThreads", 2 ); config.database.asyncThreads = getValue< uint8_t >( "Database", "AsyncThreads", 2 );
// params // params
config.parameters.dataPath = getValue< std::string >( "Parameters", "DataPath", "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" ); config.general.dataPath = getValue< std::string >( "Parameters", "DataPath", "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
config.parameters.serverSecret = getValue< std::string >( "Parameters", "ServerSecret", "default" ); config.general.serverSecret = getValue< std::string >( "Parameters", "ServerSecret", "default" );
config.parameters.worldID = getValue< uint16_t >( "Parameters", "WorldID", 67 ); config.general.worldID = getValue< uint16_t >( "Parameters", "WorldID", 67 );
config.parameters.defaultGMRank = getValue< uint8_t >( "Parameters", "DefaultGMRank", 255 ); config.general.defaultGMRank = getValue< uint8_t >( "Parameters", "DefaultGMRank", 255 );
// network // network
config.network.zoneHost = getValue< std::string >( "Network", "ZoneHost", "127.0.0.1" ); config.network.zoneHost = getValue< std::string >( "Network", "ZoneHost", "127.0.0.1" );

View file

@ -128,7 +128,7 @@ void Sapphire::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet
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().global.parameters.worldID; serverListPacket->data().server[ 0 ].id = g_serverLobby.getConfig().global.general.worldID;
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().worldName.c_str() ); strcpy( serverListPacket->data().server[ 0 ].name, g_serverLobby.getConfig().worldName.c_str() );
@ -161,8 +161,8 @@ void Sapphire::Network::GameConnection::getCharList( FFXIVARR_PACKET_RAW& packet
auto& charEntry = charList[ charIndex ]; auto& charEntry = charList[ charIndex ];
details.uniqueId = std::get< 1 >( charEntry ); details.uniqueId = std::get< 1 >( charEntry );
details.contentId = std::get< 2 >( charEntry ); details.contentId = std::get< 2 >( charEntry );
details.serverId = g_serverLobby.getConfig().global.parameters.worldID; details.serverId = g_serverLobby.getConfig().global.general.worldID;
details.serverId1 = g_serverLobby.getConfig().global.parameters.worldID; details.serverId1 = g_serverLobby.getConfig().global.general.worldID;
details.index = charIndex; details.index = charIndex;
strcpy( details.charDetailJson, std::get< 3 >( charEntry ).c_str() ); strcpy( details.charDetailJson, std::get< 3 >( charEntry ).c_str() );
strcpy( details.nameChara, std::get< 0 >( charEntry ).c_str() ); strcpy( details.nameChara, std::get< 0 >( charEntry ).c_str() );

View file

@ -155,7 +155,7 @@ namespace Sapphire
g_restConnector.restHost = m_config.global.network.restHost + ":" + g_restConnector.restHost = m_config.global.network.restHost + ":" +
std::to_string( m_config.global.network.restPort ); std::to_string( m_config.global.network.restPort );
g_restConnector.serverSecret = m_config.global.parameters.serverSecret; g_restConnector.serverSecret = m_config.global.general.serverSecret;
return true; return true;
} }

View file

@ -127,7 +127,7 @@ void Sapphire::World::ServerMgr::run( int32_t argc, char* argv[] )
Logger::info( "Setting up generated EXD data" ); Logger::info( "Setting up generated EXD data" );
auto pExdData = std::make_shared< Data::ExdDataGenerated >(); auto pExdData = std::make_shared< Data::ExdDataGenerated >();
auto dataPath = m_config.global.parameters.dataPath; auto dataPath = m_config.global.general.dataPath;
if( !pExdData->init( dataPath ) ) if( !pExdData->init( dataPath ) )
{ {
Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" ); Logger::fatal( "Error setting up generated EXD data. Make sure that DataPath is set correctly in global.ini" );