Ejemplo n.º 1
0
bool ObjectBase::ChildTypeOk (PObjectType type)
{
	// buscamos si puede haber objectos del tipo "type" como hijos
	// del actual objeto tipo.

	int nmax = 0;

	// check allowed child count
	if( GetObjectInfo()->GetObjectType()->GetName() == wxT("form") )
	{
		nmax = GetObjectInfo()->GetObjectType()->FindChildType(type, this->GetPropertyAsInteger(wxT("aui_managed")));
	}
	else
		nmax = GetObjectInfo()->GetObjectType()->FindChildType(type, false);

	if (nmax == 0)
		return false;

	if (nmax < 0)
		return true;

	// llegados aquí hay que comprobar el número de hijos del tipo pasado
	int count = 0;
	for (unsigned int i=0; i < GetChildCount() && count <= nmax; i++)
	{
		if (GetChild(i)->GetObjectInfo()->GetObjectType() == type)
			count++;
	}

	if (count > nmax)
		return false;

	return true;

}
Ejemplo n.º 2
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output : char const
//-----------------------------------------------------------------------------
const char *CTFWeaponBuilder::GetPrintName( void ) const
{
	if ( GetObjectInfo( m_iObjectType )->m_AltModes.Count() > 0 )
		return GetObjectInfo( m_iObjectType )->m_AltModes.Element( m_iObjectMode * 3 + 0 );

	return GetObjectInfo( m_iObjectType )->m_pStatusName;
}
Ejemplo n.º 3
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_TFWeaponBuilder::SetupObjectSelectionSprite( void )
{
#ifdef CLIENT_DLL
	// Use the sprite details from the text file, with a custom sprite
	char *iconTexture = GetObjectInfo( m_iObjectType )->m_pIconActive;
	if ( iconTexture && iconTexture[ 0 ] )
	{
		m_pSelectionTextureActive = gHUD.GetIcon( iconTexture );
	}
	else
	{
		m_pSelectionTextureActive = NULL;
	}

	iconTexture = GetObjectInfo( m_iObjectType )->m_pIconInactive;
	if ( iconTexture && iconTexture[ 0 ] )
	{
		m_pSelectionTextureInactive = gHUD.GetIcon( iconTexture );
	}
	else
	{
		m_pSelectionTextureInactive = NULL;
	}
#endif
}
Ejemplo n.º 4
0
//-----------------------------------------------------------------------------
// Purpose: Calculate the cost to upgrade an object of a specific type
//-----------------------------------------------------------------------------
int	CalculateObjectUpgrade( int iObjectType, int iObjectLevel )
{
	// Max level?
	if ( iObjectLevel >= GetObjectInfo( iObjectType )->m_MaxUpgradeLevel )
		return 0;

	int iCost = GetObjectInfo( iObjectType )->m_UpgradeCost;
	for ( int i = 0; i < (iObjectLevel - 1); i++ )
	{
		iCost *= OBJECT_UPGRADE_COST_MULTIPLIER_PER_LEVEL;
	}

	return iCost;
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// Purpose: 
// Output : char const
//-----------------------------------------------------------------------------
const char *C_TFWeaponBuilder::GetCurrentSelectionObjectName( void )
{
	if ( m_iObjectType == -1 || (m_iBuildState == BS_SELECTING) )
		return "";

	return GetObjectInfo( m_iObjectType )->m_pBuilderWeaponName;
}
//-----------------------------------------------------------------------------
// Frame-based update
//-----------------------------------------------------------------------------
void CVehicleBayVGuiScreen::OnTick()
{
	BaseClass::OnTick();

	if (!GetEntity())
		return;

	C_BaseTFPlayer *pLocalPlayer = C_BaseTFPlayer::GetLocalPlayer();
	if ( !pLocalPlayer )
		return;

	int nBankResources = pLocalPlayer ? pLocalPlayer->GetBankResources() : 0;

	// Set the vehicles costs
	for ( int i = 0; i < NUM_VEHICLES; i++ )
	{
		if ( !m_pVehicleButtons[i] )
			continue;

		char buf[128];
		int iCost = CalculateObjectCost( g_ValidVehicles[i], pLocalPlayer->GetNumObjects( g_ValidVehicles[i] ), pLocalPlayer->GetTeamNumber() );
		Q_snprintf( buf, sizeof( buf ), "%s : %d", GetObjectInfo( g_ValidVehicles[i] )->m_pStatusName, iCost );
		m_pVehicleButtons[i]->SetText( buf );
		// Can't build if the game hasn't started
		if ( CurrentActIsAWaitingAct() )
		{
			m_pVehicleButtons[i]->SetEnabled( false );
		}
		else
		{
			m_pVehicleButtons[i]->SetEnabled( nBankResources >= iCost );
		}
	}
}
Ejemplo n.º 7
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBaseObject::AddAndParseBuildPoint( int iAttachmentNumber, KeyValues *pkvBuildPoint )
{
	int iPoint = AddBuildPoint( iAttachmentNumber );

	
	m_BuildPoints[iPoint].m_bPutInAttachmentSpace = (pkvBuildPoint->GetInt( "PutInAttachmentSpace", 0 ) != 0);

	// Now see if we've got a set of valid objects specified
	KeyValues *pkvValidObjects = pkvBuildPoint->FindKey( "valid_objects" );
	if ( pkvValidObjects )
	{
		KeyValues *pkvObject = pkvValidObjects->GetFirstSubKey();
		while ( pkvObject )
		{
			const char *pSpecifiedObject = pkvObject->GetName();
			int iLenObjName = Q_strlen( pSpecifiedObject );

			// Find the object index for the name
			for ( int i = 0; i < OBJ_LAST; i++ )
			{
				if ( !Q_strncasecmp( GetObjectInfo( i )->m_pClassName, pSpecifiedObject, iLenObjName) )
				{
					AddValidObjectToBuildPoint( iPoint, i );
					break;
				}
			}

			pkvObject = pkvObject->GetNextKey();
		}
	}
}
Ejemplo n.º 8
0
void Target_Info(unsigned int Serial, unsigned short X, unsigned short Y, int Z)
{
	GameObject Obj;

	if(Serial == INVALID_SERIAL)
	{
		ClientPrint("Invalid target");
		return;
	}

	if(GetObjectInfo(Serial, INVALID_IDX, &Obj) == OBJECT_NOTFOUND)
	{
		ClientPrint("Object not in the world list");
		return;
	}

	ClientPrint("Serial 0x%08X", Obj.Serial);
	ClientPrint("Graphic: 0x%04X Color: 0x%04X", Obj.Graphic, Obj.Color);
	ClientPrint("Container: 0x%08X Quantity: %d", Obj.Container, Obj.Quantity);
	
	/* if the object wasn't a character, GetObjectInfo frees the pointer */
	if(Obj.Character == NULL) return;
	
	/* if it's a character display the info */
	ClientPrint("Name %s", Obj.Character->Name);
	ClientPrint("HP: %d MaxHP: %d", Obj.Character->HitPoints, Obj.Character->MaxHitPoints);
	ClientPrint("Current HP: %d%%", (Obj.Character->HitPoints*100)/Obj.Character->MaxHitPoints);

	FREECHAR(Obj);
	return;
}
Ejemplo n.º 9
0
bool ObjectBase::ChildTypeOk (PObjectType type)
{
	// buscamos si puede haber objectos del tipo "type" como hijos
	// del actual objeto tipo.
	int nmax = GetObjectInfo()->GetObjectType()->FindChildType(type);

	if (nmax == 0)
		return false;

	if (nmax < 0)
		return true;

	// llegados aquí hay que comprobar el número de hijos del tipo pasado
	int count = 0;
	for (unsigned int i=0; i < GetChildCount() && count <= nmax; i++)
	{
		if (GetChild(i)->GetObjectInfo()->GetObjectType() == type)
			count++;
	}

	if (count > nmax)
		return false;

	return true;

}
Ejemplo n.º 10
0
void delete_files( CAMHandle hCam, CAMDeviceInfoPtr pDevInfo, OPTS *pOpts)
{
    int             ret;
    uint32_t       *pHandle;
    uint32_t       *pEnd;
    CAMObjectHandlePtr pHandles = 0;
    CAMObjectInfoPtr   pObjInfo = 0;

    if (GetObjectHandles( hCam, 0xffffffff, 0, 0, &pHandles)) {
        camcli_error( "Could not get object handles");
        return;
    }

    if (!validate_range( pHandles, pOpts, &pHandle, &pEnd)) {
        if (pHandles)
            free( pHandles);
        return;
    }

    printf ( "\n Erase files  %s\n", pDevInfo->Model);
    printf (   " ===========  %s\n", underline( pDevInfo->Model));

    for (; pHandle <= pEnd; pHandle++) {
        ret = GetObjectInfo( hCam, *pHandle, &pObjInfo);
        if (ret) {
            camcli_error( "Could not get info for handle %d", *pHandle);
            if (ret == CAMERR_USBFAILURE)
                ClearStall( hCam);
            continue;
        }

        if (pObjInfo->ObjectFormat == PTP_OFC_Association)
            printf( " Handle %d is not a file - skipping...\n", *pHandle);
        else {
            ret = DeleteObject( hCam, *pHandle, 0);
            if (ret == 0)
                printf(" Erasing %3d  (%s)... done\n", *pHandle, pObjInfo->Filename);
            else {
                camcli_error( "Could not delete handle %d - rc= %X",
                              *pHandle, ret);
                if (ret == CAMERR_USBFAILURE)
                    ClearStall( hCam);
            }
        }

        free( pObjInfo);
        pObjInfo = 0;
    }

    if (pObjInfo)
        free( pObjInfo);
    if (pHandles)
        free( pHandles);

    return;
}
Ejemplo n.º 11
0
//-----------------------------------------------------------------------------
// Purpose: Return the cost of another object of the specified type
//			If bLast is set, return the cost of the last built object of the specified type
// 
// Note: Used to contain logic from tf2 that multiple instances of the same object
//       cost different amounts. See tf2/game_shared/tf_shareddefs.cpp for details
//-----------------------------------------------------------------------------
int CalculateObjectCost( int iObjectType )
{
	if ( tf_cheapobjects.GetInt() )
	{
		return 0;
	}

	int iCost = GetObjectInfo( iObjectType )->m_Cost;

	return iCost;
}
Ejemplo n.º 12
0
// -----------------------------------------------------------------------------
// Purpose:
// -----------------------------------------------------------------------------
const char *C_TFWeaponBuilder::GetViewModel( int iViewModel ) const
{
	if ( GetPlayerOwner() == NULL )
	{
		return BaseClass::GetViewModel();
	}

	if ( m_iObjectType != BUILDER_INVALID_OBJECT )
	{
		return GetObjectInfo( m_iObjectType )->m_pViewModel;
	}

	return BaseClass::GetViewModel();
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
const char *CTFWeaponBuilder::GetWorldModel( void ) const
{
	if ( GetPlayerOwner() == NULL )
	{
		return BaseClass::GetWorldModel();
	}

	if ( m_iObjectType != BUILDER_INVALID_OBJECT )
	{
		return GetObjectInfo( m_iObjectType )->m_pPlayerModel;
	}

	return BaseClass::GetWorldModel();
}
Ejemplo n.º 14
0
unsigned ReqProg_load()
{
    char            *src;
    char            *dst;
    char            *name;
    char            ch;
    prog_load_ret   *ret;
    unsigned        len;

    _DBG1(( "AccLoadProg\r\n" ));
    AtEnd = FALSE;
    dst = UtilBuff;
    src = name = GetInPtr( sizeof( prog_load_req ) );
    ret = GetOutPtr( 0 );
    while( *src++ != '\0' ) {};
    len = GetTotalSize() - (src - name) - sizeof( prog_load_req );
    if( len > 126 )
        len = 126;
    for( ; len > 0; --len ) {
        ch = *src++;
        if( ch == '\0' ) {
            if( len == 1 )
                break;
            ch = ' ';
        }
        *dst++ = ch;
    }
    *dst = '\0';
    _DBG1(( "about to debugload\r\n" ));
    _DBG1(( "Name :" ));
    _DBG1(( name ));
    _DBG1(( "\r\n" ));
    _DBG1(( "UtilBuff :" ));
    _DBG1(( UtilBuff ));
    _DBG1(( "\r\n" ));
    GetObjectInfo( name );
    ret->err = D32DebugLoad( name, UtilBuff, &Proc );
    _DBG1(( "back from debugload - %d\r\n", ret->err ));
    ret->flags = LD_FLAG_IS_32 | LD_FLAG_IS_PROT | LD_FLAG_DISPLAY_DAMAGED;
    if( ret->err == 0 ) {
        ret->task_id = Proc.es;
    } else {
        ret->task_id = 0;
    }
    ret->mod_handle = 0;
    Proc.int_id = -1;
    _DBG1(( "done AccLoadProg\r\n" ));
    return( sizeof( *ret ) );
}
//-----------------------------------------------------------------------------
// Purpose: Start placing the object
//-----------------------------------------------------------------------------
void CTFWeaponBuilder::StartPlacement( void )
{
	StopPlacement();

	// Create the slab
	m_hObjectBeingBuilt = (CBaseObject*)CreateEntityByName( GetObjectInfo( m_iObjectType )->m_pClassName );
	if ( m_hObjectBeingBuilt )
	{
		m_hObjectBeingBuilt->Spawn();
		m_hObjectBeingBuilt->StartPlacement( ToTFPlayer( GetOwner() ) );

		// Stomp this here in the same frame we make the object, so prevent clientside warnings that it's under attack
		m_hObjectBeingBuilt->m_iHealth = OBJECT_CONSTRUCTION_STARTINGHEALTH;
	}
}
Ejemplo n.º 16
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CInfoBuildPoint::Spawn( void )
{
	g_MapDefinedBuildPoints.AddToTail( this );

	m_iAllowedObjectType = -1;
	if ( m_iszAllowedObject != NULL_STRING )
	{
		for ( int i = 0; i < OBJ_LAST; i++ )
		{
			if ( !Q_strcmp( STRING(m_iszAllowedObject), GetObjectInfo(i)->m_pClassName ) )
			{
				m_iAllowedObjectType = i;
				break;
			}
		}
	}

	BaseClass::Spawn();
}
Ejemplo n.º 17
0
void list_files( CAMHandle hCam, CAMDeviceInfoPtr pDevInfo)
{
    int                i;
    struct tm *        ptm;
    CAMObjectHandlePtr pHandles = 0;
    CAMObjectInfoPtr   pObjInfo = 0;

    if (GetObjectHandles( hCam, 0xffffffff, 0, 0, &pHandles)) {
        camcli_error( "Could not get object handles");
        return;
    }

    printf( "\n File list  %s\n", pDevInfo->Model);
    printf(   " =========  %s\n", underline( pDevInfo->Model));
    printf("\n Handle\t     Size     Date     Time   Name\n");

    for (i = 0; i < pHandles->cntHandles; i++) {

        if (GetObjectInfo( hCam, pHandles->Handles[i], &pObjInfo)) {
            camcli_error( "Could not get object info for handle %d",
                          pHandles->Handles[i]);
            break;
        }

        if (pObjInfo->ObjectFormat != PTP_OFC_Association) {
            ptm = localtime( &pObjInfo->CaptureDate);
            printf( " % 4d\t% 9d  %04d-%02d-%02d  %02d:%02d  %s\n",
                    pHandles->Handles[i], pObjInfo->ObjectCompressedSize,
                    ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday,
                    ptm->tm_hour, ptm->tm_min, pObjInfo->Filename);
        }

        free( pObjInfo);
        pObjInfo = 0;
    }

    if (pObjInfo)
        free( pObjInfo);
    if (pHandles)
        free( pHandles);

    return;
}
Ejemplo n.º 18
0
void Target_TileInfo(unsigned int Serial, unsigned short X, unsigned short Y, int Z)
{
	GameObject Obj;

	if(Serial == INVALID_SERIAL)
		ClientPrint("X: %d Y: %d Z: %d", X, Y, Z);
	else
	{
		if(GetObjectInfo(Serial, INVALID_IDX, &Obj) == OBJECT_NOTFOUND)
		{
			ClientPrintWarning("The targeted object does not exist in the world list... wtf");
			return;
		}

		ClientPrint("You targeted an object, serial: 0x%08X", Serial);
		ClientPrint("Position: X: %d Y: %d Z: %d", Obj.X, Obj.Y, Obj.Z);
	}

	return;
}
Ejemplo n.º 19
0
//-----------------------------------------------------------------------------
// Purpose: Return true if this player's allowed to build another one of the specified objects
//-----------------------------------------------------------------------------
int CPlayerClass::CanBuild( int iObjectType )
{
	int iObjectCount = GetNumObjects( iObjectType );

	// Make sure we haven't hit maximum number
	if ( tf2_object_hard_limits.GetBool() )
	{
		if ( iObjectCount >= GetObjectInfo( iObjectType )->m_nMaxObjects )
			return CB_LIMIT_REACHED;
	}
	else
	{
		// Find out how much the next object should cost
		int iCost = CalculateObjectCost( iObjectType, GetNumObjects( iObjectType ), m_pPlayer->GetTeamNumber() );

		// Make sure we have enough resources
		if ( m_pPlayer->GetBankResources() < iCost )
			return CB_NEED_RESOURCES;
	}

	return CB_CAN_BUILD;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CTFWeaponBuilder::Precache( void )
{
	BaseClass::Precache();

	// Precache all the viewmodels we could possibly be building
	for ( int iObj=0; iObj < OBJ_LAST; iObj++ )
	{
		const CObjectInfo *pInfo = GetObjectInfo( iObj );

		if ( pInfo )
		{
			if ( pInfo->m_pViewModel )
			{
				PrecacheModel( pInfo->m_pViewModel );
			}

			if ( pInfo->m_pPlayerModel )
			{
				PrecacheModel( pInfo->m_pPlayerModel );
			}
		}
	}
}
Ejemplo n.º 21
0
void CrestObjects::ClearCRNodes(bool bC, bool bR)
{
	tCRNode* pCRNode;
	for(long k=0;k<m_nObjects;k++)
	{
		ResponseData *pResponse=m_pObjectInfo[k].pResponse;
		if(NULL==pResponse) continue;
		for(long i=0;i<INSTRUMENT_MAX;i++)
		{
			if(bC || GetObjectInfo(i)->pIInfo->nGraspStatus==0)
			{	
				pResponse->nCPos[i]=0;
			}

			if(bR)
			{
				pResponse->nPPos=0;
				//for(i=0;i<RNODES_MAX;i++) m_RNode[i].pVector=NULL;
				pResponse->nRPos=pResponse->nRVelocity=pResponse->nRForce=0;
			}
		}
	}
}
Ejemplo n.º 22
0
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
const char *C_BaseObject::GetHudStatusIcon( void )
{
	return GetObjectInfo( GetType() )->m_pHudStatusIcon;	
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CTFWeaponBuilder::AllowsAutoSwitchTo( void ) const
{
	// ask the object we're building
	return GetObjectInfo( m_iObjectType )->m_bAutoSwitchTo;
}
Ejemplo n.º 24
0
void show_handle_info( CAMHandle hCam, CAMDeviceInfoPtr pDevInfo, OPTS *pOpts)
{
    uint32_t       *pHandle;
    uint32_t       *pEnd;
    struct tm       *ptm;
    CAMObjectHandlePtr pHandles = 0;
    CAMObjectInfoPtr   pObjInfo = 0;

    if (GetObjectHandles( hCam, 0xffffffff, 0, 0, &pHandles)) {
        camcli_error( "Could not get object handles");
        return;
    }

    if (!validate_range( pHandles, pOpts, &pHandle, &pEnd)) {
        if (pHandles)
            free( pHandles);
        return;
    }

    printf ( "\n     File information  %s\n", pDevInfo->Model);
    printf (   "     ================  %s\n", underline( pDevInfo->Model));

    for (; pHandle <= pEnd; pHandle++) {

        if (GetObjectInfo( hCam, *pHandle, &pObjInfo)) {
            camcli_error( "Could not get object info for handle %d", *pHandle);
            continue;
        }

        printf ( "              Handle:  %04d\n", *pHandle);
        printf ( "            Filename:  %s\n", (pObjInfo->Filename ? pObjInfo->Filename : "[none]"));

        if (pObjInfo->CaptureDate == 0)
            ptm = 0;
        else
            ptm = localtime( &pObjInfo->CaptureDate);
        if (!ptm)
            printf ( "         CaptureDate:  [unknown]\n");
        else
            printf ( "         CaptureDate:  %04d-%02d-%02d  %02d:%02d:%02d\n",
                     ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday,
                     ptm->tm_hour, ptm->tm_min, ptm->tm_sec);

        if (pObjInfo->ModificationDate == 0)
            ptm = 0;
        else
            ptm = localtime( &pObjInfo->ModificationDate);
        if (!ptm)
            printf ( "    ModificationDate:  [unknown]\n");
        else
            printf ( "    ModificationDate:  %04d-%02d-%02d  %02d:%02d:%02d\n",
                     ptm->tm_year+1900, ptm->tm_mon+1, ptm->tm_mday,
                     ptm->tm_hour, ptm->tm_min, ptm->tm_sec);

        printf ( "            Keywords:  %s\n", (pObjInfo->Keywords ? pObjInfo->Keywords : "[none]"));
        printf ( "    ProtectionStatus:  0x%04X\t%s\n", pObjInfo->ProtectionStatus, GetCodeName( pObjInfo->ProtectionStatus, CAM_PROTECTION));
        printf ( "ObjectCompressedSize:  %d\n", pObjInfo->ObjectCompressedSize);
        printf ( "        ObjectFormat:  0x%04X\t%s\n", pObjInfo->ObjectFormat, GetCodeName( pObjInfo->ObjectFormat, CAM_OBJECT_FORMAT));
        printf ( "       ImagePixWidth:  %d\n", pObjInfo->ImagePixWidth);
        printf ( "      ImagePixHeight:  %d\n", pObjInfo->ImagePixHeight);
        printf ( "       ImageBitDepth:  %d\n", pObjInfo->ImageBitDepth);
        printf ( " ThumbCompressedSize:  %d\n", pObjInfo->ThumbCompressedSize);
        printf ( "         ThumbFormat:  0x%04X\t%s\n", pObjInfo->ThumbFormat, GetCodeName( pObjInfo->ThumbFormat, CAM_OBJECT_FORMAT));
        printf ( "       ThumbPixWidth:  %d\n", pObjInfo->ThumbPixWidth);
        printf ( "      ThumbPixHeight:  %d\n", pObjInfo->ThumbPixHeight);
        printf ( "        ParentObject:  %04d\n", pObjInfo->ParentObject);
        printf ( "     AssociationType:  0x%04X\t%s\n", pObjInfo->AssociationType, GetCodeName( pObjInfo->AssociationType, CAM_ASSOCIATION));
        printf ( "     AssociationDesc:  0x%04X\n", pObjInfo->AssociationDesc);
        printf ( "      SequenceNumber:  0x%04X\n", pObjInfo->SequenceNumber);
        printf ( "           StorageID:  0x%04X\n\n", pObjInfo->StorageID);

        free( pObjInfo);
        pObjInfo = 0;
    }

    if (pObjInfo)
        free( pObjInfo);
    if (pHandles)
        free( pHandles);

    return;
}
//-----------------------------------------------------------------------------
// Purpose: 
// Output : char const
//-----------------------------------------------------------------------------
const char *CTFWeaponBuilder::GetPrintName( void ) const
{
	return GetObjectInfo( m_iObjectType )->m_pStatusName;
}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CTFWeaponBuilder::GetPosition( void ) const
{
	return GetObjectInfo( m_iObjectType )->m_SelectionPosition;
}
Ejemplo n.º 27
0
void get_files( CAMHandle hCam, CAMDeviceInfoPtr pDevInfo, OPTS *pOpts)
{
    int             ret;
    int             fName;
    char           *pName;
    uint32_t       *pHandle;
    uint32_t       *pEnd;
    CAMObjectHandlePtr pHandles = 0;
    CAMObjectInfoPtr   pObjInfo = 0;
    FNSTRUCT        fns;
    char            path[260];

    if (GetObjectHandles( hCam, 0xffffffff, 0, 0, &pHandles)) {
        camcli_error( "Could not get object handles");
        return;
    }

    fName = parse_filename( pOpts->value, &fns);
    if (fName)
        pName = path;
    else
        pName = 0;

    if (!validate_range( pHandles, pOpts, &pHandle, &pEnd)) {
        if (pHandles)
            free( pHandles);
        return;
    }

    if (pOpts->flags & OPT_THUMBNAIL) {
        printf ( "\n Save thumbnails  %s\n", pDevInfo->Model);
        printf (   " ===============  %s\n", underline( pDevInfo->Model));
    }
    else {
        printf ( "\n Save files  %s\n", pDevInfo->Model);
        printf (   " ==========  %s\n", underline( pDevInfo->Model));
    }

    for (; pHandle <= pEnd; pHandle++) {

        ret = GetObjectInfo( hCam, *pHandle, &pObjInfo);
        if (ret) {
            camcli_error( "Could not get info for handle %d", *pHandle);
            if (ret == CAMERR_USBFAILURE)
                ClearStall( hCam);
            continue;
        }

        if (pObjInfo->ObjectFormat == PTP_OFC_Association)
            printf( " Handle %d is not a file - skipping...\n", *pHandle);
        else {
            if (fName)
                make_filename( pName, pObjInfo->Filename, &fns);
            ret = os2_get_file( hCam, pObjInfo, *pHandle, pName,
                               (pOpts->flags & OPT_REPLACE),
                               (pOpts->flags & OPT_THUMBNAIL));

            if (ret == CAMERR_USBFAILURE)
                ClearStall( hCam);
        }

        free( pObjInfo);
        pObjInfo = 0;
    }

    if (pObjInfo)
        free( pObjInfo);
    if (pHandles)
        free( pHandles);

    return;
}
Ejemplo n.º 28
0
void tcHookInfo::DrawOwn(tcGameObject *pHookedObj) 
{

    std::string s;
    char zBuff[128];
    float ftextx = 10.0f;
    float ftexty = 22.0f;
	Vec4 color;

    if (pHookedObj == NULL) {return;}


    s = pHookedObj->mzUnit.c_str();
	color.set(0.4f, 1.0f, 0.4f, 1.0f);
	DrawTextR(s.c_str(), ftextx-2.0f, ftexty, defaultFont.get(), color, fontSizeLarge, LEFT_BASE_LINE,
        180.0f);
    ftexty += 20.0f;

    sprintf(zBuff, "%s (id %d)", pHookedObj->GetDisplayClassName(), pHookedObj->mnID);
    s = zBuff;
	DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
    ftexty += 20.0f;

    /*** mnClassID, mnModelType, mnType (classification) ***/
    GetObjectInfo(s, pHookedObj->mpDBObject, pHookedObj);
	DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
    ftexty += 15.0f;

    // speed, heading, altitude, terrain info
    tcKinematics *pkin = &pHookedObj->mcKin;
    
    int heading_deg = int(C_180OVERPI*pkin->mfHeading_rad + 0.5f);
    heading_deg = heading_deg + (int(heading_deg < 0) - int(heading_deg >= 360))*360;

    sprintf(zBuff,"%s, hdg %03d, alt %s",
        units->GetUserSpeedString(pkin->mfSpeed_kts), heading_deg, 
        units->GetUserAltitudeString(pkin->mfAlt_m));

    s = zBuff;
	DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
    ftexty += 15;

    sprintf(zBuff, "Terrain %s", units->GetUserAltitudeString(pHookedObj->mcTerrain.mfHeight_m));
    s = zBuff;
	DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
    ftexty+=15;

    // lat, lon
    LonLatToStringB(C_180OVERPI*(float)pkin->mfLon_rad,C_180OVERPI*(float)pkin->mfLat_rad,s);
	DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
    ftexty += 15;

    /*** damage ***/
	float damageLevelPercent = 100.0f * pHookedObj->GetDamageLevel();
	if (damageLevelPercent > 100.0f) damageLevelPercent = 100.0f;

    if (damageLevelPercent == 0) 
    {
        strcpy(zBuff,"Damage: none");
    }
    else if (damageLevelPercent >= 50.0f) 
    {   
		color.set(1.0f, 0.4f, 0.4f, 1.0f);
        sprintf(zBuff, "Damage: %2.0f%%", damageLevelPercent);
    }
    else 
	{
		color.set(1.0f, 1.0f, 0.4f, 1.0f);
        sprintf(zBuff, "Damage: %2.0f%%", damageLevelPercent);
    }
    s = zBuff;
	DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
    ftexty += 15;
	color.set(0.4f, 1.0f, 0.4f, 1.0f);


	// multiplayer info
	if (mpSS->IsMultiplayerActive())
	{
		const std::string& controller = pHookedObj->GetController();

		if (controller.size())
		{
			s = "Controlled by ";
			s += controller;
		}
		else
		{
			s = "No controller";
		}

		DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
		ftexty += 15;
		color.set(0.4f, 1.0f, 0.4f, 1.0f);
	}
	

    // AI action text for platform objects
    tcPlatformObject* pPlatformObj = dynamic_cast<tcPlatformObject*>(pHookedObj);
    if (pPlatformObj != NULL) 
    {
        std::string text = pPlatformObj->GetBrain()->GetActionText();
        s = "Action: ";
        s += text;
		DrawTextR(s.c_str(), ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
        ftexty += 15;
    }
    if (tcMissileObject* missile = dynamic_cast<tcMissileObject*>(pHookedObj))
    {
        sprintf(zBuff, "Runtime: %.1f", missile->RuntimeRemaining());

		DrawTextR(zBuff, ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
        ftexty += 15;

        sprintf(zBuff, "Distance: %s", units->GetUserDistanceString(missile->GetDistanceFromLaunch()));

		DrawTextR(zBuff, ftextx, ftexty, defaultFont.get(), color, fontSize, LEFT_BASE_LINE);
        ftexty += 15;
        
    }

}
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
int CTFWeaponBuilder::GetSlot( void ) const
{
	return GetObjectInfo( m_iObjectType )->m_SelectionSlot;
}
Ejemplo n.º 30
0
//-----------------------------------------------------------------------------
// Purpose: Return true if this weapon should be visible in the weapon selection
//-----------------------------------------------------------------------------
bool C_TFWeaponBuilder::VisibleInWeaponSelection( void )
{
	return GetObjectInfo( m_iObjectType )->m_bVisibleInWeaponSelection;
}