@@ -2417,6 +2417,46 @@ void CGameClient::UpdateEditorIngameMoved()
24172417 }
24182418}
24192419
2420+ void CGameClient::ApplyPreInputs (int Tick, bool Direct, CGameWorld &GameWorld)
2421+ {
2422+ if (!g_Config.m_ClAntiPingPreInput )
2423+ return ;
2424+
2425+ for (int i = 0 ; i < MAX_CLIENTS; i++)
2426+ {
2427+ if (CCharacter *pChar = GameWorld.GetCharacterById (i))
2428+ {
2429+ if (i == m_aLocalIds[0 ] || (Client ()->DummyConnected () && i == m_aLocalIds[1 ]))
2430+ continue ;
2431+
2432+ const CNetMsg_Sv_PreInput PreInput = m_aClients[i].m_aPreInputs [Tick % 200 ];
2433+ if (PreInput.m_IntendedTick != Tick)
2434+ continue ;
2435+
2436+ // convert preinput to input
2437+ CNetObj_PlayerInput Input = {0 };
2438+ Input.m_Direction = PreInput.m_Direction ;
2439+ Input.m_TargetX = PreInput.m_TargetX ;
2440+ Input.m_TargetY = PreInput.m_TargetY ;
2441+ Input.m_Jump = PreInput.m_Jump ;
2442+ Input.m_Fire = PreInput.m_Fire ;
2443+ Input.m_Hook = PreInput.m_Hook ;
2444+ Input.m_WantedWeapon = PreInput.m_WantedWeapon ;
2445+ Input.m_NextWeapon = PreInput.m_NextWeapon ;
2446+ Input.m_PrevWeapon = PreInput.m_PrevWeapon ;
2447+
2448+ if (Direct)
2449+ {
2450+ pChar->OnDirectInput (&Input);
2451+ }
2452+ else
2453+ {
2454+ pChar->OnPredictedInput (&Input);
2455+ }
2456+ }
2457+ }
2458+ }
2459+
24202460void CGameClient::OnPredict ()
24212461{
24222462 // store the previous values so we can detect prediction errors
@@ -2511,71 +2551,15 @@ void CGameClient::OnPredict()
25112551 if (pDummyInputData && !DummyFirst)
25122552 pDummyChar->OnDirectInput (pDummyInputData);
25132553
2514- if (g_Config.m_ClAntiPingPreInput )
2515- {
2516- for (int i = 0 ; i < MAX_CLIENTS; i++)
2517- {
2518- if (CCharacter *pChar = m_PredictedWorld.GetCharacterById (i))
2519- {
2520- if (i == m_aLocalIds[0 ] || (Client ()->DummyConnected () && i == m_aLocalIds[1 ]))
2521- continue ;
2522-
2523- const CNetMsg_Sv_PreInput PreInput = m_aClients[i].m_aPreInputs [Tick % 200 ];
2524- if (PreInput.m_IntendedTick != Tick)
2525- continue ;
2526-
2527- // convert preinput to input
2528- CNetObj_PlayerInput Input = {0 };
2529- Input.m_Direction = PreInput.m_Direction ;
2530- Input.m_TargetX = PreInput.m_TargetX ;
2531- Input.m_TargetY = PreInput.m_TargetY ;
2532- Input.m_Jump = PreInput.m_Jump ;
2533- Input.m_Fire = PreInput.m_Fire ;
2534- Input.m_Hook = PreInput.m_Hook ;
2535- Input.m_WantedWeapon = PreInput.m_WantedWeapon ;
2536- Input.m_NextWeapon = PreInput.m_NextWeapon ;
2537- Input.m_PrevWeapon = PreInput.m_PrevWeapon ;
2538-
2539- pChar->OnDirectInput (&Input);
2540- }
2541- }
2542- }
2554+ ApplyPreInputs (Tick, true , m_PredictedWorld);
25432555
25442556 m_PredictedWorld.m_GameTick = Tick;
25452557 if (pInputData)
25462558 pLocalChar->OnPredictedInput (pInputData);
25472559 if (pDummyInputData)
25482560 pDummyChar->OnPredictedInput (pDummyInputData);
25492561
2550- if (g_Config.m_ClAntiPingPreInput )
2551- {
2552- for (int i = 0 ; i < MAX_CLIENTS; i++)
2553- {
2554- if (CCharacter *pChar = m_PredictedWorld.GetCharacterById (i))
2555- {
2556- if (pDummyChar == pChar || pLocalChar == pChar)
2557- continue ;
2558-
2559- const CNetMsg_Sv_PreInput PreInput = m_aClients[i].m_aPreInputs [Tick % 200 ];
2560- if (PreInput.m_IntendedTick != Tick)
2561- continue ;
2562-
2563- // convert preinput to input
2564- CNetObj_PlayerInput Input = {0 };
2565- Input.m_Direction = PreInput.m_Direction ;
2566- Input.m_TargetX = PreInput.m_TargetX ;
2567- Input.m_TargetY = PreInput.m_TargetY ;
2568- Input.m_Jump = PreInput.m_Jump ;
2569- Input.m_Fire = PreInput.m_Fire ;
2570- Input.m_Hook = PreInput.m_Hook ;
2571- Input.m_WantedWeapon = PreInput.m_WantedWeapon ;
2572- Input.m_NextWeapon = PreInput.m_NextWeapon ;
2573- Input.m_PrevWeapon = PreInput.m_PrevWeapon ;
2574-
2575- pChar->OnPredictedInput (&Input);
2576- }
2577- }
2578- }
2562+ ApplyPreInputs (Tick, false , m_PredictedWorld);
25792563
25802564 m_PredictedWorld.Tick ();
25812565
@@ -3435,11 +3419,17 @@ void CGameClient::UpdatePrediction()
34353419 pLocalChar->OnDirectInput (pInput);
34363420 if (pDummyInput)
34373421 pDummyChar->OnDirectInput (pDummyInput);
3422+
3423+ ApplyPreInputs (Tick, true , m_GameWorld);
3424+
34383425 m_GameWorld.m_GameTick = Tick;
34393426 if (pInput)
34403427 pLocalChar->OnPredictedInput (pInput);
34413428 if (pDummyInput)
34423429 pDummyChar->OnPredictedInput (pDummyInput);
3430+
3431+ ApplyPreInputs (Tick, false , m_GameWorld);
3432+
34433433 m_GameWorld.Tick ();
34443434
34453435 for (int i = 0 ; i < MAX_CLIENTS; i++)
0 commit comments