--- a/src/station_cmd.cpp Mon Aug 13 09:18:12 2007 +0000
+++ b/src/station_cmd.cpp Mon Aug 13 09:21:57 2007 +0000
@@ -665,18 +665,18 @@
// Tries to clear the given area. Returns the cost in case of success.
// Or an error code if it failed.
-CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool FSMlayoutMask, bool check_clear = true)
+CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint32 invalid_dirs, StationID* station, const FSMportsSpec *fsmportspec, bool check_clear = true)
{
CommandCost cost;
int allowed_z = -1;
- const byte *b = _airport_sections[(invalid_dirs & 0x78) >> 3];
+ byte layout_set = GB(invalid_dirs, 0, 3);
+ byte *b = NULL;
+ if (fsmportspec != NULL) {
+ b = fsmportspec->layouts[layout_set];
+ b++; //skip orientation
+ b++; //skip minipic
+ }
bool do_tile_test;
-/*
- if (invalid_dirs & 0x80) { // this is an airport
- airport_type = (invalid_dirs & 0x78) >> 3; // airport type defined by bits 6..3
- *b = _airport_sections[airport_type];
- }
-*/
BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
if (MayHaveBridgeAbove(tile_cur) && IsBridgeAbove(tile_cur)) {
@@ -716,7 +716,7 @@
// do tile tests if it is not an airport or airport tile is 255
do_tile_test = true;
- if (invalid_dirs & 0x80) {
+ if (fsmportspec != NULL) {
if ((byte)*b++ == (byte)255) {
do_tile_test = false;
}
@@ -730,7 +730,7 @@
/* test here whether build on height permitted. for FSM ports with layout masks, this is not an error
* land checking is done in airport placement
*/
- if (!FSMlayoutMask) return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
+ if (fsmportspec->layout_mask == NULL) return_cmd_error(STR_0007_FLAT_LAND_REQUIRED);
}
if (do_tile_test) {
@@ -762,7 +762,7 @@
CommandCost CheckFlatLandBelow(TileIndex tile, uint w, uint h, uint flags, uint invalid_dirs, StationID* station, bool check_clear = true)
{
- return CheckFlatLandBelow(tile, w, h, flags, invalid_dirs, station, false, check_clear);
+ return CheckFlatLandBelow(tile, w, h, flags, (uint32)invalid_dirs, station, NULL, check_clear);
}
static bool CanExpandRailroadStation(const Station* st, uint* fin, Axis axis)
@@ -1543,8 +1543,8 @@
CommandCost CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{
bool airport_upgrade = true;
- const uint airport_type_for_flat_check = 0x80 | (GB(p2, 0, 4) << 3);
byte layout_set = GB(p1, 0, 3);
+ const uint32 airport_type_for_flat_check = (GB(p2, 8, 8) << 3) | layout_set;
SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION);
@@ -1668,7 +1668,7 @@
} END_TILE_LOOP(tile_cur, w, h, tile)
}
- CommandCost cost = CheckFlatLandBelow(tile, w, h, flags, airport_type_for_flat_check, NULL, fsmportsspec->layout_mask != NULL, true);
+ CommandCost cost = CheckFlatLandBelow(tile, w, h, flags, airport_type_for_flat_check, NULL, fsmportsspec, true);
if (CmdFailed(cost)) return cost;
cost.AddCost(_price.build_airport * w * h);
@@ -1700,7 +1700,8 @@
BEGIN_TILE_LOOP(tile_cur, w, h, tile) {
byte layout = *layout_ptr++;
MakeAirport(tile_cur, st->owner, st->index, layout);
- SetCustomFSMportsSpecIndex(tile_cur, fsmportspecindex); //set top bit of m6 to indicate an fsmportsspec
+ if (layout != 255)
+ SetCustomFSMportsSpecIndex(tile_cur, fsmportspecindex); //set top bit of m6 to indicate an fsmportsspec
} END_TILE_LOOP(tile_cur, w, h, tile)
UpdateStationVirtCoordDirty(st);