diff -r e7bf3233928b -r f45a41940079 src/station_cmd.cpp --- a/src/station_cmd.cpp Fri Aug 03 18:24:48 2007 +0000 +++ b/src/station_cmd.cpp Sat Aug 04 17:26:22 2007 +0000 @@ -1516,12 +1516,12 @@ return ret; } -static void GetFSMportsLayout(byte *layout, int width, int length, const FSMportsSpec *fsmportspec) +static void GetFSMportsLayout(byte *layout, int width, int length, const FSMportsSpec *fsmportspec, byte set) { if (fsmportspec != NULL) { /* Custom layout defined, follow it. */ - memcpy(layout, fsmportspec->layouts[width - 1][length - 1], - length * width); + memcpy(layout, fsmportspec->layouts[set], + (length * width) + 2); // width*length sprites, plus orientation byte, and preview minipic sprite return; } @@ -1535,7 +1535,7 @@ * @param tile tile where airport will be built * @param flags operation to perform * @param p1 various bitstuffed elements - * - p1 = (bit 0) - orientation (Axis) + * - p1 = (bit 0-2) - layout_set for newgrf * - p1 = (bit 8-15) - length * - p1 = (bit 16-23) - width * - p1 = (bit 24) - allow stations directly adjacent to other stations. @@ -1551,6 +1551,7 @@ const uint airport_type_for_flat_check = 0x80 | (GB(p2, 0, 4) << 3); bool newfsmairport = (HASBIT(p2, 7)); byte original_airport_type = GB(p2, 0, 4); + byte layout_set = GB(p1, 0, 3); SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); @@ -1577,8 +1578,8 @@ } const AirportFTAClass *afc = GetAirport(original_airport_type); - int w = afc->size_x; - int h = afc->size_y; + byte w = afc->size_x; + byte h = afc->size_y; Station *st = NULL; @@ -1590,8 +1591,8 @@ if (newfsmairport) { /* Perform NewStation checks */ - w = fsmportsspec->width; - h = fsmportsspec->lengths; + w = fsmportsspec->size_x[layout_set]; + h = fsmportsspec->size_y[layout_set]; /* Check if the station is buildable */ if (HASBIT(fsmportsspec->callbackmask, CBM_STATION_AVAIL) && GetFSMportsCallback(CBID_STATION_AVAILABILITY, 0, 0, fsmportsspec, NULL, INVALID_TILE) == 0) { @@ -1665,6 +1666,7 @@ st->AddFacility(FACIL_AIRPORT, tile); st->airport_type = (byte)original_airport_type; st->airport_flags.ResetAll(); + st->FSMport_layout_set = layout_set; st->rect.BeforeAddRect(tile, w, h, StationRect::ADD_TRY); @@ -1681,8 +1683,10 @@ fsmportspecindex = AllocateFSMportsSpecToStation(fsmportsspec, st, flags & DC_EXEC); if (fsmportspecindex == -1) return CMD_ERROR; - layout_ptr = (byte*)alloca(w * h); - GetFSMportsLayout(layout_ptr, w, h, fsmportsspec); + layout_ptr = (byte*)alloca((w * h) + 2); + GetFSMportsLayout(layout_ptr, w, h, fsmportsspec, layout_set); + layout_ptr++; //skip orientation + layout_ptr++; //skip minipic ID } else { layout_ptr = (byte*)_airport_sections[original_airport_type]; } @@ -1713,6 +1717,7 @@ int w, h; const FSMportsSpec *fsmportsspec; const AirportFTAClass *afc; + byte layout_set = st->FSMport_layout_set; if (_current_player != OWNER_WATER && !CheckOwnership(st->owner)) return CMD_ERROR; @@ -1722,8 +1727,8 @@ if (newfsmairport) { fsmportsspec = st->fsmportsspeclist[GetCustomStationSpecIndex(tile)].spec; - w = fsmportsspec->width; - h = fsmportsspec->lengths; + w = fsmportsspec->size_x[layout_set]; + h = fsmportsspec->size_y[layout_set]; } else { afc = st->Airport(); w = afc->size_x; @@ -1743,8 +1748,10 @@ byte layout; if (newfsmairport) { - layout_ptr = (byte*)alloca(w * h); - GetFSMportsLayout(layout_ptr, w, h, fsmportsspec); + layout_ptr = (byte*)alloca((w * h) + 2); + GetFSMportsLayout(layout_ptr, w, h, fsmportsspec, layout_set); + layout_ptr++; //skip orientation + layout_ptr++; //skip minipic ID } else { layout_ptr = (byte*)_airport_sections[st->airport_type]; }