diff --git a/include/server.h b/include/server.h index 4e7d823..d9597fb 100644 --- a/include/server.h +++ b/include/server.h @@ -49,6 +49,7 @@ class Server : public QObject { void updateCharsTaken(AreaData* area); void broadcast(AOPacket packet, int area_index); void broadcast(AOPacket packet); + QString getServerName(); QVector clients; @@ -59,6 +60,7 @@ class Server : public QObject { QStringList music_list; QStringList backgrounds; DBManager* db_manager; + QString server_name; signals: diff --git a/src/aoclient.cpp b/src/aoclient.cpp index abe7ccc..215d539 100644 --- a/src/aoclient.cpp +++ b/src/aoclient.cpp @@ -216,26 +216,17 @@ void AOClient::setHwid(QString p_hwid) void AOClient::sendServerMessage(QString message) { - QSettings config("config/config.ini", QSettings::IniFormat); - config.beginGroup("Options"); - QString hostname = config.value("hostname", "Server").toString(); - sendPacket("CT", {hostname, message, "1"}); + sendPacket("CT", {server->getServerName(), message, "1"}); } void AOClient::sendServerMessageArea(QString message) { - QSettings config("config/config.ini", QSettings::IniFormat); - config.beginGroup("Options"); - QString hostname = config.value("hostname", "Server").toString(); - server->broadcast(AOPacket("CT", {hostname, message, "1"}), current_area); + server->broadcast(AOPacket("CT", {server->getServerName(), message, "1"}), current_area); } void AOClient::sendServerBroadcast(QString message) { - QSettings config("config/config.ini", QSettings::IniFormat); - config.beginGroup("Options"); - QString hostname = config.value("hostname", "Server").toString(); - server->broadcast(AOPacket("CT", {hostname, message, "1"})); + server->broadcast(AOPacket("CT", {server->getServerName(), message, "1"})); } bool AOClient::checkAuth(unsigned long long acl_mask) diff --git a/src/server.cpp b/src/server.cpp index 690a4f2..d0a038b 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -147,6 +147,14 @@ 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; +} + AOClient* Server::getClient(QString ipid) { for (AOClient* client : clients) {