本文整理汇总了C++中CItemContainer::GetParentObj方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemContainer::GetParentObj方法的具体用法?C++ CItemContainer::GetParentObj怎么用?C++ CItemContainer::GetParentObj使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItemContainer
的用法示例。
在下文中一共展示了CItemContainer::GetParentObj方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Cmd_Use_Item
bool CClient::Cmd_Use_Item( CItem *pItem, bool fTestTouch, bool fScript )
{
ADDTOCALLSTACK("CClient::Cmd_Use_Item");
// Assume we can see the target.
// called from Event_DoubleClick
if ( !pItem )
return false;
if ( pItem->m_Can & CAN_I_FORCEDC )
fTestTouch = false;
if ( fTestTouch )
{
if ( !fScript )
{
CItemContainer *pContainer = dynamic_cast<CItemContainer *>(pItem->GetParent());
if ( pContainer )
{
// protect from ,snoop - disallow picking from not opened containers
bool isInOpenedContainer = false;
if ( pContainer->GetType() == IT_EQ_TRADE_WINDOW )
isInOpenedContainer = true;
else
{
CClient::OpenedContainerMap_t::iterator itContainerFound = m_openedContainers.find(pContainer->GetUID().GetPrivateUID());
if ( itContainerFound != m_openedContainers.end() )
{
DWORD dwTopContainerUID = (((*itContainerFound).second).first).first;
DWORD dwTopMostContainerUID = (((*itContainerFound).second).first).second;
CPointMap ptOpenedContainerPosition = ((*itContainerFound).second).second;
const CObjBaseTemplate *pObjTop = pItem->GetTopLevelObj();
const CObjBase *pObjParent = pContainer->GetParentObj();
DWORD dwTopContainerUID_ToCheck = 0;
if ( pObjParent )
dwTopContainerUID_ToCheck = pObjParent->GetUID().GetPrivateUID();
else
dwTopContainerUID_ToCheck = pObjTop->GetUID().GetPrivateUID();
if ( (dwTopMostContainerUID == pObjTop->GetUID().GetPrivateUID()) && (dwTopContainerUID == dwTopContainerUID_ToCheck) )
{
if ( pObjTop->IsChar() )
{
// probably a pickup check from pack if pCharTop != this?
isInOpenedContainer = true;
}
else
{
const CItem *pItemTop = static_cast<const CItem *>(pObjTop);
if ( pItemTop && (pItemTop->IsType(IT_SHIP_HOLD) || pItemTop->IsType(IT_SHIP_HOLD_LOCK)) && (pItemTop->GetTopPoint().GetRegion(REGION_TYPE_MULTI) == m_pChar->GetTopPoint().GetRegion(REGION_TYPE_MULTI)) )
isInOpenedContainer = true;
else if ( ptOpenedContainerPosition.GetDist(pObjTop->GetTopPoint()) <= 3 )
isInOpenedContainer = true;
}
}
}
}
if ( !isInOpenedContainer )
{
SysMessageDefault(DEFMSG_REACH_UNABLE);
return false;
}
}
}
// CanTouch handles priv level compares for chars
if ( !m_pChar->CanUse(pItem, false) )
{
if ( !m_pChar->CanTouch(pItem) )
SysMessage((m_pChar->IsStatFlag(STATF_DEAD)) ? g_Cfg.GetDefaultMsg(DEFMSG_REACH_GHOST) : g_Cfg.GetDefaultMsg(DEFMSG_REACH_FAIL));
else
SysMessageDefault(DEFMSG_REACH_UNABLE);
return false;
}
}
if ( IsTrigUsed(TRIGGER_DCLICK) || IsTrigUsed(TRIGGER_ITEMDCLICK) )
{
if ( pItem->OnTrigger(ITRIG_DCLICK, m_pChar) == TRIGRET_RET_TRUE )
return true;
}
CItemBase *pItemDef = pItem->Item_GetDef();
bool bIsEquipped = pItem->IsItemEquipped();
if ( pItemDef->IsTypeEquippable() && !bIsEquipped && pItemDef->GetEquipLayer() )
{
bool bMustEquip = true;
if ( pItem->IsTypeSpellbook() )
bMustEquip = false;
else if ( (pItem->IsType(IT_LIGHT_OUT) || pItem->IsType(IT_LIGHT_LIT)) && !pItem->IsItemInContainer() )
bMustEquip = false;
if ( bMustEquip )
{
if ( !m_pChar->CanMove(pItem) )
return false;
//.........这里部分代码省略.........