Expand kick_other to consider the hwid
This commit is contained in:
parent
c79cdf3a4c
commit
97528e641c
core
@ -1367,6 +1367,9 @@ class AOClient : public QObject
|
||||
*
|
||||
* @details This command gracefully removes all multiclients from the server, disconnecting them and freeing their used character.
|
||||
*
|
||||
* @arg argv This command allows the user to specify if it should look for IPID or HWID matches. This is useful when a client mayb
|
||||
* have been connected over IPv6 and the second connection is made over IPv4
|
||||
*
|
||||
* @iscommand
|
||||
*/
|
||||
void cmdKickOther(int argc, QStringList argv);
|
||||
|
@ -117,6 +117,15 @@ class Server : public QObject
|
||||
*/
|
||||
QList<AOClient *> getClientsByIpid(QString ipid);
|
||||
|
||||
/**
|
||||
* @brief Gets a list of pointers to all clients with the given HWID.
|
||||
*
|
||||
* @param HWID The HWID to look for.
|
||||
*
|
||||
* @return A list of clients whose HWID match. List may be empty.
|
||||
*/
|
||||
QList<AOClient *> getClientsByHwid(QString f_hwid);
|
||||
|
||||
/**
|
||||
* @brief Gets a pointer to a client by user ID.
|
||||
*
|
||||
|
@ -638,12 +638,22 @@ void AOClient::cmdKickOther(int argc, QStringList argv)
|
||||
|
||||
int l_kick_counter = 0;
|
||||
|
||||
const QList<AOClient *> l_target_clients = server->getClientsByIpid(m_ipid);
|
||||
for (AOClient *l_target_client : l_target_clients) {
|
||||
if (l_target_client != this) {
|
||||
l_target_client->m_socket->close();
|
||||
l_kick_counter++;
|
||||
QList<AOClient *> l_target_clients;
|
||||
const QList<AOClient *> l_targets_hwid = server->getClientsByHwid(m_hwid);
|
||||
l_target_clients = server->getClientsByIpid(m_ipid);
|
||||
|
||||
// Merge both lookups into one single list.)
|
||||
for (AOClient *l_target_candidate : qAsConst(l_targets_hwid)) {
|
||||
if (!l_target_clients.contains(l_target_candidate)) {
|
||||
l_target_clients.append(l_target_candidate);
|
||||
}
|
||||
}
|
||||
|
||||
// The list is unique, we can only have on instance of the current client.
|
||||
l_target_clients.removeOne(this);
|
||||
for (AOClient *l_target_client : qAsConst(l_target_clients)) {
|
||||
l_target_client->m_socket->close();
|
||||
l_kick_counter++;
|
||||
}
|
||||
sendServerMessage("Kicked " + QString::number(l_kick_counter) + " multiclients from the server.");
|
||||
}
|
||||
|
@ -456,6 +456,16 @@ QList<AOClient *> Server::getClientsByIpid(QString ipid)
|
||||
return return_clients;
|
||||
}
|
||||
|
||||
QList<AOClient *> Server::getClientsByHwid(QString f_hwid)
|
||||
{
|
||||
QList<AOClient *> return_clients;
|
||||
for (AOClient *l_client : qAsConst(m_clients)) {
|
||||
if (l_client->getHwid() == f_hwid)
|
||||
return_clients.append(l_client);
|
||||
}
|
||||
return return_clients;
|
||||
}
|
||||
|
||||
AOClient *Server::getClientByID(int id)
|
||||
{
|
||||
return m_clients_ids.value(id);
|
||||
|
Loading…
Reference in New Issue
Block a user