本文整理汇总了C++中CItemBase类的典型用法代码示例。如果您正苦于以下问题:C++ CItemBase类的具体用法?C++ CItemBase怎么用?C++ CItemBase使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CItemBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ADDTOCALLSTACK
void CItemSpawn::GenerateItem(CResourceDef *pDef)
{
ADDTOCALLSTACK("CitemSpawn:GenerateItem");
RESOURCE_ID_BASE rid = pDef->GetResourceID();
ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex());
CItemContainer *pCont = dynamic_cast<CItemContainer *>(GetParent());
BYTE iCount = pCont ? static_cast<unsigned char>(pCont->ContentCount(rid)) : GetCount();
if ( iCount >= GetAmount() )
return;
CItem *pItem = CreateTemplate(id);
if ( pItem == NULL )
return;
WORD iAmountPile = static_cast<WORD>(minimum(USHRT_MAX,m_itSpawnItem.m_pile));
if ( iAmountPile > 1 )
{
CItemBase *pItemDef = pItem->Item_GetDef();
ASSERT(pItemDef);
if ( pItemDef->IsStackableType() )
pItem->SetAmount(Calc_GetRandVal(iAmountPile) + 1);
}
pItem->SetAttr(m_Attr & (ATTR_OWNED | ATTR_MOVE_ALWAYS));
pItem->SetDecayTime(g_Cfg.m_iDecay_Item); // it will decay eventually to be replaced later
pItem->MoveNearObj(this, m_itSpawnItem.m_DistMax);
AddObj(pItem->GetUID());
}
示例2: assert
CRootItemIterator& CRootItemIterator::operator++() {
assert( m_pos_stack.size() == (m_base_stack.size() ));
++m_pos;
while( m_pos >= m_base->numChildren() && !m_pos_stack.empty()) {
// go back one in increment that, possibly descending in another leave
m_pos = m_pos_stack.top();
m_pos_stack.pop();
m_base = m_base_stack.top();
m_base_stack.pop();
++m_pos;
}
if( m_pos < m_base->numChildren() ) { // do not ask for m_base->childAt( "too big" ) => that's itertor::end()
CItemBase* item = m_base->childAt(m_pos);
while(item->type() == CItemType::E_CAT) {
m_base_stack.push(m_base);
m_base = reinterpret_cast<CCategoryItem*>(item);
m_pos_stack.push(m_pos);
m_pos = 0;
item = m_base->childAt(m_pos);
}
}
return *this;
}
示例3: ASSERT
int CResource::Calc_CombatAttackSpeed( CChar * pChar, CItem * pWeapon )
{
// Combat: Speed of the attack
// based on dex and weight of the weapon.
// ? my tactics ?
// ? my skill with weapon ?
// ? How much weight i'm carrying ?
// RETURN:
// Time in tenths of a sec. (for entire swing, not just time to hit)
ASSERT(pChar);
if ( pWeapon != NULL )
{
CItemBase * pItemDef = dynamic_cast <CItemBase *> (pWeapon->Base_GetDef());
if ( pItemDef )
{
BYTE speed = pItemDef->GetSpeed();
if ( speed )
{
int iWaitTime = (TICK_PER_SEC * g_Cfg.m_iSpeedScaleFactor) / ( ( pChar->Stat_GetAdjusted(STAT_DEX) + 100 ) * speed );
return (iWaitTime > 5 ? iWaitTime : 5);
}
}
}
if ( pChar->m_pNPC &&
pChar->m_pNPC->m_Brain == NPCBRAIN_GUARD &&
m_fGuardsInstantKill )
return( 1 );
// Base speed is just your DEX range=40 to 0
int iWaitTime = IMULDIV( 100 - pChar->Stat_GetAdjusted(STAT_DEX), 40, 100 );
if ( iWaitTime < 5 ) // no-one needs to be this fast.
iWaitTime = 5;
else
iWaitTime += 5;
// Speed of the weapon as well effected by strength (minor).
if ( pWeapon != NULL )
{
DEBUG_CHECK( pWeapon->IsItemEquipped());
int iWeaponWait = (pWeapon->GetWeight() * 10 ) / ( 4 * WEIGHT_UNITS ); // tenths of a stone.
if ( pWeapon->GetEquipLayer() == LAYER_HAND2 ) // 2 handed is slower
{
iWeaponWait += iWaitTime/2;
}
iWaitTime += iWeaponWait;
}
else
{
iWaitTime += 2;
}
return( iWaitTime );
}
示例4: pt
void CWndShopCtrl::OnDraw(C2DRender* p2DRender)
{
CPoint pt( 3, 3 );
CRect rect = GetClientRect();
for( int i = 0; i < MAX_CART; i++ )
{
int x = i % 6;
int y = i / 6;
CItemBase* pItemBase = m_pItemElem[ i ];
if( pItemBase )
{
if( ((CItemElem*)pItemBase)->IsFlag( CItemElem::expired ) )
pItemBase->GetTexture()->Render2( p2DRender, CPoint( x * 35, y * 35 ), D3DCOLOR_ARGB( 255, 255, 100, 100 ) );
else
pItemBase->GetTexture()->Render( p2DRender, CPoint( x * 35, y * 35 ) );
CRect rectHittest = CRect( x * 35, y * 35 + 3, x * 35 + 35, y * 35 + 35 + 3);
CPoint point = GetMousePoint();
if( rectHittest.PtInRect( point ) )
{
CPoint point2 = point;
ClientToScreen( &point2 );
ClientToScreen( &rectHittest );
g_WndMng.PutToolTip_Item( pItemBase, point2, &rectHittest );
}
CItemElem* pItemElem = (CItemElem*)pItemBase;
if( pItemElem->GetProp()->dwPackMax > 1 )
{
//short n = m_nBuy[i];
//if( IsUsingItem( pItemBase ) )
// n = pItemBase->GetExtra();
short m_nItemNum = pItemElem->m_nItemNum;
if( pItemElem->GetExtra() > 0 )
m_nItemNum -= (short)pItemElem->GetExtra();
TCHAR szTemp[ 35 ];
_stprintf( szTemp, "%d", m_nItemNum );
//_stprintf( szTemp, "%d", n );
CD3DFont* pOldFont = p2DRender->GetFont();//adeilson
p2DRender->SetFont( CWndBase::m_Theme.m_pFontWndNewTitle );
CSize size = m_p2DRender->m_pFont->GetTextExtent( szTemp );
m_p2DRender->TextOut( x * 35 + 35 - size.cx, y * 35 + 35 - size.cy, szTemp, 0xFF000000 );
m_p2DRender->TextOut( x * 35 + 34 - size.cx, y * 35 + 34 - size.cy, szTemp, 0xFF85FF8A );
p2DRender->SetFont( pOldFont );
//_stprintf( szTemp, "%d", n );
//CSize size = p2DRender->m_pFont->GetTextExtent( szTemp );
//p2DRender->TextOut( x * 35 + 35 - size.cx, y * 35 + 35 - size.cy, szTemp, 0xff1010ff );
}
}
}
}
示例5: GetClientRect
void CWndGuildMeritCtrl::OnDraw( C2DRender* p2DRender )
{
if( m_pItemContainer.size() <= 0 )
return;
CRect rect = GetClientRect();
int nWidth = rect.Width() / 32;
int nHeight = rect.Height() / 32;
// 스크롤바 관련
CPoint pt( 0, 0 );
nWidth = 6;
int nPage = nHeight;
int nRange = m_pItemContainer.size() / nWidth;// - nPage;
if( m_pItemContainer.size() % nWidth )
nRange++;
m_wndScrollBar.SetScrollRange( 0, nRange );
m_wndScrollBar.SetScrollPage( nPage );
pt.y = 0;
pt.y += m_wndScrollBar.GetScrollPos() * nWidth;
for( int i = pt.y; i < (int)( m_pItemContainer.size() ); i++ )
{
int x = ( i - pt.x ) % 6;
int y = ( i - pt.y ) / 6;
CItemBase* pItemBase = m_pItemContainer[i];
if( pItemBase )
{
pItemBase->GetTexture()->Render( p2DRender, CPoint( x * 32 + 13, y * 32 + 7 ) );
CRect rectHittest = CRect( x * 32 + 13, y * 32 + 7, x * 32 + 13 + 32, y * 32 + 32 + 7 );
CPoint point = GetMousePoint();
if( rectHittest.PtInRect( point ) )
{
CPoint point2 = point;
ClientToScreen( &point2 );
ClientToScreen( &rectHittest );
g_WndMng.PutToolTip_Item( pItemBase, point2, &rectHittest, APP_VENDOR );
}
if( i == m_nCurSel )
p2DRender->RenderRect( CRect( x * 32 + 7, y * 32 + 11, x * 32 + 32 + 5, y * 32 + 32 + 9 ), 0xff00ffff );
CItemElem* pItemElem = (CItemElem*)pItemBase;
if( pItemElem->GetProp()->dwPackMax > 1 )
{
short nItemNum = pItemBase->GetExtra();
TCHAR szTemp[32];
_stprintf( szTemp, "%d", nItemNum );
CSize size = p2DRender->m_pFont->GetTextExtent( szTemp );
p2DRender->TextOut( x * 32 + 32 - size.cx + 17, y * 32 + 32 - size.cy + 10, szTemp, 0xff1010ff );
}
}
}
}
示例6: qDebug
void CRenderClientsListView::performDrag()
{
qDebug() << QString("performDrag");
CRenderClientsListModel* lmodel = reinterpret_cast<CRenderClientsListModel*>(model());
QModelIndexList indexList = selectedIndexes();
CModelDiff md(m_role);
for(int i = 0; i < indexList.size(); i++)
{
comb_hash_t combhash;
CItemBase* item = lmodel->itemFromIndex(indexList.at(i));
switch(item->type()) {
case CItemType::E_STREAM_CLIENT:
{
CStreamClientItem* scItem = reinterpret_cast<CStreamClientItem*>(item);
combhash.type = scItem->type();
if(m_role == E_OWN_RENDER_CLIENT) {
int filteredline = lmodel->own2availIndex(indexList.at(i).row());
combhash.line = filteredline;
}
else {
combhash.line = indexList.at(i).row();
}
md.appendToSelectedItems(combhash);
}
default:
break;
}
}
if (md.getNumSelected() > 0)
{
QMimeData *mimeData = new QMimeData;
//mimeData->setText(item->asString());
mimeData->setData(dndMimeType, md.toQByteArray());
m_dragActive = true;
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
// drag->setPixmap(QPixmap(":/images/person.png"));
Qt::DropAction action = drag->exec(Qt::MoveAction);
m_dragActive = false;
qDebug() << QString("DropAction: %1").arg(action);
}
}
示例7: ADDTOCALLSTACK
LONG CItemVendable::GetVendorPrice( int iConvertFactor )
{
ADDTOCALLSTACK("CItemVendable::GetVendorPrice");
// Player is buying/selling from a vendor.
// ASSUME this item is on the vendor !
// Consider: (if not on a player vendor)
// Quality of the item.
// rareity of the item.
// ARGS:
// iConvertFactor will consider:
// Vendors Karma.
// Players Karma
// -100 = reduce price by 100% (player selling to vendor?)
// 0 = base price
// +100 = increase price by 100% (vendor selling to player?)
INT64 lPrice = m_price;
if ( lPrice <= 0 ) // set on player vendor.
{
if ( lPrice == 0 ) // set a new randomized price for the item
{
CItemBase * pItemDef;
if ( IsType( IT_DEED ))
{
// Deeds just represent the item they are deeding.
pItemDef = CItemBase::FindItemBase(static_cast<ITEMID_TYPE>(RES_GET_INDEX(m_itDeed.m_Type)));
if ( pItemDef == NULL )
return( 1 );
}
else
{
pItemDef = Item_GetDef();
}
lPrice = pItemDef->GetMakeValue(GetQuality());
m_price = static_cast<long>(-lPrice);
}
else
{
lPrice = -lPrice;
}
}
lPrice += IMULDIV( lPrice, maximum(iConvertFactor, -100), 100 );
if (lPrice > LONG_MAX)
return LONG_MAX;
else if (lPrice <= 0)
return 0;
return static_cast<long>(lPrice);
}
示例8: qDebug
void CPlaylistView::performDrag()
{
qDebug() << QString("performDrag");
CMuroaListModel* plModel = reinterpret_cast<CMuroaListModel*>(model());
QModelIndexList indexList = selectedIndexes();
CModelDiff md(m_role);
for(int i = 0; i < indexList.size(); i++)
{
comb_hash_t combhash;
CItemBase* item = plModel->itemFromIndex(indexList.at(i));
switch(item->type()) {
case CItemType::E_PLAYLISTITEM:
{
CPlaylistItem* plitem = reinterpret_cast<CPlaylistItem*>(item);
combhash.type = plitem->type();
combhash.hash = plitem->getMediaItemHash();
combhash.pl_id = plitem->getHash();
combhash.line = indexList.at(i).row();
md.appendToSelectedItems(combhash);
break;
}
default:
// error, there should only be playlist items in the playlist.
break;
}
}
if (md.getNumSelected() > 0)
{
QMimeData *mimeData = new QMimeData;
//mimeData->setText(item->asString());
mimeData->setData("application/x-muroa-playlist-diff", md.toQByteArray());
m_dragActive = true;
QDrag *drag = new QDrag(this);
drag->setMimeData(mimeData);
// drag->setPixmap(QPixmap(":/images/person.png"));
Qt::DropAction action = drag->exec(Qt::MoveAction);
m_dragActive = false;
qDebug() << QString("DropAction: %1").arg(action);
}
}
示例9: m_base
CRootItemIterator::CRootItemIterator(CCategoryItem* base, int pos) : m_base(base),
m_pos(pos),
m_base_stack(),
m_pos_stack()
{
if(m_pos == 0) {
if(m_base->numChildren() > 0) {
CItemBase* item = m_base->childAt(0);
while(item->type() == CItemType::E_CAT) {
m_base_stack.push(m_base);
m_base = reinterpret_cast<CCategoryItem*>(item);
m_pos_stack.push(0);
item = m_base->childAt(0);
}
}
}
}
示例10: ADDTOCALLSTACK
void CItemSpawn::GenerateItem(CResourceDef * pDef)
{
ADDTOCALLSTACK("CitemSpawn:GenerateItem");
RESOURCE_ID_BASE rid = pDef->GetResourceID();
ITEMID_TYPE id = static_cast<ITEMID_TYPE>(rid.GetResIndex());
int iDistMax = m_itSpawnItem.m_DistMax;
int iAmountPile = m_itSpawnItem.m_pile;
int iCount = 0;
CItemContainer * pCont = dynamic_cast <CItemContainer *>( GetParent());
if ( pCont != NULL )
iCount = pCont->ContentCount( rid );
else
iCount = GetCount();
if ( iCount >= GetAmount())
return;
CItem * pItem = CreateTemplate( id );
if ( pItem == NULL )
return;
pItem->SetAttr( m_Attr & ( ATTR_OWNED | ATTR_MOVE_ALWAYS ));
if ( iAmountPile > 1 )
{
CItemBase * pItemDef = pItem->Item_GetDef();
ASSERT(pItemDef);
if ( pItemDef->IsStackableType())
{
if ( iAmountPile == 0 || iAmountPile > GetAmount())
iAmountPile = GetAmount();
pItem->SetAmount( Calc_GetRandVal(iAmountPile) + 1 );
}
}
pItem->SetDecayTime( g_Cfg.m_iDecay_Item ); // It will decay eventually to be replaced later.
pItem->MoveNearObj( this, iDistMax );
AddObj(pItem->GetUID());
pItem->m_uidSpawnItem = GetUID();
}
示例11: pt
void CWndVendorCtrl::OnMouseMove( UINT nFlags, CPoint point )
{
if( m_bDrag == FALSE )
return;
m_bDrag = FALSE;
CPoint pt( 3, 3 );
CRect rect;
CItemBase* pItemBase = m_pFocusItem;
if( IsUsingItem( pItemBase ) )
{
m_GlobalShortcut.m_pFromWnd = this;
m_GlobalShortcut.m_dwShortcut = SHORTCUT_ITEM;
m_GlobalShortcut.m_dwIndex = m_nCurSel;
m_GlobalShortcut.m_dwType = 0;
m_GlobalShortcut.m_dwId = pItemBase->m_dwObjId;
m_GlobalShortcut.m_pTexture = pItemBase->GetTexture();
m_GlobalShortcut.m_dwData = (DWORD)pItemBase;
_tcscpy( m_GlobalShortcut.m_szString, pItemBase->GetProp()->szName );
}
}
示例12: assert
void CWndSelectAwakeCase::SetData( BYTE byObjID, DWORD dwSerialNum, __int64 n64NewOption )
{
//server로 전송할 데이터를 유지하고, 아이템 Index를 뽑아서 아이콘을 그려줄 준비
m_byObjID = byObjID;
m_dwSerialNum = dwSerialNum;
m_n64NewOption = n64NewOption;
if( !g_pPlayer )
{
assert( 0 );
return;
}
CItemBase* pItemBase = g_pPlayer->GetItemId( m_byObjID );
if( pItemBase )
{
ItemProp* pProp = pItemBase->GetProp( );
if(pProp)
m_dwItemIndex = pProp->dwID;
}
}
示例13: ADDTOCALLSTACK
bool CRegionResourceDef::r_WriteVal( LPCTSTR pszKey, CGString & sVal, CTextConsole * pSrc )
{
ADDTOCALLSTACK("CRegionResourceDef::r_WriteVal");
EXC_TRY("r_WriteVal");
// RES_REGIONRESOURCE
switch ( FindTableSorted( pszKey, sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
{
case RMC_AMOUNT:
sVal = m_Amount.Write();
break;
case RMC_REAP: // "REAP",
{
CItemBase * pItemDef = CItemBase::FindItemBase(m_ReapItem);
if ( !pItemDef )
{
return false;
}
sVal = pItemDef->GetResourceName();
} break;
case RMC_REAPAMOUNT:
sVal = m_ReapAmount.Write();
break;
case RMC_REGEN:
sVal = m_iRegenerateTime.Write();
break;
case RMC_SKILL:
sVal = m_Skill.Write();
break;
default:
return( CResourceDef::r_WriteVal( pszKey, sVal, pSrc ));
}
return true;
EXC_CATCH;
EXC_DEBUG_START;
EXC_ADD_KEYRET(pSrc);
EXC_DEBUG_END;
return false;
}
示例14: ADDTOCALLSTACK
bool CItemVendable::IsValidNPCSaleItem() const
{
ADDTOCALLSTACK("CItemVendable::IsValidNPCSaleItem");
// This item is in an NPC's vendor box.
// Is it a valid item that NPC's should be selling ?
CItemBase * pItemDef = Item_GetDef();
if ( m_price <= 0 && pItemDef->GetMakeValue(0) <= 0 )
{
DEBUG_ERR(( "Vendor uid=0%lx selling unpriced item %s='%s'\n", static_cast<DWORD>(GetTopLevelObj()->GetUID()), GetResourceName(), GetName()));
return( false );
}
if ( ! IsValidSaleItem( true ))
{
DEBUG_ERR(( "Vendor uid=0%lx selling bad item %s='%s'\n", static_cast<DWORD>(GetTopLevelObj()->GetUID()), GetResourceName(), GetName()));
return( false );
}
return( true );
}
示例15: ADDTOCALLSTACK
bool CPointBase::r_WriteVal( LPCTSTR pszKey, CGString & sVal ) const
{
ADDTOCALLSTACK("CPointBase::r_WriteVal");
if ( !strnicmp( pszKey, "STATICS", 7 ) )
{
pszKey += 7;
const CGrayMapBlock * pBlock = g_World.GetMapBlock( *(this) );
if ( !pBlock ) return false;
if ( *pszKey == '\0' )
{
int iStaticQty = 0;
for ( size_t i = 0; i < pBlock->m_Statics.GetStaticQty(); i++ )
{
const CUOStaticItemRec * pStatic = pBlock->m_Statics.GetStatic( i );
CPointMap ptTest( pStatic->m_x+pBlock->m_x, pStatic->m_y+pBlock->m_y, pStatic->m_z, this->m_map );
if ( this->GetDist( ptTest ) > 0 )
continue;
iStaticQty++;
}
sVal.FormatVal( iStaticQty );
return true;
}
SKIP_SEPARATORS( pszKey );
const CUOStaticItemRec * pStatic = NULL;
int iStatic = 0;
int type = 0;
if ( !strnicmp( pszKey, "FINDID", 6 ) )
{
pszKey += 6;
SKIP_SEPARATORS( pszKey );
iStatic = Exp_GetVal( pszKey );
type = RES_GET_TYPE( iStatic );
if ( type == 0 )
type = RES_ITEMDEF;
SKIP_SEPARATORS( pszKey );
}
else
{
iStatic = Exp_GetVal( pszKey );
type = RES_GET_TYPE( iStatic );
}
if ( type == RES_ITEMDEF )
{
const CItemBase * pItemDef = CItemBase::FindItemBase(static_cast<ITEMID_TYPE>(RES_GET_INDEX(iStatic)));
if ( !pItemDef )
{
sVal.FormatVal( 0 );
return false;
}
for ( size_t i = 0; i < pBlock->m_Statics.GetStaticQty(); pStatic = NULL, i++ )
{
pStatic = pBlock->m_Statics.GetStatic( i );
CPointMap ptTest( pStatic->m_x+pBlock->m_x, pStatic->m_y+pBlock->m_y, pStatic->m_z, this->m_map);
if ( this->GetDist( ptTest ) > 0 )
continue;
if ( pStatic->GetDispID() == pItemDef->GetDispID() )
break;
}
}
else
{
for ( size_t i = 0; i < pBlock->m_Statics.GetStaticQty(); pStatic = NULL, i++ )
{
pStatic = pBlock->m_Statics.GetStatic( i );
CPointMap ptTest( pStatic->m_x+pBlock->m_x, pStatic->m_y+pBlock->m_y, pStatic->m_z, this->m_map);
if ( this->GetDist( ptTest ) > 0 )
continue;
if ( iStatic == 0 )
break;
iStatic--;
}
}
if ( !pStatic )
{
sVal.FormatHex(0);
return true;
}
SKIP_SEPARATORS( pszKey );
if ( !*pszKey )
pszKey = "ID";
ITEMID_TYPE idTile = pStatic->GetDispID();
if ( !strnicmp( pszKey, "COLOR", 5 ) )
{
sVal.FormatHex( pStatic->m_wHue );
return true;
}
else if ( !strnicmp( pszKey, "ID", 2 ) )
{
sVal.FormatHex( idTile );
return true;
//.........这里部分代码省略.........