diff --git a/docs/script-additions.html b/docs/script-additions.html
index 5c4fd62945..47b6b9b7b1 100644
--- a/docs/script-additions.html
+++ b/docs/script-additions.html
@@ -96,6 +96,26 @@
+
+
+
Additional Static Public Member Functions:
+
+
static bool GetAnnualExpenseValue (CompanyID company, uint32 year_offset, ExpensesType expenses_type)
+
Get the annual expense value for the given company.
+
year_offset is relative to the current year and must be either: 0, 1, or 2.
+
+
Additional Enum Values:
+
+
+
ExpensesType
+
Additional value: EXPENSES_SHARING_COST
+
Infrastructure sharing costs.
+
Additional value: EXPENSES_SHARING_INC
+
Infrastructure sharing income.
+
ExpensesType is additionally available via AICompany.
+
+
+
Inflation: GSInflation Class and AIInflation Class
Static Public Member Functions:
diff --git a/src/script/api/script_company.cpp b/src/script/api/script_company.cpp
index dddcc950c7..79d076321e 100644
--- a/src/script/api/script_company.cpp
+++ b/src/script/api/script_company.cpp
@@ -167,6 +167,17 @@
return ::Company::Get(company)->old_economy[quarter - 1].company_value;
}
+/* static */ Money ScriptCompany::GetAnnualExpenseValue(CompanyID company, uint32 year_offset, ExpensesType expenses_type)
+{
+ EnforcePrecondition(false, expenses_type < (ExpensesType)::EXPENSES_END);
+ EnforcePrecondition(false, year_offset <= 2);
+
+ company = ResolveCompanyID(company);
+ if (company == COMPANY_INVALID) return -1;
+
+ return ::Company::Get(company)->yearly_expenses[year_offset][expenses_type];
+}
+
/* static */ Money ScriptCompany::GetBankBalance(ScriptCompany::CompanyID company)
{
diff --git a/src/script/api/script_company.hpp b/src/script/api/script_company.hpp
index 947698b171..0b517eb245 100644
--- a/src/script/api/script_company.hpp
+++ b/src/script/api/script_company.hpp
@@ -97,7 +97,6 @@ public:
/**
* Types of expenses.
- * @api -ai
*/
enum ExpensesType : byte {
EXPENSES_CONSTRUCTION = ::EXPENSES_CONSTRUCTION, ///< Construction costs.
@@ -113,6 +112,8 @@ public:
EXPENSES_SHIP_INC = ::EXPENSES_SHIP_REVENUE, ///< Revenue from ships.
EXPENSES_LOAN_INT = ::EXPENSES_LOAN_INTEREST, ///< Interest payments over the loan.
EXPENSES_OTHER = ::EXPENSES_OTHER, ///< Other expenses.
+ EXPENSES_SHARING_COST = ::EXPENSES_SHARING_COST, ///< Infrastructure sharing costs.
+ EXPENSES_SHARING_INC = ::EXPENSES_SHARING_INC, ///< Infrastructure sharing income.
EXPENSES_INVALID = ::INVALID_EXPENSES, ///< Invalid expense type.
};
@@ -310,6 +311,17 @@ public:
*/
static Money GetQuarterlyCompanyValue(CompanyID company, uint32 quarter);
+ /**
+ * Get the expense category value of the company in the given year (relative to the current year).
+ * @param company The company to get the value of.
+ * @param year_offset The year, relative to the current year (value values are 0, 1, and 2).
+ * @param expenses_type The expense category to return.
+ * @pre ResolveCompanyID(company) != COMPANY_INVALID.
+ * @pre year_offset <= 2.
+ * @return The value of the company in the given quarter.
+ */
+ static Money GetAnnualExpenseValue(CompanyID company, uint32 year_offset, ExpensesType expenses_type);
+
/**
* Build your company's HQ on the given tile.
* @param tile The tile to build your HQ on, this tile is the most northern tile of your HQ.