Changeset - r3988:3fbe7e5de2f9
[Not reviewed]
master
0 2 0
peter1138 - 18 years ago 2006-06-09 07:03:53
peter1138@openttd.org
(svn r5187) - NewGRF: temporarily change a vehicle's cargo subtype when calling the refit capacity callback.
2 files changed with 9 insertions and 1 deletions:
0 comments (0 inline, 0 general)
aircraft_cmd.c
Show inline comments
 
@@ -561,18 +561,21 @@ int32 CmdRefitAircraft(TileIndex tile, u
 
	SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
 

	
 
	/* Check the refit capacity callback */
 
	if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
 
		/* Back up the existing cargo type */
 
		CargoID temp_cid = v->cargo_type;
 
		byte temp_subtype = v->cargo_subtype;
 
		v->cargo_type = new_cid;
 
		v->cargo_subtype = new_subtype;
 

	
 
		callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
 

	
 
		/* Restore the cargo type */
 
		v->cargo_type = temp_cid;
 
		v->cargo_subtype = temp_subtype;
 
	}
 

	
 
	if (callback == CALLBACK_FAILED) {
 
		/* If the callback failed, or wasn't executed, use the aircraft's
 
		 * default cargo capacity */
 
		pass = AircraftDefaultCargoCapacity(new_cid, v->engine_type);
train_cmd.c
Show inline comments
 
@@ -1757,17 +1757,22 @@ int32 CmdRefitRailVehicle(TileIndex tile
 

	
 
		if (v->cargo_cap != 0) {
 
			const RailVehicleInfo *rvi = RailVehInfo(v->engine_type);
 
			uint16 amount = CALLBACK_FAILED;
 

	
 
			if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
 
				/* Check the 'refit capacity' callback */
 
				/* Back up the vehicle's cargo type */
 
				CargoID temp_cid = v->cargo_type;
 
				byte temp_subtype = v->cargo_subtype;
 
				v->cargo_type = new_cid;
 
				v->cargo_subtype = new_subtype;
 
				/* Check the refit capacity callback */
 
				amount = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
 
				/* Restore the original cargo type */
 
				v->cargo_type = temp_cid;
 
				v->cargo_subtype = temp_subtype;
 
			}
 

	
 
			if (amount == CALLBACK_FAILED) { // callback failed or not used, use default
 
				CargoID old_cid = rvi->cargo_type;
 
				/* normally, the capacity depends on the cargo type, a rail vehicle can
 
				 * carry twice as much mail/goods as normal cargo, and four times as
0 comments (0 inline, 0 general)