From fac02650f164d967393635bc34167f6bebd2786f Mon Sep 17 00:00:00 2001 From: ChillerDragon Date: Fri, 16 Aug 2024 18:45:55 +0800 Subject: [PATCH] Fix hook coll on vanilla 0.7 servers Thanks to @fokkonaut for this F-Client commit https://github.com/fokkonaut/F-Client/commit/8ecd8c7f0ab4b41f16d165bc5ec9b9e87578012c Closed #8742 --- src/engine/client.h | 1 + src/engine/client/client.cpp | 8 ++++---- src/engine/client/client.h | 2 ++ src/game/client/components/controls.cpp | 2 +- src/game/client/components/players.cpp | 16 +++++++++++++++- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/engine/client.h b/src/engine/client.h index 8c0f501ac..a9599f89b 100644 --- a/src/engine/client.h +++ b/src/engine/client.h @@ -217,6 +217,7 @@ public: // server info virtual void GetServerInfo(class CServerInfo *pServerInfo) const = 0; + virtual bool ServerCapAnyPlayerFlag() const = 0; virtual int GetPredictionTime() = 0; diff --git a/src/engine/client/client.cpp b/src/engine/client/client.cpp index 857fec84e..51fd65278 100644 --- a/src/engine/client/client.cpp +++ b/src/engine/client/client.cpp @@ -1391,7 +1391,7 @@ void CClient::ProcessServerInfo(int RawType, NETADDR *pFrom, const void *pData, #undef GET_INT } -static CServerCapabilities GetServerCapabilities(int Version, int Flags) +static CServerCapabilities GetServerCapabilities(int Version, int Flags, bool Sixup) { CServerCapabilities Result; bool DDNet = false; @@ -1400,7 +1400,7 @@ static CServerCapabilities GetServerCapabilities(int Version, int Flags) DDNet = Flags & SERVERCAPFLAG_DDNET; } Result.m_ChatTimeoutCode = DDNet; - Result.m_AnyPlayerFlag = DDNet; + Result.m_AnyPlayerFlag = !Sixup; Result.m_PingEx = false; Result.m_AllowDummy = true; Result.m_SyncWeaponInput = false; @@ -1501,7 +1501,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy) { return; } - m_ServerCapabilities = GetServerCapabilities(Version, Flags); + m_ServerCapabilities = GetServerCapabilities(Version, Flags, IsSixup()); m_CanReceiveServerCapabilities = false; m_ServerSentCapabilities = true; } @@ -1509,7 +1509,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy) { if(m_CanReceiveServerCapabilities) { - m_ServerCapabilities = GetServerCapabilities(0, 0); + m_ServerCapabilities = GetServerCapabilities(0, 0, IsSixup()); m_CanReceiveServerCapabilities = false; } bool MapDetailsWerePresent = m_MapDetailsPresent; diff --git a/src/engine/client/client.h b/src/engine/client/client.h index a72d95173..844f38036 100644 --- a/src/engine/client/client.h +++ b/src/engine/client/client.h @@ -208,6 +208,8 @@ class CClient : public IClient, public CDemoPlayer::IListener bool m_ServerSentCapabilities = false; CServerCapabilities m_ServerCapabilities; + bool ServerCapAnyPlayerFlag() const override { return m_ServerCapabilities.m_AnyPlayerFlag; } + CServerInfo m_CurrentServerInfo; int64_t m_CurrentServerInfoRequestTime = -1; // >= 0 should request, == -1 got info diff --git a/src/game/client/components/controls.cpp b/src/game/client/components/controls.cpp index b143b909f..9eb54777a 100644 --- a/src/game/client/components/controls.cpp +++ b/src/game/client/components/controls.cpp @@ -191,7 +191,7 @@ int CControls::SnapInput(int *pData) if(m_pClient->m_Scoreboard.Active()) m_aInputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_SCOREBOARD; - if(m_pClient->m_Controls.m_aShowHookColl[g_Config.m_ClDummy]) + if(m_pClient->m_Controls.m_aShowHookColl[g_Config.m_ClDummy] && Client()->ServerCapAnyPlayerFlag()) m_aInputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_AIM; bool Send = m_aLastData[g_Config.m_ClDummy].m_PlayerFlags != m_aInputData[g_Config.m_ClDummy].m_PlayerFlags; diff --git a/src/game/client/components/players.cpp b/src/game/client/components/players.cpp index b8487b259..2b7e581ea 100644 --- a/src/game/client/components/players.cpp +++ b/src/game/client/components/players.cpp @@ -1,6 +1,7 @@ /* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */ +#include #include #include #include @@ -203,8 +204,21 @@ void CPlayers::RenderHookCollLine( Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick); // draw hook collision line { + bool Aim = (Player.m_PlayerFlags & PLAYERFLAG_AIM); + if(!Client()->ServerCapAnyPlayerFlag()) + { + for(int i = 0; i < NUM_DUMMIES; i++) + { + if(ClientId == m_pClient->m_aLocalIds[i]) + { + Aim = GameClient()->m_Controls.m_aShowHookColl[i]; + break; + } + } + } + bool AlwaysRenderHookColl = GameClient()->m_GameInfo.m_AllowHookColl && (Local ? g_Config.m_ClShowHookCollOwn : g_Config.m_ClShowHookCollOther) == 2; - bool RenderHookCollPlayer = ClientId >= 0 && Player.m_PlayerFlags & PLAYERFLAG_AIM && (Local ? g_Config.m_ClShowHookCollOwn : g_Config.m_ClShowHookCollOther) > 0; + bool RenderHookCollPlayer = ClientId >= 0 && Aim && (Local ? g_Config.m_ClShowHookCollOwn : g_Config.m_ClShowHookCollOther) > 0; if(Local && GameClient()->m_GameInfo.m_AllowHookColl && Client()->State() != IClient::STATE_DEMOPLAYBACK) RenderHookCollPlayer = GameClient()->m_Controls.m_aShowHookColl[g_Config.m_ClDummy] && g_Config.m_ClShowHookCollOwn > 0;