summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2007-05-07 15:58:05 +0000
committerrubidium <rubidium@openttd.org>2007-05-07 15:58:05 +0000
commit161786e2222b67a48624e82bc9c3aabbc86e51e9 (patch)
treeae24499f9e5c82cb54457487b656bef2c2b5055a /src
parent4591fb5b0d7f9ade45093a86d6a7150c80414dc5 (diff)
downloadopenttd-161786e2222b67a48624e82bc9c3aabbc86e51e9.tar.xz
(svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
Diffstat (limited to 'src')
-rw-r--r--src/ship.h1
-rw-r--r--src/ship_cmd.cpp9
-rw-r--r--src/train.h1
-rw-r--r--src/train_cmd.cpp7
-rw-r--r--src/vehicle.h5
5 files changed, 20 insertions, 3 deletions
diff --git a/src/ship.h b/src/ship.h
index fe5598230..f0435936d 100644
--- a/src/ship.h
+++ b/src/ship.h
@@ -44,6 +44,7 @@ struct Ship: public Vehicle {
void UpdateDeltaXY(Direction direction);
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
WindowClass GetVehicleListWindowClass() const { return WC_SHIPS_LIST; }
+ void PlayLeaveStationSound() const;
};
#endif /* SHIP_H */
diff --git a/src/ship_cmd.cpp b/src/ship_cmd.cpp
index c3ddb5226..aeda55d0d 100644
--- a/src/ship_cmd.cpp
+++ b/src/ship_cmd.cpp
@@ -235,13 +235,18 @@ void Ship::MarkDirty()
MarkAllViewportsDirty(this->left_coord, this->top_coord, this->right_coord + 1, this->bottom_coord + 1);
}
-static void PlayShipSound(Vehicle *v)
+static void PlayShipSound(const Vehicle *v)
{
if (!PlayVehicleSound(v, VSE_START)) {
SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v);
}
}
+void Ship::PlayLeaveStationSound() const
+{
+ PlayShipSound(this);
+}
+
static void ProcessShipOrder(Vehicle *v)
{
const Order *order;
@@ -308,7 +313,7 @@ static void HandleShipLoading(Vehicle *v)
if (LoadUnloadVehicle(v)) return;
- PlayShipSound(v);
+ v->PlayLeaveStationSound();
Order b = v->current_order;
v->LeaveStation();
diff --git a/src/train.h b/src/train.h
index 74f4341ba..cfda2dcdb 100644
--- a/src/train.h
+++ b/src/train.h
@@ -248,6 +248,7 @@ struct Train : public Vehicle {
void UpdateDeltaXY(Direction direction);
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; }
+ void PlayLeaveStationSound() const;
};
#endif /* TRAIN_H */
diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp
index 71cdccdd6..a28f862a6 100644
--- a/src/train_cmd.cpp
+++ b/src/train_cmd.cpp
@@ -2097,6 +2097,11 @@ static void TrainPlayLeaveStationSound(const Vehicle* v)
SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v);
}
+void Train::PlayLeaveStationSound() const
+{
+ TrainPlayLeaveStationSound(this);
+}
+
static bool CheckTrainStayInDepot(Vehicle *v)
{
/* bail out if not all wagons are in the same depot or not in a depot at all */
@@ -2531,7 +2536,7 @@ static void HandleTrainLoading(Vehicle *v, bool mode)
if (LoadUnloadVehicle(v)) return;
- TrainPlayLeaveStationSound(v);
+ v->PlayLeaveStationSound();
Order b = v->current_order;
v->LeaveStation();
diff --git a/src/vehicle.h b/src/vehicle.h
index 9143d5c87..37bff24ca 100644
--- a/src/vehicle.h
+++ b/src/vehicle.h
@@ -375,6 +375,11 @@ struct Vehicle {
* Invalidates the vehicle list window of this type of vehicle
*/
virtual WindowClass GetVehicleListWindowClass() const { return WC_NONE; }
+
+ /**
+ * Play the sound associated with leaving the station
+ */
+ virtual void PlayLeaveStationSound() const {}
};
/**