Fix hook coll on vanilla 0.7 servers

Thanks to @fokkonaut for this F-Client commit

8ecd8c7f0a

Closed #8742
This commit is contained in:
ChillerDragon 2024-08-16 18:45:55 +08:00
parent a8219530b1
commit fac02650f1
5 changed files with 23 additions and 6 deletions

View file

@ -217,6 +217,7 @@ public:
// server info // server info
virtual void GetServerInfo(class CServerInfo *pServerInfo) const = 0; virtual void GetServerInfo(class CServerInfo *pServerInfo) const = 0;
virtual bool ServerCapAnyPlayerFlag() const = 0;
virtual int GetPredictionTime() = 0; virtual int GetPredictionTime() = 0;

View file

@ -1391,7 +1391,7 @@ void CClient::ProcessServerInfo(int RawType, NETADDR *pFrom, const void *pData,
#undef GET_INT #undef GET_INT
} }
static CServerCapabilities GetServerCapabilities(int Version, int Flags) static CServerCapabilities GetServerCapabilities(int Version, int Flags, bool Sixup)
{ {
CServerCapabilities Result; CServerCapabilities Result;
bool DDNet = false; bool DDNet = false;
@ -1400,7 +1400,7 @@ static CServerCapabilities GetServerCapabilities(int Version, int Flags)
DDNet = Flags & SERVERCAPFLAG_DDNET; DDNet = Flags & SERVERCAPFLAG_DDNET;
} }
Result.m_ChatTimeoutCode = DDNet; Result.m_ChatTimeoutCode = DDNet;
Result.m_AnyPlayerFlag = DDNet; Result.m_AnyPlayerFlag = !Sixup;
Result.m_PingEx = false; Result.m_PingEx = false;
Result.m_AllowDummy = true; Result.m_AllowDummy = true;
Result.m_SyncWeaponInput = false; Result.m_SyncWeaponInput = false;
@ -1501,7 +1501,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
{ {
return; return;
} }
m_ServerCapabilities = GetServerCapabilities(Version, Flags); m_ServerCapabilities = GetServerCapabilities(Version, Flags, IsSixup());
m_CanReceiveServerCapabilities = false; m_CanReceiveServerCapabilities = false;
m_ServerSentCapabilities = true; m_ServerSentCapabilities = true;
} }
@ -1509,7 +1509,7 @@ void CClient::ProcessServerPacket(CNetChunk *pPacket, int Conn, bool Dummy)
{ {
if(m_CanReceiveServerCapabilities) if(m_CanReceiveServerCapabilities)
{ {
m_ServerCapabilities = GetServerCapabilities(0, 0); m_ServerCapabilities = GetServerCapabilities(0, 0, IsSixup());
m_CanReceiveServerCapabilities = false; m_CanReceiveServerCapabilities = false;
} }
bool MapDetailsWerePresent = m_MapDetailsPresent; bool MapDetailsWerePresent = m_MapDetailsPresent;

View file

@ -208,6 +208,8 @@ class CClient : public IClient, public CDemoPlayer::IListener
bool m_ServerSentCapabilities = false; bool m_ServerSentCapabilities = false;
CServerCapabilities m_ServerCapabilities; CServerCapabilities m_ServerCapabilities;
bool ServerCapAnyPlayerFlag() const override { return m_ServerCapabilities.m_AnyPlayerFlag; }
CServerInfo m_CurrentServerInfo; CServerInfo m_CurrentServerInfo;
int64_t m_CurrentServerInfoRequestTime = -1; // >= 0 should request, == -1 got info int64_t m_CurrentServerInfoRequestTime = -1; // >= 0 should request, == -1 got info

View file

@ -191,7 +191,7 @@ int CControls::SnapInput(int *pData)
if(m_pClient->m_Scoreboard.Active()) if(m_pClient->m_Scoreboard.Active())
m_aInputData[g_Config.m_ClDummy].m_PlayerFlags |= PLAYERFLAG_SCOREBOARD; 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; 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; bool Send = m_aLastData[g_Config.m_ClDummy].m_PlayerFlags != m_aInputData[g_Config.m_ClDummy].m_PlayerFlags;

View file

@ -1,6 +1,7 @@
/* (c) Magnus Auvinen. See licence.txt in the root of the distribution for more information. */ /* (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. */ /* If you are missing that file, acquire a complete release at teeworlds.com. */
#include <engine/client/enums.h>
#include <engine/demo.h> #include <engine/demo.h>
#include <engine/graphics.h> #include <engine/graphics.h>
#include <engine/shared/config.h> #include <engine/shared/config.h>
@ -203,8 +204,21 @@ void CPlayers::RenderHookCollLine(
Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick); Position = mix(vec2(Prev.m_X, Prev.m_Y), vec2(Player.m_X, Player.m_Y), IntraTick);
// draw hook collision line // 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 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) 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; RenderHookCollPlayer = GameClient()->m_Controls.m_aShowHookColl[g_Config.m_ClDummy] && g_Config.m_ClShowHookCollOwn > 0;