From 45a17142524b79254b0b87a8385ee36cbfac79ce Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 23 Apr 2016 04:04:00 +0300 Subject: Fix code style. --- src/resources/db/palettedb.cpp | 17 +++-------------- src/resources/dye/dyepalette.cpp | 2 +- src/resources/memorymanager.cpp | 6 +++--- src/resources/memorymanager.h | 2 +- src/resources/resource.cpp | 4 +--- 5 files changed, 9 insertions(+), 22 deletions(-) (limited to 'src/resources') diff --git a/src/resources/db/palettedb.cpp b/src/resources/db/palettedb.cpp index 88f90a1fc..4a233d67b 100644 --- a/src/resources/db/palettedb.cpp +++ b/src/resources/db/palettedb.cpp @@ -82,18 +82,6 @@ void PaletteDB::loadPalette() if (line.empty() || line[0] == '#') continue; -#ifdef ADVGCC - unsigned char r; - unsigned char g; - unsigned char b; - - if (sscanf(line.c_str(), "%10hhu %10hhu %10hhu\t%100s", - &r, &g, &b, name) == 4) - { - name[100] = 0; - mColors[name] = DyeColor(r, g, b); - } -#else unsigned int r; unsigned int g; unsigned int b; @@ -102,9 +90,10 @@ void PaletteDB::loadPalette() &r, &g, &b, name) == 4) { name[100] = 0; - mColors[name] = DyeColor(r, g, b); + mColors[name] = DyeColor(CAST_U8(r), + CAST_U8(g), + CAST_U8(b)); } -#endif } } diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp index 401eaf7ca..5884554ed 100644 --- a/src/resources/dye/dyepalette.cpp +++ b/src/resources/dye/dyepalette.cpp @@ -69,7 +69,7 @@ DyePalette::DyePalette(const std::string &restrict description, { if (str.size() != 3) continue; - alpha = (hexDecode(str[1]) << 4) + hexDecode(str[2]); + alpha = CAST_U8((hexDecode(str[1]) << 4) + hexDecode(str[2])); continue; } const DyeColor *const color = PaletteDB::getColor(str); diff --git a/src/resources/memorymanager.cpp b/src/resources/memorymanager.cpp index 546c19c45..758504326 100644 --- a/src/resources/memorymanager.cpp +++ b/src/resources/memorymanager.cpp @@ -31,12 +31,12 @@ MemoryManager::MemoryManager() } -int MemoryManager::getSurfaceSize(SDL_Surface *const surface) +int MemoryManager::getSurfaceSize(const SDL_Surface *const surface) { if (!surface) return 0; - return sizeof(SDL_Surface) + - sizeof(SDL_PixelFormat) + + return CAST_S32(sizeof(SDL_Surface)) + + CAST_S32(sizeof(SDL_PixelFormat)) + // aproximation for sizeof(SDL_BlitMap) 28 + // pixels diff --git a/src/resources/memorymanager.h b/src/resources/memorymanager.h index 8773d849a..88b55e617 100644 --- a/src/resources/memorymanager.h +++ b/src/resources/memorymanager.h @@ -35,7 +35,7 @@ class MemoryManager final ~MemoryManager() { } - int getSurfaceSize(SDL_Surface *const surface); + int getSurfaceSize(const SDL_Surface *const surface); void printMemory(const int level, const int localSum, diff --git a/src/resources/resource.cpp b/src/resources/resource.cpp index 40d44a7ec..a16f088a3 100644 --- a/src/resources/resource.cpp +++ b/src/resources/resource.cpp @@ -24,8 +24,6 @@ #include "logger.h" -#include "resources/memorycounter.h" -#include "resources/memorymanager.h" #include "resources/resourcemanager.h" #include "debug.h" @@ -73,7 +71,7 @@ void Resource::decRef() int Resource::calcMemoryLocal() { - return sizeof(Resource) + + return CAST_S32(sizeof(Resource)) + CAST_S32(mIdPath.size()) + CAST_S32(mSource.size()); } -- cgit v1.2.3-70-g09d2