--- a/src/autoreplace_cmd.cpp Sun Apr 15 17:04:44 2007 +0000
+++ b/src/autoreplace_cmd.cpp Sat Apr 21 08:23:57 2007 +0000
@@ -87,34 +87,9 @@
*/
static CargoID GetNewCargoTypeForReplace(Vehicle *v, EngineID engine_type)
{
- bool new_cargo_capacity = true;
- CargoID new_cargo_type = CT_INVALID;
-
- switch (v->type) {
- case VEH_TRAIN:
- new_cargo_capacity = (RailVehInfo(engine_type)->capacity > 0);
- new_cargo_type = RailVehInfo(engine_type)->cargo_type;
- break;
+ CargoID new_cargo_type = GetEngineCargoType(engine_type);
- case VEH_ROAD:
- new_cargo_capacity = (RoadVehInfo(engine_type)->capacity > 0);
- new_cargo_type = RoadVehInfo(engine_type)->cargo_type;
- break;
- case VEH_SHIP:
- new_cargo_capacity = (ShipVehInfo(engine_type)->capacity > 0);
- new_cargo_type = ShipVehInfo(engine_type)->cargo_type;
- break;
-
- case VEH_AIRCRAFT:
- /* all aircraft starts as passenger planes with cargo capacity
- * new_cargo_capacity is always true for aircraft, which is the init value. No need to set it here */
- new_cargo_type = CT_PASSENGERS;
- break;
-
- default: NOT_REACHED(); break;
- }
-
- if (!new_cargo_capacity) return CT_NO_REFIT; // Don't try to refit an engine with no cargo capacity
+ if (new_cargo_type == CT_INVALID) return CT_NO_REFIT; // Don't try to refit an engine with no cargo capacity
if (v->cargo_type == new_cargo_type || CanRefitTo(engine_type, v->cargo_type)) {
if (VerifyAutoreplaceRefitForOrders(v, engine_type)) {
@@ -137,7 +112,7 @@
/* Now we found a cargo type being carried on the train and we will see if it is possible to carry to this one */
if (v->cargo_type == new_cargo_type) return CT_NO_REFIT;
if (CanRefitTo(engine_type, v->cargo_type)) return v->cargo_type;
- } while ((v=v->next) != NULL);
+ } while ((v = v->next) != NULL);
return CT_NO_REFIT; // We failed to find a cargo type on the old vehicle and we will not refit the new one
}