diff options
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/imagehelper.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/atlasloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/emptyatlasloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/imageloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/imagesetloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/musicloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/rescaledloader.cpp | 4 | ||||
-rw-r--r-- | src/resources/loaders/shaderloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/shaderprogramloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/soundloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/spritedefloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/subimageloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/subimagesetloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/walklayerloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/loaders/xmlloader.cpp | 2 | ||||
-rw-r--r-- | src/resources/resourcemanager/resourcemanager.cpp | 2 | ||||
-rw-r--r-- | src/resources/sdlgfxblitfunc.cpp | 66 | ||||
-rw-r--r-- | src/resources/sdlgfxblitfunc.h | 10 | ||||
-rw-r--r-- | src/resources/sdlimagehelper.cpp | 4 |
19 files changed, 56 insertions, 58 deletions
diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp index e7e3dea14..9495dde4e 100644 --- a/src/resources/imagehelper.cpp +++ b/src/resources/imagehelper.cpp @@ -94,7 +94,7 @@ Image *ImageHelper::load(SDL_RWops *const rw, Dye const &dye) if (!surf) return nullptr; - uint32_t *const pixels = static_cast<uint32_t *const>(surf->pixels); + uint32_t *const pixels = static_cast<uint32_t *>(surf->pixels); const int type = dye.getType(); switch (type) diff --git a/src/resources/loaders/atlasloader.cpp b/src/resources/loaders/atlasloader.cpp index 1faa98b44..d3e2e276f 100644 --- a/src/resources/loaders/atlasloader.cpp +++ b/src/resources/loaders/atlasloader.cpp @@ -43,7 +43,7 @@ struct AtlasLoader final if (!v) return nullptr; - const AtlasLoader *const rl = static_cast<const AtlasLoader *const>(v); + const AtlasLoader *const rl = static_cast<const AtlasLoader *>(v); AtlasResource *const resource = AtlasManager::loadTextureAtlas( rl->name, *rl->files); if (!resource) diff --git a/src/resources/loaders/emptyatlasloader.cpp b/src/resources/loaders/emptyatlasloader.cpp index 6fe2f1463..24c73ac21 100644 --- a/src/resources/loaders/emptyatlasloader.cpp +++ b/src/resources/loaders/emptyatlasloader.cpp @@ -44,7 +44,7 @@ struct EmptyAtlasLoader final return nullptr; const EmptyAtlasLoader *const rl = - static_cast<const EmptyAtlasLoader *const>(v); + static_cast<const EmptyAtlasLoader *>(v); AtlasResource *const resource = AtlasManager::loadEmptyAtlas( rl->name, *rl->files); if (!resource) diff --git a/src/resources/loaders/imageloader.cpp b/src/resources/loaders/imageloader.cpp index 268466654..5a1830e15 100644 --- a/src/resources/loaders/imageloader.cpp +++ b/src/resources/loaders/imageloader.cpp @@ -53,7 +53,7 @@ namespace } const DyedImageLoader *const rl - = static_cast<const DyedImageLoader *const>(v); + = static_cast<const DyedImageLoader *>(v); std::string path1 = rl->path; const size_t p = path1.find('|'); diff --git a/src/resources/loaders/imagesetloader.cpp b/src/resources/loaders/imagesetloader.cpp index 468b97120..342b26d9a 100644 --- a/src/resources/loaders/imagesetloader.cpp +++ b/src/resources/loaders/imagesetloader.cpp @@ -48,7 +48,7 @@ struct ImageSetLoader final return nullptr; const ImageSetLoader *const - rl = static_cast<const ImageSetLoader *const>(v); + rl = static_cast<const ImageSetLoader *>(v); Image *const img = Loader::getImage(rl->path); if (!img) diff --git a/src/resources/loaders/musicloader.cpp b/src/resources/loaders/musicloader.cpp index 3c6c7e1c2..23a994e1b 100644 --- a/src/resources/loaders/musicloader.cpp +++ b/src/resources/loaders/musicloader.cpp @@ -45,7 +45,7 @@ namespace if (!v) return nullptr; const ResourceLoader *const - rl = static_cast<const ResourceLoader *const>(v); + rl = static_cast<const ResourceLoader *>(v); SDL_RWops *const rw = VirtFs::rwopsOpenRead(rl->path); if (!rw) { diff --git a/src/resources/loaders/rescaledloader.cpp b/src/resources/loaders/rescaledloader.cpp index 8f77103ff..c6a70f969 100644 --- a/src/resources/loaders/rescaledloader.cpp +++ b/src/resources/loaders/rescaledloader.cpp @@ -45,7 +45,7 @@ namespace if (!v) return nullptr; const RescaledLoader *const rl - = static_cast<const RescaledLoader *const>(v); + = static_cast<const RescaledLoader *>(v); if (!rl->image) return nullptr; Image *const rescaled = rl->image->SDLgetScaledImage( @@ -71,7 +71,7 @@ Image *Loader::getRescaled(const Image *const image, const std::string idPath = image->mIdPath + strprintf( "_rescaled%dx%d", width, height); const RescaledLoader rl = { image, width, height }; - Image *const img = static_cast<Image *const>( + Image *const img = static_cast<Image *>( ResourceManager::get(idPath, RescaledLoader::load, &rl)); return img; } diff --git a/src/resources/loaders/shaderloader.cpp b/src/resources/loaders/shaderloader.cpp index d2ffba348..5d5b70869 100644 --- a/src/resources/loaders/shaderloader.cpp +++ b/src/resources/loaders/shaderloader.cpp @@ -48,7 +48,7 @@ namespace return nullptr; const ShaderLoader *const rl - = static_cast<const ShaderLoader *const>(v); + = static_cast<const ShaderLoader *>(v); Shader *const resource = shaders.createShader(rl->type, rl->name); if (!resource) reportAlways("Shader creation error: %s", rl->name.c_str()); diff --git a/src/resources/loaders/shaderprogramloader.cpp b/src/resources/loaders/shaderprogramloader.cpp index 763536a6c..2f73cb5a8 100644 --- a/src/resources/loaders/shaderprogramloader.cpp +++ b/src/resources/loaders/shaderprogramloader.cpp @@ -49,7 +49,7 @@ namespace return nullptr; const ShaderProgramLoader *const rl - = static_cast<const ShaderProgramLoader *const>(v); + = static_cast<const ShaderProgramLoader *>(v); ShaderProgram *const resource = shaders.createProgram( rl->vertex, rl->fragment, diff --git a/src/resources/loaders/soundloader.cpp b/src/resources/loaders/soundloader.cpp index bbab6d6ee..f5e7f1058 100644 --- a/src/resources/loaders/soundloader.cpp +++ b/src/resources/loaders/soundloader.cpp @@ -45,7 +45,7 @@ namespace if (!v) return nullptr; const ResourceLoader *const - rl = static_cast<const ResourceLoader *const>(v); + rl = static_cast<const ResourceLoader *>(v); SDL_RWops *const rw = VirtFs::rwopsOpenRead(rl->path); if (!rw) { diff --git a/src/resources/loaders/spritedefloader.cpp b/src/resources/loaders/spritedefloader.cpp index cb535ca7a..69f182b89 100644 --- a/src/resources/loaders/spritedefloader.cpp +++ b/src/resources/loaders/spritedefloader.cpp @@ -46,7 +46,7 @@ namespace return nullptr; const SpriteDefLoader *const - rl = static_cast<const SpriteDefLoader *const>(v); + rl = static_cast<const SpriteDefLoader *>(v); return SpriteDef::load(rl->path, rl->variant, settings.uselonglivesprites); diff --git a/src/resources/loaders/subimageloader.cpp b/src/resources/loaders/subimageloader.cpp index c63bf74d6..f340f69c9 100644 --- a/src/resources/loaders/subimageloader.cpp +++ b/src/resources/loaders/subimageloader.cpp @@ -48,7 +48,7 @@ namespace return nullptr; const SubImageLoader *const - rl = static_cast<const SubImageLoader *const>(v); + rl = static_cast<const SubImageLoader *>(v); if (!rl->parent) return nullptr; diff --git a/src/resources/loaders/subimagesetloader.cpp b/src/resources/loaders/subimagesetloader.cpp index f721b1c2b..4aefb4c2e 100644 --- a/src/resources/loaders/subimagesetloader.cpp +++ b/src/resources/loaders/subimagesetloader.cpp @@ -47,7 +47,7 @@ namespace return nullptr; const SubImageSetLoader *const - rl = static_cast<const SubImageSetLoader *const>(v); + rl = static_cast<const SubImageSetLoader *>(v); if (!rl->parent) return nullptr; diff --git a/src/resources/loaders/walklayerloader.cpp b/src/resources/loaders/walklayerloader.cpp index bfbee82ab..c5e4569c8 100644 --- a/src/resources/loaders/walklayerloader.cpp +++ b/src/resources/loaders/walklayerloader.cpp @@ -46,7 +46,7 @@ struct WalkLayerLoader final return nullptr; const WalkLayerLoader *const rl = static_cast<const - WalkLayerLoader *const>(v); + WalkLayerLoader *>(v); Resource *const resource = NavigationManager::loadWalkLayer(rl->map); if (!resource) reportAlways("WalkLayer creation error"); diff --git a/src/resources/loaders/xmlloader.cpp b/src/resources/loaders/xmlloader.cpp index 776dbcf76..9cacd1c41 100644 --- a/src/resources/loaders/xmlloader.cpp +++ b/src/resources/loaders/xmlloader.cpp @@ -43,7 +43,7 @@ namespace if (!v) return nullptr; const ResourceLoader *const - rl = static_cast<const ResourceLoader *const>(v); + rl = static_cast<const ResourceLoader *>(v); Resource *const res = new XML::Document(rl->path, rl->useResman, rl->skipError); diff --git a/src/resources/resourcemanager/resourcemanager.cpp b/src/resources/resourcemanager/resourcemanager.cpp index a18b526c2..0e77cea38 100644 --- a/src/resources/resourcemanager/resourcemanager.cpp +++ b/src/resources/resourcemanager/resourcemanager.cpp @@ -267,7 +267,7 @@ void logResource(const Resource *const res) if (!res) return; #ifdef USE_OPENGL - const Image *const image = dynamic_cast<const Image *const>(res); + const Image *const image = dynamic_cast<const Image *>(res); if (image) { std::string src = image->mSource; diff --git a/src/resources/sdlgfxblitfunc.cpp b/src/resources/sdlgfxblitfunc.cpp index 77c67bbc4..14e8dadcf 100644 --- a/src/resources/sdlgfxblitfunc.cpp +++ b/src/resources/sdlgfxblitfunc.cpp @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* +/* SDL_gfxBlitFunc: custom blitters (part of SDL_gfx library) @@ -31,13 +31,12 @@ LGPL (c) A. Schiffler #include "utils/checkutils.h" -#include <SDL.h> #include <SDL_video.h> #include "debug.h" #define GFX_DUFFS_LOOP4(pixel_copy_increment, width) \ - int n = (width+3)/4; \ + int n = (width + 3) / 4; \ switch (width & 3) \ { \ case 0: do { \ @@ -51,7 +50,7 @@ LGPL (c) A. Schiffler namespace { - typedef struct + struct SDL_gfxBlitInfo { Uint8 *s_pixels; int s_width; @@ -65,7 +64,7 @@ namespace SDL_PixelFormat *src; Uint8 *table; SDL_PixelFormat *dst; - } SDL_gfxBlitInfo; + }; static unsigned int GFX_ALPHA_ADJUST_ARRAY[256] = { @@ -330,12 +329,12 @@ namespace static void _SDL_gfxBlitBlitterRGBA(SDL_gfxBlitInfo *info) { - int width = info->d_width; + const int width = info->d_width; int height = info->d_height; Uint8 *src = info->s_pixels; - int srcskip = info->s_skip; + const int srcskip = info->s_skip; Uint8 *dst = info->d_pixels; - int dstskip = info->d_skip; + const int dstskip = info->d_skip; SDL_PixelFormat *srcfmt = info->src; while (height--) @@ -384,20 +383,20 @@ static void _SDL_gfxBlitBlitterRGBA(SDL_gfxBlitInfo *info) } } -static int _SDL_gfxBlitRGBACall(SDL_Surface *src, - SDL_Rect *srcrect, - SDL_Surface *dst, - SDL_Rect *dstrect) +static int _SDL_gfxBlitRGBACall(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect) { /* - * Set up source and destination buffer pointers, then blit + * Set up source and destination buffer pointers, then blit */ if (srcrect->w && srcrect->h) { SDL_gfxBlitInfo info; /* - * Set up the blit information + * Set up the blit information */ info.s_pixels = static_cast<Uint8 *>(src->pixels) + src->offset + static_cast<Uint16>(srcrect->y) * src->pitch + @@ -413,13 +412,13 @@ static int _SDL_gfxBlitRGBACall(SDL_Surface *src, info.d_height = dstrect->h; info.d_skip = CAST_S32(dst->pitch - info.d_width * dst->format->BytesPerPixel); - info.aux_data = NULL; + info.aux_data = nullptr; info.src = src->format; - info.table = NULL; + info.table = nullptr; info.dst = dst->format; /* - * Run the actual software blitter + * Run the actual software blitter */ _SDL_gfxBlitBlitterRGBA(&info); return 1; @@ -428,10 +427,10 @@ static int _SDL_gfxBlitRGBACall(SDL_Surface *src, return (0); } -int SDLgfxBlitRGBA(SDL_Surface *src, - SDL_Rect *srcrect, - SDL_Surface *dst, - SDL_Rect *dstrect) +int SDLgfxBlitRGBA(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect) { SDL_Rect sr; SDL_Rect dr; @@ -441,7 +440,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, int h; /* - * Make sure the surfaces aren't locked + * Make sure the surfaces aren't locked */ if (!src || !dst) { @@ -450,14 +449,14 @@ int SDLgfxBlitRGBA(SDL_Surface *src, } /* - * If the destination rectangle is NULL, use the entire dest surface + * If the destination rectangle is NULL, use the entire dest surface */ if (dstrect == nullptr) { dr.x = 0; dr.y = 0; - dr.w = dst->w; - dr.h = dst->h; + dr.w = CAST_U16(dst->w); + dr.h = CAST_U16(dst->h); } else { @@ -465,7 +464,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, } /* - * Clip the source rectangle to the source surface + * Clip the source rectangle to the source surface */ if (srcrect) { @@ -483,7 +482,6 @@ int SDLgfxBlitRGBA(SDL_Surface *src, maxh = src->h - srcy; if (maxh < h) h = maxh; - } else { @@ -494,7 +492,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, } /* - * Clip the destination rectangle against the clip rectangle + * Clip the destination rectangle against the clip rectangle */ SDL_Rect *clip = &dst->clip_rect; int dx; @@ -505,7 +503,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, { w -= dx; dr.x += dx; - srcx += dx; + srcx += CAST_S16(dx); } dx = dr.x + w - clip->x - clip->w; if (dx > 0) @@ -516,7 +514,7 @@ int SDLgfxBlitRGBA(SDL_Surface *src, { h -= dy; dr.y += dy; - srcy += dy; + srcy += CAST_S16(dy); } dy = dr.y + h - clip->y - clip->h; if (dy > 0) @@ -524,10 +522,10 @@ int SDLgfxBlitRGBA(SDL_Surface *src, if (w > 0 && h > 0) { - sr.x = srcx; - sr.y = srcy; - sr.w = dr.w = w; - sr.h = dr.h = h; + sr.x = CAST_S16(srcx); + sr.y = CAST_S16(srcy); + sr.w = dr.w = CAST_U16(w); + sr.h = dr.h = CAST_U16(h); return _SDL_gfxBlitRGBACall(src, &sr, dst, &dr); } diff --git a/src/resources/sdlgfxblitfunc.h b/src/resources/sdlgfxblitfunc.h index dcf59fdca..5060e3552 100644 --- a/src/resources/sdlgfxblitfunc.h +++ b/src/resources/sdlgfxblitfunc.h @@ -18,7 +18,7 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -/* +/* SDL_gfxBlitFunc: custom blitters (part of SDL_gfx library) @@ -34,9 +34,9 @@ struct SDL_Rect; // src surface can be any format (most time 32 bit surface with any masks) // dst surface always correct 32 sufraces (shared format for all) -int SDLgfxBlitRGBA(SDL_Surface *src, - SDL_Rect *srcrect, - SDL_Surface *dst, - SDL_Rect *dstrect); +int SDLgfxBlitRGBA(SDL_Surface *const src, + SDL_Rect *const srcrect, + SDL_Surface *const dst, + SDL_Rect *const dstrect); #endif // RESOURCE_SDLGFXBLITFUNC_H diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp index 3c1653ca4..afb81d170 100644 --- a/src/resources/sdlimagehelper.cpp +++ b/src/resources/sdlimagehelper.cpp @@ -145,7 +145,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage, uint32_t c = (static_cast<uint32_t*>(tmpImage->pixels))[i]; const unsigned v = (c & fmt->Amask) >> fmt->Ashift; - const uint8_t a = static_cast<const uint8_t>((v << fmt->Aloss) + const uint8_t a = static_cast<uint8_t>((v << fmt->Aloss) + (v >> (8 - (fmt->Aloss << 1)))); const uint8_t a2 = CAST_U8( @@ -235,7 +235,7 @@ Image *SDLImageHelper::_SDLload(SDL_Surface *tmpImage) cilk_for (size_t i = 0; i < sz; ++ i) { const unsigned v = (pixels[i] & amask) >> ashift; - const uint8_t a = static_cast<const uint8_t>((v << aloss) + const uint8_t a = static_cast<uint8_t>((v << aloss) + (v >> (8 - (aloss << 1)))); if (a != 255) |