1749 * @param flags type of operation |
1749 * @param flags type of operation |
1750 * @param p1 vehicle ID of the train to refit |
1750 * @param p1 vehicle ID of the train to refit |
1751 * param p2 various bitstuffed elements |
1751 * param p2 various bitstuffed elements |
1752 * - p2 = (bit 0-7) - the new cargo type to refit to |
1752 * - p2 = (bit 0-7) - the new cargo type to refit to |
1753 * - p2 = (bit 8-15) - the new cargo subtype to refit to |
1753 * - p2 = (bit 8-15) - the new cargo subtype to refit to |
|
1754 * - p2 = (bit 16) - refit only this vehicle |
|
1755 * @return cost of refit or error |
1754 */ |
1756 */ |
1755 int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1757 int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) |
1756 { |
1758 { |
1757 CargoID new_cid = GB(p2, 0, 8); |
1759 CargoID new_cid = GB(p2, 0, 8); |
1758 byte new_subtype = GB(p2, 8, 8); |
1760 byte new_subtype = GB(p2, 8, 8); |
|
1761 bool only_this = HASBIT(p2, 16); |
1759 |
1762 |
1760 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
1763 if (!IsValidVehicleID(p1)) return CMD_ERROR; |
1761 |
1764 |
1762 Vehicle *v = GetVehicle(p1); |
1765 Vehicle *v = GetVehicle(p1); |
1763 |
1766 |
1831 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
1834 InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); |
1832 RebuildVehicleLists(); |
1835 RebuildVehicleLists(); |
1833 } |
1836 } |
1834 } |
1837 } |
1835 } |
1838 } |
1836 } while ((v = v->next) != NULL); |
1839 } while ((v = v->next) != NULL && !only_this); |
1837 |
1840 |
1838 _returned_refit_capacity = num; |
1841 _returned_refit_capacity = num; |
1839 |
1842 |
1840 /* Update the train's cached variables */ |
1843 /* Update the train's cached variables */ |
1841 if (flags & DC_EXEC) TrainConsistChanged(GetFirstVehicleInChain(GetVehicle(p1))); |
1844 if (flags & DC_EXEC) TrainConsistChanged(GetFirstVehicleInChain(GetVehicle(p1))); |