Changeset - r3954:667f1e8cf285
[Not reviewed]
master
0 3 0
peter1138 - 18 years ago 2006-06-04 17:38:48
peter1138@openttd.org
(svn r5103) - Add cargo subtype parameter to refit commands (mart3p)
3 files changed with 15 insertions and 2 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -480,19 +480,21 @@ int32 CmdSendAircraftToHangar(TileIndex 
 

	
 
/** Refits an aircraft to the specified cargo type.
 
 * @param tile unused
 
 * @param p1 vehicle ID of the aircraft to refit
 
 * @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 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
 
{
 
	Vehicle *v;
 
	int pass, mail;
 
	int32 cost;
 
	CargoID new_cid = GB(p2, 0, 8);
 
	byte new_subtype = GB(p2, 8, 8);
 
	const AircraftVehicleInfo *avi;
 

	
 
	if (!IsVehicleIndex(p1)) return CMD_ERROR;
 

	
 
	v = GetVehicle(p1);
 

	
 
@@ -535,12 +537,13 @@ int32 CmdRefitAircraft(TileIndex tile, u
 

	
 
		u = v->next;
 
		mail = (new_cid != CT_PASSENGERS) ? 0 : avi->mail_capacity;
 
		u->cargo_cap = mail;
 
		v->cargo_count = u->cargo_count = 0;
 
		v->cargo_type = new_cid;
 
		v->cargo_subtype = new_subtype;
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		RebuildVehicleLists();
 
	}
 

	
 
	return cost;
ship_cmd.c
Show inline comments
 
@@ -1027,18 +1027,20 @@ int32 CmdSendShipToDepot(TileIndex tile,
 

	
 
/** Refits a ship to the specified cargo type.
 
 * @param tile unused
 
 * @param p1 vehicle ID of the ship to refit
 
 * @param p2 various bitstuffed elements
 
 * - 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)
 
{
 
	Vehicle *v;
 
	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;
 

	
 
	v = GetVehicle(p1);
 

	
 
	if (v->type != VEH_Ship || !CheckOwnership(v->owner)) return CMD_ERROR;
 
@@ -1058,12 +1060,15 @@ int32 CmdRefitShip(TileIndex tile, uint3
 
		cost = _price.ship_base >> 7;
 
	}
 

	
 
	if (flags & DC_EXEC) {
 
		v->cargo_count = 0;
 
		v->cargo_type = new_cid;
 
		v->cargo_subtype = new_subtype;
 
		InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
		InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
		RebuildVehicleLists();
 
	}
 

	
 
	return cost;
 

	
 
}
train_cmd.c
Show inline comments
 
@@ -1716,17 +1716,20 @@ int32 CmdForceTrainProceed(TileIndex til
 
	return 0;
 
}
 

	
 
/** Refits a train to the specified cargo type.
 
 * @param tile unused
 
 * @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)
 
{
 
	CargoID new_cid = GB(p2, 0, 8);
 
	byte new_subtype = GB(p2, 8, 8);
 
	Vehicle *v;
 
	int32 cost;
 
	uint num;
 

	
 
	if (!IsVehicleIndex(p1)) return CMD_ERROR;
 

	
 
@@ -1786,14 +1789,16 @@ int32 CmdRefitRailVehicle(TileIndex tile
 
				if (new_cid != v->cargo_type) cost += _price.build_railvehicle >> 8;
 
				num += amount;
 
				if (flags & DC_EXEC) {
 
					v->cargo_count = 0;
 
					v->cargo_type = new_cid;
 
					v->cargo_cap = amount;
 
					v->cargo_subtype = new_subtype;
 
					InvalidateWindow(WC_VEHICLE_DETAILS, v->index);
 
					InvalidateWindow(WC_VEHICLE_DEPOT, v->tile);
 
					RebuildVehicleLists();
 
				}
 
			}
 
		}
 
	} while ((v = v->next) != NULL);
 

	
 
	_returned_refit_capacity = num;
0 comments (0 inline, 0 general)