当前位置: 首页>>代码示例>>C++>>正文


C++ CVehicle::GetOwner方法代码示例

本文整理汇总了C++中CVehicle::GetOwner方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetOwner方法的具体用法?C++ CVehicle::GetOwner怎么用?C++ CVehicle::GetOwner使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CVehicle的用法示例。


在下文中一共展示了CVehicle::GetOwner方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: AddUnit

void CAIUnitList::AddUnit( DWORD dwID )
{
	int iPlayer = 0;
	int iType = 0xFFFE;
	int iUnitType = 0xFFFE;
	BOOL bControl = FALSE;

	EnterCriticalSection (&cs);
	CVehicle *pVehicle = theVehicleMap.GetVehicle( dwID );
	if( pVehicle != NULL )
	{
		iPlayer = pVehicle->GetOwner()->GetPlyrNum();
		iType = CUnit::vehicle;
		iUnitType = pVehicle->GetData()->GetType();
		bControl = pVehicle->GetOwner()->IsAI();
	}
	else
	{
		CBuilding *pBldg = theBuildingMap.GetBldg( dwID );
		if( pBldg != NULL )
		{
			iPlayer = pBldg->GetOwner()->GetPlyrNum();
			iType = CUnit::building;
			iUnitType = pBldg->GetData()->GetType();
			bControl = pBldg->GetOwner()->IsAI();
		}
		else
			return;
	}
	LeaveCriticalSection (&cs);

	if( !iPlayer )
		return;

	CAIUnit *pUnit = NULL;
	try
	{
		// CAIUnit( DWORD dwID, int iOwner, class, type );
		pUnit = new CAIUnit( dwID, iPlayer, iType, iUnitType );
		ASSERT_VALID( pUnit );
		AddTail( (CObject *)pUnit );
	}
	catch( CException e )
	{
		// need to report this error occurred
		throw(ERR_CAI_BAD_NEW);
	}
	
	if( pUnit == NULL )
		return;

	// indicate what controls this unit
	pUnit->SetControl(bControl);
}
开发者ID:Marenz,项目名称:EnemyNations,代码行数:54,代码来源:caiunit.cpp

示例2: 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 );
}
开发者ID:Marenz,项目名称:EnemyNations,代码行数:66,代码来源:caiunit.cpp


注:本文中的CVehicle::GetOwner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。