diff options
author | smatz <smatz@openttd.org> | 2009-08-27 13:47:03 +0000 |
---|---|---|
committer | smatz <smatz@openttd.org> | 2009-08-27 13:47:03 +0000 |
commit | 072ce4bb17dcb02e8e832f46e4fcadfd7c4be944 (patch) | |
tree | a7db2661ae804f06e41ab9b237e7a9e2558be39b | |
parent | 100ae8efcc592ec44f0cc161e0045fb84b67c45e (diff) | |
download | openttd-072ce4bb17dcb02e8e832f46e4fcadfd7c4be944.tar.xz |
(svn r17293) -Fix [NoAI]: AITown::GetLastMonthTransported didn't work as documented at all, make it return what AITown::GetLastMonthProduction did
-Change [NoAI]: mark AITown::GetMaxProduction as deprecated, AITown::GetLastMonthProduction returns now the value GetMaxProduction did
-rw-r--r-- | bin/ai/compat_0.7.nut | 7 | ||||
-rw-r--r-- | src/ai/api/ai_changelog.hpp | 1 | ||||
-rw-r--r-- | src/ai/api/ai_station.cpp | 2 | ||||
-rw-r--r-- | src/ai/api/ai_town.cpp | 22 | ||||
-rw-r--r-- | src/ai/api/ai_town.hpp | 12 | ||||
-rw-r--r-- | src/ai/api/ai_town.hpp.sq | 1 |
6 files changed, 13 insertions, 32 deletions
diff --git a/bin/ai/compat_0.7.nut b/bin/ai/compat_0.7.nut index 8020d57b2..377044326 100644 --- a/bin/ai/compat_0.7.nut +++ b/bin/ai/compat_0.7.nut @@ -69,3 +69,10 @@ AISubsidy.GetDestination <- function(subsidy_id) return AISubsidy.GetDestinationIndex(subsidy_id); } + +AITown.GetMaxProduction <- function(town_id, cargo_id) +{ + AILog.Warning("AITown::GetMaxProduction is deprecated and will be removed soon, please use AITown::GetLastMonthProduction instead."); + AILog.Warning("Also note that behaviour of AITown::GetLastMonthProduction has slightly changed."); + return AITown.GetLastMonthProduction(town_id, cargo_id); +} diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp index 34cc39130..d3511422c 100644 --- a/src/ai/api/ai_changelog.hpp +++ b/src/ai/api/ai_changelog.hpp @@ -35,6 +35,7 @@ * \li AISubsidy::GetSource * \li AISubsidy::DestinationIsTown * \li AISubsidy::GetDestination + * \li AITown::GetMaxProduction * \li AIWaypoint::WAYPOINT_INVALID * * Other changes: diff --git a/src/ai/api/ai_station.cpp b/src/ai/api/ai_station.cpp index 725b1471a..ce9dc62a8 100644 --- a/src/ai/api/ai_station.cpp +++ b/src/ai/api/ai_station.cpp @@ -48,7 +48,7 @@ if (!IsValidStation(station_id)) return -1; if (!AICargo::IsValidCargo(cargo_id)) return -1; - return ::Station::Get(station_id)->goods[cargo_id].rating * 101 >> 8; + return ::ToPercent8(::Station::Get(station_id)->goods[cargo_id].rating); } /* static */ int32 AIStation::GetCoverageRadius(AIStation::StationType station_type) diff --git a/src/ai/api/ai_town.cpp b/src/ai/api/ai_town.cpp index 9f497047d..72f068f09 100644 --- a/src/ai/api/ai_town.cpp +++ b/src/ai/api/ai_town.cpp @@ -72,8 +72,8 @@ const Town *t = ::Town::Get(town_id); switch (AICargo::GetTownEffect(cargo_id)) { - case AICargo::TE_PASSENGERS: return t->act_pass; - case AICargo::TE_MAIL: return t->act_mail; + case AICargo::TE_PASSENGERS: return t->max_pass; + case AICargo::TE_MAIL: return t->max_mail; default: return -1; } } @@ -86,22 +86,8 @@ const Town *t = ::Town::Get(town_id); switch (AICargo::GetTownEffect(cargo_id)) { - case AICargo::TE_PASSENGERS: return t->pct_pass_transported; - case AICargo::TE_MAIL: return t->pct_mail_transported; - default: return -1; - } -} - -/* static */ int32 AITown::GetMaxProduction(TownID town_id, CargoID cargo_id) -{ - if (!IsValidTown(town_id)) return -1; - if (!AICargo::IsValidCargo(cargo_id)) return -1; - - const Town *t = ::Town::Get(town_id); - - switch (AICargo::GetTownEffect(cargo_id)) { - case AICargo::TE_PASSENGERS: return t->max_pass; - case AICargo::TE_MAIL: return t->max_mail; + case AICargo::TE_PASSENGERS: return t->act_pass; + case AICargo::TE_MAIL: return t->act_mail; default: return -1; } } diff --git a/src/ai/api/ai_town.hpp b/src/ai/api/ai_town.hpp index f0df98c2a..dca8a36e9 100644 --- a/src/ai/api/ai_town.hpp +++ b/src/ai/api/ai_town.hpp @@ -176,18 +176,6 @@ public: static int32 GetLastMonthTransported(TownID town_id, CargoID cargo_id); /** - * Get the maximum production of the given cargo at a town. - * @param town_id The index of the town. - * @param cargo_id The index of the cargo. - * @pre IsValidTown(town_id). - * @pre AICargo::IsValidCargo(cargo_id). - * @pre AICargo::GetTownEffect(cargo_id) == TE_PASSENGERS || AICargo::GetTownEffect(cargo_id) == TE_MAIL. - * @return The maximum production of the given cargo for this town. - * @post Return value is always non-negative. - */ - static int32 GetMaxProduction(TownID town_id, CargoID cargo_id); - - /** * Get the manhattan distance from the tile to the AITown::GetLocation() * of the town. * @param town_id The town to get the distance to. diff --git a/src/ai/api/ai_town.hpp.sq b/src/ai/api/ai_town.hpp.sq index 58937f62b..bb10e8fba 100644 --- a/src/ai/api/ai_town.hpp.sq +++ b/src/ai/api/ai_town.hpp.sq @@ -65,7 +65,6 @@ void SQAITown_Register(Squirrel *engine) { SQAITown.DefSQStaticMethod(engine, &AITown::GetLocation, "GetLocation", 2, ".i"); SQAITown.DefSQStaticMethod(engine, &AITown::GetLastMonthProduction, "GetLastMonthProduction", 3, ".ii"); SQAITown.DefSQStaticMethod(engine, &AITown::GetLastMonthTransported, "GetLastMonthTransported", 3, ".ii"); - SQAITown.DefSQStaticMethod(engine, &AITown::GetMaxProduction, "GetMaxProduction", 3, ".ii"); SQAITown.DefSQStaticMethod(engine, &AITown::GetDistanceManhattanToTile, "GetDistanceManhattanToTile", 3, ".ii"); SQAITown.DefSQStaticMethod(engine, &AITown::GetDistanceSquareToTile, "GetDistanceSquareToTile", 3, ".ii"); SQAITown.DefSQStaticMethod(engine, &AITown::IsWithinTownInfluence, "IsWithinTownInfluence", 3, ".ii"); |