197 |
197 |
198 { |
198 { |
199 Station *s; |
199 Station *s; |
200 |
200 |
201 FOR_ALL_STATIONS(s) { |
201 FOR_ALL_STATIONS(s) { |
202 if (s != st && s->town==t) { |
202 if (s != st && s->town == t) { |
203 uint str = M(s->string_id); |
203 uint str = M(s->string_id); |
204 if (str <= 0x20) { |
204 if (str <= 0x20) { |
205 if (str == M(STR_SV_STNAME_FOREST)) |
205 if (str == M(STR_SV_STNAME_FOREST)) |
206 str = M(STR_SV_STNAME_WOODS); |
206 str = M(STR_SV_STNAME_WOODS); |
207 CLRBIT(free_names, str); |
207 CLRBIT(free_names, str); |
228 goto done; |
228 goto done; |
229 } |
229 } |
230 } |
230 } |
231 |
231 |
232 /* check close enough to town to get central as name? */ |
232 /* check close enough to town to get central as name? */ |
233 if (DistanceMax(tile,t->xy) < 8) { |
233 if (DistanceMax(tile, t->xy) < 8) { |
234 found = M(STR_SV_STNAME); |
234 found = M(STR_SV_STNAME); |
235 if (HASBIT(free_names, M(STR_SV_STNAME))) goto done; |
235 if (HASBIT(free_names, M(STR_SV_STNAME))) goto done; |
236 |
236 |
237 found = M(STR_SV_STNAME_CENTRAL); |
237 found = M(STR_SV_STNAME_CENTRAL); |
238 if (HASBIT(free_names, M(STR_SV_STNAME_CENTRAL))) goto done; |
238 if (HASBIT(free_names, M(STR_SV_STNAME_CENTRAL))) goto done; |
270 } |
270 } |
271 |
271 |
272 /* check direction compared to town */ |
272 /* check direction compared to town */ |
273 { |
273 { |
274 static const int8 _direction_and_table[] = { |
274 static const int8 _direction_and_table[] = { |
275 ~( (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ), |
275 ~( (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ), |
276 ~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_NORTH)) ), |
276 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_NORTH)) ), |
277 ~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_EAST)) | (1<<M(STR_SV_STNAME_NORTH)) ), |
277 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_EAST)) | (1 << M(STR_SV_STNAME_NORTH)) ), |
278 ~( (1<<M(STR_SV_STNAME_SOUTH)) | (1<<M(STR_SV_STNAME_WEST)) | (1<<M(STR_SV_STNAME_EAST)) ), |
278 ~( (1 << M(STR_SV_STNAME_SOUTH)) | (1 << M(STR_SV_STNAME_WEST)) | (1 << M(STR_SV_STNAME_EAST)) ), |
279 }; |
279 }; |
280 |
280 |
281 free_names &= _direction_and_table[ |
281 free_names &= _direction_and_table[ |
282 (TileX(tile) < TileX(t->xy)) + |
282 (TileX(tile) < TileX(t->xy)) + |
283 (TileY(tile) < TileY(t->xy)) * 2]; |
283 (TileY(tile) < TileY(t->xy)) * 2]; |
284 } |
284 } |
285 |
285 |
286 tmp = free_names & ((1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<6)|(1<<7)|(1<<12)|(1<<26)|(1<<27)|(1<<28)|(1<<29)|(1<<30)); |
286 tmp = free_names & ((1 << 1) | (1 << 2) | (1 << 3) | (1 << 4) | (1 << 6) | (1 << 7) | (1 << 12) | (1 << 26) | (1 << 27) | (1 << 28) | (1 << 29) | (1 << 30)); |
287 if (tmp == 0) { |
287 if (tmp == 0) { |
288 _error_message = STR_3007_TOO_MANY_STATIONS_LOADING; |
288 _error_message = STR_3007_TOO_MANY_STATIONS_LOADING; |
289 return false; |
289 return false; |
290 } |
290 } |
291 found = FindFirstBit(tmp); |
291 found = FindFirstBit(tmp); |
366 for (uint i = 0; i < num_items; i++) { |
366 for (uint i = 0; i < num_items; i++) { |
367 SetDParam(i + 1, GetCargo(cargo[i])->name); |
367 SetDParam(i + 1, GetCargo(cargo[i])->name); |
368 } |
368 } |
369 |
369 |
370 SetDParam(0, st->index); |
370 SetDParam(0, st->index); |
371 AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT|NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0); |
371 AddNewsItem(msg, NEWS_FLAGS(NM_SMALL, NF_VIEWPORT | NF_TILE, NT_ACCEPTANCE, 0), st->xy, 0); |
372 } |
372 } |
373 |
373 |
374 // Get a list of the cargo types being produced around the tile. |
374 // Get a list of the cargo types being produced around the tile. |
375 void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, |
375 void GetProductionAroundTiles(AcceptedCargo produced, TileIndex tile, |
376 int w, int h, int rad) |
376 int w, int h, int rad) |
644 } |
644 } |
645 |
645 |
646 int flat_z = z; |
646 int flat_z = z; |
647 if (tileh != SLOPE_FLAT) { |
647 if (tileh != SLOPE_FLAT) { |
648 // need to check so the entrance to the station is not pointing at a slope. |
648 // need to check so the entrance to the station is not pointing at a slope. |
649 if ((invalid_dirs&1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) || |
649 if ((invalid_dirs & 1 && !(tileh & SLOPE_NE) && (uint)w_cur == w) || |
650 (invalid_dirs&2 && !(tileh & SLOPE_SE) && h_cur == 1) || |
650 (invalid_dirs & 2 && !(tileh & SLOPE_SE) && h_cur == 1) || |
651 (invalid_dirs&4 && !(tileh & SLOPE_SW) && w_cur == 1) || |
651 (invalid_dirs & 4 && !(tileh & SLOPE_SW) && w_cur == 1) || |
652 (invalid_dirs&8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) { |
652 (invalid_dirs & 8 && !(tileh & SLOPE_NW) && (uint)h_cur == h)) { |
653 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
653 return_cmd_error(STR_0007_FLAT_LAND_REQUIRED); |
654 } |
654 } |
655 cost += _price.terraform; |
655 cost += _price.terraform; |
656 flat_z += TILE_HEIGHT; |
656 flat_z += TILE_HEIGHT; |
657 } |
657 } |
746 |
746 |
747 static inline byte *CreateSingle(byte *layout, int n) |
747 static inline byte *CreateSingle(byte *layout, int n) |
748 { |
748 { |
749 int i = n; |
749 int i = n; |
750 do *layout++ = 0; while (--i); |
750 do *layout++ = 0; while (--i); |
751 layout[((n-1) >> 1)-n] = 2; |
751 layout[((n - 1) >> 1) - n] = 2; |
752 return layout; |
752 return layout; |
753 } |
753 } |
754 |
754 |
755 static inline byte *CreateMulti(byte *layout, int n, byte b) |
755 static inline byte *CreateMulti(byte *layout, int n, byte b) |
756 { |
756 { |
757 int i = n; |
757 int i = n; |
758 do *layout++ = b; while (--i); |
758 do *layout++ = b; while (--i); |
759 if (n > 4) { |
759 if (n > 4) { |
760 layout[0-n] = 0; |
760 layout[0 - n] = 0; |
761 layout[n-1-n] = 0; |
761 layout[n - 1 - n] = 0; |
762 } |
762 } |
763 return layout; |
763 return layout; |
764 } |
764 } |
765 |
765 |
766 static void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSpec *statspec) |
766 static void GetStationLayout(byte *layout, int numtracks, int plat_len, const StationSpec *statspec) |
787 } |
787 } |
788 } |
788 } |
789 |
789 |
790 /** Build railroad station |
790 /** Build railroad station |
791 * @param tile_org starting position of station dragging/placement |
791 * @param tile_org starting position of station dragging/placement |
|
792 * @param flags operation to perform |
792 * @param p1 various bitstuffed elements |
793 * @param p1 various bitstuffed elements |
793 * - p1 = (bit 0) - orientation (Axis) |
794 * - p1 = (bit 0) - orientation (Axis) |
794 * - p1 = (bit 8-15) - number of tracks |
795 * - p1 = (bit 8-15) - number of tracks |
795 * - p1 = (bit 16-23) - platform length |
796 * - p1 = (bit 16-23) - platform length |
796 * @param p2 various bitstuffed elements |
797 * @param p2 various bitstuffed elements |
1021 } |
1022 } |
1022 |
1023 |
1023 /** Remove a single tile from a railroad station. |
1024 /** Remove a single tile from a railroad station. |
1024 * This allows for custom-built station with holes and weird layouts |
1025 * This allows for custom-built station with holes and weird layouts |
1025 * @param tile tile of station piece to remove |
1026 * @param tile tile of station piece to remove |
|
1027 * @param flags operation to perform |
1026 * @param p1 unused |
1028 * @param p1 unused |
1027 * @param p2 unused |
1029 * @param p2 unused |
1028 */ |
1030 */ |
1029 int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1031 int32 CmdRemoveFromRailroadStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1030 { |
1032 { |
1151 |
1153 |
1152 return _price.build_rail / 2; |
1154 return _price.build_rail / 2; |
1153 } |
1155 } |
1154 |
1156 |
1155 /** |
1157 /** |
1156 * @param[in] truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK |
1158 * @param truck_station Determines whether a stop is RoadStop::BUS or RoadStop::TRUCK |
1157 * @param[in] station The station to do the whole procedure for |
1159 * @param st The Station to do the whole procedure for |
1158 * @return a pointer to where to link a new RoadStop* |
1160 * @return a pointer to where to link a new RoadStop* |
1159 */ |
1161 */ |
1160 static RoadStop **FindRoadStopSpot(bool truck_station, Station* st) |
1162 static RoadStop **FindRoadStopSpot(bool truck_station, Station* st) |
1161 { |
1163 { |
1162 RoadStop **primary_stop = (truck_station) ? &st->truck_stops : &st->bus_stops; |
1164 RoadStop **primary_stop = (truck_station) ? &st->truck_stops : &st->bus_stops; |
1163 |
1165 |
1164 if (*primary_stop == NULL) { |
1166 if (*primary_stop == NULL) { |
1165 //we have no roadstop of the type yet, so write a "primary stop" |
1167 /* we have no roadstop of the type yet, so write a "primary stop" */ |
1166 return primary_stop; |
1168 return primary_stop; |
1167 } else { |
1169 } else { |
1168 //there are stops already, so append to the end of the list |
1170 /* there are stops already, so append to the end of the list */ |
1169 RoadStop *stop = *primary_stop; |
1171 RoadStop *stop = *primary_stop; |
1170 while (stop->next != NULL) stop = stop->next; |
1172 while (stop->next != NULL) stop = stop->next; |
1171 return &stop->next; |
1173 return &stop->next; |
1172 } |
1174 } |
1173 } |
1175 } |
1174 |
1176 |
1175 /** Build a bus or truck stop |
1177 /** Build a bus or truck stop |
1176 * @param tile tile to build the stop at |
1178 * @param tile tile to build the stop at |
|
1179 * @param flags operation to perform |
1177 * @param p1 entrance direction (DiagDirection) |
1180 * @param p1 entrance direction (DiagDirection) |
1178 * @param p2 bit 0: 0 for Bus stops, 1 for truck stops |
1181 * @param p2 bit 0: 0 for Bus stops, 1 for truck stops |
1179 * bit 1: 0 for normal, 1 for drive-through |
1182 * bit 1: 0 for normal, 1 for drive-through |
1180 */ |
1183 */ |
1181 int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1184 int32 CmdBuildRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1339 return (is_truck) ? _price.remove_truck_station : _price.remove_bus_station; |
1342 return (is_truck) ? _price.remove_truck_station : _price.remove_bus_station; |
1340 } |
1343 } |
1341 |
1344 |
1342 /** Remove a bus or truck stop |
1345 /** Remove a bus or truck stop |
1343 * @param tile tile to remove the stop from |
1346 * @param tile tile to remove the stop from |
|
1347 * @param flags operation to perform |
1344 * @param p1 not used |
1348 * @param p1 not used |
1345 * @param p2 bit 0: 0 for Bus stops, 1 for truck stops |
1349 * @param p2 bit 0: 0 for Bus stops, 1 for truck stops |
1346 */ |
1350 */ |
1347 int32 CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1351 int32 CmdRemoveRoadStop(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1348 { |
1352 { |
1464 _airport_sections_helistation // Helistation |
1468 _airport_sections_helistation // Helistation |
1465 }; |
1469 }; |
1466 |
1470 |
1467 /** Place an Airport. |
1471 /** Place an Airport. |
1468 * @param tile tile where airport will be built |
1472 * @param tile tile where airport will be built |
|
1473 * @param flags operation to perform |
1469 * @param p1 airport type, @see airport.h |
1474 * @param p1 airport type, @see airport.h |
1470 * @param p2 unused |
1475 * @param p2 unused |
1471 */ |
1476 */ |
1472 int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1477 int32 CmdBuildAirport(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1473 { |
1478 { |
1616 |
1621 |
1617 if (flags & DC_EXEC) { |
1622 if (flags & DC_EXEC) { |
1618 DeleteAnimatedTile(tile_cur); |
1623 DeleteAnimatedTile(tile_cur); |
1619 DoClearSquare(tile_cur); |
1624 DoClearSquare(tile_cur); |
1620 } |
1625 } |
1621 } END_TILE_LOOP(tile_cur, w,h,tile) |
1626 } END_TILE_LOOP(tile_cur, w, h, tile) |
1622 |
1627 |
1623 if (flags & DC_EXEC) { |
1628 if (flags & DC_EXEC) { |
1624 for (uint i = 0; i < afc->nof_depots; ++i) { |
1629 for (uint i = 0; i < afc->nof_depots; ++i) { |
1625 DeleteWindowById( |
1630 DeleteWindowById( |
1626 WC_VEHICLE_DEPOT, tile + ToTileIndexDiff(afc->airport_depots[i]) |
1631 WC_VEHICLE_DEPOT, tile + ToTileIndexDiff(afc->airport_depots[i]) |
1747 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 }; |
1753 static const byte _dock_w_chk[4] = { 2, 1, 2, 1 }; |
1748 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 }; |
1754 static const byte _dock_h_chk[4] = { 1, 2, 1, 2 }; |
1749 |
1755 |
1750 /** Build a dock/haven. |
1756 /** Build a dock/haven. |
1751 * @param tile tile where dock will be built |
1757 * @param tile tile where dock will be built |
|
1758 * @param flags operation to perform |
1752 * @param p1 unused |
1759 * @param p1 unused |
1753 * @param p2 unused |
1760 * @param p2 unused |
1754 */ |
1761 */ |
1755 int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1762 int32 CmdBuildDock(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1756 { |
1763 { |
2379 st->MarkTilesDirty(); |
2386 st->MarkTilesDirty(); |
2380 } |
2387 } |
2381 |
2388 |
2382 /** Rename a station |
2389 /** Rename a station |
2383 * @param tile unused |
2390 * @param tile unused |
|
2391 * @param flags operation to perform |
2384 * @param p1 station ID that is to be renamed |
2392 * @param p1 station ID that is to be renamed |
2385 * @param p2 unused |
2393 * @param p2 unused |
2386 */ |
2394 */ |
2387 int32 CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
2395 int32 CmdRenameStation(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
2388 { |
2396 { |
2785 /* Used by newstations for graphic variations */ |
2793 /* Used by newstations for graphic variations */ |
2786 SLE_CONDVAR(Station, random_bits, SLE_UINT16, 27, SL_MAX_VERSION), |
2794 SLE_CONDVAR(Station, random_bits, SLE_UINT16, 27, SL_MAX_VERSION), |
2787 SLE_CONDVAR(Station, waiting_triggers, SLE_UINT8, 27, SL_MAX_VERSION), |
2795 SLE_CONDVAR(Station, waiting_triggers, SLE_UINT8, 27, SL_MAX_VERSION), |
2788 SLE_CONDVAR(Station, num_specs, SLE_UINT8, 27, SL_MAX_VERSION), |
2796 SLE_CONDVAR(Station, num_specs, SLE_UINT8, 27, SL_MAX_VERSION), |
2789 |
2797 |
|
2798 SLE_CONDLST(Station, loading_vehicles, REF_VEHICLE, 57, SL_MAX_VERSION), |
|
2799 |
2790 // reserve extra space in savegame here. (currently 32 bytes) |
2800 // reserve extra space in savegame here. (currently 32 bytes) |
2791 SLE_CONDNULL(32, 2, SL_MAX_VERSION), |
2801 SLE_CONDNULL(32, 2, SL_MAX_VERSION), |
2792 |
2802 |
2793 SLE_END() |
2803 SLE_END() |
2794 }; |
2804 }; |
2818 |
2828 |
2819 |
2829 |
2820 static void SaveLoad_STNS(Station *st) |
2830 static void SaveLoad_STNS(Station *st) |
2821 { |
2831 { |
2822 SlObject(st, _station_desc); |
2832 SlObject(st, _station_desc); |
2823 for (CargoID i = 0; i < NUM_CARGO; i++) { |
2833 |
|
2834 uint num_cargo = CheckSavegameVersion(55) ? 12 : NUM_CARGO; |
|
2835 for (CargoID i = 0; i < num_cargo; i++) { |
2824 SlObject(&st->goods[i], _goods_desc); |
2836 SlObject(&st->goods[i], _goods_desc); |
2825 } |
2837 } |
2826 |
2838 |
2827 if (st->num_specs != 0) { |
2839 if (st->num_specs != 0) { |
2828 /* Allocate speclist memory when loading a game */ |
2840 /* Allocate speclist memory when loading a game */ |