Update to 14.0-beta1

This commit is contained in:
dP
2024-02-04 02:18:17 +05:30
parent 79037e2c65
commit 33ef333b57
1325 changed files with 138465 additions and 70987 deletions

View File

@@ -23,7 +23,7 @@
static SoundEntry _original_sounds[ORIGINAL_SAMPLE_COUNT];
static void OpenBankFile(const char *filename)
static void OpenBankFile(const std::string &filename)
{
/**
* The sound file for the original sounds, i.e. those not defined/overridden by a NewGRF.
@@ -34,7 +34,7 @@ static void OpenBankFile(const char *filename)
memset(_original_sounds, 0, sizeof(_original_sounds));
/* If there is no sound file (nosound set), don't load anything */
if (filename == nullptr) return;
if (filename.empty()) return;
original_sound_file.reset(new RandomAccessFile(filename, BASESET_DIR));
size_t pos = original_sound_file->GetPos();
@@ -75,8 +75,8 @@ static void OpenBankFile(const char *filename)
/* Read riff tags */
for (;;) {
uint32 tag = original_sound_file->ReadDword();
uint32 size = original_sound_file->ReadDword();
uint32_t tag = original_sound_file->ReadDword();
uint32_t size = original_sound_file->ReadDword();
if (tag == ' tmf') {
original_sound_file->ReadWord(); // wFormatTag
@@ -119,7 +119,7 @@ static bool SetBankSource(MixerChannel *mc, const SoundEntry *sound)
/* Check for valid sound size. */
if (sound->file_size == 0 || sound->file_size > ((size_t)-1) - 2) return false;
int8 *mem = MallocT<int8>(sound->file_size + 2);
int8_t *mem = MallocT<int8_t>(sound->file_size + 2);
/* Add two extra bytes so rate conversion can read these
* without reading out of its input buffer. */
mem[sound->file_size ] = 0;
@@ -139,7 +139,7 @@ static bool SetBankSource(MixerChannel *mc, const SoundEntry *sound)
#if TTD_ENDIAN == TTD_BIG_ENDIAN
if (sound->bits_per_sample == 16) {
uint num_samples = sound->file_size / 2;
int16 *samples = (int16 *)mem;
int16_t *samples = (int16_t *)mem;
for (uint i = 0; i < num_samples; i++) {
samples[i] = BSWAP16(samples[i]);
}
@@ -195,7 +195,7 @@ static void StartSound(SoundID sound_id, float pan, uint volume)
static const byte _vol_factor_by_zoom[] = {255, 255, 255, 190, 134, 87};
static_assert(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_COUNT);
static_assert(lengthof(_vol_factor_by_zoom) == ZOOM_LVL_END);
static const byte _sound_base_vol[] = {
128, 90, 128, 128, 128, 128, 128, 128,
@@ -258,7 +258,7 @@ static void SndPlayScreenCoordFx(SoundID sound, int left, int right, int top, in
StartSound(
sound,
panning,
_vol_factor_by_zoom[vp->zoom - ZOOM_LVL_BEGIN]
_vol_factor_by_zoom[vp->zoom]
);
return;
}
@@ -268,8 +268,8 @@ static void SndPlayScreenCoordFx(SoundID sound, int left, int right, int top, in
void SndPlayTileFx(SoundID sound, TileIndex tile)
{
/* emits sound from center of the tile */
int x = std::min(MapMaxX() - 1, TileX(tile)) * TILE_SIZE + TILE_SIZE / 2;
int y = std::min(MapMaxY() - 1, TileY(tile)) * TILE_SIZE - TILE_SIZE / 2;
int x = std::min(Map::MaxX() - 1, TileX(tile)) * TILE_SIZE + TILE_SIZE / 2;
int y = std::min(Map::MaxY() - 1, TileY(tile)) * TILE_SIZE - TILE_SIZE / 2;
int z = (y < 0 ? 0 : GetSlopePixelZ(x, y));
Point pt = RemapCoords(x, y, z);
y += 2 * TILE_SIZE;