equal
deleted
inserted
replaced
668 } |
668 } |
669 |
669 |
670 /** Build a railroad vehicle. |
670 /** Build a railroad vehicle. |
671 * @param x,y tile coordinates (depot) where rail-vehicle is built |
671 * @param x,y tile coordinates (depot) where rail-vehicle is built |
672 * @param p1 engine type id |
672 * @param p1 engine type id |
673 * @param p2 bit 0 prevents any free cars from being added to the train |
673 * @param p2 bit 0 when set, the train will get number 0, otherwise it will get a free number |
|
674 * bit 1 prevents any free cars from being added to the train |
674 */ |
675 */ |
675 int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
676 int32 CmdBuildRailVehicle(int x, int y, uint32 flags, uint32 p1, uint32 p2) |
676 { |
677 { |
677 const RailVehicleInfo *rvi; |
678 const RailVehicleInfo *rvi; |
678 int value; |
679 int value; |
712 if (!AllocateVehicles(vl, num_vehicles) || IsOrderPoolFull()) |
713 if (!AllocateVehicles(vl, num_vehicles) || IsOrderPoolFull()) |
713 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
714 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
714 |
715 |
715 v = vl[0]; |
716 v = vl[0]; |
716 |
717 |
717 unit_num = GetFreeUnitNumber(VEH_Train); |
718 unit_num = (HASBIT(p2, 0) == true) ? 0 : GetFreeUnitNumber(VEH_Train); |
718 if (unit_num > _patches.max_trains) |
719 if (unit_num > _patches.max_trains) |
719 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
720 return_cmd_error(STR_00E1_TOO_MANY_VEHICLES_IN_GAME); |
720 |
721 |
721 if (flags & DC_EXEC) { |
722 if (flags & DC_EXEC) { |
722 uint dir; |
723 uint dir; |
780 } |
781 } |
781 |
782 |
782 TrainConsistChanged(v); |
783 TrainConsistChanged(v); |
783 UpdateTrainAcceleration(v); |
784 UpdateTrainAcceleration(v); |
784 |
785 |
785 if (!HASBIT(p2, 0)) { // check if the cars should be added to the new vehicle |
786 if (!HASBIT(p2, 1)) { // check if the cars should be added to the new vehicle |
786 NormalizeTrainVehInDepot(v); |
787 NormalizeTrainVehInDepot(v); |
787 } |
788 } |
788 |
789 |
789 InvalidateWindow(WC_VEHICLE_DEPOT, tile); |
790 InvalidateWindow(WC_VEHICLE_DEPOT, tile); |
790 RebuildVehicleLists(); |
791 RebuildVehicleLists(); |