mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-03 23:56:43 +00:00 
			
		
		
		
	Added exception handlers when trying to retreive enchantment and magic effect data.
This commit is contained in:
		
							parent
							
								
									17ede44628
								
							
						
					
					
						commit
						14165352f6
					
				
					 2 changed files with 37 additions and 13 deletions
				
			
		| 
						 | 
					@ -394,6 +394,8 @@ namespace MWGui
 | 
				
			||||||
        const ESM::Enchantment* enchant = 0;
 | 
					        const ESM::Enchantment* enchant = 0;
 | 
				
			||||||
        const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
 | 
					        const MWWorld::ESMStore& store = MWBase::Environment::get().getWorld()->getStore();
 | 
				
			||||||
        if (info.enchant != "")
 | 
					        if (info.enchant != "")
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            try
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                enchant = store.get<ESM::Enchantment>().find(info.enchant);
 | 
					                enchant = store.get<ESM::Enchantment>().find(info.enchant);
 | 
				
			||||||
                if (enchant->mData.mType == ESM::Enchantment::CastOnce)
 | 
					                if (enchant->mData.mType == ESM::Enchantment::CastOnce)
 | 
				
			||||||
| 
						 | 
					@ -405,6 +407,11 @@ namespace MWGui
 | 
				
			||||||
                else if (enchant->mData.mType == ESM::Enchantment::ConstantEffect)
 | 
					                else if (enchant->mData.mType == ESM::Enchantment::ConstantEffect)
 | 
				
			||||||
                    text += "\n#{sItemCastConstant}";
 | 
					                    text += "\n#{sItemCastConstant}";
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            catch (const std::runtime_error& ex)
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        // this the maximum width of the tooltip before it starts word-wrapping
 | 
					        // this the maximum width of the tooltip before it starts word-wrapping
 | 
				
			||||||
        setCoord(0, 0, 300, 300);
 | 
					        setCoord(0, 0, 300, 300);
 | 
				
			||||||
| 
						 | 
					@ -472,9 +479,8 @@ namespace MWGui
 | 
				
			||||||
            totalSize.width = std::max(totalSize.width, coord.width);
 | 
					            totalSize.width = std::max(totalSize.width, coord.width);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        if (info.enchant != "")
 | 
					        if (enchant)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            assert(enchant);
 | 
					 | 
				
			||||||
            MyGUI::Widget* enchantArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("",
 | 
					            MyGUI::Widget* enchantArea = mDynamicToolTipBox->createWidget<MyGUI::Widget>("",
 | 
				
			||||||
                MyGUI::IntCoord(padding.left, totalSize.height, 300-padding.left, 300-totalSize.height),
 | 
					                MyGUI::IntCoord(padding.left, totalSize.height, 300-padding.left, 300-totalSize.height),
 | 
				
			||||||
                MyGUI::Align::Stretch);
 | 
					                MyGUI::Align::Stretch);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1143,10 +1143,28 @@ namespace MWRender
 | 
				
			||||||
        std::string enchantmentName = item.getClass().getEnchantment(item);
 | 
					        std::string enchantmentName = item.getClass().getEnchantment(item);
 | 
				
			||||||
        if (enchantmentName.empty())
 | 
					        if (enchantmentName.empty())
 | 
				
			||||||
            return result;
 | 
					            return result;
 | 
				
			||||||
        const ESM::Enchantment* enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName);
 | 
					
 | 
				
			||||||
 | 
					        const ESM::Enchantment* enchantment = NULL;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            enchantment = MWBase::Environment::get().getWorld()->getStore().get<ESM::Enchantment>().find(enchantmentName);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (const std::runtime_error& ex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return result;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        assert (enchantment->mEffects.mList.size());
 | 
					        assert (enchantment->mEffects.mList.size());
 | 
				
			||||||
        const ESM::MagicEffect* magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(
 | 
					
 | 
				
			||||||
 | 
					        const ESM::MagicEffect* magicEffect = NULL;
 | 
				
			||||||
 | 
					        try
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            magicEffect = MWBase::Environment::get().getWorld()->getStore().get<ESM::MagicEffect>().find(
 | 
				
			||||||
                enchantment->mEffects.mList.front().mEffectID);
 | 
					                enchantment->mEffects.mList.front().mEffectID);
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        catch (const std::runtime_error& ex)
 | 
				
			||||||
 | 
					        {
 | 
				
			||||||
 | 
					            return result;
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
        result.x() = magicEffect->mData.mRed / 255.f;
 | 
					        result.x() = magicEffect->mData.mRed / 255.f;
 | 
				
			||||||
        result.y() = magicEffect->mData.mGreen / 255.f;
 | 
					        result.y() = magicEffect->mData.mGreen / 255.f;
 | 
				
			||||||
        result.z() = magicEffect->mData.mBlue / 255.f;
 | 
					        result.z() = magicEffect->mData.mBlue / 255.f;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue