Add a new method of loading values from config.ini
- Centralizes the loading of values from config.ini, loading them all in at server start and holding them in memory. - Removes all other methods of loading config.ini values and replaces them with references to these central values. - Removes getServerName() and getDiceValue()
This commit is contained in:
		
							parent
							
								
									cff51674bb
								
							
						
					
					
						commit
						86c25555b2
					
				| @ -1399,6 +1399,13 @@ class AOClient : public QObject { | |||||||
|      */ |      */ | ||||||
|     void cmd8Ball(int argc, QStringList argv); |     void cmd8Ball(int argc, QStringList argv); | ||||||
| 
 | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief Reloads all server configuration files. | ||||||
|  |      * | ||||||
|  |      * @details No arguments. | ||||||
|  |      */ | ||||||
|  |     void cmdReload(int argc, QStringList argv); | ||||||
|  | 
 | ||||||
|     ///@}
 |     ///@}
 | ||||||
| 
 | 
 | ||||||
|     /**
 |     /**
 | ||||||
|  | |||||||
| @ -282,6 +282,11 @@ class AreaData : public QObject { | |||||||
|      * @brief The last IC packet sent in an area. |      * @brief The last IC packet sent in an area. | ||||||
|      */ |      */ | ||||||
|     QStringList last_ic_message; |     QStringList last_ic_message; | ||||||
|  | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief The value of logger in config.ini. | ||||||
|  |      */ | ||||||
|  |     QString log_type; | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| #endif // AREA_DATA_H
 | #endif // AREA_DATA_H
 | ||||||
|  | |||||||
| @ -125,24 +125,6 @@ class Server : public QObject { | |||||||
|      */ |      */ | ||||||
|     void broadcast(AOPacket packet); |     void broadcast(AOPacket packet); | ||||||
| 
 | 
 | ||||||
|     /**
 |  | ||||||
|      * @brief Returns the server's name according to the configuration file. |  | ||||||
|      * |  | ||||||
|      * @return See brief description. |  | ||||||
|      */ |  | ||||||
|     QString getServerName(); |  | ||||||
| 
 |  | ||||||
|     /**
 |  | ||||||
|      * @brief Returns some value regarding the @ref AOClient::diceThrower "dice thrower commands". |  | ||||||
|      * |  | ||||||
|      * @param value_type `max_value` for the maximum amount of faces a die may have, |  | ||||||
|      * `max_dice` for the maximum amount of dice that may be thrown at once. |  | ||||||
|      * |  | ||||||
|      * @return The associated value if it is found in the configuration file under the "Dice" section, |  | ||||||
|      * or `100` if not. |  | ||||||
|      */ |  | ||||||
|     int getDiceValue(QString value_type); |  | ||||||
| 
 |  | ||||||
|     /**
 |     /**
 | ||||||
|      * @brief Returns the character's character ID (= their index in the character list). |      * @brief Returns the character's character ID (= their index in the character list). | ||||||
|      * |      * | ||||||
| @ -199,6 +181,10 @@ class Server : public QObject { | |||||||
|      */ |      */ | ||||||
|     DBManager* db_manager; |     DBManager* db_manager; | ||||||
| 
 | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief The max amount of players on the server. | ||||||
|  |      */ | ||||||
|  |     QString max_players; | ||||||
|     /**
 |     /**
 | ||||||
|      * @brief The user-facing server name. |      * @brief The user-facing server name. | ||||||
|      * |      * | ||||||
| @ -211,11 +197,43 @@ class Server : public QObject { | |||||||
|      */ |      */ | ||||||
|     QString MOTD; |     QString MOTD; | ||||||
| 
 | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief The authorization type of the server. | ||||||
|  |      * | ||||||
|  |      * @details In simple mode, the modpass stored in config.ini is used for moderator logins. In advanced mode, logins found in the database are used. | ||||||
|  |      */ | ||||||
|  |     QString auth_type; | ||||||
|  | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief The modpass for moderator login with simple auth_type. | ||||||
|  |      */ | ||||||
|  |     QString modpass; | ||||||
|  | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief The amount of subscripts zalgo is stripped by. | ||||||
|  |      */ | ||||||
|  |     int zalgo_tolerance; | ||||||
|  | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief The highest value dice can have. | ||||||
|  |      */ | ||||||
|  |     uint dice_value; | ||||||
|  | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief The max amount of dice that can be rolled at once. | ||||||
|  |      */ | ||||||
|  |     int max_dice; | ||||||
|  | 
 | ||||||
|     /**
 |     /**
 | ||||||
|      * @brief The server-wide global timer. |      * @brief The server-wide global timer. | ||||||
|      */ |      */ | ||||||
|     QTimer* timer; |     QTimer* timer; | ||||||
| 
 | 
 | ||||||
|  |     /**
 | ||||||
|  |      * @brief Loads values from config.ini. | ||||||
|  |      */ | ||||||
|  |     void loadServerConfig(); | ||||||
|  | 
 | ||||||
|     /**
 |     /**
 | ||||||
|      * @brief Loads the configuration files for commands into stringlists. |      * @brief Loads the configuration files for commands into stringlists. | ||||||
|      */ |      */ | ||||||
|  | |||||||
| @ -276,17 +276,17 @@ void AOClient::calculateIpid() | |||||||
| 
 | 
 | ||||||
| void AOClient::sendServerMessage(QString message) | void AOClient::sendServerMessage(QString message) | ||||||
| { | { | ||||||
|     sendPacket("CT", {server->getServerName(), message, "1"}); |     sendPacket("CT", {server->server_name, message, "1"}); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AOClient::sendServerMessageArea(QString message) | void AOClient::sendServerMessageArea(QString message) | ||||||
| { | { | ||||||
|     server->broadcast(AOPacket("CT", {server->getServerName(), message, "1"}), current_area); |     server->broadcast(AOPacket("CT", {server->server_name, message, "1"}), current_area); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void AOClient::sendServerBroadcast(QString message) | void AOClient::sendServerBroadcast(QString message) | ||||||
| { | { | ||||||
|     server->broadcast(AOPacket("CT", {server->getServerName(), message, "1"})); |     server->broadcast(AOPacket("CT", {server->server_name, message, "1"})); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| bool AOClient::checkAuth(unsigned long long acl_mask) | bool AOClient::checkAuth(unsigned long long acl_mask) | ||||||
| @ -300,14 +300,11 @@ bool AOClient::checkAuth(unsigned long long acl_mask) | |||||||
|         else if (!authenticated) { |         else if (!authenticated) { | ||||||
|             return false; |             return false; | ||||||
|         } |         } | ||||||
|         QSettings settings("config/config.ini", QSettings::IniFormat); |         if (server->auth_type == "advanced") { | ||||||
|         settings.beginGroup("Options"); |  | ||||||
|         QString auth_type = settings.value("auth", "simple").toString(); |  | ||||||
|         if (auth_type == "advanced") { |  | ||||||
|             unsigned long long user_acl = server->db_manager->getACL(moderator_name); |             unsigned long long user_acl = server->db_manager->getACL(moderator_name); | ||||||
|             return (user_acl & acl_mask) != 0; |             return (user_acl & acl_mask) != 0; | ||||||
|         } |         } | ||||||
|         else if (auth_type == "simple") { |         else if (server->auth_type == "simple") { | ||||||
|             return authenticated; |             return authenticated; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -42,6 +42,7 @@ AreaData::AreaData(QString p_name, int p_index) : | |||||||
|     QSettings config_ini("config/config.ini", QSettings::IniFormat); |     QSettings config_ini("config/config.ini", QSettings::IniFormat); | ||||||
|     config_ini.beginGroup("Options"); |     config_ini.beginGroup("Options"); | ||||||
|     int log_size = config_ini.value("logbuffer", 50).toInt(); |     int log_size = config_ini.value("logbuffer", 50).toInt(); | ||||||
|  |     log_type = config_ini.value("logger","modcall").toString(); | ||||||
|     config_ini.endGroup(); |     config_ini.endGroup(); | ||||||
|     if (log_size == 0) |     if (log_size == 0) | ||||||
|         log_size = 500; |         log_size = 500; | ||||||
|  | |||||||
| @ -27,21 +27,16 @@ void AOClient::cmdDefault(int argc, QStringList argv) | |||||||
| 
 | 
 | ||||||
| void AOClient::cmdLogin(int argc, QStringList argv) | void AOClient::cmdLogin(int argc, QStringList argv) | ||||||
| { | { | ||||||
|     QSettings config("config/config.ini", QSettings::IniFormat); |  | ||||||
|     config.beginGroup("Options"); |  | ||||||
|     QString modpass = config.value("modpass", "default").toString(); |  | ||||||
|     QString auth_type = config.value("auth", "simple").toString(); |  | ||||||
| 
 |  | ||||||
|     if (authenticated) { |     if (authenticated) { | ||||||
|         sendServerMessage("You are already logged in!"); |         sendServerMessage("You are already logged in!"); | ||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     if (auth_type == "simple") { |     if (server->auth_type == "simple") { | ||||||
|         if (modpass == "") { |         if (server->modpass == "") { | ||||||
|             sendServerMessage("No modpass is set! Please set a modpass before authenticating."); |             sendServerMessage("No modpass is set! Please set a modpass before authenticating."); | ||||||
|         } |         } | ||||||
|         else if(argv[0] == modpass) { |         else if(argv[0] == server->modpass) { | ||||||
|             sendPacket("AUTH", {"1"}); // Client: "You were granted the Disable Modcalls button."
 |             sendPacket("AUTH", {"1"}); // Client: "You were granted the Disable Modcalls button."
 | ||||||
|             sendServerMessage("Logged in as a moderator."); // pre-2.9.1 clients are hardcoded to display the mod UI when this string is sent in OOC
 |             sendServerMessage("Logged in as a moderator."); // pre-2.9.1 clients are hardcoded to display the mod UI when this string is sent in OOC
 | ||||||
|             authenticated = true; |             authenticated = true; | ||||||
| @ -52,7 +47,7 @@ void AOClient::cmdLogin(int argc, QStringList argv) | |||||||
|         } |         } | ||||||
|         server->areas.value(current_area)->logger->logLogin(this, authenticated, "moderator"); |         server->areas.value(current_area)->logger->logLogin(this, authenticated, "moderator"); | ||||||
|     } |     } | ||||||
|     else if (auth_type == "advanced") { |     else if (server->auth_type == "advanced") { | ||||||
|         if (argc < 2) { |         if (argc < 2) { | ||||||
|             sendServerMessage("You must specify a username and a password"); |             sendServerMessage("You must specify a username and a password"); | ||||||
|             return; |             return; | ||||||
| @ -194,11 +189,7 @@ void AOClient::cmdKick(int argc, QStringList argv) | |||||||
| 
 | 
 | ||||||
| void AOClient::cmdChangeAuth(int argc, QStringList argv) | void AOClient::cmdChangeAuth(int argc, QStringList argv) | ||||||
| { | { | ||||||
|     QSettings settings("config/config.ini", QSettings::IniFormat); |     if (server->auth_type == "simple") { | ||||||
|     settings.beginGroup("Options"); |  | ||||||
|     QString auth_type = settings.value("auth", "simple").toString(); |  | ||||||
| 
 |  | ||||||
|     if (auth_type == "simple") { |  | ||||||
|         change_auth_started = true; |         change_auth_started = true; | ||||||
|         sendServerMessage("WARNING!\nThis command will change how logging in as a moderator works.\nOnly proceed if you know what you are doing\nUse the command /rootpass to set the password for your root account."); |         sendServerMessage("WARNING!\nThis command will change how logging in as a moderator works.\nOnly proceed if you know what you are doing\nUse the command /rootpass to set the password for your root account."); | ||||||
|     } |     } | ||||||
| @ -214,6 +205,7 @@ void AOClient::cmdSetRootPass(int argc, QStringList argv) | |||||||
|     QSettings settings("config/config.ini", QSettings::IniFormat); |     QSettings settings("config/config.ini", QSettings::IniFormat); | ||||||
|     settings.beginGroup("Options"); |     settings.beginGroup("Options"); | ||||||
|     settings.setValue("auth", "advanced"); |     settings.setValue("auth", "advanced"); | ||||||
|  |     server->auth_type = "advanced"; | ||||||
| 
 | 
 | ||||||
| #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) | #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) | ||||||
|     qsrand(QDateTime::currentMSecsSinceEpoch()); |     qsrand(QDateTime::currentMSecsSinceEpoch()); | ||||||
| @ -828,14 +820,11 @@ void AOClient::cmdToggleGlobal(int argc, QStringList argv) | |||||||
| void AOClient::cmdMods(int argc, QStringList argv) | void AOClient::cmdMods(int argc, QStringList argv) | ||||||
| { | { | ||||||
|     QStringList entries; |     QStringList entries; | ||||||
|     QSettings config("config/config.ini", QSettings::IniFormat); |  | ||||||
|     config.beginGroup("Options"); |  | ||||||
|     QString auth_type = config.value("auth", "simple").toString(); |  | ||||||
|     int online_count = 0; |     int online_count = 0; | ||||||
|     for (AOClient* client : server->clients) { |     for (AOClient* client : server->clients) { | ||||||
|         if (client->authenticated) { |         if (client->authenticated) { | ||||||
|             entries << "---"; |             entries << "---"; | ||||||
|             if (auth_type != "simple") |             if (server->auth_type != "simple") | ||||||
|                 entries << "Moderator: " + client->moderator_name; |                 entries << "Moderator: " + client->moderator_name; | ||||||
|             entries << "OOC name: " + client->ooc_name; |             entries << "OOC name: " + client->ooc_name; | ||||||
|             entries << "ID: " + QString::number(client->id); |             entries << "ID: " + QString::number(client->id); | ||||||
| @ -1325,8 +1314,8 @@ int AOClient::genRand(int min, int max) | |||||||
| void AOClient::diceThrower(int argc, QStringList argv, RollType type) | void AOClient::diceThrower(int argc, QStringList argv, RollType type) | ||||||
| { | { | ||||||
|     QString sender_name = ooc_name; |     QString sender_name = ooc_name; | ||||||
|     int max_value = server->getDiceValue("max_value"); |     int max_value = server->dice_value; | ||||||
|     int max_dice = server->getDiceValue("max_dice"); |     int max_dice = server->max_dice; | ||||||
|     int bounded_value; |     int bounded_value; | ||||||
|     int bounded_amount; |     int bounded_amount; | ||||||
|     QString dice_results; |     QString dice_results; | ||||||
|  | |||||||
| @ -77,13 +77,10 @@ QString Logger::buildEntry(AOClient *client, QString type, QString message) | |||||||
| 
 | 
 | ||||||
| void Logger::addEntry(QString entry) | void Logger::addEntry(QString entry) | ||||||
| { | { | ||||||
|     QSettings config("config/config.ini", QSettings::IniFormat); |  | ||||||
|     config.beginGroup("Options"); |  | ||||||
|     QString log_type = config.value("logging", "modcall").toString(); |  | ||||||
|     if (buffer.length() < max_length) { |     if (buffer.length() < max_length) { | ||||||
|         buffer.enqueue(entry); |         buffer.enqueue(entry); | ||||||
|         if (log_type == "full") { |         if (area->log_type == "full") { | ||||||
|             flush(); |            flush(); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|     else { |     else { | ||||||
| @ -99,20 +96,20 @@ void Logger::flush() | |||||||
|         dir.mkpath("."); |         dir.mkpath("."); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     QSettings config("config/config.ini", QSettings::IniFormat); |  | ||||||
|     config.beginGroup("Options"); |  | ||||||
|     QString log_type = config.value("logging", "modcall").toString(); |  | ||||||
|     QFile logfile; |     QFile logfile; | ||||||
|     if (log_type == "modcall") { |     if (area->log_type == "modcall") { | ||||||
|         logfile.setFileName(QString("logs/report_%1_%2.log").arg((area->name), (QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss")))); |         logfile.setFileName(QString("logs/report_%1_%2.log").arg((area->name), (QDateTime::currentDateTime().toString("yyyy-MM-dd_hhmmss")))); | ||||||
|     } |     } | ||||||
|     else if (log_type == "full") { |     else if (area->log_type == "full") { | ||||||
|         logfile.setFileName(QString("logs/%1.log").arg(QDate::currentDate().toString("yyyy-MM-dd"))); |         logfile.setFileName(QString("logs/%1.log").arg(QDate::currentDate().toString("yyyy-MM-dd"))); | ||||||
|     } |     } | ||||||
|         if (logfile.open(QIODevice::WriteOnly | QIODevice::Append)) { |     else { | ||||||
|         QTextStream file_stream(&logfile); |         qCritical("Invalid logger set!"); | ||||||
|         while (!buffer.isEmpty()) |     } | ||||||
|             file_stream << buffer.dequeue(); |     if (logfile.open(QIODevice::WriteOnly | QIODevice::Append)) { | ||||||
|  |     QTextStream file_stream(&logfile); | ||||||
|  |     while (!buffer.isEmpty()) | ||||||
|  |         file_stream << buffer.dequeue(); | ||||||
|         } |         } | ||||||
|     logfile.close(); |     logfile.close(); | ||||||
| } | } | ||||||
|  | |||||||
| @ -37,10 +37,7 @@ void AOClient::pktHardwareId(AreaData* area, int argc, QStringList argv, AOPacke | |||||||
| 
 | 
 | ||||||
| void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacket packet) | void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacket packet) | ||||||
| { | { | ||||||
|     QSettings config("config/config.ini", QSettings::IniFormat); | 
 | ||||||
|     config.beginGroup("Options"); |  | ||||||
|     QString max_players = config.value("max_players").toString(); |  | ||||||
|     config.endGroup(); |  | ||||||
| 
 | 
 | ||||||
|     // Full feature list as of AO 2.8.5
 |     // Full feature list as of AO 2.8.5
 | ||||||
|     // The only ones that are critical to ensuring the server works are
 |     // The only ones that are critical to ensuring the server works are
 | ||||||
| @ -64,7 +61,7 @@ void AOClient::pktSoftwareId(AreaData* area, int argc, QStringList argv, AOPacke | |||||||
|         version.minor = match.captured(3).toInt(); |         version.minor = match.captured(3).toInt(); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     sendPacket("PN", {QString::number(server->player_count), max_players}); |     sendPacket("PN", {QString::number(server->player_count), server->max_players}); | ||||||
|     sendPacket("FL", feature_list); |     sendPacket("FL", feature_list); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -181,7 +178,7 @@ void AOClient::pktOocChat(AreaData* area, int argc, QStringList argv, AOPacket p | |||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     ooc_name = dezalgo(argv[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), ""); // no fucky wucky shit here
 |     ooc_name = dezalgo(argv[0]).replace(QRegExp("\\[|\\]|\\{|\\}|\\#|\\$|\\%|\\&"), ""); // no fucky wucky shit here
 | ||||||
|     if (ooc_name.isEmpty() || ooc_name == server->getServerName()) // impersonation & empty name protection
 |     if (ooc_name.isEmpty() || ooc_name == server->server_name) // impersonation & empty name protection
 | ||||||
|         return; |         return; | ||||||
|      |      | ||||||
|     QString message = dezalgo(argv[1]); |     QString message = dezalgo(argv[1]); | ||||||
| @ -629,14 +626,7 @@ AOPacket AOClient::validateIcPacket(AOPacket packet) | |||||||
| 
 | 
 | ||||||
| QString AOClient::dezalgo(QString p_text) | QString AOClient::dezalgo(QString p_text) | ||||||
| { | { | ||||||
|     QSettings config("config/config.ini", QSettings::IniFormat); |     QRegExp rxp("([\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f\u115f\u1160\u3164]{" + QRegExp::escape(QString::number(server->zalgo_tolerance)) + ",})"); | ||||||
|     config.beginGroup("Options"); |  | ||||||
|     bool zalgo_tolerance_conversion_success; |  | ||||||
|     int zalgo_tolerance = config.value("zalgo_tolerance", "3").toInt(&zalgo_tolerance_conversion_success); |  | ||||||
|     if (!zalgo_tolerance_conversion_success) |  | ||||||
|         zalgo_tolerance = 3; |  | ||||||
| 
 |  | ||||||
|     QRegExp rxp("([\u0300-\u036f\u1ab0-\u1aff\u1dc0-\u1dff\u20d0-\u20ff\ufe20-\ufe2f\u115f\u1160\u3164]{" + QRegExp::escape(QString::number(zalgo_tolerance)) + ",})"); |  | ||||||
|     QString filtered = p_text.replace(rxp, ""); |     QString filtered = p_text.replace(rxp, ""); | ||||||
|     return filtered; |     return filtered; | ||||||
| } | } | ||||||
|  | |||||||
| @ -51,7 +51,8 @@ void Server::start() | |||||||
|         qDebug() << "Server listening on" << port; |         qDebug() << "Server listening on" << port; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     MOTD = config.value("motd","MOTD is not set.").toString(); |     loadServerConfig(); | ||||||
|  |     loadCommandConfig(); | ||||||
| 
 | 
 | ||||||
|     proxy = new WSProxy(port, ws_port, this); |     proxy = new WSProxy(port, ws_port, this); | ||||||
|     if(ws_port != -1) |     if(ws_port != -1) | ||||||
| @ -96,7 +97,6 @@ void Server::start() | |||||||
|         QString area_name = raw_area_names[i]; |         QString area_name = raw_area_names[i]; | ||||||
|         areas.insert(i, new AreaData(area_name, i)); |         areas.insert(i, new AreaData(area_name, i)); | ||||||
|     } |     } | ||||||
|     loadCommandConfig(); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| void Server::clientConnected() | void Server::clientConnected() | ||||||
| @ -169,24 +169,6 @@ void Server::broadcast(AOPacket packet) | |||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| QString Server::getServerName() |  | ||||||
| { |  | ||||||
|     QSettings settings("config/config.ini", QSettings::IniFormat); |  | ||||||
|     settings.beginGroup("Options"); |  | ||||||
|     QString server_name = settings.value("server_name", "Akashi").toString(); |  | ||||||
|     return server_name; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| int Server::getDiceValue(QString value_type) |  | ||||||
| { |  | ||||||
|     QSettings settings("config/config.ini", QSettings::IniFormat); |  | ||||||
| 
 |  | ||||||
|     settings.beginGroup("Dice"); |  | ||||||
|     int value = settings.value(value_type, "100").toUInt(); |  | ||||||
|     settings.endGroup(); |  | ||||||
|     return value; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| QList<AOClient*> Server::getClientsByIpid(QString ipid) | QList<AOClient*> Server::getClientsByIpid(QString ipid) | ||||||
| { | { | ||||||
|     QList<AOClient*> return_clients; |     QList<AOClient*> return_clients; | ||||||
| @ -235,6 +217,29 @@ QStringList Server::loadConfigFile(QString filename) | |||||||
|     return stringlist; |     return stringlist; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | void Server::loadServerConfig() | ||||||
|  | { | ||||||
|  |     QSettings config("config/config.ini", QSettings::IniFormat); | ||||||
|  |     config.beginGroup("Options"); | ||||||
|  |     //Load config.ini values
 | ||||||
|  |     max_players = config.value("max_players","100").toString(); | ||||||
|  |     server_name = config.value("server_name","An Unnamed Server").toString(); | ||||||
|  |     MOTD = config.value("motd","MOTD is not set.").toString(); | ||||||
|  |     auth_type = config.value("auth","simple").toString(); | ||||||
|  |     modpass = config.value("modpass","").toString(); | ||||||
|  |     bool zalgo_tolerance_conversion_success; | ||||||
|  |         zalgo_tolerance = config.value("zalgo_tolerance", "3").toInt(&zalgo_tolerance_conversion_success); | ||||||
|  |         if (!zalgo_tolerance_conversion_success) | ||||||
|  |             zalgo_tolerance = 3; | ||||||
|  |     config.endGroup(); | ||||||
|  | 
 | ||||||
|  |     //Load dice values
 | ||||||
|  |     config.beginGroup("Dice"); | ||||||
|  |     dice_value = config.value("value_type", "100").toUInt(); | ||||||
|  |     max_dice = config.value("max_dice","100").toInt(); | ||||||
|  |     config.endGroup(); | ||||||
|  | } | ||||||
|  | 
 | ||||||
| Server::~Server() | Server::~Server() | ||||||
| { | { | ||||||
|     for (AOClient* client : clients) { |     for (AOClient* client : clients) { | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 MangosArentLiterature
						MangosArentLiterature