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

Method OnDirectInput

src/game/server/player.cpp:560–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

558}
559
560void CPlayer::OnDirectInput(const CNetObj_PlayerInput *pNewInput)
561{
562 Server()->SetClientFlags(m_ClientId, pNewInput->m_PlayerFlags);
563
564 AfkTimer();
565
566 if(((pNewInput->m_PlayerFlags & PLAYERFLAG_SPEC_CAM) || GetClientVersion() < VERSION_DDNET_PLAYERFLAG_SPEC_CAM) && ((!m_pCharacter && m_Team == TEAM_SPECTATORS) || m_Paused) && m_SpectatorId == SPEC_FREEVIEW)
567 m_ViewPos = vec2(pNewInput->m_TargetX, pNewInput->m_TargetY);
568
569 // check for activity
570 // if a player is killed, their scoreboard opens automatically, so ignore that flag
571 CNetObj_PlayerInput NewWithoutScoreboard = *pNewInput;
572 CNetObj_PlayerInput LastWithoutScoreboard = *m_pLastTarget;
573 NewWithoutScoreboard.m_PlayerFlags &= ~PLAYERFLAG_SCOREBOARD;
574 LastWithoutScoreboard.m_PlayerFlags &= ~PLAYERFLAG_SCOREBOARD;
575 if(mem_comp(&NewWithoutScoreboard, &LastWithoutScoreboard, sizeof(CNetObj_PlayerInput)))
576 {
577 mem_copy(m_pLastTarget, pNewInput, sizeof(CNetObj_PlayerInput));
578 // Ignore the first direct input and keep the player afk as it is sent automatically
579 if(m_LastTargetInit)
580 UpdatePlaytime();
581 m_LastActionTick = Server()->Tick();
582 m_LastTargetInit = true;
583 }
584}
585
586void CPlayer::OnPredictedEarlyInput(const CNetObj_PlayerInput *pNewInput)
587{

Callers 2

OnClientDirectInputMethod · 0.45
OnPredictedEarlyInputMethod · 0.45

Calls 5

mem_compFunction · 0.85
mem_copyFunction · 0.85
SetClientFlagsMethod · 0.80
ServerClass · 0.50
TickMethod · 0.45

Tested by

no test coverage detected