From 593cccb16074fe9269dd2f278bd79859769eb1fd Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sat, 8 Sep 2012 00:17:45 +0300 Subject: Improve constructors in some classes. --- src/resources/colordb.h | 8 ++++---- src/resources/image.cpp | 11 ++++++----- src/resources/imageset.cpp | 1 + src/resources/iteminfo.cpp | 3 ++- src/resources/music.cpp | 1 + src/resources/soundeffect.h | 1 + src/resources/spritedef.h | 3 ++- 7 files changed, 17 insertions(+), 11 deletions(-) (limited to 'src/resources') diff --git a/src/resources/colordb.h b/src/resources/colordb.h index fd479d00a..4be6503fb 100644 --- a/src/resources/colordb.h +++ b/src/resources/colordb.h @@ -40,11 +40,11 @@ namespace ColorDB { } ItemColor(const int id0, const std::string &name0, - const std::string &color0) + const std::string &color0) : + id(id0), + name(name0), + color(color0) { - this->id = id0; - this->name = name0; - this->color = color0; } int id; diff --git a/src/resources/image.cpp b/src/resources/image.cpp index e70ee3de5..0e2423bf9 100644 --- a/src/resources/image.cpp +++ b/src/resources/image.cpp @@ -45,6 +45,8 @@ Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0, uint8_t *const alphaChannel) : + Resource(), + mLoaded(false), mAlpha(1.0f), mHasAlphaChannel(hasAlphaChannel0), mSDLSurface(image), @@ -61,8 +63,6 @@ Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0, mBounds.x = 0; mBounds.y = 0; - mLoaded = false; - if (mSDLSurface) { mBounds.w = static_cast(mSDLSurface->w); @@ -82,6 +82,8 @@ Image::Image(SDL_Surface *const image, const bool hasAlphaChannel0, #ifdef USE_OPENGL Image::Image(const GLuint glimage, const int width, const int height, const int texWidth, const int texHeight) : + Resource(), + mLoaded(false), mAlpha(1.0f), mHasAlphaChannel(true), mSDLSurface(nullptr), @@ -104,9 +106,8 @@ Image::Image(const GLuint glimage, const int width, const int height, } else { - logger->log( - "Image::Image(GLuint*, ...): Couldn't load invalid Surface!"); - mLoaded = false; + logger->log("Image::Image(GLuint*, ...):" + " Couldn't load invalid Surface!"); } } #endif diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp index 538b27c84..2e10f74a2 100644 --- a/src/resources/imageset.cpp +++ b/src/resources/imageset.cpp @@ -32,6 +32,7 @@ ImageSet::ImageSet(Image *const img, const int width, const int height, const int margin, const int spacing) : + Resource(), mWidth(width), mHeight(height), mOffsetX(0), diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index e72893d12..7e106af80 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -82,7 +82,8 @@ ItemInfo::ItemInfo() : mColors(nullptr), mColorList(""), mHitEffectId(0), - mCriticalHitEffectId(0) + mCriticalHitEffectId(0), + maxFloorOffset(32) { for (int f = 0; f < 10; f ++) { diff --git a/src/resources/music.cpp b/src/resources/music.cpp index 1b66e6bad..d88b3ccac 100644 --- a/src/resources/music.cpp +++ b/src/resources/music.cpp @@ -27,6 +27,7 @@ #include "debug.h" Music::Music(Mix_Music *const music) : + Resource(), mMusic(music) { } diff --git a/src/resources/soundeffect.h b/src/resources/soundeffect.h index 5f3676064..7d23dcca0 100644 --- a/src/resources/soundeffect.h +++ b/src/resources/soundeffect.h @@ -66,6 +66,7 @@ class SoundEffect : public Resource * Constructor. */ SoundEffect(Mix_Chunk *const soundEffect) : + Resource(), mChunk(soundEffect) { } diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index 86f2d7f12..74960f64e 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -143,7 +143,8 @@ class SpriteDef : public Resource /** * Constructor. */ - SpriteDef() + SpriteDef() : + Resource() { } /** -- cgit v1.2.3-70-g09d2