summaryrefslogtreecommitdiff
path: root/src/ai/api
diff options
context:
space:
mode:
Diffstat (limited to 'src/ai/api')
-rw-r--r--src/ai/api/ai_rail.cpp2
-rw-r--r--src/ai/api/ai_rail.hpp1
-rw-r--r--src/ai/api/ai_tile.cpp5
-rw-r--r--src/ai/api/ai_tile.hpp2
4 files changed, 8 insertions, 2 deletions
diff --git a/src/ai/api/ai_rail.cpp b/src/ai/api/ai_rail.cpp
index c6aefe714..8d4606544 100644
--- a/src/ai/api/ai_rail.cpp
+++ b/src/ai/api/ai_rail.cpp
@@ -14,6 +14,7 @@
#include "ai_map.hpp"
#include "ai_station.hpp"
#include "ai_industrytype.hpp"
+#include "ai_cargo.hpp"
#include "../../debug.h"
#include "../../station_base.h"
#include "../../company_func.h"
@@ -170,6 +171,7 @@
EnforcePrecondition(false, platform_length > 0 && platform_length <= 0xFF);
EnforcePrecondition(false, IsRailTypeAvailable(GetCurrentRailType()));
EnforcePrecondition(false, station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id));
+ EnforcePrecondition(false, AICargo::IsValidCargo(cargo_id));
EnforcePrecondition(false, source_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(source_industry));
EnforcePrecondition(false, goal_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(goal_industry));
diff --git a/src/ai/api/ai_rail.hpp b/src/ai/api/ai_rail.hpp
index 5f58c3014..9bb759ea7 100644
--- a/src/ai/api/ai_rail.hpp
+++ b/src/ai/api/ai_rail.hpp
@@ -279,6 +279,7 @@ public:
* @pre num_platforms > 0 && num_platforms <= 255.
* @pre platform_length > 0 && platform_length <= 255.
* @pre station_id == AIStation::STATION_NEW || station_id == AIStation::STATION_JOIN_ADJACENT || AIStation::IsValidStation(station_id).
+ * @pre AICargo::IsValidCargo(cargo_type)
* @pre source_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || source_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(source_industry).
* @pre goal_industry == AIIndustryType::INDUSTRYTYPE_UNKNOWN || goal_industry == AIIndustryType::INDUSTRYTYPE_TOWN || AIIndustryType::IsValidIndustryType(goal_industry).
* @exception AIError::ERR_OWNED_BY_ANOTHER_COMPANY
diff --git a/src/ai/api/ai_tile.cpp b/src/ai/api/ai_tile.cpp
index 3e0b339f7..671567190 100644
--- a/src/ai/api/ai_tile.cpp
+++ b/src/ai/api/ai_tile.cpp
@@ -13,6 +13,7 @@
#include "ai_tile.hpp"
#include "ai_map.hpp"
#include "ai_town.hpp"
+#include "ai_cargo.hpp"
#include "../../station_func.h"
#include "../../company_func.h"
#include "../../water_map.h"
@@ -192,7 +193,7 @@
/* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
{
- if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0) return -1;
+ if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !AICargo::IsValidCargo(cargo_type)) return -1;
CargoArray acceptance = ::GetAcceptanceAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
return acceptance[cargo_type];
@@ -200,7 +201,7 @@
/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
{
- if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0) return -1;
+ if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius < 0 || !AICargo::IsValidCargo(cargo_type)) return -1;
CargoArray produced = ::GetProductionAroundTiles(tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
return produced[cargo_type];
diff --git a/src/ai/api/ai_tile.hpp b/src/ai/api/ai_tile.hpp
index 944821e00..17a292ae3 100644
--- a/src/ai/api/ai_tile.hpp
+++ b/src/ai/api/ai_tile.hpp
@@ -319,6 +319,7 @@ public:
* @param height The height of the station.
* @param radius The radius of the station.
* @pre AIMap::IsValidTile(tile).
+ * @pre AICargo::IsValidCargo(cargo_type)
* @pre width > 0.
* @pre height > 0.
* @pre radius >= 0.
@@ -335,6 +336,7 @@ public:
* @param height The height of the station.
* @param radius The radius of the station.
* @pre AIMap::IsValidTile(tile).
+ * @pre AICargo::IsValidCargo(cargo_type)
* @pre width > 0.
* @pre height > 0.
* @pre radius >= 0.