Skip to content

Commit

Permalink
Merge pull request ddnet#9452 from TsFreddie/spec-cam-fix
Browse files Browse the repository at this point in the history
Fix auto spec cam unexpectedly being available for players without camera info & make self spec always use user zoom.
  • Loading branch information
def- authored Dec 31, 2024
2 parents ead9eb2 + 288a7a3 commit 658b139
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/game/client/components/camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,16 @@ void CCamera::UpdateCamera()
// use hardcoded smooth camera for spectating unless player explictly turn it off
bool IsSpectatingPlayer = !GameClient()->m_MultiViewActivated;
if(Client()->State() == IClient::STATE_DEMOPLAYBACK)
{
IsSpectatingPlayer = IsSpectatingPlayer && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId >= 0;
}
else
IsSpectatingPlayer = IsSpectatingPlayer && m_pClient->m_Snap.m_SpecInfo.m_Active && m_pClient->m_Snap.m_SpecInfo.m_SpectatorId >= 0;
{
IsSpectatingPlayer = IsSpectatingPlayer && m_pClient->m_Snap.m_SpecInfo.m_Active &&
m_pClient->m_Snap.m_SpecInfo.m_SpectatorId >= 0 &&
m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != m_pClient->m_aLocalIds[0] &&
(!m_pClient->Client()->DummyConnected() || m_pClient->m_Snap.m_SpecInfo.m_SpectatorId != m_pClient->m_aLocalIds[1]);
}

bool UsingAutoSpecCamera = m_AutoSpecCamera && CanUseAutoSpecCamera();
float CurrentZoom = m_Zooming ? m_ZoomSmoothingTarget : m_Zoom;
Expand Down
2 changes: 1 addition & 1 deletion src/game/client/gameclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1767,7 +1767,7 @@ void CGameClient::OnNewSnapshot()
else if(Item.m_Type == NETOBJTYPE_DDNETSPECTATORINFO)
{
const CNetObj_DDNetSpectatorInfo *pDDNetSpecInfo = (const CNetObj_DDNetSpectatorInfo *)Item.m_pData;
m_Snap.m_SpecInfo.m_HasCameraInfo = true;
m_Snap.m_SpecInfo.m_HasCameraInfo = pDDNetSpecInfo->m_HasCameraInfo;
m_Snap.m_SpecInfo.m_Zoom = pDDNetSpecInfo->m_Zoom / 1000.0f;
m_Snap.m_SpecInfo.m_Deadzone = pDDNetSpecInfo->m_Deadzone;
m_Snap.m_SpecInfo.m_FollowFactor = pDDNetSpecInfo->m_FollowFactor;
Expand Down

0 comments on commit 658b139

Please sign in to comment.