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

shift a lot of config around

This commit is contained in:
NotAdam 2019-01-07 22:11:52 +11:00
parent 092b343114
commit 3521ae7c8d
8 changed files with 134 additions and 123 deletions

3
config/api.ini.default Normal file
View file

@ -0,0 +1,3 @@
[Network]
ListenIp = 0.0.0.0
ListenPort = 80

View file

@ -1,62 +0,0 @@
[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/config.ini
[Housing]
; Set the default estate name. %i will be replaced with the plot number
DefaultEstateName = Estate #%i

24
config/global.ini.default Normal file
View file

@ -0,0 +1,24 @@
[Database]
Host = 127.0.0.1
Port = 3306
Database = sapphire
Username = sapphire
Password =
SyncThreads = 2
AsyncThreads = 2
[Parameters]
ServerSecret = default
DataPath = C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack
WorldID = 67
[Network]
; 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

8
config/lobby.ini.default Normal file
View file

@ -0,0 +1,8 @@
[Lobby]
AllowNoSessionConnect = false
WorldName = Sapphire
DefaultGMRank = 255
[Network]
ListenIp = 0.0.0.0
ListenPort = 54994

20
config/world.ini.default Normal file
View file

@ -0,0 +1,20 @@
[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]
ListenIp = 0.0.0.0
ListenPort = 54992
DisconnectTimeout = 20
[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/config.ini
[Housing]
; Set the default estate name. {0} will be replaced with the plot number
DefaultEstateName = Estate ${0}

View file

@ -1,9 +1,9 @@
#ifndef SAPPHIRE_CONFIGDEF_H #ifndef SAPPHIRE_CONFIGDEF_H
#define SAPPHIRE_CONFIGDEF_H #define SAPPHIRE_CONFIGDEF_H
namespace Sapphire::Common namespace Sapphire::Common::Config
{ {
struct Configuration struct GlobalConfig
{ {
struct Database struct Database
{ {
@ -14,16 +14,16 @@ namespace Sapphire::Common
std::string password; std::string password;
uint8_t syncThreads; uint8_t syncThreads;
uint8_t asyncThreads; uint8_t asyncThreads;
} database; } database;
struct GlobalParameters struct Parameters
{ {
std::string serverSecret; std::string serverSecret;
std::string dataPath; std::string dataPath;
} globalParameters; uint16_t worldID;
} parameters;
struct GlobalNetwork struct Network
{ {
std::string zoneHost; std::string zoneHost;
uint16_t zonePort; uint16_t zonePort;
@ -33,31 +33,26 @@ namespace Sapphire::Common
std::string restHost; std::string restHost;
uint16_t restPort; uint16_t restPort;
} globalNetwork; } network;
};
struct Lobby
{
uint16_t worldID;
bool allowNoSessionConnect;
std::string worldName;
} lobby;
struct LobbyNetwork struct WorldConfig
{
GlobalConfig global;
struct Network
{ {
std::string listenIp; std::string listenIp;
uint16_t listenPort; uint16_t listenPort;
} lobbyNetwork;
struct CharacterCreation uint16_t disconnectTimeout;
{ } network;
uint8_t defaultGMRank;
} characterCreation;
struct RestNetwork struct Housing
{ {
std::string listenIP; std::string defaultEstateName;
uint16_t listenPort; } housing;
} restNetwork;
struct Scripts struct Scripts
{ {
@ -66,30 +61,34 @@ namespace Sapphire::Common
bool hotSwap; bool hotSwap;
} scripts; } scripts;
std::string motd;
};
struct LobbyConfig
{
GlobalConfig global;
struct Network struct Network
{
Network() :
disconnectTimeout( 20 )
{}
uint16_t disconnectTimeout;
} network;
struct ZoneNetwork
{ {
std::string listenIp; std::string listenIp;
uint16_t listenPort; uint16_t listenPort;
} zoneNetwork; } network;
struct General bool allowNoSessionConnect;
{ std::string worldName;
std::string motd;
} general;
struct Housing uint8_t defaultGMRank;
};
struct ApiConfig
{
GlobalConfig global;
struct Network
{ {
std::string defaultEstateName; std::string listenIP;
} housing; uint16_t listenPort;
} network;
}; };
} }

View file

@ -31,6 +31,45 @@ bool Sapphire::ConfigMgr::loadConfig( const std::string& configName )
return true; return true;
} }
bool Sapphire::ConfigMgr::loadGlobalConfig( Common::Config::GlobalConfig& config, const string& configName )
{
auto configFile = fs::path( fs::path( m_configFolderRoot ) / configName );
if( !fs::exists( configFile ) )
{
copyDefaultConfig( configName );
return false;
}
m_pInih = std::make_unique< INIReader >( configFile.string() );
if( m_pInih->ParseError() < 0 )
return false;
// database
config.database.host = getValue< std::string >( "Database", "Host", "127.0.0.1" );
config.database.port = getValue< uint16_t >( "Database", "Port", 3306 );
config.database.database = getValue< std::string >( "Database", "Database", "sapphire" );
config.database.username = getValue< std::string >( "Database", "Username", "sapphire" );
config.database.password = getValue< std::string >( "Database", "Password", "" );
config.database.syncThreads = getValue< uint8_t >( "Database", "SyncThreads", 2 );
config.database.asyncThreads = getValue< uint8_t >( "Database", "AsyncThreads", 2 );
// params
config.parameters.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.parameters.worldID = getValue< uint16_t >( "Parameters", "WorldID", 67 );
// network
config.network.zoneHost = getValue< std::string >( "Network", "ZoneHost", "127.0.0.1" );
config.network.zonePort = getValue< uint16_t >( "Network", "ZonePort", 54992 );
config.network.lobbyHost = getValue< std::string >( "Network", "LobbyHost", "127.0.0.1" );
config.network.lobbyPort = getValue< uint16_t >( "Network", "LobbyPort", 54994 );
config.network.restHost = getValue< std::string >( "Network", "RestHost", "127.0.0.1" );
config.network.restPort = getValue< uint16_t >( "Network", "RestPort", 80 );
return true;
}
bool Sapphire::ConfigMgr::copyDefaultConfig( const std::string& configName ) bool Sapphire::ConfigMgr::copyDefaultConfig( const std::string& configName )
{ {
fs::path configPath( m_configFolderRoot ); fs::path configPath( m_configFolderRoot );
@ -51,27 +90,6 @@ void Sapphire::ConfigMgr::initConfigData()
{ {
m_pConfig = std::make_shared< Common::Configuration >(); m_pConfig = std::make_shared< Common::Configuration >();
// database
m_pConfig->database.host = getValue< std::string >( "Database", "Host", "127.0.0.1" );
m_pConfig->database.port = getValue< uint16_t >( "Database", "Port", 3306 );
m_pConfig->database.database = getValue< std::string >( "Database", "Database", "sapphire" );
m_pConfig->database.username = getValue< std::string >( "Database", "Username", "sapphire" );
m_pConfig->database.password = getValue< std::string >( "Database", "Password", "" );
m_pConfig->database.syncThreads = getValue< uint8_t >( "Database", "SyncThreads", 2 );
m_pConfig->database.asyncThreads = getValue< uint8_t >( "Database", "AsyncThreads", 2 );
// global parameters
m_pConfig->globalParameters.dataPath = getValue< std::string >( "GlobalParameters", "DataPath", "C:\\SquareEnix\\FINAL FANTASY XIV - A Realm Reborn\\game\\sqpack" );
m_pConfig->globalParameters.serverSecret = getValue< std::string >( "GlobalParameters", "ServerSecret", "default" );
// global network
m_pConfig->globalNetwork.zoneHost = getValue< std::string >( "GlobalNetwork", "ZoneHost", "127.0.0.1" );
m_pConfig->globalNetwork.zonePort = getValue< uint16_t >( "GlobalNetwork", "ZonePort", 54992 );
m_pConfig->globalNetwork.lobbyHost = getValue< std::string >( "GlobalNetwork", "LobbyHost", "127.0.0.1" );
m_pConfig->globalNetwork.lobbyPort = getValue< uint16_t >( "GlobalNetwork", "LobbyPort", 54994 );
m_pConfig->globalNetwork.restHost = getValue< std::string >( "GlobalNetwork", "RestHost", "127.0.0.1" );
m_pConfig->globalNetwork.restPort = getValue< uint16_t >( "GlobalNetwork", "RestPort", 80 );
// lobby // lobby
m_pConfig->lobby.worldID = getValue< uint16_t >( "Lobby", "WorldID", 67 ); m_pConfig->lobby.worldID = getValue< uint16_t >( "Lobby", "WorldID", 67 );
m_pConfig->lobby.allowNoSessionConnect = getValue< bool >( "Lobby", "AllowNoSessionConnect", false ); m_pConfig->lobby.allowNoSessionConnect = getValue< bool >( "Lobby", "AllowNoSessionConnect", false );

View file

@ -19,6 +19,7 @@ namespace Sapphire
using ConfigurationPtr = std::shared_ptr< Common::Configuration >; using ConfigurationPtr = std::shared_ptr< Common::Configuration >;
bool loadConfig( const std::string& configName ); bool loadConfig( const std::string& configName );
bool loadGlobalConfig( Common::Config::GlobalConfig& config, const string& configName = "config.ini" );
template<class T> struct always_false : std::false_type {}; template<class T> struct always_false : std::false_type {};