1
0
Fork 0

(svn r17858) -Codechange: Unindent some code.

release/1.0
frosch 2009-10-24 19:16:18 +00:00
parent 8e23ba540c
commit 9b80bc1f9b
1 changed files with 45 additions and 46 deletions

View File

@ -2118,57 +2118,56 @@ CommandCost CmdRefitRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
if (!CanRefitTo(v->engine_type, new_cid)) continue; if (!CanRefitTo(v->engine_type, new_cid)) continue;
const Engine *e = Engine::Get(v->engine_type); const Engine *e = Engine::Get(v->engine_type);
if (e->CanCarryCargo()) { if (!e->CanCarryCargo()) continue;
uint16 amount = CALLBACK_FAILED;
if (HasBit(e->info.callback_mask, CBM_VEHICLE_REFIT_CAPACITY)) { uint16 amount = CALLBACK_FAILED;
/* Back up the vehicle's cargo type */ if (HasBit(e->info.callback_mask, CBM_VEHICLE_REFIT_CAPACITY)) {
CargoID temp_cid = v->cargo_type; /* Back up the vehicle's cargo type */
byte temp_subtype = v->cargo_subtype; CargoID temp_cid = v->cargo_type;
v->cargo_type = new_cid; byte temp_subtype = v->cargo_subtype;
v->cargo_subtype = new_subtype; v->cargo_type = new_cid;
/* Check the refit capacity callback */ v->cargo_subtype = new_subtype;
amount = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v); /* Check the refit capacity callback */
/* Restore the original cargo type */ amount = GetVehicleCallback(CBID_VEHICLE_REFIT_CAPACITY, 0, 0, v->engine_type, v);
v->cargo_type = temp_cid; /* Restore the original cargo type */
v->cargo_subtype = temp_subtype; v->cargo_type = temp_cid;
} v->cargo_subtype = temp_subtype;
}
if (amount == CALLBACK_FAILED) { // callback failed or not used, use default if (amount == CALLBACK_FAILED) { // callback failed or not used, use default
CargoID old_cid = e->GetDefaultCargoType(); CargoID old_cid = e->GetDefaultCargoType();
/* normally, the capacity depends on the cargo type, a rail vehicle can /* 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 * carry twice as much mail/goods as normal cargo, and four times as
* many passengers * many passengers
*/ */
amount = e->u.rail.capacity; amount = e->u.rail.capacity;
switch (old_cid) { switch (old_cid) {
case CT_PASSENGERS: break; case CT_PASSENGERS: break;
case CT_MAIL: case CT_MAIL:
case CT_GOODS: amount *= 2; break; case CT_GOODS: amount *= 2; break;
default: amount *= 4; break; default: amount *= 4; break;
}
switch (new_cid) {
case CT_PASSENGERS: break;
case CT_MAIL:
case CT_GOODS: amount /= 2; break;
default: amount /= 4; break;
}
} }
switch (new_cid) {
case CT_PASSENGERS: break;
case CT_MAIL:
case CT_GOODS: amount /= 2; break;
default: amount /= 4; break;
}
}
if (new_cid != v->cargo_type) { if (new_cid != v->cargo_type) {
cost.AddCost(GetRefitCost(v->engine_type)); cost.AddCost(GetRefitCost(v->engine_type));
} }
num += amount; num += amount;
if (flags & DC_EXEC) { if (flags & DC_EXEC) {
v->cargo.Truncate((v->cargo_type == new_cid) ? amount : 0); v->cargo.Truncate((v->cargo_type == new_cid) ? amount : 0);
v->cargo_type = new_cid; v->cargo_type = new_cid;
v->cargo_cap = amount; v->cargo_cap = amount;
v->cargo_subtype = new_subtype; v->cargo_subtype = new_subtype;
SetWindowDirty(WC_VEHICLE_DETAILS, v->index); SetWindowDirty(WC_VEHICLE_DETAILS, v->index);
SetWindowDirty(WC_VEHICLE_DEPOT, v->tile); SetWindowDirty(WC_VEHICLE_DEPOT, v->tile);
InvalidateWindowClassesData(WC_TRAINS_LIST, 0); InvalidateWindowClassesData(WC_TRAINS_LIST, 0);
}
} }
} while ((v = v->Next()) != NULL && !only_this); } while ((v = v->Next()) != NULL && !only_this);