//----------------------------------------------------------------------------- // Purpose: Overridden to allow players to run faster than the maxspeed //----------------------------------------------------------------------------- void CTFGameMovement::ProcessMovement( CBasePlayer *pBasePlayer, CMoveData *pMove ) { // Verify data. Assert( pBasePlayer ); Assert( pMove ); if ( !pBasePlayer || !pMove ) return; // Reset point contents for water check. ResetGetPointContentsCache(); // Cropping movement speed scales mv->m_fForwardSpeed etc. globally // Once we crop, we don't want to recursively crop again, so we set the crop // flag globally here once per usercmd cycle. m_iSpeedCropped = SPEED_CROPPED_RESET; // Get the current TF player. m_pTFPlayer = ToTFPlayer( pBasePlayer ); player = m_pTFPlayer; mv = pMove; // The max speed is currently set to the scout - if this changes we need to change this! mv->m_flMaxSpeed = TF_MAX_SPEED; /*tf_maxspeed.GetFloat();*/ // Run the command. PlayerMove(); FinishMove(); }
//----------------------------------------------------------------------------- // Purpose: // Input : *pMove - //----------------------------------------------------------------------------- void CPortalGameMovement::ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMove ) { Assert( pMove && pPlayer ); float flStoreFrametime = gpGlobals->frametime; //!!HACK HACK: Adrian - slow down all player movement by this factor. //!!Blame Yahn for this one. gpGlobals->frametime *= pPlayer->GetLaggedMovementValue(); // ResetGetPointContentsCache(); // Cropping movement speed scales mv->m_fForwardSpeed etc. globally // Once we crop, we don't want to recursively crop again, so we set the crop // flag globally here once per usercmd cycle. m_bSpeedCropped = false; player = pPlayer; mv = pMove; mv->m_flMaxSpeed = sv_maxspeed.GetFloat(); m_bInPortalEnv = (((CPortal_Player *)pPlayer)->m_hPortalEnvironment != NULL); g_bAllowForcePortalTrace = m_bInPortalEnv; g_bForcePortalTrace = m_bInPortalEnv; // Run the command. PlayerMove(); FinishMove(); g_bAllowForcePortalTrace = false; g_bForcePortalTrace = false; #ifndef CLIENT_DLL pPlayer->UnforceButtons( IN_DUCK ); pPlayer->UnforceButtons( IN_JUMP ); #endif //This is probably not needed, but just in case. gpGlobals->frametime = flStoreFrametime; }
//----------------------------------------------------------------------------- // Purpose: Runs movement commands for the player // Input : *player - // *ucmd - // *moveHelper - // Output : void CPlayerMove::RunCommand //----------------------------------------------------------------------------- void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper ) { StartCommand( player, ucmd ); // Set globals appropriately gpGlobals->curtime = player->m_nTickBase * TICK_INTERVAL; gpGlobals->frametime = player->m_bGamePaused ? 0 : TICK_INTERVAL; if ( player->m_bGamePaused ) { // If no clipping and cheats enabled and noclipduring game enabled, then leave // forwardmove and angles stuff in usercmd if ( player->GetMoveType() == MOVETYPE_NOCLIP && sv_cheats->GetBool() && sv_noclipduringpause.GetBool() ) { gpGlobals->frametime = TICK_INTERVAL; } } /* // TODO: We can check whether the player is sending more commands than elapsed real time cmdtimeremaining -= ucmd->msec; if ( cmdtimeremaining < 0 ) { // return; } */ IGameSystem::FrameUpdatePrePlayerRunCommandAllSystems( player, ucmd ); // Do weapon selection if ( ucmd->weaponselect != 0 ) { CBaseCombatWeapon *weapon = dynamic_cast< CBaseCombatWeapon * >( CBaseEntity::Instance( ucmd->weaponselect ) ); if ( weapon ) { VPROF( "player->SelectItem()" ); player->SelectItem( weapon->GetName(), ucmd->weaponsubtype ); } } IServerVehicle *pVehicle = player->GetVehicle(); // Latch in impulse. if ( ucmd->impulse ) { // Discard impulse commands unless the vehicle allows them. // FIXME: UsingStandardWeapons seems like a bad filter for this. The flashlight is an impulse command, for example. if ( !pVehicle || player->UsingStandardWeaponsInVehicle() ) { player->m_nImpulse = ucmd->impulse; } } // Update player input button states VPROF_SCOPE_BEGIN( "player->UpdateButtonState" ); player->UpdateButtonState( ucmd->buttons ); VPROF_SCOPE_END(); CheckMovingGround( player, TICK_INTERVAL ); g_pMoveData->m_vecOldAngles = player->pl.v_angle; // Copy from command to player unless game .dll has set angle using fixangle if ( player->pl.fixangle == FIXANGLE_NONE ) { player->pl.v_angle = ucmd->viewangles; } else if( player->pl.fixangle == FIXANGLE_RELATIVE ) { player->pl.v_angle = ucmd->viewangles + player->pl.anglechange; } // Call standard client pre-think RunPreThink( player ); // Call Think if one is set RunThink( player, TICK_INTERVAL ); // Setup input. SetupMove( player, ucmd, moveHelper, g_pMoveData ); // Let the game do the movement. if ( !pVehicle ) { VPROF( "g_pGameMovement->ProcessMovement()" ); Assert( g_pGameMovement ); g_pGameMovement->ProcessMovement( player, g_pMoveData ); } else { VPROF( "pVehicle->ProcessMovement()" ); pVehicle->ProcessMovement( player, g_pMoveData ); } // Copy output FinishMove( player, ucmd, g_pMoveData ); // Let server invoke any needed impact functions VPROF_SCOPE_BEGIN( "moveHelper->ProcessImpacts" ); moveHelper->ProcessImpacts(); VPROF_SCOPE_END(); RunPostThink( player ); FinishCommand( player ); // Let time pass player->m_nTickBase++; }
//----------------------------------------------------------------------------- // Purpose: Runs movement commands for the player // Input : *player - // *ucmd - // *moveHelper - // Output : void CPlayerMove::RunCommand //----------------------------------------------------------------------------- void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper ) { const float playerCurTime = player->m_nTickBase * TICK_INTERVAL; const float playerFrameTime = player->m_bGamePaused ? 0 : TICK_INTERVAL; const float flTimeAllowedForProcessing = player->ConsumeMovementTimeForUserCmdProcessing( playerFrameTime ); if ( !player->IsBot() && ( flTimeAllowedForProcessing < playerFrameTime ) ) { // Make sure that the activity in command is erased because player cheated or dropped too many packets double dblWarningFrequencyThrottle = sv_maxusrcmdprocessticks_warning.GetFloat(); if ( dblWarningFrequencyThrottle >= 0 ) { static double s_dblLastWarningTime = 0; double dblTimeNow = Plat_FloatTime(); if ( !s_dblLastWarningTime || ( dblTimeNow - s_dblLastWarningTime >= dblWarningFrequencyThrottle ) ) { s_dblLastWarningTime = dblTimeNow; Warning( "sv_maxusrcmdprocessticks_warning at server tick %u: Ignored client %s usrcmd (%.6f < %.6f)!\n", gpGlobals->tickcount, player->GetPlayerName(), flTimeAllowedForProcessing, playerFrameTime ); } } return; // Don't process this command } StartCommand( player, ucmd ); // Set globals appropriately gpGlobals->curtime = playerCurTime; gpGlobals->frametime = playerFrameTime; // Prevent hacked clients from sending us invalid view angles to try to get leaf server code to crash if ( !ucmd->viewangles.IsValid() || !IsEntityQAngleReasonable(ucmd->viewangles) ) { ucmd->viewangles = vec3_angle; } // Add and subtract buttons we're forcing on the player ucmd->buttons |= player->m_afButtonForced; ucmd->buttons &= ~player->m_afButtonDisabled; if ( player->m_bGamePaused ) { // If no clipping and cheats enabled and noclipduring game enabled, then leave // forwardmove and angles stuff in usercmd if ( player->GetMoveType() == MOVETYPE_NOCLIP && sv_cheats->GetBool() && sv_noclipduringpause.GetBool() ) { gpGlobals->frametime = TICK_INTERVAL; } } /* // TODO: We can check whether the player is sending more commands than elapsed real time cmdtimeremaining -= ucmd->msec; if ( cmdtimeremaining < 0 ) { // return; } */ g_pGameMovement->StartTrackPredictionErrors( player ); CommentarySystem_PePlayerRunCommand( player, ucmd ); // Do weapon selection if ( ucmd->weaponselect != 0 ) { CBaseCombatWeapon *weapon = dynamic_cast< CBaseCombatWeapon * >( CBaseEntity::Instance( ucmd->weaponselect ) ); if ( weapon ) { VPROF( "player->SelectItem()" ); player->SelectItem( weapon->GetName(), ucmd->weaponsubtype ); } } IServerVehicle *pVehicle = player->GetVehicle(); // Latch in impulse. if ( ucmd->impulse ) { // Discard impulse commands unless the vehicle allows them. // FIXME: UsingStandardWeapons seems like a bad filter for this. The flashlight is an impulse command, for example. if ( !pVehicle || player->UsingStandardWeaponsInVehicle() ) { player->m_nImpulse = ucmd->impulse; } } // Update player input button states VPROF_SCOPE_BEGIN( "player->UpdateButtonState" ); player->UpdateButtonState( ucmd->buttons ); VPROF_SCOPE_END(); CheckMovingGround( player, TICK_INTERVAL ); g_pMoveData->m_vecOldAngles = player->pl.v_angle; // Copy from command to player unless game .dll has set angle using fixangle if ( player->pl.fixangle == FIXANGLE_NONE ) { player->pl.v_angle = ucmd->viewangles; } else if( player->pl.fixangle == FIXANGLE_RELATIVE ) { player->pl.v_angle = ucmd->viewangles + player->pl.anglechange; } // Call standard client pre-think RunPreThink( player ); // Call Think if one is set RunThink( player, TICK_INTERVAL ); // Setup input. SetupMove( player, ucmd, moveHelper, g_pMoveData ); // Let the game do the movement. if ( !pVehicle ) { VPROF( "g_pGameMovement->ProcessMovement()" ); Assert( g_pGameMovement ); g_pGameMovement->ProcessMovement( player, g_pMoveData ); } else { VPROF( "pVehicle->ProcessMovement()" ); pVehicle->ProcessMovement( player, g_pMoveData ); } // Copy output FinishMove( player, ucmd, g_pMoveData ); // If we have to restore the view angle then do so right now if ( !player->IsBot() && ( gpGlobals->tickcount - player->GetLockViewanglesTickNumber() < sv_maxusrcmdprocessticks_holdaim.GetInt() ) ) { player->pl.v_angle = player->GetLockViewanglesData(); } // Let server invoke any needed impact functions VPROF_SCOPE_BEGIN( "moveHelper->ProcessImpacts" ); moveHelper->ProcessImpacts(); VPROF_SCOPE_END(); RunPostThink( player ); g_pGameMovement->FinishTrackPredictionErrors( player ); FinishCommand( player ); // Let time pass if ( gpGlobals->frametime > 0 ) { player->m_nTickBase++; } }
void CBPGameMovement::ProcessMovement( CBasePlayer *pPlayer, CMoveData *pMove ) { Assert( pMove && pPlayer ); float flStoreFrametime = gpGlobals->frametime; //!!HACK HACK: Adrian - slow down all player movement by this factor. //!!Blame Yahn for this one. gpGlobals->frametime *= pPlayer->GetLaggedMovementValue(); ResetGetPointContentsCache(); Assert( player == pPlayer ); player = pPlayer; mv = pMove; bpmv = (CBPMoveData*) pMove ; mv->m_flMaxSpeed = pPlayer->GetPlayerMaxSpeed(); // Add trigger to history for interp stuff m_flInterpLTrigger.AddToTail( float_time( bpmv->m_flLTrigger, gpGlobals->curtime ) ); m_flInterpRTrigger.AddToTail( float_time( bpmv->m_flRTrigger, gpGlobals->curtime ) ); m_flLTriggerAvg = 0; for ( int i = 0; i < m_flInterpLTrigger.Count(); i++ ) m_flLTriggerAvg += m_flInterpLTrigger[i].m_flValue; m_flLTriggerAvg /= m_flInterpLTrigger.Count(); m_flLTriggerDiff = bpmv->m_flLTrigger - m_flLTriggerAvg; //DevMsg("Diff = %.2f - %.2f = %.2f\n",bpmv->m_flLTrigger,lDiff, m_flLTriggerDiff,m_flLTriggerDiff); m_flRTriggerAvg = 0; for ( int i = 0; i < m_flInterpRTrigger.Count(); i++ ) m_flRTriggerAvg += m_flInterpRTrigger[i].m_flValue; m_flRTriggerAvg /= m_flInterpRTrigger.Count(); m_flRTriggerDiff = bpmv->m_flRTrigger - m_flRTriggerAvg; int iCount = m_flInterpLTrigger.Count(); for ( int i = iCount-1; i >= 0; i-- ) { if ( m_flInterpLTrigger[i].m_flTime < gpGlobals->curtime-0.15 ) m_flInterpLTrigger.Remove(i); } iCount = m_flInterpRTrigger.Count(); for ( int i = iCount-1; i >= 0; i-- ) { if ( m_flInterpRTrigger[i].m_flTime < gpGlobals->curtime-0.15 ) m_flInterpRTrigger.Remove(i); } DiffPrint( "start %f %f %f", mv->GetAbsOrigin().x, mv->GetAbsOrigin().y, mv->GetAbsOrigin().z ); // Run the command. PlayerMove(); FinishMove(); DiffPrint( "end %f %f %f", mv->GetAbsOrigin().x, mv->GetAbsOrigin().y, mv->GetAbsOrigin().z ); //This is probably not needed, but just in case. gpGlobals->frametime = flStoreFrametime; }
void CHL2WarsPlayerMove::RunCommand( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper ) { CHL2WarsPlayer *pWarsPlayer = static_cast<CHL2WarsPlayer*>( player ); Assert( pWarsPlayer ); StartCommand( player, ucmd ); // Set globals appropriately gpGlobals->curtime = player->m_nTickBase * TICK_INTERVAL; gpGlobals->frametime = player->m_bGamePaused ? 0 : TICK_INTERVAL; // Add and subtract buttons we're forcing on the player ucmd->buttons |= player->m_afButtonForced; ucmd->buttons &= ~player->m_afButtonDisabled; if ( player->m_bGamePaused ) { // If no clipping and cheats enabled and noclipduring game enabled, then leave // forwardmove and angles stuff in usercmd if ( player->GetMoveType() == MOVETYPE_NOCLIP && sv_cheats->GetBool() )// && //sv_noclipduringpause.GetBool() ) { gpGlobals->frametime = TICK_INTERVAL; } } /* // TODO: We can check whether the player is sending more commands than elapsed real time cmdtimeremaining -= ucmd->msec; if ( cmdtimeremaining < 0 ) { // return; } */ g_pGameMovement->StartTrackPredictionErrors( player ); //CommentarySystem_PePlayerRunCommand( player, ucmd ); IServerVehicle *pVehicle = player->GetVehicle(); // Latch in impulse. if ( ucmd->impulse ) { // Discard impulse commands unless the vehicle allows them. // FIXME: UsingStandardWeapons seems like a bad filter for this. The flashlight is an impulse command, for example. if ( !pVehicle || player->UsingStandardWeaponsInVehicle() ) { player->m_nImpulse = ucmd->impulse; } } // Update player input button states VPROF_SCOPE_BEGIN( "player->UpdateButtonState" ); player->UpdateButtonState( ucmd->buttons ); VPROF_SCOPE_END(); CheckMovingGround( player, TICK_INTERVAL ); g_pMoveData->m_vecOldAngles = player->pl.v_angle; // Copy from command to player unless game .dll has set angle using fixangle if ( player->pl.fixangle == FIXANGLE_NONE ) { player->pl.v_angle = ucmd->viewangles; } else if( player->pl.fixangle == FIXANGLE_RELATIVE ) { player->pl.v_angle = ucmd->viewangles + player->pl.anglechange; } // TrackIR //player->SetEyeAngleOffset(ucmd->headangles); //player->SetEyeOffset(ucmd->headoffset); // TrackIR // Call standard client pre-think RunPreThink( player ); // Call Think if one is set RunThink( player, TICK_INTERVAL ); // Setup input. SetupMove( player, ucmd, moveHelper, g_pMoveData ); // Let the game do the movement. if( pWarsPlayer && !pWarsPlayer->GetControlledUnit() ) { if( ucmd->directmove ) { g_pMoveData->SetAbsOrigin( ucmd->vecmovetoposition ); } else { if ( !pVehicle ) { VPROF( "g_pGameMovement->ProcessMovement()" ); Assert( g_pGameMovement ); g_pGameMovement->ProcessMovement( player, g_pMoveData ); } else { VPROF( "pVehicle->ProcessMovement()" ); pVehicle->ProcessMovement( player, g_pMoveData ); } } } // Copy output FinishMove( player, ucmd, g_pMoveData ); // Let server invoke any needed impact functions VPROF_SCOPE_BEGIN( "moveHelper->ProcessImpacts" ); moveHelper->ProcessImpacts(); VPROF_SCOPE_END(); // put lag compensation here so it affects weapons //lagcompensation->StartLagCompensation( player, LAG_COMPENSATE_BOUNDS ); RunPostThink( player ); //lagcompensation->FinishLagCompensation( player ); // let the player drive marine movement here if( pWarsPlayer->GetControlledUnit() ) pWarsPlayer->GetControlledUnit()->GetIUnit()->UserCmd( ucmd ); g_pGameMovement->FinishTrackPredictionErrors( player ); FinishCommand( player ); // Let time pass player->m_nTickBase++; }
//----------------------------------------------------------------------------- // Purpose: Predicts a single movement command for player // Input : *moveHelper - // *player - // *u - //----------------------------------------------------------------------------- void CASW_Prediction::RunCommand( C_BasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper ) { #if !defined( NO_ENTITY_PREDICTION ) VPROF( "CPrediction::RunCommand" ); #if defined( _DEBUG ) char sz[ 32 ]; Q_snprintf( sz, sizeof( sz ), "runcommand%04d", ucmd->command_number ); PREDICTION_TRACKVALUECHANGESCOPE( sz ); #endif C_ASW_Player *pASWPlayer = (C_ASW_Player*)player; Assert( pASWPlayer ); StartCommand( player, ucmd ); pASWPlayer->SetHighlightEntity( C_BaseEntity::Instance( ucmd->crosshair_entity ) ); // Set globals appropriately gpGlobals->curtime = player->m_nTickBase * TICK_INTERVAL; gpGlobals->frametime = TICK_INTERVAL; g_pGameMovement->StartTrackPredictionErrors( player ); // TODO // TODO: Check for impulse predicted? // Do weapon selection if ( ucmd->weaponselect != 0 ) { C_BaseCombatWeapon *weapon = dynamic_cast< C_BaseCombatWeapon * >( CBaseEntity::Instance( ucmd->weaponselect ) ); if (weapon) { pASWPlayer->ASWSelectWeapon(weapon, 0); //ucmd->weaponsubtype); // asw - subtype var used for sending marine profile index instead } } // Latch in impulse. IClientVehicle *pVehicle = player->GetVehicle(); if ( ucmd->impulse ) { // Discard impulse commands unless the vehicle allows them. // FIXME: UsingStandardWeapons seems like a bad filter for this. // The flashlight is an impulse command, for example. if ( !pVehicle || player->UsingStandardWeaponsInVehicle() ) { player->m_nImpulse = ucmd->impulse; } } // Get button states player->UpdateButtonState( ucmd->buttons ); // TODO // CheckMovingGround( player, ucmd->frametime ); // TODO // g_pMoveData->m_vecOldAngles = player->pl.v_angle; // Copy from command to player unless game .dll has set angle using fixangle // if ( !player->pl.fixangle ) { player->SetLocalViewAngles( ucmd->viewangles ); } // Call standard client pre-think RunPreThink( player ); // Call Think if one is set RunThink( player, TICK_INTERVAL ); // Setup input. { SetupMove( player, ucmd, moveHelper, g_pMoveData ); } // Run regular player movement if we're not controlling a marine if ( asw_allow_detach.GetBool() ) { if ( !pVehicle ) { Assert( g_pGameMovement ); g_pGameMovement->ProcessMovement( player, g_pMoveData ); } else { pVehicle->ProcessMovement( player, g_pMoveData ); } } // if ( !asw_allow_detach.GetBool() && pASWPlayer->GetMarine() ) // { // g_pMoveData->SetAbsOrigin( pASWPlayer->GetMarine()->GetAbsOrigin() ); // } pASWPlayer->SetCrosshairTracePos( ucmd->crosshairtrace ); FinishMove( player, ucmd, g_pMoveData ); RunPostThink( player ); // let the player drive marine movement here pASWPlayer->DriveMarineMovement( ucmd, moveHelper ); g_pGameMovement->FinishTrackPredictionErrors( player ); FinishCommand( player ); player->m_nTickBase++; #endif }