summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-02-07 16:18:13 +0300
committerAndrei Karas <akaras@inbox.ru>2016-02-07 16:18:13 +0300
commit9fe21fcd8883b37bdc30224822e6e42afb35b8f0 (patch)
tree798117abd4dc7e610997d59d530a96ddc1509f53 /src/resources
parent4429cb14e9e187edef27aba692a4266733f79c17 (diff)
downloadmv-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.gz
mv-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.bz2
mv-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.tar.xz
mv-9fe21fcd8883b37bdc30224822e6e42afb35b8f0.zip
Replace most static_cast<Type> to shorter versions from defines.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/ambientlayer.cpp20
-rw-r--r--src/resources/animation/simpleanimation.cpp8
-rw-r--r--src/resources/beingcommon.cpp2
-rw-r--r--src/resources/beinginfo.cpp2
-rw-r--r--src/resources/db/colordb.cpp2
-rw-r--r--src/resources/dye/dye.cpp4
-rw-r--r--src/resources/dye/dyepalette.cpp24
-rw-r--r--src/resources/image.cpp22
-rw-r--r--src/resources/imagehelper.cpp16
-rw-r--r--src/resources/imageset.cpp2
-rw-r--r--src/resources/imagewriter.cpp4
-rw-r--r--src/resources/inventory/complexinventory.cpp4
-rw-r--r--src/resources/inventory/inventory.cpp24
-rw-r--r--src/resources/item/item.cpp2
-rw-r--r--src/resources/iteminfo.cpp10
-rw-r--r--src/resources/iteminfo.h4
-rw-r--r--src/resources/map/map.cpp16
-rw-r--r--src/resources/map/map.h2
-rw-r--r--src/resources/map/mapheights.h2
-rw-r--r--src/resources/map/maplayer.cpp10
-rw-r--r--src/resources/mapreader.cpp6
-rw-r--r--src/resources/resourcemanager.h2
-rw-r--r--src/resources/sdlimagehelper.cpp6
-rw-r--r--src/resources/sprite/animatedsprite.cpp14
-rw-r--r--src/resources/subimage.cpp24
-rw-r--r--src/resources/wallpaper.cpp4
26 files changed, 118 insertions, 118 deletions
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 298bdb0e1..644c71578 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -64,9 +64,9 @@ AmbientLayer::AmbientLayer(Image *const img,
// the default resolution...
Image *const rescaledOverlay = resourceManager->getRescaled(
mImage,
- static_cast<int>(mImage->mBounds.w) /
+ CAST_S32(mImage->mBounds.w) /
defaultScreenWidth * width,
- static_cast<int>(mImage->mBounds.h) /
+ CAST_S32(mImage->mBounds.h) /
defaultScreenHeight * height);
if (rescaledOverlay)
@@ -127,18 +127,18 @@ void AmbientLayer::draw(Graphics *const graphics, const int x,
if (imageHelper->useOpenGL() == RENDER_SOFTWARE ||
!mKeepRatio)
{
- graphics->drawPattern(mImage, static_cast<int>(-mPosX),
- static_cast<int>(-mPosY), x + static_cast<int>(mPosX),
- y + static_cast<int>(mPosY));
+ graphics->drawPattern(mImage, CAST_S32(-mPosX),
+ CAST_S32(-mPosY), x + CAST_S32(mPosX),
+ y + CAST_S32(mPosY));
}
else
{
- graphics->drawRescaledPattern(mImage, static_cast<int>(-mPosX),
- static_cast<int>(-mPosY), x + static_cast<int>(mPosX),
- y + static_cast<int>(mPosY),
- static_cast<int>(mImage->mBounds.w)
+ graphics->drawRescaledPattern(mImage, CAST_S32(-mPosX),
+ CAST_S32(-mPosY), x + CAST_S32(mPosX),
+ y + CAST_S32(mPosY),
+ CAST_S32(mImage->mBounds.w)
/ defaultScreenWidth * graphics->mWidth,
- static_cast<int>(mImage->mBounds.h) / defaultScreenHeight
+ CAST_S32(mImage->mBounds.h) / defaultScreenHeight
* graphics->mHeight);
}
}
diff --git a/src/resources/animation/simpleanimation.cpp b/src/resources/animation/simpleanimation.cpp
index 1a1d30094..e4c0d8a3f 100644
--- a/src/resources/animation/simpleanimation.cpp
+++ b/src/resources/animation/simpleanimation.cpp
@@ -98,8 +98,8 @@ void SimpleAnimation::setFrame(int frame)
if (frame < 0)
frame = 0;
- const unsigned int len = static_cast<unsigned>(mAnimation->getLength());
- if (static_cast<unsigned>(frame) >= len)
+ const unsigned int len = CAST_U32(mAnimation->getLength());
+ if (CAST_U32(frame) >= len)
frame = len - 1;
mAnimationPhase = frame;
mCurrentFrame = &mAnimation->mFrames[frame];
@@ -119,7 +119,7 @@ bool SimpleAnimation::update(const int timePassed)
mAnimationTime -= mCurrentFrame->delay;
mAnimationPhase++;
- if (static_cast<size_t>(mAnimationPhase) >= mAnimation->getLength())
+ if (CAST_SIZE(mAnimationPhase) >= mAnimation->getLength())
mAnimationPhase = 0;
mCurrentFrame = &mAnimation->mFrames[mAnimationPhase];
@@ -132,7 +132,7 @@ int SimpleAnimation::getLength() const
if (!mAnimation)
return 0;
- return static_cast<int>(mAnimation->getLength());
+ return CAST_S32(mAnimation->getLength());
}
Image *SimpleAnimation::getCurrentImage() const
diff --git a/src/resources/beingcommon.cpp b/src/resources/beingcommon.cpp
index d9b65bb02..af1f8e138 100644
--- a/src/resources/beingcommon.cpp
+++ b/src/resources/beingcommon.cpp
@@ -75,7 +75,7 @@ void BeingCommon::readBasicAttributes(BeingInfo *const info,
else if (walkStr == "walkswim" || walkStr == "swimwalk") // legacy
block |= BlockMask::GROUND | BlockMask::WATER;
}
- info->setBlockWalkMask(static_cast<unsigned char>(block ^ allFlags));
+ info->setBlockWalkMask(CAST_U8(block ^ allFlags));
}
bool BeingCommon::readObjectNodes(XmlNodePtrConst &spriteNode,
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index aa393dc72..d27339483 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -161,7 +161,7 @@ const SoundInfo &BeingInfo::getSound(const ItemSoundEvent::Type event) const
if (!vect || vect->empty())
return emptySound;
else
- return vect->at(static_cast<size_t>(rand()) % vect->size());
+ return vect->at(CAST_SIZE(rand()) % vect->size());
}
const Attack *BeingInfo::getAttack(const int id) const
diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp
index 674f70ef6..07dd7b46e 100644
--- a/src/resources/db/colordb.cpp
+++ b/src/resources/db/colordb.cpp
@@ -63,7 +63,7 @@ void ColorDB::load()
it = mColorLists.find("hair");
if (it != mColorLists.end())
- mHairColorsSize = static_cast<int>((*it).second.size());
+ mHairColorsSize = CAST_S32((*it).second.size());
else
mHairColorsSize = 0;
mLoaded = true;
diff --git a/src/resources/dye/dye.cpp b/src/resources/dye/dye.cpp
index c6e2ddd17..129756673 100644
--- a/src/resources/dye/dye.cpp
+++ b/src/resources/dye/dye.cpp
@@ -211,7 +211,7 @@ endlabel:{}
#else // ENABLE_CILKPLUS
- for (uint32_t *p_end = pixels + static_cast<size_t>(bufSize);
+ for (uint32_t *p_end = pixels + CAST_SIZE(bufSize);
pixels != p_end;
++ pixels)
{
@@ -330,7 +330,7 @@ endlabel:{}
#else // ENABLE_CILKPLUS
- for (uint32_t *p_end = pixels + static_cast<size_t>(bufSize);
+ for (uint32_t *p_end = pixels + CAST_SIZE(bufSize);
pixels != p_end;
++ pixels)
{
diff --git a/src/resources/dye/dyepalette.cpp b/src/resources/dye/dyepalette.cpp
index 19ded4295..6ec85a399 100644
--- a/src/resources/dye/dyepalette.cpp
+++ b/src/resources/dye/dyepalette.cpp
@@ -40,7 +40,7 @@ DyePalette::DyePalette(const std::string &restrict description,
const uint8_t blockSize) :
mColors()
{
- const size_t size = static_cast<size_t>(description.length());
+ const size_t size = CAST_SIZE(description.length());
if (size == 0)
return;
@@ -100,7 +100,7 @@ void DyePalette::hexToColor(const std::string &hexStr,
i < blockSize && colorIdx < 4;
i += 2, colorIdx ++)
{
- color.value[colorIdx] = static_cast<unsigned char>((
+ color.value[colorIdx] = CAST_U8((
hexDecode(hexStr[i]) << 4)
+ hexDecode(hexStr[i + 1]));
}
@@ -129,7 +129,7 @@ void DyePalette::getColor(const unsigned int intensity,
return;
}
- const int last = static_cast<int>(mColors.size());
+ const int last = CAST_S32(mColors.size());
if (last == 0)
return;
@@ -193,8 +193,8 @@ void DyePalette::getColor(double intensity,
intensity *= static_cast<double>(mColors.size() - 1);
// Color indices
- const int i = static_cast<int>(floor(intensity));
- const int j = static_cast<int>(ceil(intensity));
+ const int i = CAST_S32(floor(intensity));
+ const int j = CAST_S32(ceil(intensity));
const DyeColor &colorI = mColors[i];
if (i == j)
@@ -211,11 +211,11 @@ void DyePalette::getColor(double intensity,
const DyeColor &colorJ = mColors[j];
// Perform the interpolation.
- color[0] = static_cast<int>(rest * colorI.value[0] +
+ color[0] = CAST_S32(rest * colorI.value[0] +
intensity * colorJ.value[0]);
- color[1] = static_cast<int>(rest * colorI.value[1] +
+ color[1] = CAST_S32(rest * colorI.value[1] +
intensity * colorJ.value[1]);
- color[2] = static_cast<int>(rest * colorI.value[2] +
+ color[2] = CAST_S32(rest * colorI.value[2] +
intensity * colorJ.value[2]);
}
@@ -277,7 +277,7 @@ void DyePalette::replaceSColor(uint32_t *restrict pixels,
}
#else // ENABLE_CILKPLUS
- for (uint32_t *p_end = pixels + static_cast<size_t>(bufSize);
+ for (uint32_t *p_end = pixels + CAST_SIZE(bufSize);
pixels != p_end;
++ pixels)
{
@@ -377,7 +377,7 @@ void DyePalette::replaceAColor(uint32_t *restrict pixels,
#else // ENABLE_CILKPLUS
- for (uint32_t *p_end = pixels + static_cast<size_t>(bufSize);
+ for (uint32_t *p_end = pixels + CAST_SIZE(bufSize);
pixels != p_end;
++pixels)
{
@@ -470,7 +470,7 @@ void DyePalette::replaceSOGLColor(uint32_t *restrict pixels,
#else // ENABLE_CILKPLUS
- for (uint32_t *p_end = pixels + static_cast<size_t>(bufSize);
+ for (uint32_t *p_end = pixels + CAST_SIZE(bufSize);
pixels != p_end;
++pixels)
{
@@ -562,7 +562,7 @@ void DyePalette::replaceAOGLColor(uint32_t *restrict pixels,
#else // ENABLE_CILKPLUS
- for (uint32_t *p_end = pixels + static_cast<size_t>(bufSize);
+ for (uint32_t *p_end = pixels + CAST_SIZE(bufSize);
pixels != p_end;
++pixels)
{
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index b16ea8939..d820adcfb 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -72,8 +72,8 @@ Image::Image(SDL_Texture *restrict const image,
if (mTexture)
{
- mBounds.w = static_cast<uint16_t>(width);
- mBounds.h = static_cast<uint16_t>(height);
+ mBounds.w = CAST_U16(width);
+ mBounds.h = CAST_U16(height);
mLoaded = true;
}
@@ -118,8 +118,8 @@ Image::Image(SDL_Surface *restrict const image, const bool hasAlphaChannel0,
if (mSDLSurface)
{
- mBounds.w = static_cast<uint16_t>(mSDLSurface->w);
- mBounds.h = static_cast<uint16_t>(mSDLSurface->h);
+ mBounds.w = CAST_U16(mSDLSurface->w);
+ mBounds.h = CAST_U16(mSDLSurface->h);
mLoaded = true;
}
@@ -159,8 +159,8 @@ Image::Image(const GLuint glimage, const int width, const int height,
mBounds.x = 0;
mBounds.y = 0;
- mBounds.w = static_cast<uint16_t>(width);
- mBounds.h = static_cast<uint16_t>(height);
+ mBounds.w = CAST_U16(width);
+ mBounds.h = CAST_U16(height);
if (mGLImage)
{
@@ -314,11 +314,11 @@ void Image::setAlpha(const float alpha)
{
#ifdef USE_SDL2
SDL_SetSurfaceAlphaMod(mSDLSurface,
- static_cast<unsigned char>(255 * mAlpha));
+ CAST_U8(255 * mAlpha));
#else
// Set the alpha value this image is drawn at
SDL_SetAlpha(mSDLSurface, SDL_SRCALPHA,
- static_cast<unsigned char>(255 * mAlpha));
+ CAST_U8(255 * mAlpha));
#endif
}
else
@@ -349,7 +349,7 @@ void Image::setAlpha(const float alpha)
const uint8_t sourceAlpha = mAlphaChannel[i];
if (sourceAlpha > 0)
{
- const uint8_t a = static_cast<uint8_t>(
+ const uint8_t a = CAST_U8(
static_cast<float>(sourceAlpha) * mAlpha);
uint32_t c = (static_cast<uint32_t*>(
@@ -372,7 +372,7 @@ void Image::setAlpha(const float alpha)
const uint8_t sourceAlpha = mAlphaChannel[i];
if (sourceAlpha > 0)
{
- const uint8_t a = static_cast<uint8_t>(
+ const uint8_t a = CAST_U8(
static_cast<float>(sourceAlpha) * mAlpha);
uint32_t c = (static_cast<uint32_t*>(
@@ -395,7 +395,7 @@ void Image::setAlpha(const float alpha)
{
mAlpha = alpha;
SDL_SetTextureAlphaMod(mTexture,
- static_cast<unsigned char>(255 * mAlpha));
+ CAST_U8(255 * mAlpha));
}
#endif
else
diff --git a/src/resources/imagehelper.cpp b/src/resources/imagehelper.cpp
index f4e09b834..af573709b 100644
--- a/src/resources/imagehelper.cpp
+++ b/src/resources/imagehelper.cpp
@@ -176,15 +176,15 @@ void ImageHelper::dumpSurfaceFormat(const SDL_Surface *const image)
logger->log("Alpha: %d", format->alpha);
#endif
logger->log("Loss: %02x, %02x, %02x, %02x",
- static_cast<unsigned int>(format->Rloss),
- static_cast<unsigned int>(format->Gloss),
- static_cast<unsigned int>(format->Bloss),
- static_cast<unsigned int>(format->Aloss));
+ CAST_U32(format->Rloss),
+ CAST_U32(format->Gloss),
+ CAST_U32(format->Bloss),
+ CAST_U32(format->Aloss));
logger->log("Shift: %02x, %02x, %02x, %02x",
- static_cast<unsigned int>(format->Rshift),
- static_cast<unsigned int>(format->Gshift),
- static_cast<unsigned int>(format->Bshift),
- static_cast<unsigned int>(format->Ashift));
+ CAST_U32(format->Rshift),
+ CAST_U32(format->Gshift),
+ CAST_U32(format->Bshift),
+ CAST_U32(format->Ashift));
logger->log("Mask: %08x, %08x, %08x, %08x", format->Rmask,
format->Gmask, format->Bmask, format->Amask);
}
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index 2580b5684..e3ce9e7d1 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -67,7 +67,7 @@ Image* ImageSet::get(const size_type i) const
if (i >= mImages.size())
{
logger->log("Warning: No sprite %d in this image set",
- static_cast<int>(i));
+ CAST_S32(i));
return nullptr;
}
else
diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp
index 50db9b867..e599af156 100644
--- a/src/resources/imagewriter.cpp
+++ b/src/resources/imagewriter.cpp
@@ -83,7 +83,7 @@ bool ImageWriter::writePNG(SDL_Surface *const surface,
png_set_packing(png_ptr);
png_bytep *const row_pointers
- = new png_bytep[static_cast<size_t>(surface->h)];
+ = new png_bytep[CAST_SIZE(surface->h)];
/*
if (!row_pointers)
{
@@ -96,7 +96,7 @@ bool ImageWriter::writePNG(SDL_Surface *const surface,
for (int i = 0; i < surface->h; i++)
{
row_pointers[i] = static_cast<png_bytep>(static_cast<uint8_t *>(
- surface->pixels) + static_cast<size_t>(i * surface->pitch));
+ surface->pixels) + CAST_SIZE(i * surface->pitch));
}
png_write_image(png_ptr, row_pointers);
diff --git a/src/resources/inventory/complexinventory.cpp b/src/resources/inventory/complexinventory.cpp
index 06a8cf5c0..5264406cb 100644
--- a/src/resources/inventory/complexinventory.cpp
+++ b/src/resources/inventory/complexinventory.cpp
@@ -47,7 +47,7 @@ bool ComplexInventory::addVirtualItem(const Item *const item,
if (!item || PlayerInfo::isItemProtected(item->getId()))
return false;
- if (index >= 0 && index < static_cast<int>(mSize))
+ if (index >= 0 && index < CAST_S32(mSize))
{
ComplexItem *citem = nullptr;
if (mItems[index] != nullptr)
@@ -126,7 +126,7 @@ void ComplexInventory::setItem(const int index,
const Equipm equipment,
const Equipped equipped)
{
- if (index < 0 || index >= static_cast<int>(mSize))
+ if (index < 0 || index >= CAST_S32(mSize))
{
logger->log("Warning: invalid inventory index: %d", index);
return;
diff --git a/src/resources/inventory/inventory.cpp b/src/resources/inventory/inventory.cpp
index c73d9d8b6..f7f6dcaee 100644
--- a/src/resources/inventory/inventory.cpp
+++ b/src/resources/inventory/inventory.cpp
@@ -58,9 +58,9 @@ Inventory::Inventory(const InventoryTypeT type, const int size1) :
mInventoryListeners(),
mVirtualRemove(),
mType(type),
- mSize(size1 == -1 ? static_cast<unsigned>(
+ mSize(size1 == -1 ? CAST_U32(
inventoryHandler->getSize(type))
- : static_cast<unsigned>(size1)),
+ : CAST_U32(size1)),
mItems(new Item*[mSize]),
mUsed(0)
{
@@ -78,7 +78,7 @@ Inventory::~Inventory()
Item *Inventory::getItem(const int index) const
{
- if (index < 0 || index >= static_cast<int>(mSize) || !mItems[index]
+ if (index < 0 || index >= CAST_S32(mSize) || !mItems[index]
|| mItems[index]->mQuantity <= 0)
{
return nullptr;
@@ -137,7 +137,7 @@ void Inventory::setItem(const int index,
const Equipm equipment,
const Equipped equipped)
{
- if (index < 0 || index >= static_cast<int>(mSize))
+ if (index < 0 || index >= CAST_S32(mSize))
{
logger->log("Warning: invalid inventory index: %d", index);
return;
@@ -173,7 +173,7 @@ void Inventory::setCards(const int index,
const int *const cards,
const int size) const
{
- if (index < 0 || index >= static_cast<int>(mSize))
+ if (index < 0 || index >= CAST_S32(mSize))
{
logger->log("Warning: invalid inventory index: %d", index);
return;
@@ -232,7 +232,7 @@ int Inventory::getFreeSlot() const
Item **const i = std::find_if(mItems, mItems + mSize,
std::not1(SlotUsed()));
return (i == mItems + mSize) ? -1
- : static_cast<int>(i - mItems);
+ : CAST_S32(i - mItems);
}
int Inventory::getLastUsedSlot() const
@@ -355,7 +355,7 @@ void Inventory::resize(const unsigned int newSize)
delete [] mItems;
mSize = newSize;
- mItems = new Item*[static_cast<size_t>(mSize)];
+ mItems = new Item*[CAST_SIZE(mSize)];
std::fill_n(mItems, mSize, static_cast<Item*>(nullptr));
}
@@ -377,7 +377,7 @@ bool Inventory::addVirtualItem(const Item *const item,
{
if (item && !PlayerInfo::isItemProtected(item->getId()))
{
- if (index >= 0 && index < static_cast<int>(mSize))
+ if (index >= 0 && index < CAST_S32(mSize))
{
if (mItems[index] != nullptr)
return false;
@@ -434,7 +434,7 @@ void Inventory::virtualRemove(Item *const item,
void Inventory::restoreVirtuals()
{
- const int sz = static_cast<int>(mSize);
+ const int sz = CAST_S32(mSize);
logger->log("Inventory::restoreVirtuals 1");
FOR_EACH (IntMapCIter, it, mVirtualRemove)
@@ -461,7 +461,7 @@ void Inventory::virtualRestore(const Item *const item,
mVirtualRemove[index] -= amount;
if (mVirtualRemove[index] < 0)
mVirtualRemove.erase(index);
- if (index < 0 || index >= static_cast<int>(mSize) || !mItems[index])
+ if (index < 0 || index >= CAST_S32(mSize) || !mItems[index])
return;
mItems[index]->mQuantity += amount;
}
@@ -471,9 +471,9 @@ void Inventory::moveItem(const int index1,
const int index2)
{
if (index1 < 0 ||
- index1 >= static_cast<int>(mSize) ||
+ index1 >= CAST_S32(mSize) ||
index2 < 0 ||
- index2 >= static_cast<int>(mSize))
+ index2 >= CAST_S32(mSize))
{
return;
}
diff --git a/src/resources/item/item.cpp b/src/resources/item/item.cpp
index ae31dd94c..044e11fdb 100644
--- a/src/resources/item/item.cpp
+++ b/src/resources/item/item.cpp
@@ -87,7 +87,7 @@ void Item::setId(const int id,
mColor = color;
// Types 0 and 1 are not equippable items.
- mEquipment = fromBool(id && static_cast<int>(getInfo().getType())
+ mEquipment = fromBool(id && CAST_S32(getInfo().getType())
>= 2, Equipm);
if (mImage)
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 5d96e382e..9fd4f2ba2 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -102,12 +102,12 @@ const std::string &ItemInfo::getSprite(const GenderT gender,
{
static const std::string empty;
std::map<int, std::string>::const_iterator i =
- mAnimationFiles.find(static_cast<int>(gender) +
+ mAnimationFiles.find(CAST_S32(gender) +
toInt(race, int) * 4);
if (i != mAnimationFiles.end())
return i->second;
- i = mAnimationFiles.find(static_cast<int>(gender));
+ i = mAnimationFiles.find(CAST_S32(gender));
if (i != mAnimationFiles.end())
return i->second;
return empty;
@@ -162,7 +162,7 @@ const SoundInfo &ItemInfo::getSound(const ItemSoundEvent::Type event) const
if (i == mSounds.end())
return empty;
- return (!i->second.empty()) ? i->second[static_cast<unsigned int>(rand())
+ return (!i->second.empty()) ? i->second[CAST_U32(rand())
% i->second.size()] : empty;
}
@@ -275,7 +275,7 @@ const std::string ItemInfo::replaceColors(std::string str,
str = replaceAll(str, "%color%", name);
if (!name.empty())
- name[0] = static_cast<signed char>(toupper(name[0]));
+ name[0] = CAST_S8(toupper(name[0]));
return replaceAll(str, "%Color%", name);
}
@@ -397,7 +397,7 @@ void ItemInfo::setSprite(const std::string &animationFile,
const GenderT gender,
const int race)
{
- mAnimationFiles[static_cast<int>(gender) + race * 4] = animationFile;
+ mAnimationFiles[CAST_S32(gender) + race * 4] = animationFile;
}
std::string ItemInfo::getColorName(const ItemColor idx) const
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index b58ae0b60..2bf4e7980 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -292,11 +292,11 @@ class ItemInfo final
{ return mProtected; }
int getColorsSize() const
- { return mColorsList ? static_cast<int>(mColorsList->size()) : 0; }
+ { return mColorsList ? CAST_S32(mColorsList->size()) : 0; }
int getIconColorsSize() const
{
- return mIconColorsList ? static_cast<int>(mIconColorsList->size())
+ return mIconColorsList ? CAST_S32(mIconColorsList->size())
: 0;
}
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index cb5d67583..51bb90f9d 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -1207,7 +1207,7 @@ void Map::saveExtraLayer() const restrict2
&& item->mType != MapItemType::HOME)
{
mapFile << x << " " << y << " "
- << static_cast<int>(item->mType) << " "
+ << CAST_S32(item->mType) << " "
<< item->mComment << std::endl;
}
}
@@ -1365,8 +1365,8 @@ void Map::indexTilesets() restrict2
FOR_EACH (Tilesets::const_iterator, it, mTilesets)
{
const size_t sz = (*it)->size();
- if (!s || static_cast<size_t>(s->getFirstGid()) + sSz
- < static_cast<size_t>((*it)->getFirstGid()) + sz)
+ if (!s || CAST_SIZE(s->getFirstGid()) + sSz
+ < CAST_SIZE((*it)->getFirstGid()) + sz)
{
s = *it;
sSz = sz;
@@ -1379,10 +1379,10 @@ void Map::indexTilesets() restrict2
return;
}
- const int size = static_cast<int>(s->getFirstGid())
- + static_cast<int>(s->size());
+ const int size = CAST_S32(s->getFirstGid())
+ + CAST_S32(s->size());
mIndexedTilesetsSize = size;
- mIndexedTilesets = new Tileset*[static_cast<size_t>(size)];
+ mIndexedTilesets = new Tileset*[CAST_SIZE(size)];
std::fill_n(mIndexedTilesets, size, static_cast<Tileset*>(nullptr));
FOR_EACH (Tilesets::const_iterator, it, mTilesets)
@@ -1391,7 +1391,7 @@ void Map::indexTilesets() restrict2
if (s2)
{
const int start = s2->getFirstGid();
- const int end = start + static_cast<int>(s2->size());
+ const int end = start + CAST_S32(s2->size());
for (int f = start; f < end; f ++)
{
if (f < size)
@@ -1546,7 +1546,7 @@ void Map::reduce() restrict2
++ ri;
continue;
}
- const size_t pos = static_cast<size_t>(
+ const size_t pos = CAST_SIZE(
x + y * layer2->mWidth);
img = layer2->mTiles[pos].image;
if (img)
diff --git a/src/resources/map/map.h b/src/resources/map/map.h
index ea540907a..4ee387f8f 100644
--- a/src/resources/map/map.h
+++ b/src/resources/map/map.h
@@ -290,7 +290,7 @@ class Map final : public Properties, public ConfigListener
const int y) const restrict2 A_WARN_UNUSED;
int getActorsCount() const restrict2 A_WARN_UNUSED
- { return static_cast<int>(mActors.size()); }
+ { return CAST_S32(mActors.size()); }
void setPvpMode(const int mode) restrict2;
diff --git a/src/resources/map/mapheights.h b/src/resources/map/mapheights.h
index 67e73bcc4..333e7fac4 100644
--- a/src/resources/map/mapheights.h
+++ b/src/resources/map/mapheights.h
@@ -38,7 +38,7 @@ class MapHeights final
uint8_t getHeight(const int x, const int y) const
{ return x < mWidth && y < mHeight ? mTiles[x + y * mWidth]
- : static_cast<uint8_t>(0U); }
+ : CAST_U8(0U); }
private:
int mWidth;
diff --git a/src/resources/map/maplayer.cpp b/src/resources/map/maplayer.cpp
index bedd0da35..6567b2177 100644
--- a/src/resources/map/maplayer.cpp
+++ b/src/resources/map/maplayer.cpp
@@ -135,7 +135,7 @@ void MapLayer::draw(Graphics *const graphics,
const int py0 = y32 + dy;
- TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
+ TileInfo *tilePtr = &mTiles[CAST_SIZE(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
@@ -235,7 +235,7 @@ void MapLayer::updateSDL(const Graphics *const graphics,
const int yWidth = y * mWidth;
const int py0 = y * mapTileSize + dy;
- TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
+ TileInfo *tilePtr = &mTiles[CAST_SIZE(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
@@ -304,7 +304,7 @@ void MapLayer::updateOGL(Graphics *const graphics,
{
const int yWidth = y * mWidth;
const int py0 = y * mapTileSize + dy;
- TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
+ TileInfo *tilePtr = &mTiles[CAST_SIZE(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
if (!tilePtr->isEnabled)
@@ -509,7 +509,7 @@ void MapLayer::drawFringe(Graphics *const graphics,
const int py0 = y32 + dy;
const int py1 = y32 - scrollY;
- TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
+ TileInfo *tilePtr = &mTiles[CAST_SIZE(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
if (!tilePtr->isEnabled)
@@ -598,7 +598,7 @@ void MapLayer::drawFringe(Graphics *const graphics,
const int py0 = y32 + dy;
- TileInfo *tilePtr = &mTiles[static_cast<size_t>(startX + yWidth)];
+ TileInfo *tilePtr = &mTiles[CAST_SIZE(startX + yWidth)];
for (int x = startX; x < endX; x++, tilePtr++)
{
if (!tilePtr->isEnabled)
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index 40a64217d..ff0fa6a7d 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -159,7 +159,7 @@ int inflateMemory(unsigned char *restrict const in,
return Z_MEM_ERROR;
}
- strm.next_out = out + static_cast<size_t>(bufferSize);
+ strm.next_out = out + CAST_SIZE(bufferSize);
strm.avail_out = bufferSize;
bufferSize *= 2;
}
@@ -564,7 +564,7 @@ inline static void setTile(Map *const map,
break;
if (heights && map->getVersion() >= 2)
{
- heights->setHeight(x, y, static_cast<uint8_t>(
+ heights->setHeight(x, y, CAST_U8(
gid - set->getFirstGid() + 1));
}
else
@@ -644,7 +644,7 @@ bool MapReader::readBase64Layer(const XmlNodePtrConst childNode,
int binLen;
unsigned char *binData = php3_base64_decode(charData,
- static_cast<int>(strlen(reinterpret_cast<char*>(
+ CAST_S32(strlen(reinterpret_cast<char*>(
charData))), &binLen);
delete [] charData;
diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h
index 7d173a99c..350c9b97f 100644
--- a/src/resources/resourcemanager.h
+++ b/src/resources/resourcemanager.h
@@ -229,7 +229,7 @@ class ResourceManager final
static void deleteInstance();
int size() const A_WARN_UNUSED
- { return static_cast<int>(mResources.size()); }
+ { return CAST_S32(mResources.size()); }
typedef std::map<std::string, Resource*> Resources;
typedef Resources::iterator ResourceIterator;
diff --git a/src/resources/sdlimagehelper.cpp b/src/resources/sdlimagehelper.cpp
index e0901f178..e61391d14 100644
--- a/src/resources/sdlimagehelper.cpp
+++ b/src/resources/sdlimagehelper.cpp
@@ -137,7 +137,7 @@ Image *SDLImageHelper::createTextSurface(SDL_Surface *const tmpImage,
const uint8_t a = static_cast<const uint8_t>((v << fmt->Aloss)
+ (v >> (8 - (fmt->Aloss << 1))));
- const uint8_t a2 = static_cast<uint8_t>(
+ const uint8_t a2 = CAST_U8(
static_cast<float>(a) * alpha);
c &= ~fmt->Amask;
@@ -297,8 +297,8 @@ void SDLImageHelper::copySurfaceToImage(const Image *const image,
SDL_SetAlpha(surface, 0, SDL_ALPHA_OPAQUE);
SDL_Rect rect =
{
- static_cast<int16_t>(x), static_cast<int16_t>(y),
- static_cast<uint16_t>(surface->w), static_cast<uint16_t>(surface->h)
+ CAST_S16(x), CAST_S16(y),
+ CAST_U16(surface->w), static_cast<uint16_t>(surface->h)
};
SDL_BlitSurface(surface, nullptr, image->mSDLSurface, &rect);
diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp
index 5210ce626..08d73c2c5 100644
--- a/src/resources/sprite/animatedsprite.cpp
+++ b/src/resources/sprite/animatedsprite.cpp
@@ -214,16 +214,16 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
mFrameTime += time;
- while ((mFrameTime > static_cast<unsigned int>(mFrame->delay) &&
+ while ((mFrameTime > CAST_U32(mFrame->delay) &&
mFrame->delay > 0) ||
(mFrame->type != Frame::ANIMATION &&
mFrame->type != Frame::PAUSE))
{
bool fail(true);
- mFrameTime -= static_cast<unsigned int>(mFrame->delay);
+ mFrameTime -= CAST_U32(mFrame->delay);
mFrameIndex++;
- if (mFrameIndex >= static_cast<unsigned int>(mAnimation->getLength()))
+ if (mFrameIndex >= CAST_U32(mAnimation->getLength()))
mFrameIndex = 0;
mFrame = &mAnimation->mFrames[mFrameIndex];
@@ -249,8 +249,8 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
if (frame->type == Frame::LABEL &&
mFrame->nextAction == frame->nextAction)
{
- mFrameIndex = static_cast<unsigned int>(i);
- if (mFrameIndex >= static_cast<unsigned int>(
+ mFrameIndex = CAST_U32(i);
+ if (mFrameIndex >= CAST_U32(
mAnimation->getLength()))
{
mFrameIndex = 0;
@@ -293,7 +293,7 @@ bool AnimatedSprite::updateCurrentAnimation(const unsigned int time) restrict2
else
{
if (mFrame->rand == 100 || mFrameIndex
- >= static_cast<unsigned int>(mAnimation->getLength()))
+ >= CAST_U32(mAnimation->getLength()))
{
fail = false;
}
@@ -376,7 +376,7 @@ bool AnimatedSprite::setSpriteDirection(const SpriteDirection::Type direction)
unsigned int AnimatedSprite::getFrameCount() const restrict2
{
if (mAnimation)
- return static_cast<unsigned int>(mAnimation->getLength());
+ return CAST_U32(mAnimation->getLength());
else
return 0;
}
diff --git a/src/resources/subimage.cpp b/src/resources/subimage.cpp
index 33177909b..af579e4ec 100644
--- a/src/resources/subimage.cpp
+++ b/src/resources/subimage.cpp
@@ -60,10 +60,10 @@ SubImage::SubImage(Image *const parent,
}
// Set up the rectangle.
- mBounds.x = static_cast<int16_t>(x);
- mBounds.y = static_cast<int16_t>(y);
- mBounds.w = static_cast<uint16_t>(width);
- mBounds.h = static_cast<uint16_t>(height);
+ mBounds.x = CAST_S16(x);
+ mBounds.y = CAST_S16(y);
+ mBounds.w = CAST_U16(width);
+ mBounds.h = CAST_U16(height);
if (mParent)
{
mInternalBounds.x = mParent->mBounds.x;
@@ -114,10 +114,10 @@ SubImage::SubImage(Image *const parent,
}
// Set up the rectangle.
- mBounds.x = static_cast<int16_t>(x);
- mBounds.y = static_cast<int16_t>(y);
- mBounds.w = static_cast<uint16_t>(width);
- mBounds.h = static_cast<uint16_t>(height);
+ mBounds.x = CAST_S16(x);
+ mBounds.y = CAST_S16(y);
+ mBounds.w = CAST_U16(width);
+ mBounds.h = CAST_U16(height);
if (mParent)
{
mInternalBounds.x = mParent->mBounds.x;
@@ -149,10 +149,10 @@ SubImage::SubImage(Image *const parent,
mParent->incRef();
// Set up the rectangle.
- mBounds.x = static_cast<int16_t>(x);
- mBounds.y = static_cast<int16_t>(y);
- mBounds.w = static_cast<uint16_t>(width);
- mBounds.h = static_cast<uint16_t>(height);
+ mBounds.x = CAST_S16(x);
+ mBounds.y = CAST_S16(y);
+ mBounds.w = CAST_U16(width);
+ mBounds.h = CAST_U16(height);
if (mParent)
{
mInternalBounds.x = mParent->mBounds.x;
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index f6cb32e1b..e7a1b8253 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -141,8 +141,8 @@ std::string Wallpaper::getWallpaper(const int width, const int height)
{
// Return randomly a wallpaper between vector[0] and
// vector[vector.size() - 1]
- srand(static_cast<unsigned>(time(nullptr)));
- return wallPaperVector[static_cast<int>(static_cast<double>(
+ srand(CAST_U32(time(nullptr)));
+ return wallPaperVector[CAST_S32(static_cast<double>(
wallPaperVector.size()) * rand() / (RAND_MAX + 1.0))];
}