Codechange: Use std::endian instead of TTD_ENDIAN where trivial. (#12778)

pull/741/head
Peter Nelson 3 months ago committed by GitHub
parent f9f07e9001
commit b68172c225
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -71,7 +71,7 @@ struct ScreenshotFormat {
ScreenshotHandlerProc *proc; ///< Function for writing the screenshot. ScreenshotHandlerProc *proc; ///< Function for writing the screenshot.
}; };
#define MKCOLOUR(x) TO_LE32X(x) #define MKCOLOUR(x) TO_LE32(x)
/************************************************* /*************************************************
**** SCREENSHOT CODE FOR WINDOWS BITMAP (.BMP) **** SCREENSHOT CODE FOR WINDOWS BITMAP (.BMP)
@ -360,12 +360,12 @@ static bool MakePNGImage(const char *name, ScreenshotCallback *callb, void *user
sig_bit.gray = 8; sig_bit.gray = 8;
png_set_sBIT(png_ptr, info_ptr, &sig_bit); png_set_sBIT(png_ptr, info_ptr, &sig_bit);
#if TTD_ENDIAN == TTD_LITTLE_ENDIAN if constexpr (std::endian::native == std::endian::little) {
png_set_bgr(png_ptr); png_set_bgr(png_ptr);
png_set_filler(png_ptr, 0, PNG_FILLER_AFTER); png_set_filler(png_ptr, 0, PNG_FILLER_AFTER);
#else } else {
png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE); png_set_filler(png_ptr, 0, PNG_FILLER_BEFORE);
#endif /* TTD_ENDIAN == TTD_LITTLE_ENDIAN */ }
} }
/* use by default 64k temp memory */ /* use by default 64k temp memory */

@ -137,15 +137,15 @@ static bool SetBankSource(MixerChannel *mc, const SoundEntry *sound)
} }
} }
#if TTD_ENDIAN == TTD_BIG_ENDIAN if constexpr (std::endian::native == std::endian::big) {
if (sound->bits_per_sample == 16) { if (sound->bits_per_sample == 16) {
uint num_samples = sound->file_size / 2; size_t num_samples = sound->file_size / 2;
int16_t *samples = (int16_t *)mem; int16_t *samples = reinterpret_cast<int16_t *>(mem);
for (uint i = 0; i < num_samples; i++) { for (size_t i = 0; i < num_samples; i++) {
samples[i] = BSWAP16(samples[i]); samples[i] = BSWAP16(samples[i]);
} }
} }
#endif }
assert(sound->bits_per_sample == 8 || sound->bits_per_sample == 16); assert(sound->bits_per_sample == 8 || sound->bits_per_sample == 16);
assert(sound->channels == 1); assert(sound->channels == 1);

@ -20,7 +20,6 @@
#include "../debug.h" #include "../debug.h"
#include "../driver.h" #include "../driver.h"
#include "../mixer.h" #include "../mixer.h"
#include "../core/endian_type.hpp"
#include "cocoa_s.h" #include "cocoa_s.h"
#define Rect OTTDRect #define Rect OTTDRect
@ -58,9 +57,9 @@ std::optional<std::string_view> SoundDriver_Cocoa::Start(const StringList &parm)
requestedDesc.mBitsPerChannel = 16; requestedDesc.mBitsPerChannel = 16;
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger; requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsSignedInteger;
#if TTD_ENDIAN == TTD_BIG_ENDIAN if constexpr (std::endian::native == std::endian::big) {
requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian; requestedDesc.mFormatFlags |= kLinearPCMFormatFlagIsBigEndian;
#endif /* TTD_ENDIAN == TTD_BIG_ENDIAN */ }
requestedDesc.mFramesPerPacket = 1; requestedDesc.mFramesPerPacket = 1;
requestedDesc.mBytesPerFrame = requestedDesc.mBitsPerChannel * requestedDesc.mChannelsPerFrame / 8; requestedDesc.mBytesPerFrame = requestedDesc.mBitsPerChannel * requestedDesc.mChannelsPerFrame / 8;

@ -219,13 +219,8 @@ void SurveyOpenTTD(nlohmann::json &survey)
32 32
#endif #endif
; ;
survey["endian"] = if constexpr (std::endian::native == std::endian::little) survey["endian"] = "little";
#if (TTD_ENDIAN == TTD_LITTLE_ENDIAN) if constexpr (std::endian::native == std::endian::big) survey["endian"] = "big";
"little"
#else
"big"
#endif
;
survey["dedicated_build"] = survey["dedicated_build"] =
#ifdef DEDICATED #ifdef DEDICATED
"yes" "yes"

Loading…
Cancel
Save