From de27205e6c8aec594f7ae3b8205e8a1d60c24751 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sat, 15 Oct 2011 20:42:32 +0000 Subject: (svn r23031) -Fix [FS#4804]: for the admin "bots" there was no distinction between bankruptcy and manual removal of companies even though the API suggested that --- src/network/core/tcp_admin.cpp | 20 +++++++++++++------- src/network/core/tcp_admin.h | 4 +++- src/network/network_server.cpp | 6 ++---- 3 files changed, 18 insertions(+), 12 deletions(-) (limited to 'src/network') diff --git a/src/network/core/tcp_admin.cpp b/src/network/core/tcp_admin.cpp index 077ac3048..fbf9ac580 100644 --- a/src/network/core/tcp_admin.cpp +++ b/src/network/core/tcp_admin.cpp @@ -19,6 +19,12 @@ #include "tcp_admin.h" #include "../../debug.h" +/* Make sure that these enums match. */ +assert_compile((int)CRR_MANUAL == (int)ADMIN_CRR_MANUAL); +assert_compile((int)CRR_AUTOCLEAN == (int)ADMIN_CRR_AUTOCLEAN); +assert_compile((int)CRR_BANKRUPT == (int)ADMIN_CRR_BANKRUPT); +assert_compile((int)CRR_END == (int)ADMIN_CRR_END); + /** * Create the admin handler for the given socket. * @param s The socket to communicate over. @@ -55,13 +61,13 @@ NetworkRecvStatus NetworkAdminSocketHandler::HandlePacket(Packet *p) case ADMIN_PACKET_ADMIN_CHAT: return this->Receive_ADMIN_CHAT(p); case ADMIN_PACKET_ADMIN_RCON: return this->Receive_ADMIN_RCON(p); - case ADMIN_PACKET_SERVER_FULL: return this->Receive_SERVER_FULL(p); - case ADMIN_PACKET_SERVER_BANNED: return this->Receive_SERVER_BANNED(p); - case ADMIN_PACKET_SERVER_ERROR: return this->Receive_SERVER_ERROR(p); - case ADMIN_PACKET_SERVER_PROTOCOL: return this->Receive_SERVER_PROTOCOL(p); - case ADMIN_PACKET_SERVER_WELCOME: return this->Receive_SERVER_WELCOME(p); - case ADMIN_PACKET_SERVER_NEWGAME: return this->Receive_SERVER_NEWGAME(p); - case ADMIN_PACKET_SERVER_SHUTDOWN: return this->Receive_SERVER_SHUTDOWN(p); + case ADMIN_PACKET_SERVER_FULL: return this->Receive_SERVER_FULL(p); + case ADMIN_PACKET_SERVER_BANNED: return this->Receive_SERVER_BANNED(p); + case ADMIN_PACKET_SERVER_ERROR: return this->Receive_SERVER_ERROR(p); + case ADMIN_PACKET_SERVER_PROTOCOL: return this->Receive_SERVER_PROTOCOL(p); + case ADMIN_PACKET_SERVER_WELCOME: return this->Receive_SERVER_WELCOME(p); + case ADMIN_PACKET_SERVER_NEWGAME: return this->Receive_SERVER_NEWGAME(p); + case ADMIN_PACKET_SERVER_SHUTDOWN: return this->Receive_SERVER_SHUTDOWN(p); case ADMIN_PACKET_SERVER_DATE: return this->Receive_SERVER_DATE(p); case ADMIN_PACKET_SERVER_CLIENT_JOIN: return this->Receive_SERVER_CLIENT_JOIN(p); diff --git a/src/network/core/tcp_admin.h b/src/network/core/tcp_admin.h index c0491f0cc..46b876952 100644 --- a/src/network/core/tcp_admin.h +++ b/src/network/core/tcp_admin.h @@ -99,7 +99,9 @@ DECLARE_ENUM_AS_BIT_SET(AdminUpdateFrequency) enum AdminCompanyRemoveReason { ADMIN_CRR_MANUAL, ///< The company is manually removed. ADMIN_CRR_AUTOCLEAN, ///< The company is removed due to autoclean. - ADMIN_CRR_BANKRUPT ///< The company went belly-up. + ADMIN_CRR_BANKRUPT, ///< The company went belly-up. + + ADMIN_CRR_END ///< Sentinel for end. }; /** Main socket handler for admin related connections. */ diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 507c9232e..ebf78a320 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1643,8 +1643,7 @@ static void NetworkAutoCleanCompanies() /* Is the company empty for autoclean_unprotected-months, and is there no protection? */ if (_settings_client.network.autoclean_unprotected != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_unprotected && StrEmpty(_network_company_states[c->index].password)) { /* Shut the company down */ - DoCommandP(0, 2 | c->index << 16, 0, CMD_COMPANY_CTRL); - NetworkAdminCompanyRemove(c->index, ADMIN_CRR_AUTOCLEAN); + DoCommandP(0, 2 | c->index << 16, CRR_AUTOCLEAN, CMD_COMPANY_CTRL); IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d with no password", c->index + 1); } /* Is the company empty for autoclean_protected-months, and there is a protection? */ @@ -1658,8 +1657,7 @@ static void NetworkAutoCleanCompanies() /* Is the company empty for autoclean_novehicles-months, and has no vehicles? */ if (_settings_client.network.autoclean_novehicles != 0 && _network_company_states[c->index].months_empty > _settings_client.network.autoclean_novehicles && vehicles_in_company[c->index] == 0) { /* Shut the company down */ - DoCommandP(0, 2 | c->index << 16, 0, CMD_COMPANY_CTRL); - NetworkAdminCompanyRemove(c->index, ADMIN_CRR_AUTOCLEAN); + DoCommandP(0, 2 | c->index << 16, CRR_AUTOCLEAN, CMD_COMPANY_CTRL); IConsolePrintF(CC_DEFAULT, "Auto-cleaned company #%d with no vehicles", c->index + 1); } } else { -- cgit v1.2.3-54-g00ecf