From 5c38054b42617c3ef78476df90a454fd695d4efb Mon Sep 17 00:00:00 2001 From: cow-face Date: Wed, 6 Jul 2022 15:00:12 -0500 Subject: [PATCH 1/2] added server nickname support --- bin/config_sample/config.ini | 5 ++++- bin_tests/config/config.ini | 5 ++++- core/include/config_manager.h | 7 +++++++ core/src/aoclient.cpp | 6 +++--- core/src/config_manager.cpp | 4 ++++ 5 files changed, 22 insertions(+), 5 deletions(-) diff --git a/bin/config_sample/config.ini b/bin/config_sample/config.ini index aa550251..79bd560a 100644 --- a/bin/config_sample/config.ini +++ b/bin/config_sample/config.ini @@ -8,9 +8,12 @@ port=27016 ; The server description that will appear on the master server. server_description=This is a placeholder server description. Tell the world of AO who you are here! -; The server's name. This appears both on the master server, and in messages sent to users by the server. +; The server's name. This appears on the master server. server_name=An Unnamed Server +; The server's nickname. This appears in messages sent to users by the server. +server_nick=NickName + ; The server's Message of the Day. This will be sent in OOC to joining users. motd=MOTD is not set. diff --git a/bin_tests/config/config.ini b/bin_tests/config/config.ini index aa550251..79bd560a 100644 --- a/bin_tests/config/config.ini +++ b/bin_tests/config/config.ini @@ -8,9 +8,12 @@ port=27016 ; The server description that will appear on the master server. server_description=This is a placeholder server description. Tell the world of AO who you are here! -; The server's name. This appears both on the master server, and in messages sent to users by the server. +; The server's name. This appears on the master server. server_name=An Unnamed Server +; The server's nickname. This appears in messages sent to users by the server. +server_nick=NickName + ; The server's Message of the Day. This will be sent in OOC to joining users. motd=MOTD is not set. diff --git a/core/include/config_manager.h b/core/include/config_manager.h index 434eda9f..5a5e9a54 100644 --- a/core/include/config_manager.h +++ b/core/include/config_manager.h @@ -150,6 +150,13 @@ class ConfigManager */ static QString serverName(); + /** + * @brief Returns the server nickname. + * + * @return See short description. + */ + static QString serverNick(); + /** * @brief Returns the server's Message of the Day. * diff --git a/core/src/aoclient.cpp b/core/src/aoclient.cpp index 9866b557..c5127223 100644 --- a/core/src/aoclient.cpp +++ b/core/src/aoclient.cpp @@ -433,17 +433,17 @@ void AOClient::calculateIpid() void AOClient::sendServerMessage(QString message) { - sendPacket("CT", {ConfigManager::serverName(), message, "1"}); + sendPacket("CT", {ConfigManager::serverNick(), message, "1"}); } void AOClient::sendServerMessageArea(QString message) { - server->broadcast(AOPacket("CT", {ConfigManager::serverName(), message, "1"}), m_current_area); + server->broadcast(AOPacket("CT", {ConfigManager::serverNick(), message, "1"}), m_current_area); } void AOClient::sendServerBroadcast(QString message) { - server->broadcast(AOPacket("CT", {ConfigManager::serverName(), message, "1"})); + server->broadcast(AOPacket("CT", {ConfigManager::serverNick(), message, "1"})); } bool AOClient::checkPermission(ACLRole::Permission f_permission) const diff --git a/core/src/config_manager.cpp b/core/src/config_manager.cpp index 07595fab..812d4c98 100644 --- a/core/src/config_manager.cpp +++ b/core/src/config_manager.cpp @@ -301,6 +301,10 @@ QString ConfigManager::serverName() return m_settings->value("Options/server_name", "An Unnamed Server").toString(); } +QString ConfigManager::serverNick() { + return m_settings->value("Options/server_nick", "").toString(); +} + QString ConfigManager::motd() { return m_settings->value("Options/motd", "MOTD not set").toString(); From 9f890fdc07defac173361af7653e6517121782d7 Mon Sep 17 00:00:00 2001 From: cow-face Date: Wed, 6 Jul 2022 15:02:25 -0500 Subject: [PATCH 2/2] clang formatting --- core/src/config_manager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/src/config_manager.cpp b/core/src/config_manager.cpp index 812d4c98..b11cc926 100644 --- a/core/src/config_manager.cpp +++ b/core/src/config_manager.cpp @@ -301,7 +301,8 @@ QString ConfigManager::serverName() return m_settings->value("Options/server_name", "An Unnamed Server").toString(); } -QString ConfigManager::serverNick() { +QString ConfigManager::serverNick() +{ return m_settings->value("Options/server_nick", "").toString(); }