summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2011-01-19 16:52:57 +0000
committerrubidium <rubidium@openttd.org>2011-01-19 16:52:57 +0000
commit3f9fa65a42e0a3370a2204a7c0ce570c7476361d (patch)
treea68c421aa20b43675e8932ee99b43395c3622a1e
parent795a5283289473185afdedb3133155101e84b0fe (diff)
downloadopenttd-3f9fa65a42e0a3370a2204a7c0ce570c7476361d.tar.xz
(svn r21855) -Feature [FS#4368]: [Network] Console command to change the password of other companies for servers (dihedral)
-rw-r--r--src/console_cmds.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp
index e13e9df20..56f06937e 100644
--- a/src/console_cmds.cpp
+++ b/src/console_cmds.cpp
@@ -1518,19 +1518,43 @@ DEF_CONSOLE_CMD(ConSayClient)
DEF_CONSOLE_CMD(ConCompanyPassword)
{
if (argc == 0) {
- IConsoleHelp("Change the password of your company. Usage: 'company_pw \"<password>\"'");
+ const char *helpmsg;
+
+ if (_network_dedicated) {
+ helpmsg = "Change the password of a company. Usage: 'company_pw <company-no> \"<password>\"";
+ } else if (_network_server) {
+ helpmsg = "Change the password of your or any other company. Usage: 'company_pw [<company-no>] \"<password>\"'";
+ } else {
+ helpmsg = "Change the password of your company. Usage: 'company_pw \"<password>\"'";
+ }
+
+ 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 (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;
+ }
- if (!Company::IsValidID(_local_company)) {
- IConsoleError("You have to own a company to make use of this command.");
+ if (!Company::IsValidHumanID(company_id)) {
+ IConsoleError(errormsg);
return false;
}
- const char *password = NetworkChangeCompanyPassword(_local_company, argv[1], false);
+ password = NetworkChangeCompanyPassword(company_id, password, false);
if (StrEmpty(password)) {
IConsolePrintF(CC_WARNING, "Company password cleared");