您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ GetFlags函数代码示例

51自学网 2021-06-01 21:08:10
  C++
这篇教程C++ GetFlags函数代码示例写得很实用,希望能帮到您。

本文整理汇总了C++中GetFlags函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFlags函数的具体用法?C++ GetFlags怎么用?C++ GetFlags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。

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

示例1: i

// Count valid remaining entries and the number of blocks in them.void BackupStoreCheck::CountDirectoryEntries(BackupStoreDirectory& dir){	BackupStoreDirectory::Iterator i(dir);	BackupStoreDirectory::Entry *en = 0;	while((en = i.Next()) != 0)	{		int32_t iIndex;		IDBlock *piBlock = LookupID(en->GetObjectID(), iIndex);		bool badEntry = false;		bool wasAlreadyContained = false;		ASSERT(piBlock != 0 ||			mDirsWhichContainLostDirs.find(en->GetObjectID())			!= mDirsWhichContainLostDirs.end());		if (piBlock)		{			// Normally it would exist and this			// check would not be necessary, but			// we might have missing directories			// that we will recreate later.			// cf mDirsWhichContainLostDirs.			uint8_t iflags = GetFlags(piBlock, iIndex);			wasAlreadyContained = (iflags & Flags_IsContained);			SetFlags(piBlock, iIndex, iflags | Flags_IsContained);		}		if(wasAlreadyContained)		{			// don't double-count objects that are			// contained by another directory as well.		}		else if(en->IsDir())		{			mNumDirectories++;		}		else if(!en->IsFile())		{			BOX_TRACE("Not counting object " <<				BOX_FORMAT_OBJECTID(en->GetObjectID()) <<				" with flags " << en->GetFlags());		}		else // it's a file		{			// Add to sizes?			// If piBlock was zero, then wasAlreadyContained			// might be uninitialized; but we only process			// files here, and if a file's piBlock was zero			// then badEntry would be set above, so we			// wouldn't be here.			ASSERT(!badEntry)			// It can be both old and deleted.			// If neither, then it's current.			if(en->IsDeleted())			{				mNumDeletedFiles++;				mBlocksInDeletedFiles += en->GetSizeInBlocks();			}			if(en->IsOld())			{				mNumOldFiles++;				mBlocksInOldFiles += en->GetSizeInBlocks();			}			if(!en->IsDeleted() && !en->IsOld())			{				mNumCurrentFiles++;				mBlocksInCurrentFiles += en->GetSizeInBlocks();			}		}		mapNewRefs->AddReference(en->GetObjectID());	}}
开发者ID:jamesog,项目名称:boxbackup,代码行数:77,


示例2: GetBestSize

bool wxRibbonPanel::ShowExpanded(){    if(!IsMinimised())    {        return false;    }    if(m_expanded_dummy != NULL || m_expanded_panel != NULL)    {        return false;    }    wxSize size = GetBestSize();    // Special case for flexible panel layout, where GetBestSize doesn't work    if (GetFlags() & wxRIBBON_PANEL_FLEXIBLE)    {        size = GetBestSizeForParentSize(wxSize(400, 1000));    }    wxPoint pos = GetExpandedPosition(wxRect(GetScreenPosition(), GetSize()),        size, m_preferred_expand_direction).GetTopLeft();    // Need a top-level frame to contain the expanded panel    wxFrame *container = new wxFrame(NULL, wxID_ANY, GetLabel(),        pos, size, wxFRAME_NO_TASKBAR | wxBORDER_NONE);    m_expanded_panel = new wxRibbonPanel(container, wxID_ANY,        GetLabel(), m_minimised_icon, wxPoint(0, 0), size, (m_flags /* & ~wxRIBBON_PANEL_FLEXIBLE */));    m_expanded_panel->SetArtProvider(m_art);    m_expanded_panel->m_expanded_dummy = this;    // Move all children to the new panel.    // Conceptually it might be simpler to reparent this entire panel to the    // container and create a new panel to sit in its place while expanded.    // This approach has a problem though - when the panel is reinserted into    // its original parent, it'll be at a different position in the child list    // and thus assume a new position.    // NB: Children iterators not used as behaviour is not well defined    // when iterating over a container which is being emptied#if defined(__INTEL_COMPILER) && 1 /* VDM auto patch */#   pragma ivdep#   pragma swp#   pragma unroll#   pragma prefetch#   if 0#       pragma simd noassert#   endif#endif /* VDM auto patch */    while(!GetChildren().IsEmpty())    {        wxWindow *child = GetChildren().GetFirst()->GetData();        child->Reparent(m_expanded_panel);        child->Show();    }    // Move sizer to new panel    if(GetSizer())    {        wxSizer* sizer = GetSizer();        SetSizer(NULL, false);        m_expanded_panel->SetSizer(sizer);    }    m_expanded_panel->Realize();    Refresh();    container->SetMinClientSize(size);    container->Show();    m_expanded_panel->SetFocus();    return true;}
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:72,


示例3: switch

//-----------------------------------------------------------------------------// Purpose: // Input  : pTask - //-----------------------------------------------------------------------------void CNPC_Crow::RunTask( const Task_t *pTask ){	switch ( pTask->iTask )	{		case TASK_CROW_TAKEOFF:		{			if ( GetNavigator()->IsGoalActive() )			{				GetMotor()->SetIdealYawToTargetAndUpdate( GetAbsOrigin() + GetNavigator()->GetCurWaypointPos(), AI_KEEP_YAW_SPEED );			}			else				TaskFail( FAIL_NO_ROUTE );			if ( IsActivityFinished() )			{				TaskComplete();				SetIdealActivity( ACT_FLY );				m_bSoar = false;				m_flSoarTime = gpGlobals->curtime + random->RandomFloat( 2, 5 );			}						break;		}		case TASK_CROW_HOP:		{			if ( IsActivityFinished() )			{				TaskComplete();				SetIdealActivity( ACT_IDLE );			}			if ( ( GetAbsOrigin().z < m_flHopStartZ ) && ( !( GetFlags() & FL_ONGROUND ) ) )			{				//				// We've hopped off of something! See if we're going to fall very far.				//				trace_t tr;				AI_TraceLine( GetAbsOrigin(), GetAbsOrigin() + Vector( 0, 0, -32 ), MASK_SOLID, this, HL2COLLISION_GROUP_CROW, &tr );				if ( tr.fraction == 1.0f )				{					//					// We're falling! Better fly away. SelectSchedule will check ONGROUND and do the right thing.					//					TaskComplete();				}				else				{					//					// We'll be okay. Don't check again unless what we're hopping onto moves					// out from under us.					//					m_flHopStartZ = GetAbsOrigin().z - ( 32 * tr.fraction );				}			}			break;		}		//		// Face the direction we are flying.		//		case TASK_CROW_FLY:		{			GetMotor()->SetIdealYawToTargetAndUpdate( GetAbsOrigin() + GetAbsVelocity(), AI_KEEP_YAW_SPEED );			break;		}		case TASK_CROW_FALL_TO_GROUND:		{			if ( GetFlags() & FL_ONGROUND )			{				SetFlyingState( FlyState_Walking );				TaskComplete();			}			break;		}		case TASK_CROW_WAIT_FOR_BARNACLE_KILL:		{			if ( m_flNextFlinchTime < gpGlobals->curtime )			{				m_flNextFlinchTime = gpGlobals->curtime + random->RandomFloat( 0.5f, 2.0f );				// dvs: TODO: squirm				// dvs: TODO: spawn feathers				EmitSound( "NPC_Crow.Squawk" );			}			break;		}		default:		{			CAI_BaseNPC::RunTask( pTask );		}//.........这里部分代码省略.........
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:101,


示例4: EqPartial

// Partial equality test. Only returns false if an attribute doesn't match.bool wxTextAttr::EqPartial(const wxTextAttr& attr, bool weakTest) const{    int flags = attr.GetFlags();    if (!weakTest &&        ((!HasTextColour() && attr.HasTextColour()) ||         (!HasBackgroundColour() && attr.HasBackgroundColour()) ||         (!HasFontFaceName() && attr.HasFontFaceName()) ||         (!HasFontSize() && attr.HasFontSize()) ||         (!HasFontWeight() && attr.HasFontWeight()) ||         (!HasFontItalic() && attr.HasFontItalic()) ||         (!HasFontUnderlined() && attr.HasFontUnderlined()) ||         (!HasFontStrikethrough() && attr.HasFontStrikethrough()) ||         (!HasFontEncoding() && attr.HasFontEncoding()) ||         (!HasFontFamily() && attr.HasFontFamily()) ||         (!HasURL() && attr.HasURL()) ||         (!HasAlignment() && attr.HasAlignment()) ||         (!HasLeftIndent() && attr.HasLeftIndent()) ||         (!HasParagraphSpacingAfter() && attr.HasParagraphSpacingAfter()) ||         (!HasParagraphSpacingBefore() && attr.HasParagraphSpacingBefore()) ||         (!HasLineSpacing() && attr.HasLineSpacing()) ||         (!HasCharacterStyleName() && attr.HasCharacterStyleName()) ||         (!HasParagraphStyleName() && attr.HasParagraphStyleName()) ||         (!HasListStyleName() && attr.HasListStyleName()) ||         (!HasBulletStyle() && attr.HasBulletStyle()) ||         (!HasBulletNumber() && attr.HasBulletNumber()) ||         (!HasBulletText() && attr.HasBulletText()) ||         (!HasBulletName() && attr.HasBulletName()) ||         (!HasTabs() && attr.HasTabs()) ||         (!HasTextEffects() && attr.HasTextEffects()) ||         (!HasOutlineLevel() && attr.HasOutlineLevel())))    {        return false;    }    if (HasTextColour() && attr.HasTextColour() && GetTextColour() != attr.GetTextColour())        return false;    if (HasBackgroundColour() && attr.HasBackgroundColour() && GetBackgroundColour() != attr.GetBackgroundColour())        return false;    if (HasFontFaceName() && attr.HasFontFaceName() && GetFontFaceName() != attr.GetFontFaceName())        return false;    // This checks whether the two objects have the same font size dimension (px versus pt)    if (HasFontSize() && attr.HasFontSize() && (flags & wxTEXT_ATTR_FONT) != (GetFlags() & wxTEXT_ATTR_FONT))        return false;    if (HasFontPointSize() && attr.HasFontPointSize() && GetFontSize() != attr.GetFontSize())        return false;    if (HasFontPixelSize() && attr.HasFontPixelSize() && GetFontSize() != attr.GetFontSize())        return false;    if (HasFontWeight() && attr.HasFontWeight() && GetFontWeight() != attr.GetFontWeight())        return false;    if (HasFontItalic() && attr.HasFontItalic() && GetFontStyle() != attr.GetFontStyle())        return false;    if (HasFontUnderlined() && attr.HasFontUnderlined() && GetFontUnderlined() != attr.GetFontUnderlined())        return false;    if (HasFontStrikethrough() && attr.HasFontStrikethrough() && GetFontStrikethrough() != attr.GetFontStrikethrough())        return false;    if (HasFontEncoding() && attr.HasFontEncoding() && GetFontEncoding() != attr.GetFontEncoding())        return false;    if (HasFontFamily() && attr.HasFontFamily() && GetFontFamily() != attr.GetFontFamily())        return false;    if (HasURL() && attr.HasURL() && GetURL() != attr.GetURL())        return false;    if (HasAlignment() && attr.HasAlignment() && GetAlignment() != attr.GetAlignment())        return false;    if (HasLeftIndent() && attr.HasLeftIndent() &&        ((GetLeftIndent() != attr.GetLeftIndent()) || (GetLeftSubIndent() != attr.GetLeftSubIndent())))        return false;    if (HasRightIndent() && attr.HasRightIndent() && (GetRightIndent() != attr.GetRightIndent()))        return false;    if (HasParagraphSpacingAfter() && attr.HasParagraphSpacingAfter() &&        (GetParagraphSpacingAfter() != attr.GetParagraphSpacingAfter()))        return false;    if (HasParagraphSpacingBefore() && attr.HasParagraphSpacingBefore() &&        (GetParagraphSpacingBefore() != attr.GetParagraphSpacingBefore()))        return false;    if (HasLineSpacing() && attr.HasLineSpacing() && (GetLineSpacing() != attr.GetLineSpacing()))        return false;    if (HasCharacterStyleName() && attr.HasCharacterStyleName() && (GetCharacterStyleName() != attr.GetCharacterStyleName()))        return false;//.........这里部分代码省略.........
开发者ID:AaronDP,项目名称:wxWidgets,代码行数:101,


示例5: defined

//.........这里部分代码省略.........	//Msg( "PushScale = %f/n", flPushStrength );	// Check to see if we have enough push strength to make a difference.	if ( flPushStrength < 0.01f )		return;	Vector vecPush;	if ( GetAbsVelocity().Length2DSqr() > 0.1f )	{		Vector vecVelocity = GetAbsVelocity();		vecVelocity.z = 0.0f;		CrossProduct( vecUp, vecVelocity, vecPush );		VectorNormalize( vecPush );	}	else	{		// We are not moving, but we're still intersecting.		QAngle angView = pCmd->viewangles;		angView.x = 0.0f;		AngleVectors( angView, NULL, &vecPush, NULL );	}	// Move away from the other player/object.	Vector vecSeparationVelocity;	if ( vecDelta.Dot( vecPush ) < 0 )	{		vecSeparationVelocity = vecPush * flPushStrength;	}	else	{		vecSeparationVelocity = vecPush * -flPushStrength;	}	// Don't allow the MAX push speed to be greater than the MAX player speed.	float flMaxPlayerSpeed = MaxSpeed();	float flCropFraction = 1.33333333f;	if ( ( GetFlags() & FL_DUCKING ) && ( GetGroundEntity() != NULL ) )	{			flMaxPlayerSpeed *= flCropFraction;	}		float flMaxPlayerSpeedSqr = flMaxPlayerSpeed * flMaxPlayerSpeed;	if ( vecSeparationVelocity.LengthSqr() > flMaxPlayerSpeedSqr )	{		vecSeparationVelocity.NormalizeInPlace();		VectorScale( vecSeparationVelocity, flMaxPlayerSpeed, vecSeparationVelocity );	}	QAngle vAngles = pCmd->viewangles;	vAngles.x = 0;	Vector currentdir;	Vector rightdir;	AngleVectors( vAngles, &currentdir, &rightdir, NULL );	Vector vDirection = vecSeparationVelocity;	VectorNormalize( vDirection );	float fwd = currentdir.Dot( vDirection );	float rt = rightdir.Dot( vDirection );	float forward = fwd * flPushStrength;	float side = rt * flPushStrength;	//Msg( "fwd: %f - rt: %f - forward: %f - side: %f/n", fwd, rt, forward, side );	pCmd->forwardmove	+= forward;	pCmd->sidemove		+= side;	// Clamp the move to within legal limits, preserving direction. This is a little	// complicated because we have different limits for forward, back, and side	//Msg( "PRECLAMP: forwardmove=%f, sidemove=%f/n", pCmd->forwardmove, pCmd->sidemove );	float flForwardScale = 1.0f;	if ( pCmd->forwardmove > fabs( cl_forwardspeed.GetFloat() ) )	{		flForwardScale = fabs( cl_forwardspeed.GetFloat() ) / pCmd->forwardmove;	}	else if ( pCmd->forwardmove < -fabs( cl_backspeed.GetFloat() ) )	{		flForwardScale = fabs( cl_backspeed.GetFloat() ) / fabs( pCmd->forwardmove );	}	float flSideScale = 1.0f;	if ( fabs( pCmd->sidemove ) > fabs( cl_sidespeed.GetFloat() ) )	{		flSideScale = fabs( cl_sidespeed.GetFloat() ) / fabs( pCmd->sidemove );	}	float flScale = MIN( flForwardScale, flSideScale );	pCmd->forwardmove *= flScale;	pCmd->sidemove *= flScale;	//Msg( "Pforwardmove=%f, sidemove=%f/n", pCmd->forwardmove, pCmd->sidemove );#endif}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:101,


示例6: GetFlags

void wxSettableHeaderColumn::ClearFlag(int flag){    int flags = GetFlags();    if ( flags & flag )        SetFlags(flags & ~flag);}
开发者ID:chromylei,项目名称:third_party,代码行数:6,


示例7: GetFlags

wxString wxAcceleratorEntry::AsPossiblyLocalizedString(bool localized) const{    wxString text;    int flags = GetFlags();    if ( flags & wxACCEL_ALT )        text += PossiblyLocalize(wxTRANSLATE("Alt+"), localized);    if ( flags & wxACCEL_CTRL )        text += PossiblyLocalize(wxTRANSLATE("Ctrl+"), localized);    if ( flags & wxACCEL_SHIFT )        text += PossiblyLocalize(wxTRANSLATE("Shift+"), localized);#if defined(__WXMAC__) || defined(__WXCOCOA__)    if ( flags & wxACCEL_RAW_CTRL )        text += PossiblyLocalize(wxTRANSLATE("RawCtrl+"), localized);#endif        const int code = GetKeyCode();    if ( code >= WXK_F1 && code <= WXK_F12 )        text << PossiblyLocalize(wxTRANSLATE("F"), localized)             << code - WXK_F1 + 1;    else if ( code >= WXK_NUMPAD0 && code <= WXK_NUMPAD9 )        text << PossiblyLocalize(wxTRANSLATE("KP_"), localized)             << code - WXK_NUMPAD0;    else if ( code >= WXK_SPECIAL1 && code <= WXK_SPECIAL20 )        text << PossiblyLocalize(wxTRANSLATE("SPECIAL"), localized)             << code - WXK_SPECIAL1 + 1;    else // check the named keys    {        size_t n;        for ( n = 0; n < WXSIZEOF(wxKeyNames); n++ )        {            const wxKeyName& kn = wxKeyNames[n];            if ( code == kn.code )            {                text << PossiblyLocalize(kn.name, localized);                break;            }        }        if ( n == WXSIZEOF(wxKeyNames) )        {            // must be a simple key            if (#if !wxUSE_UNICODE                 // we can't call wxIsalnum() for non-ASCII characters in ASCII                 // build as they're only defined for the ASCII range (or EOF)                 wxIsascii(code) &&#endif // ANSI                    wxIsprint(code) )            {                text << (wxChar)code;            }            else            {                wxFAIL_MSG( wxT("unknown keyboard accelerator code") );            }        }    }    return text;}
开发者ID:0ryuO,项目名称:dolphin-avsync,代码行数:62,


示例8: ExecuteCreateDestructibleMesh

void FAssetTypeActions_StaticMesh::ExecuteCreateDestructibleMesh(TArray<TWeakObjectPtr<UStaticMesh>> Objects){	TArray< UObject* > Assets;	for (auto ObjIt = Objects.CreateConstIterator(); ObjIt; ++ObjIt)	{		auto Object = (*ObjIt).Get();		if ( Object )		{			FText ErrorMsg;			FDestructibleMeshEditorModule& DestructibleMeshEditorModule = FModuleManager::LoadModuleChecked<FDestructibleMeshEditorModule>( "DestructibleMeshEditor" );			UDestructibleMesh* DestructibleMesh = DestructibleMeshEditorModule.CreateDestructibleMeshFromStaticMesh(Object->GetOuter(), Object, NAME_None, Object->GetFlags(), ErrorMsg);			if ( DestructibleMesh )			{				FAssetEditorManager::Get().OpenEditorForAsset(DestructibleMesh);				Assets.Add(DestructibleMesh);			}			else if ( !ErrorMsg.IsEmpty() )			{				FNotificationInfo ErrorNotification( ErrorMsg );				FSlateNotificationManager::Get().AddNotification(ErrorNotification);			}		}	}	if ( Assets.Num() > 0 )	{		FAssetTools::Get().SyncBrowserToAssets(Assets);	}}
开发者ID:PickUpSU,项目名称:UnrealEngine4,代码行数:28,


示例9: GetFlags

FX_BOOL	CPDFSDK_Annot::IsVisible() const{	int nFlags = GetFlags();	return !((nFlags & ANNOTFLAG_INVISIBLE) || (nFlags & ANNOTFLAG_HIDDEN) || (nFlags & ANNOTFLAG_NOVIEW));}
开发者ID:witwall,项目名称:pdfium,代码行数:5,


示例10: ObserverUse

//-----------------------------------------------------------------------------// Purpose: Handles USE keypress//-----------------------------------------------------------------------------void CBasePlayer::PlayerUse ( void ){#ifdef GAME_DLL	// Was use pressed or released?	if ( ! ((m_nButtons | m_afButtonPressed | m_afButtonReleased) & IN_USE) )		return;	if ( IsObserver() )	{		// do special use operation in oberserver mode		if ( m_afButtonPressed & IN_USE )			ObserverUse( true );		else if ( m_afButtonReleased & IN_USE )			ObserverUse( false );				return;	}#if !defined(_XBOX)	// push objects in turbo physics mode	if ( (m_nButtons & IN_USE) && sv_turbophysics.GetBool() )	{		Vector forward, up;		EyeVectors( &forward, NULL, &up );		trace_t tr;		// Search for objects in a sphere (tests for entities that are not solid, yet still useable)		Vector searchCenter = EyePosition();		CUsePushFilter filter;		UTIL_TraceLine( searchCenter, searchCenter + forward * 96.0f, MASK_SOLID, &filter, &tr );		// try the hit entity if there is one, or the ground entity if there isn't.		CBaseEntity *entity = tr.m_pEnt;		if ( entity )		{			IPhysicsObject *pObj = entity->VPhysicsGetObject();			if ( pObj )			{				Vector vPushAway = (entity->WorldSpaceCenter() - WorldSpaceCenter());				vPushAway.z = 0;				float flDist = VectorNormalize( vPushAway );				flDist = max( flDist, 1 );				float flForce = sv_pushaway_force.GetFloat() / flDist;				flForce = min( flForce, sv_pushaway_max_force.GetFloat() );				pObj->ApplyForceOffset( vPushAway * flForce, WorldSpaceCenter() );			}		}	}#endif	if ( m_afButtonPressed & IN_USE )	{		// Controlling some latched entity?		if ( ClearUseEntity() )		{			return;		}		else		{			if ( m_afPhysicsFlags & PFLAG_DIROVERRIDE )			{				m_afPhysicsFlags &= ~PFLAG_DIROVERRIDE;				m_iTrain = TRAIN_NEW|TRAIN_OFF;				return;			}			else			{	// Start controlling the train!				CBaseEntity *pTrain = GetGroundEntity();				if ( pTrain && !(m_nButtons & IN_JUMP) && (GetFlags() & FL_ONGROUND) && (pTrain->ObjectCaps() & FCAP_DIRECTIONAL_USE) && pTrain->OnControls(this) )				{					m_afPhysicsFlags |= PFLAG_DIROVERRIDE;					m_iTrain = TrainSpeed(pTrain->m_flSpeed, ((CFuncTrackTrain*)pTrain)->GetMaxSpeed());					m_iTrain |= TRAIN_NEW;					EmitSound( "Player.UseTrain" );					return;				}			}		}	}	CBaseEntity *pUseEntity = FindUseEntity();	// Found an object	if ( pUseEntity )	{		//!!!UNDONE: traceline here to prevent +USEing buttons through walls					int caps = pUseEntity->ObjectCaps();		variant_t emptyVariant;//.........这里部分代码省略.........
开发者ID:kbeirne,项目名称:SourceEngineBlink,代码行数:101,


示例11: VectorLength

void CBasePlayer::UpdateStepSound( surfacedata_t *psurface, const Vector &vecOrigin, const Vector &vecVelocity ){	bool bWalking;	float fvol;	Vector knee;	Vector feet;	float height;	float speed;	float velrun;	float velwalk;	int	fLadder;	if ( m_flStepSoundTime > 0 )	{		m_flStepSoundTime -= 1000.0f * gpGlobals->frametime;		if ( m_flStepSoundTime < 0 )		{			m_flStepSoundTime = 0;		}	}	if ( m_flStepSoundTime > 0 )		return;	if ( GetFlags() & (FL_FROZEN|FL_ATCONTROLS))		return;	if ( GetMoveType() == MOVETYPE_NOCLIP || GetMoveType() == MOVETYPE_OBSERVER )		return;	if ( !sv_footsteps.GetFloat() )		return;	speed = VectorLength( vecVelocity );	float groundspeed = Vector2DLength( vecVelocity.AsVector2D() );	// determine if we are on a ladder	fLadder = ( GetMoveType() == MOVETYPE_LADDER );	GetStepSoundVelocities( &velwalk, &velrun );	bool onground = ( GetFlags() & FL_ONGROUND );	bool movingalongground = ( groundspeed > 0.0001f );	bool moving_fast_enough =  ( speed >= velwalk );#ifdef PORTAL	// In Portal we MUST play footstep sounds even when the player is moving very slowly	// This is used to count the number of footsteps they take in the challenge mode	// -Jeep	moving_fast_enough = true;#endif	// To hear step sounds you must be either on a ladder or moving along the ground AND	// You must be moving fast enough	if ( !moving_fast_enough || !(fLadder || ( onground && movingalongground )) )			return;//	MoveHelper()->PlayerSetAnimation( PLAYER_WALK );	bWalking = speed < velrun;			VectorCopy( vecOrigin, knee );	VectorCopy( vecOrigin, feet );	height = GetPlayerMaxs()[ 2 ] - GetPlayerMins()[ 2 ];	knee[2] = vecOrigin[2] + 0.2 * height;	// find out what we're stepping in or on...	if ( fLadder )	{		psurface = GetLadderSurface(vecOrigin);		fvol = 0.5;		SetStepSoundTime( STEPSOUNDTIME_ON_LADDER, bWalking );	}	else if ( GetWaterLevel() == WL_Waist )	{		static int iSkipStep = 0;		if ( iSkipStep == 0 )		{			iSkipStep++;			return;		}		if ( iSkipStep++ == 3 )		{			iSkipStep = 0;		}		psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "wade" ) );		fvol = 0.65;		SetStepSoundTime( STEPSOUNDTIME_WATER_KNEE, bWalking );	}	else if ( GetWaterLevel() == WL_Feet )	{		psurface = physprops->GetSurfaceData( physprops->GetSurfaceIndex( "water" ) );		fvol = bWalking ? 0.2 : 0.5;//.........这里部分代码省略.........
开发者ID:kbeirne,项目名称:SourceEngineBlink,代码行数:101,


示例12: MakePlayerAlreadyMember

void Channel::Join(uint64 p, const char *pass){    WorldPacket data;    if (IsOn(p))    {        if (!IsConstant())                                   // non send error message for built-in channels        {            MakePlayerAlreadyMember(&data, p);            SendToOne(&data, p);        }        return;    }    Player *plr = sObjectMgr.GetPlayer(p);    if ((!plr || !plr->isGameMaster()) && !IsConstant() && m_name != "world" && m_name != "engworld" && m_name != "handel")    {        uint32 limitCount = sWorld.getConfig(CONFIG_PRIVATE_CHANNEL_LIMIT);        if (limitCount && players.size() > limitCount)        {            MakeInvalidName(&data);            SendToOne(&data, p);            return;        }    }    if (!m_ownerGUID && (!plr || !plr->CanSpeak())) // muted players can't create new channels    {        MakeBanned(&data);//no idea what to send        SendToOne(&data, p);        return;    }    if (IsBanned(p) && (!plr || !plr->isGameMaster()))    {        MakeBanned(&data);        SendToOne(&data, p);        return;    }    if (m_password.length() > 0 && strcmp(pass, m_password.c_str()) && (!plr || !plr->isGameMaster()))    {        MakeWrongPassword(&data);        SendToOne(&data, p);        return;    }    if (plr)    {        if (IsLFG() &&            sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && !plr->GetSession()->HasPermissions(PERM_GMT) &&            plr->m_lookingForGroup.Empty())        {            MakeNotInLfg(&data);            SendToOne(&data, p);            return;        }        if (plr->GetGuildId() && (GetFlags() == 0x38))            return;        plr->JoinedChannel(this);    }    if (m_announce && (!plr || !plr->GetSession()->HasPermissions(PERM_GMT) || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))    {        //MakeJoined(&data, p);        //SendToAll(&data);    }    data.clear();    PlayerInfo pinfo;    pinfo.player = p;    pinfo.flags = 0;    players[p] = pinfo;    MakeYouJoined(&data);    SendToOne(&data, p);    JoinNotify(p);    // if no owner first logged will become    if (!IsConstant() && !m_ownerGUID)    {        SetOwner(p, (players.size() > 1 ? true : false));        players[p].SetModerator(true);    }}
开发者ID:Blumfield,项目名称:ptc2,代码行数:90,


示例13: LookupID

bool BackupStoreCheck::CheckDirectoryEntry(BackupStoreDirectory::Entry& rEntry,	int64_t DirectoryID, bool& rIsModified){	int32_t IndexInDirBlock;	IDBlock *piBlock = LookupID(rEntry.GetObjectID(), IndexInDirBlock);	ASSERT(piBlock != 0);	uint8_t iflags = GetFlags(piBlock, IndexInDirBlock);	// Is the type the same?	if(((iflags & Flags_IsDir) == Flags_IsDir) != rEntry.IsDir())	{		// Entry is of wrong type		BOX_ERROR("Directory ID " <<			BOX_FORMAT_OBJECTID(DirectoryID) <<			" references object " <<			BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) <<			" which has a different type than expected.");		++mNumberErrorsFound;		return false; // remove this entry	}	// Check that the entry is not already contained.	if(iflags & Flags_IsContained)	{		BOX_ERROR("Directory ID " <<			BOX_FORMAT_OBJECTID(DirectoryID) <<			" references object " <<			BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) <<			" which is already contained.");		++mNumberErrorsFound;		return false; // remove this entry	}	// Not already contained by another directory.	// Don't set the flag until later, after we finish repairing	// the directory and removing all bad entries.		// Check that the container ID of the object is correct	if(piBlock->mContainer[IndexInDirBlock] != DirectoryID)	{		// Needs fixing...		if(iflags & Flags_IsDir)		{			// Add to will fix later list			BOX_ERROR("Directory ID " <<				BOX_FORMAT_OBJECTID(rEntry.GetObjectID())				<< " has wrong container ID.");			mDirsWithWrongContainerID.push_back(rEntry.GetObjectID());			++mNumberErrorsFound;		}		else		{			// This is OK for files, they might move			BOX_INFO("File ID " <<				BOX_FORMAT_OBJECTID(rEntry.GetObjectID())				<< " has different container ID, "				"probably moved");		}				// Fix entry for now		piBlock->mContainer[IndexInDirBlock] = DirectoryID;	}	// Check the object size	if(rEntry.GetSizeInBlocks() != piBlock->mObjectSizeInBlocks[IndexInDirBlock])	{		// Wrong size, correct it.		BOX_ERROR("Directory " << BOX_FORMAT_OBJECTID(DirectoryID) <<			" entry for " << BOX_FORMAT_OBJECTID(rEntry.GetObjectID()) <<			" has wrong size " << rEntry.GetSizeInBlocks() <<			", should be " << piBlock->mObjectSizeInBlocks[IndexInDirBlock]);		rEntry.SetSizeInBlocks(piBlock->mObjectSizeInBlocks[IndexInDirBlock]);		// Mark as changed		rIsModified = true;		++mNumberErrorsFound;	}	return true; // don't delete this entry}
开发者ID:jamesog,项目名称:boxbackup,代码行数:82,


示例14: WrapObject

JSBoolWrapObject(JSContext *cx, JSObject *parent, jsval *vp, XPCWrappedNative* wn){  NS_ASSERTION(XPCPerThreadData::IsMainThread(cx),               "Can't do this off the main thread!");  // Our argument should be a wrapped native object, but the caller may have  // passed it in as an optimization.  JSObject *wrappedObj;  if (JSVAL_IS_PRIMITIVE(*vp) ||      !(wrappedObj = JSVAL_TO_OBJECT(*vp)) ||      wrappedObj->getClass() == &XOWClass) {    return JS_TRUE;  }  if (!wn &&      !(wn = XPCWrappedNative::GetAndMorphWrappedNativeOfJSObject(cx, wrappedObj))) {    return JS_TRUE;  }  CheckWindow(wn);  // The parent must be the inner global object for its scope.  parent = JS_GetGlobalForObject(cx, parent);  OBJ_TO_INNER_OBJECT(cx, parent);  if (!parent) {    return JS_FALSE;  }  XPCWrappedNativeWithXOW *wnxow = nsnull;  if (wn->NeedsXOW()) {    JSObject *innerWrappedObj = wrappedObj;    OBJ_TO_INNER_OBJECT(cx, innerWrappedObj);    if (!innerWrappedObj) {      return JS_FALSE;    }    if (innerWrappedObj == parent) {      wnxow = static_cast<XPCWrappedNativeWithXOW *>(wn);      JSObject *xow = wnxow->GetXOW();      if (xow) {        *vp = OBJECT_TO_JSVAL(xow);        return JS_TRUE;      }    }  }  XPCWrappedNative *parentwn =    XPCWrappedNative::GetWrappedNativeOfJSObject(cx, parent);  XPCWrappedNativeScope *parentScope;  if (NS_LIKELY(parentwn)) {    parentScope = parentwn->GetScope();  } else {    parentScope = XPCWrappedNativeScope::FindInJSObjectScope(cx, parent);  }  JSObject *outerObj = nsnull;  WrappedNative2WrapperMap *map = parentScope->GetWrapperMap();  outerObj = map->Find(wrappedObj);  if (outerObj) {    NS_ASSERTION(outerObj->getClass() == &XOWClass,                 "What crazy object are we getting here?");    *vp = OBJECT_TO_JSVAL(outerObj);    if (wnxow) {      // NB: wnxow->GetXOW() must have returned false.      SetFlags(cx, outerObj, AddFlags(GetFlags(cx, outerObj), FLAG_IS_CACHED));      wnxow->SetXOW(outerObj);    }    return JS_TRUE;  }  outerObj = JS_NewObjectWithGivenProto(cx, js::Jsvalify(&XOWClass), nsnull,                                        parent);  if (!outerObj) {    return JS_FALSE;  }  jsval flags = INT_TO_JSVAL(wnxow ? FLAG_IS_CACHED : 0);  if (!JS_SetReservedSlot(cx, outerObj, sWrappedObjSlot, *vp) ||      !JS_SetReservedSlot(cx, outerObj, sFlagsSlot, flags) ||      !JS_SetReservedSlot(cx, outerObj, XPC_XOW_ScopeSlot,                          PRIVATE_TO_JSVAL(parentScope))) {    return JS_FALSE;  }  *vp = OBJECT_TO_JSVAL(outerObj);  map->Add(wn->GetScope()->GetWrapperMap(), wrappedObj, outerObj);  if(wnxow) {    wnxow->SetXOW(outerObj);  }  return JS_TRUE;}
开发者ID:lofter2011,项目名称:Icefox,代码行数:97,


示例15: ClearMultiDamage

void CBaseGrenade::BounceTouch( CBaseEntity *pOther ){	if ( pOther->IsSolidFlagSet(FSOLID_TRIGGER | FSOLID_VOLUME_CONTENTS) )		return;	// don't hit the guy that launched this grenade	if ( pOther == GetThrower() )		return;	// only do damage if we're moving fairly fast	if ( (pOther->m_takedamage != DAMAGE_NO) && (m_flNextAttack < gpGlobals->curtime && GetAbsVelocity().Length() > 100))	{		if (m_hThrower)		{#if !defined( CLIENT_DLL )			trace_t tr;			tr = CBaseEntity::GetTouchTrace( );			ClearMultiDamage( );			Vector forward;			AngleVectors( GetLocalAngles(), &forward, NULL, NULL );			CTakeDamageInfo info( this, m_hThrower, 1, DMG_CLUB );			CalculateMeleeDamageForce( &info, GetAbsVelocity(), GetAbsOrigin() );			pOther->DispatchTraceAttack( info, forward, &tr ); 			ApplyMultiDamage();#endif		}		m_flNextAttack = gpGlobals->curtime + 1.0; // debounce	}	Vector vecTestVelocity;	// m_vecAngVelocity = Vector (300, 300, 300);	// this is my heuristic for modulating the grenade velocity because grenades dropped purely vertical	// or thrown very far tend to slow down too quickly for me to always catch just by testing velocity. 	// trimming the Z velocity a bit seems to help quite a bit.	vecTestVelocity = GetAbsVelocity(); 	vecTestVelocity.z *= 0.45;	if ( !m_bHasWarnedAI && vecTestVelocity.Length() <= 60 )	{		// grenade is moving really slow. It's probably very close to where it will ultimately stop moving. 		// emit the danger sound.				// register a radius louder than the explosion, so we make sure everyone gets out of the way#if !defined( CLIENT_DLL )		CSoundEnt::InsertSound ( SOUND_DANGER, GetAbsOrigin(), m_flDamage / 0.4, 0.3, this );#endif		m_bHasWarnedAI = true;	}	if (GetFlags() & FL_ONGROUND)	{		// add a bit of static friction//		SetAbsVelocity( GetAbsVelocity() * 0.8 );		// SetSequence( random->RandomInt( 1, 1 ) ); // FIXME: missing tumble animations	}	else	{		// play bounce sound		BounceSound();	}	m_flPlaybackRate = GetAbsVelocity().Length() / 200.0;	if (GetPlaybackRate() > 1.0)		m_flPlaybackRate = 1;	else if (GetPlaybackRate() < 0.5)		m_flPlaybackRate = 0;}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:69,


示例16: GetFlags

CPDF_PageObject* CPDF_Annot::GetBorder(FX_BOOL bPrint, const CPDF_RenderOptions* pOptions){    if (GetSubType() == "Popup") {        return NULL;    }    FX_DWORD annot_flags = GetFlags();    if (annot_flags & ANNOTFLAG_HIDDEN) {        return NULL;    }    FX_BOOL bPrinting = bPrint || (pOptions && (pOptions->m_Flags & RENDER_PRINTPREVIEW));    if (bPrinting && (annot_flags & ANNOTFLAG_PRINT) == 0) {        return NULL;    }    if (!bPrinting && (annot_flags & ANNOTFLAG_NOVIEW)) {        return NULL;    }    CPDF_Dictionary* pBS = m_pAnnotDict->GetDict("BS");    char style_char;    FX_FLOAT width;    CPDF_Array* pDashArray = NULL;    if (pBS == NULL) {        CPDF_Array* pBorderArray = m_pAnnotDict->GetArray("Border");        style_char = 'S';        if (pBorderArray) {            width = pBorderArray->GetNumber(2);            if (pBorderArray->GetCount() == 4) {                pDashArray = pBorderArray->GetArray(3);                if (pDashArray == NULL) {                    return NULL;                }                style_char = 'D';            }        } else {            width = 1;        }    } else {        CFX_ByteString style = pBS->GetString("S");        pDashArray = pBS->GetArray("D");        style_char = style[1];        width = pBS->GetNumber("W");    }    if (width <= 0) {        return NULL;    }    CPDF_Array* pColor = m_pAnnotDict->GetArray("C");    FX_DWORD argb = 0xff000000;    if (pColor != NULL) {        int R = (FX_INT32)(pColor->GetNumber(0) * 255);        int G = (FX_INT32)(pColor->GetNumber(1) * 255);        int B = (FX_INT32)(pColor->GetNumber(2) * 255);        argb = ArgbEncode(0xff, R, G, B);    }    nonstd::unique_ptr<CPDF_PathObject> pPathObject(new CPDF_PathObject());    CPDF_GraphStateData *pGraphState = pPathObject->m_GraphState.GetModify();    if (!pGraphState) {        return NULL;    }    pGraphState->m_LineWidth = width;    CPDF_ColorStateData *pColorData = pPathObject->m_ColorState.GetModify();    if (!pColorData) {        return NULL;    }    pColorData->m_StrokeRGB = argb;    pPathObject->m_bStroke = TRUE;    pPathObject->m_FillType = 0;    if (style_char == 'D') {        if (pDashArray) {            FX_DWORD dash_count = pDashArray->GetCount();            if (dash_count % 2) {                dash_count ++;            }            pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, dash_count);            if (pGraphState->m_DashArray == NULL) {                return NULL;            }            pGraphState->m_DashCount = dash_count;            FX_DWORD i;            for (i = 0; i < pDashArray->GetCount(); i ++) {                pGraphState->m_DashArray[i] = pDashArray->GetNumber(i);            }            if (i < dash_count) {                pGraphState->m_DashArray[i] = pGraphState->m_DashArray[i - 1];            }        } else {            pGraphState->m_DashArray = FX_Alloc(FX_FLOAT, 2);            if (pGraphState->m_DashArray == NULL) {                return NULL;            }            pGraphState->m_DashCount = 2;            pGraphState->m_DashArray[0] = pGraphState->m_DashArray[1] = 3 * 1.0f;        }    }    CFX_FloatRect rect;    GetRect(rect);    width /= 2;    CPDF_PathData *pPathData = pPathObject->m_Path.GetModify();    if (pPathData) {        pPathData->AppendRect(rect.left + width, rect.bottom + width, rect.right - width, rect.top - width);    }    pPathObject->CalcBoundingBox();//.........这里部分代码省略.........
开发者ID:Gardenya,项目名称:pdfium,代码行数:101,


示例17: Msg

//-----------------------------------------------------------------------------// Purpose: called when an event that counts toward an achievement occurs//-----------------------------------------------------------------------------void CBaseAchievement::IncrementCount( int iOptIncrement ){	if ( !IsAchieved() && LocalPlayerCanEarn() )	{		if ( !AlwaysEnabled() && !m_pAchievementMgr->CheckAchievementsEnabled() )		{			Msg( "Achievements disabled, ignoring achievement progress for %s/n", GetName() );			return;		}		// on client, where the count is kept, increment count		if ( iOptIncrement > 0 )		{			// user specified that we want to increase by more than one.			m_iCount += iOptIncrement;			if ( m_iCount > m_iGoal )			{				m_iCount = m_iGoal;			}		}		else		{			m_iCount++;		}		// if this achievement gets saved w/global state, flag our global state as dirty		if ( GetFlags() & ACH_SAVE_GLOBAL )		{			m_pAchievementMgr->SetDirty( true );		}		if ( cc_achievement_debug.GetInt() )		{			Msg( "Achievement count increased for %s: %d/%d/n", GetName(), m_iCount, m_iGoal );		}#ifndef NO_STEAM		// if this achievement's progress should be stored in Steam, set the steam stat for it		if ( StoreProgressInSteam() && steamapicontext->SteamUserStats() )		{			// Set the Steam stat with the same name as the achievement.  Only cached locally until we upload it.			char pszProgressName[1024];			Q_snprintf( pszProgressName, 1024, "%s_STAT", GetStat() );			bool bRet = steamapicontext->SteamUserStats()->SetStat( pszProgressName, m_iCount );			if ( !bRet )			{				DevMsg( "ISteamUserStats::GetStat failed to set progress value in Steam for achievement %s/n", pszProgressName );			}			m_pAchievementMgr->SetDirty( true );		}#endif		// if we've hit goal, award the achievement		if ( m_iGoal > 0 )		{			if ( m_iCount >= m_iGoal )			{				AwardAchievement();			}			else			{					HandleProgressUpdate();			}		}	}}
开发者ID:Au-heppa,项目名称:source-sdk-2013,代码行数:70,


示例18: AutoMovement

//-----------------------------------------------------------------------------// Purpose: // Input  : flInterval - //			 - //			*pTraceResult - // Output : Returns true on success, false on failure.//-----------------------------------------------------------------------------bool CAI_BaseNPC::AutoMovement( float flInterval, CBaseEntity *pTarget, AIMoveTrace_t *pTraceResult ){	bool ignored;	Vector newPos;	QAngle newAngles;	if (flInterval <= 0.0)		return true;	m_ScheduleState.bTaskRanAutomovement = true;	if (GetIntervalMovement( flInterval, ignored, newPos, newAngles ))	{		// DevMsg( "%.2f : (%.1f) %.1f %.1f %.1f/n", gpGlobals->curtime, (newPos - GetLocalOrigin()).Length(), newPos.x, newPos.y, newAngles.y );			if ( m_hCine )		{			m_hCine->ModifyScriptedAutoMovement( &newPos );		}		if (GetMoveType() == MOVETYPE_STEP)		{			if (!(GetFlags() & FL_FLY))			{				if ( !pTarget )				{					pTarget = GetNavTargetEntity();				}				// allow NPCs to adjust the automatic movement				if ( ModifyAutoMovement( newPos ) )				{					// Set our motor's speed here					Vector vecOriginalPosition = GetAbsOrigin();					bool bResult = false;					if (!TaskIsComplete())					{						bResult = ( GetMotor()->MoveGroundStep( newPos, pTarget, newAngles.y, false, true, pTraceResult ) == AIM_SUCCESS );					}					Vector change = GetAbsOrigin() - vecOriginalPosition;					if (flInterval != 0)					{						change /= flInterval;					}					GetMotor()->SetMoveVel(change);					return bResult;				}				return ( GetMotor()->MoveGroundStep( newPos, pTarget, newAngles.y, false, true, pTraceResult ) == AIM_SUCCESS );			}			else			{				// FIXME: here's no direct interface to a fly motor, plus this needs to support a state where going through the world is okay.				// FIXME: add callbacks into the script system for validation				// FIXME: add function on scripts to force only legal movements				// FIXME: GetIntervalMovement deals in Local space, nor global.  Currently now way to communicate that through these interfaces.				SetLocalOrigin( newPos );				SetLocalAngles( newAngles );				return true;			}		}		else if (GetMoveType() == MOVETYPE_FLY)		{			Vector dist = newPos - GetLocalOrigin();			VectorScale( dist, 1.0 / flInterval, dist );			SetLocalVelocity( dist );			return true;		}	}	return false;}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:83,


示例19: MakeNotMember

void Channel::List(PlayerPointer player){    ObjectGuid p = player->GetObjectGuid();    MasterPlayer* masterPlayer = player->ToMasterPlayer();    Player* asPlayer = player->ToPlayer();    if (!IsOn(p))    {        WorldPacket data;        MakeNotMember(&data);        SendToOne(&data, p);    }    else    {        WorldPacket data(SMSG_CHANNEL_LIST, 1 + (GetName().size() + 1) + 1 + 4 + m_players.size() * (8 + 1));        data << uint8(1);                                   // channel type?        data << GetName();                                  // channel name        data << uint8(GetFlags());                          // channel flags?        size_t pos = data.wpos();        data << uint32(0);                                  // size of list, placeholder        AccountTypes gmLevelInWhoList = (AccountTypes)sWorld.getConfig(CONFIG_UINT32_GM_LEVEL_IN_WHO_LIST);        uint32 count  = 0;        for (PlayerList::const_iterator i = m_players.begin(); i != m_players.end(); ++i)        {            if (masterPlayer)            {                MasterPlayer* plr = sObjectAccessor.FindMasterPlayer(i->first);                // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters                // MODERATOR, GAME MASTER, ADMINISTRATOR can see all                if (plr && (masterPlayer->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) &&                        plr->IsVisibleGloballyFor(masterPlayer))                {                    data << ObjectGuid(i->first);                    data << uint8(i->second.flags);             // flags seems to be changed...                    ++count;                }            }            else            {                Player *plr = sObjectMgr.GetPlayer(i->first);                // PLAYER can't see MODERATOR, GAME MASTER, ADMINISTRATOR characters                // MODERATOR, GAME MASTER, ADMINISTRATOR can see all                if (plr && (asPlayer->GetSession()->GetSecurity() > SEC_PLAYER || plr->GetSession()->GetSecurity() <= gmLevelInWhoList) &&                        plr->IsVisibleGloballyFor(asPlayer))                {                    data << ObjectGuid(i->first);                    data << uint8(i->second.flags);             // flags seems to be changed...                    ++count;                }            }        }        data.put<uint32>(pos, count);        SendToOne(&data, p);    }}
开发者ID:Maduse,项目名称:server,代码行数:62,


示例20: Flight

//------------------------------------------------------------------------------//------------------------------------------------------------------------------void CBaseHelicopter::Flight( void ){	if( GetFlags() & FL_ONGROUND )	{		//This would be really bad.		SetGroundEntity( NULL );	}	// Generic speed up	if (m_flGoalSpeed < GetMaxSpeed())	{		m_flGoalSpeed += GetAcceleration();	}		//NDebugOverlay::Line(GetAbsOrigin(), m_vecDesiredPosition, 0,0,255, true, 0.1);	// tilt model 5 degrees (why?! sjb)	QAngle vecAdj = QAngle( 5.0, 0, 0 );	// estimate where I'll be facing in one seconds	Vector forward, right, up;	AngleVectors( GetLocalAngles() + GetLocalAngularVelocity() * 2 + vecAdj, &forward, &right, &up );	// Vector vecEst1 = GetLocalOrigin() + GetAbsVelocity() + up * m_flForce - Vector( 0, 0, 384 );	// float flSide = DotProduct( m_vecDesiredPosition - vecEst1, right );	QAngle angVel = GetLocalAngularVelocity();	float flSide = DotProduct( m_vecDesiredFaceDir, right );	if (flSide < 0)	{		if (angVel.y < 60)		{			angVel.y += 8;		}	}	else	{		if (angVel.y > -60)		{			angVel.y -= 8;		}	}	angVel.y *= ( 0.98 ); // why?! (sjb)	// estimate where I'll be in two seconds	AngleVectors( GetLocalAngles() + angVel * 1 + vecAdj, NULL, NULL, &up );	Vector vecEst = GetAbsOrigin() + GetAbsVelocity() * 2.0 + up * m_flForce * 20 - Vector( 0, 0, 384 * 2 );	// add immediate force	AngleVectors( GetLocalAngles() + vecAdj, &forward, &right, &up );		Vector vecImpulse( 0, 0, 0 );	vecImpulse.x += up.x * m_flForce;	vecImpulse.y += up.y * m_flForce;	vecImpulse.z += up.z * m_flForce;	// add gravity	vecImpulse.z -= 38.4; // 32ft/sec	ApplyAbsVelocityImpulse( vecImpulse );	float flSpeed = GetAbsVelocity().Length();	float flDir = DotProduct( Vector( forward.x, forward.y, 0 ), Vector( GetAbsVelocity().x, GetAbsVelocity().y, 0 ) );	if (flDir < 0)	{		flSpeed = -flSpeed;	}	float flDist = DotProduct( GetDesiredPosition() - vecEst, forward );	// float flSlip = DotProduct( GetAbsVelocity(), right );	float flSlip = -DotProduct( GetDesiredPosition() - vecEst, right );	// fly sideways	if (flSlip > 0)	{		if (GetLocalAngles().z > -30 && angVel.z > -15)			angVel.z -= 4;		else			angVel.z += 2;	}	else	{		if (GetLocalAngles().z < 30 && angVel.z < 15)			angVel.z += 4;		else			angVel.z -= 2;	}	// These functions contain code Ken wrote that used to be right here as part of the flight model,	// but we want different helicopter vehicles to have different drag characteristics, so I made	// them virtual functions (sjb)	ApplySidewaysDrag( right );	ApplyGeneralDrag();		// apply power to stay correct height	// FIXME: these need to be per class variables#define MAX_FORCE		80#define FORCE_POSDELTA	12	//.........这里部分代码省略.........
开发者ID:SizzlingStats,项目名称:hl2sdk-ob-valve,代码行数:101,


示例21: CalculateAccuracy

//-----------------------------------------------------------------------------// Purpose: Calculates the players "accuracy" level//-----------------------------------------------------------------------------void CBaseTFPlayer::CalculateAccuracy( void ){	static flLastTime = 0;	// Get the time since the last calculation	float flTimeSlice = (gpGlobals->curtime - flLastTime);	m_flTargetAccuracy = 0;	if ( !GetPlayerClass()  )		return;	// Get the base accuracy from the current weapon	if ( m_hActiveWeapon )	{		m_flTargetAccuracy = m_hActiveWeapon->GetAccuracy();		// Accuracy is increased if the player's crouching		if ( GetFlags() & FL_DUCKING )			m_flTargetAccuracy *= m_hActiveWeapon->GetDuckingMultiplier();		// Accuracy is decreased if the player's moving		if ( m_vecVelocity.Length2D() > ( GetPlayerClass()->GetMaxSpeed() * 0.5 ) )			m_flTargetAccuracy *= m_hActiveWeapon->GetRunningMultiplier();	}	// Accuracy is decreased if the player's arms are injured	// Accuracy is increased if there's an Officer nearby	// Accuracy is decreased if this player's being supressed (bullets/explosions impacting nearby)	float flFarTime = (m_flLastRicochetNearby + ACC_RICOCHET_TIME);	if ( gpGlobals->curtime <= flFarTime )		m_flTargetAccuracy *= 1 + (m_flNumberOfRicochets * ACC_RICOCHET_MULTIPLE) * (ACCMULT_RICOCHET * ((flFarTime - gpGlobals->curtime) / ACC_RICOCHET_TIME));	// Accuracy is decreased if the player's just been hit by a bullet/explosion	// Now float towards the target accuracy	if ( m_bSnapAccuracy )	{		m_bSnapAccuracy = false;		m_flAccuracy = m_flTargetAccuracy;	}	else	{		if ( m_flAccuracy < m_flTargetAccuracy )		{			m_flAccuracy += (flTimeSlice * ACCURACY_CHANGE_SPEED);			if ( m_flAccuracy > m_flTargetAccuracy )				m_flAccuracy = m_flTargetAccuracy ;		}		else if ( m_flAccuracy > m_flTargetAccuracy )		{			m_flAccuracy -= (flTimeSlice * ACCURACY_CHANGE_SPEED);			if ( m_flAccuracy < m_flTargetAccuracy )				m_flAccuracy = m_flTargetAccuracy ;		}	}	// Clip to prevent silly accuracies	if ( m_flAccuracy > 1024 )		m_flAccuracy = 1024;	flLastTime = gpGlobals->curtime;}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:67,


示例22: MakePlayerAlreadyMember

void Channel::Join(uint64 p, const char *pass){    WorldPacket data;    if (IsOn(p))    {        if (!IsConstant())                                   // non send error message for built-in channels        {            MakePlayerAlreadyMember(&data, p);            SendToOne(&data, p);        }        return;    }    if (IsBanned(p))    {        MakeBanned(&data);        SendToOne(&data, p);        return;    }    if (m_password.length() > 0 && strcmp(pass, m_password.c_str()))    {        MakeWrongPassword(&data);        SendToOne(&data, p);        return;    }    Player *plr = objmgr.GetPlayer(p);    if (plr)    {        if (HasFlag(CHANNEL_FLAG_LFG) &&            sWorld.getConfig(CONFIG_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER && plr->GetGroup())        {            MakeNotInLfg(&data);            SendToOne(&data, p);            return;        }        if (plr->GetGuildId() && (GetFlags() == 0x38))            return;        plr->JoinedChannel(this);    }    if (m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_SILENTLY_GM_JOIN_TO_CHANNEL)))    {        MakeJoined(&data, p);        SendToAll(&data);    }    data.clear();    PlayerInfo pinfo;    pinfo.player = p;    pinfo.flags = MEMBER_FLAG_NONE;    players[p] = pinfo;    MakeYouJoined(&data);    SendToOne(&data, p);    sIRC.Handle_WoW_Channel(m_name, objmgr.GetPlayer(p), CHANNEL_JOIN);    JoinNotify(p);    // if no owner first logged will become    if (!IsConstant() && !m_ownerGUID)    {        SetOwner(p, (players.size() > 1 ? true : false));        players[p].SetModerator(true);    }    /*    else if (!IsConstant() && m_ownerGUID && plr && m_ownerGUID == plr->GetGUID()))    {        SetOwner(p, (players.size() > 1 ? true : false));        players[p].SetModerator(true);    }*/}
开发者ID:Rhyuk,项目名称:Dev,代码行数:77,


示例23: Forget

int CE_Cycler_Fix::OnTakeDamage_Alive(const CTakeDamageInfo& info){#if 0	return BaseClass::OnTakeDamage_Alive(info);#endif	Forget( bits_MEMORY_INCOVER );	if ( !CCombatCharacter::FAKE_OnTakeDamage_Alive( info ) )		return 0;	if ( GetSleepState() == AISS_WAITING_FOR_THREAT )		Wake();	CEntity *attacker = CEntity::Instance(info.GetAttacker());	// NOTE: This must happen after the base class is called; we need to reduce	// health before the pain sound, since some NPCs use the final health	// level as a modifier to determine which pain sound to use.	// REVISIT: Combine soldiers shoot each other a lot and then talk about it	// this improves that case a bunch, but it seems kind of harsh.	if ( !GetSquad() || !GetSquad()->SquadIsMember( attacker ) )	{		PainSound( info );// "Ouch!"	}	// See if we're running a dynamic interaction that should break when I am damaged.	if ( IsActiveDynamicInteraction() )	{		ScriptedNPCInteraction_t *pInteraction = GetRunningDynamicInteraction();		if ( pInteraction->iLoopBreakTriggerMethod & SNPCINT_LOOPBREAK_ON_DAMAGE )		{			CEAI_ScriptedSequence *_m_hCine = Get_m_hCine();			// Can only break when we're in the action anim			if ( _m_hCine->IsPlayingAction() )			{				_m_hCine->StopActionLoop( true );			}		}	}	// If we're not allowed to die, refuse to die	// Allow my interaction partner to kill me though	if ( m_iHealth <= 0 && HasInteractionCantDie() && attacker != m_hInteractionPartner )	{		m_iHealth = 1;	}	// -----------------------------------	//  Fire outputs 	// -----------------------------------	if ( m_flLastDamageTime != gpGlobals->curtime )	{		// only fire once per frame		m_OnDamaged->FireOutput( attacker, this);		if( attacker && attacker->IsPlayer() )		{			m_OnDamagedByPlayer->FireOutput( attacker, this );						// This also counts as being harmed by player's squad.			m_OnDamagedByPlayerSquad->FireOutput( attacker, this );		} else {			// See if the person that injured me is an NPC.			CAI_NPC *pAttacker = dynamic_cast<CAI_NPC *>( attacker );			if( pAttacker && pAttacker->IsAlive() )			{				if( pAttacker->GetSquad() != NULL && pAttacker->IsInPlayerSquad() )				{					m_OnDamagedByPlayerSquad->FireOutput( attacker, this );				}			}		}	}	if( (info.GetDamageType() & DMG_CRUSH) && !(info.GetDamageType() & DMG_PHYSGUN) && info.GetDamage() >= MIN_PHYSICS_FLINCH_DAMAGE )	{		SetCondition( COND_PHYSICS_DAMAGE );	}	if ( m_iHealth <= ( m_iMaxHealth / 2 ) )	{		m_OnHalfHealth->FireOutput( attacker, this );	}	// react to the damage (get mad)	if ( ( (GetFlags() & FL_NPC) == 0 ) || !attacker )		return 1;	// If the attacker was an NPC or client update my position memory	if ( attacker->GetFlags() & (FL_NPC | FL_CLIENT) )	{		// ------------------------------------------------------------------		//				DO NOT CHANGE THIS CODE W/O CONSULTING		// Only update information about my attacker I don't see my attacker		// ------------------------------------------------------------------		if ( !FInViewCone_Entity( info.GetAttacker() ) || !FVisible_Entity( info.GetAttacker() ) )//.........这里部分代码省略.........
开发者ID:KissLick,项目名称:sourcemod-npc-in-css,代码行数:101,


示例24: ClearCondition

//-----------------------------------------------------------------------------// Purpose: Returns the best new schedule for this NPC based on current conditions.//-----------------------------------------------------------------------------int CNPC_Crow::SelectSchedule( void ){	if ( HasCondition( COND_CROW_BARNACLED ) )	{		// Caught by a barnacle!		return SCHED_CROW_BARNACLED;	}	//	// If we're flying, just find somewhere to fly to.	//	if ( IsFlying() )	{		return SCHED_CROW_IDLE_FLY;	}	//	// If we were told to fly away via our FlyAway input, do so ASAP.	//	if ( HasCondition( COND_CROW_FORCED_FLY ) )	{		ClearCondition( COND_CROW_FORCED_FLY );		return SCHED_CROW_FLY_AWAY;	}	//	// If we're not flying but we're not on the ground, start flying.	// Maybe we hopped off of something? Don't do this immediately upon	// because we may be falling to the ground on spawn.	//	if ( !( GetFlags() & FL_ONGROUND ) && ( gpGlobals->curtime > 2.0 ) && m_bOnJeep == false )	{		return SCHED_CROW_FLY_AWAY;	}	//	// If we heard a gunshot or have taken damage, fly away.	//	if ( HasCondition( COND_LIGHT_DAMAGE ) || HasCondition( COND_HEAVY_DAMAGE ) )	{		return SCHED_CROW_FLY_AWAY;	}	if ( m_flDangerSoundTime <= gpGlobals->curtime )	{		if ( HasCondition( COND_HEAR_DANGER ) || HasCondition( COND_HEAR_COMBAT ) )		{			m_flDangerSoundTime = gpGlobals->curtime + 10.0f;			return SCHED_CROW_FLY_AWAY;		}	}	//	// If someone we hate is getting WAY too close for comfort, fly away.	//	if ( HasCondition( COND_CROW_ENEMY_WAY_TOO_CLOSE ) )	{		ClearCondition( COND_CROW_ENEMY_WAY_TOO_CLOSE );		m_nMorale = 0;		return SCHED_CROW_FLY_AWAY;	}	//	// If someone we hate is getting a little too close for comfort, avoid them.	//	if ( HasCondition( COND_CROW_ENEMY_TOO_CLOSE ) && m_flDangerSoundTime <= gpGlobals->curtime )	{		ClearCondition( COND_CROW_ENEMY_TOO_CLOSE );		if ( m_bOnJeep == true )		{			m_nMorale = 0;			return SCHED_CROW_FLY_AWAY;		}		if ( m_flEnemyDist > 400 )		{			return SCHED_CROW_WALK_AWAY;		}		else if ( m_flEnemyDist > 300 )		{			m_nMorale -= 1;			return SCHED_CROW_RUN_AWAY;		}	}	switch ( m_NPCState )	{		case NPC_STATE_IDLE:		case NPC_STATE_ALERT:		case NPC_STATE_COMBAT:		{			if ( !IsFlying() )			{				if ( m_bOnJeep == true )				     return SCHED_IDLE_STAND;//.........这里部分代码省略.........
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:101,


示例25: BiteSound

void CASW_Parasite::LeapTouch( CBaseEntity *pOther ){	m_bMidJump = false;		if ( IRelationType( pOther ) == D_HT )	{		if (m_bDefanged)		{			if ( pOther->m_takedamage != DAMAGE_NO )			{				BiteSound();				TouchDamage( pOther );				//ClearSchedule( "About to gib self" );				// gib us				CTakeDamageInfo info(NULL, NULL, Vector(0,0,0), GetAbsOrigin(), GetHealth() * 2,						DMG_ACID);				TakeDamage(info);				SetSchedule( SCHED_DIE );				return;			}			else			{				//ImpactSound();			}		}		// Don't hit if back on ground		//if ( !( GetFlags() & FL_ONGROUND ) && m_bDefanged)	// if we're defanged, don't infest, just do some combat damage		//{	 				//}		//else		//{			//ImpactSound();		//}	}	else if( !(GetFlags() & FL_ONGROUND) )	{		// Still in the air...		if( gpGlobals->curtime < m_flIgnoreWorldCollisionTime )		{			// Headcrabs try to ignore the world, static props, and friends for a 			// fraction of a second after they jump. This is because they often brush			// doorframes or props as they leap, and touching those objects turns off			// this touch function, which can cause them to hit the player and not bite.			// A timer probably isn't the best way to fix this, but it's one of our 			// safer options at this point (sjb).			return;		}		if( !pOther->IsSolid() )		{			// Touching a trigger or something.			return;		}	}	// make sure we're solid	RemoveSolidFlags( FSOLID_NOT_SOLID );	// Shut off the touch function.	SetTouch( &CASW_Parasite::NormalTouch );	SetThink ( &CASW_Parasite::CallNPCThink );	SetCollisionGroup( ASW_COLLISION_GROUP_PARASITE );	// if we hit a marine, infest him and go away	NormalTouch( pOther );}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:67,


示例26: MakePlayerAlreadyMember

void Channel::Join(ObjectGuid p, const char* pass){    WorldPacket data;    if (IsOn(p))    {        if (!IsConstant())                                  // non send error message for built-in channels        {            MakePlayerAlreadyMember(&data, p);            SendToOne(&data, p);        }        return;    }    if (IsBanned(p))    {        MakeBanned(&data);        SendToOne(&data, p);        return;    }    if (m_password.length() > 0 && strcmp(pass, m_password.c_str()))    {        MakeWrongPassword(&data);        SendToOne(&data, p);        return;    }    Player* plr = sObjectMgr.GetPlayer(p);    if (plr)    {        if (HasFlag(CHANNEL_FLAG_LFG) && sWorld.getConfig(CONFIG_BOOL_RESTRICTED_LFG_CHANNEL) && plr->GetSession()->GetSecurity() == SEC_PLAYER)        {            MakeNotInLfg(&data);            SendToOne(&data, p);            return;        }        if (plr->GetGuildId() && (GetFlags() == 0x38))            return;        plr->JoinedChannel(this);    }    if (m_announce && (!plr || plr->GetSession()->GetSecurity() < SEC_GAMEMASTER || !sWorld.getConfig(CONFIG_BOOL_SILENTLY_GM_JOIN_TO_CHANNEL)))    {        MakeJoined(&data, p);        SendToAll(&data);    }    data.clear();    PlayerInfo& pinfo = m_players[p];    pinfo.player = p;    pinfo.flags = 0;    MakeYouJoined(&data);    SendToOne(&data, p);    JoinNotify(p);    // if no owner first logged will become    if (!IsConstant() && !m_ownerGuid)    {        SetOwner(p, (m_players.size() > 1 ? true : false));        m_players[p].SetModerator(true);    }}
开发者ID:lsqtzj,项目名称:server,代码行数:68,


示例27: GetFlags

// --------------------------------------------------------------------------//// Function//		Name:    BackupStoreCheck::CheckDirectories()//		Purpose: Check the directories//		Created: 22/4/04//// --------------------------------------------------------------------------void BackupStoreCheck::CheckDirectories(){	// Phase 1 did this:	//    Checked that all the directories are readable	//    Built a list of all directories and files which exist on the store	//	// This phase will check all the files in the directories, make	// a note of all directories which are missing, and do initial fixing.	// The root directory is not contained inside another directory, so	// it has no directory entry to scan, but we have to count it	// somewhere, so we'll count it here.	mNumDirectories++;	// Scan all objects.	for(Info_t::const_iterator i(mInfo.begin()); i != mInfo.end(); ++i)	{		IDBlock *pblock = i->second;		int32_t bentries = (pblock == mpInfoLastBlock)?mInfoLastBlockEntries:BACKUPSTORECHECK_BLOCK_SIZE;		for(int e = 0; e < bentries; ++e)		{			uint8_t flags = GetFlags(pblock, e);			if(flags & Flags_IsDir)			{				// Found a directory. Read it in.				std::string filename;				StoreStructure::MakeObjectFilename(pblock->mID[e], mStoreRoot, mDiscSetNumber, filename, false /* no dir creation */);				BackupStoreDirectory dir;				{					std::auto_ptr<RaidFileRead> file(RaidFileRead::Open(mDiscSetNumber, filename));					dir.ReadFromStream(*file, IOStream::TimeOutInfinite);				}								// Flag for modifications				bool isModified = CheckDirectory(dir);				// Check the directory again, now that entries have been removed				if(dir.CheckAndFix())				{					// Wasn't quite right, and has been modified					BOX_ERROR("Directory ID " <<						BOX_FORMAT_OBJECTID(pblock->mID[e]) <<						" was still bad after all checks");					++mNumberErrorsFound;					isModified = true;				}				else if(isModified)				{					BOX_INFO("Directory ID " <<						BOX_FORMAT_OBJECTID(pblock->mID[e]) <<						" was OK after fixing");				}				if(isModified && mFixErrors)				{					BOX_WARNING("Writing modified directory to disk: " <<						BOX_FORMAT_OBJECTID(pblock->mID[e]));					RaidFileWrite fixed(mDiscSetNumber, filename);					fixed.Open(true /* allow overwriting */);					dir.WriteToStream(fixed);					fixed.Commit(true /* convert to raid representation now */);				}				CountDirectoryEntries(dir);			}		}	}}
开发者ID:jamesog,项目名称:boxbackup,代码行数:77,



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


C++ GetFloat函数代码示例
C++ GetFlagState函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。