mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-02 09:40:35 +00:00
(svn r21904) -Fix: Include the capacity of non-refittable vehicles in the refitted-capacity, if their cargo matches.
This commit is contained in:
parent
25a22ec255
commit
072f6d67ef
@ -270,13 +270,19 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
|
|||||||
if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index) && !only_this) continue;
|
if (v->type == VEH_TRAIN && !vehicles_to_refit.Contains(v->index) && !only_this) continue;
|
||||||
|
|
||||||
const Engine *e = Engine::Get(v->engine_type);
|
const Engine *e = Engine::Get(v->engine_type);
|
||||||
if (!e->CanCarryCargo() || !HasBit(e->info.refit_mask, new_cid)) continue;
|
if (!e->CanCarryCargo()) continue;
|
||||||
|
|
||||||
|
/* If the vehicle is not refittable, count its capacity nevertheless if the cargo matches */
|
||||||
|
bool refittable = HasBit(e->info.refit_mask, new_cid);
|
||||||
|
if (!refittable && v->cargo_type != new_cid) continue;
|
||||||
|
|
||||||
/* Back up the vehicle's cargo type */
|
/* Back up the vehicle's cargo type */
|
||||||
CargoID temp_cid = v->cargo_type;
|
CargoID temp_cid = v->cargo_type;
|
||||||
byte temp_subtype = v->cargo_subtype;
|
byte temp_subtype = v->cargo_subtype;
|
||||||
v->cargo_type = new_cid;
|
if (refittable) {
|
||||||
v->cargo_subtype = new_subtype;
|
v->cargo_type = new_cid;
|
||||||
|
v->cargo_subtype = new_subtype;
|
||||||
|
}
|
||||||
|
|
||||||
uint16 mail_capacity = 0;
|
uint16 mail_capacity = 0;
|
||||||
uint amount = GetVehicleCapacity(v, &mail_capacity);
|
uint amount = GetVehicleCapacity(v, &mail_capacity);
|
||||||
@ -284,6 +290,8 @@ static CommandCost RefitVehicle(Vehicle *v, bool only_this, uint8 num_vehicles,
|
|||||||
/* mail_capacity will always be zero if the vehicle is not an aircraft. */
|
/* mail_capacity will always be zero if the vehicle is not an aircraft. */
|
||||||
total_mail_capacity += mail_capacity;
|
total_mail_capacity += mail_capacity;
|
||||||
|
|
||||||
|
if (!refittable) continue;
|
||||||
|
|
||||||
/* Restore the original cargo type */
|
/* Restore the original cargo type */
|
||||||
v->cargo_type = temp_cid;
|
v->cargo_type = temp_cid;
|
||||||
v->cargo_subtype = temp_subtype;
|
v->cargo_subtype = temp_subtype;
|
||||||
|
Loading…
Reference in New Issue
Block a user