本文整理汇总了C++中CVehicle::GetUnitType方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetUnitType方法的具体用法?C++ CVehicle::GetUnitType怎么用?C++ CVehicle::GetUnitType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVehicle
的用法示例。
在下文中一共展示了CVehicle::GetUnitType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetUnit
//
// retrieve a pointer to a unit controlled by another player
// either HP or AI.
//
CAIUnit *CAIUnitList::GetOpForUnit( DWORD dwID )
{
// if already known, then return it
CAIUnit *pOpFor = GetUnit( dwID );
if( pOpFor != NULL )
return( pOpFor );
// else get a copy from the game and save it
// NOTE: the thread must be granted exclusive access
EnterCriticalSection (&cs);
CVehicle *pVehicle =
theVehicleMap.GetVehicle( dwID );
if( pVehicle != NULL )
{
if( !pVehicle->IsFlag(CUnit::dying) )
{
try
{
// CAIUnit::CAIUnit( DWORD dwID, int iOwner, int iType )
pOpFor = new CAIUnit( dwID,
pVehicle->GetOwner()->GetPlyrNum(),
pVehicle->GetUnitType(), pVehicle->GetData()->GetType() );
AddTail( (CObject *)pOpFor );
}
catch( CException e )
{
LeaveCriticalSection (&cs);
throw(ERR_CAI_BAD_NEW);
}
}
}
else
{
CBuilding *pBldg = theBuildingMap.GetBldg( dwID );
if( pBldg != NULL )
{
if( !pBldg->IsFlag(CUnit::dying) )
{
try
{
// CAIUnit::CAIUnit( DWORD dwID, int iOwner, int iType )
pOpFor = new CAIUnit( dwID,
pBldg->GetOwner()->GetPlyrNum(),
pBldg->GetUnitType(), pBldg->GetData()->GetType() );
AddTail( (CObject *)pOpFor );
}
catch( CException e )
{
LeaveCriticalSection (&cs);
throw(ERR_CAI_BAD_NEW);
}
}
}
}
LeaveCriticalSection (&cs);
return( pOpFor );
}