From 08b4639cbb62235e02f80267da14d56af2ab08b3 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Fri, 17 Apr 2020 02:42:39 +0200 Subject: [PATCH] ALL: fix a bunch of const warnings Also while add it, constify some code --- backends/platform/sdl/macosx/macosx.cpp | 2 +- engines/dragons/credits.cpp | 4 ++-- engines/dragons/credits.h | 2 +- engines/dragons/screen.cpp | 20 ++++++++++---------- engines/dragons/screen.h | 12 ++++++------ engines/pink/cel_decoder.cpp | 6 +++--- 6 files changed, 23 insertions(+), 23 deletions(-) diff --git a/backends/platform/sdl/macosx/macosx.cpp b/backends/platform/sdl/macosx/macosx.cpp index 1545d9ab613..595d650d4f4 100644 --- a/backends/platform/sdl/macosx/macosx.cpp +++ b/backends/platform/sdl/macosx/macosx.cpp @@ -147,7 +147,7 @@ bool OSystem_MacOSX::setTextInClipboard(const Common::String &text) { } bool OSystem_MacOSX::openUrl(const Common::String &url) { - CFURLRef urlRef = CFURLCreateWithBytes (NULL, (UInt8*)url.c_str(), url.size(), kCFStringEncodingASCII, NULL); + CFURLRef urlRef = CFURLCreateWithBytes (NULL, (const UInt8*)url.c_str(), url.size(), kCFStringEncodingASCII, NULL); OSStatus err = LSOpenCFURLRef(urlRef, NULL); CFRelease(urlRef); return err == noErr; diff --git a/engines/dragons/credits.cpp b/engines/dragons/credits.cpp index 7e8f7277f2c..79048a46cec 100644 --- a/engines/dragons/credits.cpp +++ b/engines/dragons/credits.cpp @@ -85,7 +85,7 @@ void Credits::update() { if (_linesRemaining) { _linesRemaining--; } - convertToWideChar(line, (byte *)" ", 40); + convertToWideChar(line, (const byte *)" ", 40); } _fontManager->_fonts[0]->renderToSurface(_surface, 0, (_yOffset + 200) % 208, line, 40); @@ -102,7 +102,7 @@ void Credits::update() { } -void Credits::convertToWideChar(uint16 *destBuf, byte *text, uint16 maxLength) { +void Credits::convertToWideChar(uint16 *destBuf, const byte *text, uint16 maxLength) { bool finished = false; for (int i = 0; i < maxLength; i++) { if (text[i] == 0) { diff --git a/engines/dragons/credits.h b/engines/dragons/credits.h index 702940276de..10e18a27356 100644 --- a/engines/dragons/credits.h +++ b/engines/dragons/credits.h @@ -55,7 +55,7 @@ public: void update(); private: void cleanup(); - void convertToWideChar(uint16 *destBuf, byte *text, uint16 maxLength); + void convertToWideChar(uint16 *destBuf, const byte *text, uint16 maxLength); }; } // End of namespace Dragons diff --git a/engines/dragons/screen.cpp b/engines/dragons/screen.cpp index 56c84650705..ac92fad4bd0 100644 --- a/engines/dragons/screen.cpp +++ b/engines/dragons/screen.cpp @@ -80,9 +80,9 @@ void Screen::copyRectToSurface(const Graphics::Surface &srcSurface, int destX, i copyRectToSurface(srcSurface.getBasePtr(clipRect.left, clipRect.top), srcSurface.pitch, srcSurface.w, clipRect.left, destX, destY, clipRect.width(), clipRect.height(), flipX, alpha); } -void Screen::copyRectToSurface8bpp(const Graphics::Surface &srcSurface, byte *palette, int destX, int destY, const Common::Rect srcRect, bool flipX, AlphaBlendMode alpha, uint16 scale) { +void Screen::copyRectToSurface8bpp(const Graphics::Surface &srcSurface, const byte *palette, int destX, int destY, const Common::Rect srcRect, bool flipX, AlphaBlendMode alpha, uint16 scale) { if (scale != DRAGONS_ENGINE_SPRITE_100_PERCENT_SCALE) { - drawScaledSprite(_backSurface, (byte *)srcSurface.getBasePtr(0, 0), + drawScaledSprite(_backSurface, (const byte *)srcSurface.getBasePtr(0, 0), srcRect.width(), srcRect.height(), destX, destY, srcRect.width() * scale / DRAGONS_ENGINE_SPRITE_100_PERCENT_SCALE, srcRect.height() * scale / DRAGONS_ENGINE_SPRITE_100_PERCENT_SCALE, @@ -171,7 +171,7 @@ void Screen::copyRectToSurface(const void *buffer, int srcPitch, int srcWidth, i } } -void Screen::copyRectToSurface8bpp(const void *buffer, byte* palette, int srcPitch, int srcWidth, int srcXOffset, int destX, int destY, int width, int height, bool flipX, AlphaBlendMode alpha) { +void Screen::copyRectToSurface8bpp(const void *buffer, const byte* palette, int srcPitch, int srcWidth, int srcXOffset, int destX, int destY, int width, int height, bool flipX, AlphaBlendMode alpha) { assert(buffer); assert(destX >= 0 && destX < _backSurface->w); @@ -201,8 +201,8 @@ void Screen::copyRectToSurface8bpp(const void *buffer, byte* palette, int srcPit } } -void Screen::drawScaledSprite(Graphics::Surface *destSurface, byte *source, int sourceWidth, int sourceHeight, - int destX, int destY, int destWidth, int destHeight, byte *palette, bool flipX, uint8 alpha) { +void Screen::drawScaledSprite(Graphics::Surface *destSurface, const byte *source, int sourceWidth, int sourceHeight, + int destX, int destY, int destWidth, int destHeight, const byte *palette, bool flipX, uint8 alpha) { // Based on the GNAP engine scaling code if (destWidth == 0 || destHeight == 0) { return; @@ -231,11 +231,11 @@ void Screen::drawScaledSprite(Graphics::Surface *destSurface, byte *source, int return; byte *dst = (byte *)destSurface->getBasePtr(destX, destY); int yi = ys * clipY; - byte *hsrc = source + sourceWidth * ((yi + 0x8000) >> 16); + const byte *hsrc = source + sourceWidth * ((yi + 0x8000) >> 16); for (int yc = 0; yc < destHeight; ++yc) { byte *wdst = flipX ? dst + (destWidth - 1) * 2 : dst; int xi = flipX ? xs : xs * clipX; - byte *wsrc = hsrc + ((xi + 0x8000) >> 16); + const byte *wsrc = hsrc + ((xi + 0x8000) >> 16); for (int xc = 0; xc < destWidth; ++xc) { byte colorIndex = *wsrc; uint16 c = READ_LE_UINT16(&palette[colorIndex * 2]); @@ -328,7 +328,7 @@ void Screen::updatePaletteTransparency(uint16 paletteNum, uint16 startOffset, ui } } -void Screen::loadPalette(uint16 paletteNum, byte *palette) { +void Screen::loadPalette(uint16 paletteNum, const byte *palette) { bool isTransPalette = (paletteNum & 0x8000); paletteNum &= ~0x8000; assert(paletteNum < DRAGONS_NUM_PALETTES); @@ -394,7 +394,7 @@ void Screen::setScreenShakeOffset(int16 x, int16 y) { _screenShakeOffset.y = y; } -void Screen::copyRectToSurface8bppWrappedY(const Graphics::Surface &srcSurface, byte *palette, int yOffset) { +void Screen::copyRectToSurface8bppWrappedY(const Graphics::Surface &srcSurface, const byte *palette, int yOffset) { byte *dst = (byte *)_backSurface->getBasePtr(0, 0); for (int i = 0; i < DRAGONS_SCREEN_HEIGHT; i++) { const byte *src = (const byte *)srcSurface.getPixels() + ((yOffset + i) % srcSurface.h) * srcSurface.pitch; @@ -408,7 +408,7 @@ void Screen::copyRectToSurface8bppWrappedY(const Graphics::Surface &srcSurface, } } -void Screen::copyRectToSurface8bppWrappedX(const Graphics::Surface &srcSurface, byte *palette, Common::Rect srcRect, +void Screen::copyRectToSurface8bppWrappedX(const Graphics::Surface &srcSurface, const byte *palette, Common::Rect srcRect, AlphaBlendMode alpha) { // Copy buffer data to internal buffer const byte *src = (const byte *)srcSurface.getBasePtr(0, 0); diff --git a/engines/dragons/screen.h b/engines/dragons/screen.h index 45b3654f613..310b8e78ce7 100644 --- a/engines/dragons/screen.h +++ b/engines/dragons/screen.h @@ -71,10 +71,10 @@ public: Graphics::PixelFormat getPixelFormat() { return _pixelFormat; } void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY); void copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, Common::Rect srcRect, bool flipX = false, AlphaBlendMode alpha = NONE); - void copyRectToSurface8bpp(const Graphics::Surface &srcSurface, byte *palette, int destX, int destY, Common::Rect srcRect, bool flipX = false, AlphaBlendMode alpha = NONE, uint16 scale = DRAGONS_ENGINE_SPRITE_100_PERCENT_SCALE); - void copyRectToSurface8bppWrappedX(const Graphics::Surface &srcSurface, byte *palette, Common::Rect srcRect, AlphaBlendMode alpha = NONE); + void copyRectToSurface8bpp(const Graphics::Surface &srcSurface, const byte *palette, int destX, int destY, Common::Rect srcRect, bool flipX = false, AlphaBlendMode alpha = NONE, uint16 scale = DRAGONS_ENGINE_SPRITE_100_PERCENT_SCALE); + void copyRectToSurface8bppWrappedX(const Graphics::Surface &srcSurface, const byte *palette, Common::Rect srcRect, AlphaBlendMode alpha = NONE); void updateScreen(); - void loadPalette(uint16 paletteNum, byte *palette); + void loadPalette(uint16 paletteNum, const byte *palette); byte *getPalette(uint16 paletteNum); void setPaletteRecord(uint16 paletteNum, uint16 offset, uint16 newValue); void updatePaletteTransparency(uint16 paletteNum, uint16 startOffset, uint16 endOffset, bool isTransparent); @@ -86,7 +86,7 @@ public: void setScreenShakeOffset(int16 x, int16 y); - void copyRectToSurface8bppWrappedY(const Graphics::Surface &srcSurface, byte *palette, int yOffset); + void copyRectToSurface8bppWrappedY(const Graphics::Surface &srcSurface, const byte *palette, int yOffset); int16 addFlatQuad(int16 x0, int16 y0, int16 x1, int16 y1, int16 x3, int16 y3, int16 x2, int16 y2, uint16 colour, int16 priorityLayer, uint16 flags); void drawFlatQuads(uint16 priorityLayer); @@ -95,8 +95,8 @@ public: private: void copyRectToSurface(const void *buffer, int srcPitch, int srcWidth, int srcXOffset, int destX, int destY, int width, int height, bool flipX, AlphaBlendMode alpha); - void copyRectToSurface8bpp(const void *buffer, byte* palette, int srcPitch, int srcWidth, int srcXOffset, int destX, int destY, int width, int height, bool flipX, AlphaBlendMode alpha); - void drawScaledSprite(Graphics::Surface *destSurface, byte *source, int sourceWidth, int sourceHeight, int destX, int destY, int destWidth, int destHeight, byte *palette, bool flipX, uint8 alpha); + void copyRectToSurface8bpp(const void *buffer, const byte* palette, int srcPitch, int srcWidth, int srcXOffset, int destX, int destY, int width, int height, bool flipX, AlphaBlendMode alpha); + void drawScaledSprite(Graphics::Surface *destSurface, const byte *source, int sourceWidth, int sourceHeight, int destX, int destY, int destWidth, int destHeight, const byte *palette, bool flipX, uint8 alpha); }; } // End of namespace Dragons diff --git a/engines/pink/cel_decoder.cpp b/engines/pink/cel_decoder.cpp index e048e8b5aaf..fafd6cc9a1f 100644 --- a/engines/pink/cel_decoder.cpp +++ b/engines/pink/cel_decoder.cpp @@ -55,21 +55,21 @@ bool CelDecoder::loadStream(Common::SeekableReadStream *stream) { uint16 CelDecoder::getTransparentColourIndex() const { - CelVideoTrack *track = (CelVideoTrack *)getTrack(0); + const CelVideoTrack *track = (const CelVideoTrack *)getTrack(0); if (!track) return 0; return track->getTransparentColourIndex(); } const Graphics::Surface *CelDecoder::getCurrentFrame() const { - CelVideoTrack *track = (CelVideoTrack *)getTrack(0); + const CelVideoTrack *track = (const CelVideoTrack *)getTrack(0); if (!track) return 0; return track->getCurrentFrame(); } Common::Point CelDecoder::getCenter() const { - CelVideoTrack *track = (CelVideoTrack *)getTrack(0); + const CelVideoTrack *track = (const CelVideoTrack *)getTrack(0); if (!track) return Common::Point(0, 0); return track->getCenter();