(svn r17700) -Codechange: Integrate ShipVehicleInfo::refittable into EngineInfo::refit_mask during initialisation.

This commit is contained in:
frosch 2009-10-04 20:33:18 +00:00
parent 67a11a5776
commit 2adc2f4324
6 changed files with 7 additions and 10 deletions

View File

@ -55,7 +55,6 @@
if (GetCargoType(engine_id) == cargo_id) return true;
if (cargo_id == CT_MAIL && ::Engine::Get(engine_id)->type == VEH_AIRCRAFT) return true;
if (::Engine::Get(engine_id)->type == VEH_SHIP && !ShipVehInfo(engine_id)->refittable) return false;
return ::CanRefitTo(engine_id, cargo_id);
}

View File

@ -75,10 +75,8 @@ static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, VehicleType
CargoID initial_cargo_type;
if (GetVehicleDefaultCapacity(engine, type, &initial_cargo_type) > 0) {
if (type != VEH_SHIP || ShipVehInfo(engine)->refittable) {
const EngineInfo *ei = EngInfo(engine);
cargos = ei->refit_mask;
}
const EngineInfo *ei = EngInfo(engine);
cargos = ei->refit_mask;
if (include_initial_cargo_type && initial_cargo_type < NUM_CARGO) SetBit(cargos, initial_cargo_type);
}

View File

@ -784,8 +784,6 @@ bool IsEngineRefittable(EngineID engine)
/* check if it's an engine that is in the engine array */
if (e == NULL) return false;
if (e->type == VEH_SHIP && !e->u.ship.refittable) return false;
if (!e->CanCarryCargo()) return false;
const EngineInfo *ei = &e->info;

View File

@ -67,7 +67,7 @@ struct ShipVehicleInfo {
uint16 capacity;
byte running_cost;
SoundID sfx;
bool refittable;
bool old_refittable; ///< Is ship refittable; only used during initialisation. Later use EngineInfo::refit_mask.
};
/* AircraftVehicleInfo subtypes, bitmask type.

View File

@ -888,7 +888,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
} break;
case 0x09: // Refittable
svi->refittable = (grf_load_byte(&buf) != 0);
svi->old_refittable = (grf_load_byte(&buf) != 0);
break;
case PROP_SHIP_COST_FACTOR: // 0x0A Cost factor
@ -5756,6 +5756,9 @@ static void CalculateRefitMasks()
* cargo type. Finally disable the vehicle, if there is still no cargo. */
if (ei->cargo_type == CT_INVALID && ei->refit_mask != 0) ei->cargo_type = (CargoID)FindFirstBit(ei->refit_mask);
if (ei->cargo_type == CT_INVALID) ei->climates = 0x80;
/* Clear refit_mask for not refittable ships */
if (e->type == VEH_SHIP && !e->u.ship.old_refittable) ei->refit_mask = 0;
}
}

View File

@ -920,7 +920,6 @@ CommandCost CmdRefitShip(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_REFIT_DESTROYED_VEHICLE);
/* Check cargo */
if (!ShipVehInfo(v->engine_type)->refittable) return CMD_ERROR;
if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
/* Check the refit capacity callback */