Skip to content

Commit

Permalink
Replace PLAYERFLAG_SPEC_CAM with unused PLAYERFLAG_PLAYING
Browse files Browse the repository at this point in the history
  • Loading branch information
sjrc6 committed Dec 7, 2024
1 parent d270af9 commit ad6f475
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion datasrc/network.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from datatypes import Enum, Flags, NetArray, NetBool, NetEvent, NetEventEx, NetIntAny, NetIntRange, NetMessage, NetMessageEx, NetObject, NetObjectEx, NetString, NetStringHalfStrict, NetStringStrict, NetTick

Emotes = ["NORMAL", "PAIN", "HAPPY", "SURPRISE", "ANGRY", "BLINK"]
PlayerFlags = ["PLAYING", "IN_MENU", "CHATTING", "SCOREBOARD", "AIM", "SPEC_CAM"]
PlayerFlags = ["SPEC_TARGET", "IN_MENU", "CHATTING", "SCOREBOARD", "AIM"]
GameFlags = ["TEAMS", "FLAGS"]
GameStateFlags = ["GAMEOVER", "SUDDENDEATH", "PAUSED", "RACETIME"]
CharacterFlags = ["SOLO", "JETPACK", "COLLISION_DISABLED", "ENDLESS_HOOK", "ENDLESS_JUMP", "SUPER",
Expand Down
2 changes: 1 addition & 1 deletion src/engine/shared/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ enum
VERSION_DDNET_MULTI_LASER = 16040,
VERSION_DDNET_ENTITY_NETOBJS = 16200,
VERSION_DDNET_REDIRECT = 17020,
VERSION_DDNET_PLAYERFLAG_SPEC_CAM = 18090,
VERSION_DDNET_PLAYERFLAG_SPEC_TARGET = 18090,
};

typedef std::bitset<MAX_CLIENTS> CClientMask;
Expand Down
13 changes: 9 additions & 4 deletions src/game/client/components/controls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -181,28 +181,33 @@ void CControls::OnMessage(int Msg, void *pRawMsg)
int CControls::SnapInput(int *pData)
{
// update player state
bool IsPlaying = false;
if(m_pClient->m_Chat.IsActive())
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags = PLAYERFLAG_CHATTING;
else if(m_pClient->m_Menus.IsActive())
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags = PLAYERFLAG_IN_MENU;
else
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags = PLAYERFLAG_PLAYING;
{
IsPlaying = true;
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags = 0;
}

if(m_pClient->m_Scoreboard.Active())
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_SCOREBOARD;

if(Client()->ServerCapAnyPlayerFlag() && m_pClient->m_Controls.m_aShowHookColl[g_Config.m_ClDummy])
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_AIM;

if(Client()->ServerCapAnyPlayerFlag() && m_pClient->m_Camera.CamType() == CCamera::CAMTYPE_SPEC)
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_SPEC_CAM;
// set SPEC_TARGET flag if client is using the mouse position to specify view position
if(m_pClient->m_Camera.CamType() == CCamera::CAMTYPE_SPEC)
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_SPEC_TARGET;

bool Send = m_aLastData[g_Config.m_ClDummy].m_PlayerFlags != m_aInputData[g_Config.m_ClDummy].m_PlayerFlags;

m_aLastData[g_Config.m_ClDummy].m_PlayerFlags = m_aInputData[g_Config.m_ClDummy].m_PlayerFlags;

// we freeze the input if chat or menu is activated
if(!(m_aInputData[g_Config.m_ClDummy].m_PlayerFlags & PLAYERFLAG_PLAYING))
if(!IsPlaying)
{
if(!GameClient()->m_GameInfo.m_BugDDRaceInput)
ResetInput(g_Config.m_ClDummy);
Expand Down
8 changes: 4 additions & 4 deletions src/game/server/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ void CPlayer::OnPredictedInput(CNetObj_PlayerInput *pNewInput)

m_NumInputs++;

if(m_pCharacter && !m_Paused && !(pNewInput->m_PlayerFlags & PLAYERFLAG_SPEC_CAM))
if(m_pCharacter && !m_Paused && !(pNewInput->m_PlayerFlags & PLAYERFLAG_SPEC_TARGET))
m_pCharacter->OnPredictedInput(pNewInput);

// Magic number when we can hope that client has successfully identified itself
Expand All @@ -528,8 +528,8 @@ void CPlayer::OnDirectInput(CNetObj_PlayerInput *pNewInput)
Server()->SetClientFlags(m_ClientId, pNewInput->m_PlayerFlags);

AfkTimer();

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)
bool IsSpecTarget = (pNewInput->m_PlayerFlags & PLAYERFLAG_SPEC_TARGET && GetClientVersion() >= VERSION_DDNET_PLAYERFLAG_SPEC_TARGET) || GetClientVersion() < VERSION_DDNET_PLAYERFLAG_SPEC_TARGET;
if(IsSpecTarget && ((!m_pCharacter && m_Team == TEAM_SPECTATORS) || m_Paused) && m_SpectatorId == SPEC_FREEVIEW)
m_ViewPos = vec2(pNewInput->m_TargetX, pNewInput->m_TargetY);

// check for activity
Expand All @@ -555,7 +555,7 @@ void CPlayer::OnPredictedEarlyInput(CNetObj_PlayerInput *pNewInput)
if(m_PlayerFlags & PLAYERFLAG_CHATTING)
return;

if(m_pCharacter && !m_Paused && !(m_PlayerFlags & PLAYERFLAG_SPEC_CAM))
if(m_pCharacter && !m_Paused && !(m_PlayerFlags & PLAYERFLAG_SPEC_TARGET))
m_pCharacter->OnDirectInput(pNewInput);
}

Expand Down

0 comments on commit ad6f475

Please sign in to comment.