src/station_cmd.cpp
changeset 8429 ec2a1005006e
parent 8424 c3477565c975
child 8466 4e3b01d2f1c5
equal deleted inserted replaced
8428:fb88a9033b48 8429:ec2a1005006e
   698 /** Tries to clear the given area.
   698 /** Tries to clear the given area.
   699  * @param tile TileIndex to start check
   699  * @param tile TileIndex to start check
   700  * @param w width of search area
   700  * @param w width of search area
   701  * @param h height of search area
   701  * @param h height of search area
   702  * @param flags operation to perform
   702  * @param flags operation to perform
   703  * @param invalid_dirs prohibited directions
   703  * @param invalid_dirs prohibited directions (set of DiagDirections)
   704  * @param station StationID to be queried and returned if available
   704  * @param station StationID to be queried and returned if available
   705  * @param check_clear if clearing tile should be performed (in wich case, cost will be added)
   705  * @param check_clear if clearing tile should be performed (in wich case, cost will be added)
   706  * @return the cost in case of success, or an error code if it failed.
   706  * @return the cost in case of success, or an error code if it failed.
   707  */
   707  */
   708 CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID *station, bool check_clear = true)
   708 CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID *station, bool check_clear = true)
   733 			return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
   733 			return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
   734 		}
   734 		}
   735 
   735 
   736 		int flat_z = z;
   736 		int flat_z = z;
   737 		if (tileh != SLOPE_FLAT) {
   737 		if (tileh != SLOPE_FLAT) {
   738 			/* need to check so the entrance to the station is not pointing at a slope. */
   738 			/* need to check so the entrance to the station is not pointing at a slope.
   739 			if ((invalid_dirs & 1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) ||
   739 			 * This must be valid for all station tiles, as the user can remove single station tiles. */
   740 					(invalid_dirs & 2 && !(tileh & SLOPE_SE) && h_cur == 1) ||
   740 			if ((HasBit(invalid_dirs, DIAGDIR_NE) && !(tileh & SLOPE_NE)) ||
   741 					(invalid_dirs & 4 && !(tileh & SLOPE_SW) && w_cur == 1) ||
   741 			    (HasBit(invalid_dirs, DIAGDIR_SE) && !(tileh & SLOPE_SE)) ||
   742 					(invalid_dirs & 8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) {
   742 			    (HasBit(invalid_dirs, DIAGDIR_SW) && !(tileh & SLOPE_SW)) ||
       
   743 			    (HasBit(invalid_dirs, DIAGDIR_NW) && !(tileh & SLOPE_NW))) {
   743 				return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
   744 				return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
   744 			}
   745 			}
   745 			cost.AddCost(_price.terraform);
   746 			cost.AddCost(_price.terraform);
   746 			flat_z += TILE_HEIGHT;
   747 			flat_z += TILE_HEIGHT;
   747 		}
   748 		}