本文整理汇总了C++中ClearBits函数的典型用法代码示例。如果您正苦于以下问题:C++ ClearBits函数的具体用法?C++ ClearBits怎么用?C++ ClearBits使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ClearBits函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Use
void CPathTrack :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
int on;
// Use toggles between two paths
if ( m_paltpath )
{
on = !FBitSet( pev->spawnflags, SF_PATH_ALTERNATE );
if ( ShouldToggle( useType, on ) )
{
if ( on )
SetBits( pev->spawnflags, SF_PATH_ALTERNATE );
else
ClearBits( pev->spawnflags, SF_PATH_ALTERNATE );
}
}
else // Use toggles between enabled/disabled
{
on = !FBitSet( pev->spawnflags, SF_PATH_DISABLED );
if ( ShouldToggle( useType, on ) )
{
if ( on )
SetBits( pev->spawnflags, SF_PATH_DISABLED );
else
ClearBits( pev->spawnflags, SF_PATH_DISABLED );
}
}
}
示例2: InitSensors
void InitSensors( void )
{
TWCR = 0; // Force TWI off (AD4 & 5 share the TWI pins)
// For DDRx pins, 1 = output, 0 = input.
// For input pins, PORTx = 0 = pullup disabled
// PORTx = 1 = pullup enabled
DDRC = 0; // All input pins
PORTC = 0; // All pullups off
{
// Setup the input pins on Port D
uns8 pins = ( 1 << PgmSelect1 )
| ( 1 << PgmSelect2 )
| ( 1 << PgmSelect4 )
| ( 1 << BlackButton );
ClearBits( DDRD, pins ); // Configure inputs
ClearBits( PORTD, pins ); // Disable pullups
}
ADC_Init( ADC_PRESCALAR_AUTO );
// Delay for a short time to allow the ADC to initialize
ms_spin( 1 );
}
示例3: ClearBits
void CSmokeGrenade::ShieldSecondaryFire( int animUp, int animDown )
{
if( !m_pPlayer->HasShield() || m_flStartThrow )
{
return;
}
if( FBitSet( m_fWeaponState, WEAPONSTATE_SHIELD_DRAWN ) )
{
ClearBits( m_fWeaponState, WEAPONSTATE_SHIELD_DRAWN );
ClearBits( m_pPlayer->m_fUserPrefs, USERPREFS_SHIELD_DRAWN );
SendWeaponAnim( animDown, UseDecrement() );
strcpy( m_pPlayer->m_szAnimExtention, "shieldgren" );
m_flWeaponSpeed = 250.0;
}
else
{
SetBits( m_fWeaponState, WEAPONSTATE_SHIELD_DRAWN );
SetBits( m_pPlayer->m_fUserPrefs, USERPREFS_SHIELD_DRAWN );
SendWeaponAnim( animUp, UseDecrement() );
strcpy( m_pPlayer->m_szAnimExtention, "shielded" );
m_flWeaponSpeed = 180.0;
}
m_pPlayer->UpdateShieldCrosshair( ~m_fWeaponState & WEAPONSTATE_SHIELD_DRAWN );
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.4;
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 0.4;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.6;
}
示例4: Precache
void CRotButton::Spawn( void )
{
Precache();
// set the axis of rotation
AxisDir( pev );
// check for clockwise rotation
if( FBitSet( pev->spawnflags, SF_ROTBUTTON_ROTATE_BACKWARDS ))
pev->movedir = pev->movedir * -1;
pev->movetype = MOVETYPE_PUSH;
if( FBitSet( pev->spawnflags, SF_ROTBUTTON_PASSABLE ))
pev->solid = SOLID_NOT;
else pev->solid = SOLID_BSP;
// shared code use this flag as BUTTON_DONTMOVE so we need to clear it here
ClearBits( pev->spawnflags, SF_ROTBUTTON_PASSABLE );
ClearBits( pev->spawnflags, SF_BUTTON_SPARK_IF_OFF );
ClearBits( pev->spawnflags, SF_BUTTON_DAMAGED_AT_LASER );
SET_MODEL( edict(), GetModel() );
if( pev->speed == 0 )
pev->speed = 40;
if( m_flWait == 0 )
m_flWait = 1;
if( pev->health > 0 )
{
pev->takedamage = DAMAGE_YES;
}
m_iState = STATE_OFF;
m_vecAngle1 = GetLocalAngles();
m_vecAngle2 = GetLocalAngles() + pev->movedir * m_flMoveDistance;
ASSERTSZ( m_vecAngle1 != m_vecAngle2, "rotating button start/end positions are equal" );
m_fStayPushed = (m_flWait == -1) ? TRUE : FALSE;
m_fRotating = TRUE;
// if the button is flagged for USE button activation only, take away it's touch function and add a use function
if( !FBitSet( pev->spawnflags, SF_BUTTON_TOUCH_ONLY ))
{
SetTouch( NULL );
SetUse( &CBaseButton::ButtonUse );
}
else
{
// touchable button
SetTouch( &CBaseButton::ButtonTouch );
}
UTIL_SetOrigin( this, GetLocalOrigin( ));
m_pUserData = WorldPhysic->CreateKinematicBodyFromEntity( this );
}
示例5: ClearBits
bool BitTest::test_ClearBits()
{
int x = 3, y = 5;
ClearBits(x,0,1);
ClearBits(y,1,2);
return (x == 0 & y == 1);
}
示例6: UTIL_SetAvelocity
void UTIL_SetAvelocity(CBaseEntity *pEnt, const Vector vecSet)
{
Vector vecNew;
if (pEnt->m_pMoveWith)
vecNew = vecSet + pEnt->m_pMoveWith->pev->avelocity;
else
vecNew = vecSet;
// ALERT(at_console, "Setting AVelocity %f %f %f\n", vecNew.x, vecNew.y, vecNew.z);
if (pEnt->m_pChildMoveWith)
{
CBaseEntity *pMoving = pEnt->m_pChildMoveWith;
int sloopbreaker = MAX_MOVEWITH_DEPTH; // LRC - to save us from infinite loops
while (pMoving)
{
UTIL_SetMoveWithAvelocity(pMoving, vecNew, MAX_MOVEWITH_DEPTH);
UTIL_MergePos(pMoving); //force to update
if (vecSet != g_vecZero)SetBits(pMoving->m_iLFlags, LF_PARENTMOVE);
else ClearBits(pMoving->m_iLFlags, LF_PARENTMOVE);
pMoving = pMoving->m_pSiblingMoveWith;
sloopbreaker--;
if (sloopbreaker <= 0)
{
ALERT(at_error, "SetAvelocity: Infinite sibling list for MoveWith!\n");
break;
}
}
}
pEnt->pev->avelocity = vecNew;
}
示例7: UTIL_SetVelocity
//LRC
void UTIL_SetVelocity(CBaseEntity *pEnt, const Vector vecSet)
{
Vector vecNew;
if (pEnt->m_pMoveWith)
vecNew = vecSet + pEnt->m_pMoveWith->pev->velocity;
else
vecNew = vecSet;
// ALERT(at_console,"SetV: %s is sent (%f,%f,%f) - goes from (%f,%f,%f) to (%f,%f,%f)\n",
// STRING(pEnt->pev->targetname), vecSet.x, vecSet.y, vecSet.z,
// pEnt->pev->velocity.x, pEnt->pev->velocity.y, pEnt->pev->velocity.z,
// vecNew.x, vecNew.y, vecNew.z
// );
if (pEnt->m_pChildMoveWith)
{
CBaseEntity *pMoving = pEnt->m_pChildMoveWith;
int sloopbreaker = MAX_MOVEWITH_DEPTH; // LRC - to save us from infinite loops
while (pMoving)
{
UTIL_SetMoveWithVelocity(pMoving, vecNew, MAX_MOVEWITH_DEPTH);
if (vecSet != g_vecZero)SetBits(pMoving->m_iLFlags, LF_PARENTMOVE);
else ClearBits(pMoving->m_iLFlags, LF_PARENTMOVE);
pMoving = pMoving->m_pSiblingMoveWith;
sloopbreaker--;
if (sloopbreaker <= 0)
{
ALERT(at_error, "SetVelocity: Infinite sibling list for MoveWith!\n");
break;
}
}
}
pEnt->pev->velocity = vecNew;
}
示例8: HandleAnimEvent
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CHeadCrab :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
switch( pEvent->event )
{
case HC_AE_JUMPATTACK:
{
ClearBits( pev->flags, FL_ONGROUND );
UTIL_SetOrigin (pev, pev->origin + Vector ( 0 , 0 , 1) );// take him off ground so engine doesn't instantly reset onground
UTIL_MakeVectors ( pev->angles );
Vector vecJumpDir;
if (m_hEnemy != NULL)
{
float gravity = g_psv_gravity->value;
if (gravity <= 1)
gravity = 1;
// How fast does the headcrab need to travel to reach that height given gravity?
float height = (m_hEnemy->pev->origin.z + m_hEnemy->pev->view_ofs.z - pev->origin.z);
if (height < 16)
height = 16;
float speed = sqrt( 2 * gravity * height );
float time = speed / gravity;
// Scale the sideways velocity to get there at the right time
vecJumpDir = (m_hEnemy->pev->origin + m_hEnemy->pev->view_ofs - pev->origin);
vecJumpDir = vecJumpDir * ( 1.0 / time );
// Speed to offset gravity at the desired height
vecJumpDir.z = speed;
// Don't jump too far/fast
float distance = vecJumpDir.Length();
if (distance > 650)
{
vecJumpDir = vecJumpDir * ( 650.0 / distance );
}
}
else
{
// jump hop, don't care where
vecJumpDir = Vector( gpGlobals->v_forward.x, gpGlobals->v_forward.y, gpGlobals->v_up.z ) * 350;
}
int iSound = RANDOM_LONG(0,2);
if ( iSound != 0 )
EMIT_SOUND_DYN( edict(), CHAN_VOICE, pAttackSounds[iSound], GetSoundVolue(), ATTN_IDLE, 0, GetVoicePitch() );
pev->velocity = vecJumpDir;
m_flNextAttack = gpGlobals->time + 2;
}
break;
default:
CBaseMonster::HandleAnimEvent( pEvent );
break;
}
}
示例9: UTIL_SetOrigin
void CTriggerCamera::TurnOn( void )
{
pev->dmgtime = gpGlobals->time;
pev->armorvalue = pev->speed;
pev->frags = 0;
// copy over player information
if ( pev->spawnflags & SF_CAMERA_PLAYER_POSITION )
{
UTIL_SetOrigin( this, m_hActivator->pev->origin + m_hActivator->pev->view_ofs );
pev->angles.x = -m_hActivator->pev->angles.x;
pev->angles.y = m_hActivator->pev->angles.y;
pev->angles.z = 0;
pev->velocity = m_hActivator->pev->velocity;
ClearBits( pev->spawnflags, SF_CAMERA_PLAYER_POSITION );
}
// time-based camera
if( m_flWait ) pev->teleport_time = gpGlobals->time + m_flWait;
Move();
UpdatePlayerView();
m_iState = STATE_ON;
SetNextThink( gpGlobals->frametime );
}
示例10: RANDOM_LONG
void CLeech::Killed(entvars_t *pevAttacker, int iGib)
{
Vector vecSplatDir;
TraceResult tr;
//ALERT(at_aiconsole, "Leech: killed\n");
// tell owner ( if any ) that we're dead.This is mostly for MonsterMaker functionality.
CBaseEntity *pOwner = CBaseEntity::Instance(pev->owner);
if (pOwner)
pOwner->DeathNotice(pev);
// When we hit the ground, play the "death_end" activity
if ( pev->waterlevel )
{
pev->angles.z = 0;
pev->angles.x = 0;
pev->origin.z += 1;
pev->avelocity = g_vecZero;
if ( RANDOM_LONG( 0, 99 ) < 70 )
pev->avelocity.y = RANDOM_LONG( -720, 720 );
pev->gravity = 0.02;
ClearBits(pev->flags, FL_ONGROUND);
SetActivity( ACT_DIESIMPLE );
}
else
SetActivity( ACT_DIEFORWARD );
pev->movetype = MOVETYPE_TOSS;
pev->takedamage = DAMAGE_NO;
SetThink( &CLeech::DeadThink );
}
示例11: ClearGuardedMemoryBits
/**
Clear corresponding bits in bitmap table according to given memory range.
@param[in] Address Memory address to unset from.
@param[in] NumberOfPages Number of pages to unset guard.
@return VOID
**/
VOID
EFIAPI
ClearGuardedMemoryBits (
IN EFI_PHYSICAL_ADDRESS Address,
IN UINTN NumberOfPages
)
{
UINT64 *BitMap;
UINTN Bits;
UINTN BitsToUnitEnd;
while (NumberOfPages > 0) {
BitsToUnitEnd = FindGuardedMemoryMap (Address, TRUE, &BitMap);
ASSERT (BitMap != NULL);
if (NumberOfPages > BitsToUnitEnd) {
// Cross map unit
Bits = BitsToUnitEnd;
} else {
Bits = NumberOfPages;
}
ClearBits (Address, Bits, BitMap);
NumberOfPages -= Bits;
Address += EFI_PAGES_TO_SIZE (Bits);
}
}
示例12: ClearBits
int CSentry::TakeDamage(entvars_t *pevInflictor, entvars_t *pevAttacker, float flDamage, int bitsDamageType)
{
if ( !pev->takedamage )
return 0;
// if (!m_iOn)
// {
// SetThink( Deploy );
// SetUse( NULL );
// pev->nextthink = gpGlobals->time + 0.1;
// }
pev->health -= flDamage;
if (pev->health <= 0)
{
pev->health = 0;
pev->takedamage = DAMAGE_NO;
pev->dmgtime = gpGlobals->time;
ClearBits (pev->flags, FL_MONSTER); // why are they set in the first place???
SetUse(NULL);
SetThink(&CSentry::SentryDeath);
SUB_UseTargets( this, USE_ON, 0 ); // wake up others
pev->nextthink = gpGlobals->time + 0.1;
return 0;
}
return 1;
}
示例13: ClearBits
void CUSP::SecondaryAttack()
{
if( ShieldSecondaryFire( GUN_SHIELD_UP, GUN_SHIELD_DOWN ) )
{
return;
}
int anim;
if( FBitSet( m_fWeaponState, WEAPONSTATE_USP_SILENCED ) )
{
ClearBits( m_fWeaponState, WEAPONSTATE_USP_SILENCED );
anim = USP_DETACH_SILENCER;
}
else
{
SetBits( m_fWeaponState, WEAPONSTATE_USP_SILENCED );
anim = USP_ADD_SILENCER;
}
SendWeaponAnim( anim, UseDecrement() );
strcpy( m_pPlayer->m_szAnimExtention, "onehanded" );
m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + 3.0;
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 3.0;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3.0;
}
示例14: GetNextTarget
//
// Train next - path corner needs to change to next target
//
void CFuncTrain::Next( void )
{
CBaseEntity *pTarg;
// now find our next target
//TODO: this entity is supposed to work with path_corner only. Other entities will work, but will probably misbehave. - Solokiller
//Check for classname and ignore others?
pTarg = GetNextTarget();
if( !pTarg )
{
if( pev->noiseMovement )
STOP_SOUND( this, CHAN_STATIC, ( char* ) STRING( pev->noiseMovement ) );
// Play stop sound
if( pev->noiseStopMoving )
EMIT_SOUND( this, CHAN_VOICE, ( char* ) STRING( pev->noiseStopMoving ), m_volume, ATTN_NORM );
return;
}
// Save last target in case we need to find it again
pev->message = pev->target;
pev->target = pTarg->pev->target;
m_flWait = pTarg->GetDelay();
if( m_pevCurrentTarget && m_pevCurrentTarget->speed != 0 )
{// don't copy speed from target if it is 0 (uninitialized)
pev->speed = m_pevCurrentTarget->speed;
ALERT( at_aiconsole, "Train %s speed to %4.2f\n", GetTargetname(), pev->speed );
}
m_pevCurrentTarget = pTarg->pev;// keep track of this since path corners change our target for us.
pev->enemy = pTarg->edict();//hack
if( FBitSet( m_pevCurrentTarget->spawnflags, SF_CORNER_TELEPORT ) )
{
// Path corner has indicated a teleport to the next corner.
SetBits( pev->effects, EF_NOINTERP );
SetAbsOrigin( pTarg->GetAbsOrigin() - ( pev->mins + pev->maxs )* 0.5 );
Wait(); // Get on with doing the next path corner.
}
else
{
// Normal linear move.
// CHANGED this from CHAN_VOICE to CHAN_STATIC around OEM beta time because trains should
// use CHAN_STATIC for their movement sounds to prevent sound field problems.
// this is not a hack or temporary fix, this is how things should be. (sjb).
if( pev->noiseMovement )
{
STOP_SOUND( this, CHAN_STATIC, ( char* ) STRING( pev->noiseMovement ) );
EMIT_SOUND( this, CHAN_STATIC, ( char* ) STRING( pev->noiseMovement ), m_volume, ATTN_NORM );
}
ClearBits( pev->effects, EF_NOINTERP );
SetMoveDone( &CFuncTrain::Wait );
LinearMove( pTarg->GetAbsOrigin() - ( pev->mins + pev->maxs )* 0.5, pev->speed );
}
}
示例15: Killed
void CFlyingMonster :: Killed( entvars_t *pevAttacker, int iGib )
{
pev->movetype = MOVETYPE_STEP;
ClearBits( pev->flags, FL_ONGROUND );
pev->angles.z = 0;
pev->angles.x = 0;
CBaseMonster::Killed( pevAttacker, iGib );
}