From 306ad2effe4d0897453e61ad787e01dc47c33076 Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Tue, 12 Mar 2024 13:24:16 +0100 Subject: 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 --- src/resources/beinginfo.h | 2 -- src/resources/monsterdb.cpp | 2 +- src/resources/npcdb.cpp | 2 +- src/resources/resourcemanager.h | 6 ++---- src/resources/specialdb.cpp | 3 ++- src/resources/specialdb.h | 3 --- src/resources/spritedef.h | 2 -- src/resources/theme.cpp | 2 +- src/resources/theme.h | 10 +++------- src/resources/wallpaper.cpp | 15 +++------------ 10 files changed, 13 insertions(+), 34 deletions(-) (limited to 'src/resources') 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; - #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 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 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; - using ResourceIterator = Resources::iterator; - Resources mResources; - Resources mOrphanedResources; + std::map mResources; + std::map 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 namespace { - SpecialInfos mSpecialInfos; + std::map 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 -#include #include "utils/xml.h" struct SpecialInfo @@ -65,6 +64,4 @@ namespace SpecialDB SpecialInfo::TargetMode targetModeFromString(const std::string& str); } -using SpecialInfos = std::map; - #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 particles; }; -using SpriteRefs = std::list::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; - using SkinIterator = Skins::iterator; - - Skins mSkins; + std::map mSkins; static std::string mThemePath; static Theme *mInstance; @@ -245,8 +242,7 @@ class Theme : public Palette, public EventListener */ float mMinimumOpacity; - using ProgressColors = std::vector; - ProgressColors mProgressColors; + std::vector 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 #include #include -#include #include 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::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; } -- cgit v1.2.3-70-g09d2