mirror of https://github.com/OpenTTD/OpenTTD
(svn r17726) -Cleanup: Remove some unneeded/unused parameters.
parent
f3aacb8fe3
commit
7a8a97e68a
|
@ -49,11 +49,10 @@ uint CountArticulatedParts(EngineID engine_type, bool purchase_window)
|
||||||
/**
|
/**
|
||||||
* Returns the default (non-refitted) capacity of a specific EngineID.
|
* Returns the default (non-refitted) capacity of a specific EngineID.
|
||||||
* @param engine the EngineID of iterest
|
* @param engine the EngineID of iterest
|
||||||
* @param type the type of the engine
|
|
||||||
* @param cargo_type returns the default cargo type, if needed
|
* @param cargo_type returns the default cargo type, if needed
|
||||||
* @return capacity
|
* @return capacity
|
||||||
*/
|
*/
|
||||||
static inline uint16 GetVehicleDefaultCapacity(EngineID engine, VehicleType type, CargoID *cargo_type)
|
static inline uint16 GetVehicleDefaultCapacity(EngineID engine, CargoID *cargo_type)
|
||||||
{
|
{
|
||||||
const Engine *e = Engine::Get(engine);
|
const Engine *e = Engine::Get(engine);
|
||||||
CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
|
CargoID cargo = (e->CanCarryCargo() ? e->GetDefaultCargoType() : (CargoID)CT_INVALID);
|
||||||
|
@ -65,16 +64,15 @@ static inline uint16 GetVehicleDefaultCapacity(EngineID engine, VehicleType type
|
||||||
/**
|
/**
|
||||||
* Returns all cargos a vehicle can carry.
|
* Returns all cargos a vehicle can carry.
|
||||||
* @param engine the EngineID of iterest
|
* @param engine the EngineID of iterest
|
||||||
* @param type the type of the engine
|
|
||||||
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
|
* @param include_initial_cargo_type if true the default cargo type of the vehicle is included; if false only the refit_mask
|
||||||
* @return bit set of CargoIDs
|
* @return bit set of CargoIDs
|
||||||
*/
|
*/
|
||||||
static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, VehicleType type, bool include_initial_cargo_type)
|
static inline uint32 GetAvailableVehicleCargoTypes(EngineID engine, bool include_initial_cargo_type)
|
||||||
{
|
{
|
||||||
uint32 cargos = 0;
|
uint32 cargos = 0;
|
||||||
CargoID initial_cargo_type;
|
CargoID initial_cargo_type;
|
||||||
|
|
||||||
if (GetVehicleDefaultCapacity(engine, type, &initial_cargo_type) > 0) {
|
if (GetVehicleDefaultCapacity(engine, &initial_cargo_type) > 0) {
|
||||||
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);
|
||||||
|
@ -88,7 +86,7 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
|
||||||
CargoArray capacity;
|
CargoArray capacity;
|
||||||
|
|
||||||
CargoID cargo_type;
|
CargoID cargo_type;
|
||||||
uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, type, &cargo_type);
|
uint16 cargo_capacity = GetVehicleDefaultCapacity(engine, &cargo_type);
|
||||||
if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity;
|
if (cargo_type < NUM_CARGO) capacity[cargo_type] = cargo_capacity;
|
||||||
|
|
||||||
if (type != VEH_TRAIN && type != VEH_ROAD) return capacity;
|
if (type != VEH_TRAIN && type != VEH_ROAD) return capacity;
|
||||||
|
@ -101,7 +99,7 @@ CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type)
|
||||||
|
|
||||||
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
|
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
|
||||||
|
|
||||||
cargo_capacity = GetVehicleDefaultCapacity(artic_engine, type, &cargo_type);
|
cargo_capacity = GetVehicleDefaultCapacity(artic_engine, &cargo_type);
|
||||||
if (cargo_type < NUM_CARGO) capacity[cargo_type] += cargo_capacity;
|
if (cargo_type < NUM_CARGO) capacity[cargo_type] += cargo_capacity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -142,7 +140,7 @@ bool IsArticulatedVehicleRefittable(EngineID engine)
|
||||||
*/
|
*/
|
||||||
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type)
|
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type)
|
||||||
{
|
{
|
||||||
uint32 cargos = GetAvailableVehicleCargoTypes(engine, type, include_initial_cargo_type);
|
uint32 cargos = GetAvailableVehicleCargoTypes(engine, include_initial_cargo_type);
|
||||||
|
|
||||||
if (type != VEH_TRAIN && type != VEH_ROAD) return cargos;
|
if (type != VEH_TRAIN && type != VEH_ROAD) return cargos;
|
||||||
|
|
||||||
|
@ -153,7 +151,7 @@ uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool i
|
||||||
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
|
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
|
||||||
|
|
||||||
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
|
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
|
||||||
cargos |= GetAvailableVehicleCargoTypes(artic_engine, type, include_initial_cargo_type);
|
cargos |= GetAvailableVehicleCargoTypes(artic_engine, include_initial_cargo_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cargos;
|
return cargos;
|
||||||
|
@ -170,7 +168,7 @@ uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type,
|
||||||
{
|
{
|
||||||
uint32 cargos = UINT32_MAX;
|
uint32 cargos = UINT32_MAX;
|
||||||
|
|
||||||
uint32 veh_cargos = GetAvailableVehicleCargoTypes(engine, type, include_initial_cargo_type);
|
uint32 veh_cargos = GetAvailableVehicleCargoTypes(engine, include_initial_cargo_type);
|
||||||
if (veh_cargos != 0) cargos &= veh_cargos;
|
if (veh_cargos != 0) cargos &= veh_cargos;
|
||||||
|
|
||||||
if (type != VEH_TRAIN && type != VEH_ROAD) return cargos;
|
if (type != VEH_TRAIN && type != VEH_ROAD) return cargos;
|
||||||
|
@ -182,7 +180,7 @@ uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type,
|
||||||
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
|
if (callback == CALLBACK_FAILED || GB(callback, 0, 8) == 0xFF) break;
|
||||||
|
|
||||||
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
|
EngineID artic_engine = GetNewEngineID(GetEngineGRF(engine), type, GB(callback, 0, 7));
|
||||||
veh_cargos = GetAvailableVehicleCargoTypes(artic_engine, type, include_initial_cargo_type);
|
veh_cargos = GetAvailableVehicleCargoTypes(artic_engine, include_initial_cargo_type);
|
||||||
if (veh_cargos != 0) cargos &= veh_cargos;
|
if (veh_cargos != 0) cargos &= veh_cargos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,7 +248,7 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
|
||||||
CargoArray real_default_capacity;
|
CargoArray real_default_capacity;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
uint32 refit_mask = GetAvailableVehicleCargoTypes(v->engine_type, v->type, true);
|
uint32 refit_mask = GetAvailableVehicleCargoTypes(v->engine_type, true);
|
||||||
real_refit_union |= refit_mask;
|
real_refit_union |= refit_mask;
|
||||||
if (refit_mask != 0) real_refit_intersection &= refit_mask;
|
if (refit_mask != 0) real_refit_intersection &= refit_mask;
|
||||||
|
|
||||||
|
@ -287,8 +285,9 @@ void CheckConsistencyOfArticulatedVehicle(const Vehicle *v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddArticulatedParts(Vehicle *first, VehicleType type)
|
void AddArticulatedParts(Vehicle *first)
|
||||||
{
|
{
|
||||||
|
VehicleType type = first->type;
|
||||||
if (!HasBit(EngInfo(first->engine_type)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return;
|
if (!HasBit(EngInfo(first->engine_type)->callback_mask, CBM_VEHICLE_ARTIC_ENGINE)) return;
|
||||||
|
|
||||||
Vehicle *v = first;
|
Vehicle *v = first;
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
|
uint CountArticulatedParts(EngineID engine_type, bool purchase_window);
|
||||||
CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type);
|
CargoArray GetCapacityOfArticulatedParts(EngineID engine, VehicleType type);
|
||||||
void AddArticulatedParts(Vehicle *first, VehicleType type);
|
void AddArticulatedParts(Vehicle *first);
|
||||||
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
|
uint32 GetUnionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
|
||||||
uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
|
uint32 GetIntersectionOfArticulatedRefitMasks(EngineID engine, VehicleType type, bool include_initial_cargo_type);
|
||||||
bool IsArticulatedVehicleCarryingDifferentCargos(const Vehicle *v, CargoID *cargo_type);
|
bool IsArticulatedVehicleCarryingDifferentCargos(const Vehicle *v, CargoID *cargo_type);
|
||||||
|
|
|
@ -280,7 +280,7 @@ CommandCost CmdBuildRoadVeh(TileIndex tile, DoCommandFlag flags, uint32 p1, uint
|
||||||
|
|
||||||
v->cargo_cap = rvi->capacity;
|
v->cargo_cap = rvi->capacity;
|
||||||
|
|
||||||
AddArticulatedParts(v, VEH_ROAD);
|
AddArticulatedParts(v);
|
||||||
v->InvalidateNewGRFCacheOfChain();
|
v->InvalidateNewGRFCacheOfChain();
|
||||||
|
|
||||||
/* Call various callbacks after the whole consist has been constructed */
|
/* Call various callbacks after the whole consist has been constructed */
|
||||||
|
|
|
@ -756,7 +756,7 @@ static CommandCost CmdBuildRailWagon(EngineID engine, TileIndex tile, DoCommandF
|
||||||
|
|
||||||
v->group_id = DEFAULT_GROUP;
|
v->group_id = DEFAULT_GROUP;
|
||||||
|
|
||||||
AddArticulatedParts(v, VEH_TRAIN);
|
AddArticulatedParts(v);
|
||||||
|
|
||||||
_new_vehicle_id = v->index;
|
_new_vehicle_id = v->index;
|
||||||
|
|
||||||
|
@ -926,7 +926,7 @@ CommandCost CmdBuildRailVehicle(TileIndex tile, DoCommandFlag flags, uint32 p1,
|
||||||
if (rvi->railveh_type == RAILVEH_MULTIHEAD) {
|
if (rvi->railveh_type == RAILVEH_MULTIHEAD) {
|
||||||
AddRearEngineToMultiheadedTrain(v);
|
AddRearEngineToMultiheadedTrain(v);
|
||||||
} else {
|
} else {
|
||||||
AddArticulatedParts(v, VEH_TRAIN);
|
AddArticulatedParts(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
TrainConsistChanged(v, false);
|
TrainConsistChanged(v, false);
|
||||||
|
|
Loading…
Reference in New Issue