From 766cfd2f1891b11f5de704f2a7fe7583459eb8b0 Mon Sep 17 00:00:00 2001 From: Crystal Squirrel Date: Sat, 15 Nov 2025 18:47:30 +0100 Subject: [PATCH] Replace reinterpret_cast with static_cast --- src/openrct2-ui/audio/AudioChannel.cpp | 2 +- src/openrct2-ui/audio/FlacAudioSource.cpp | 16 ++++++++-------- src/openrct2-ui/audio/MemoryAudioSource.cpp | 2 +- src/openrct2-ui/audio/OggAudioSource.cpp | 8 ++++---- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/openrct2-ui/audio/AudioChannel.cpp b/src/openrct2-ui/audio/AudioChannel.cpp index c033a0e700..f188e7637d 100644 --- a/src/openrct2-ui/audio/AudioChannel.cpp +++ b/src/openrct2-ui/audio/AudioChannel.cpp @@ -254,7 +254,7 @@ namespace OpenRCT2::Audio size_t readLen = _source->Read(dst, _offset, bytesToRead); if (readLen > 0) { - dst = reinterpret_cast(reinterpret_cast(dst) + readLen); + dst = static_cast(static_cast(dst) + readLen); bytesToRead -= readLen; bytesRead += readLen; _offset += readLen; diff --git a/src/openrct2-ui/audio/FlacAudioSource.cpp b/src/openrct2-ui/audio/FlacAudioSource.cpp index 17a5665659..accdcb299d 100644 --- a/src/openrct2-ui/audio/FlacAudioSource.cpp +++ b/src/openrct2-ui/audio/FlacAudioSource.cpp @@ -96,7 +96,7 @@ namespace OpenRCT2::Audio _currentOffset = offset; } - auto dst8 = reinterpret_cast(dst); + auto dst8 = static_cast(dst); auto bytesRead = ReadFromDecodeBuffer(dst8, len); dst8 += bytesRead; if (bytesRead < len) @@ -171,7 +171,7 @@ namespace OpenRCT2::Audio static FLAC__StreamDecoderReadStatus FlacCallbackRead( const FLAC__StreamDecoder* decoder, FLAC__byte buffer[], size_t* bytes, void* clientData) { - auto* self = reinterpret_cast(clientData); + auto* self = static_cast(clientData); if (*bytes > 0) { *bytes = SDL_RWread(self->_rw, buffer, sizeof(FLAC__byte), *bytes); @@ -193,7 +193,7 @@ namespace OpenRCT2::Audio static FLAC__StreamDecoderSeekStatus FlacCallbackSeek( const FLAC__StreamDecoder* decoder, FLAC__uint64 absoluteByteOffset, void* clientData) { - auto* self = reinterpret_cast(clientData); + auto* self = static_cast(clientData); if (SDL_RWseek(self->_rw, absoluteByteOffset, RW_SEEK_SET) < 0) { return FLAC__STREAM_DECODER_SEEK_STATUS_ERROR; @@ -207,7 +207,7 @@ namespace OpenRCT2::Audio static FLAC__StreamDecoderTellStatus FlacCallbackTell( const FLAC__StreamDecoder* decoder, FLAC__uint64* absoluteByteOffset, void* clientData) { - auto* self = reinterpret_cast(clientData); + auto* self = static_cast(clientData); auto pos = SDL_RWtell(self->_rw); if (pos < 0) { @@ -223,7 +223,7 @@ namespace OpenRCT2::Audio static FLAC__StreamDecoderLengthStatus FlacCallbackLength( const FLAC__StreamDecoder* decoder, FLAC__uint64* streamLength, void* clientData) { - auto* self = reinterpret_cast(clientData); + auto* self = static_cast(clientData); auto pos = SDL_RWtell(self->_rw); auto length = SDL_RWseek(self->_rw, 0, RW_SEEK_END); if (SDL_RWseek(self->_rw, pos, RW_SEEK_SET) != pos || length < 0) @@ -239,7 +239,7 @@ namespace OpenRCT2::Audio static FLAC__bool FlacCallbackEof(const FLAC__StreamDecoder* decoder, void* clientData) { - auto* self = reinterpret_cast(clientData); + auto* self = static_cast(clientData); auto pos = SDL_RWtell(self->_rw); auto end = SDL_RWseek(self->_rw, 0, RW_SEEK_END); if (pos == end) @@ -256,7 +256,7 @@ namespace OpenRCT2::Audio static FLAC__StreamDecoderWriteStatus FlacCallbackWrite( const FLAC__StreamDecoder* decoder, const FLAC__Frame* frame, const FLAC__int32* const buffer[], void* clientData) { - auto* self = reinterpret_cast(clientData); + auto* self = static_cast(clientData); // Determine sizes auto channels = self->_format.channels; @@ -301,7 +301,7 @@ namespace OpenRCT2::Audio static void FlacCallbackMetadata( const FLAC__StreamDecoder* decoder, const FLAC__StreamMetadata* metadata, void* clientData) { - auto* self = reinterpret_cast(clientData); + auto* self = static_cast(clientData); if (metadata->type == FLAC__METADATA_TYPE_STREAMINFO) { self->_bitsPerSample = metadata->data.stream_info.bits_per_sample; diff --git a/src/openrct2-ui/audio/MemoryAudioSource.cpp b/src/openrct2-ui/audio/MemoryAudioSource.cpp index 696bd4293f..88dc696d32 100644 --- a/src/openrct2-ui/audio/MemoryAudioSource.cpp +++ b/src/openrct2-ui/audio/MemoryAudioSource.cpp @@ -55,7 +55,7 @@ namespace OpenRCT2::Audio auto src = _data.data(); if (src != nullptr) { - std::copy_n(src + offset, bytesToRead, reinterpret_cast(dst)); + std::copy_n(src + offset, bytesToRead, static_cast(dst)); } } return bytesToRead; diff --git a/src/openrct2-ui/audio/OggAudioSource.cpp b/src/openrct2-ui/audio/OggAudioSource.cpp index 99f07f046f..3fcf663cbd 100644 --- a/src/openrct2-ui/audio/OggAudioSource.cpp +++ b/src/openrct2-ui/audio/OggAudioSource.cpp @@ -101,7 +101,7 @@ namespace OpenRCT2::Audio } auto readLen = static_cast(len); - auto dst8 = reinterpret_cast(dst); + auto dst8 = static_cast(dst); int64_t totalBytesRead{}; int64_t bytesRead; do @@ -139,17 +139,17 @@ namespace OpenRCT2::Audio private: static size_t VorbisCallbackRead(void* ptr, size_t size, size_t nmemb, void* datasource) { - return SDL_RWread(reinterpret_cast(datasource), ptr, size, nmemb); + return SDL_RWread(static_cast(datasource), ptr, size, nmemb); } static int VorbisCallbackSeek(void* datasource, ogg_int64_t offset, int whence) { - return (SDL_RWseek(reinterpret_cast(datasource), offset, whence) < 0) ? -1 : 0; + return (SDL_RWseek(static_cast(datasource), offset, whence) < 0) ? -1 : 0; } static long VorbisCallbackTell(void* datasource) { - return static_cast(SDL_RWtell(reinterpret_cast(datasource))); + return static_cast(SDL_RWtell(static_cast(datasource))); } }; #endif