mirror of
https://github.com/OpenMW/openmw.git
synced 2025-02-03 18:15:35 +00:00
Don't crash if certain class doesn't exist
This commit is contained in:
parent
c9150c9680
commit
7c7c71428a
1 changed files with 8 additions and 7 deletions
|
@ -132,22 +132,23 @@ namespace MWGui
|
||||||
const ESM::Class *cls =
|
const ESM::Class *cls =
|
||||||
world->getStore().get<ESM::Class>().find(playerData->mClass);
|
world->getStore().get<ESM::Class>().find(playerData->mClass);
|
||||||
|
|
||||||
// Vanilla uses thief.dds for custom classes. A player with a custom class
|
|
||||||
// doesn't have mId set, see mwworld/esmstore.hpp where it is initialised as
|
|
||||||
// "$dynamic0". This check should resolve bug #1260.
|
|
||||||
// Choosing Stealth specialization and Speed/Agility as attributes.
|
|
||||||
if(world->getStore().get<ESM::Class>().isDynamic(cls->mId))
|
if(world->getStore().get<ESM::Class>().isDynamic(cls->mId))
|
||||||
{
|
{
|
||||||
|
// Vanilla uses thief.dds for custom classes.
|
||||||
|
// Choosing Stealth specialization and Speed/Agility as attributes, if possible. Otherwise fall back to first class found.
|
||||||
MWWorld::SharedIterator<ESM::Class> it = world->getStore().get<ESM::Class>().begin();
|
MWWorld::SharedIterator<ESM::Class> it = world->getStore().get<ESM::Class>().begin();
|
||||||
for(; it != world->getStore().get<ESM::Class>().end(); it++)
|
for(; it != world->getStore().get<ESM::Class>().end(); it++)
|
||||||
{
|
{
|
||||||
if(it->mData.mIsPlayable && it->mData.mSpecialization == 2 && it->mData.mAttribute[0] == 4 && it->mData.mAttribute[1] == 3)
|
if(it->mData.mIsPlayable && it->mData.mSpecialization == 2 && it->mData.mAttribute[0] == 4 && it->mData.mAttribute[1] == 3)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
mClassImage->setImageTexture ("textures\\levelup\\" + it->mId + ".dds");
|
if (it == world->getStore().get<ESM::Class>().end())
|
||||||
|
it = world->getStore().get<ESM::Class>().begin();
|
||||||
|
if (it != world->getStore().get<ESM::Class>().end())
|
||||||
|
cls = &*it;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds");
|
mClassImage->setImageTexture ("textures\\levelup\\" + cls->mId + ".dds");
|
||||||
|
|
||||||
int level = creatureStats.getLevel ()+1;
|
int level = creatureStats.getLevel ()+1;
|
||||||
mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + boost::lexical_cast<std::string>(level));
|
mLevelText->setCaptionWithReplacing("#{sLevelUpMenu1} " + boost::lexical_cast<std::string>(level));
|
||||||
|
|
Loading…
Reference in a new issue