summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-07-01 18:45:05 +0000
committersmatz <smatz@openttd.org>2009-07-01 18:45:05 +0000
commit76a50ce94dc7c78d76c309d8a639591fed2a2da8 (patch)
tree342be7030b9760781f886bca89cbe01863985008 /src/ai
parentaaeb53066dff98cac2d66d1f02f545d14c9f650c (diff)
downloadopenttd-76a50ce94dc7c78d76c309d8a639591fed2a2da8.tar.xz
(svn r16714) -Codechange: use pool-like accessors for Subsidy
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/api/ai_subsidy.cpp18
-rw-r--r--src/ai/api/ai_subsidylist.cpp4
2 files changed, 11 insertions, 11 deletions
diff --git a/src/ai/api/ai_subsidy.cpp b/src/ai/api/ai_subsidy.cpp
index d8804a828..839654e43 100644
--- a/src/ai/api/ai_subsidy.cpp
+++ b/src/ai/api/ai_subsidy.cpp
@@ -4,27 +4,27 @@
#include "ai_subsidy.hpp"
#include "ai_date.hpp"
-#include "../../subsidy_type.h"
+#include "../../subsidy_base.h"
#include "../../station_base.h"
#include "../../cargotype.h"
/* static */ bool AISubsidy::IsValidSubsidy(SubsidyID subsidy_id)
{
- return subsidy_id < lengthof(_subsidies) && _subsidies[subsidy_id].cargo_type != CT_INVALID;
+ return Subsidy::IsValidID(subsidy_id);
}
/* static */ bool AISubsidy::IsAwarded(SubsidyID subsidy_id)
{
if (!IsValidSubsidy(subsidy_id)) return false;
- return _subsidies[subsidy_id].age >= 12;
+ return Subsidy::Get(subsidy_id)->age >= 12;
}
/* static */ AICompany::CompanyID AISubsidy::GetAwardedTo(SubsidyID subsidy_id)
{
if (!IsAwarded(subsidy_id)) return AICompany::COMPANY_INVALID;
- return (AICompany::CompanyID)((byte)Station::Get(_subsidies[subsidy_id].from)->owner);
+ return (AICompany::CompanyID)((byte)Station::Get(Subsidy::Get(subsidy_id)->from)->owner);
}
/* static */ int32 AISubsidy::GetExpireDate(SubsidyID subsidy_id)
@@ -35,9 +35,9 @@
int month = AIDate::GetMonth(AIDate::GetCurrentDate());
if (IsAwarded(subsidy_id)) {
- month += 24 - _subsidies[subsidy_id].age;
+ month += 24 - Subsidy::Get(subsidy_id)->age;
} else {
- month += 12 - _subsidies[subsidy_id].age;
+ month += 12 - Subsidy::Get(subsidy_id)->age;
}
year += (month - 1) / 12;
@@ -50,7 +50,7 @@
{
if (!IsValidSubsidy(subsidy_id)) return CT_INVALID;
- return _subsidies[subsidy_id].cargo_type;
+ return Subsidy::Get(subsidy_id)->cargo_type;
}
/* static */ bool AISubsidy::SourceIsTown(SubsidyID subsidy_id)
@@ -65,7 +65,7 @@
{
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
- return _subsidies[subsidy_id].from;
+ return Subsidy::Get(subsidy_id)->from;
}
/* static */ bool AISubsidy::DestinationIsTown(SubsidyID subsidy_id)
@@ -87,5 +87,5 @@
{
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
- return _subsidies[subsidy_id].to;
+ return Subsidy::Get(subsidy_id)->to;
}
diff --git a/src/ai/api/ai_subsidylist.cpp b/src/ai/api/ai_subsidylist.cpp
index d372b4b2f..430899cb4 100644
--- a/src/ai/api/ai_subsidylist.cpp
+++ b/src/ai/api/ai_subsidylist.cpp
@@ -4,12 +4,12 @@
#include "ai_subsidylist.hpp"
#include "ai_subsidy.hpp"
-#include "../../subsidy_type.h"
+#include "../../subsidy_base.h"
AISubsidyList::AISubsidyList()
{
const Subsidy *s;
FOR_ALL_SUBSIDIES(s) {
- this->AddItem(s - _subsidies);
+ this->AddItem(s->Index());
}
}