mirror of https://github.com/OpenTTD/OpenTTD
(svn r16340) -Codechange: introduce SoundID (uint16) and use that instead of SoundFX, which was used as a byte and uint16 at different places, when the uint16 sound ID is meant.
parent
e3bd95e7b6
commit
9c24e2bb8f
|
@ -62,7 +62,7 @@ struct ShipVehicleInfo {
|
||||||
CargoID cargo_type;
|
CargoID cargo_type;
|
||||||
uint16 capacity;
|
uint16 capacity;
|
||||||
byte running_cost;
|
byte running_cost;
|
||||||
SoundFxByte sfx;
|
SoundID sfx;
|
||||||
bool refittable;
|
bool refittable;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -80,7 +80,7 @@ struct AircraftVehicleInfo {
|
||||||
byte cost_factor;
|
byte cost_factor;
|
||||||
byte running_cost;
|
byte running_cost;
|
||||||
byte subtype;
|
byte subtype;
|
||||||
SoundFxByte sfx;
|
SoundID sfx;
|
||||||
byte acceleration;
|
byte acceleration;
|
||||||
uint16 max_speed;
|
uint16 max_speed;
|
||||||
byte mail_capacity;
|
byte mail_capacity;
|
||||||
|
@ -92,7 +92,7 @@ struct RoadVehicleInfo {
|
||||||
byte cost_factor;
|
byte cost_factor;
|
||||||
byte running_cost;
|
byte running_cost;
|
||||||
byte running_cost_class;
|
byte running_cost_class;
|
||||||
SoundFxByte sfx;
|
SoundID sfx;
|
||||||
uint16 max_speed; ///< Maximum speed in mph/3.2 units
|
uint16 max_speed; ///< Maximum speed in mph/3.2 units
|
||||||
byte capacity;
|
byte capacity;
|
||||||
CargoID cargo_type;
|
CargoID cargo_type;
|
||||||
|
|
|
@ -811,7 +811,7 @@ static ChangeInfoResult RoadVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x12: // SFX
|
case 0x12: // SFX
|
||||||
rvi->sfx = (SoundFx)grf_load_byte(&buf);
|
rvi->sfx = grf_load_byte(&buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x13: // Power in 10hp
|
case 0x13: // Power in 10hp
|
||||||
|
@ -937,7 +937,7 @@ static ChangeInfoResult ShipVehicleChangeInfo(uint engine, int numinfo, int prop
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x10: // SFX
|
case 0x10: // SFX
|
||||||
svi->sfx = (SoundFx)grf_load_byte(&buf);
|
svi->sfx = grf_load_byte(&buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x11: // Cargos available for refitting
|
case 0x11: // Cargos available for refitting
|
||||||
|
@ -1053,7 +1053,7 @@ static ChangeInfoResult AircraftVehicleChangeInfo(uint engine, int numinfo, int
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x12: // SFX
|
case 0x12: // SFX
|
||||||
avi->sfx = (SoundFx)grf_load_byte(&buf);
|
avi->sfx = grf_load_byte(&buf);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x13: // Cargos available for refitting
|
case 0x13: // Cargos available for refitting
|
||||||
|
@ -2020,7 +2020,7 @@ static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, b
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < numinfo; i++) {
|
for (int i = 0; i < numinfo; i++) {
|
||||||
uint sound = sid + i + _cur_grffile->sound_offset - ORIGINAL_SAMPLE_COUNT;
|
SoundID sound = sid + i + _cur_grffile->sound_offset - ORIGINAL_SAMPLE_COUNT;
|
||||||
|
|
||||||
if (sound >= GetNumSounds()) {
|
if (sound >= GetNumSounds()) {
|
||||||
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds());
|
grfmsg(1, "SoundEffectChangeInfo: Sound %d not defined (max %d)", sound, GetNumSounds());
|
||||||
|
@ -2037,7 +2037,7 @@ static ChangeInfoResult SoundEffectChangeInfo(uint sid, int numinfo, int prop, b
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x0A: { // Override old sound
|
case 0x0A: { // Override old sound
|
||||||
uint orig_sound = grf_load_byte(&buf);
|
SoundID orig_sound = grf_load_byte(&buf);
|
||||||
|
|
||||||
if (orig_sound >= ORIGINAL_SAMPLE_COUNT) {
|
if (orig_sound >= ORIGINAL_SAMPLE_COUNT) {
|
||||||
grfmsg(1, "SoundEffectChangeInfo: Original sound %d not defined (max %d)", orig_sound, ORIGINAL_SAMPLE_COUNT);
|
grfmsg(1, "SoundEffectChangeInfo: Original sound %d not defined (max %d)", orig_sound, ORIGINAL_SAMPLE_COUNT);
|
||||||
|
|
|
@ -34,7 +34,7 @@ void InitializeSoundPool()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
FileEntry *GetSound(uint index)
|
FileEntry *GetSound(SoundID index)
|
||||||
{
|
{
|
||||||
if (index >= GetNumSounds()) return NULL;
|
if (index >= GetNumSounds()) return NULL;
|
||||||
return GetSoundInternal(index);
|
return GetSoundInternal(index);
|
||||||
|
|
|
@ -23,9 +23,9 @@ enum VehicleSoundEvent {
|
||||||
|
|
||||||
FileEntry *AllocateFileEntry();
|
FileEntry *AllocateFileEntry();
|
||||||
void InitializeSoundPool();
|
void InitializeSoundPool();
|
||||||
FileEntry *GetSound(uint index);
|
FileEntry *GetSound(SoundID sound_id);
|
||||||
uint GetNumSounds();
|
uint GetNumSounds();
|
||||||
bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event);
|
bool PlayVehicleSound(const Vehicle *v, VehicleSoundEvent event);
|
||||||
bool PlayTileSound(const struct GRFFile *file, uint16 sound_id, TileIndex tile);
|
bool PlayTileSound(const struct GRFFile *file, SoundID sound_id, TileIndex tile);
|
||||||
|
|
||||||
#endif /* NEWGRF_SOUND_H */
|
#endif /* NEWGRF_SOUND_H */
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
#ifndef NEWS_TYPE_H
|
#ifndef NEWS_TYPE_H
|
||||||
#define NEWS_TYPE_H
|
#define NEWS_TYPE_H
|
||||||
|
|
||||||
|
#include "core/enum_type.hpp"
|
||||||
#include "date_type.h"
|
#include "date_type.h"
|
||||||
#include "strings_type.h"
|
#include "strings_type.h"
|
||||||
#include "sound_type.h"
|
#include "sound_type.h"
|
||||||
|
|
|
@ -690,7 +690,7 @@ TileIndex RoadVehicle::GetOrderStationLocation(StationID station)
|
||||||
static void StartRoadVehSound(const Vehicle *v)
|
static void StartRoadVehSound(const Vehicle *v)
|
||||||
{
|
{
|
||||||
if (!PlayVehicleSound(v, VSE_START)) {
|
if (!PlayVehicleSound(v, VSE_START)) {
|
||||||
SoundFx s = RoadVehInfo(v->engine_type)->sfx;
|
SoundID s = RoadVehInfo(v->engine_type)->sfx;
|
||||||
if (s == SND_19_BUS_START_PULL_AWAY && (v->tick_counter & 3) == 0)
|
if (s == SND_19_BUS_START_PULL_AWAY && (v->tick_counter & 3) == 0)
|
||||||
s = SND_1A_BUS_START_PULL_AWAY_WITH_HORN;
|
s = SND_1A_BUS_START_PULL_AWAY_WITH_HORN;
|
||||||
SndPlayVehicleFx(s, v);
|
SndPlayVehicleFx(s, v);
|
||||||
|
|
|
@ -123,11 +123,11 @@ bool SoundInitialize(const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Low level sound player */
|
/* Low level sound player */
|
||||||
static void StartSound(uint sound, int panning, uint volume)
|
static void StartSound(SoundID sound_id, int panning, uint volume)
|
||||||
{
|
{
|
||||||
if (volume == 0) return;
|
if (volume == 0) return;
|
||||||
|
|
||||||
const FileEntry *fe = GetSound(sound);
|
const FileEntry *fe = GetSound(sound_id);
|
||||||
if (fe == NULL) return;
|
if (fe == NULL) return;
|
||||||
|
|
||||||
MixerChannel *mc = MxAllocateChannel();
|
MixerChannel *mc = MxAllocateChannel();
|
||||||
|
@ -195,7 +195,7 @@ void SndCopyToPool()
|
||||||
* @param top Top edge of virtual coordinates where the sound is produced
|
* @param top Top edge of virtual coordinates where the sound is produced
|
||||||
* @param bottom Bottom edge of virtual coordinates where the sound is produced
|
* @param bottom Bottom edge of virtual coordinates where the sound is produced
|
||||||
*/
|
*/
|
||||||
static void SndPlayScreenCoordFx(SoundFx sound, int left, int right, int top, int bottom)
|
static void SndPlayScreenCoordFx(SoundID sound, int left, int right, int top, int bottom)
|
||||||
{
|
{
|
||||||
if (msf.effect_vol == 0) return;
|
if (msf.effect_vol == 0) return;
|
||||||
|
|
||||||
|
@ -220,7 +220,7 @@ static void SndPlayScreenCoordFx(SoundFx sound, int left, int right, int top, in
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SndPlayTileFx(SoundFx sound, TileIndex tile)
|
void SndPlayTileFx(SoundID sound, TileIndex tile)
|
||||||
{
|
{
|
||||||
/* emits sound from center of the tile */
|
/* emits sound from center of the tile */
|
||||||
int x = min(MapMaxX() - 1, TileX(tile)) * TILE_SIZE + TILE_SIZE / 2;
|
int x = min(MapMaxX() - 1, TileX(tile)) * TILE_SIZE + TILE_SIZE / 2;
|
||||||
|
@ -232,7 +232,7 @@ void SndPlayTileFx(SoundFx sound, TileIndex tile)
|
||||||
SndPlayScreenCoordFx(sound, pt.x, pt2.x, pt.y, pt2.y);
|
SndPlayScreenCoordFx(sound, pt.x, pt2.x, pt.y, pt2.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SndPlayVehicleFx(SoundFx sound, const Vehicle *v)
|
void SndPlayVehicleFx(SoundID sound, const Vehicle *v)
|
||||||
{
|
{
|
||||||
SndPlayScreenCoordFx(sound,
|
SndPlayScreenCoordFx(sound,
|
||||||
v->coord.left, v->coord.right,
|
v->coord.left, v->coord.right,
|
||||||
|
@ -240,7 +240,7 @@ void SndPlayVehicleFx(SoundFx sound, const Vehicle *v)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SndPlayFx(SoundFx sound)
|
void SndPlayFx(SoundID sound)
|
||||||
{
|
{
|
||||||
StartSound(sound, 0, msf.effect_vol);
|
StartSound(sound, 0, msf.effect_vol);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,9 @@ extern MusicFileSettings msf;
|
||||||
|
|
||||||
bool SoundInitialize(const char *filename);
|
bool SoundInitialize(const char *filename);
|
||||||
|
|
||||||
void SndPlayTileFx(SoundFx sound, TileIndex tile);
|
void SndPlayTileFx(SoundID sound, TileIndex tile);
|
||||||
void SndPlayVehicleFx(SoundFx sound, const Vehicle *v);
|
void SndPlayVehicleFx(SoundID sound, const Vehicle *v);
|
||||||
void SndPlayFx(SoundFx sound);
|
void SndPlayFx(SoundID sound);
|
||||||
void SndCopyToPool();
|
void SndCopyToPool();
|
||||||
|
|
||||||
#endif /* SOUND_FUNC_H */
|
#endif /* SOUND_FUNC_H */
|
||||||
|
|
|
@ -5,8 +5,6 @@
|
||||||
#ifndef SOUND_TYPE_H
|
#ifndef SOUND_TYPE_H
|
||||||
#define SOUND_TYPE_H
|
#define SOUND_TYPE_H
|
||||||
|
|
||||||
#include "core/enum_type.hpp"
|
|
||||||
|
|
||||||
struct MusicFileSettings {
|
struct MusicFileSettings {
|
||||||
byte playlist;
|
byte playlist;
|
||||||
byte music_vol;
|
byte music_vol;
|
||||||
|
@ -106,11 +104,9 @@ enum SoundFx {
|
||||||
SND_END
|
SND_END
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Define basic enum properties */
|
|
||||||
template <> struct EnumPropsT<SoundFx> : MakeEnumPropsT<SoundFx, byte, SND_BEGIN, SND_END, SND_END> {};
|
|
||||||
typedef TinyEnumT<SoundFx> SoundFxByte;
|
|
||||||
|
|
||||||
/** The number of sounds in the original sample.cat */
|
/** The number of sounds in the original sample.cat */
|
||||||
static const uint ORIGINAL_SAMPLE_COUNT = 73;
|
static const uint ORIGINAL_SAMPLE_COUNT = 73;
|
||||||
|
|
||||||
|
typedef uint16 SoundID;
|
||||||
|
|
||||||
#endif /* SOUND_TYPE_H */
|
#endif /* SOUND_TYPE_H */
|
||||||
|
|
|
@ -518,7 +518,7 @@ static const RailVehicleInfo _orig_rail_vehicle_info[] = {
|
||||||
* @param g sound effect
|
* @param g sound effect
|
||||||
* @param h refittable
|
* @param h refittable
|
||||||
*/
|
*/
|
||||||
#define SVI(a, b, c, d, e, f, g, h) { a, b, c, d, e, f, {g}, h }
|
#define SVI(a, b, c, d, e, f, g, h) { a, b, c, d, e, f, g, h }
|
||||||
static const ShipVehicleInfo _orig_ship_vehicle_info[] = {
|
static const ShipVehicleInfo _orig_ship_vehicle_info[] = {
|
||||||
/* image_index cargo_type cargo_amount refittable
|
/* image_index cargo_type cargo_amount refittable
|
||||||
* | base_cost | | running_cost |
|
* | base_cost | | running_cost |
|
||||||
|
@ -550,7 +550,7 @@ static const ShipVehicleInfo _orig_ship_vehicle_info[] = {
|
||||||
* @param h mail_capacity
|
* @param h mail_capacity
|
||||||
* @param i passenger_capacity
|
* @param i passenger_capacity
|
||||||
*/
|
*/
|
||||||
#define AVI(a, b, c, d, e, f, g, h, i) { a, b, c, d, {e}, f, (g * 129) / 10, h, i }
|
#define AVI(a, b, c, d, e, f, g, h, i) { a, b, c, d, e, f, (g * 129) / 10, h, i }
|
||||||
#define H AIR_HELI
|
#define H AIR_HELI
|
||||||
#define P AIR_CTOL
|
#define P AIR_CTOL
|
||||||
#define J AIR_CTOL | AIR_FAST
|
#define J AIR_CTOL | AIR_FAST
|
||||||
|
@ -619,7 +619,7 @@ static const AircraftVehicleInfo _orig_aircraft_vehicle_info[] = {
|
||||||
* @param h weight (1/4ton)
|
* @param h weight (1/4ton)
|
||||||
* @param i power (10hp)
|
* @param i power (10hp)
|
||||||
*/
|
*/
|
||||||
#define ROV(a, b, c, d, e, f, g, h, i) { a, b, c, RC_R, {d}, e, f, g, h, i, 76, 0 }
|
#define ROV(a, b, c, d, e, f, g, h, i) { a, b, c, RC_R, d, e, f, g, h, i, 76, 0 }
|
||||||
static const RoadVehicleInfo _orig_road_vehicle_info[] = {
|
static const RoadVehicleInfo _orig_road_vehicle_info[] = {
|
||||||
/* image_index sfx max_speed
|
/* image_index sfx max_speed
|
||||||
* | base_cost | | capacity
|
* | base_cost | | capacity
|
||||||
|
|
Loading…
Reference in New Issue