Do not clip players with hook in the field of view

This commit is contained in:
c0d3d3v 2022-05-04 20:08:02 +02:00
parent d64445d983
commit ab37f95bb4
No known key found for this signature in database
GPG key ID: 068AF680530DFF31
2 changed files with 3 additions and 2 deletions

View file

@ -147,11 +147,11 @@ typedef vector2_base<int> ivec2;
template<typename T>
inline bool closest_point_on_line(vector2_base<T> line_pointA, vector2_base<T> line_pointB, vector2_base<T> target_point, vector2_base<T> &out_pos)
{
vector2_base<T> AP = target_point - line_pointA;
vector2_base<T> AB = line_pointB - line_pointA;
T SquaredMagnitudeAB = dot(AB, AB);
if(SquaredMagnitudeAB > 0)
{
vector2_base<T> AP = target_point - line_pointA;
T APdotAB = dot(AP, AB);
T t = APdotAB / SquaredMagnitudeAB;
out_pos = line_pointA + AB * clamp(t, (T)0, (T)1);

View file

@ -1191,7 +1191,8 @@ void CCharacter::Snap(int SnappingClient)
if(!Server()->Translate(ID, SnappingClient))
return;
if(NetworkClipped(SnappingClient) || !CanSnapCharacter(SnappingClient))
// A player may not be clipped away if his hook is in the field of view
if(NetworkClippedLine(SnappingClient, m_Pos, m_Core.m_HookPos) || !CanSnapCharacter(SnappingClient))
return;
SnapCharacter(SnappingClient, ID);