Add method to configure the server name

+ Remove some redundant code to make use of this method
This commit is contained in:
Salanto 2021-02-28 00:45:54 +01:00
parent 2422287753
commit 11066acdb3
3 changed files with 13 additions and 12 deletions

View File

@ -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<AOClient*> clients;
@ -59,6 +60,7 @@ class Server : public QObject {
QStringList music_list;
QStringList backgrounds;
DBManager* db_manager;
QString server_name;
signals:

View File

@ -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)

View File

@ -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) {