MCPcopy Create free account
hub / github.com/ddnet/ddnet / OnClientPredictedEarlyInput

Method OnClientPredictedEarlyInput

src/game/server/gamecontext.cpp:1497–1528  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1495}
1496
1497void CGameContext::OnClientPredictedEarlyInput(int ClientId, const void *pInput)
1498{
1499 const CNetObj_PlayerInput *pApplyInput = static_cast<const CNetObj_PlayerInput *>(pInput);
1500
1501 if(pApplyInput == nullptr)
1502 {
1503 // early return if no input at all has been sent by a player
1504 if(!m_aPlayerHasInput[ClientId])
1505 {
1506 return;
1507 }
1508 // set to last sent input when no new input has been sent
1509 pApplyInput = &m_aLastPlayerInput[ClientId];
1510 }
1511 else
1512 {
1513 // Store input in this function and not in `OnClientPredictedInput`,
1514 // because this function is called on all inputs, while
1515 // `OnClientPredictedInput` is only called on the first input of each
1516 // tick.
1517 mem_copy(&m_aLastPlayerInput[ClientId], pApplyInput, sizeof(m_aLastPlayerInput[ClientId]));
1518 m_aPlayerHasInput[ClientId] = true;
1519 }
1520
1521 if(!m_pController->IsGamePaused())
1522 m_apPlayers[ClientId]->OnPredictedEarlyInput(pApplyInput);
1523
1524 if(m_TeeHistorianActive)
1525 {
1526 m_TeeHistorian.RecordPlayerInput(ClientId, m_apPlayers[ClientId]->GetUniqueCid(), pApplyInput);
1527 }
1528}
1529
1530const CVoteOptionServer *CGameContext::GetVoteOption(int Index) const
1531{

Callers 1

RunMethod · 0.80

Calls 5

mem_copyFunction · 0.85
IsGamePausedMethod · 0.80
OnPredictedEarlyInputMethod · 0.80
RecordPlayerInputMethod · 0.80
GetUniqueCidMethod · 0.80

Tested by

no test coverage detected