本文整理汇总了C++中CItemBase::GetID方法的典型用法代码示例。如果您正苦于以下问题:C++ CItemBase::GetID方法的具体用法?C++ CItemBase::GetID怎么用?C++ CItemBase::GetID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItemBase
的用法示例。
在下文中一共展示了CItemBase::GetID方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetHeightPoint
void CWorld::GetHeightPoint( const CPointMap & pt, CGrayMapBlockState & block, bool fHouseCheck )
{
ADDTOCALLSTACK("CWorld::GetHeightPoint");
CItemBase * pItemDef = NULL;
CItemBaseDupe * pDupeDef = NULL;
CItem * pItem = NULL;
DWORD wBlockThis = 0;
signed char z = 0;
height_t zHeight = 0;
int x2 = 0, y2 = 0;
// Height of statics at/above given coordinates
// do gravity here for the z.
const CGrayMapBlock * pMapBlock = GetMapBlock( pt );
if (pMapBlock == NULL)
return;
size_t iQty = pMapBlock->m_Statics.GetStaticQty();
if ( iQty > 0 ) // no static items here.
{
x2 = pMapBlock->GetOffsetX(pt.m_x);
y2 = pMapBlock->GetOffsetY(pt.m_y);
const CUOStaticItemRec * pStatic = NULL;
for ( size_t i = 0; i < iQty; ++i, z = 0, zHeight = 0, pStatic = NULL, pDupeDef = NULL )
{
if ( ! pMapBlock->m_Statics.IsStaticPoint( i, x2, y2 ))
continue;
pStatic = pMapBlock->m_Statics.GetStatic( i );
if ( pStatic == NULL )
continue;
z = pStatic->m_z;
//DEBUG_ERR(("z (%d) block.m_zHeight (%d) block.m_Bottom.m_z (%d)\n",z,block.m_zHeight,block.m_Bottom.m_z));
if ( ! block.IsUsableZ( z, block.m_zHeight ))
continue;
// This static is at the coordinates in question.
// enough room for me to stand here ?
pItemDef = CItemBase::FindItemBase( pStatic->GetDispID() );
if ( pItemDef )
{
//DEBUG_ERR(("pItemDef->GetID(0%x) pItemDef->GetDispID(0%x) pStatic->GetDispID(0%x)\n",pItemDef->GetID(),pItemDef->GetDispID(),pStatic->GetDispID()));
if ( pItemDef->GetID() == pStatic->GetDispID() ) //parent item
{
zHeight = pItemDef->GetHeight();
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK ); //Use only Block flags, other remove
}
else //non-parent item
{
pDupeDef = CItemBaseDupe::GetDupeRef(static_cast<ITEMID_TYPE>(pStatic->GetDispID()));
if ( ! pDupeDef )
{
g_Log.EventDebug("Failed to get non-parent reference (static) (DispID 0%x) (X: %d Y: %d Z: %d)\n",pStatic->GetDispID(),pStatic->m_x+pMapBlock->m_x,pStatic->m_y+pMapBlock->m_y,pStatic->m_z);
zHeight = pItemDef->GetHeight();
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK );
}
else
{
zHeight = pDupeDef->GetHeight();
wBlockThis = ( pDupeDef->m_Can & CAN_I_MOVEMASK ); //Use only Block flags, other remove - CAN flags cannot be inherited from the parent item due to bad script pack...
}
}
}
else if ( pStatic->GetDispID() )
CItemBase::GetItemTiledataFlags(wBlockThis,pStatic->GetDispID());
block.CheckTile_Item( wBlockThis, z, zHeight, pStatic->GetDispID() + TERRAIN_QTY );
}
}
pItemDef = NULL;
pDupeDef = NULL;
pItem = NULL;
wBlockThis = 0;
z = 0;
zHeight = 0;
x2 = y2 = 0;
iQty = 0;
// Any multi items here ?
// Check all of them
if ( fHouseCheck )
{
CRegionLinks rlinks;
size_t iRegionQty = pt.GetRegions( REGION_TYPE_MULTI, rlinks );
if ( iRegionQty > 0 )
{
// ------------ For variables --------------------
CRegionBase * pRegion = NULL;
const CGrayMulti * pMulti = NULL;
const CUOMultiItemRec2 * pMultiItem = NULL;
x2 = 0;
y2 = 0;
// ------------ For variables --------------------
for ( size_t iRegion = 0; iRegion < iRegionQty; ++iRegion, pRegion = NULL, pItem = NULL, pMulti = NULL, x2 = 0, y2 = 0 )
{
//.........这里部分代码省略.........
示例2: FindTypeNear_Top
CPointMap CWorld::FindTypeNear_Top( const CPointMap & pt, IT_TYPE iType, int iDistance )
{
ADDTOCALLSTACK("CWorld::FindTypeNear_Top");
#define RESOURCE_Z_CHECK 8
CPointMap ptFound;
CItemBase * pItemDef = NULL;
CItem * pItem = NULL;
CItemBaseDupe * pDupeDef = NULL;
height_t Height = 0;
BYTE z = 0;
CPointMap ptTest;
unsigned int iRetElem = 4;
CPointMap ptElem[5];
memset(ptElem, 0, sizeof(ptElem));
//for ( iQty = 0; iQty < 4; ++iQty )
// ptElem[iQty].m_z = UO_SIZE_MIN_Z;
ptElem[0].m_z = ptElem[1].m_z = ptElem[2].m_z = ptElem[3].m_z = UO_SIZE_MIN_Z;
ptElem[4] = CPointMap(USHRT_MAX, USHRT_MAX, UO_SIZE_MIN_Z);
bool fElem[4] = { false, false, false, false };
// Check dynamics
CWorldSearch Area( pt, iDistance );
Area.SetAllShow( true );
for (;;)
{
z = 0;
Height = 0;
pItem = Area.GetItem();
if ( pItem == NULL )
break;
if ( pt.GetDist( pItem->GetTopPoint() ) > iDistance )
continue;
pItemDef = CItemBase::FindItemBase( pItem->GetDispID() );
if ( pItemDef == NULL )
continue;
Height = pItemDef->GetHeight();
if ( pItemDef->GetID() != pItem->GetDispID() ) //not a parent item
{
pDupeDef = CItemBaseDupe::GetDupeRef(static_cast<ITEMID_TYPE>(pItem->GetDispID()));
if ( ! pDupeDef )
{
g_Log.EventDebug("Failed to get non-parent reference (dynamic) (DispID 0%x) (X: %d Y: %d Z: %d)\n",pItem->GetDispID(),ptTest.m_x,ptTest.m_y,ptTest.m_z);
Height = pItemDef->GetHeight();
}
else
Height = pDupeDef->GetHeight();
}
z = minimum( Height + pItem->GetTopPoint().m_z, UO_SIZE_Z ); //height + current position = the top point
if ( ptElem[0].m_z > z ) //if ( ptElem[0].m_z > pItem->GetTopPoint().m_z )
continue;
if ( ((( z - pt.m_z ) > 0) && ( z - pt.m_z ) > RESOURCE_Z_CHECK ) || ((( pt.m_z - z ) < 0) && (( pt.m_z - z ) < - RESOURCE_Z_CHECK ))) //if ( ((( pItem->GetTopPoint().m_z - pt.m_z ) > 0) && ( pItem->GetTopPoint().m_z - pt.m_z ) > RESOURCE_Z_CHECK ) || ((( pt.m_z - pItem->GetTopPoint().m_z ) < 0) && (( pt.m_z - pItem->GetTopPoint().m_z ) < - RESOURCE_Z_CHECK )))
continue;
if (( z < ptElem[0].m_z ) || (( z == ptElem[0].m_z ) && ( fElem[0] )))
continue;
ptElem[0] = pItem->GetTopPoint();
ptElem[0].m_z = z;
fElem[0] = false;
//DEBUG_ERR(("dynamic pItem->IsType( iType %d) %d\n",iType,pItem->IsType( iType )));
if ( pItem->IsType( iType ) ) //( pItem->Item_GetDef()->IsType(iType) ) )
{
fElem[0] = true;
iRetElem = 0;
}
}
// Parts of multis ?
const CGrayMulti * pMulti = NULL; // Multi Def (multi check)
const CUOMultiItemRec2 * pMultiItem = NULL; // Multi item iterator
CRegionBase * pRegion = NULL;
CRegionLinks rlinks;
size_t iRegionQty = pt.GetRegions( REGION_TYPE_MULTI, rlinks );
if ( iRegionQty > 0 )
{
for ( size_t iRegion = 0; iRegion < iRegionQty; pMulti = NULL, ++iRegion)
{
pRegion = rlinks.GetAt(iRegion);
pItem = pRegion->GetResourceID().ItemFind();
if ( !pItem )
continue;
pMulti = g_Cfg.GetMultiItemDefs(pItem);
if ( !pMulti )
continue;
size_t iMultiQty = pMulti->GetItemCount();
for ( size_t iMulti = 0; iMulti < iMultiQty; pItemDef = NULL, pMultiItem = NULL, Height = 0, ++iMulti )
{
pMultiItem = pMulti->GetItem(iMulti);
if ( !pMultiItem )
break;
//.........这里部分代码省略.........
示例3: GetFixPoint
void CWorld::GetFixPoint( const CPointMap & pt, CGrayMapBlockState & block)
{
//Will get the highest CAN_I_PLATFORM|CAN_I_CLIMB and places it into block.Bottom
ADDTOCALLSTACK("CWorld::GetFixPoint");
CItemBase * pItemDef = NULL;
CItemBaseDupe * pDupeDef = NULL;
CItem * pItem = NULL;
DWORD wBlockThis = 0;
signed char z = 0;
int x2 = 0, y2 = 0;
// Height of statics at/above given coordinates
// do gravity here for the z.
const CGrayMapBlock * pMapBlock = GetMapBlock( pt );
if (pMapBlock == NULL)
return;
size_t iQty = pMapBlock->m_Statics.GetStaticQty();
if ( iQty > 0 ) // no static items here.
{
x2 = pMapBlock->GetOffsetX(pt.m_x);
y2 = pMapBlock->GetOffsetY(pt.m_y);
const CUOStaticItemRec * pStatic = NULL;
for ( size_t i = 0; i < iQty; ++i, z = 0, pStatic = NULL, pDupeDef = NULL )
{
if ( ! pMapBlock->m_Statics.IsStaticPoint( i, x2, y2 ))
continue;
pStatic = pMapBlock->m_Statics.GetStatic( i );
if ( pStatic == NULL )
continue;
z = pStatic->m_z;
pItemDef = CItemBase::FindItemBase( pStatic->GetDispID() );
if ( pItemDef )
{
if (pItemDef->GetID() == pStatic->GetDispID()) //parent item
{
wBlockThis = (pItemDef->m_Can & CAN_I_MOVEMASK);
z += ((wBlockThis & CAN_I_CLIMB) ? pItemDef->GetHeight()/2 : pItemDef->GetHeight());
}
else //non-parent item
{
pDupeDef = CItemBaseDupe::GetDupeRef(static_cast<ITEMID_TYPE>(pStatic->GetDispID()));
if ( ! pDupeDef )
{
g_Log.EventDebug("Failed to get non-parent reference (static) (DispID 0%x) (X: %d Y: %d Z: %d)\n",pStatic->GetDispID(),pStatic->m_x+pMapBlock->m_x,pStatic->m_y+pMapBlock->m_y,pStatic->m_z);
wBlockThis = ( pItemDef->m_Can & CAN_I_MOVEMASK );
z += ((wBlockThis & CAN_I_CLIMB) ? pItemDef->GetHeight()/2 : pItemDef->GetHeight());
}
else
{
wBlockThis = (pDupeDef->m_Can & CAN_I_MOVEMASK);
z += ((wBlockThis & CAN_I_CLIMB) ? pDupeDef->GetHeight()/2 : pDupeDef->GetHeight());
}
}
}
else if ( pStatic->GetDispID() )
CItemBase::GetItemTiledataFlags(wBlockThis,pStatic->GetDispID());
if (block.m_Bottom.m_z < z)
{
if ((z < pt.m_z+PLAYER_HEIGHT) && (wBlockThis & (CAN_I_PLATFORM|CAN_I_CLIMB|CAN_I_WATER)))
{
block.m_Bottom.m_dwBlockFlags = wBlockThis;
block.m_Bottom.m_dwTile = pStatic->GetDispID() + TERRAIN_QTY;
block.m_Bottom.m_z = z;
}
else if (block.m_Top.m_z > z)
{
block.m_Top.m_dwBlockFlags = wBlockThis;
block.m_Top.m_dwTile = pStatic->GetDispID() + TERRAIN_QTY;
block.m_Top.m_z = z;
}
}
}
}
pItemDef = NULL;
pDupeDef = NULL;
pItem = NULL;
wBlockThis = 0;
z = 0;
x2 = y2 = 0;
iQty = 0;
// Any multi items here ?
// Check all of them
CRegionLinks rlinks;
size_t iRegionQty = pt.GetRegions( REGION_TYPE_MULTI, rlinks );
if ( iRegionQty > 0 )
{
// ------------ For variables --------------------
CRegionBase * pRegion = NULL;
const CGrayMulti * pMulti = NULL;
const CUOMultiItemRec2 * pMultiItem = NULL;
x2 = 0;
y2 = 0;
// ------------ For variables --------------------
//.........这里部分代码省略.........
示例4: CanSeeLOS_New
//.........这里部分代码省略.........
//Fix for Stacked items blocking view
if ( (pStatic->m_x == ptDst.m_x) && (pStatic->m_y == ptDst.m_y) && (pStatic->m_z >= GetTopZ()) && (pStatic->m_z <= ptSrc.m_z) )
continue;
pItemDef = CItemBase::FindItemBase(pStatic->GetDispID());
wTFlags = 0;
Height = 0;
bNullTerrain = false;
if ( !pItemDef )
{
WARNLOS(("STATIC - Cannot get pItemDef for item (0%x)\n", pStatic->GetDispID()));
}
else
{
if (pItemDef->Can(CAN_I_BLOCKLOS))
{
WARNLOS(("pStatic blocked by CAN_I_BLOCKLOS"));
bPath = false;
break;
}
if ( (flags & LOS_FISHING) && (ptSrc.GetDist(ptNow) >= 2) && (pItemDef->GetType() != IT_WATER) &&
( pItemDef->Can(CAN_I_DOOR | CAN_I_PLATFORM | CAN_I_BLOCK | CAN_I_CLIMB | CAN_I_FIRE | CAN_I_ROOF | CAN_I_BLOCKLOS | CAN_I_BLOCKLOS_HEIGHT)) )
{
WARNLOS(("pStatic blocked - flags & 0800, distance >= 2 and type of pItemDef is not IT_WATER\n"));
bPath = false;
break;
}
wTFlags = pItemDef->GetTFlags();
Height = pItemDef->GetHeight();
if ( pItemDef->GetID() != pStatic->GetDispID() ) //not a parent item
{
WARNLOS(("Not a parent item (STATIC)\n"));
pDupeDef = CItemBaseDupe::GetDupeRef((ITEMID_TYPE)(pStatic->GetDispID()));
if ( !pDupeDef )
{
g_Log.EventDebug("AdvancedLoS: Failed to get non-parent reference (static) (DispID 0%x) (X: %d Y: %d Z: %hhd M: %hhu)\n", pStatic->GetDispID(), ptNow.m_x, ptNow.m_y, pStatic->m_z, ptNow.m_map);
}
else
{
wTFlags = pDupeDef->GetTFlags();
Height = pDupeDef->GetHeight();
}
}
else
{
WARNLOS(("Parent item (STATIC)\n"));
}
Height = (wTFlags & UFLAG2_CLIMBABLE) ? Height / 2 : Height;
if ( ((wTFlags & (UFLAG1_WALL|UFLAG1_BLOCK|UFLAG2_PLATFORM)) || (pItemDef->Can(CAN_I_BLOCKLOS_HEIGHT))) && !((wTFlags & UFLAG2_WINDOW) && (flags & LOS_NB_WINDOWS)) )
{
WARNLOS(("pStatic %0x %d,%d,%d - %d\n", pStatic->GetDispID(), pStatic->m_x, pStatic->m_y, pStatic->m_z, Height));
min_z = pStatic->m_z;
max_z = minimum(Height + min_z, UO_SIZE_Z);
WARNLOS(("wTFlags(0%x)\n", wTFlags));
WARNLOS(("pStatic %0x Z check: %d,%d (Now: %d) (Dest: %d).\n", pStatic->GetDispID(), min_z, max_z, ptNow.m_z, ptDst.m_z));
if ( (min_z <= ptNow.m_z) && (max_z >= ptNow.m_z) )
{
if ( ptNow.m_x != ptDst.m_x || ptNow.m_y != ptDst.m_y || min_z > ptDst.m_z || max_z < ptDst.m_z )
{