--- a/src/ai/api/ai_town.cpp Wed Jun 04 22:57:17 2008 +0000
+++ b/src/ai/api/ai_town.cpp Fri Jun 06 00:44:23 2008 +0000
@@ -4,6 +4,7 @@
#include "ai_town.hpp"
#include "ai_map.hpp"
+#include "ai_cargo.hpp"
#include "../../openttd.h"
#include "../../town.h"
#include "../../strings_func.h"
@@ -44,6 +45,13 @@
return t->population;
}
+/* static */ int32 AITown::GetNumHouses(TownID town_id)
+{
+ if (!IsValidTown(town_id)) return -1;
+ const Town *t = ::GetTown(town_id);
+ return t->num_houses;
+}
+
/* static */ TileIndex AITown::GetLocation(TownID town_id)
{
if (!IsValidTown(town_id)) return INVALID_TILE;
@@ -51,6 +59,48 @@
return t->xy;
}
+/* static */ int32 AITown::GetLastMonthProduction(TownID town_id, CargoID cargo_id)
+{
+ if (!IsValidTown(town_id)) return -1;
+ if (!AICargo::IsValidCargo(cargo_id)) return -1;
+
+ const Town *t = ::GetTown(town_id);
+
+ switch(AICargo::GetTownEffect(cargo_id)) {
+ case AICargo::TE_PASSENGERS: return t->act_pass;
+ case AICargo::TE_MAIL: return t->act_mail;
+ default: return -1;
+ }
+}
+
+/* static */ int32 AITown::GetLastMonthTransported(TownID town_id, CargoID cargo_id)
+{
+ if (!IsValidTown(town_id)) return -1;
+ if (!AICargo::IsValidCargo(cargo_id)) return -1;
+
+ const Town *t = ::GetTown(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 = ::GetTown(town_id);
+
+ switch(AICargo::GetTownEffect(cargo_id)) {
+ case AICargo::TE_PASSENGERS: return t->max_pass;
+ case AICargo::TE_MAIL: return t->max_mail;
+ default: return -1;
+ }
+}
+
/* static */ int32 AITown::GetDistanceManhattanToTile(TownID town_id, TileIndex tile)
{
return AIMap::DistanceManhattan(tile, GetLocation(town_id));