summaryrefslogtreecommitdiff
path: root/src/ai
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2009-08-07 22:23:34 +0000
committersmatz <smatz@openttd.org>2009-08-07 22:23:34 +0000
commit74d3382b946d71445fbce5699d1541946e928450 (patch)
tree03fe2b58ca63a3e1629c08eefbdf061154cc977c /src/ai
parent39e145e586385861b4e3ded70f7df0a29b56fa00 (diff)
downloadopenttd-74d3382b946d71445fbce5699d1541946e928450.tar.xz
(svn r17107) -Codechange: store type of subsidy source and destination in the Subsidy struct instead of determining it every time it's needed
Diffstat (limited to 'src/ai')
-rw-r--r--src/ai/api/ai_subsidy.cpp29
1 files changed, 10 insertions, 19 deletions
diff --git a/src/ai/api/ai_subsidy.cpp b/src/ai/api/ai_subsidy.cpp
index 6e43982c3..fd3e29745 100644
--- a/src/ai/api/ai_subsidy.cpp
+++ b/src/ai/api/ai_subsidy.cpp
@@ -10,21 +10,21 @@
/* static */ bool AISubsidy::IsValidSubsidy(SubsidyID subsidy_id)
{
- return Subsidy::IsValidID(subsidy_id);
+ return ::Subsidy::IsValidID(subsidy_id);
}
/* static */ bool AISubsidy::IsAwarded(SubsidyID subsidy_id)
{
if (!IsValidSubsidy(subsidy_id)) return false;
- return Subsidy::Get(subsidy_id)->IsAwarded();
+ return ::Subsidy::Get(subsidy_id)->IsAwarded();
}
/* static */ AICompany::CompanyID AISubsidy::GetAwardedTo(SubsidyID subsidy_id)
{
if (!IsAwarded(subsidy_id)) return AICompany::COMPANY_INVALID;
- return (AICompany::CompanyID)((byte)Station::Get(Subsidy::Get(subsidy_id)->from)->owner);
+ return (AICompany::CompanyID)((byte)::Station::Get(::Subsidy::Get(subsidy_id)->src)->owner);
}
/* static */ int32 AISubsidy::GetExpireDate(SubsidyID subsidy_id)
@@ -35,9 +35,9 @@
int month = AIDate::GetMonth(AIDate::GetCurrentDate());
if (IsAwarded(subsidy_id)) {
- month += 24 - Subsidy::Get(subsidy_id)->age;
+ month += 24 - ::Subsidy::Get(subsidy_id)->age;
} else {
- month += 12 - Subsidy::Get(subsidy_id)->age;
+ month += 12 - ::Subsidy::Get(subsidy_id)->age;
}
year += (month - 1) / 12;
@@ -50,42 +50,33 @@
{
if (!IsValidSubsidy(subsidy_id)) return CT_INVALID;
- return Subsidy::Get(subsidy_id)->cargo_type;
+ return ::Subsidy::Get(subsidy_id)->cargo_type;
}
/* static */ bool AISubsidy::SourceIsTown(SubsidyID subsidy_id)
{
if (!IsValidSubsidy(subsidy_id) || IsAwarded(subsidy_id)) return false;
- return CargoSpec::Get(GetCargoType(subsidy_id))->town_effect == TE_PASSENGERS ||
- CargoSpec::Get(GetCargoType(subsidy_id))->town_effect == TE_MAIL;
+ return ::Subsidy::Get(subsidy_id)->src_type == ST_TOWN;
}
/* static */ int32 AISubsidy::GetSource(SubsidyID subsidy_id)
{
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
- return Subsidy::Get(subsidy_id)->from;
+ return ::Subsidy::Get(subsidy_id)->src;
}
/* static */ bool AISubsidy::DestinationIsTown(SubsidyID subsidy_id)
{
if (!IsValidSubsidy(subsidy_id) || IsAwarded(subsidy_id)) return false;
- switch (CargoSpec::Get(GetCargoType(subsidy_id))->town_effect) {
- case TE_PASSENGERS:
- case TE_MAIL:
- case TE_GOODS:
- case TE_FOOD:
- return true;
- default:
- return false;
- }
+ return ::Subsidy::Get(subsidy_id)->dst_type == ST_TOWN;
}
/* static */ int32 AISubsidy::GetDestination(SubsidyID subsidy_id)
{
if (!IsValidSubsidy(subsidy_id)) return INVALID_STATION;
- return Subsidy::Get(subsidy_id)->to;
+ return ::Subsidy::Get(subsidy_id)->dst;
}