From 2853b56ed599b70fa886f391ac9e4e1a8716ef50 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Thu, 15 Aug 2013 04:52:01 -0700 Subject: [PATCH] Throw an exception when trying to get an empty Ptr's type --- apps/openmw/mwgui/tradeitemmodel.cpp | 41 +++++++++++++++------------- apps/openmw/mwworld/ptr.cpp | 1 - apps/openmw/mwworld/ptr.hpp | 19 +++++-------- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/apps/openmw/mwgui/tradeitemmodel.cpp b/apps/openmw/mwgui/tradeitemmodel.cpp index b4fa4e16f..e836355d3 100644 --- a/apps/openmw/mwgui/tradeitemmodel.cpp +++ b/apps/openmw/mwgui/tradeitemmodel.cpp @@ -146,27 +146,30 @@ namespace MWGui for (size_t i=0; igetItemCount(); ++i) { ItemStack item = mSourceModel->getItem(i); - MWWorld::Ptr base = item.mBase; - if (!mMerchant.isEmpty() && Misc::StringUtils::ciEqual(base.getCellRef().mRefID, "gold_001")) - continue; - if (!mMerchant.isEmpty() && !MWWorld::Class::get(base).canSell(base, services)) - continue; - - // don't show equipped items - if (mMerchant.getTypeName() == typeid(ESM::NPC).name()) + if(!mMerchant.isEmpty()) { - bool isEquipped = false; - MWWorld::InventoryStore& store = MWWorld::Class::get(mMerchant).getInventoryStore(mMerchant); - for (int slot=0; slotmTypeName : sEmptyString; - } - - Ptr (MWWorld::LiveCellRefBase *liveCellRef, CellStore *cell) - : mContainerStore (0) - { - mRef = liveCellRef; - mCell = cell; + if(mRef != 0) + return mRef->mTypeName; + throw std::runtime_error("Can't get type name from an empty object."); } template