summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bin/ai/compat_0.7.nut5
-rw-r--r--bin/ai/compat_1.0.nut5
-rw-r--r--bin/ai/compat_1.1.nut5
-rw-r--r--bin/ai/regression/regression.nut95
-rw-r--r--bin/ai/regression/regression.txt243
-rw-r--r--src/ai/api/ai_changelog.hpp11
-rw-r--r--src/ai/api/ai_company.cpp55
-rw-r--r--src/ai/api/ai_company.hpp66
-rw-r--r--src/ai/api/ai_company.hpp.sq66
9 files changed, 423 insertions, 128 deletions
diff --git a/bin/ai/compat_0.7.nut b/bin/ai/compat_0.7.nut
index 75669eaf6..d85a5fbe0 100644
--- a/bin/ai/compat_0.7.nut
+++ b/bin/ai/compat_0.7.nut
@@ -321,3 +321,8 @@ AIAbstractList <- AIList;
AIList.ChangeItem <- AIList.SetValue;
AIRail.ERR_NONUNIFORM_STATIONS_DISABLED <- 0xFFFF;
+
+AICompany.GetCompanyValue <- function(company)
+{
+ return AICompany.GetQuarterlyCompanyValue(company, AICompany.CURRENT_QUARTER);
+}
diff --git a/bin/ai/compat_1.0.nut b/bin/ai/compat_1.0.nut
index 92eca47d8..ea76952f4 100644
--- a/bin/ai/compat_1.0.nut
+++ b/bin/ai/compat_1.0.nut
@@ -72,3 +72,8 @@ AIAbstractList <- AIList;
AIList.ChangeItem <- AIList.SetValue;
AIRail.ERR_NONUNIFORM_STATIONS_DISABLED <- 0xFFFF;
+
+AICompany.GetCompanyValue <- function(company)
+{
+ return AICompany.GetQuarterlyCompanyValue(company, AICompany.CURRENT_QUARTER);
+}
diff --git a/bin/ai/compat_1.1.nut b/bin/ai/compat_1.1.nut
index 16440bf92..8328e4b9a 100644
--- a/bin/ai/compat_1.1.nut
+++ b/bin/ai/compat_1.1.nut
@@ -8,3 +8,8 @@
*/
AILog.Info("1.1 API compatability in effect.");
+
+AICompany.GetCompanyValue <- function(company)
+{
+ return AICompany.GetQuarterlyCompanyValue(company, AICompany.CURRENT_QUARTER);
+}
diff --git a/bin/ai/regression/regression.nut b/bin/ai/regression/regression.nut
index 5494c1b7a..05243346a 100644
--- a/bin/ai/regression/regression.nut
+++ b/bin/ai/regression/regression.nut
@@ -394,50 +394,57 @@ function Regression::Company()
}
}
- print(" GetName(): " + AICompany.GetName(AICompany.COMPANY_SELF));
- print(" GetPresidentName(): " + AICompany.GetPresidentName(AICompany.COMPANY_SELF));
- print(" SetPresidentName(): " + AICompany.SetPresidentName("Regression AI"));
- print(" GetPresidentName(): " + AICompany.GetPresidentName(AICompany.COMPANY_SELF));
- print(" GetCompanyValue(): " + AICompany.GetCompanyValue(AICompany.COMPANY_SELF));
- print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
- print(" GetName(): " + AICompany.GetName(240));
- print(" GetLoanAmount(): " + AICompany.GetLoanAmount());
- print(" GetMaxLoanAmount(): " + AICompany.GetMaxLoanAmount());
- print(" GetLoanInterval(): " + AICompany.GetLoanInterval());
- print(" SetLoanAmount(1): " + AICompany.SetLoanAmount(1));
- print(" SetLoanAmount(100): " + AICompany.SetLoanAmount(100));
- print(" SetLoanAmount(10000): " + AICompany.SetLoanAmount(10000));
- print(" GetLastErrorString(): " + AIError.GetLastErrorString());
- print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
- print(" GetLoanAmount(): " + AICompany.GetLoanAmount());
- print(" SetMinimumLoanAmount(31337): " + AICompany.SetMinimumLoanAmount(31337));
- print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
- print(" GetLoanAmount(): " + AICompany.GetLoanAmount());
- print(" SetLoanAmount(10000): " + AICompany.SetLoanAmount(AICompany.GetMaxLoanAmount()));
- print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
- print(" GetLoanAmount(): " + AICompany.GetLoanAmount());
- print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF));
- print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(127, 129)));
- print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF));
- print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(129, 129)));
- print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF));
- print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(129, 128)));
- print(" GetLastErrorString(): " + AIError.GetLastErrorString());
- print(" GetAutoRenewStatus(); " + AICompany.GetAutoRenewStatus(AICompany.COMPANY_SELF));
- print(" SetAutoRenewStatus(true); " + AICompany.SetAutoRenewStatus(true));
- print(" GetAutoRenewStatus(); " + AICompany.GetAutoRenewStatus(AICompany.COMPANY_SELF));
- print(" SetAutoRenewStatus(true); " + AICompany.SetAutoRenewStatus(true));
- print(" SetAutoRenewStatus(false); " + AICompany.SetAutoRenewStatus(false));
- print(" GetAutoRenewMonths(); " + AICompany.GetAutoRenewMonths(AICompany.COMPANY_SELF));
- print(" SetAutoRenewMonths(-12); " + AICompany.SetAutoRenewMonths(-12));
- print(" GetAutoRenewMonths(); " + AICompany.GetAutoRenewMonths(AICompany.COMPANY_SELF));
- print(" SetAutoRenewMonths(-12); " + AICompany.SetAutoRenewMonths(-12));
- print(" SetAutoRenewMonths(6); " + AICompany.SetAutoRenewMonths(6));
- print(" GetAutoRenewMoney(); " + AICompany.GetAutoRenewMoney(AICompany.COMPANY_SELF));
- print(" SetAutoRenewMoney(200000); " + AICompany.SetAutoRenewMoney(200000));
- print(" GetAutoRenewMoney(); " + AICompany.GetAutoRenewMoney(AICompany.COMPANY_SELF));
- print(" SetAutoRenewMoney(200000); " + AICompany.SetAutoRenewMoney(200000));
- print(" SetAutoRenewMoney(100000); " + AICompany.SetAutoRenewMoney(100000));
+ print(" GetName(): " + AICompany.GetName(AICompany.COMPANY_SELF));
+ print(" GetPresidentName(): " + AICompany.GetPresidentName(AICompany.COMPANY_SELF));
+ print(" SetPresidentName(): " + AICompany.SetPresidentName("Regression AI"));
+ print(" GetPresidentName(): " + AICompany.GetPresidentName(AICompany.COMPANY_SELF));
+ print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
+ print(" GetName(): " + AICompany.GetName(240));
+ print(" GetLoanAmount(): " + AICompany.GetLoanAmount());
+ print(" GetMaxLoanAmount(): " + AICompany.GetMaxLoanAmount());
+ print(" GetLoanInterval(): " + AICompany.GetLoanInterval());
+ print(" SetLoanAmount(1): " + AICompany.SetLoanAmount(1));
+ print(" SetLoanAmount(100): " + AICompany.SetLoanAmount(100));
+ print(" SetLoanAmount(10000): " + AICompany.SetLoanAmount(10000));
+ print(" GetLastErrorString(): " + AIError.GetLastErrorString());
+ print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
+ print(" GetLoanAmount(): " + AICompany.GetLoanAmount());
+ print(" SetMinimumLoanAmount(31337): " + AICompany.SetMinimumLoanAmount(31337));
+ print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
+ print(" GetLoanAmount(): " + AICompany.GetLoanAmount());
+ print(" SetLoanAmount(10000): " + AICompany.SetLoanAmount(AICompany.GetMaxLoanAmount()));
+ print(" GetBankBalance(): " + AICompany.GetBankBalance(AICompany.COMPANY_SELF));
+ print(" GetLoanAmount(): " + AICompany.GetLoanAmount());
+ print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF));
+ print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(127, 129)));
+ print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF));
+ print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(129, 129)));
+ print(" GetCompanyHQ(): " + AICompany.GetCompanyHQ(AICompany.COMPANY_SELF));
+ print(" BuildCompanyHQ(): " + AICompany.BuildCompanyHQ(AIMap.GetTileIndex(129, 128)));
+ print(" GetLastErrorString(): " + AIError.GetLastErrorString());
+ print(" GetAutoRenewStatus(); " + AICompany.GetAutoRenewStatus(AICompany.COMPANY_SELF));
+ print(" SetAutoRenewStatus(true); " + AICompany.SetAutoRenewStatus(true));
+ print(" GetAutoRenewStatus(); " + AICompany.GetAutoRenewStatus(AICompany.COMPANY_SELF));
+ print(" SetAutoRenewStatus(true); " + AICompany.SetAutoRenewStatus(true));
+ print(" SetAutoRenewStatus(false); " + AICompany.SetAutoRenewStatus(false));
+ print(" GetAutoRenewMonths(); " + AICompany.GetAutoRenewMonths(AICompany.COMPANY_SELF));
+ print(" SetAutoRenewMonths(-12); " + AICompany.SetAutoRenewMonths(-12));
+ print(" GetAutoRenewMonths(); " + AICompany.GetAutoRenewMonths(AICompany.COMPANY_SELF));
+ print(" SetAutoRenewMonths(-12); " + AICompany.SetAutoRenewMonths(-12));
+ print(" SetAutoRenewMonths(6); " + AICompany.SetAutoRenewMonths(6));
+ print(" GetAutoRenewMoney(); " + AICompany.GetAutoRenewMoney(AICompany.COMPANY_SELF));
+ print(" SetAutoRenewMoney(200000); " + AICompany.SetAutoRenewMoney(200000));
+ print(" GetAutoRenewMoney(); " + AICompany.GetAutoRenewMoney(AICompany.COMPANY_SELF));
+ print(" SetAutoRenewMoney(200000); " + AICompany.SetAutoRenewMoney(200000));
+ print(" SetAutoRenewMoney(100000); " + AICompany.SetAutoRenewMoney(100000));
+ for (local i = -1; i <= AICompany.EARLIEST_QUARTER; i++) {
+ print(" Quarter: " + i);
+ print(" GetQuarterlyIncome(); " + AICompany.GetQuarterlyIncome(AICompany.COMPANY_SELF, i));
+ print(" GetQuarterlyExpenses(); " + AICompany.GetQuarterlyExpenses(AICompany.COMPANY_SELF, i));
+ print(" GetQuarterlyCargoDelivered(); " + AICompany.GetQuarterlyCargoDelivered(AICompany.COMPANY_SELF, i));
+ print(" GetQuarterlyPerformanceRating(); " + AICompany.GetQuarterlyPerformanceRating(AICompany.COMPANY_SELF, i));
+ print(" GetQuarterlyCompanyValue(); " + AICompany.GetQuarterlyCompanyValue(AICompany.COMPANY_SELF, i));
+ }
}
function Regression::Engine()
diff --git a/bin/ai/regression/regression.txt b/bin/ai/regression/regression.txt
index 709667216..81b2699bf 100644
--- a/bin/ai/regression/regression.txt
+++ b/bin/ai/regression/regression.txt
@@ -584,50 +584,205 @@ ERROR: IsEnd() is invalid as Begin() is never called
SetName(): true
SetName(): false
GetLastErrorString(): ERR_NAME_IS_NOT_UNIQUE
- GetName(): Regression
- GetPresidentName(): I. McAlpine
- SetPresidentName(): true
- GetPresidentName(): Regression AI
- GetCompanyValue(): 1
- GetBankBalance(): 100000
- GetName(): (null : 0x00000000)
- GetLoanAmount(): 100000
- GetMaxLoanAmount(): 500000
- GetLoanInterval(): 10000
- SetLoanAmount(1): false
- SetLoanAmount(100): false
- SetLoanAmount(10000): true
- GetLastErrorString(): ERR_NONE
- GetBankBalance(): 10000
- GetLoanAmount(): 10000
- SetMinimumLoanAmount(31337): true
- GetBankBalance(): 40000
- GetLoanAmount(): 40000
- SetLoanAmount(10000): true
- GetBankBalance(): 500000
- GetLoanAmount(): 500000
- GetCompanyHQ(): -1
- BuildCompanyHQ(): true
- GetCompanyHQ(): 33151
- BuildCompanyHQ(): true
- GetCompanyHQ(): 33153
- BuildCompanyHQ(): false
- GetLastErrorString(): ERR_AREA_NOT_CLEAR
- GetAutoRenewStatus(); false
- SetAutoRenewStatus(true); true
- GetAutoRenewStatus(); true
- SetAutoRenewStatus(true); true
- SetAutoRenewStatus(false); true
- GetAutoRenewMonths(); 6
- SetAutoRenewMonths(-12); true
- GetAutoRenewMonths(); -12
- SetAutoRenewMonths(-12); true
- SetAutoRenewMonths(6); true
- GetAutoRenewMoney(); 100000
- SetAutoRenewMoney(200000); true
- GetAutoRenewMoney(); 200000
- SetAutoRenewMoney(200000); true
- SetAutoRenewMoney(100000); true
+ GetName(): Regression
+ GetPresidentName(): I. McAlpine
+ SetPresidentName(): true
+ GetPresidentName(): Regression AI
+ GetBankBalance(): 100000
+ GetName(): (null : 0x00000000)
+ GetLoanAmount(): 100000
+ GetMaxLoanAmount(): 500000
+ GetLoanInterval(): 10000
+ SetLoanAmount(1): false
+ SetLoanAmount(100): false
+ SetLoanAmount(10000): true
+ GetLastErrorString(): ERR_NONE
+ GetBankBalance(): 10000
+ GetLoanAmount(): 10000
+ SetMinimumLoanAmount(31337): true
+ GetBankBalance(): 40000
+ GetLoanAmount(): 40000
+ SetLoanAmount(10000): true
+ GetBankBalance(): 500000
+ GetLoanAmount(): 500000
+ GetCompanyHQ(): -1
+ BuildCompanyHQ(): true
+ GetCompanyHQ(): 33151
+ BuildCompanyHQ(): true
+ GetCompanyHQ(): 33153
+ BuildCompanyHQ(): false
+ GetLastErrorString(): ERR_AREA_NOT_CLEAR
+ GetAutoRenewStatus(); false
+ SetAutoRenewStatus(true); true
+ GetAutoRenewStatus(); true
+ SetAutoRenewStatus(true); true
+ SetAutoRenewStatus(false); true
+ GetAutoRenewMonths(); 6
+ SetAutoRenewMonths(-12); true
+ GetAutoRenewMonths(); -12
+ SetAutoRenewMonths(-12); true
+ SetAutoRenewMonths(6); true
+ GetAutoRenewMoney(); 100000
+ SetAutoRenewMoney(200000); true
+ GetAutoRenewMoney(); 200000
+ SetAutoRenewMoney(200000); true
+ SetAutoRenewMoney(100000); true
+ Quarter: -1
+ GetQuarterlyIncome(); -1
+ GetQuarterlyExpenses(); -1
+ GetQuarterlyCargoDelivered(); -1
+ GetQuarterlyPerformanceRating(); -1
+ GetQuarterlyCompanyValue(); -1
+ Quarter: 0
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); -210
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); -1
+ GetQuarterlyCompanyValue(); 1
+ Quarter: 1
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 2
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 3
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 4
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 5
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 6
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 7
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 8
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 9
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 10
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 11
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 12
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 13
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 14
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 15
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 16
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 17
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 18
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 19
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 20
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 21
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 22
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 23
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
+ Quarter: 24
+ GetQuarterlyIncome(); 0
+ GetQuarterlyExpenses(); 0
+ GetQuarterlyCargoDelivered(); 0
+ GetQuarterlyPerformanceRating(); 0
+ GetQuarterlyCompanyValue(); 0
--AIAirport--
IsHangarTile(): false
diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp
index d9cc76e3a..76897a837 100644
--- a/src/ai/api/ai_changelog.hpp
+++ b/src/ai/api/ai_changelog.hpp
@@ -19,6 +19,17 @@
*
* 1.2.0 is not yet released. The following changes are not set in stone yet.
*
+ * API additions:
+ *
+ * \li AICompany::GetQuarterlyIncome
+ * \li AICompany::GetQuarterlyExpenses
+ * \li AICompany::GetQuarterlyCargoDelivered
+ * \li AICompany::GetQuarterlyPerformanceRating
+ * \li AICompany::GetQuarterlyCompanyValue
+ *
+ * API removals:
+ * \li AICompany::GetCompanyValue, use AICompany::GetQuarterlyCompanyValue instead.
+ *
* \b 1.1.0
*
* API additions:
diff --git a/src/ai/api/ai_company.cpp b/src/ai/api/ai_company.cpp
index c2a4f2935..90487951c 100644
--- a/src/ai/api/ai_company.cpp
+++ b/src/ai/api/ai_company.cpp
@@ -101,14 +101,65 @@
return HasBit(ge, ::GENDER_FEMALE) ? GENDER_FEMALE : GENDER_MALE;
}
-/* static */ Money AICompany::GetCompanyValue(AICompany::CompanyID company)
+/* static */ Money AICompany::GetQuarterlyIncome(AICompany::CompanyID company, uint32 quarter)
{
company = ResolveCompanyID(company);
if (company == COMPANY_INVALID) return -1;
+ if (quarter > EARLIEST_QUARTER) return -1;
- return ::CalculateCompanyValue(::Company::Get((CompanyID)company));
+ if (quarter == CURRENT_QUARTER) {
+ return ::Company::Get((::CompanyID)company)->cur_economy.income;
+ }
+ return ::Company::Get((::CompanyID)company)->old_economy[quarter - 1].income;
+}
+
+/* static */ Money AICompany::GetQuarterlyExpenses(AICompany::CompanyID company, uint32 quarter)
+{
+ company = ResolveCompanyID(company);
+ if (company == COMPANY_INVALID) return -1;
+ if (quarter > EARLIEST_QUARTER) return -1;
+
+ if (quarter == CURRENT_QUARTER) {
+ return ::Company::Get((::CompanyID)company)->cur_economy.expenses;
+ }
+ return ::Company::Get((::CompanyID)company)->old_economy[quarter - 1].expenses;
+}
+
+/* static */ int32 AICompany::GetQuarterlyCargoDelivered(AICompany::CompanyID company, uint32 quarter)
+{
+ company = ResolveCompanyID(company);
+ if (company == COMPANY_INVALID) return -1;
+ if (quarter > EARLIEST_QUARTER) return -1;
+
+ if (quarter == CURRENT_QUARTER) {
+ return ::Company::Get((::CompanyID)company)->cur_economy.delivered_cargo;
+ }
+ return ::Company::Get((::CompanyID)company)->old_economy[quarter - 1].delivered_cargo;
}
+/* static */ int32 AICompany::GetQuarterlyPerformanceRating(AICompany::CompanyID company, uint32 quarter)
+{
+ company = ResolveCompanyID(company);
+ if (company == COMPANY_INVALID) return -1;
+ if (quarter > EARLIEST_QUARTER) return -1;
+ if (quarter == CURRENT_QUARTER) return -1;
+
+ return ::Company::Get((::CompanyID)company)->old_economy[quarter - 1].performance_history;
+}
+
+/* static */ Money AICompany::GetQuarterlyCompanyValue(AICompany::CompanyID company, uint32 quarter)
+{
+ company = ResolveCompanyID(company);
+ if (company == COMPANY_INVALID) return -1;
+ if (quarter > EARLIEST_QUARTER) return -1;
+
+ if (quarter == CURRENT_QUARTER) {
+ return ::CalculateCompanyValue(::Company::Get((::CompanyID)company));
+ }
+ return ::Company::Get((::CompanyID)company)->old_economy[quarter - 1].company_value;
+}
+
+
/* static */ Money AICompany::GetBankBalance(AICompany::CompanyID company)
{
company = ResolveCompanyID(company);
diff --git a/src/ai/api/ai_company.hpp b/src/ai/api/ai_company.hpp
index 263271fc1..f7e329531 100644
--- a/src/ai/api/ai_company.hpp
+++ b/src/ai/api/ai_company.hpp
@@ -22,6 +22,12 @@ public:
/** Get the name of this class to identify it towards squirrel. */
static const char *GetClassName() { return "AICompany"; }
+ /** The range of possible quarters to get company information of. */
+ enum Quarter {
+ CURRENT_QUARTER = 0, ///< The current quarter.
+ EARLIEST_QUARTER = MAX_HISTORY_QUARTERS, ///< The earliest quarter company information is available for.
+ };
+
/** Different constants related to CompanyID. */
enum CompanyID {
COMPANY_FIRST = 0, ///< The first available company.
@@ -149,14 +155,6 @@ public:
static Money GetLoanInterval();
/**
- * Gets the current value of the given company.
- * @param company The company to get the company value of.
- * @pre ResolveCompanyID(company) != COMPANY_INVALID.
- * @return The current value of the given company.
- */
- static Money GetCompanyValue(CompanyID company);
-
- /**
* Gets the bank balance. In other words, the amount of money the given company can spent.
* @param company The company to get the bank balance of.
* @pre ResolveCompanyID(company) != COMPANY_INVALID.
@@ -165,6 +163,58 @@ public:
static Money GetBankBalance(CompanyID company);
/**
+ * Get the income of the company in the given quarter.
+ * @param company The company to get the quarterly income of.
+ * @param quarter The quarter to get the income of.
+ * @pre ResolveCompanyID(company) != COMPANY_INVALID.
+ * @pre quarter <= EARLIEST_QUARTER.
+ * @return The bruto income of the company in the given quarter.
+ */
+ static Money GetQuarterlyIncome(CompanyID company, uint32 quarter);
+
+ /**
+ * Get the expenses of the company in the given quarter.
+ * @param company The company to get the quarterly expenses of.
+ * @param quarter The quarter to get the expenses of.
+ * @pre ResolveCompanyID(company) != COMPANY_INVALID.
+ * @pre quarter <= EARLIEST_QUARTER.
+ * @return The expenses of the company in the given quarter.
+ */
+ static Money GetQuarterlyExpenses(CompanyID company, uint32 quarter);
+
+ /**
+ * Get the amount of cargo delivered by the given company in the given quarter.
+ * @param company The company to get the amount of delivered cargo of.
+ * @param quarter The quarter to get the amount of delivered cargo of.
+ * @pre ResolveCompanyID(company) != COMPANY_INVALID.
+ * @pre quarter <= EARLIEST_QUARTER.
+ * @return The amount of cargo delivered by the given company in the given quarter.
+ */
+ static int32 GetQuarterlyCargoDelivered(CompanyID company, uint32 quarter);
+
+ /**
+ * Get the performance rating of the given company in the given quarter.
+ * @param company The company to get the performance rating of.
+ * @param quarter The quarter to get the performance rating of.
+ * @pre ResolveCompanyID(company) != COMPANY_INVALID.
+ * @pre quarter <= EARLIEST_QUARTER.
+ * @pre quarter != CURRENT_QUARTER.
+ * @note The performance rating is calculated after every quarter, so the value for CURRENT_QUARTER is undefined.
+ * @return The performance rating of the given company in the given quarter.
+ */
+ static int32 GetQuarterlyPerformanceRating(CompanyID company, uint32 quarter);
+
+ /**
+ * Get the value of the company in the given quarter.
+ * @param company The company to get the value of.
+ * @param quarter The quarter to get the value of.
+ * @pre ResolveCompanyID(company) != COMPANY_INVALID.
+ * @pre quarter <= EARLIEST_QUARTER.
+ * @return The value of the company in the given quarter.
+ */
+ static Money GetQuarterlyCompanyValue(CompanyID company, uint32 quarter);
+
+ /**
* Build your company's HQ on the given tile.
* @param tile The tile to build your HQ on, this tile is the most nothern tile of your HQ.
* @pre AIMap::IsValidTile(tile).
diff --git a/src/ai/api/ai_company.hpp.sq b/src/ai/api/ai_company.hpp.sq
index e91989834..8673cb842 100644
--- a/src/ai/api/ai_company.hpp.sq
+++ b/src/ai/api/ai_company.hpp.sq
@@ -32,37 +32,43 @@ void SQAICompany_Register(Squirrel *engine)
SQAICompany.PreRegister(engine);
SQAICompany.AddConstructor<void (AICompany::*)(), 1>(engine, "x");
- SQAICompany.DefSQConst(engine, AICompany::COMPANY_FIRST, "COMPANY_FIRST");
- SQAICompany.DefSQConst(engine, AICompany::COMPANY_LAST, "COMPANY_LAST");
- SQAICompany.DefSQConst(engine, AICompany::COMPANY_SELF, "COMPANY_SELF");
- SQAICompany.DefSQConst(engine, AICompany::COMPANY_INVALID, "COMPANY_INVALID");
- SQAICompany.DefSQConst(engine, AICompany::GENDER_MALE, "GENDER_MALE");
- SQAICompany.DefSQConst(engine, AICompany::GENDER_FEMALE, "GENDER_FEMALE");
- SQAICompany.DefSQConst(engine, AICompany::GENDER_INVALID, "GENDER_INVALID");
+ SQAICompany.DefSQConst(engine, AICompany::CURRENT_QUARTER, "CURRENT_QUARTER");
+ SQAICompany.DefSQConst(engine, AICompany::EARLIEST_QUARTER, "EARLIEST_QUARTER");
+ SQAICompany.DefSQConst(engine, AICompany::COMPANY_FIRST, "COMPANY_FIRST");
+ SQAICompany.DefSQConst(engine, AICompany::COMPANY_LAST, "COMPANY_LAST");
+ SQAICompany.DefSQConst(engine, AICompany::COMPANY_SELF, "COMPANY_SELF");
+ SQAICompany.DefSQConst(engine, AICompany::COMPANY_INVALID, "COMPANY_INVALID");
+ SQAICompany.DefSQConst(engine, AICompany::GENDER_MALE, "GENDER_MALE");
+ SQAICompany.DefSQConst(engine, AICompany::GENDER_FEMALE, "GENDER_FEMALE");
+ SQAICompany.DefSQConst(engine, AICompany::GENDER_INVALID, "GENDER_INVALID");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::ResolveCompanyID, "ResolveCompanyID", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::IsMine, "IsMine", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::SetName, "SetName", 2, "..");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetName, "GetName", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::SetPresidentName, "SetPresidentName", 2, "..");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetPresidentName, "GetPresidentName", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::SetPresidentGender, "SetPresidentGender", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetPresidentGender, "GetPresidentGender", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::SetLoanAmount, "SetLoanAmount", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::SetMinimumLoanAmount, "SetMinimumLoanAmount", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetLoanAmount, "GetLoanAmount", 1, ".");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetMaxLoanAmount, "GetMaxLoanAmount", 1, ".");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetLoanInterval, "GetLoanInterval", 1, ".");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetCompanyValue, "GetCompanyValue", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetBankBalance, "GetBankBalance", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::BuildCompanyHQ, "BuildCompanyHQ", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetCompanyHQ, "GetCompanyHQ", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::SetAutoRenewStatus, "SetAutoRenewStatus", 2, ".b");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetAutoRenewStatus, "GetAutoRenewStatus", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::SetAutoRenewMonths, "SetAutoRenewMonths", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetAutoRenewMonths, "GetAutoRenewMonths", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::SetAutoRenewMoney, "SetAutoRenewMoney", 2, ".i");
- SQAICompany.DefSQStaticMethod(engine, &AICompany::GetAutoRenewMoney, "GetAutoRenewMoney", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::ResolveCompanyID, "ResolveCompanyID", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::IsMine, "IsMine", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::SetName, "SetName", 2, "..");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetName, "GetName", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::SetPresidentName, "SetPresidentName", 2, "..");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetPresidentName, "GetPresidentName", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::SetPresidentGender, "SetPresidentGender", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetPresidentGender, "GetPresidentGender", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::SetLoanAmount, "SetLoanAmount", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::SetMinimumLoanAmount, "SetMinimumLoanAmount", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetLoanAmount, "GetLoanAmount", 1, ".");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetMaxLoanAmount, "GetMaxLoanAmount", 1, ".");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetLoanInterval, "GetLoanInterval", 1, ".");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetQuarterlyIncome, "GetQuarterlyIncome", 3, ".ii");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetQuarterlyExpenses, "GetQuarterlyExpenses", 3, ".ii");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetQuarterlyCargoDelivered, "GetQuarterlyCargoDelivered", 3, ".ii");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetQuarterlyPerformanceRating, "GetQuarterlyPerformanceRating", 3, ".ii");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetQuarterlyCompanyValue, "GetQuarterlyCompanyValue", 3, ".ii");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetBankBalance, "GetBankBalance", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::BuildCompanyHQ, "BuildCompanyHQ", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetCompanyHQ, "GetCompanyHQ", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::SetAutoRenewStatus, "SetAutoRenewStatus", 2, ".b");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetAutoRenewStatus, "GetAutoRenewStatus", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::SetAutoRenewMonths, "SetAutoRenewMonths", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetAutoRenewMonths, "GetAutoRenewMonths", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::SetAutoRenewMoney, "SetAutoRenewMoney", 2, ".i");
+ SQAICompany.DefSQStaticMethod(engine, &AICompany::GetAutoRenewMoney, "GetAutoRenewMoney", 2, ".i");
SQAICompany.PostRegister(engine);
}