void CParticleSystemQuery::GetLocalPlayerEyeVectors( Vector *pForward, Vector *pRight, Vector *pUp ) { #ifdef CLIENT_DLL // HACK_GETLOCALPLAYER_GUARD( "CParticleSystemQuery::GetLocalPlayerPos" ); int slot = GET_ACTIVE_SPLITSCREEN_SLOT(); ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot ); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) { *pForward = vec3_origin; *pRight = vec3_origin; *pUp = vec3_origin; return; } pPlayer->EyeVectors( pForward, pRight, pUp ); #else CBasePlayer *pPlayer = AI_GetSinglePlayer(); if ( !pPlayer ) { *pForward = vec3_origin; *pRight = vec3_origin; *pUp = vec3_origin; return; } pPlayer->EyeVectors( pForward, pRight, pUp ); #endif }
void C_World::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); // Always force reset to normal mode upon receipt of world in new map if ( updateType == DATA_UPDATE_CREATED ) { modemanager->SwitchMode( false, true ); if ( m_bStartDark ) { ScreenFade_t sf; memset( &sf, 0, sizeof( sf ) ); sf.a = 255; sf.r = 0; sf.g = 0; sf.b = 0; sf.duration = (float)(1<<SCREENFADE_FRACBITS) * 5.0f; sf.holdTime = (float)(1<<SCREENFADE_FRACBITS) * 1.0f; sf.fadeFlags = FFADE_IN | FFADE_PURGE; FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); GetViewEffects()->Fade( sf ); } } OcclusionParams_t params; params.m_flMaxOccludeeArea = m_flMaxOccludeeArea; params.m_flMinOccluderArea = m_flMinOccluderArea; engine->SetOcclusionParameters( params ); modelinfo->SetLevelScreenFadeRange( m_flMinPropScreenSpaceWidth, m_flMaxPropScreenSpaceWidth ); }
//----------------------------------------------------------------------------- // Purpose: Gives back the cursor and stops centering of mouse //----------------------------------------------------------------------------- void CInput::DeactivateMouse (void) { // This gets called whenever the mouse should be inactive. We only respond to it if we had // previously activated the mouse. We'll show the cursor in here. if ( !m_fMouseActive ) return; if ( m_fMouseInitialized ) { if ( m_fRestoreSPI ) { #ifdef WIN32 SystemParametersInfo( SPI_SETMOUSE, 0, m_rgOrigMouseParms, 0 ); #endif } m_fMouseActive = false; g_pInputStackSystem->SetCursorIcon( m_hInputContext, g_pInputSystem->GetStandardCursor( INPUT_CURSOR_ARROW ) ); // Clear accumulated error, too for ( int hh = 0; hh < MAX_SPLITSCREEN_PLAYERS; ++hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); GetPerUser().m_flAccumulatedMouseXMovement = 0; GetPerUser().m_flAccumulatedMouseYMovement = 0; } } }
// register message handler once void HookPyNetworkCls() { for ( int hh = 0; hh < MAX_SPLITSCREEN_PLAYERS; ++hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); usermessages->HookMessage( "PyNetworkCls", __MsgFunc_PyNetworkCls ); } }
void CSDKModeManager::LevelInit( const char *newmap ) { for( int i = 0; i < MAX_SPLITSCREEN_PLAYERS; ++i ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( i ); GetClientMode()->LevelInit( newmap ); } }
void CSDKModeManager::LevelShutdown( void ) { for( int i = 0; i < MAX_SPLITSCREEN_PLAYERS; ++i ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( i ); GetClientMode()->LevelShutdown(); } }
void Init() { for( int i = 0; i < MAX_SPLITSCREEN_PLAYERS; ++i ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( i ); g_pClientMode[ i ] = GetClientModeNormal(); } }
//----------------------------------------------------------------------------- // Is the game rendering in 3rd person mode? //----------------------------------------------------------------------------- bool CClientTools::IsRenderingThirdPerson() const { ACTIVE_SPLITSCREEN_PLAYER_GUARD( 0 ); C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pLocalPlayer ) return false; return pLocalPlayer->ShouldDrawLocalPlayer(); }
void LevelInit( const char* newmap ) { for( int i = 0; i < MAX_SPLITSCREEN_PLAYERS; ++i ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( i ); GetClientMode()->LevelInit(newmap); } GetFullscreenClientMode()->LevelInit(newmap); }
void LevelShutdown() { for( int i = 0; i < MAX_SPLITSCREEN_PLAYERS; ++i ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( i ); GetClientMode()->LevelShutdown(); } GetFullscreenClientMode()->LevelShutdown(); }
void CSDKModeManager::Init() { for( int i = 0; i < MAX_SPLITSCREEN_PLAYERS; ++i ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( i ); g_pClientMode[ i ] = GetClientModeNormal(); } PanelMetaClassMgr()->LoadMetaClassDefinitionFile( SCREEN_FILE ); }
void CProjectedLight::UpdateTexture( const char * pTextureName ) { //ASSERT_LOCAL_PLAYER_RESOLVABLE(); //m_Lights.Element( GET_ACTIVE_SPLITSCREEN_SLOT() )->UpdateTexture( pTextureName ); for ( int hh = 0; hh < MAX_SPLITSCREEN_PLAYERS; ++hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); m_Lights.Element( hh )->UpdateTexture( pTextureName ); } }
void CProjectedLight::Update( const Vector & vecPos, const Vector & vecForward, const Vector & vecRight, const Vector & vecUp ) { //ASSERT_LOCAL_PLAYER_RESOLVABLE(); //m_Lights.Element( GET_ACTIVE_SPLITSCREEN_SLOT() )->Update( vecPos, vecForward, vecRight, vecUp ); for ( int hh = 0; hh < MAX_SPLITSCREEN_PLAYERS; ++hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); m_Lights.Element( hh )->Update( vecPos, vecForward, vecRight, vecUp ); } }
void CProjectedLight::Think() { //ASSERT_LOCAL_PLAYER_RESOLVABLE(); //m_Lights.Element( GET_ACTIVE_SPLITSCREEN_SLOT() )->Think(); for ( int hh = 0; hh < MAX_SPLITSCREEN_PLAYERS; ++hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); m_Lights.Element( hh )->Think(); } }
Vector CParticleSystemQuery::GetCurrentViewOrigin() { #ifdef CLIENT_DLL int slot = GET_ACTIVE_SPLITSCREEN_SLOT(); ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot ); return CurrentViewOrigin(); #else return vec3_origin; #endif }
//----------------------------------------------------------------------------- // Purpose: ClearStates -- Resets mouse accumulators so you don't get a pop when returning to trapped mouse //----------------------------------------------------------------------------- void CInput::ClearStates (void) { if ( !m_fMouseActive ) return; for ( int hh = 0; hh < MAX_SPLITSCREEN_PLAYERS; ++hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); GetPerUser().m_flAccumulatedMouseXMovement = 0; GetPerUser().m_flAccumulatedMouseYMovement = 0; } }
bool CClientTools::GetLocalPlayerEyePosition( Vector& org, QAngle& ang, float &fov ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( 0 ); C_BasePlayer *pl = C_BasePlayer::GetLocalPlayer(); if ( pl == NULL ) return false; org = pl->EyePosition(); ang = pl->EyeAngles(); fov = pl->GetFOV(); return true; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- Vector GetTracerOrigin( const CEffectData &data ) { Vector vecStart = data.m_vStart; QAngle vecAngles; int iAttachment = data.m_nAttachmentIndex;; // Attachment? if ( data.m_fFlags & TRACER_FLAG_USEATTACHMENT ) { C_BaseViewModel *pViewModel = NULL; // If the entity specified is a weapon being carried by this player, use the viewmodel instead IClientRenderable *pRenderable = data.GetRenderable(); if ( !pRenderable ) return vecStart; C_BaseEntity *pEnt = data.GetEntity(); FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); C_BaseCombatWeapon *pWpn = ToBaseCombatWeapon( pEnt ); if ( pWpn && pWpn->IsCarriedByLocalPlayer() ) { C_BasePlayer *player = ToBasePlayer( pWpn->GetOwner() ); if( !player && pWpn->GetOwner() && pWpn->GetOwner()->IsUnit() ) { player = pWpn->GetOwner()->MyUnitPointer()->GetCommander(); } pViewModel = player ? player->GetViewModel( 0 ) : NULL; if ( pViewModel ) { // Get the viewmodel and use it instead pRenderable = pViewModel; break; } } } // Get the attachment origin if ( !pRenderable->GetAttachment( iAttachment, vecStart, vecAngles ) ) { DevMsg( "GetTracerOrigin: Couldn't find attachment %d on model %s\n", iAttachment, modelinfo->GetModelName( pRenderable->GetModel() ) ); } }
float CParticleSystemQuery::GetPixelVisibility( int *pQueryHandle, const Vector &vecOrigin, float flScale ) { #ifdef CLIENT_DLL int slot = GET_ACTIVE_SPLITSCREEN_SLOT(); ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot ); pixelvis_queryparams_t params; params.Init( vecOrigin, flScale, 1.0 ); float flVisibility = PixelVisibility_FractionVisible( params, pQueryHandle ); flVisibility = MAX( 0.0f, flVisibility ); return flVisibility; #else return 0.0f; #endif }
void CBindPanel::ApplySettings( KeyValues *inResourceData ) { const char *pszBind = inResourceData->GetString( "bind", "" ); if ( pszBind && pszBind[0] ) { int nSlot = vgui::ipanel()->GetMessageContextId( GetVPanel() ); ACTIVE_SPLITSCREEN_PLAYER_GUARD( nSlot ); SetBind( pszBind, nSlot ); } BaseClass::ApplySettings( inResourceData ); }
//----------------------------------------------------------------------------- // Purpose: One-time initialization //----------------------------------------------------------------------------- void CInput::Init_Mouse (void) { if ( CommandLine()->FindParm("-nomouse" ) ) return; for ( int hh = 0; hh < MAX_SPLITSCREEN_PLAYERS; ++hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); GetPerUser().m_flPreviousMouseXPosition = 0.0f; GetPerUser().m_flPreviousMouseYPosition = 0.0f; } m_fMouseInitialized = true; m_fMouseParmsValid = false; if ( CommandLine()->FindParm ("-useforcedmparms" ) ) { #ifdef WIN32 m_fMouseParmsValid = SystemParametersInfo( SPI_GETMOUSE, 0, m_rgOrigMouseParms, 0 ) ? true : false; #else m_fMouseParmsValid = false; #endif if ( m_fMouseParmsValid ) { if ( CommandLine()->FindParm ("-noforcemspd" ) ) { m_rgNewMouseParms[ MOUSE_SPEED_FACTOR ] = m_rgOrigMouseParms[ MOUSE_SPEED_FACTOR ]; } else { m_rgCheckMouseParam[ MOUSE_SPEED_FACTOR ] = true; } if ( CommandLine()->FindParm ("-noforcemaccel" ) ) { m_rgNewMouseParms[ MOUSE_ACCEL_THRESHHOLD1 ] = m_rgOrigMouseParms[ MOUSE_ACCEL_THRESHHOLD1 ]; m_rgNewMouseParms[ MOUSE_ACCEL_THRESHHOLD2 ] = m_rgOrigMouseParms[ MOUSE_ACCEL_THRESHHOLD2 ]; } else { m_rgCheckMouseParam[ MOUSE_ACCEL_THRESHHOLD1 ] = true; m_rgCheckMouseParam[ MOUSE_ACCEL_THRESHHOLD2 ] = true; } } } }
Vector CParticleSystemQuery::GetLocalPlayerPos( void ) { #ifdef CLIENT_DLL // HACK_GETLOCALPLAYER_GUARD( "CParticleSystemQuery::GetLocalPlayerPos" ); int slot = GET_ACTIVE_SPLITSCREEN_SLOT(); ACTIVE_SPLITSCREEN_PLAYER_GUARD( slot ); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return vec3_origin; return pPlayer->WorldSpaceCenter(); #else CBasePlayer *pPlayer = AI_GetSinglePlayer(); if ( !pPlayer ) return vec3_origin; return pPlayer->WorldSpaceCenter(); #endif }
void C_ASW_Queen::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); if ( updateType == DATA_UPDATE_CREATED ) { // We want to think every frame. SetNextClientThink( CLIENT_THINK_ALWAYS ); FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); // launch panel to show our health CASW_VGUI_Queen_Health_Panel *m_pQueenHealthPanel = new CASW_VGUI_Queen_Health_Panel( GetClientMode()->GetViewport(), "QueenHealthPanel", this ); vgui::HScheme scheme = vgui::scheme()->LoadSchemeFromFile("resource/SwarmSchemeNew.res", "SwarmSchemeNew"); m_pQueenHealthPanel->SetScheme(scheme); m_pQueenHealthPanel->SetVisible(true); } }
//----------------------------------------------------------------------------- // Purpose: // Input : bnewentity - //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); // If it's being carried by the *local* player, on the first update, // find the registered weapon for this ID C_BaseCombatCharacter *pOwner = GetOwner(); C_BasePlayer *pPlayer = ToBasePlayer( pOwner ); // check if weapon is carried by local player bool bIsLocalPlayer = C_BasePlayer::IsLocalPlayer( pPlayer ); if ( bIsLocalPlayer ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( C_BasePlayer::GetSplitScreenSlotForPlayer( pPlayer ) ); // If I was just picked up, or created & immediately carried, add myself to this client's list of weapons if ( ( m_iState != WEAPON_NOT_CARRIED ) && ( m_iOldState == WEAPON_NOT_CARRIED ) ) { // Tell the HUD this weapon's been picked up if ( ShouldDrawPickup() ) { CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection(); if ( pHudSelection ) { pHudSelection->OnWeaponPickup( this ); } pPlayer->EmitSound( "Player.PickupWeapon" ); } } } UpdateVisibility(); m_iOldState = m_iState; m_bJustRestored = false; }
void CSDKModeManager::LevelInit( const char *newmap ) { //g_pClientMode->LevelInit( newmap ); for( int i = 0; i < MAX_SPLITSCREEN_PLAYERS; ++i ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( i ); g_pClientMode[ i ]->LevelInit( newmap ); } // HACK: the detail sway convars are archive, and default to 0. Existing CS:S players thus have no detail // prop sway. We'll force them to DoD's default values for now. //if ( !cl_detail_max_sway.GetFloat() && // !cl_detail_avoid_radius.GetFloat() && // !cl_detail_avoid_force.GetFloat() && // !cl_detail_avoid_recover_speed.GetFloat() ) //{ // cl_detail_max_sway.SetValue( "5" ); // cl_detail_avoid_radius.SetValue( "64" ); // cl_detail_avoid_force.SetValue( "0.4" ); // cl_detail_avoid_recover_speed.SetValue( "0.25" ); //} }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CParticleProperty::UpdateControlPoint( ParticleEffectList_t *pEffect, int iPoint, bool bInitializing ) { ParticleControlPoint_t *pPoint = &pEffect->pControlPoints[iPoint]; if ( pEffect->pParticleEffect->m_pDef->IsScreenSpaceEffect() && iPoint == 0 ) { pEffect->pParticleEffect->SetControlPointOrientation( pPoint->iControlPoint, Vector(1,0,0), Vector(0,1,0), Vector(0,0,1) ); pEffect->pParticleEffect->SetControlPoint( pPoint->iControlPoint, vec3_origin ); return; } if ( !pPoint->hEntity.Get() ) { if ( pPoint->iAttachType == PATTACH_WORLDORIGIN && bInitializing ) { pEffect->pParticleEffect->SetControlPointOrientation( pPoint->iControlPoint, Vector(1,0,0), Vector(0,1,0), Vector(0,0,1) ); pEffect->pParticleEffect->SetControlPoint( pPoint->iControlPoint, pPoint->vecOriginOffset ); pEffect->pParticleEffect->SetSortOrigin( pPoint->vecOriginOffset ); } pEffect->pParticleEffect->SetControlPointEntity( pPoint->iControlPoint, NULL ); return; } // Only update non-follow particles when we're initializing, if ( !bInitializing && (pPoint->iAttachType == PATTACH_ABSORIGIN || pPoint->iAttachType == PATTACH_POINT ) ) return; if ( pPoint->iAttachType == PATTACH_CUSTOMORIGIN ) return; Vector vecOrigin, vecForward, vecRight, vecUp; switch ( pPoint->iAttachType ) { case PATTACH_POINT: case PATTACH_POINT_FOLLOW: { C_BaseAnimating *pAnimating = pPoint->hEntity->GetBaseAnimating(); bool bValid = false; Assert( pAnimating ); if ( pAnimating ) { matrix3x4_t attachmentToWorld; if ( pAnimating->IsViewModel() ) { C_BasePlayer *pPlayer = ToBasePlayer( ((C_BaseViewModel *)pAnimating)->GetOwner() ); ACTIVE_SPLITSCREEN_PLAYER_GUARD( C_BasePlayer::GetSplitScreenSlotForPlayer( pPlayer ) ); if ( pAnimating->GetAttachment( pPoint->iAttachmentPoint, attachmentToWorld ) ) { bValid = true; MatrixVectors( attachmentToWorld, &vecForward, &vecRight, &vecUp ); MatrixPosition( attachmentToWorld, vecOrigin ); if ( pEffect->pParticleEffect->m_pDef->IsViewModelEffect() ) { FormatViewModelAttachment( pPlayer, vecOrigin, true ); } } } else { // HACK_GETLOCALPLAYER_GUARD( "CParticleProperty::UpdateControlPoint" ); if ( pAnimating->GetAttachment( pPoint->iAttachmentPoint, attachmentToWorld ) ) { bValid = true; MatrixVectors( attachmentToWorld, &vecForward, &vecRight, &vecUp ); #ifdef _DEBUG float flTests[3] = {vecForward.Dot( vecRight ), vecRight.Dot( vecUp ), vecUp.Dot( vecForward )}; static float s_flMaxTest = 0.001f; Assert( fabs( flTests[0] ) + fabs( flTests[1] ) + fabs( flTests[2] ) < s_flMaxTest ); #endif MatrixPosition( attachmentToWorld, vecOrigin ); if ( pEffect->pParticleEffect->m_pDef->IsViewModelEffect() ) { HACK_GETLOCALPLAYER_GUARD( "CParticleProperty::UpdateControlPoint" ); FormatViewModelAttachment( NULL, vecOrigin, true ); } } } } if ( !bValid ) { static bool bWarned = false; if ( !bWarned ) { bWarned = true; DevWarning( "Attempted to attach particle effect %s to an unknown attachment on entity %s\n", pEffect->pParticleEffect->m_pDef->GetName(), pAnimating->GetClassname() ); } } if ( !bValid ) { AssertOnce( 0 ); return; } } break; case PATTACH_ABSORIGIN: case PATTACH_ABSORIGIN_FOLLOW: default: { vecOrigin = pPoint->hEntity->GetAbsOrigin() + pPoint->vecOriginOffset; pPoint->hEntity->GetVectors( &vecForward, &vecRight, &vecUp ); } break; case PATTACH_EYES_FOLLOW: { C_BaseEntity *pEnt = pPoint->hEntity; if ( !pEnt->IsPlayer() ) return; C_BasePlayer *pPlayer = assert_cast< C_BasePlayer* >( pEnt ); bool bValid = false; Assert( pPlayer ); if ( pPlayer ) { bValid = true; vecOrigin = pPlayer->EyePosition() + pPoint->vecOriginOffset; pPlayer->EyeVectors( &vecForward, &vecRight, &vecUp ); } if ( !bValid ) { AssertOnce( 0 ); return; } } break; case PATTACH_CUSTOMORIGIN_FOLLOW: { matrix3x4_t mat; MatrixMultiply( pPoint->hEntity->RenderableToWorldTransform(), pPoint->matOffset, mat ); MatrixVectors( mat, &vecForward, &vecRight, &vecUp ); vecOrigin = pPoint->hEntity->GetAbsOrigin() + pPoint->vecOriginOffset; } break; } pEffect->pParticleEffect->SetControlPointOrientation( pPoint->iControlPoint, vecForward, vecRight, vecUp ); pEffect->pParticleEffect->SetControlPointEntity( pPoint->iControlPoint, pPoint->hEntity ); pEffect->pParticleEffect->SetControlPoint( pPoint->iControlPoint, vecOrigin ); pEffect->pParticleEffect->SetSortOrigin( vecOrigin ); }
void CRagdollLRURetirement::Update( float frametime ) // EPISODIC VERSION { VPROF( "CRagdollLRURetirement::Update" ); // Compress out dead items int i, next; int iMaxRagdollCount = m_iMaxRagdolls; if ( iMaxRagdollCount == -1 ) { iMaxRagdollCount = g_ragdoll_maxcount.GetInt(); } // fade them all for the low violence version if ( g_RagdollLVManager.IsLowViolence() ) { iMaxRagdollCount = 0; } m_iRagdollCount = 0; m_iSimulatedRagdollCount = 0; // First, find ragdolls that are good candidates for deletion because they are not // visible at all, or are in a culled visibility box for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next ) { next = m_LRU.Next(i); CBaseAnimating *pRagdoll = m_LRU[i].Get(); if ( pRagdoll ) { m_iRagdollCount++; IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); if (pObject && !pObject->IsAsleep()) { m_iSimulatedRagdollCount++; } if ( m_LRU.Count() > iMaxRagdollCount ) { //Found one, we're done. if ( ShouldRemoveThisRagdoll( pRagdoll ) == true ) { #ifdef CLIENT_DLL pRagdoll->SUB_Remove(); #else pRagdoll->SUB_StartFadeOut( 0 ); #endif m_LRU.Remove(i); return; } } } else { m_LRU.Remove(i); } } ////////////////////////////// /// EPISODIC ALGORITHM /// ////////////////////////////// // If we get here, it means we couldn't find a suitable ragdoll to remove, // so just remove the furthest one. int furthestOne = m_LRU.Head(); float furthestDistSq = 0; #ifdef CLIENT_DLL ACTIVE_SPLITSCREEN_PLAYER_GUARD( 0 ); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); #else CBasePlayer *pPlayer = g_pGameRules->IsMultiplayer() ? NULL : UTIL_GetLocalPlayer(); #endif if (pPlayer && m_LRU.Count() > iMaxRagdollCount) // find the furthest one algorithm { Vector PlayerOrigin = pPlayer->GetAbsOrigin(); // const CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next ) { CBaseAnimating *pRagdoll = m_LRU[i].Get(); next = m_LRU.Next(i); IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); if ( pRagdoll && (pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) ) continue; if ( pRagdoll ) { // float distToPlayer = (pPlayer->GetAbsOrigin() - pRagdoll->GetAbsOrigin()).LengthSqr(); float distToPlayer = (PlayerOrigin - pRagdoll->GetAbsOrigin()).LengthSqr(); if (distToPlayer > furthestDistSq) { furthestOne = i; furthestDistSq = distToPlayer; } } else // delete bad rags first. { furthestOne = i; break; } } CBaseAnimating *pRemoveRagdoll = m_LRU[ furthestOne ].Get(); #ifdef CLIENT_DLL pRemoveRagdoll->SUB_Remove(); #else pRemoveRagdoll->SUB_StartFadeOut( 0 ); #endif } else // fall back on old-style pick the oldest one algorithm { for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next ) { if ( m_LRU.Count() <= iMaxRagdollCount ) break; next = m_LRU.Next(i); CBaseAnimating *pRagdoll = m_LRU[i].Get(); //Just ignore it until we're done burning/dissolving. IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); if ( pRagdoll && (pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) ) continue; #ifdef CLIENT_DLL pRagdoll->SUB_Remove(); #else pRagdoll->SUB_StartFadeOut( 0 ); #endif m_LRU.Remove(i); } } }
void CViewRender::Render( vrect_t *rect ) { VPROF_BUDGET( "CViewRender::Render", "CViewRender::Render" ); m_bAllowViewAccess = true; CUtlVector< vgui::Panel * > roots; VGui_GetPanelList( roots ); // Stub out the material system if necessary. CMatStubHandler matStub; engine->EngineStats_BeginFrame(); // Assume normal vis m_bForceNoVis = false; float flViewportScale = mat_viewportscale.GetFloat(); vrect_t engineRect = *rect; // The tool framework wants to adjust the entire 3d viewport, not the per-split screen one from below ToolFramework_AdjustEngineViewport( engineRect.x, engineRect.y, engineRect.width, engineRect.height ); IterateRemoteSplitScreenViewSlots_Push( true ); FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD_VGUI( hh ); CViewSetup &view = GetView( hh ); float engineAspectRatio = engine->GetScreenAspectRatio( view.width, view.height ); Assert( s_DbgSetupOrigin[ hh ] == view.origin ); Assert( s_DbgSetupAngles[ hh ] == view.angles ); // Using this API gives us a chance to "inset" the 3d views as needed for splitscreen int insetX, insetY; VGui_GetEngineRenderBounds( hh, view.x, view.y, view.width, view.height, insetX, insetY ); float aspectRatio = engineAspectRatio * 0.75f; // / (4/3) view.fov = ScaleFOVByWidthRatio( view.fov, aspectRatio ); view.fovViewmodel = ScaleFOVByWidthRatio( view.fovViewmodel, aspectRatio ); // Let the client mode hook stuff. GetClientMode()->PreRender( &view ); GetClientMode()->AdjustEngineViewport( view.x, view.y, view.width, view.height ); view.width *= flViewportScale; view.height *= flViewportScale; if ( IsX360() ) { // view must be compliant to resolve restrictions view.width = AlignValue( view.width, GPU_RESOLVE_ALIGNMENT ); view.height = AlignValue( view.height, GPU_RESOLVE_ALIGNMENT ); } view.m_flAspectRatio = ( engineAspectRatio > 0.0f ) ? engineAspectRatio : ( (float)view.width / (float)view.height ); int nClearFlags = VIEW_CLEAR_DEPTH | VIEW_CLEAR_STENCIL; if ( gl_clear_randomcolor.GetBool() ) { CMatRenderContextPtr pRenderContext( materials ); pRenderContext->ClearColor3ub( rand()%256, rand()%256, rand()%256 ); pRenderContext->ClearBuffers( true, false, false ); pRenderContext->Release(); } else if ( gl_clear.GetBool() ) { nClearFlags |= VIEW_CLEAR_COLOR; } // Determine if we should draw view model ( client mode override ) bool drawViewModel = GetClientMode()->ShouldDrawViewModel(); // Apply any player specific overrides C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( pPlayer ) { // Override view model if necessary if ( !pPlayer->m_Local.m_bDrawViewmodel ) { drawViewModel = false; } } if ( cl_leveloverview.GetFloat() > 0 ) { SetUpOverView(); nClearFlags |= VIEW_CLEAR_COLOR; drawViewModel = false; } render->SetMainView( view.origin, view.angles ); int flags = (pPlayer == NULL) ? 0 : RENDERVIEW_DRAWHUD; if ( drawViewModel ) { flags |= RENDERVIEW_DRAWVIEWMODEL; } // This is the hook for per-split screen player views C_BaseEntity::PreRenderEntities( hh ); if ( ( ss_debug_draw_player.GetInt() < 0 ) || ( hh == ss_debug_draw_player.GetInt() ) ) { CViewSetup hudViewSetup; VGui_GetHudBounds( hh, hudViewSetup.x, hudViewSetup.y, hudViewSetup.width, hudViewSetup.height ); RenderView( view, hudViewSetup, nClearFlags, flags ); } GetClientMode()->PostRender(); } IterateRemoteSplitScreenViewSlots_Pop(); engine->EngineStats_EndFrame(); #if !defined( _X360 ) // Stop stubbing the material system so we can see the budget panel matStub.End(); #endif // Render the new-style embedded UI // TODO: when embedded UI will be used for HUD, we will need it to maintain // a separate screen for HUD and a separate screen stack for pause menu & main menu. // for now only render embedded UI in pause menu & main menu #if defined( GAMEUI_UISYSTEM2_ENABLED ) && 0 BaseModUI::CBaseModPanel *pBaseModPanel = BaseModUI::CBaseModPanel::GetSingletonPtr(); // render the new-style embedded UI only if base mod panel is not visible (game-hud) // otherwise base mod panel will render the embedded UI on top of video/productscreen if ( !pBaseModPanel || !pBaseModPanel->IsVisible() ) { Rect_t uiViewport; uiViewport.x = rect->x; uiViewport.y = rect->y; uiViewport.width = rect->width; uiViewport.height = rect->height; g_pGameUIGameSystem->Render( uiViewport, gpGlobals->curtime ); } #endif // Draw all of the UI stuff "fullscreen" if ( true ) // For PIXEVENT { #if PIX_ENABLE { CMatRenderContextPtr pRenderContext( materials ); PIXEVENT( pRenderContext, "VGui UI" ); } #endif CViewSetup view2d; view2d.x = rect->x; view2d.y = rect->y; view2d.width = rect->width; view2d.height = rect->height; render->Push2DView( view2d, 0, NULL, GetFrustum() ); render->VGui_Paint( PAINT_UIPANELS ); { // The engine here is trying to access CurrentView() etc. which is bogus ACTIVE_SPLITSCREEN_PLAYER_GUARD( 0 ); render->PopView( GetFrustum() ); } } m_bAllowViewAccess = false; }
EntitySearchResult CClientTools::GetLocalPlayer() { ACTIVE_SPLITSCREEN_PLAYER_GUARD( 0 ); C_BasePlayer *p = C_BasePlayer::GetLocalPlayer(); return reinterpret_cast< EntitySearchResult >( p ); }
//----------------------------------------------------------------------------- // Purpose: Advanced joystick setup //----------------------------------------------------------------------------- void CInput::Joystick_Advanced( bool bSilent ) { m_fJoystickAdvancedInit = true; // called whenever an update is needed int i; DWORD dwTemp; if ( IsX360() ) { // Xbox always uses a joystick in_joystick.SetValue( 1 ); } for ( int hh = 0; hh < MAX_SPLITSCREEN_PLAYERS; ++hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); PerUserInput_t &user = GetPerUser(); // Initialize all the maps for ( i = 0; i < MAX_JOYSTICK_AXES; i++ ) { user.m_rgAxes[i].AxisMap = GAME_AXIS_NONE; user.m_rgAxes[i].ControlMap = JOY_ABSOLUTE_AXIS; } if ( !joy_advanced.GetBool() ) { // default joystick initialization // 2 axes only with joystick control user.m_rgAxes[JOY_AXIS_X].AxisMap = GAME_AXIS_YAW; user.m_rgAxes[JOY_AXIS_Y].AxisMap = GAME_AXIS_FORWARD; } else { if ( !bSilent && hh == 0 && Q_stricmp( joy_name.GetString(), "joystick") ) { // notify user of advanced controller Msg( "Using joystick '%s' configuration\n", joy_name.GetString() ); } static SplitScreenConVarRef s_joy_movement_stick( "joy_movement_stick" ); bool bJoyMovementStick = s_joy_movement_stick.GetBool( hh ); // advanced initialization here // data supplied by user via joy_axisn cvars dwTemp = ( bJoyMovementStick ) ? (DWORD)joy_advaxisu.GetInt() : (DWORD)joy_advaxisx.GetInt(); user.m_rgAxes[JOY_AXIS_X].AxisMap = dwTemp & 0x0000000f; user.m_rgAxes[JOY_AXIS_X].ControlMap = dwTemp & JOY_RELATIVE_AXIS; dwTemp = ( bJoyMovementStick ) ? (DWORD)joy_advaxisr.GetInt() : (DWORD)joy_advaxisy.GetInt(); user.m_rgAxes[JOY_AXIS_Y].AxisMap = dwTemp & 0x0000000f; user.m_rgAxes[JOY_AXIS_Y].ControlMap = dwTemp & JOY_RELATIVE_AXIS; dwTemp = (DWORD)joy_advaxisz.GetInt(); user.m_rgAxes[JOY_AXIS_Z].AxisMap = dwTemp & 0x0000000f; user.m_rgAxes[JOY_AXIS_Z].ControlMap = dwTemp & JOY_RELATIVE_AXIS; dwTemp = ( bJoyMovementStick ) ? (DWORD)joy_advaxisy.GetInt() : (DWORD)joy_advaxisr.GetInt(); user.m_rgAxes[JOY_AXIS_R].AxisMap = dwTemp & 0x0000000f; user.m_rgAxes[JOY_AXIS_R].ControlMap = dwTemp & JOY_RELATIVE_AXIS; dwTemp = ( bJoyMovementStick ) ? (DWORD)joy_advaxisx.GetInt() : (DWORD)joy_advaxisu.GetInt(); user.m_rgAxes[JOY_AXIS_U].AxisMap = dwTemp & 0x0000000f; user.m_rgAxes[JOY_AXIS_U].ControlMap = dwTemp & JOY_RELATIVE_AXIS; dwTemp = (DWORD)joy_advaxisv.GetInt(); user.m_rgAxes[JOY_AXIS_V].AxisMap = dwTemp & 0x0000000f; user.m_rgAxes[JOY_AXIS_V].ControlMap = dwTemp & JOY_RELATIVE_AXIS; if ( !bSilent ) { Msg( "Advanced joystick settings initialized for joystick %d\n------------\n", hh + 1 ); DescribeJoystickAxis( hh, "x axis", &user.m_rgAxes[JOY_AXIS_X] ); DescribeJoystickAxis( hh, "y axis", &user.m_rgAxes[JOY_AXIS_Y] ); DescribeJoystickAxis( hh, "z axis", &user.m_rgAxes[JOY_AXIS_Z] ); DescribeJoystickAxis( hh, "r axis", &user.m_rgAxes[JOY_AXIS_R] ); DescribeJoystickAxis( hh, "u axis", &user.m_rgAxes[JOY_AXIS_U] ); DescribeJoystickAxis( hh, "v axis", &user.m_rgAxes[JOY_AXIS_V] ); } } } #if defined( SWARM_DLL ) // If we have an xbox controller, load the cfg file if it hasn't been loaded. ConVarRef var( "joy_xcontroller_found" ); if ( var.IsValid() && var.GetBool() && in_joystick.GetBool() ) { if ( joy_xcontroller_cfg_loaded.GetBool() == false ) { if ( IsPC() ) { engine->ClientCmd( "exec 360controller_pc.cfg" ); } else if ( IsX360() ) { engine->ClientCmd( "exec 360controller_xbox.cfg" ); } joy_xcontroller_cfg_loaded.SetValue( 1 ); } } else if ( joy_xcontroller_cfg_loaded.GetBool() ) { engine->ClientCmd( "exec undo360controller.cfg" ); joy_xcontroller_cfg_loaded.SetValue( 0 ); } #else // SWARM_DLL if ( IsPC() ) { // If we have an xcontroller on the PC, load the cfg file if it hasn't been loaded. ConVarRef var( "joy_xcontroller_found" ); if ( var.IsValid() && var.GetBool() && in_joystick.GetBool() ) { if ( joy_xcontroller_cfg_loaded.GetBool() == false ) { engine->ClientCmd( "exec 360controller.cfg" ); joy_xcontroller_cfg_loaded.SetValue( 1 ); } } else if ( joy_xcontroller_cfg_loaded.GetBool() ) { engine->ClientCmd( "exec undo360controller.cfg" ); joy_xcontroller_cfg_loaded.SetValue( 0 ); } } #endif // SWARM_DLL }