From 518a34c28624ff622c177b0b9505fc33a443793c Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 3 May 2025 17:41:51 +0200 Subject: [PATCH] Codechange: Use std::byte for generic buffers. --- src/blitter/8bpp_simple.cpp | 3 ++- src/landscape.cpp | 2 +- src/spritecache.cpp | 2 +- src/spritecache.h | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/blitter/8bpp_simple.cpp b/src/blitter/8bpp_simple.cpp index 9e80909068..e54fe9d376 100644 --- a/src/blitter/8bpp_simple.cpp +++ b/src/blitter/8bpp_simple.cpp @@ -73,8 +73,9 @@ Sprite *Blitter_8bppSimple::Encode(SpriteType, const SpriteLoader::SpriteCollect dest_sprite->y_offs = root_sprite.y_offs; /* Copy over only the 'remap' channel, as that is what we care about in 8bpp */ + uint8_t *dst = reinterpret_cast(dest_sprite->data); for (int i = 0; i < root_sprite.height * root_sprite.width; i++) { - dest_sprite->data[i] = root_sprite.data[i].m; + dst[i] = root_sprite.data[i].m; } return dest_sprite; diff --git a/src/landscape.cpp b/src/landscape.cpp index 2d0abb44db..19b3c690b0 100644 --- a/src/landscape.cpp +++ b/src/landscape.cpp @@ -836,7 +836,7 @@ static void GenerateTerrain(int type, uint flag) if (DiagDirToAxis(direction) == AXIS_Y) std::swap(w, h); - const uint8_t *p = templ->data; + const uint8_t *p = reinterpret_cast(templ->data); if ((flag & 4) != 0) { /* This is only executed in secondary/tertiary loops to generate the terrain for arctic and tropic. diff --git a/src/spritecache.cpp b/src/spritecache.cpp index 2eec68db0b..4eb118056b 100644 --- a/src/spritecache.cpp +++ b/src/spritecache.cpp @@ -526,7 +526,7 @@ static void *ReadSprite(const SpriteCache *sc, SpriteID id, SpriteType sprite_ty s->y_offs = root_sprite.y_offs; SpriteLoader::CommonPixel *src = root_sprite.data; - uint8_t *dest = s->data; + uint8_t *dest = reinterpret_cast(s->data); while (num-- > 0) { *dest++ = src->m; src++; diff --git a/src/spritecache.h b/src/spritecache.h index 3f0e99dd7a..09fee98a92 100644 --- a/src/spritecache.h +++ b/src/spritecache.h @@ -19,7 +19,7 @@ struct Sprite { uint16_t width; ///< Width of the sprite. int16_t x_offs; ///< Number of pixels to shift the sprite to the right. int16_t y_offs; ///< Number of pixels to shift the sprite downwards. - uint8_t data[]; ///< Sprite data. + std::byte data[]; ///< Sprite data. }; enum SpriteCacheCtrlFlags : uint8_t {