changeset 9659 | 187142ff9b6c |
parent 9652 | 0405e98d8e96 |
child 9893 | bd16f5239fa4 |
9658:f5c4d3c04b5d | 9659:187142ff9b6c |
---|---|
592 return true; |
592 return true; |
593 } |
593 } |
594 |
594 |
595 DEF_CONSOLE_CMD(ConResetCompany) |
595 DEF_CONSOLE_CMD(ConResetCompany) |
596 { |
596 { |
597 const Player *p; |
|
598 PlayerID index; |
597 PlayerID index; |
599 |
598 |
600 if (argc == 0) { |
599 if (argc == 0) { |
601 IConsoleHelp("Remove an idle company from the game. Usage: 'reset_company <company-id>'"); |
600 IConsoleHelp("Remove an idle company from the game. Usage: 'reset_company <company-id>'"); |
602 IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Player 1 is 1, etc."); |
601 IConsoleHelp("For company-id's, see the list of companies from the dropdown menu. Player 1 is 1, etc."); |
611 if (!IsValidPlayerID(index)) { |
610 if (!IsValidPlayerID(index)) { |
612 IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_PLAYERS); |
611 IConsolePrintF(CC_ERROR, "Company does not exist. Company-id must be between 1 and %d.", MAX_PLAYERS); |
613 return true; |
612 return true; |
614 } |
613 } |
615 |
614 |
616 /* Check if company does exist */ |
615 const Player *p = GetPlayer(index); |
617 p = GetPlayer(index); |
|
618 if (!p->is_active) { |
|
619 IConsoleError("Company does not exist."); |
|
620 return true; |
|
621 } |
|
622 |
616 |
623 if (p->is_ai) { |
617 if (p->is_ai) { |
624 IConsoleError("Company is owned by an AI."); |
618 IConsoleError("Company is owned by an AI."); |
625 return true; |
619 return true; |
626 } |
620 } |
1155 NetworkPopulateCompanyInfo(); |
1149 NetworkPopulateCompanyInfo(); |
1156 |
1150 |
1157 FOR_ALL_PLAYERS(p) { |
1151 FOR_ALL_PLAYERS(p) { |
1158 char buffer[512]; |
1152 char buffer[512]; |
1159 |
1153 |
1160 if (!p->is_active) continue; |
|
1161 |
|
1162 const NetworkPlayerInfo *npi = &_network_player_info[p->index]; |
1154 const NetworkPlayerInfo *npi = &_network_player_info[p->index]; |
1163 |
1155 |
1164 GetString(buffer, STR_00D1_DARK_BLUE + _player_colors[p->index], lastof(buffer)); |
1156 GetString(buffer, STR_00D1_DARK_BLUE + _player_colors[p->index], lastof(buffer)); |
1165 IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: %" OTTD_PRINTF64 "d Loan: %" OTTD_PRINTF64 "d Value: %" OTTD_PRINTF64 "d (T:%d, R:%d, P:%d, S:%d) %sprotected", |
1157 IConsolePrintF(CC_INFO, "#:%d(%s) Company Name: '%s' Year Founded: %d Money: %" OTTD_PRINTF64 "d Loan: %" OTTD_PRINTF64 "d Value: %" OTTD_PRINTF64 "d (T:%d, R:%d, P:%d, S:%d) %sprotected", |
1166 p->index + 1, buffer, npi->company_name, p->inaugurated_year, (int64)p->player_money, (int64)p->current_loan, (int64)CalculateCompanyValue(p), |
1158 p->index + 1, buffer, npi->company_name, p->inaugurated_year, (int64)p->player_money, (int64)p->current_loan, (int64)CalculateCompanyValue(p), |
1183 } |
1175 } |
1184 |
1176 |
1185 if (argc != 3) return false; |
1177 if (argc != 3) return false; |
1186 |
1178 |
1187 PlayerID player_id = (PlayerID)(atoi(argv[1]) - 1); |
1179 PlayerID player_id = (PlayerID)(atoi(argv[1]) - 1); |
1188 if (!IsValidPlayerID(player_id) || !GetPlayer(player_id)->is_active) { |
1180 if (!IsValidPlayerID(player_id)) { |
1189 IConsolePrintF(CC_DEFAULT, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS); |
1181 IConsolePrintF(CC_DEFAULT, "Unknown player. Player range is between 1 and %d.", MAX_PLAYERS); |
1190 return true; |
1182 return true; |
1191 } |
1183 } |
1192 |
1184 |
1193 if (!_network_server) { |
1185 if (!_network_server) { |