(svn r16352) -Codechange: use PoolItem::GetIfValid() instead of PoolItem::IsValidID() and PoolItem::Get()

This commit is contained in:
smatz
2009-05-18 16:21:28 +00:00
parent 5fe906e149
commit 8808f3beea
35 changed files with 201 additions and 305 deletions

View File

@@ -716,8 +716,6 @@ DEF_CONSOLE_CMD(ConMoveClient)
DEF_CONSOLE_CMD(ConResetCompany)
{
CompanyID index;
if (argc == 0) {
IConsoleHelp("Remove an idle company from the game. Usage: 'reset_company <company-id>'");
IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Company 1 is 1, etc.");
@@ -726,16 +724,15 @@ DEF_CONSOLE_CMD(ConResetCompany)
if (argc != 2) return false;
index = (CompanyID)(atoi(argv[1]) - 1);
CompanyID index = (CompanyID)(atoi(argv[1]) - 1);
const Company *c = Company::GetIfValid(index);
/* Check valid range */
if (!Company::IsValidID(index)) {
if (c == NULL) {
IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_COMPANIES);
return true;
}
const Company *c = Company::Get(index);
if (c->is_ai) {
IConsoleError("Company is owned by an AI.");
return true;