Add method to configure the server name
+ Remove some redundant code to make use of this method
This commit is contained in:
parent
2422287753
commit
11066acdb3
@ -49,6 +49,7 @@ class Server : public QObject {
|
|||||||
void updateCharsTaken(AreaData* area);
|
void updateCharsTaken(AreaData* area);
|
||||||
void broadcast(AOPacket packet, int area_index);
|
void broadcast(AOPacket packet, int area_index);
|
||||||
void broadcast(AOPacket packet);
|
void broadcast(AOPacket packet);
|
||||||
|
QString getServerName();
|
||||||
|
|
||||||
QVector<AOClient*> clients;
|
QVector<AOClient*> clients;
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ class Server : public QObject {
|
|||||||
QStringList music_list;
|
QStringList music_list;
|
||||||
QStringList backgrounds;
|
QStringList backgrounds;
|
||||||
DBManager* db_manager;
|
DBManager* db_manager;
|
||||||
|
QString server_name;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -216,26 +216,17 @@ void AOClient::setHwid(QString p_hwid)
|
|||||||
|
|
||||||
void AOClient::sendServerMessage(QString message)
|
void AOClient::sendServerMessage(QString message)
|
||||||
{
|
{
|
||||||
QSettings config("config/config.ini", QSettings::IniFormat);
|
sendPacket("CT", {server->getServerName(), message, "1"});
|
||||||
config.beginGroup("Options");
|
|
||||||
QString hostname = config.value("hostname", "Server").toString();
|
|
||||||
sendPacket("CT", {hostname, message, "1"});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::sendServerMessageArea(QString message)
|
void AOClient::sendServerMessageArea(QString message)
|
||||||
{
|
{
|
||||||
QSettings config("config/config.ini", QSettings::IniFormat);
|
server->broadcast(AOPacket("CT", {server->getServerName(), message, "1"}), current_area);
|
||||||
config.beginGroup("Options");
|
|
||||||
QString hostname = config.value("hostname", "Server").toString();
|
|
||||||
server->broadcast(AOPacket("CT", {hostname, message, "1"}), current_area);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AOClient::sendServerBroadcast(QString message)
|
void AOClient::sendServerBroadcast(QString message)
|
||||||
{
|
{
|
||||||
QSettings config("config/config.ini", QSettings::IniFormat);
|
server->broadcast(AOPacket("CT", {server->getServerName(), message, "1"}));
|
||||||
config.beginGroup("Options");
|
|
||||||
QString hostname = config.value("hostname", "Server").toString();
|
|
||||||
server->broadcast(AOPacket("CT", {hostname, message, "1"}));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AOClient::checkAuth(unsigned long long acl_mask)
|
bool AOClient::checkAuth(unsigned long long acl_mask)
|
||||||
|
@ -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)
|
AOClient* Server::getClient(QString ipid)
|
||||||
{
|
{
|
||||||
for (AOClient* client : clients) {
|
for (AOClient* client : clients) {
|
||||||
|
Loading…
Reference in New Issue
Block a user