Merge pull request #8745 from ChillerDragon/pr_07_hook_coll

Fix hook coll on vanilla 0.7 servers
This commit is contained in:
heinrich5991 2024-08-16 12:56:24 +00:00 committed by GitHub
commit f057898ce0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 23 additions and 6 deletions

View file

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

View file

@ -1392,7 +1392,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;
@ -1401,7 +1401,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;
@ -1502,7 +1502,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;
}
@ -1510,7 +1510,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;

View file

@ -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

View file

@ -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;

View file

@ -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 <engine/client/enums.h>
#include <engine/demo.h>
#include <engine/graphics.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);
// 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;