diff --git a/CMakeLists.txt b/CMakeLists.txt index 721140a6..8a4c5140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -90,7 +90,7 @@ make_directory(${CMAKE_BINARY_DIR}/locale) make_directory(${CMAKE_BINARY_DIR}/logs) # Copy resource files on first build -set(RESOURCE_FILES "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf") +set(RESOURCE_FILES "sharedconfig.ini" "authconfig.ini" "chatconfig.ini" "worldconfig.ini" "masterconfig.ini" "blacklist.dcf") foreach(resource_file ${RESOURCE_FILES}) if (NOT EXISTS ${PROJECT_BINARY_DIR}/${resource_file}) configure_file( diff --git a/README.md b/README.md index dfae2bab..cdb1d343 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ Initial setup can vary drastically based on which operating system or distributi #### Configuration -After the server has been built there should be four `ini` files in the build director: `authconfig.ini`, `chatconfig.ini`, `masterconfig.ini`, and `worldconfig.ini`. Go through them and fill in the database credentials and configure other settings if necessary. +After the server has been built there should be four `ini` files in the build director: `sharedconfig.ini`, `authconfig.ini`, `chatconfig.ini`, `masterconfig.ini`, and `worldconfig.ini`. Go through them and fill in the database credentials and configure other settings if necessary. #### Migrations diff --git a/dCommon/dConfig.cpp b/dCommon/dConfig.cpp index 9750238a..c22c91cc 100644 --- a/dCommon/dConfig.cpp +++ b/dCommon/dConfig.cpp @@ -12,6 +12,15 @@ dConfig::dConfig(const std::string& filepath) { if (line[0] != '#') ProcessLine(line); } } + + std::ifstream sharedConfig("sharedconfig.ini", std::ios::in); + if (!sharedConfig.good()) return; + + while (std::getline(sharedConfig, line)) { + if (line.length() > 0) { + if (line[0] != '#') ProcessLine(line); + } + } } dConfig::~dConfig(void) { @@ -40,6 +49,12 @@ void dConfig::ProcessLine(const std::string& line) { if (!seglist[1].empty() && seglist[1][seglist[1].size() - 1] == '\r') seglist[1].erase(seglist[1].size() - 1); + for (const auto& key : m_Keys) { + if (seglist[0] == key) { + return; // first loaded key is preferred due to loading shared config secondarily + } + } + m_Keys.push_back(seglist[0]); m_Values.push_back(seglist[1]); } diff --git a/resources/authconfig.ini b/resources/authconfig.ini index 40ca146e..ec414bc0 100644 --- a/resources/authconfig.ini +++ b/resources/authconfig.ini @@ -1,27 +1,6 @@ -# MySQL connection info: -mysql_host= -mysql_database= -mysql_username= -mysql_password= - -# The public facing IP address. Can be 'localhost' for locally hosted servers -external_ip=localhost - # Port number. The client has the authserver port hardcoded to 1001 port=1001 -# Where to put crashlogs -dump_folder= - -# How many clients can be connected to the server at once -max_clients=999 - -# 0 or 1, should log to console -log_to_console=1 - -# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation -log_debug_statements=0 - # 0 or 1, should ignore playkeys # If 1 everyone with an account will be able to login, regardless of if they have a key or not dont_use_keys=0 diff --git a/resources/chatconfig.ini b/resources/chatconfig.ini index f30fb8f9..26b26cc7 100644 --- a/resources/chatconfig.ini +++ b/resources/chatconfig.ini @@ -1,26 +1,2 @@ -# MySQL connection info: -mysql_host= -mysql_database= -mysql_username= -mysql_password= - -# The public facing IP address. Can be 'localhost' for locally hosted servers -external_ip=localhost - # Port number port=2005 - -# Where to put crashlogs -dump_folder= - -# How many clients can be connected to the server at once -max_clients=999 - -# 0 or 1, should log to console -log_to_console=1 - -# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation -log_debug_statements=0 - -# 0 or 1, should not compile chat hash map to file -dont_generate_dcf=0 diff --git a/resources/masterconfig.ini b/resources/masterconfig.ini index c2d884a5..4864d8cb 100644 --- a/resources/masterconfig.ini +++ b/resources/masterconfig.ini @@ -1,12 +1,3 @@ -# MySQL connection info: -mysql_host= -mysql_database= -mysql_username= -mysql_password= - -# The public facing IP address. Can be 'localhost' for locally hosted servers -external_ip=localhost - # The internal ip of the master server master_ip=localhost @@ -26,17 +17,5 @@ use_sudo_chat=0 # Use sudo when launching world servers use_sudo_world=0 -# Where to put crashlogs -dump_folder= - -# How many clients can be connected to the server at once -max_clients=999 - -# 0 or 1, should log to console -log_to_console=1 - -# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation -log_debug_statements=0 - # 0 or 1, should autostart auth, chat, and char servers prestart_servers=1 diff --git a/resources/sharedconfig.ini b/resources/sharedconfig.ini new file mode 100644 index 00000000..1a377d28 --- /dev/null +++ b/resources/sharedconfig.ini @@ -0,0 +1,23 @@ +# MySQL connection info: +mysql_host= +mysql_database= +mysql_username= +mysql_password= + +# 0 or 1, should log to console +log_to_console=1 + +# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation +log_debug_statements=0 + +# The public facing IP address. Can be 'localhost' for locally hosted servers +external_ip=localhost + +# 0 or 1, should not compile chat hash map to file +dont_generate_dcf=0 + +# How many clients can be connected to the server at once +max_clients=999 + +# Where to put crashlogs +dump_folder= diff --git a/resources/worldconfig.ini b/resources/worldconfig.ini index 931da28c..ee6b6651 100644 --- a/resources/worldconfig.ini +++ b/resources/worldconfig.ini @@ -1,9 +1,3 @@ -# MySQL connection info: -mysql_host= -mysql_database= -mysql_username= -mysql_password= - # URL to the code repository for the hosted server # If you fork this repository and/or make changes to the code, reflect that here to comply with AGPLv3 source=https://github.com/DarkflameUniverse/DarkflameServer @@ -11,21 +5,6 @@ source=https://github.com/DarkflameUniverse/DarkflameServer # Port to the chat server, same as in chatconfig.ini chat_server_port=2005 -# Where to put crashlogs -dump_folder= - -# How many clients can be connected to the server at once -max_clients=999 - -# 0 or 1, should log to console -log_to_console=1 - -# 0 or 1, should log debug (developer only) statements to console for debugging, not needed for normal operation -log_debug_statements=0 - -# 0 or 1, should not compile chat hash map to file -dont_generate_dcf=0 - # 0 or 1, should disable chat disable_chat=0 @@ -63,4 +42,4 @@ pets_take_imagination=1 # If you would like to increase the maximum number of best friends a player can have on the server # Change the value below to what you would like this to be (5 is live accurate) -max_number_of_best_friends=5 \ No newline at end of file +max_number_of_best_friends=5