summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-08 22:35:09 +0100
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-02-09 17:14:25 +0100
commit1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7 (patch)
tree74cff7036d1ecfb4df5a79a7ca68bedce5bea47e /src/resources
parent0ca05c54dd814f294617eda286ef175f01baa542 (diff)
downloadmana-1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7.tar.gz
mana-1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7.tar.bz2
mana-1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7.tar.xz
mana-1b041ecccfbe44a4f50ffc086e3996e2b6eea4f7.zip
C++11: Use default member initializers
This patch is not exhaustive.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/hairdb.h10
-rw-r--r--src/resources/imageset.cpp14
-rw-r--r--src/resources/imageset.h8
-rw-r--r--src/resources/itemdb.h9
-rw-r--r--src/resources/iteminfo.h12
-rw-r--r--src/resources/resource.h10
6 files changed, 24 insertions, 39 deletions
diff --git a/src/resources/hairdb.h b/src/resources/hairdb.h
index 65cca496..b4374985 100644
--- a/src/resources/hairdb.h
+++ b/src/resources/hairdb.h
@@ -33,10 +33,8 @@
*/
class HairDB
{
- public:
- HairDB():
- mLoaded(false)
- {}
+public:
+ HairDB() = default;
~HairDB()
{ unload(); }
@@ -74,7 +72,7 @@ class HairDB
*/
void addHairStyle(int id);
- private:
+private:
/**
* Load the hair colors, contained in a <colors> node.
*/
@@ -94,7 +92,7 @@ class HairDB
using HairStyles = std::set<int>;
HairStyles mHairStyles;
- bool mLoaded;
+ bool mLoaded = false;
};
extern HairDB hairDB;
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index 74b4034f..4eec23f8 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -29,8 +29,8 @@
ImageSet::ImageSet(Image *img, int width, int height,
int margin, int spacing) :
- mOffsetX(0),
- mOffsetY(0)
+ mWidth(width),
+ mHeight(height)
{
for (int y = margin; y + height <= img->getHeight() - margin; y += height + spacing)
{
@@ -39,8 +39,6 @@ ImageSet::ImageSet(Image *img, int width, int height,
mImages.push_back(img->getSubImage(x, y, width, height));
}
}
- mWidth = width;
- mHeight = height;
}
ImageSet::~ImageSet()
@@ -48,15 +46,13 @@ ImageSet::~ImageSet()
delete_all(mImages);
}
-Image* ImageSet::get(size_type i) const
+Image *ImageSet::get(size_type i) const
{
if (i >= mImages.size())
{
logger->log("Warning: No sprite %d in this image set", (int) i);
return nullptr;
}
- else
- {
- return mImages[i];
- }
+
+ return mImages[i];
}
diff --git a/src/resources/imageset.h b/src/resources/imageset.h
index c73e7e37..8f377369 100644
--- a/src/resources/imageset.h
+++ b/src/resources/imageset.h
@@ -52,7 +52,7 @@ class ImageSet : public Resource
int getHeight() const { return mHeight; }
using size_type = std::vector<Image *>::size_type;
- Image* get(size_type i) const;
+ Image *get(size_type i) const;
size_type size() const { return mImages.size(); }
@@ -71,10 +71,10 @@ class ImageSet : public Resource
private:
std::vector<Image*> mImages;
- int mHeight; /**< Height of the images in the image set. */
int mWidth; /**< Width of the images in the image set. */
- int mOffsetX;
- int mOffsetY;
+ int mHeight; /**< Height of the images in the image set. */
+ int mOffsetX = 0;
+ int mOffsetY = 0;
};
#endif
diff --git a/src/resources/itemdb.h b/src/resources/itemdb.h
index 016e6194..d8d37bc4 100644
--- a/src/resources/itemdb.h
+++ b/src/resources/itemdb.h
@@ -73,10 +73,7 @@ void setStatsList(const std::list<ItemStat> &stats);
class ItemDB
{
public:
- ItemDB() :
- mUnknown(nullptr),
- mLoaded(false)
- {}
+ ItemDB() = default;
virtual ~ItemDB()
{}
@@ -126,9 +123,9 @@ class ItemDB
void loadEmptyItemDefinition();
// Default unknown reference
- ItemInfo *mUnknown;
+ ItemInfo *mUnknown = nullptr;
- bool mLoaded;
+ bool mLoaded = false;
private:
/**
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index da73bd3e..df559d69 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -81,10 +81,6 @@ class ItemInfo
public:
ItemInfo():
- mType(ITEM_UNUSABLE),
- mWeight(0),
- mView(0),
- mId(0),
mAttackAction(SpriteAction::INVALID)
{
}
@@ -159,11 +155,11 @@ class ItemInfo
std::string mName;
std::string mDescription; /**< Short description. */
std::vector<std::string> mEffect; /**< Description of effects. */
- ItemType mType; /**< Item type. */
+ ItemType mType = ITEM_UNUSABLE; /**< Item type. */
std::string mParticle; /**< Particle effect used with this item */
- int mWeight; /**< Weight in grams. */
- int mView; /**< Item ID of how this item looks. */
- int mId; /**< Item ID */
+ int mWeight = 0; /**< Weight in grams. */
+ int mView = 0; /**< Item ID of how this item looks. */
+ int mId = 0; /**< Item ID */
bool mEquippable; /**< Whether this item can be equipped. */
bool mActivatable; /**< Whether this item can be activated. */
diff --git a/src/resources/resource.h b/src/resources/resource.h
index 988b78a5..7f1f4836 100644
--- a/src/resources/resource.h
+++ b/src/resources/resource.h
@@ -38,9 +38,7 @@ class Resource
DeleteImmediately
};
- Resource():
- mRefCount(0)
- {}
+ Resource() = default;
/**
* Increments the internal reference count.
@@ -64,9 +62,9 @@ class Resource
virtual ~Resource() {}
private:
- std::string mIdPath; /**< Path identifying this resource. */
- time_t mTimeStamp; /**< Time at which the resource was orphaned. */
- unsigned mRefCount; /**< Reference count. */
+ std::string mIdPath; /**< Path identifying this resource. */
+ time_t mTimeStamp; /**< Time at which the resource was orphaned. */
+ unsigned mRefCount = 0; /**< Reference count. */
};
/**