mirror of https://github.com/OpenTTD/OpenTTD
(svn r17700) -Codechange: Integrate ShipVehicleInfo::refittable into EngineInfo::refit_mask during initialisation.
parent
5ff6053326
commit
b243f6ca97
|
@ -55,7 +55,6 @@
|
||||||
|
|
||||||
if (GetCargoType(engine_id) == cargo_id) return true;
|
if (GetCargoType(engine_id) == cargo_id) return true;
|
||||||
if (cargo_id == CT_MAIL && ::Engine::Get(engine_id)->type == VEH_AIRCRAFT) 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);
|
return ::CanRefitTo(engine_id, cargo_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -75,10 +75,8 @@ static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, VehicleType
|
||||||
CargoID initial_cargo_type;
|
CargoID initial_cargo_type;
|
||||||
|
|
||||||
if (GetVehicleDefaultCapacity(engine, type, &initial_cargo_type) > 0) {
|
if (GetVehicleDefaultCapacity(engine, type, &initial_cargo_type) > 0) {
|
||||||
if (type != VEH_SHIP || ShipVehInfo(engine)->refittable) {
|
const EngineInfo *ei = EngInfo(engine);
|
||||||
const EngineInfo *ei = EngInfo(engine);
|
cargos = ei->refit_mask;
|
||||||
cargos = ei->refit_mask;
|
|
||||||
}
|
|
||||||
if (include_initial_cargo_type && initial_cargo_type < NUM_CARGO) SetBit(cargos, initial_cargo_type);
|
if (include_initial_cargo_type && initial_cargo_type < NUM_CARGO) SetBit(cargos, initial_cargo_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -784,8 +784,6 @@ bool IsEngineRefittable(EngineID engine)
|
||||||
/* check if it's an engine that is in the engine array */
|
/* check if it's an engine that is in the engine array */
|
||||||
if (e == NULL) return false;
|
if (e == NULL) return false;
|
||||||
|
|
||||||
if (e->type == VEH_SHIP && !e->u.ship.refittable) return false;
|
|
||||||
|
|
||||||
if (!e->CanCarryCargo()) return false;
|
if (!e->CanCarryCargo()) return false;
|
||||||
|
|
||||||
const EngineInfo *ei = &e->info;
|
const EngineInfo *ei = &e->info;
|
||||||
|
|
|
@ -67,7 +67,7 @@ struct ShipVehicleInfo {
|
||||||
uint16 capacity;
|
uint16 capacity;
|
||||||
byte running_cost;
|
byte running_cost;
|
||||||
SoundID sfx;
|
SoundID sfx;
|
||||||
bool refittable;
|
bool old_refittable; ///< Is ship refittable; only used during initialisation. Later use EngineInfo::refit_mask.
|
||||||
};
|
};
|
||||||
|
|
||||||
/* AircraftVehicleInfo subtypes, bitmask type.
|
/* AircraftVehicleInfo subtypes, bitmask type.
|
||||||
|
|
|
@ -888,7 +888,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 0x09: // Refittable
|
case 0x09: // Refittable
|
||||||
svi->refittable = (grf_load_byte(&buf) != 0);
|
svi->old_refittable = (grf_load_byte(&buf) != 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case PROP_SHIP_COST_FACTOR: // 0x0A Cost factor
|
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. */
|
* 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->refit_mask != 0) ei->cargo_type = (CargoID)FindFirstBit(ei->refit_mask);
|
||||||
if (ei->cargo_type == CT_INVALID) ei->climates = 0x80;
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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);
|
if (v->vehstatus & VS_CRASHED) return_cmd_error(STR_ERROR_CAN_T_REFIT_DESTROYED_VEHICLE);
|
||||||
|
|
||||||
/* Check cargo */
|
/* 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;
|
if (new_cid >= NUM_CARGO || !CanRefitTo(v->engine_type, new_cid)) return CMD_ERROR;
|
||||||
|
|
||||||
/* Check the refit capacity callback */
|
/* Check the refit capacity callback */
|
||||||
|
|
Loading…
Reference in New Issue