mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-20 06:58:20 +00:00
No network clip in client prediction
This commit is contained in:
parent
460f2190f5
commit
f9aae5d53a
|
@ -234,9 +234,3 @@ bool CProjectile::Match(CProjectile *pProj)
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int CProjectile::NetworkClipped(vec2 ViewPos)
|
|
||||||
{
|
|
||||||
float Ct = (GameWorld()->GameTick() - m_StartTick) / (float)GameWorld()->GameTickSpeed();
|
|
||||||
return ((CEntity *)this)->NetworkClipped(GetPos(Ct), ViewPos);
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,7 +40,6 @@ public:
|
||||||
const int &GetOwner() { return m_Owner; }
|
const int &GetOwner() { return m_Owner; }
|
||||||
const int &GetStartTick() { return m_StartTick; }
|
const int &GetStartTick() { return m_StartTick; }
|
||||||
CProjectile(CGameWorld *pGameWorld, int ID, CNetObj_Projectile *pProj);
|
CProjectile(CGameWorld *pGameWorld, int ID, CNetObj_Projectile *pProj);
|
||||||
virtual int NetworkClipped(vec2 ViewPos);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
vec2 m_Direction;
|
vec2 m_Direction;
|
||||||
|
|
|
@ -33,24 +33,6 @@ CEntity::~CEntity()
|
||||||
GameWorld()->RemoveEntity(this);
|
GameWorld()->RemoveEntity(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
int CEntity::NetworkClipped(vec2 ViewPos)
|
|
||||||
{
|
|
||||||
return NetworkClipped(m_Pos, ViewPos);
|
|
||||||
}
|
|
||||||
|
|
||||||
int CEntity::NetworkClipped(vec2 CheckPos, vec2 ViewPos)
|
|
||||||
{
|
|
||||||
float dx = ViewPos.x - CheckPos.x;
|
|
||||||
float dy = ViewPos.y - CheckPos.y;
|
|
||||||
|
|
||||||
if(absolute(dx) > 1000.0f || absolute(dy) > 800.0f)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
if(distance(ViewPos, CheckPos) > 4000.0f)
|
|
||||||
return 1;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CEntity::GameLayerClipped(vec2 CheckPos)
|
bool CEntity::GameLayerClipped(vec2 CheckPos)
|
||||||
{
|
{
|
||||||
return round_to_int(CheckPos.x) / 32 < -200 || round_to_int(CheckPos.x) / 32 > Collision()->GetWidth() + 200 ||
|
return round_to_int(CheckPos.x) / 32 < -200 || round_to_int(CheckPos.x) / 32 > Collision()->GetWidth() + 200 ||
|
||||||
|
|
|
@ -54,8 +54,6 @@ public:
|
||||||
virtual void TickDefered() {}
|
virtual void TickDefered() {}
|
||||||
|
|
||||||
bool GameLayerClipped(vec2 CheckPos);
|
bool GameLayerClipped(vec2 CheckPos);
|
||||||
virtual int NetworkClipped(vec2 ViewPos);
|
|
||||||
virtual int NetworkClipped(vec2 CheckPos, vec2 ViewPos);
|
|
||||||
float m_ProximityRadius;
|
float m_ProximityRadius;
|
||||||
vec2 m_Pos;
|
vec2 m_Pos;
|
||||||
int m_Number;
|
int m_Number;
|
||||||
|
|
|
@ -485,14 +485,6 @@ void CGameWorld::NetObjEnd(int LocalID)
|
||||||
pHookedChar->m_KeepHooked = true;
|
pHookedChar->m_KeepHooked = true;
|
||||||
pHookedChar->m_MarkedForDestroy = false;
|
pHookedChar->m_MarkedForDestroy = false;
|
||||||
}
|
}
|
||||||
// keep entities that are out of view for a short while, for some entity types
|
|
||||||
if(CCharacter *pLocal = GetCharacterByID(LocalID))
|
|
||||||
for(int i : {ENTTYPE_CHARACTER, ENTTYPE_PROJECTILE, ENTTYPE_LASER})
|
|
||||||
for(CEntity *pEnt = FindFirst(i); pEnt; pEnt = pEnt->TypeNext())
|
|
||||||
if(pEnt->m_MarkedForDestroy)
|
|
||||||
if(pEnt->m_SnapTicks < 2 * SERVER_TICK_SPEED || (i != ENTTYPE_CHARACTER && pEnt->m_SnapTicks < 5 * SERVER_TICK_SPEED))
|
|
||||||
if(pEnt->NetworkClipped(pLocal->m_Core.m_Pos))
|
|
||||||
pEnt->m_MarkedForDestroy = false;
|
|
||||||
RemoveEntities();
|
RemoveEntities();
|
||||||
|
|
||||||
// Update character IDs and pointers
|
// Update character IDs and pointers
|
||||||
|
|
Loading…
Reference in a new issue