src/ai/api/ai_tile.cpp
branchnoai
changeset 9728 d7bd32dc6c59
parent 9724 b39bc69bb2f2
child 9729 c264c78a3567
equal deleted inserted replaced
9727:a5fdea13a991 9728:d7bd32dc6c59
    14 {
    14 {
    15 	/* Outside of the map */
    15 	/* Outside of the map */
    16 	if (tile >= ::MapSize()) return false;
    16 	if (tile >= ::MapSize()) return false;
    17 
    17 
    18 	switch (::GetTileType(tile)) {
    18 	switch (::GetTileType(tile)) {
    19 		default: return 1;
    19 		default: return true;
    20 		case MP_VOID:
    20 		case MP_VOID:
    21 		case MP_HOUSE:
    21 		case MP_HOUSE:
    22 		case MP_STATION:
    22 		case MP_STATION:
    23 		case MP_INDUSTRY:
    23 		case MP_INDUSTRY:
    24 		case MP_UNMOVABLE:
    24 		case MP_UNMOVABLE:
    25 		case MP_WATER: return 0;
    25 		case MP_WATER: return false;
    26 	}
    26 	}
    27 }
    27 }
    28 
    28 
    29 bool AITile::IsWater(TileIndex tile)
    29 bool AITile::IsWater(TileIndex tile)
    30 {
    30 {
    51 }
    51 }
    52 
    52 
    53 int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint rad)
    53 int32 AITile::GetCargoAcceptance(TileIndex tile, CargoID cargo_type, uint width, uint height, uint rad)
    54 {
    54 {
    55 	/* Outside of the map */
    55 	/* Outside of the map */
    56 	if (tile >= ::MapSize()) return false;
    56 	if (tile >= ::MapSize()) return 0;
    57 
    57 
    58 	AcceptedCargo accepts;
    58 	AcceptedCargo accepts;
    59 	GetAcceptanceAroundTiles(accepts, tile, width, height, _patches.modified_catchment ? rad : 4);
    59 	GetAcceptanceAroundTiles(accepts, tile, width, height, _patches.modified_catchment ? rad : 4);
    60 	return accepts[cargo_type];
    60 	return accepts[cargo_type];
    61 }
    61 }
    62 
    62 
    63 bool AITile::RaiseTile(TileIndex tile, int32 slope)
    63 bool AITile::RaiseTile(TileIndex tile, int32 slope)
    64 {
    64 {
    65 	/* Outside of the map */
    65 	/* Outside of the map */
    66 	if (tile >= ::MapSize()) return 0;
    66 	if (tile >= ::MapSize()) return false;
    67 
    67 
    68 	return this->DoCommand(tile, slope, 1, CMD_TERRAFORM_LAND);
    68 	return this->DoCommand(tile, slope, 1, CMD_TERRAFORM_LAND);
    69 }
    69 }
    70 
    70 
    71 bool AITile::LowerTile(TileIndex tile, int32 slope)
    71 bool AITile::LowerTile(TileIndex tile, int32 slope)
    72 {
    72 {
    73 	/* Outside of the map */
    73 	/* Outside of the map */
    74 	if (tile >= ::MapSize()) return 0;
    74 	if (tile >= ::MapSize()) return false;
    75 
    75 
    76 	return this->DoCommand(tile, slope, 0, CMD_TERRAFORM_LAND);
    76 	return this->DoCommand(tile, slope, 0, CMD_TERRAFORM_LAND);
    77 }
    77 }