equal
deleted
inserted
replaced
10 #include "pathfind.h" |
10 #include "pathfind.h" |
11 #include "town.h" |
11 #include "town.h" |
12 #include "sound.h" |
12 #include "sound.h" |
13 #include "station.h" |
13 #include "station.h" |
14 #include "sprite.h" |
14 #include "sprite.h" |
|
15 #include "depot.h" |
15 |
16 |
16 extern uint16 _custom_sprites_base; |
17 extern uint16 _custom_sprites_base; |
17 |
18 |
18 void ShowTrainDepotWindow(uint tile); |
19 void ShowTrainDepotWindow(uint tile); |
19 |
20 |
630 */ |
631 */ |
631 int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
632 int32 CmdBuildTrainDepot(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
632 { |
633 { |
633 uint tile = TILE_FROM_XY(x,y); |
634 uint tile = TILE_FROM_XY(x,y); |
634 int32 cost, ret; |
635 int32 cost, ret; |
635 Depot *dep; |
636 Depot *depot; |
636 uint tileh; |
637 uint tileh; |
637 |
638 |
638 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
639 SET_EXPENSES_TYPE(EXPENSES_CONSTRUCTION); |
639 |
640 |
640 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
641 if (!EnsureNoVehicle(tile)) return CMD_ERROR; |
647 |
648 |
648 ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
649 ret = DoCommandByTile(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR); |
649 if (ret == CMD_ERROR) return CMD_ERROR; |
650 if (ret == CMD_ERROR) return CMD_ERROR; |
650 cost = ret; |
651 cost = ret; |
651 |
652 |
652 dep = AllocateDepot(); |
653 depot = AllocateDepot(); |
653 if (dep == NULL) |
654 if (depot == NULL) |
654 return CMD_ERROR; |
655 return CMD_ERROR; |
655 |
656 |
656 if (flags & DC_EXEC) { |
657 if (flags & DC_EXEC) { |
657 if (_current_player == _local_player) |
658 if (_current_player == _local_player) |
658 _last_built_train_depot_tile = (TileIndex)tile; |
659 _last_built_train_depot_tile = (TileIndex)tile; |
662 MP_MAP3LO | MP_MAPOWNER_CURRENT | MP_MAP5, |
663 MP_MAP3LO | MP_MAPOWNER_CURRENT | MP_MAP5, |
663 p1, /* map3_lo */ |
664 p1, /* map3_lo */ |
664 p2 | RAIL_TYPE_DEPOT /* map5 */ |
665 p2 | RAIL_TYPE_DEPOT /* map5 */ |
665 ); |
666 ); |
666 |
667 |
667 dep->xy = tile; |
668 depot->xy = tile; |
668 dep->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
669 depot->town_index = ClosestTownFromTile(tile, (uint)-1)->index; |
669 |
670 |
670 SetSignalsOnBothDir(tile, (p2&1) ? 2 : 1); |
671 SetSignalsOnBothDir(tile, (p2&1) ? 2 : 1); |
671 |
672 |
672 } |
673 } |
673 |
674 |