--- a/src/ai/api/ai_company.cpp Sun Mar 18 20:15:57 2007 +0000
+++ b/src/ai/api/ai_company.cpp Sun Mar 18 20:56:03 2007 +0000
@@ -59,19 +59,9 @@
return false;
}
- /* When we get/repay everything at once (or the maximum we can repay),
- * use the shortcut for that. Otherwise send several commands at once */
- if (loan == 0) {
- return this->DoCommand(0, 0, true, DC_EXEC, CMD_DECREASE_LOAN);
- }
- if (loan == this->GetMaxLoanAmount()) {
- return this->DoCommand(0, 0, true, DC_EXEC, CMD_INCREASE_LOAN);
- }
+ if (loan == this->GetLoanAmount()) return true;
- bool increase = loan > this->GetLoanAmount();
- for (uint diff_loan = abs(loan - this->GetLoanAmount()) / this->GetLoanInterval(); diff_loan > 0; diff_loan--) {
- if (!this->DoCommand(0, 0, false, DC_EXEC, increase ? CMD_INCREASE_LOAN : CMD_DECREASE_LOAN)) return false;
- }
-
- return true;
+ return this->DoCommand(0,
+ abs(loan - this->GetLoanAmount()), 2, DC_EXEC,
+ (loan > this->GetLoanAmount()) ? CMD_INCREASE_LOAN : CMD_DECREASE_LOAN);
}