1
0
Fork 0

(svn r5103) - Add cargo subtype parameter to refit commands (mart3p)

release/0.5
peter1138 2006-06-04 17:38:48 +00:00
parent fa74002356
commit f00c3e7e25
3 changed files with 15 additions and 2 deletions

View File

@ -483,6 +483,7 @@ int32 CmdSendAircraftToHangar(TileIndex tile, uint32 flags, uint32 p1, uint32 p2
* @param p1 vehicle ID of the aircraft to refit * @param p1 vehicle ID of the aircraft to refit
* @param p2 various bitstuffed elements * @param p2 various bitstuffed elements
* - p2 = (bit 0-7) - the new cargo type to refit to * - p2 = (bit 0-7) - the new cargo type to refit to
* - p2 = (bit 8-15) - the new cargo subtype to refit to
*/ */
int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{ {
@ -490,6 +491,7 @@ int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
int pass, mail; int pass, mail;
int32 cost; int32 cost;
CargoID new_cid = GB(p2, 0, 8); CargoID new_cid = GB(p2, 0, 8);
byte new_subtype = GB(p2, 8, 8);
const AircraftVehicleInfo *avi; const AircraftVehicleInfo *avi;
if (!IsVehicleIndex(p1)) return CMD_ERROR; if (!IsVehicleIndex(p1)) return CMD_ERROR;
@ -538,6 +540,7 @@ int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
u->cargo_cap = mail; u->cargo_cap = mail;
v->cargo_count = u->cargo_count = 0; v->cargo_count = u->cargo_count = 0;
v->cargo_type = new_cid; v->cargo_type = new_cid;
v->cargo_subtype = new_subtype;
InvalidateWindow(WC_VEHICLE_DETAILS, v->index); InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
RebuildVehicleLists(); RebuildVehicleLists();

View File

@ -1030,12 +1030,14 @@ int32 CmdSendShipToDepot(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
* @param p1 vehicle ID of the ship to refit * @param p1 vehicle ID of the ship to refit
* @param p2 various bitstuffed elements * @param p2 various bitstuffed elements
* - p2 = (bit 0-7) - the new cargo type to refit to (p2 & 0xFF) * - p2 = (bit 0-7) - the new cargo type to refit to (p2 & 0xFF)
* - p2 = (bit 8-15) - the new cargo subtype to refit to
*/ */
int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{ {
Vehicle *v; Vehicle *v;
int32 cost; int32 cost;
CargoID new_cid = p2 & 0xFF; //gets the cargo number CargoID new_cid = GB(p2, 0, 8); //gets the cargo number
byte new_subtype = GB(p2, 8, 8);
if (!IsVehicleIndex(p1)) return CMD_ERROR; if (!IsVehicleIndex(p1)) return CMD_ERROR;
@ -1061,7 +1063,10 @@ int32 CmdRefitShip(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
v->cargo_count = 0; v->cargo_count = 0;
v->cargo_type = new_cid; v->cargo_type = new_cid;
v->cargo_subtype = new_subtype;
InvalidateWindow(WC_VEHICLE_DETAILS, v->index); InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
RebuildVehicleLists();
} }
return cost; return cost;

View File

@ -1719,11 +1719,14 @@ int32 CmdForceTrainProceed(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
/** Refits a train to the specified cargo type. /** Refits a train to the specified cargo type.
* @param tile unused * @param tile unused
* @param p1 vehicle ID of the train to refit * @param p1 vehicle ID of the train to refit
* @param p2 the new cargo type to refit to (p2 & 0xFF) * param p2 various bitstuffed elements
* - p2 = (bit 0-7) - the new cargo type to refit to
* - p2 = (bit 8-15) - the new cargo subtype to refit to
*/ */
int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2) int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
{ {
CargoID new_cid = GB(p2, 0, 8); CargoID new_cid = GB(p2, 0, 8);
byte new_subtype = GB(p2, 8, 8);
Vehicle *v; Vehicle *v;
int32 cost; int32 cost;
uint num; uint num;
@ -1789,8 +1792,10 @@ int32 CmdRefitRailVehicle(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
v->cargo_count = 0; v->cargo_count = 0;
v->cargo_type = new_cid; v->cargo_type = new_cid;
v->cargo_cap = amount; v->cargo_cap = amount;
v->cargo_subtype = new_subtype;
InvalidateWindow(WC_VEHICLE_DETAILS, v->index); InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
InvalidateWindow(WC_VEHICLE_DEPOT, v->tile); InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
RebuildVehicleLists();
} }
} }
} }