summaryrefslogtreecommitdiff
path: root/src/ai/api
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2010-01-04 21:10:20 +0000
committerrubidium <rubidium@openttd.org>2010-01-04 21:10:20 +0000
commit28fc7b47bd35acc860e84e3885d13ffb0fad2c83 (patch)
treec461b7b47abb73891c5caf5d490cede32158ed0d /src/ai/api
parent1ed599f5cf6a0dec14d91d5442a08560e254d35c (diff)
downloadopenttd-28fc7b47bd35acc860e84e3885d13ffb0fad2c83.tar.xz
(svn r18726) -Fix [FS#3463]: with non-uniform industries the 'supplies' text when building a station could be incorrect (missing a cargo)
-Change [NoAI]: AITile::GetCargoProduction now returns the number of producers and not the number of tiles of producers. -Fix [NoAI]: AITileList_IndustryProducing would omit some tiles for at which a station would get cargo.
Diffstat (limited to 'src/ai/api')
-rw-r--r--src/ai/api/ai_changelog.hpp6
-rw-r--r--src/ai/api/ai_tile.hpp8
-rw-r--r--src/ai/api/ai_tilelist.cpp21
3 files changed, 13 insertions, 22 deletions
diff --git a/src/ai/api/ai_changelog.hpp b/src/ai/api/ai_changelog.hpp
index 23b9d1573..7abe9023f 100644
--- a/src/ai/api/ai_changelog.hpp
+++ b/src/ai/api/ai_changelog.hpp
@@ -91,6 +91,12 @@
* vehicle of that type in your company, regardless if it's still buildable
* or not. AIEngine::IsBuildable returns only true when you can actually
* build an engine.
+ * \li AITile::GetCargoProduction will now return the number of producers,
+ * including houses instead the number of producing tiles. This means that
+ * also industries that do not have a tile within the radius, but where
+ * the search bounding box and the industry's bounding box intersect, are
+ * counted. Previously these industries (and their cargos), although they
+ * produced cargo for a station at the given location, were not returned.
*
* \b 0.7.5
*
diff --git a/src/ai/api/ai_tile.hpp b/src/ai/api/ai_tile.hpp
index 6b254899f..9ba0df031 100644
--- a/src/ai/api/ai_tile.hpp
+++ b/src/ai/api/ai_tile.hpp
@@ -309,9 +309,8 @@ public:
static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
/**
- * Checks how many tiles in the radius produces this cargo.
- * It creates a radius around the tile, and adds up all tiles that produce
- * this cargo.
+ * Checks how many producers in the radius produces this cargo.
+ * It creates a radius around the tile, and counts all producer of this cargo.
* @param tile The tile to check on.
* @param cargo_type The cargo to check the production of.
* @param width The width of the station.
@@ -321,8 +320,7 @@ public:
* @pre width > 0.
* @pre height > 0.
* @pre radius >= 0.
- * @return The tiles that produce this cargo within radius of the tile.
- * @note Town(houses) are not included in the value.
+ * @return The number of producers that produce this cargo within radius of the tile.
*/
static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
diff --git a/src/ai/api/ai_tilelist.cpp b/src/ai/api/ai_tilelist.cpp
index 12ebb1ead..8513ba17c 100644
--- a/src/ai/api/ai_tilelist.cpp
+++ b/src/ai/api/ai_tilelist.cpp
@@ -90,13 +90,11 @@ AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_i
const Industry *i = ::Industry::Get(industry_id);
/* Check if this industry produces anything */
- {
- bool cargo_produces = false;
- for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
- if (i->produced_cargo[j] != CT_INVALID) cargo_produces = true;
- }
- if (!cargo_produces) return;
+ bool cargo_produces = false;
+ for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
+ if (i->produced_cargo[j] != CT_INVALID) cargo_produces = true;
}
+ if (!cargo_produces) return;
if (!_settings_game.station.modified_catchment) radius = CA_UNMODIFIED;
@@ -105,17 +103,6 @@ AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_i
/* Exclude all tiles that belong to this industry */
if (::IsTileType(cur_tile, MP_INDUSTRY) && ::GetIndustryIndex(cur_tile) == industry_id) continue;
- /* Only add the tile if it produces the cargo (a bug in OpenTTD makes this
- * inconsitance). */
- CargoArray produced = ::GetProductionAroundTiles(cur_tile, 1, 1, radius);
- {
- bool cargo_produces = false;
- for (byte j = 0; j < lengthof(i->produced_cargo); j++) {
- if (i->produced_cargo[j] != CT_INVALID && produced[i->produced_cargo[j]] != 0) cargo_produces = true;
- }
- if (!cargo_produces) continue;
- }
-
this->AddTile(cur_tile);
}
}