mirror of https://github.com/OpenTTD/OpenTTD
(svn r9807) -Codechange: unify playing of sound when vehicle has been loaded and leaves the station.
parent
4591fb5b0d
commit
161786e222
|
@ -44,6 +44,7 @@ struct Ship: public Vehicle {
|
||||||
void UpdateDeltaXY(Direction direction);
|
void UpdateDeltaXY(Direction direction);
|
||||||
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
|
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_SHIP_INC : EXPENSES_SHIP_RUN; }
|
||||||
WindowClass GetVehicleListWindowClass() const { return WC_SHIPS_LIST; }
|
WindowClass GetVehicleListWindowClass() const { return WC_SHIPS_LIST; }
|
||||||
|
void PlayLeaveStationSound() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* SHIP_H */
|
#endif /* SHIP_H */
|
||||||
|
|
|
@ -235,13 +235,18 @@ void Ship::MarkDirty()
|
||||||
MarkAllViewportsDirty(this->left_coord, this->top_coord, this->right_coord + 1, this->bottom_coord + 1);
|
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)) {
|
if (!PlayVehicleSound(v, VSE_START)) {
|
||||||
SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v);
|
SndPlayVehicleFx(ShipVehInfo(v->engine_type)->sfx, v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Ship::PlayLeaveStationSound() const
|
||||||
|
{
|
||||||
|
PlayShipSound(this);
|
||||||
|
}
|
||||||
|
|
||||||
static void ProcessShipOrder(Vehicle *v)
|
static void ProcessShipOrder(Vehicle *v)
|
||||||
{
|
{
|
||||||
const Order *order;
|
const Order *order;
|
||||||
|
@ -308,7 +313,7 @@ static void HandleShipLoading(Vehicle *v)
|
||||||
|
|
||||||
if (LoadUnloadVehicle(v)) return;
|
if (LoadUnloadVehicle(v)) return;
|
||||||
|
|
||||||
PlayShipSound(v);
|
v->PlayLeaveStationSound();
|
||||||
|
|
||||||
Order b = v->current_order;
|
Order b = v->current_order;
|
||||||
v->LeaveStation();
|
v->LeaveStation();
|
||||||
|
|
|
@ -248,6 +248,7 @@ struct Train : public Vehicle {
|
||||||
void UpdateDeltaXY(Direction direction);
|
void UpdateDeltaXY(Direction direction);
|
||||||
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
|
ExpensesType GetExpenseType(bool income) const { return income ? EXPENSES_TRAIN_INC : EXPENSES_TRAIN_RUN; }
|
||||||
WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; }
|
WindowClass GetVehicleListWindowClass() const { return WC_TRAINS_LIST; }
|
||||||
|
void PlayLeaveStationSound() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* TRAIN_H */
|
#endif /* TRAIN_H */
|
||||||
|
|
|
@ -2097,6 +2097,11 @@ static void TrainPlayLeaveStationSound(const Vehicle* v)
|
||||||
SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v);
|
SndPlayVehicleFx(sfx[RailVehInfo(engtype)->engclass], v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Train::PlayLeaveStationSound() const
|
||||||
|
{
|
||||||
|
TrainPlayLeaveStationSound(this);
|
||||||
|
}
|
||||||
|
|
||||||
static bool CheckTrainStayInDepot(Vehicle *v)
|
static bool CheckTrainStayInDepot(Vehicle *v)
|
||||||
{
|
{
|
||||||
/* bail out if not all wagons are in the same depot or not in a depot at all */
|
/* 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;
|
if (LoadUnloadVehicle(v)) return;
|
||||||
|
|
||||||
TrainPlayLeaveStationSound(v);
|
v->PlayLeaveStationSound();
|
||||||
|
|
||||||
Order b = v->current_order;
|
Order b = v->current_order;
|
||||||
v->LeaveStation();
|
v->LeaveStation();
|
||||||
|
|
|
@ -375,6 +375,11 @@ struct Vehicle {
|
||||||
* Invalidates the vehicle list window of this type of vehicle
|
* Invalidates the vehicle list window of this type of vehicle
|
||||||
*/
|
*/
|
||||||
virtual WindowClass GetVehicleListWindowClass() const { return WC_NONE; }
|
virtual WindowClass GetVehicleListWindowClass() const { return WC_NONE; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Play the sound associated with leaving the station
|
||||||
|
*/
|
||||||
|
virtual void PlayLeaveStationSound() const {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue