summaryrefslogtreecommitdiff
path: root/src/vehicle_gui.cpp
diff options
context:
space:
mode:
authorsmatz <smatz@openttd.org>2010-04-24 14:29:30 +0000
committersmatz <smatz@openttd.org>2010-04-24 14:29:30 +0000
commit4a9ef6ce6094b95f1a688ae1563d002f9ff71e07 (patch)
treedd9ba4bfa0ca5762efc6f4ccf76d531edc1354c4 /src/vehicle_gui.cpp
parentf56ebd81c35beb0094c487cc3dc45dc0427fae46 (diff)
downloadopenttd-4a9ef6ce6094b95f1a688ae1563d002f9ff71e07.tar.xz
(svn r19710) -Codechange: deduplicate GUI code for starting/stopping vehicles
Diffstat (limited to 'src/vehicle_gui.cpp')
-rw-r--r--src/vehicle_gui.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index fa14063fe..db638838c 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1868,6 +1868,16 @@ static const uint32 _vehicle_command_translation_table[][4] = {
},
};
+/**
+ * Executes #CMD_START_STOP_VEHICLE for given vehicle.
+ * @param v Vehicle to start/stop
+ */
+void StartStopVehicle(const Vehicle *v)
+{
+ assert(v->IsPrimaryVehicle());
+ DoCommandP(v->tile, v->index, 0, _vehicle_command_translation_table[VCT_CMD_START_STOP][v->type]);
+}
+
/** Checks whether the vehicle may be refitted at the moment.*/
static bool IsVehicleRefitable(const Vehicle *v)
{
@@ -2119,8 +2129,7 @@ public:
if (tile != INVALID_TILE) ScrollMainWindowToTile(tile);
} else {
/* Start/Stop */
- DoCommandP(v->tile, v->index, 0,
- _vehicle_command_translation_table[VCT_CMD_START_STOP][v->type]);
+ StartStopVehicle(v);
}
break;
case VVW_WIDGET_CENTER_MAIN_VIEH: {// center main view