1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 20:19:57 +00:00

Remove useless throwing of exception

This commit is contained in:
scrawl 2014-05-22 15:29:36 +02:00
parent 3380e1e1c5
commit 4b5f02f644
2 changed files with 20 additions and 21 deletions

View file

@ -53,29 +53,27 @@ namespace MWMechanics
return std::string();
std::string item = candidates[std::rand()%candidates.size()];
// Is this another levelled item or a real item?
try
// Vanilla doesn't fail on nonexistent items in levelled lists
if (!MWBase::Environment::get().getWorld()->getStore().find(Misc::StringUtils::lowerCase(item)))
{
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), item, 1);
if (ref.getPtr().getTypeName() != typeid(ESM::ItemLevList).name()
&& ref.getPtr().getTypeName() != typeid(ESM::CreatureLevList).name())
{
return item;
}
else
{
if (ref.getPtr().getTypeName() == typeid(ESM::ItemLevList).name())
return getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, failChance);
else
return getLevelledItem(ref.getPtr().get<ESM::CreatureLevList>()->mBase, failChance);
}
}
catch (std::logic_error&)
{
// Vanilla doesn't fail on nonexistent items in levelled lists
std::cerr << "Warning: ignoring nonexistent item '" << item << "'" << std::endl;
std::cerr << "Warning: ignoring nonexistent item '" << item << "' in levelled list '" << levItem->mId << "'" << std::endl;
return std::string();
}
// Is this another levelled item or a real item?
MWWorld::ManualRef ref (MWBase::Environment::get().getWorld()->getStore(), item, 1);
if (ref.getPtr().getTypeName() != typeid(ESM::ItemLevList).name()
&& ref.getPtr().getTypeName() != typeid(ESM::CreatureLevList).name())
{
return item;
}
else
{
if (ref.getPtr().getTypeName() == typeid(ESM::ItemLevList).name())
return getLevelledItem(ref.getPtr().get<ESM::ItemLevList>()->mBase, failChance);
else
return getLevelledItem(ref.getPtr().get<ESM::CreatureLevList>()->mBase, failChance);
}
}
}

View file

@ -85,7 +85,8 @@ namespace MWWorld
return mStores.end();
}
// Look up the given ID in 'all'. Returns 0 if not found.
/// Look up the given ID in 'all'. Returns 0 if not found.
/// \note id must be in lower case.
int find(const std::string &id) const
{
std::map<std::string, int>::const_iterator it = mIds.find(id);