From 161786e2222b67a48624e82bc9c3aabbc86e51e9 Mon Sep 17 00:00:00 2001 From: rubidium Date: Mon, 7 May 2007 15:58:05 +0000 Subject: (svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station. --- src/ship.h | 1 + src/ship_cmd.cpp | 9 +++++++-- src/train.h | 1 + src/train_cmd.cpp | 7 ++++++- src/vehicle.h | 5 +++++ 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 {} }; /** -- cgit v1.2.3-54-g00ecf