本文整理汇总了C++中CItem::GetNext方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::GetNext方法的具体用法?C++ CItem::GetNext怎么用?C++ CItem::GetNext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::GetNext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GoAwake
void CSector::GoAwake()
{
ADDTOCALLSTACK("CSector::GoAwake");
ProfileTask charactersTask(PROFILE_TIMERS);
CTimedObject::GoAwake(); // Awake it first, otherwise other things won't work.
CChar * pCharNext = nullptr;
CChar * pChar = static_cast <CChar*>(m_Chars_Active.GetHead());
for (; pChar != nullptr; pChar = pCharNext)
{
pCharNext = pChar->GetNext();
if (pChar->IsSleeping())
pChar->GoAwake();
}
pChar = static_cast<CChar*>(m_Chars_Disconnect.GetHead());
for (; pChar != nullptr; pChar = pCharNext)
{
pCharNext = pChar->GetNext();
if (pChar->IsSleeping())
pChar->GoAwake();
}
CItem * pItemNext = nullptr;
CItem * pItem = static_cast <CItem*>(m_Items_Timer.GetHead());
for (; pItem != nullptr; pItem = pItemNext)
{
pItemNext = pItem->GetNext();
if (pItem->IsSleeping())
pItem->GoAwake();
}
pItem = static_cast <CItem*>(m_Items_Inert.GetHead());
for (; pItem != nullptr; pItem = pItemNext)
{
pItemNext = pItem->GetNext();
if (pItem->IsSleeping())
pItem->GoAwake();
}
/*
* Awake adjacent sectors when awaking this one to avoid the effect
* of NPCs being stop until you enter the sector, or all the spawns
* generating NPCs at once.
*/
static CSector *pCentral = nullptr; // do this only for the awaken sector
if (!pCentral)
{
pCentral = this;
for (int i = 0; i < (int)DIR_QTY; ++i)
{
CSector *pSector = GetAdjacentSector((DIR_TYPE)i);
if (pSector && !pSector->IsSleeping())
{
pSector->GoAwake();
}
}
pCentral = nullptr;
}
OnTick(); // Unknown time passed, make the sector tick now to reflect any possible environ changes.
}
示例2: GoSleep
void CSector::GoSleep()
{
ADDTOCALLSTACK("CSector::Sleep");
ProfileTask charactersTask(PROFILE_TIMERS);
CTimedObject::GoSleep();
CChar * pCharNext = nullptr;
CChar * pChar = static_cast <CChar*>(m_Chars_Active.GetHead());
for (; pChar != nullptr; pChar = pCharNext)
{
pCharNext = pChar->GetNext();
if (!pChar->IsSleeping())
pChar->GoSleep();
}
CItem * pItemNext = nullptr;
CItem * pItem = static_cast <CItem*>(m_Items_Timer.GetHead());
for (; pItem != nullptr; pItem = pItemNext)
{
pItemNext = pItem->GetNext();
if (!pItem->IsSleeping())
pItem->GoSleep();
}
pItemNext = nullptr;
pItem = static_cast <CItem*>(m_Items_Inert.GetHead());
for (; pItem != nullptr; pItem = pItemNext)
{
pItemNext = pItem->GetNext();
if (!pItem->IsSleeping())
pItem->GoSleep();
}
}
示例3: NPC_StablePetRetrieve
bool CChar::NPC_StablePetRetrieve( CChar * pCharPlayer )
{
ADDTOCALLSTACK("CChar::NPC_StablePetRetrieve");
// Get pets for this person from my inventory.
// May want to put up a menu ???
if ( !m_pNPC || m_pNPC->m_Brain != NPCBRAIN_STABLE )
return false;
int iCount = 0;
CItem *pItemNext = NULL;
for ( CItem *pItem = GetBank()->GetContentHead(); pItem != NULL; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
if ( pItem->IsType(IT_FIGURINE) && pItem->m_uidLink == pCharPlayer->GetUID() )
{
if ( !pCharPlayer->Use_Figurine(pItem) )
{
tchar *pszTemp = Str_GetTemp();
sprintf(pszTemp, g_Cfg.GetDefaultMsg(DEFMSG_NPC_STABLEMASTER_CLAIM_FOLLOWER), pItem->GetName());
Speak(pszTemp);
return true;
}
pItem->Delete();
iCount++;
}
}
Speak(g_Cfg.GetDefaultMsg((iCount > 0) ? DEFMSG_NPC_STABLEMASTER_CLAIM : DEFMSG_NPC_STABLEMASTER_CLAIM_NOPETS));
return true;
}
示例4: ItemEquipWeapon
bool CChar::ItemEquipWeapon( bool fForce )
{
ADDTOCALLSTACK("CChar::ItemEquipWeapon");
// Find my best weapon and equip it
if ( !fForce && m_uidWeapon.IsValidUID() ) // we already have a weapon equipped
return true;
CCharBase *pCharDef = Char_GetDef();
CItemContainer *pPack = GetPack();
if ( !pPack || !pCharDef || !pCharDef->Can(CAN_C_USEHANDS) )
return false;
// Loop through all my weapons and come up with a score for it's usefulness
CItem *pBestWeapon = NULL;
int iWeaponScoreMax = NPC_GetWeaponUseScore(NULL); // wrestling
for ( CItem *pItem = pPack->GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
{
int iWeaponScore = NPC_GetWeaponUseScore(pItem);
if ( iWeaponScore > iWeaponScoreMax )
{
iWeaponScoreMax = iWeaponScore;
pBestWeapon = pItem;
}
}
if ( pBestWeapon )
return ItemEquip(pBestWeapon);
return true;
}
示例5: Restock
void CSector::Restock()
{
ADDTOCALLSTACK("CSector::Restock");
// ARGS: iTime = time in seconds
// set restock time of all vendors in Sector.
// set the respawn time of all spawns in Sector.
CChar * pCharNext;
CChar * pChar = dynamic_cast <CChar*>( m_Chars_Active.GetHead());
for ( ; pChar; pChar = pCharNext )
{
pCharNext = pChar->GetNext();
pChar->NPC_Vendor_Restock(true);
}
CItem * pItemNext;
CItem * pItem = dynamic_cast <CItem*>( m_Items_Timer.GetHead());
for ( ; pItem; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
if (pItem->IsType(IT_SPAWN_ITEM) || pItem->IsType(IT_SPAWN_CHAR))
{
static_cast<CItemSpawn*>(pItem)->OnTick(true);
}
}
}
示例6: RaiseCorpse
// We are creating a char from the current char and the corpse.
// Move the items from the corpse back onto us.
bool CChar::RaiseCorpse( CItemCorpse * pCorpse )
{
ADDTOCALLSTACK("CChar::RaiseCorpse");
if ( !pCorpse )
return false;
if ( pCorpse->GetCount() > 0 )
{
CItemContainer *pPack = GetPackSafe();
CItem *pItemNext = NULL;
for ( CItem *pItem = pCorpse->GetContentHead(); pItem != NULL; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
if ( pItem->IsType(IT_HAIR) || pItem->IsType(IT_BEARD) ) // hair on corpse was copied!
continue;
if ( pItem->GetContainedLayer() )
ItemEquip(pItem);
else if ( pPack )
pPack->ContentAdd(pItem);
}
pCorpse->ContentsDump( GetTopPoint()); // drop left items on ground
}
UpdateAnimate((pCorpse->m_itCorpse.m_facing_dir & 0x80) ? ANIM_DIE_FORWARD : ANIM_DIE_BACK, true, true);
pCorpse->Delete();
return true;
}
示例7: OnContTriggerForLoop
TRIGRET_TYPE CContainer::OnContTriggerForLoop( CScript &s, CTextConsole * pSrc, CScriptTriggerArgs * pArgs, CGString * pResult, CScriptLineContext & StartContext, CScriptLineContext & EndContext, RESOURCE_ID_BASE rid, DWORD dwArg, int iDecendLevels )
{
ADDTOCALLSTACK("CContainer::OnContTriggerForLoop");
if ( rid.GetResIndex() != 0 )
{
CItem* pItem = GetContentHead();
CItem * pItemNext;
for ( ; pItem!=NULL; pItem=pItemNext)
{
pItemNext = pItem->GetNext();
if ( pItem->IsResourceMatch( rid, dwArg ))
{
s.SeekContext( StartContext );
TRIGRET_TYPE iRet = pItem->OnTriggerRun( s, TRIGRUN_SECTION_TRUE, pSrc, pArgs, pResult );
if ( iRet == TRIGRET_BREAK )
{
EndContext = StartContext;
break;
}
if (( iRet != TRIGRET_ENDIF ) && ( iRet != TRIGRET_CONTINUE ))
return( iRet );
if ( iRet == TRIGRET_CONTINUE )
EndContext = StartContext;
else
EndContext = s.GetContext();
}
if ( iDecendLevels <= 0 )
continue;
CItemContainer * pCont = dynamic_cast <CItemContainer*>(pItem);
if ( pCont != NULL )
{
if ( pCont->IsSearchable())
{
CContainer * pContBase = dynamic_cast <CContainer *> (pCont);
TRIGRET_TYPE iRet = pContBase->OnContTriggerForLoop( s, pSrc, pArgs, pResult, StartContext, EndContext, rid, dwArg, iDecendLevels-1 );
if ( iRet != TRIGRET_ENDIF )
{
return( iRet );
}
// Since the previous call has already found the EndContext, set it.
EndContext = s.GetContext();
}
}
}
}
if ( EndContext.m_lOffset <= StartContext.m_lOffset )
{
CScriptObj * pScript = dynamic_cast <CScriptObj *> (this);
TRIGRET_TYPE iRet = pScript->OnTriggerRun( s, TRIGRUN_SECTION_FALSE, pSrc, pArgs, pResult );
if ( iRet != TRIGRET_ENDIF )
return( iRet );
}
else
s.SeekContext( EndContext );
return( TRIGRET_ENDIF );
}
示例8: r_WriteValContainer
bool CContainer::r_WriteValContainer(LPCTSTR pszKey, CGString & sVal, CTextConsole *pSrc)
{
ADDTOCALLSTACK("CContainer::r_WriteValContainer");
EXC_TRY("WriteVal");
static LPCTSTR const sm_szParams[] =
{
"count",
"fcount",
"rescount",
"restest"
};
int i = FindTableHeadSorted(pszKey, sm_szParams, COUNTOF(sm_szParams));
if ( i < 0 )
return false;
LPCTSTR pKey = pszKey + strlen(sm_szParams[i]);
SKIP_SEPARATORS(pKey);
switch ( i )
{
case 0: // count
{
int iTotal = 0;
for ( CItem* pItem = GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
iTotal++;
sVal.FormatVal(iTotal);
} break;
case 1: // fcount
sVal.FormatVal(ContentCountAll());
break;
case 2: // rescount
sVal.FormatVal(*pKey ? ContentCount(g_Cfg.ResourceGetID(RES_ITEMDEF, pKey)) : GetCount());
break;
case 3: // restest
{
CResourceQtyArray Resources;
sVal.FormatVal(Resources.Load(pKey) ? ResourceConsume(&Resources, 1, true) : 0);
} break;
default:
return false;
}
return true;
EXC_CATCH;
EXC_DEBUG_START;
EXC_ADD_KEYRET(pSrc);
EXC_DEBUG_END;
return false;
}
示例9: OnHearItem
void CSector::OnHearItem( CChar * pChar, lpctstr pszText )
{
ADDTOCALLSTACK("CSector::OnHearItem");
// report to any of the items that something was said.
ASSERT(m_ListenItems);
CItem * pItemNext;
CItem * pItem = static_cast <CItem*>( m_Items_Timer.GetHead());
for ( ; pItem != nullptr; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
pItem->OnHear( pszText, pChar );
}
pItem = static_cast <CItem*>( m_Items_Inert.GetHead());
for ( ; pItem != nullptr; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
pItem->OnHear( pszText, pChar );
}
}
示例10: OnHearItem
void CSector::OnHearItem( CChar * pChar, TCHAR * szText )
{
ADDTOCALLSTACK("CSector::OnHearItem");
// report to any of the items that something was said.
ASSERT(m_ListenItems);
CItem * pItemNext;
CItem * pItem = STATIC_CAST <CItem*>( m_Items_Timer.GetHead());
for ( ; pItem != NULL; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
pItem->OnHear( szText, pChar );
}
pItem = STATIC_CAST <CItem*>( m_Items_Inert.GetHead());
for ( ; pItem != NULL; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
pItem->OnHear( szText, pChar );
}
}
示例11: ItemEquipArmor
bool CChar::ItemEquipArmor( bool fForce )
{
ADDTOCALLSTACK("CChar::ItemEquipArmor");
// Equip ourselves as best as possible.
CCharBase *pCharDef = Char_GetDef();
CItemContainer *pPack = GetPack();
if ( !pPack || !pCharDef || !pCharDef->Can(CAN_C_EQUIP) )
return false;
int iBestScore[LAYER_HORSE];
memset(iBestScore, 0, sizeof(iBestScore));
CItem *pBestArmor[LAYER_HORSE];
memset(pBestArmor, 0, sizeof(pBestArmor));
if ( !fForce )
{
// Block those layers that are already used
for ( size_t i = 0; i < COUNTOF(iBestScore); i++ )
{
pBestArmor[i] = LayerFind(static_cast<LAYER_TYPE>(i));
if ( pBestArmor[i] != NULL )
iBestScore[i] = INT_MAX;
}
}
for ( CItem *pItem = pPack->GetContentHead(); pItem != NULL; pItem = pItem->GetNext() )
{
int iScore = pItem->Armor_GetDefense();
if ( !iScore ) // might not be armor
continue;
// Can I even equip this?
LAYER_TYPE layer = CanEquipLayer(pItem, LAYER_QTY, NULL, true);
if ( layer == LAYER_NONE )
continue;
if ( iScore > iBestScore[layer] )
{
iBestScore[layer] = iScore;
pBestArmor[layer] = pItem;
}
}
// Equip all the stuff we found
for ( size_t i = 0; i < COUNTOF(iBestScore); i++ )
{
if ( pBestArmor[i] )
ItemEquip(pBestArmor[i], this);
}
return true;
}
示例12: r_WriteContent
void CContainer::r_WriteContent( CScript & s ) const
{
ADDTOCALLSTACK("CContainer::r_WriteContent");
ASSERT(dynamic_cast<const CGObList *>(this) != NULL);
// Write out all the items in me.
CItem* pItemNext;
for ( CItem* pItem = GetContentHead(); pItem != NULL; pItem = pItemNext)
{
pItemNext = pItem->GetNext();
ASSERT( pItem->GetParent() == this );
pItem->r_WriteSafe(s);
}
}
示例13: NPC_PetClearOwners
void CChar::NPC_PetClearOwners(bool bResendTooltip)
{
ADDTOCALLSTACK("CChar::NPC_PetClearOwners");
CChar *pOwner = NPC_PetGetOwner();
Memory_ClearTypes(MEMORY_IPET|MEMORY_FRIEND);
if ( m_pNPC )
m_pNPC->m_bonded = 0; // pets without owner cannot be bonded
if ( NPC_IsVendor() )
{
StatFlag_Clear(STATF_INVUL);
if ( pOwner ) // give back to NPC owner all the stuff we are trying to sell
{
CItemContainer *pBankVendor = GetContainerCreate(LAYER_BANKBOX);
CItemContainer *pBankOwner = pOwner->GetContainerCreate(LAYER_BANKBOX);
pOwner->AddGoldToPack(pBankVendor->m_itEqBankBox.m_Check_Amount, pBankOwner);
pBankVendor->m_itEqBankBox.m_Check_Amount = 0;
for ( size_t i = 0; i < COUNTOF(sm_VendorLayers); i++ )
{
CItemContainer *pCont = GetContainerCreate(sm_VendorLayers[i]);
if ( !pCont )
continue;
CItem *pItemNext = NULL;
for ( CItem *pItem = pCont->GetContentHead(); pItem != NULL; pItem = pItemNext )
{
pItemNext = pItem->GetNext();
pBankOwner->ContentAdd(pItem);
}
}
}
}
if ( IsStatFlag(STATF_Ridden) )
{
CChar *pCharRider = Horse_GetMountChar();
if ( pCharRider )
pCharRider->Horse_UnMount();
}
if ( pOwner )
{
if ( IsSetOF(OF_PetSlots) )
pOwner->FollowersUpdate(this, static_cast<short>(-maximum(1, GetDefNum("FOLLOWERSLOTS", true))));
if ( bResendTooltip )
ResendTooltip();
}
}
示例14: Trade_Delete
void CItemContainer::Trade_Delete()
{
ADDTOCALLSTACK("CItemContainer::Trade_Delete");
// Called when object deleted.
ASSERT( IsType(IT_EQ_TRADE_WINDOW) );
CChar * pChar = dynamic_cast <CChar*> (GetParent());
if ( pChar == NULL )
return;
if ( pChar->IsClient())
{
// Send the cancel trade message.
PacketTradeAction cmd(SECURE_TRADE_CLOSE);
cmd.prepareClose(this);
cmd.send(pChar->GetClient());
}
// Drop items back in my pack.
CItem * pItemNext;
for ( CItem* pItem = GetContentHead(); pItem!=NULL; pItem=pItemNext)
{
pItemNext = pItem->GetNext();
pChar->ItemBounce( pItem );
}
// Kill my trading partner.
CItemContainer * pPartner = dynamic_cast <CItemContainer *> ( m_uidLink.ItemFind());
if ( pPartner == NULL )
return;
if ( IsTrigUsed(TRIGGER_TRADECLOSE) )
{
CChar * pChar2 = dynamic_cast <CChar*> (pPartner->GetParent());
CScriptTriggerArgs Args( pChar2 );
pChar->OnTrigger( CTRIG_TradeClose, pChar , &Args );
CScriptTriggerArgs Args2( pChar );
pChar2->OnTrigger( CTRIG_TradeClose, pChar, &Args2);
}
m_uidLink.InitUID(); // unlink.
pPartner->m_uidLink.InitUID();
pPartner->Delete();
}
示例15: ContentNotifyDelete
void CContainer::ContentNotifyDelete()
{
ADDTOCALLSTACK("CContainer::ContentNotifyDelete");
if ( IsTrigUsed(TRIGGER_DESTROY) ) // no point entering this loop if the trigger is disabled
return;
// trigger @Destroy on contained items
CItem *pItemNext = NULL;
for (CItem *pItem = GetContentHead(); pItem != NULL; pItem = pItemNext)
{
pItemNext = pItem->GetNext();
if ( pItem->NotifyDelete() == false )
{
// item shouldn't be destroyed and so cannot remain in this container,
// drop it to the ground if it hasn't been moved already
if (pItem->GetParent() == this)
pItem->MoveToCheck( pItem->GetTopLevelObj()->GetTopPoint() );
}
}
}