本文整理汇总了C++中CVehicle::GetData方法的典型用法代码示例。如果您正苦于以下问题:C++ CVehicle::GetData方法的具体用法?C++ CVehicle::GetData怎么用?C++ CVehicle::GetData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CVehicle
的用法示例。
在下文中一共展示了CVehicle::GetData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例2: if
//
// get a current pointer to data copy based on
// the type of data requested
//
CAICopy *CAIUnit::GetCopyData( int iType )
{
ASSERT_VALID( this );
ASSERT_VALID( m_plCopyData );
CVehicle *pVehicle = NULL;
CBuilding *pBldg = NULL;
EnterCriticalSection (&cs);
switch( iType )
{
case CAICopy::CUnitData :
if( m_iType == CUnit::building )
{
CBuilding const *pBldg =
pGameData->GetBuildingData( m_iOwner, m_dwID );
if( pBldg == NULL )
break;
CStructureData const *pData = pBldg->GetData();
Update( (CUnitData const *)pData );
}
else if( m_iType == CUnit::vehicle )
{
CVehicle *pVehicle =
pGameData->GetVehicleData( m_iOwner, m_dwID );
if( pVehicle == NULL )
break;
CTransportData const *pData = pVehicle->GetData();
Update( (CUnitData const *)pData );
}
break;
case CAICopy::CVehicle :
case CAICopy::CTransportData :
pVehicle = pGameData->GetVehicleData( m_iOwner, m_dwID );
if( pVehicle == NULL )
break;
// update CVehicle copy data
if( iType == CAICopy::CVehicle )
Update( pVehicle );
// update CTransportData copy data
else if( iType == CAICopy::CTransportData )
Update( pVehicle->GetData() );
break;
case CAICopy::CBuilding :
case CAICopy::CStructureData :
case CAICopy::CBuildMaterials :
case CAICopy::CBuildMine:
case CAICopy::CBuildFarm:
// BUGBUG build units are now an array of CBuildUnit objects
// contained in the CBuildVehicle pointer from CStructureData
//
case CAICopy::CBuildUnit :
// get CBuilding *pBldg from game for this unit
pBldg = pGameData->GetBuildingData( m_iOwner, m_dwID );
if( pBldg == NULL )
break;
// update CBuilding copy data
if( iType == CAICopy::CBuilding )
Update( pBldg );
// update CStructureData copy data
else if( iType == CAICopy::CStructureData )
Update( pBldg->GetData() );
// update CBuildMaterials copy data
else if( iType == CAICopy::CBuildMaterials )
Update( pBldg->GetData()->GetBldMaterials() );
// update CBuildMine copy data
else if( iType == CAICopy::CBuildMine )
Update( pBldg->GetData()->GetBldMine() );
// update CBuildFarm copy data
else if( iType == CAICopy::CBuildFarm )
Update( pBldg->GetData()->GetBldFarm() );
// update CBuildUnit copy data
else if( iType == CAICopy::CBuildUnit )
{
if( pBldg->GetData()->GetUnionType()
== CStructureData::UTvehicle )
{
// capture data based on what the building
// is producing or the 1st thing it could
// produce if it is not producing anything
CVehicleBuilding *pVehBldg =
(CVehicleBuilding *)pBldg;
CBuildUnit const *pBuildVeh = pVehBldg->GetBldUnt();
if( pBuildVeh != NULL )
Update( pBuildVeh );
//.........这里部分代码省略.........
示例3: 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 );
}