diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-11-07 19:34:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-11-07 19:34:52 +0300 |
commit | 9e83411f7e4147d09af5a5006888dcc187ea0ef8 (patch) | |
tree | c084bdf8afabc6220779645dcb5dbf71af6a151f /src/resources | |
parent | bc7d91cc0c9c0f6dcad01d612932c6899afb5514 (diff) | |
download | mv-9e83411f7e4147d09af5a5006888dcc187ea0ef8.tar.gz mv-9e83411f7e4147d09af5a5006888dcc187ea0ef8.tar.bz2 mv-9e83411f7e4147d09af5a5006888dcc187ea0ef8.tar.xz mv-9e83411f7e4147d09af5a5006888dcc187ea0ef8.zip |
Fix some warnings under gcc 4.7.
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/action.cpp | 2 | ||||
-rw-r--r-- | src/resources/animation.cpp | 4 | ||||
-rw-r--r-- | src/resources/emotedb.cpp | 6 | ||||
-rw-r--r-- | src/resources/image.cpp | 42 | ||||
-rw-r--r-- | src/resources/image.h | 3 | ||||
-rw-r--r-- | src/resources/imageloader.cpp | 5 | ||||
-rw-r--r-- | src/resources/imageset.cpp | 2 | ||||
-rw-r--r-- | src/resources/imagewriter.cpp | 6 | ||||
-rw-r--r-- | src/resources/mapreader.cpp | 24 | ||||
-rw-r--r-- | src/resources/music.cpp | 2 | ||||
-rw-r--r-- | src/resources/resourcemanager.cpp | 42 | ||||
-rw-r--r-- | src/resources/soundeffect.cpp | 4 | ||||
-rw-r--r-- | src/resources/specialdb.cpp | 4 | ||||
-rw-r--r-- | src/resources/spritedef.cpp | 4 | ||||
-rw-r--r-- | src/resources/wallpaper.cpp | 2 |
15 files changed, 77 insertions, 75 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/animation.cpp b/src/resources/animation.cpp index 32b57b3b1..363e9b2ac 100644 --- a/src/resources/animation.cpp +++ b/src/resources/animation.cpp @@ -44,12 +44,12 @@ 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) 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..537630a2c 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -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 @@ -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 @@ -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,7 +573,7 @@ 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.colorkey = 0; @@ -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) @@ -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); @@ -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..d88e633be 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) { } @@ -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..2498f9c31 100644 --- a/src/resources/imagewriter.cpp +++ b/src/resources/imagewriter.cpp @@ -60,14 +60,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 +113,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/mapreader.cpp b/src/resources/mapreader.cpp index f702864ea..a6e1074f3 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 @@ -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")) 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..af9f664d4 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), @@ -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; @@ -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; } }; 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..2d49e8cd1 100644 --- a/src/resources/spritedef.cpp +++ b/src/resources/spritedef.cpp @@ -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; diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index 5cfec3b84..93eb8a40f 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; |