summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-11-13 04:57:16 +0300
committerAndrei Karas <akaras@inbox.ru>2011-11-13 04:57:16 +0300
commit4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80 (patch)
treec1edb8d8b368fdd43cd8639e6044b0f4e8dde70a /src/resources
parentece00592ecd93f7a96db0ca82589d00846e2f938 (diff)
parentd471e99fd38ac589a8a9e8e8677b9f577f0cc5c6 (diff)
downloadplus-4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80.tar.gz
plus-4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80.tar.bz2
plus-4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80.tar.xz
plus-4d453108f45f9fb2ff4f5715cc1b3ddd63d36a80.zip
Merge branch 'master' into strippedstripped1.1.11.12
Conflicts: data/fonts/mplus-1p-bold.ttf data/fonts/mplus-1p-regular.ttf src/guichan/basiccontainer.cpp src/guichan/focushandler.cpp src/guichan/graphics.cpp src/guichan/gui.cpp src/guichan/image.cpp src/guichan/include/guichan/widgets/checkbox.hpp src/guichan/include/guichan/widgets/dropdown.hpp src/guichan/sdl/sdlgraphics.cpp src/guichan/sdl/sdlimage.cpp src/guichan/widget.cpp src/guichan/widgets/dropdown.cpp src/guichan/widgets/icon.cpp src/guichan/widgets/imagebutton.cpp src/guichan/widgets/listbox.cpp src/guichan/widgets/scrollarea.cpp src/guichan/widgets/tab.cpp src/guichan/widgets/tabbedarea.cpp src/guichan/widgets/textbox.cpp src/guichan/widgets/window.cpp
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/action.cpp2
-rw-r--r--src/resources/ambientlayer.cpp2
-rw-r--r--src/resources/animation.cpp10
-rw-r--r--src/resources/beinginfo.cpp6
-rw-r--r--src/resources/colordb.cpp2
-rw-r--r--src/resources/dye.cpp4
-rw-r--r--src/resources/emotedb.cpp6
-rw-r--r--src/resources/image.cpp68
-rw-r--r--src/resources/image.h3
-rw-r--r--src/resources/imageloader.cpp9
-rw-r--r--src/resources/imageset.cpp2
-rw-r--r--src/resources/imagewriter.cpp9
-rw-r--r--src/resources/itemdb.cpp2
-rw-r--r--src/resources/iteminfo.cpp14
-rw-r--r--src/resources/mapreader.cpp36
-rw-r--r--src/resources/music.cpp2
-rw-r--r--src/resources/resourcemanager.cpp50
-rw-r--r--src/resources/soundeffect.cpp4
-rw-r--r--src/resources/specialdb.cpp4
-rw-r--r--src/resources/spritedef.cpp8
-rw-r--r--src/resources/wallpaper.cpp4
21 files changed, 125 insertions, 122 deletions
diff --git a/src/resources/action.cpp b/src/resources/action.cpp
index a95ebc5e3..c2af3ff9b 100644
--- a/src/resources/action.cpp
+++ b/src/resources/action.cpp
@@ -61,7 +61,7 @@ Animation *Action::getAnimation(int direction) const
i = mAnimations.begin();
}
- return (i == mAnimations.end()) ? NULL : i->second;
+ return (i == mAnimations.end()) ? nullptr : i->second;
}
void Action::setAnimation(int direction, Animation *animation)
diff --git a/src/resources/ambientlayer.cpp b/src/resources/ambientlayer.cpp
index 319bc5b8c..2ad25dcd0 100644
--- a/src/resources/ambientlayer.cpp
+++ b/src/resources/ambientlayer.cpp
@@ -68,7 +68,7 @@ AmbientLayer::~AmbientLayer()
if (mImage)
{
mImage->decRef();
- mImage = 0;
+ mImage = nullptr;
}
}
diff --git a/src/resources/animation.cpp b/src/resources/animation.cpp
index 32b57b3b1..1f3336a8b 100644
--- a/src/resources/animation.cpp
+++ b/src/resources/animation.cpp
@@ -44,28 +44,28 @@ void Animation::addFrame(Image *image, int delay, int offsetX, int offsetY,
void Animation::addTerminator(int rand)
{
- addFrame(NULL, 0, 0, 0, rand);
+ addFrame(nullptr, 0, 0, 0, rand);
}
bool Animation::isTerminator(const Frame &candidate)
{
- return (candidate.image == NULL && candidate.type == Frame::ANIMATION);
+ return (!candidate.image && candidate.type == Frame::ANIMATION);
}
void Animation::addJump(std::string name, int rand)
{
- Frame frame = { 0, 0, 0, 0, rand, Frame::JUMP, name };
+ Frame frame = { nullptr, 0, 0, 0, rand, Frame::JUMP, name };
mFrames.push_back(frame);
}
void Animation::addLabel(std::string name)
{
- Frame frame = { 0, 0, 0, 0, 100, Frame::LABEL, name };
+ Frame frame = { nullptr, 0, 0, 0, 100, Frame::LABEL, name };
mFrames.push_back(frame);
}
void Animation::addGoto(std::string name, int rand)
{
- Frame frame = { 0, 0, 0, 0, rand, Frame::GOTO, name };
+ Frame frame = { nullptr, 0, 0, 0, rand, Frame::GOTO, name };
mFrames.push_back(frame);
}
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index 4aa7515b1..0b2aaa8fa 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -29,7 +29,7 @@
#include "debug.h"
-BeingInfo *BeingInfo::unknown = 0;
+BeingInfo *BeingInfo::unknown = nullptr;
Attack *BeingInfo::empty = new Attack(SpriteAction::ATTACK, "", "");
BeingInfo::BeingInfo():
@@ -121,7 +121,7 @@ void BeingInfo::addAttack(int id, std::string action,
void BeingInfo::clear()
{
delete unknown;
- unknown = 0;
+ unknown = nullptr;
delete empty;
- empty = 0;
+ empty = nullptr;
}
diff --git a/src/resources/colordb.cpp b/src/resources/colordb.cpp
index ed8c934dc..225abef91 100644
--- a/src/resources/colordb.cpp
+++ b/src/resources/colordb.cpp
@@ -175,5 +175,5 @@ std::map <int, ColorDB::ItemColor> *ColorDB::getColorsList(std::string name)
if (it != mColorLists.end())
return &it->second;
- return 0;
+ return nullptr;
}
diff --git a/src/resources/dye.cpp b/src/resources/dye.cpp
index a782b6ec1..29b1c864e 100644
--- a/src/resources/dye.cpp
+++ b/src/resources/dye.cpp
@@ -208,7 +208,7 @@ void DyePalette::getColor(double intensity, int color[3]) const
Dye::Dye(const std::string &description)
{
for (int i = 0; i < 7; ++i)
- mDyePalettes[i] = 0;
+ mDyePalettes[i] = nullptr;
if (description.empty())
return;
@@ -255,7 +255,7 @@ Dye::~Dye()
for (int i = 0; i < 7; ++i)
{
delete mDyePalettes[i];
- mDyePalettes[i] = 0;
+ mDyePalettes[i] = nullptr;
}
}
diff --git a/src/resources/emotedb.cpp b/src/resources/emotedb.cpp
index b7f7d7901..c456c49e4 100644
--- a/src/resources/emotedb.cpp
+++ b/src/resources/emotedb.cpp
@@ -199,7 +199,7 @@ const EmoteInfo *EmoteDB::get(int id, bool allowNull)
if (i == mEmoteInfos.end())
{
if (allowNull)
- return NULL;
+ return nullptr;
logger->log("EmoteDB: Warning, unknown emote ID %d requested", id);
return &mUnknown;
}
@@ -213,7 +213,7 @@ const AnimatedSprite *EmoteDB::getAnimation(int id, bool allowNull)
{
const EmoteInfo *info = get(id, allowNull);
if (!info)
- return NULL;
+ return nullptr;
return info->sprites.front()->sprite;
}
@@ -222,7 +222,7 @@ const EmoteSprite *EmoteDB::getSprite(int id, bool allowNull)
{
const EmoteInfo *info = get(id, allowNull);
if (!info)
- return NULL;
+ return nullptr;
return info->sprites.front();
}
diff --git a/src/resources/image.cpp b/src/resources/image.cpp
index 8f5ee1d2d..df07c16a2 100644
--- a/src/resources/image.cpp
+++ b/src/resources/image.cpp
@@ -87,8 +87,8 @@ Image::Image(GLuint glimage, int width, int height,
int texWidth, int texHeight):
mAlpha(1.0f),
mHasAlphaChannel(true),
- mSDLSurface(0),
- mAlphaChannel(0),
+ mSDLSurface(nullptr),
+ mAlphaChannel(nullptr),
mUseAlphaCache(false),
mIsAlphaVisible(true),
mIsAlphaCalculated(false),
@@ -128,7 +128,7 @@ Resource *Image::load(void *buffer, unsigned bufferSize)
if (!tmpImage)
{
logger->log("Error, image load failed: %s", IMG_GetError());
- return NULL;
+ return nullptr;
}
Image *image = load(tmpImage);
@@ -145,11 +145,11 @@ Resource *Image::load(void *buffer, unsigned bufferSize, Dye const &dye)
if (!tmpImage)
{
logger->log("Error, image load failed: %s", IMG_GetError());
- return NULL;
+ return nullptr;
}
SDL_PixelFormat rgba;
- rgba.palette = NULL;
+ rgba.palette = nullptr;
rgba.BitsPerPixel = 32;
rgba.BytesPerPixel = 4;
rgba.Rmask = 0xFF000000; rgba.Rloss = 0; rgba.Rshift = 24;
@@ -195,7 +195,7 @@ Image *Image::load(SDL_Surface *tmpImage)
Image *Image::createTextSurface(SDL_Surface *tmpImage, float alpha)
{
if (!tmpImage)
- return NULL;
+ return nullptr;
Image *img;
#ifdef USE_OPENGL
@@ -251,14 +251,14 @@ Image *Image::createTextSurface(SDL_Surface *tmpImage, float alpha)
// We also delete the alpha channel since
// it's not used.
delete[] alphaChannel;
- alphaChannel = 0;
+ alphaChannel = nullptr;
}
if (!image)
{
logger->log1("Error: Image convert failed.");
delete[] alphaChannel;
- return 0;
+ return nullptr;
}
if (converted)
@@ -279,7 +279,7 @@ void Image::SDLCleanCache()
{
if (mSDLSurface != i->second)
resman->scheduleDelete(i->second);
- i->second = 0;
+ i->second = nullptr;
}
mAlphaCache.clear();
}
@@ -293,10 +293,10 @@ void Image::unload()
SDLCleanCache();
// Free the image surface.
SDL_FreeSurface(mSDLSurface);
- mSDLSurface = NULL;
+ mSDLSurface = nullptr;
delete[] mAlphaChannel;
- mAlphaChannel = NULL;
+ mAlphaChannel = nullptr;
}
#ifdef USE_OPENGL
@@ -339,7 +339,7 @@ SDL_Surface *Image::getByAlpha(float alpha)
std::map<float, SDL_Surface*>::const_iterator it = mAlphaCache.find(alpha);
if (it != mAlphaCache.end())
return (*it).second;
- return 0;
+ return nullptr;
}
void Image::setAlpha(float alpha)
@@ -451,7 +451,7 @@ void Image::setAlpha(float alpha)
Image* Image::SDLmerge(Image *image, int x, int y)
{
if (!mSDLSurface || !image || !image->mSDLSurface)
- return NULL;
+ return nullptr;
SDL_Surface* surface = new SDL_Surface(*(image->mSDLSurface));
@@ -543,14 +543,14 @@ Image* Image::SDLgetScaledImage(int width, int height)
{
// No scaling on incorrect new values.
if (width == 0 || height == 0)
- return NULL;
+ return nullptr;
// No scaling when there is ... no different given size ...
if (width == getWidth() && height == getHeight())
- return NULL;
+ return nullptr;
- Image* scaledImage = NULL;
- SDL_Surface* scaledSurface = NULL;
+ Image* scaledImage = nullptr;
+ SDL_Surface* scaledSurface = nullptr;
if (mSDLSurface)
{
@@ -573,9 +573,9 @@ Image* Image::SDLgetScaledImage(int width, int height)
SDL_Surface* Image::convertTo32Bit(SDL_Surface* tmpImage)
{
if (!tmpImage)
- return NULL;
+ return nullptr;
SDL_PixelFormat RGBAFormat;
- RGBAFormat.palette = 0;
+ RGBAFormat.palette = nullptr;
RGBAFormat.colorkey = 0;
RGBAFormat.alpha = 0;
RGBAFormat.BitsPerPixel = 32;
@@ -613,7 +613,7 @@ SDL_Surface* Image::convertTo32Bit(SDL_Surface* tmpImage)
SDL_Surface* Image::SDLDuplicateSurface(SDL_Surface* tmpImage)
{
if (!tmpImage || !tmpImage->format)
- return NULL;
+ return nullptr;
return SDL_ConvertSurface(tmpImage, tmpImage->format, SDL_SWSURFACE);
}
@@ -621,7 +621,7 @@ SDL_Surface* Image::SDLDuplicateSurface(SDL_Surface* tmpImage)
Image *Image::_SDLload(SDL_Surface *tmpImage)
{
if (!tmpImage)
- return NULL;
+ return nullptr;
bool hasAlpha = false;
bool converted = false;
@@ -636,14 +636,14 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
if (!tmpImage)
{
delete[] alphaChannel;
- return NULL;
+ return nullptr;
}
converted = true;
}
const int sz = tmpImage->w * tmpImage->h;
// Figure out whether the image uses its alpha layer
- if (tmpImage->format->palette == NULL)
+ if (!tmpImage->format->palette)
{
const SDL_PixelFormat * const fmt = tmpImage->format;
if (fmt->Amask)
@@ -692,14 +692,14 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
// We also delete the alpha channel since
// it's not used.
delete[] alphaChannel;
- alphaChannel = 0;
+ alphaChannel = nullptr;
}
if (!image)
{
logger->log1("Error: Image convert failed.");
delete[] alphaChannel;
- return 0;
+ return nullptr;
}
if (converted)
@@ -713,7 +713,7 @@ Image *Image::_SDLload(SDL_Surface *tmpImage)
Image *Image::_GLload(SDL_Surface *tmpImage)
{
if (!tmpImage)
- return NULL;
+ return nullptr;
// Flush current error flag.
glGetError();
@@ -753,10 +753,10 @@ Image *Image::_GLload(SDL_Surface *tmpImage)
if (!tmpImage)
{
logger->log("Error, image convert failed: out of memory");
- return NULL;
+ return nullptr;
}
- SDL_BlitSurface(oldImage, NULL, tmpImage, NULL);
+ SDL_BlitSurface(oldImage, nullptr, tmpImage, nullptr);
GLuint texture;
glGenTextures(1, &texture);
@@ -811,7 +811,7 @@ Image *Image::_GLload(SDL_Surface *tmpImage)
break;
}
logger->log("Error: Image GL import failed: %s", errmsg.c_str());
- return NULL;
+ return nullptr;
}
return new Image(texture, width, height, realWidth, realHeight);
@@ -880,7 +880,7 @@ SubImage::SubImage(Image *parent, SDL_Surface *image,
{
mHasAlphaChannel = false;
mIsAlphaVisible = false;
- mAlphaChannel = 0;
+ mAlphaChannel = nullptr;
}
// Set up the rectangle.
@@ -921,16 +921,16 @@ SubImage::SubImage(Image *parent, GLuint image,
SubImage::~SubImage()
{
// Avoid destruction of the image
- mSDLSurface = 0;
+ mSDLSurface = nullptr;
// Avoid possible destruction of its alpha channel
- mAlphaChannel = 0;
+ mAlphaChannel = nullptr;
#ifdef USE_OPENGL
mGLImage = 0;
#endif
if (mParent)
{
mParent->decRef();
- mParent = 0;
+ mParent = nullptr;
}
}
@@ -939,5 +939,5 @@ Image *SubImage::getSubImage(int x, int y, int w, int h)
if (mParent)
return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
else
- return NULL;
+ return nullptr;
}
diff --git a/src/resources/image.h b/src/resources/image.h
index 941b34465..333dc63f9 100644
--- a/src/resources/image.h
+++ b/src/resources/image.h
@@ -23,6 +23,7 @@
#ifndef IMAGE_H
#define IMAGE_H
+#include "localconsts.h"
#include "main.h"
#include "resources/resource.h"
@@ -252,7 +253,7 @@ class Image : public Resource
/** SDL Constructor */
Image(SDL_Surface *image, bool hasAlphaChannel = false,
- Uint8 *alphaChannel = NULL);
+ Uint8 *alphaChannel = nullptr);
/** SDL_Surface to SDL_Surface Image loader */
static Image *_SDLload(SDL_Surface *tmpImage);
diff --git a/src/resources/imageloader.cpp b/src/resources/imageloader.cpp
index 72a839573..a8563c679 100644
--- a/src/resources/imageloader.cpp
+++ b/src/resources/imageloader.cpp
@@ -36,7 +36,8 @@
#endif
ProxyImage::ProxyImage(SDL_Surface *s):
- mImage(NULL), mSDLImage(s)
+ mImage(nullptr),
+ mSDLImage(s)
{
}
@@ -50,12 +51,12 @@ void ProxyImage::free()
if (mSDLImage)
{
SDL_FreeSurface(mSDLImage);
- mSDLImage = 0;
+ mSDLImage = nullptr;
}
else
{
delete mImage;
- mImage = 0;
+ mImage = nullptr;
}
}
@@ -103,7 +104,7 @@ void ProxyImage::convertToDisplayFormat()
SDL_MapRGB(mSDLImage->format, 255, 0, 255));
mImage = ::Image::load(mSDLImage);
SDL_FreeSurface(mSDLImage);
- mSDLImage = NULL;
+ mSDLImage = nullptr;
}
gcn::Image *ImageLoader::load(const std::string &filename, bool convert)
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index 5cf3e7d82..09b57be28 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -62,7 +62,7 @@ Image* ImageSet::get(size_type i) const
{
logger->log("Warning: No sprite %d in this image set",
static_cast<int>(i));
- return NULL;
+ return nullptr;
}
else
{
diff --git a/src/resources/imagewriter.cpp b/src/resources/imagewriter.cpp
index e6f3c8c27..a3a35cfd1 100644
--- a/src/resources/imagewriter.cpp
+++ b/src/resources/imagewriter.cpp
@@ -50,7 +50,8 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
if (SDL_MUSTLOCK(surface))
SDL_LockSurface(surface);
- png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING, 0, 0, 0);
+ png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,
+ nullptr, nullptr, nullptr);
if (!png_ptr)
{
logger->log1("Had trouble creating png_structp");
@@ -60,14 +61,14 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
info_ptr = png_create_info_struct(png_ptr);
if (!info_ptr)
{
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(NULL));
+ png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
logger->log1("Could not create png_info");
return false;
}
if (setjmp(png_jmpbuf(png_ptr)))
{
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(NULL));
+ png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
logger->log("problem writing to %s", filename.c_str());
return false;
}
@@ -113,7 +114,7 @@ bool ImageWriter::writePNG(SDL_Surface *surface, const std::string &filename)
delete [] row_pointers;
- png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(NULL));
+ png_destroy_write_struct(&png_ptr, static_cast<png_infopp>(nullptr));
if (SDL_MUSTLOCK(surface))
SDL_UnlockSurface(surface);
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index 74474e067..3e53dd6e7 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -421,7 +421,7 @@ void ItemDB::unload()
logger->log1("Unloading item database...");
delete mUnknown;
- mUnknown = 0;
+ mUnknown = nullptr;
delete_all(mItemInfos);
mItemInfos.clear();
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 5b07724a1..dfcff3f76 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -77,14 +77,14 @@ ItemInfo::ItemInfo() :
mAttackAction(SpriteAction::INVALID),
mAttackRange(0),
mMissileParticle(""),
- mColors(0),
+ mColors(nullptr),
mColorList(""),
mHitEffectId(0),
mCriticalHitEffectId(0)
{
for (int f = 0; f < 9; f ++)
{
- mSpriteToItemReplaceMap[f] = 0;
+ mSpriteToItemReplaceMap[f] = nullptr;
mDrawBefore[f] = -1;
mDrawAfter[f] = -1;
mDrawPriority[f] = 0;
@@ -96,7 +96,7 @@ ItemInfo::~ItemInfo()
delete_all(mSpriteToItemReplaceList);
mSpriteToItemReplaceList.clear();
for (int f = 0; f < 9; f ++)
- mSpriteToItemReplaceMap[f] = 0;
+ mSpriteToItemReplaceMap[f] = nullptr;
}
const std::string &ItemInfo::getSprite(Gender gender) const
@@ -145,7 +145,7 @@ const std::string &ItemInfo::getSound(EquipmentSoundEvent event) const
std::map<int, int> *ItemInfo::addReplaceSprite(int sprite, int direction)
{
if (direction < 0 || direction >= 9)
- return 0;
+ return nullptr;
SpriteToItemMap *spMap = mSpriteToItemReplaceMap[direction];
@@ -170,7 +170,7 @@ void ItemInfo::setColorsList(std::string name)
{
if (name.empty())
{
- mColors = 0;
+ mColors = nullptr;
mColorList = "";
}
else
@@ -231,7 +231,7 @@ const std::string ItemInfo::replaceColors(std::string str,
SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(int direction) const
{
if (direction < 0 || direction >= 9)
- return 0;
+ return nullptr;
SpriteToItemMap *spMap = mSpriteToItemReplaceMap[direction];
if (spMap)
@@ -242,7 +242,7 @@ SpriteToItemMap *ItemInfo::getSpriteToItemReplaceMap(int direction) const
if (direction == DIRECTION_DOWNLEFT || direction == DIRECTION_DOWNRIGHT)
return mSpriteToItemReplaceMap[DIRECTION_DOWN];
- return 0;
+ return nullptr;
}
void ItemInfo::setSpriteOrder(int *ptr, int direction, int n, int def)
diff --git a/src/resources/mapreader.cpp b/src/resources/mapreader.cpp
index f702864ea..68d39f0ae 100644
--- a/src/resources/mapreader.cpp
+++ b/src/resources/mapreader.cpp
@@ -102,7 +102,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
do
{
- if (strm.next_out == NULL)
+ if (!strm.next_out)
{
inflateEnd(&strm);
return Z_MEM_ERROR;
@@ -128,7 +128,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
{
out = static_cast<unsigned char*>(realloc(out, bufferSize * 2));
- if (out == NULL)
+ if (!out)
{
inflateEnd(&strm);
return Z_MEM_ERROR;
@@ -153,7 +153,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
unsigned int outLength = 0;
int ret = inflateMemory(in, inLength, out, outLength);
- if (ret != Z_OK || out == NULL)
+ if (ret != Z_OK || !out)
{
if (ret == Z_MEM_ERROR)
{
@@ -173,7 +173,7 @@ int inflateMemory(unsigned char *in, unsigned int inLength,
}
free(out);
- out = NULL;
+ out = nullptr;
outLength = 0;
}
@@ -188,12 +188,12 @@ Map *MapReader::readMap(const std::string &filename,
ResourceManager *resman = ResourceManager::getInstance();
int fileSize;
void *buffer = resman->loadFile(realFilename, fileSize);
- Map *map = NULL;
+ Map *map = nullptr;
- if (buffer == NULL)
+ if (!buffer)
{
logger->log("Map file not found (%s)", realFilename.c_str());
- return NULL;
+ return nullptr;
}
unsigned char *inflated;
@@ -207,11 +207,11 @@ Map *MapReader::readMap(const std::string &filename,
fileSize, inflated);
free(buffer);
- if (inflated == NULL)
+ if (!inflated)
{
logger->log("Could not decompress map file (%s)",
realFilename.c_str());
- return NULL;
+ return nullptr;
}
}
else
@@ -251,7 +251,7 @@ Map *MapReader::readMap(const std::string &filename,
Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
{
if (!node)
- return 0;
+ return nullptr;
// Take the filename off the path
const std::string pathDir = path.substr(0, path.rfind("/") + 1);
@@ -270,7 +270,7 @@ Map *MapReader::readMap(xmlNodePtr node, const std::string &path)
logger->log("MapReader: Warning: "
"Unitialized tile width or height value for map: %s",
path.c_str());
- return 0;
+ return nullptr;
}
Map *map = new Map(w, h, tilew, tileh);
@@ -405,7 +405,7 @@ inline static void setTile(Map *map, MapLayer *layer, int x, int y, int gid)
if (layer)
{
// Set regular tile on a layer
- Image * const img = set ? set->get(gid - set->getFirstGid()) : 0;
+ Image * const img = set ? set->get(gid - set->getFirstGid()) : nullptr;
layer->setTile(x, y, img);
}
else
@@ -458,7 +458,7 @@ void MapReader::readLayer(xmlNodePtr node, Map *map)
map->indexTilesets();
- MapLayer *layer = 0;
+ MapLayer *layer = nullptr;
if (!isCollisionLayer)
{
@@ -651,13 +651,13 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
Map *map)
{
if (!map)
- return NULL;
+ return nullptr;
int firstGid = XML::getProperty(node, "firstgid", 0);
int margin = XML::getProperty(node, "margin", 0);
int spacing = XML::getProperty(node, "spacing", 0);
- XML::Document* doc = NULL;
- Tileset *set = NULL;
+ XML::Document* doc = nullptr;
+ Tileset *set = nullptr;
std::string pathDir(path);
if (xmlHasProp(node, BAD_CAST "source"))
@@ -668,7 +668,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
doc = new XML::Document(filename);
node = doc->rootNode();
if (!node)
- return 0;
+ return nullptr;
// Reset path to be realtive to the tsx file
pathDir = filename.substr(0, filename.rfind("/") + 1);
@@ -760,7 +760,7 @@ Tileset *MapReader::readTileset(xmlNodePtr node, const std::string &path,
else
{
delete ani;
- ani = 0;
+ ani = nullptr;
}
}
}
diff --git a/src/resources/music.cpp b/src/resources/music.cpp
index 5ae9a2202..099d030b0 100644
--- a/src/resources/music.cpp
+++ b/src/resources/music.cpp
@@ -54,7 +54,7 @@ Resource *Music::load(void *buffer, unsigned bufferSize)
else
{
logger->log("Error, failed to load music: %s", Mix_GetError());
- return NULL;
+ return nullptr;
}
}
diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp
index fcba17812..a99ca622e 100644
--- a/src/resources/resourcemanager.cpp
+++ b/src/resources/resourcemanager.cpp
@@ -48,7 +48,7 @@
#include "debug.h"
-ResourceManager *ResourceManager::instance = NULL;
+ResourceManager *ResourceManager::instance = nullptr;
ResourceManager::ResourceManager() :
mOldestOrphan(0),
@@ -94,7 +94,7 @@ ResourceManager::~ResourceManager()
continue;
}
#endif
- if (dynamic_cast<SpriteDef*>(iter->second) != 0)
+ if (dynamic_cast<SpriteDef*>(iter->second))
{
cleanUp(iter->second);
ResourceIterator toErase = iter;
@@ -118,7 +118,7 @@ ResourceManager::~ResourceManager()
continue;
}
#endif
- if (dynamic_cast<ImageSet*>(iter->second) != 0)
+ if (dynamic_cast<ImageSet*>(iter->second))
{
cleanUp(iter->second);
ResourceIterator toErase = iter;
@@ -177,7 +177,7 @@ void ResourceManager::cleanUp(Resource *res)
void ResourceManager::cleanOrphans(bool always)
{
timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
// Delete orphaned resources after 30 seconds.
time_t oldest = tv.tv_sec, threshold = oldest - 30;
@@ -324,7 +324,7 @@ std::string ResourceManager::getPath(const std::string &file)
const char* tmp = PHYSFS_getRealDir(file.c_str());
std::string path;
- // if the file is not in the search path, then its NULL
+ // if the file is not in the search path, then its nullptr
if (tmp)
{
path = std::string(tmp) + "/" + file;
@@ -388,7 +388,7 @@ Resource *ResourceManager::get(const std::string &idPath, generator fun,
logger->log("Error loaging image: " + idPath);
}
- // Returns NULL if the object could not be created.
+ // Returns nullptr if the object could not be created.
return resource;
}
@@ -400,14 +400,14 @@ struct ResourceLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
ResourceLoader *l = static_cast< ResourceLoader * >(v);
int fileSize;
if (!l->manager)
- return NULL;
+ return nullptr;
void *buffer = l->manager->loadFile(l->path, fileSize);
if (!buffer)
- return NULL;
+ return nullptr;
Resource *res = l->fun(buffer, fileSize);
free(buffer);
return res;
@@ -437,15 +437,15 @@ struct DyedImageLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
DyedImageLoader *l = static_cast< DyedImageLoader * >(v);
if (!l->manager)
- return NULL;
+ return nullptr;
std::string path = l->path;
std::string::size_type p = path.find('|');
- Dye *d = NULL;
+ Dye *d = nullptr;
if (p != std::string::npos)
{
d = new Dye(path.substr(p + 1));
@@ -495,15 +495,15 @@ struct ImageSetLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
ImageSetLoader *l = static_cast< ImageSetLoader * >(v);
if (!l->manager)
- return NULL;
+ return nullptr;
Image *img = l->manager->getImage(l->path);
if (!img)
- return NULL;
+ return nullptr;
ImageSet *res = new ImageSet(img, l->w, l->h);
img->decRef();
return res;
@@ -526,7 +526,7 @@ struct SpriteDefLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
SpriteDefLoader *l = static_cast< SpriteDefLoader * >(v);
return SpriteDef::load(l->path, l->variant);
@@ -552,7 +552,7 @@ void ResourceManager::release(Resource *res)
assert(resIter != mResources.end() && resIter->second == res);
timeval tv;
- gettimeofday(&tv, NULL);
+ gettimeofday(&tv, nullptr);
time_t timestamp = tv.tv_sec;
res->mTimeStamp = timestamp;
@@ -574,7 +574,7 @@ ResourceManager *ResourceManager::getInstance()
void ResourceManager::deleteInstance()
{
delete instance;
- instance = 0;
+ instance = nullptr;
}
void *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
@@ -583,11 +583,11 @@ void *ResourceManager::loadFile(const std::string &fileName, int &fileSize)
PHYSFS_file *file = PHYSFS_openRead(fileName.c_str());
// If the handler is an invalid pointer indicate failure
- if (file == NULL)
+ if (!file)
{
logger->log("Warning: Failed to load %s: %s",
fileName.c_str(), PHYSFS_getLastError());
- return NULL;
+ return nullptr;
}
// Log the real dir of the file
@@ -698,7 +698,7 @@ SDL_Surface *ResourceManager::loadSDLSurface(const std::string &filename)
{
int fileSize;
void *buffer = loadFile(filename, fileSize);
- SDL_Surface *tmp = NULL;
+ SDL_Surface *tmp = nullptr;
if (buffer)
{
@@ -734,13 +734,13 @@ struct RescaledLoader
static Resource *load(void *v)
{
if (!v)
- return NULL;
+ return nullptr;
RescaledLoader *l = static_cast< RescaledLoader * >(v);
if (!l->manager)
- return NULL;
+ return nullptr;
Image *rescaled = l->image->SDLgetScaledImage(l->width, l->height);
if (!rescaled)
- return NULL;
+ return nullptr;
return rescaled;
}
};
@@ -748,7 +748,7 @@ struct RescaledLoader
Image *ResourceManager::getRescaled(Image *image, int width, int height)
{
if (!image)
- return 0;
+ return nullptr;
std::string idPath = image->getIdPath() + strprintf(
"_rescaled%dx%d", width, height);
diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp
index e8e5d3dbb..a8da8dd80 100644
--- a/src/resources/soundeffect.cpp
+++ b/src/resources/soundeffect.cpp
@@ -34,7 +34,7 @@ SoundEffect::~SoundEffect()
Resource *SoundEffect::load(void *buffer, unsigned bufferSize)
{
if (!buffer)
- return NULL;
+ return nullptr;
// Load the raw file data from the buffer in an RWops structure
SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize);
@@ -49,7 +49,7 @@ Resource *SoundEffect::load(void *buffer, unsigned bufferSize)
else
{
logger->log("Error, failed to load sound effect: %s", Mix_GetError());
- return NULL;
+ return nullptr;
}
}
diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp
index 2463da06a..51ba4bc74 100644
--- a/src/resources/specialdb.cpp
+++ b/src/resources/specialdb.cpp
@@ -126,9 +126,9 @@ SpecialInfo *SpecialDB::get(int id)
SpecialInfos::const_iterator i = mSpecialInfos.find(id);
if (i == mSpecialInfos.end())
- return NULL;
+ return nullptr;
else
return i->second;
- return NULL;
+ return nullptr;
}
diff --git a/src/resources/spritedef.cpp b/src/resources/spritedef.cpp
index 2e32f6c5f..3e2aac785 100644
--- a/src/resources/spritedef.cpp
+++ b/src/resources/spritedef.cpp
@@ -39,7 +39,7 @@
#include "debug.h"
-SpriteReference *SpriteReference::Empty = 0;
+SpriteReference *SpriteReference::Empty = nullptr;
Action *SpriteDef::getAction(std::string action) const
{
@@ -48,7 +48,7 @@ Action *SpriteDef::getAction(std::string action) const
if (i == mActions.end())
{
logger->log("Warning: no action \"%s\" defined!", action.c_str());
- return NULL;
+ return nullptr;
}
return i->second;
@@ -73,7 +73,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile, int variant)
if (animationFile != errorFile)
return load(errorFile, 0);
else
- return NULL;
+ return nullptr;
}
SpriteDef *def = new SpriteDef;
@@ -360,7 +360,7 @@ SpriteDef::~SpriteDef()
if (i->second)
{
i->second->decRef();
- i->second = 0;
+ i->second = nullptr;
}
}
}
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 5cfec3b84..c8cd5ad60 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -94,7 +94,7 @@ void Wallpaper::loadWallpapers()
char **imgs = PHYSFS_enumerateFiles(wallpaperPath.c_str());
- for (char **i = imgs; *i != NULL; i++)
+ for (char **i = imgs; *i; i++)
{
int width;
int height;
@@ -157,7 +157,7 @@ std::string Wallpaper::getWallpaper(int width, int height)
{
// Return randomly a wallpaper between vector[0] and
// vector[vector.size() - 1]
- srand(static_cast<unsigned>(time(0)));
+ srand(static_cast<unsigned>(time(nullptr)));
return wallPaperVector[int(static_cast<double>(
wallPaperVector.size()) * rand() / (RAND_MAX + 1.0))];
}