mirror of https://github.com/OpenTTD/OpenTTD.git
(svn r16524) -Fix [FS#2963]: missing guards in the NoAI API making it possible to hit an assert in OpenTTD.
This commit is contained in:
parent
0b8ceb3007
commit
ec3ef70adb
|
@ -175,21 +175,21 @@
|
|||
return ::TrackStatusToTrackdirBits(::GetTileTrackStatus(tile, (::TransportType)transport_type, UINT32_MAX)) != TRACKDIR_BIT_NONE;
|
||||
}
|
||||
|
||||
/* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius)
|
||||
/* static */ int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
|
||||
{
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius <= 0) return -1;
|
||||
|
||||
AcceptedCargo accepts;
|
||||
::GetAcceptanceAroundTiles(accepts, tile, width, height, _settings_game.station.modified_catchment ? radius : (uint)CA_UNMODIFIED);
|
||||
::GetAcceptanceAroundTiles(accepts, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
|
||||
return accepts[cargo_type];
|
||||
}
|
||||
|
||||
/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius)
|
||||
/* static */ int32 AITile::GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius)
|
||||
{
|
||||
if (!::IsValidTile(tile)) return false;
|
||||
if (!::IsValidTile(tile) || width <= 0 || height <= 0 || radius <= 0) return -1;
|
||||
|
||||
AcceptedCargo produced;
|
||||
::GetProductionAroundTiles(produced, tile, width, height, _settings_game.station.modified_catchment ? radius : (uint)CA_UNMODIFIED);
|
||||
::GetProductionAroundTiles(produced, tile, width, height, _settings_game.station.modified_catchment ? radius : (int)CA_UNMODIFIED);
|
||||
return produced[cargo_type];
|
||||
}
|
||||
|
||||
|
|
|
@ -303,9 +303,12 @@ public:
|
|||
* @param height The height of the station.
|
||||
* @param radius The radius of the station.
|
||||
* @pre AIMap::IsValidTile(tile).
|
||||
* @pre width > 0.
|
||||
* @pre height > 0.
|
||||
* @pre radius > 0.
|
||||
* @return Value below 8 means no acceptance; the more the better.
|
||||
*/
|
||||
static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
|
||||
static int32 GetCargoAcceptance(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
|
||||
|
||||
/**
|
||||
* Checks how many tiles in the radius produces this cargo.
|
||||
|
@ -317,10 +320,13 @@ public:
|
|||
* @param height The height of the station.
|
||||
* @param radius The radius of the station.
|
||||
* @pre AIMap::IsValidTile(tile).
|
||||
* @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.
|
||||
*/
|
||||
static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, uint width, uint height, uint radius);
|
||||
static int32 GetCargoProduction(TileIndex tile, CargoID cargo_type, int width, int height, int radius);
|
||||
|
||||
/**
|
||||
* Get the manhattan distance from the tile to the tile.
|
||||
|
|
|
@ -68,9 +68,9 @@ void AITileList::RemoveTile(TileIndex tile)
|
|||
this->RemoveItem(tile);
|
||||
}
|
||||
|
||||
AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_id, uint radius)
|
||||
AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_id, int radius)
|
||||
{
|
||||
if (!AIIndustry::IsValidIndustry(industry_id)) return;
|
||||
if (!AIIndustry::IsValidIndustry(industry_id) || radius <= 0) return;
|
||||
|
||||
const Industry *i = ::Industry::Get(industry_id);
|
||||
|
||||
|
@ -106,9 +106,9 @@ AITileList_IndustryAccepting::AITileList_IndustryAccepting(IndustryID industry_i
|
|||
} END_TILE_LOOP(cur_tile, i->width + radius * 2, i->height + radius * 2, i->xy - ::TileDiffXY(radius, radius))
|
||||
}
|
||||
|
||||
AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_id, uint radius)
|
||||
AITileList_IndustryProducing::AITileList_IndustryProducing(IndustryID industry_id, int radius)
|
||||
{
|
||||
if (!AIIndustry::IsValidIndustry(industry_id)) return;
|
||||
if (!AIIndustry::IsValidIndustry(industry_id) || radius <= 0) return;
|
||||
|
||||
const Industry *i = ::Industry::Get(industry_id);
|
||||
|
||||
|
|
|
@ -71,8 +71,10 @@ public:
|
|||
/**
|
||||
* @param industry_id The industry to create the AITileList around.
|
||||
* @param radius The radius of the station you will be using.
|
||||
* @pre AIIndustry::IsValidIndustry(industry_id).
|
||||
* @pre radius > 0.
|
||||
*/
|
||||
AITileList_IndustryAccepting(IndustryID industry_id, uint radius);
|
||||
AITileList_IndustryAccepting(IndustryID industry_id, int radius);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -87,8 +89,10 @@ public:
|
|||
/**
|
||||
* @param industry_id The industry to create the AITileList around.
|
||||
* @param radius The radius of the station you will be using.
|
||||
* @pre AIIndustry::IsValidIndustry(industry_id).
|
||||
* @pre radius > 0.
|
||||
*/
|
||||
AITileList_IndustryProducing(IndustryID industry_id, uint radius);
|
||||
AITileList_IndustryProducing(IndustryID industry_id, int radius);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue