diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-12 13:24:16 +0100 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-03-12 21:23:10 +0100 |
commit | 306ad2effe4d0897453e61ad787e01dc47c33076 (patch) | |
tree | 75b8b291af55e80d01d9eb85afd7d465233a1a57 /src/resources | |
parent | 66599a9896e0cf69b58c0a73152aba4750d87af2 (diff) | |
download | mana-306ad2effe4d0897453e61ad787e01dc47c33076.tar.gz mana-306ad2effe4d0897453e61ad787e01dc47c33076.tar.bz2 mana-306ad2effe4d0897453e61ad787e01dc47c33076.tar.xz mana-306ad2effe4d0897453e61ad787e01dc47c33076.zip |
General code cleanups
* Use default member initializers
* Use range-based for loops
* Avoid needless pointer references for ShopItem::mDuplicates
* Removed type aliases that are only used once or twice
* Removed more unused includes
* Removed some unused functions
* Removed superfluous .c_str()
* Rely on default copy and assignment operators for Vector class
* Use std::unique_ptr in some places
* Removed duplicated mPlayerMoney updating in SellDialog
* Removed duplicated Game::handleInput call
* Removed unused SDLInput::mMouseInWindow
* Removed remnant of manual widget positioning in HelpWindow
* Removed superfluous initialization of static pointers
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/beinginfo.h | 2 | ||||
-rw-r--r-- | src/resources/monsterdb.cpp | 2 | ||||
-rw-r--r-- | src/resources/npcdb.cpp | 2 | ||||
-rw-r--r-- | src/resources/resourcemanager.h | 6 | ||||
-rw-r--r-- | src/resources/specialdb.cpp | 3 | ||||
-rw-r--r-- | src/resources/specialdb.h | 3 | ||||
-rw-r--r-- | src/resources/spritedef.h | 2 | ||||
-rw-r--r-- | src/resources/theme.cpp | 2 | ||||
-rw-r--r-- | src/resources/theme.h | 10 | ||||
-rw-r--r-- | src/resources/wallpaper.cpp | 15 |
10 files changed, 13 insertions, 34 deletions
diff --git a/src/resources/beinginfo.h b/src/resources/beinginfo.h index a4736439..d65feb5e 100644 --- a/src/resources/beinginfo.h +++ b/src/resources/beinginfo.h @@ -124,6 +124,4 @@ class BeingInfo Map::BlockType mBlockType = Map::BLOCKTYPE_CHARACTER; }; -using BeingInfos = std::map<int, BeingInfo *>; - #endif // BEINGINFO_H diff --git a/src/resources/monsterdb.cpp b/src/resources/monsterdb.cpp index 49ee2174..e28fe75e 100644 --- a/src/resources/monsterdb.cpp +++ b/src/resources/monsterdb.cpp @@ -37,7 +37,7 @@ namespace { - BeingInfos mMonsterInfos; + std::map<int, BeingInfo *> mMonsterInfos; bool mLoaded = false; int mMonsterIdOffset; } diff --git a/src/resources/npcdb.cpp b/src/resources/npcdb.cpp index 83d91b20..ce1bf14c 100644 --- a/src/resources/npcdb.cpp +++ b/src/resources/npcdb.cpp @@ -30,7 +30,7 @@ namespace { - BeingInfos mNPCInfos; + std::map<int, BeingInfo *> mNPCInfos; bool mLoaded = false; } diff --git a/src/resources/resourcemanager.h b/src/resources/resourcemanager.h index 9a427ba0..2377eea1 100644 --- a/src/resources/resourcemanager.h +++ b/src/resources/resourcemanager.h @@ -237,10 +237,8 @@ class ResourceManager void cleanOrphans(); static ResourceManager *instance; - using Resources = std::map<std::string, Resource *>; - using ResourceIterator = Resources::iterator; - Resources mResources; - Resources mOrphanedResources; + std::map<std::string, Resource *> mResources; + std::map<std::string, Resource *> mOrphanedResources; time_t mOldestOrphan; }; diff --git a/src/resources/specialdb.cpp b/src/resources/specialdb.cpp index 89bd4d8d..c2ff16c2 100644 --- a/src/resources/specialdb.cpp +++ b/src/resources/specialdb.cpp @@ -24,10 +24,11 @@ #include "utils/dtor.h" +#include <map> namespace { - SpecialInfos mSpecialInfos; + std::map<int, SpecialInfo *> mSpecialInfos; bool mLoaded = false; } diff --git a/src/resources/specialdb.h b/src/resources/specialdb.h index 71aae0ba..50aebf1f 100644 --- a/src/resources/specialdb.h +++ b/src/resources/specialdb.h @@ -22,7 +22,6 @@ #define SPECIAL_DB_H #include <string> -#include <map> #include "utils/xml.h" struct SpecialInfo @@ -65,6 +64,4 @@ namespace SpecialDB SpecialInfo::TargetMode targetModeFromString(const std::string& str); } -using SpecialInfos = std::map<int, SpecialInfo *>; - #endif diff --git a/src/resources/spritedef.h b/src/resources/spritedef.h index fafd6a41..49798afc 100644 --- a/src/resources/spritedef.h +++ b/src/resources/spritedef.h @@ -53,8 +53,6 @@ struct SpriteDisplay std::list<std::string> particles; }; -using SpriteRefs = std::list<SpriteReference>::const_iterator; - /* * Remember those are the main action. * Action subtypes, e.g.: "attack_bow" are to be passed by items.xml after diff --git a/src/resources/theme.cpp b/src/resources/theme.cpp index 4686edf1..1db92feb 100644 --- a/src/resources/theme.cpp +++ b/src/resources/theme.cpp @@ -105,7 +105,7 @@ int Skin::getMinHeight() const Theme::Theme(): Palette(THEME_COLORS_END), mMinimumOpacity(-1.0f), - mProgressColors(ProgressColors(THEME_PROG_END)) + mProgressColors(THEME_PROG_END) { initDefaultThemePath(); diff --git a/src/resources/theme.h b/src/resources/theme.h index ae795ed4..434bd6d8 100644 --- a/src/resources/theme.h +++ b/src/resources/theme.h @@ -107,7 +107,7 @@ class Theme : public Palette, public EventListener static void deleteInstance(); static void prepareThemePath(); - static std::string getThemePath() { return mThemePath; } + static const std::string &getThemePath() { return mThemePath; } /** * Returns the patch to the given gui resource relative to the theme @@ -227,10 +227,7 @@ class Theme : public Palette, public EventListener Skin *readSkin(const std::string &filename); // Map containing all window skins - using Skins = std::map<std::string, Skin *>; - using SkinIterator = Skins::iterator; - - Skins mSkins; + std::map<std::string, Skin *> mSkins; static std::string mThemePath; static Theme *mInstance; @@ -245,8 +242,7 @@ class Theme : public Palette, public EventListener */ float mMinimumOpacity; - using ProgressColors = std::vector<DyePalette *>; - ProgressColors mProgressColors; + std::vector<DyePalette *> mProgressColors; }; #endif diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp index a1990ed0..e8167b6b 100644 --- a/src/resources/wallpaper.cpp +++ b/src/resources/wallpaper.cpp @@ -21,17 +21,12 @@ #include "resources/wallpaper.h" -#include "resources/resourcemanager.h" -#include "log.h" - -#include "utils/stringutils.h" #include "configuration.h" #include <physfs.h> #include <algorithm> #include <cstring> -#include <ctime> #include <vector> struct WallpaperData @@ -144,16 +139,12 @@ std::string Wallpaper::getWallpaper(int width, int height) WallpaperData wallpaper; // Search for the smallest wallpaper at least as large as the screen - std::vector<WallpaperData>::iterator iter; - for (iter = wallpaperData.begin(); iter != wallpaperData.end(); iter++) + for (auto &wp : wallpaperData) { - const WallpaperData &wp = *iter; - if (wp.width >= width && wp.height >= height) { - if (wallpaper.filename.empty() || - (wallpaper.width < wp.width && - wallpaper.height < wp.height)) + if (wallpaper.filename.empty() || (wallpaper.width < wp.width && + wallpaper.height < wp.height)) { wallpaper = wp; } |