mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-06-21 12:39:47 +01:00
(svn r18724) -Fix [FS#3475] (r17899): refitting a non-refittable vehicle to it's default cargotype failed, causing problems for AIs
This commit is contained in:
parent
b42e76d858
commit
27fc22a76b
@ -307,13 +307,11 @@ CommandCost RefitVehicle(Vehicle *v, bool only_this, CargoID new_cid, byte new_s
|
|||||||
{
|
{
|
||||||
CommandCost cost(v->GetExpenseType(false));
|
CommandCost cost(v->GetExpenseType(false));
|
||||||
uint total_capacity = 0;
|
uint total_capacity = 0;
|
||||||
bool success = false;
|
|
||||||
|
|
||||||
v->InvalidateNewGRFCacheOfChain();
|
v->InvalidateNewGRFCacheOfChain();
|
||||||
for (; v != NULL; v = (only_this ? NULL : v->Next())) {
|
for (; v != NULL; v = (only_this ? NULL : v->Next())) {
|
||||||
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() || !HasBit(e->info.refit_mask, new_cid)) continue;
|
||||||
success = true;
|
|
||||||
|
|
||||||
/* 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;
|
||||||
@ -347,7 +345,7 @@ CommandCost RefitVehicle(Vehicle *v, bool only_this, CargoID new_cid, byte new_s
|
|||||||
}
|
}
|
||||||
|
|
||||||
_returned_refit_capacity = total_capacity;
|
_returned_refit_capacity = total_capacity;
|
||||||
return success ? cost : CMD_ERROR;
|
return cost;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Test if a name is unique among vehicle names.
|
/** Test if a name is unique among vehicle names.
|
||||||
|
Loading…
Reference in New Issue
Block a user