summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2017-08-21 22:44:29 +0300
committerAndrei Karas <akaras@inbox.ru>2017-08-21 22:45:15 +0300
commit42f47e483da19079a937c4801ca94bd62d8dc970 (patch)
tree56dc96737e01e04d54357ce7118de3a1f000c516 /src/resources
parent2d8b9246c8003f1d32ba396bc19cc11bc5a595b2 (diff)
downloadplus-42f47e483da19079a937c4801ca94bd62d8dc970.tar.gz
plus-42f47e483da19079a937c4801ca94bd62d8dc970.tar.bz2
plus-42f47e483da19079a937c4801ca94bd62d8dc970.tar.xz
plus-42f47e483da19079a937c4801ca94bd62d8dc970.zip
Remove useless else.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/animation/simpleanimation.cpp3
-rw-r--r--src/resources/beinginfo.cpp5
-rw-r--r--src/resources/chatobject.cpp6
-rw-r--r--src/resources/db/avatardb.cpp3
-rw-r--r--src/resources/db/colordb.cpp5
-rw-r--r--src/resources/db/elementaldb.cpp9
-rw-r--r--src/resources/db/emotedb.cpp10
-rw-r--r--src/resources/db/homunculusdb.cpp9
-rw-r--r--src/resources/db/horsedb.cpp5
-rw-r--r--src/resources/db/mercenarydb.cpp9
-rw-r--r--src/resources/db/moddb.cpp3
-rw-r--r--src/resources/db/monsterdb.cpp9
-rw-r--r--src/resources/db/npcdb.cpp5
-rw-r--r--src/resources/db/palettedb.cpp3
-rw-r--r--src/resources/db/petdb.cpp5
-rw-r--r--src/resources/db/skillunitdb.cpp5
-rw-r--r--src/resources/db/unitsdb.cpp102
-rw-r--r--src/resources/image/image.cpp9
-rw-r--r--src/resources/image/subimage.cpp3
-rw-r--r--src/resources/imageset.cpp5
-rw-r--r--src/resources/item/item.cpp5
-rw-r--r--src/resources/iteminfo.cpp25
-rw-r--r--src/resources/loaders/musicloader.cpp8
-rw-r--r--src/resources/loaders/soundloader.cpp9
-rw-r--r--src/resources/map/map.cpp3
-rw-r--r--src/resources/sdlmusic.cpp3
-rw-r--r--src/resources/sprite/animatedsprite.cpp9
-rw-r--r--src/resources/sprite/spritedef.cpp3
-rw-r--r--src/resources/wallpaper.cpp3
29 files changed, 98 insertions, 183 deletions
diff --git a/src/resources/animation/simpleanimation.cpp b/src/resources/animation/simpleanimation.cpp
index ed92d2b50..3ee18830d 100644
--- a/src/resources/animation/simpleanimation.cpp
+++ b/src/resources/animation/simpleanimation.cpp
@@ -141,8 +141,7 @@ Image *SimpleAnimation::getCurrentImage() const
{
if (mCurrentFrame != nullptr)
return mCurrentFrame->image;
- else
- return nullptr;
+ return nullptr;
}
void SimpleAnimation::initializeAnimation(XmlNodeConstPtr animationNode,
diff --git a/src/resources/beinginfo.cpp b/src/resources/beinginfo.cpp
index f077beada..6c082d85f 100644
--- a/src/resources/beinginfo.cpp
+++ b/src/resources/beinginfo.cpp
@@ -170,10 +170,9 @@ const SoundInfo &BeingInfo::getSound(const ItemSoundEvent::Type event) const
return emptySound;
const SoundInfoVect *const vect = i->second;
- if ((vect == nullptr) || vect->empty())
+ if (vect == nullptr || vect->empty())
return emptySound;
- else
- return vect->at(CAST_SIZE(rand()) % vect->size());
+ return vect->at(CAST_SIZE(rand()) % vect->size());
}
const Attack *BeingInfo::getAttack(const int id) const
diff --git a/src/resources/chatobject.cpp b/src/resources/chatobject.cpp
index 24dc5436d..c0ce7800d 100644
--- a/src/resources/chatobject.cpp
+++ b/src/resources/chatobject.cpp
@@ -57,8 +57,7 @@ ChatObject *ChatObject::findByName(const std::string &name)
chatNameMap.find(name);
if (it == chatNameMap.end())
return nullptr;
- else
- return (*it).second;
+ return (*it).second;
}
ChatObject *ChatObject::findById(const int id)
@@ -66,6 +65,5 @@ ChatObject *ChatObject::findById(const int id)
const std::map<int, ChatObject*>::iterator it = chatIdMap.find(id);
if (it == chatIdMap.end())
return nullptr;
- else
- return (*it).second;
+ return (*it).second;
}
diff --git a/src/resources/db/avatardb.cpp b/src/resources/db/avatardb.cpp
index 4e2fb821d..cfa1a4517 100644
--- a/src/resources/db/avatardb.cpp
+++ b/src/resources/db/avatardb.cpp
@@ -142,6 +142,5 @@ BeingInfo *AvatarDB::get(const BeingTypeId id)
const BeingInfoIterator i = mAvatarInfos.find(id);
if (i == mAvatarInfos.end())
return BeingInfo::unknown;
- else
- return i->second;
+ return i->second;
}
diff --git a/src/resources/db/colordb.cpp b/src/resources/db/colordb.cpp
index 100688d7f..626ef78ae 100644
--- a/src/resources/db/colordb.cpp
+++ b/src/resources/db/colordb.cpp
@@ -206,10 +206,7 @@ std::string &ColorDB::getHairColorName(const ItemColor id)
toInt(id, int));
return mFail;
}
- else
- {
- return i->second.name;
- }
+ return i->second.name;
}
int ColorDB::getHairSize()
diff --git a/src/resources/db/elementaldb.cpp b/src/resources/db/elementaldb.cpp
index ce11dfeda..1bebf7633 100644
--- a/src/resources/db/elementaldb.cpp
+++ b/src/resources/db/elementaldb.cpp
@@ -148,13 +148,6 @@ BeingInfo *ElementalDb::get(const BeingTypeId id)
toInt(id, int));
return BeingInfo::unknown;
}
- else
- {
- return i->second;
- }
- }
- else
- {
- return i->second;
}
+ return i->second;
}
diff --git a/src/resources/db/emotedb.cpp b/src/resources/db/emotedb.cpp
index 02018d963..e519b531d 100644
--- a/src/resources/db/emotedb.cpp
+++ b/src/resources/db/emotedb.cpp
@@ -265,10 +265,7 @@ const EmoteInfo *EmoteDB::get(const int id, const bool allowNull)
id);
return &mUnknown;
}
- else
- {
- return i->second;
- }
+ return i->second;
}
const EmoteInfo *EmoteDB::get2(int id, const bool allowNull)
@@ -287,10 +284,7 @@ const EmoteInfo *EmoteDB::get2(int id, const bool allowNull)
id);
return &mUnknown;
}
- else
- {
- return i->second;
- }
+ return i->second;
}
const EmoteSprite *EmoteDB::getSprite(const int id, const bool allowNull)
diff --git a/src/resources/db/homunculusdb.cpp b/src/resources/db/homunculusdb.cpp
index a6453661a..83912e936 100644
--- a/src/resources/db/homunculusdb.cpp
+++ b/src/resources/db/homunculusdb.cpp
@@ -154,13 +154,6 @@ BeingInfo *HomunculusDB::get(const BeingTypeId id)
toInt(id, int));
return BeingInfo::unknown;
}
- else
- {
- return i->second;
- }
- }
- else
- {
- return i->second;
}
+ return i->second;
}
diff --git a/src/resources/db/horsedb.cpp b/src/resources/db/horsedb.cpp
index a59c18e3f..00228ecd7 100644
--- a/src/resources/db/horsedb.cpp
+++ b/src/resources/db/horsedb.cpp
@@ -293,10 +293,7 @@ HorseInfo *HorseDB::get(const int id, const bool allowNull)
id);
return &mUnknown;
}
- else
- {
- return i->second;
- }
+ return i->second;
}
int HorseDB::size()
diff --git a/src/resources/db/mercenarydb.cpp b/src/resources/db/mercenarydb.cpp
index 464daac63..befbdafea 100644
--- a/src/resources/db/mercenarydb.cpp
+++ b/src/resources/db/mercenarydb.cpp
@@ -152,13 +152,6 @@ BeingInfo *MercenaryDB::get(const BeingTypeId id)
toInt(id, int));
return BeingInfo::unknown;
}
- else
- {
- return i->second;
- }
- }
- else
- {
- return i->second;
}
+ return i->second;
}
diff --git a/src/resources/db/moddb.cpp b/src/resources/db/moddb.cpp
index 7db96f4bd..4e0be461f 100644
--- a/src/resources/db/moddb.cpp
+++ b/src/resources/db/moddb.cpp
@@ -109,8 +109,7 @@ ModInfo *ModDB::get(const std::string &name)
const ModInfoIterator i = mModInfos.find(name);
if (i == mModInfos.end())
return nullptr;
- else
- return i->second;
+ return i->second;
}
const ModInfos &ModDB::getAll()
diff --git a/src/resources/db/monsterdb.cpp b/src/resources/db/monsterdb.cpp
index 59b8f9808..b6cdc4f53 100644
--- a/src/resources/db/monsterdb.cpp
+++ b/src/resources/db/monsterdb.cpp
@@ -155,13 +155,6 @@ BeingInfo *MonsterDB::get(const BeingTypeId id)
toInt(id, int));
return BeingInfo::unknown;
}
- else
- {
- return i->second;
- }
- }
- else
- {
- return i->second;
}
+ return i->second;
}
diff --git a/src/resources/db/npcdb.cpp b/src/resources/db/npcdb.cpp
index d6cc55264..26034de12 100644
--- a/src/resources/db/npcdb.cpp
+++ b/src/resources/db/npcdb.cpp
@@ -191,10 +191,7 @@ BeingInfo *NPCDB::get(const BeingTypeId id)
toInt(id, int));
return BeingInfo::unknown;
}
- else
- {
- return i->second;
- }
+ return i->second;
}
BeingTypeId NPCDB::getAvatarFor(const BeingTypeId id)
diff --git a/src/resources/db/palettedb.cpp b/src/resources/db/palettedb.cpp
index 484e62751..d7ec6b78d 100644
--- a/src/resources/db/palettedb.cpp
+++ b/src/resources/db/palettedb.cpp
@@ -111,6 +111,5 @@ const DyeColor *PaletteDB::getColor(const std::string &name)
mColors.find(name);
if (it != mColors.end())
return &(*it).second;
- else
- return nullptr;
+ return nullptr;
}
diff --git a/src/resources/db/petdb.cpp b/src/resources/db/petdb.cpp
index 2710356ae..721b27bfb 100644
--- a/src/resources/db/petdb.cpp
+++ b/src/resources/db/petdb.cpp
@@ -163,8 +163,5 @@ BeingInfo *PETDB::get(const BeingTypeId id)
toInt(id, int));
return BeingInfo::unknown;
}
- else
- {
- return i->second;
- }
+ return i->second;
}
diff --git a/src/resources/db/skillunitdb.cpp b/src/resources/db/skillunitdb.cpp
index d7028e672..0150c4a16 100644
--- a/src/resources/db/skillunitdb.cpp
+++ b/src/resources/db/skillunitdb.cpp
@@ -157,8 +157,5 @@ BeingInfo *SkillUnitDb::get(const BeingTypeId id)
toInt(id, int));
return BeingInfo::unknown;
}
- else
- {
- return i->second;
- }
+ return i->second;
}
diff --git a/src/resources/db/unitsdb.cpp b/src/resources/db/unitsdb.cpp
index ab42ba04c..aac6b72e3 100644
--- a/src/resources/db/unitsdb.cpp
+++ b/src/resources/db/unitsdb.cpp
@@ -254,74 +254,70 @@ static std::string formatUnit(const int value,
ul = ud.levels[0];
return strprintf("0%s", ul.symbol.c_str());
}
- else
+
+ double amount = ud.conversion * value;
+ const unsigned int sz = CAST_U32(ud.levels.size());
+
+ // If only the first level is needed, act like mix if false
+ if (ud.mix && !ud.levels.empty() && ud.levels[1].count < amount)
{
- double amount = ud.conversion * value;
- const unsigned int sz = CAST_U32(ud.levels.size());
+ std::string output;
+ UnitLevel pl = ud.levels[0];
+ ul = ud.levels[1];
+ int levelAmount = CAST_S32(amount);
+ int nextAmount = 0;
- // If only the first level is needed, act like mix if false
- if (ud.mix && !ud.levels.empty() && ud.levels[1].count < amount)
- {
- std::string output;
- UnitLevel pl = ud.levels[0];
- ul = ud.levels[1];
- int levelAmount = CAST_S32(amount);
- int nextAmount = 0;
+ if (ul.count != 0)
+ levelAmount /= ul.count;
- if (ul.count != 0)
- levelAmount /= ul.count;
+ amount -= static_cast<double>(levelAmount * ul.count);
- amount -= static_cast<double>(levelAmount * ul.count);
+ if (amount > 0)
+ {
+ output = splitNumber(strprintf("%.*f", pl.round,
+ amount), pl.separator).append(pl.symbol);
+ }
+
+ for (unsigned int i = 2; i < sz; i++)
+ {
+ pl = ul;
+ ul = ud.levels[i];
- if (amount > 0)
+ if (ul.count != 0)
{
- output = splitNumber(strprintf("%.*f", pl.round,
- amount), pl.separator).append(pl.symbol);
+ nextAmount = levelAmount / ul.count;
+ levelAmount %= ul.count;
}
- for (unsigned int i = 2; i < sz; i++)
+ if (levelAmount > 0)
{
- pl = ul;
- ul = ud.levels[i];
-
- if (ul.count != 0)
- {
- nextAmount = levelAmount / ul.count;
- levelAmount %= ul.count;
- }
-
- if (levelAmount > 0)
- {
- output = splitNumber(strprintf("%d", levelAmount),
- pl.separator).append(pl.symbol).append(output);
- }
-
- if (nextAmount == 0)
- break;
- levelAmount = nextAmount;
+ output = splitNumber(strprintf("%d", levelAmount),
+ pl.separator).append(pl.symbol).append(output);
}
- return output;
+ if (nextAmount == 0)
+ break;
+ levelAmount = nextAmount;
}
- else
- {
- ul.round = 0;
- for (unsigned int i = 0; i < sz; i++)
- {
- ul = ud.levels[i];
- if (amount < ul.count && ul.count > 0)
- {
- ul = ud.levels[i - 1];
- break;
- }
- if (ul.count != 0)
- amount /= ul.count;
- }
- return splitNumber(strprintf("%.*f", ul.round, amount),
- ul.separator).append(ul.symbol);
+ return output;
+ }
+
+ ul.round = 0;
+ for (unsigned int i = 0; i < sz; i++)
+ {
+ ul = ud.levels[i];
+ if (amount < ul.count && ul.count > 0)
+ {
+ ul = ud.levels[i - 1];
+ break;
}
+ if (ul.count != 0)
+ amount /= ul.count;
}
+
+ return splitNumber(strprintf("%.*f", ul.round, amount),
+ ul.separator).append(ul.symbol);
}
std::string UnitsDb::formatCurrency(const int value)
diff --git a/src/resources/image/image.cpp b/src/resources/image/image.cpp
index 03f35a77c..ec17bbdf4 100644
--- a/src/resources/image/image.cpp
+++ b/src/resources/image/image.cpp
@@ -330,12 +330,9 @@ void Image::setAlpha(const float alpha)
mAlpha = alpha;
return;
}
- else
- {
- mSDLSurface = SDLImageHelper::SDLDuplicateSurface(mSDLSurface);
- if (mSDLSurface == nullptr)
- return;
- }
+ mSDLSurface = SDLImageHelper::SDLDuplicateSurface(mSDLSurface);
+ if (mSDLSurface == nullptr)
+ return;
}
mAlpha = alpha;
diff --git a/src/resources/image/subimage.cpp b/src/resources/image/subimage.cpp
index 735ed27f5..9eda05164 100644
--- a/src/resources/image/subimage.cpp
+++ b/src/resources/image/subimage.cpp
@@ -215,8 +215,7 @@ Image *SubImage::getSubImage(const int x, const int y,
{
if (mParent != nullptr)
return mParent->getSubImage(mBounds.x + x, mBounds.y + y, w, h);
- else
- return nullptr;
+ return nullptr;
}
#ifdef USE_OPENGL
diff --git a/src/resources/imageset.cpp b/src/resources/imageset.cpp
index 9f6bb2ecc..724038100 100644
--- a/src/resources/imageset.cpp
+++ b/src/resources/imageset.cpp
@@ -71,10 +71,7 @@ Image* ImageSet::get(const size_type i) const
CAST_S32(i));
return nullptr;
}
- else
- {
- return mImages[i];
- }
+ return mImages[i];
}
int ImageSet::calcMemoryLocal() const
diff --git a/src/resources/item/item.cpp b/src/resources/item/item.cpp
index 897340732..a9a2c89df 100644
--- a/src/resources/item/item.cpp
+++ b/src/resources/item/item.cpp
@@ -144,11 +144,8 @@ std::string Item::getName() const
{
return info.getName();
}
- else
#endif // TWMA_SUPPORT
- {
- return info.getName(mColor);
- }
+ return info.getName(mColor);
}
void Item::setCard(const int index, const int id)
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index 2997a48ad..60810e000 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -104,20 +104,17 @@ const std::string &ItemInfo::getSprite(const GenderT gender,
// Forward the request to the item defining how to view this item
return ItemDB::get(mView).getSprite(gender, race);
}
- else
- {
- static const std::string empty;
- std::map<int, std::string>::const_iterator i =
- mAnimationFiles.find(CAST_S32(gender) +
- toInt(race, int) * 4);
-
- if (i != mAnimationFiles.end())
- return i->second;
- i = mAnimationFiles.find(CAST_S32(gender));
- if (i != mAnimationFiles.end())
- return i->second;
- return empty;
- }
+ static const std::string empty;
+ std::map<int, std::string>::const_iterator i =
+ mAnimationFiles.find(CAST_S32(gender) +
+ toInt(race, int) * 4);
+
+ if (i != mAnimationFiles.end())
+ return i->second;
+ i = mAnimationFiles.find(CAST_S32(gender));
+ if (i != mAnimationFiles.end())
+ return i->second;
+ return empty;
}
void ItemInfo::setAttackAction(const std::string &attackAction)
diff --git a/src/resources/loaders/musicloader.cpp b/src/resources/loaders/musicloader.cpp
index f0b67cb67..e734ddce6 100644
--- a/src/resources/loaders/musicloader.cpp
+++ b/src/resources/loaders/musicloader.cpp
@@ -66,11 +66,9 @@ namespace
return new SDLMusic(music, rw, rl->path);
}
#endif // USE_SDL2
- else
- {
- logger->log("Error, failed to load music: %s", Mix_GetError());
- return nullptr;
- }
+
+ logger->log("Error, failed to load music: %s", Mix_GetError());
+ return nullptr;
}
};
} // namespace
diff --git a/src/resources/loaders/soundloader.cpp b/src/resources/loaders/soundloader.cpp
index a84898201..b99b48b6c 100644
--- a/src/resources/loaders/soundloader.cpp
+++ b/src/resources/loaders/soundloader.cpp
@@ -60,12 +60,9 @@ namespace
{
return new SoundEffect(tmpSoundEffect, rl->path);
}
- else
- {
- reportAlways("Error, failed to load sound effect: %s",
- Mix_GetError());
- return nullptr;
- }
+ reportAlways("Error, failed to load sound effect: %s",
+ Mix_GetError());
+ return nullptr;
}
};
} // namespace
diff --git a/src/resources/map/map.cpp b/src/resources/map/map.cpp
index 675c9ca58..6a70048e8 100644
--- a/src/resources/map/map.cpp
+++ b/src/resources/map/map.cpp
@@ -689,8 +689,7 @@ const Tileset *Map::getTilesetWithGid(const int gid) const restrict2
{
if (gid >= 0 && gid < mIndexedTilesetsSize)
return mIndexedTilesets[gid];
- else
- return nullptr;
+ return nullptr;
}
void Map::addBlockMask(const int x, const int y,
diff --git a/src/resources/sdlmusic.cpp b/src/resources/sdlmusic.cpp
index d3801d453..be363fc48 100644
--- a/src/resources/sdlmusic.cpp
+++ b/src/resources/sdlmusic.cpp
@@ -62,8 +62,7 @@ bool SDLMusic::play(const int loops,
{
if (fadeIn > 0)
return Mix_FadeInMusicPos(mMusic, loops, fadeIn, 0.0) != 0;
- else
- return Mix_FadeInMusicPos(mMusic, loops, 0, 0.0) != 0;
+ return Mix_FadeInMusicPos(mMusic, loops, 0, 0.0) != 0;
}
int SDLMusic::calcMemoryLocal() const
diff --git a/src/resources/sprite/animatedsprite.cpp b/src/resources/sprite/animatedsprite.cpp
index d2dbc1b72..4905f2f3e 100644
--- a/src/resources/sprite/animatedsprite.cpp
+++ b/src/resources/sprite/animatedsprite.cpp
@@ -383,24 +383,21 @@ unsigned int AnimatedSprite::getFrameCount() const restrict2
{
if (mAnimation != nullptr)
return CAST_U32(mAnimation->getLength());
- else
- return 0;
+ return 0;
}
int AnimatedSprite::getWidth() const restrict2
{
if ((mFrame != nullptr) && (mFrame->image != nullptr))
return mFrame->image->mBounds.w;
- else
- return 0;
+ return 0;
}
int AnimatedSprite::getHeight() const restrict2
{
if ((mFrame != nullptr) && (mFrame->image != nullptr))
return mFrame->image->mBounds.h;
- else
- return 0;
+ return 0;
}
std::string AnimatedSprite::getIdPath() const restrict2
diff --git a/src/resources/sprite/spritedef.cpp b/src/resources/sprite/spritedef.cpp
index ccb8af30c..5fdb68584 100644
--- a/src/resources/sprite/spritedef.cpp
+++ b/src/resources/sprite/spritedef.cpp
@@ -112,8 +112,7 @@ SpriteDef *SpriteDef::load(const std::string &animationFile,
doc->decRef();
if (animationFile != errorFile)
return load(errorFile, 0, prot);
- else
- return nullptr;
+ return nullptr;
}
SpriteDef *const def = new SpriteDef;
diff --git a/src/resources/wallpaper.cpp b/src/resources/wallpaper.cpp
index 1fc253f72..dfaca1f30 100644
--- a/src/resources/wallpaper.cpp
+++ b/src/resources/wallpaper.cpp
@@ -69,8 +69,7 @@ static void initDefaultWallpaperPaths()
if (!wallpaperFile.empty() && !VirtFs::isDirectory(wallpaperFile))
return;
- else
- wallpaperFile = paths.getValue("wallpaperFile", "");
+ wallpaperFile = paths.getValue("wallpaperFile", "");
if (wallpaperFile.empty() || VirtFs::isDirectory(wallpaperFile))
wallpaperFile = "login_wallpaper.png";