diff options
author | smatz <smatz@openttd.org> | 2010-02-10 15:17:27 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2010-02-10 15:17:27 +0000 |
commit | 73ed81b1c78232c14de861207db9b40ff2550536 (patch) | |
tree | b426188d7abe9279c2d94cdbadf82f360bc8b55c /src/console_cmds.cpp | |
parent | b91b3ac836604ad364e5d8027a30e0c9bc7b4fcc (diff) | |
download | openttd-73ed81b1c78232c14de861207db9b40ff2550536.tar.xz |
(svn r19075) -Codechange: unhackify NetworkChangeCompanyPassword()
Diffstat (limited to 'src/console_cmds.cpp')
-rw-r--r-- | src/console_cmds.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index 2237c956d..8989b340f 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -1544,8 +1544,7 @@ DEF_CONSOLE_CMD(ConSayClient) extern void HashCurrentCompanyPassword(const char *password); -/* Also use from within company_gui to change the password graphically */ -bool NetworkChangeCompanyPassword(byte argc, char *argv[]) +DEF_CONSOLE_CMD(ConCompanyPassword) { if (argc == 0) { IConsoleHelp("Change the password of your company. Usage: 'company_pw \"<password>\"'"); @@ -1553,23 +1552,21 @@ bool NetworkChangeCompanyPassword(byte argc, char *argv[]) return true; } + if (argc != 1) return false; + if (!Company::IsValidID(_local_company)) { IConsoleError("You have to own a company to make use of this command."); return false; } - if (argc != 1) return false; - - if (strcmp(argv[0], "*") == 0) argv[0][0] = '\0'; + const char *password = NetworkChangeCompanyPassword(argv[0]); - if (!_network_server) { - NetworkClientSetPassword(argv[0]); + if (StrEmpty(password)) { + IConsolePrintF(CC_WARNING, "Company password cleared"); } else { - HashCurrentCompanyPassword(argv[0]); + IConsolePrintF(CC_WARNING, "Company password changed to: %s", password); } - IConsolePrintF(CC_WARNING, "'company_pw' changed to: %s", argv[0]); - return true; } @@ -1909,7 +1906,7 @@ void IConsoleStdLibRegister() /*** Networking variables ***/ IConsoleVarStringRegister("company_pw", NULL, 0, "Set a password for your company, so no one without the correct password can join. Use '*' to clear the password"); IConsoleVarHookAdd("company_pw", ICONSOLE_HOOK_ACCESS, ConHookNeedNetwork); - IConsoleVarProcAdd("company_pw", NetworkChangeCompanyPassword); + IConsoleVarProcAdd("company_pw", ConCompanyPassword); IConsoleAliasRegister("company_password", "company_pw %+"); IConsoleAliasRegister("net_frame_freq", "setting frame_freq %+"); |