Mercurial > hg > openttd
comparison src/vehicle_cmd.cpp @ 14176:41303b56f42c draft
(svn r18724) -Fix [FS#3475] (r17899): refitting a non-refittable vehicle to it's default cargotype failed, causing problems for AIs
author | yexo <yexo@openttd.org> |
---|---|
date | Mon, 04 Jan 2010 18:50:50 +0000 |
parents | 9b98b4f050e5 |
children | 860ea22258ba |
comparison
equal
deleted
inserted
replaced
14175:f1393258ecd5 | 14176:41303b56f42c |
---|---|
305 */ | 305 */ |
306 CommandCost RefitVehicle(Vehicle *v, bool only_this, CargoID new_cid, byte new_subtype, DoCommandFlag flags) | 306 CommandCost RefitVehicle(Vehicle *v, bool only_this, CargoID new_cid, byte new_subtype, DoCommandFlag flags) |
307 { | 307 { |
308 CommandCost cost(v->GetExpenseType(false)); | 308 CommandCost cost(v->GetExpenseType(false)); |
309 uint total_capacity = 0; | 309 uint total_capacity = 0; |
310 bool success = false; | |
311 | 310 |
312 v->InvalidateNewGRFCacheOfChain(); | 311 v->InvalidateNewGRFCacheOfChain(); |
313 for (; v != NULL; v = (only_this ? NULL : v->Next())) { | 312 for (; v != NULL; v = (only_this ? NULL : v->Next())) { |
314 const Engine *e = Engine::Get(v->engine_type); | 313 const Engine *e = Engine::Get(v->engine_type); |
315 if (!e->CanCarryCargo() || !HasBit(e->info.refit_mask, new_cid)) continue; | 314 if (!e->CanCarryCargo() || !HasBit(e->info.refit_mask, new_cid)) continue; |
316 success = true; | |
317 | 315 |
318 /* Back up the vehicle's cargo type */ | 316 /* Back up the vehicle's cargo type */ |
319 CargoID temp_cid = v->cargo_type; | 317 CargoID temp_cid = v->cargo_type; |
320 byte temp_subtype = v->cargo_subtype; | 318 byte temp_subtype = v->cargo_subtype; |
321 v->cargo_type = new_cid; | 319 v->cargo_type = new_cid; |
345 } | 343 } |
346 } | 344 } |
347 } | 345 } |
348 | 346 |
349 _returned_refit_capacity = total_capacity; | 347 _returned_refit_capacity = total_capacity; |
350 return success ? cost : CMD_ERROR; | 348 return cost; |
351 } | 349 } |
352 | 350 |
353 /** Test if a name is unique among vehicle names. | 351 /** Test if a name is unique among vehicle names. |
354 * @param name Name to test. | 352 * @param name Name to test. |
355 * @return True ifffffff the name is unique. | 353 * @return True ifffffff the name is unique. |