diff --git a/src/company_cmd.cpp b/src/company_cmd.cpp index 89a185dd5c..41a90c6ee2 100644 --- a/src/company_cmd.cpp +++ b/src/company_cmd.cpp @@ -1008,18 +1008,18 @@ CommandCost CmdCompanyCtrl(DoCommandFlags flags, CompanyCtrlAction cca, CompanyI static bool ExecuteAllowListCtrlAction(CompanyAllowListCtrlAction action, Company *c, const std::string &public_key) { switch (action) { - case CALCA_ADD: + case CompanyAllowListCtrlAction::AddKey: return c->allow_list.Add(public_key); - case CALCA_REMOVE: + case CompanyAllowListCtrlAction::RemoveKey: return c->allow_list.Remove(public_key); - case CALCA_ALLOW_ANY: + case CompanyAllowListCtrlAction::AllowAny: if (c->allow_any) return false; c->allow_any = true; return true; - case CALCA_ALLOW_LISTED: + case CompanyAllowListCtrlAction::AllowListed: if (!c->allow_any) return false; c->allow_any = false; return true; @@ -1042,14 +1042,14 @@ CommandCost CmdCompanyAllowListCtrl(DoCommandFlags flags, CompanyAllowListCtrlAc if (c == nullptr) return CMD_ERROR; switch (action) { - case CALCA_ADD: - case CALCA_REMOVE: + case CompanyAllowListCtrlAction::AddKey: + case CompanyAllowListCtrlAction::RemoveKey: /* The public key length includes the '\0'. */ if (public_key.size() != NETWORK_PUBLIC_KEY_LENGTH - 1) return CMD_ERROR; break; - case CALCA_ALLOW_ANY: - case CALCA_ALLOW_LISTED: + case CompanyAllowListCtrlAction::AllowAny: + case CompanyAllowListCtrlAction::AllowListed: if (public_key.size() != 0) return CMD_ERROR; break; diff --git a/src/company_type.h b/src/company_type.h index b03b789eff..682b188730 100644 --- a/src/company_type.h +++ b/src/company_type.h @@ -75,13 +75,11 @@ enum class CompanyCtrlAction : uint8_t { }; /** The action to do with Commands::CompanyAllowListControl. */ -enum CompanyAllowListCtrlAction : uint8_t { - CALCA_ADD, ///< Create a public key. - CALCA_REMOVE, ///< Remove a public key. - CALCA_ALLOW_ANY, ///< Allow joining the company without a key. - CALCA_ALLOW_LISTED, ///< Allow only listed keys to join the company. - - CALCA_END, ///< Sentinel for end. +enum class CompanyAllowListCtrlAction : uint8_t { + AddKey, ///< Create a public key. + RemoveKey, ///< Remove a public key. + AllowAny, ///< Allow joining the company without a key. + AllowListed, ///< Allow only listed keys to join the company. }; #endif /* COMPANY_TYPE_H */ diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 3243b4dbbc..9c0cdde126 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -2146,7 +2146,7 @@ static void PerformNetworkAuthorizedKeyAction(std::string_view name, NetworkAuth authorized_keys->Add(authorized_key); } else { AutoRestoreBackup backup(_current_company, company); - Command::Post(CALCA_ADD, authorized_key); + Command::Post(CompanyAllowListCtrlAction::AddKey, authorized_key); } IConsolePrint(CC_INFO, "Added {} to {}.", authorized_key, name); return; @@ -2161,7 +2161,7 @@ static void PerformNetworkAuthorizedKeyAction(std::string_view name, NetworkAuth authorized_keys->Remove(authorized_key); } else { AutoRestoreBackup backup(_current_company, company); - Command::Post(CALCA_REMOVE, authorized_key); + Command::Post(CompanyAllowListCtrlAction::RemoveKey, authorized_key); } IConsolePrint(CC_INFO, "Removed {} from {}.", authorized_key, name); return; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 69894c97ad..e1787b4bf1 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -1654,7 +1654,7 @@ private: static void OnClickClientAuthorize([[maybe_unused]] NetworkClientListWindow *w, [[maybe_unused]] Point pt, ClientID client_id) { AutoRestoreBackup cur_company(_current_company, NetworkClientInfo::GetByClientID(_network_own_client_id)->client_playas); - Command::Post(CALCA_ADD, NetworkClientInfo::GetByClientID(client_id)->public_key); + Command::Post(CompanyAllowListCtrlAction::AddKey, NetworkClientInfo::GetByClientID(client_id)->public_key); } /** @@ -1910,13 +1910,13 @@ public: case DropDownAction::CompanyAllowAny: { AutoRestoreBackup cur_company(_current_company, this->dd_company_id); - Command::Post(CALCA_ALLOW_ANY, {}); + Command::Post(CompanyAllowListCtrlAction::AllowAny, {}); return; } case DropDownAction::CompanyAllowListed: { AutoRestoreBackup cur_company(_current_company, this->dd_company_id); - Command::Post(CALCA_ALLOW_LISTED, {}); + Command::Post(CompanyAllowListCtrlAction::AllowListed, {}); return; } diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 4d49a548a0..75506e0861 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -2215,7 +2215,7 @@ void NetworkServerNewCompany(const Company *c, NetworkClientInfo *ci) * different state/president/company name in the different clients, we need to * circumvent the normal ::Post logic and go directly to sending the command. */ - Command::SendNet(STR_NULL, c->index, CALCA_ADD, ci->public_key); + Command::SendNet(STR_NULL, c->index, CompanyAllowListCtrlAction::AddKey, ci->public_key); Command::SendNet(STR_NULL, c->index, ci->client_name); NetworkServerSendChat(NETWORK_ACTION_COMPANY_NEW, DESTTYPE_BROADCAST, 0, "", ci->client_id, c->index + 1);