summaryrefslogtreecommitdiff
path: root/src/resources/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/resources/db')
-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
14 files changed, 63 insertions, 119 deletions
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)