From 52b95bdc96c4763d1465bac0f9165bdfe55ddf1a Mon Sep 17 00:00:00 2001 From: yexo Date: Sun, 26 Apr 2009 20:01:14 +0000 Subject: (svn r16176) -Fix: forbid joining AI companies via the 'move' and 'join' console commands. --- src/console_cmds.cpp | 10 ++++++++++ src/network/network_server.cpp | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index ac418c583..ced66db8b 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -636,6 +636,11 @@ DEF_CONSOLE_CMD(ConJoinCompany) return true; } + if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) { + IConsoleError("Cannot join AI company."); + return true; + } + /* Check if the company requires a password */ if (NetworkCompanyIsPassworded(company_id) && argc < 3) { IConsolePrintF(CC_ERROR, "Company %d requires a password to join.", company_id + 1); @@ -674,6 +679,11 @@ DEF_CONSOLE_CMD(ConMoveClient) return true; } + if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) { + IConsoleError("You cannot move clients to AI companies."); + return true; + } + if (ci->client_id == CLIENT_ID_SERVER && _network_dedicated) { IConsoleError("Silly boy, you cannot move the server!"); return true; diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index 2e2971fa7..4597b2c71 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -1235,6 +1235,8 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_MOVE) /* Check if the company is valid */ if (!IsValidCompanyID(company_id) && company_id != COMPANY_SPECTATOR) return; + /* We don't allow moving to AI companies */ + if (company_id != COMPANY_SPECTATOR && GetCompany(company_id)->is_ai) return; /* Check if we require a password for this company */ if (company_id != COMPANY_SPECTATOR && !StrEmpty(_network_company_states[company_id].password)) { -- cgit v1.2.3-70-g09d2