summaryrefslogtreecommitdiff
path: root/src/autoreplace_cmd.cpp
diff options
context:
space:
mode:
authorbjarni <bjarni@openttd.org>2007-04-20 16:56:55 +0000
committerbjarni <bjarni@openttd.org>2007-04-20 16:56:55 +0000
commit809888fa21deb78aca76f2647eb2a94c7d858442 (patch)
tree5ebbc58e20bc27e0078c3a734402509a3debef53 /src/autoreplace_cmd.cpp
parent9c40b92323b8691622aa94886640cefb69788df4 (diff)
downloadopenttd-809888fa21deb78aca76f2647eb2a94c7d858442.tar.xz
(svn r9688) -Codechange: Created a function to get default cargo type for a cargo type
Diffstat (limited to 'src/autoreplace_cmd.cpp')
-rw-r--r--src/autoreplace_cmd.cpp29
1 files changed, 2 insertions, 27 deletions
diff --git a/src/autoreplace_cmd.cpp b/src/autoreplace_cmd.cpp
index 6a191cb49..36bf98e7f 100644
--- a/src/autoreplace_cmd.cpp
+++ b/src/autoreplace_cmd.cpp
@@ -87,34 +87,9 @@ static bool VerifyAutoreplaceRefitForOrders(const Vehicle *v, const EngineID eng
*/
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;
-
- 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;
- }
+ CargoID new_cargo_type = GetEngineCargoType(engine_type);
- 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)) {