1
0
Fork 0

(svn r5147) - NewGRF: Use refit capacity callback when refitting an aircraft (mart3p)

release/0.5
peter1138 2006-06-07 07:33:56 +00:00
parent d286235a6a
commit 36672afd8f
1 changed files with 19 additions and 15 deletions

View File

@ -544,6 +544,7 @@ int32 CmdRefitAircraft(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); byte new_subtype = GB(p2, 8, 8);
const AircraftVehicleInfo *avi; const AircraftVehicleInfo *avi;
uint16 callback = CALLBACK_FAILED;
if (!IsVehicleIndex(p1)) return CMD_ERROR; if (!IsVehicleIndex(p1)) return CMD_ERROR;
@ -559,21 +560,24 @@ int32 CmdRefitAircraft(TileIndex tile, uint32 flags, uint32 p1, uint32 p2)
SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN); SET_EXPENSES_TYPE(EXPENSES_AIRCRAFT_RUN);
switch (new_cid) { /* Check the refit capacity callback */
case CT_PASSENGERS: if (HASBIT(EngInfo(v->engine_type)->callbackmask, CBM_REFIT_CAPACITY)) {
pass = avi->passenger_capacity; /* Back up the existing cargo type */
break; CargoID temp_cid = v->cargo_type;
case CT_MAIL: v->cargo_type = new_cid;
pass = avi->passenger_capacity + avi->mail_capacity;
break; callback = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
case CT_GOODS:
pass = avi->passenger_capacity + avi->mail_capacity; /* Restore the cargo type */
pass /= 2; v->cargo_type = temp_cid;
break; }
default:
pass = avi->passenger_capacity + avi->mail_capacity; if (callback == CALLBACK_FAILED) {
pass /= 4; /* If the callback failed, or wasn't executed, use the aircraft's
break; * default cargo capacity */
pass = AircraftDefaultCargoCapacity(new_cid, v->engine_type);
} else {
pass = callback;
} }
_returned_refit_capacity = pass; _returned_refit_capacity = pass;