diff -r 23ae16737f75 -r 898721b730a3 src/console_cmds.cpp --- a/src/console_cmds.cpp Wed Jan 19 00:50:56 2011 +0100 +++ b/src/console_cmds.cpp Wed Jan 19 00:51:13 2011 +0100 @@ -1518,19 +1518,43 @@ DEF_CONSOLE_CMD(ConCompanyPassword) { if (argc == 0) { - IConsoleHelp("Change the password of your company. Usage: 'company_pw \"\"'"); + const char *helpmsg; + + if (_network_dedicated) { + helpmsg = "Change the password of a company. Usage: 'company_pw \"\""; + } else if (_network_server) { + helpmsg = "Change the password of your or any other company. Usage: 'company_pw [] \"\"'"; + } else { + helpmsg = "Change the password of your company. Usage: 'company_pw \"\"'"; + } + + IConsoleHelp(helpmsg); IConsoleHelp("Use \"*\" to disable the password."); return true; } - if (argc != 2) return false; + CompanyID company_id; + const char *password; + const char *errormsg; - if (!Company::IsValidID(_local_company)) { - IConsoleError("You have to own a company to make use of this command."); + if (argc == 2) { + company_id = _local_company; + password = argv[1]; + errormsg = "You have to own a company to make use of this command."; + } else if (argc == 3 && _network_server) { + company_id = (CompanyID)(atoi(argv[1]) - 1); + password = argv[2]; + errormsg = "You have to specify the ID of a valid human controlled company."; + } else { return false; } - const char *password = NetworkChangeCompanyPassword(argv[1]); + if (!Company::IsValidHumanID(company_id)) { + IConsoleError(errormsg); + return false; + } + + password = NetworkChangeCompanyPassword(company_id, password, false); if (StrEmpty(password)) { IConsolePrintF(CC_WARNING, "Company password cleared");