mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 01:58:19 +00:00
Merge #5245
5245: disable dragger beams soon, not only every 150ms r=def- a=C0D3D3V The check whether a dragger is active, I somehow forgot in the dragger beams. Sorry! Actually, I should have noticed this during testing. But when I tested Fall into the Future today, it seemed strange to me (already at the first part). I should have noticed it when I tested it. I have compared that in any case with 15.9.1 and looked at the code again and saw that there the check is made every tick. ## Checklist - [x] Tested the change ingame - [ ] Provided screenshots if it is a visual change - [ ] Tested in combination with possibly related configuration options - [ ] Written a unit test if it works standalone, system.c especially - [x] Considered possible null pointers and out of bounds array indexing - [x] Changed no physics that affect existing maps - [x] Tested the change with [ASan+UBSan or valgrind's memcheck](https://github.com/ddnet/ddnet/#using-addresssanitizer--undefinedbehavioursanitizer-or-valgrinds-memcheck) (optional) Co-authored-by: c0d3d3v <c0d3d3v@mag-keinen-spam.de>
This commit is contained in:
commit
74b94b3e71
|
@ -141,7 +141,7 @@ void CDragger::LookForPlayersToDrag()
|
|||
// Create Dragger Beams which have not been created yet
|
||||
if(IsTarget[i] && m_apDraggerBeam[i] == nullptr)
|
||||
{
|
||||
m_apDraggerBeam[i] = new CDraggerBeam(&GameServer()->m_World, this, m_Pos, m_Strength, m_IgnoreWalls, i);
|
||||
m_apDraggerBeam[i] = new CDraggerBeam(&GameServer()->m_World, this, m_Pos, m_Strength, m_IgnoreWalls, i, m_Layer, m_Number);
|
||||
}
|
||||
// Remove dragger beams that have not yet been deleted
|
||||
else if(!IsTarget[i] && m_apDraggerBeam[i] != nullptr)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#include <game/server/teams.h>
|
||||
|
||||
CDraggerBeam::CDraggerBeam(CGameWorld *pGameWorld, CDragger *pDragger, vec2 Pos, float Strength, bool IgnoreWalls,
|
||||
int ForClientID) :
|
||||
int ForClientID, int Layer, int Number) :
|
||||
CEntity(pGameWorld, CGameWorld::ENTTYPE_LASER)
|
||||
{
|
||||
m_pDragger = pDragger;
|
||||
|
@ -20,6 +20,8 @@ CDraggerBeam::CDraggerBeam(CGameWorld *pGameWorld, CDragger *pDragger, vec2 Pos,
|
|||
m_IgnoreWalls = IgnoreWalls;
|
||||
m_ForClientID = ForClientID;
|
||||
m_Active = true;
|
||||
m_Layer = Layer;
|
||||
m_Number = Number;
|
||||
m_EvalTick = Server()->Tick();
|
||||
|
||||
GameWorld()->InsertEntity(this);
|
||||
|
@ -40,11 +42,20 @@ void CDraggerBeam::Tick()
|
|||
return;
|
||||
}
|
||||
|
||||
// The following checks are necessary, because the checks in CDragger::LookForPlayersToDrag only take place every 150ms
|
||||
// When the dragger is disabled for the target player's team, the dragger beam dissolves
|
||||
if(m_Layer == LAYER_SWITCH && m_Number > 0 &&
|
||||
!GameServer()->Collision()->m_pSwitchers[m_Number].m_Status[pTarget->Team()])
|
||||
{
|
||||
Reset();
|
||||
return;
|
||||
}
|
||||
|
||||
// When the dragger can no longer reach the target player, the dragger beam dissolves
|
||||
int IsReachable =
|
||||
m_IgnoreWalls ?
|
||||
!GameServer()->Collision()->IntersectNoLaserNW(m_Pos, pTarget->m_Pos, 0, 0) :
|
||||
!GameServer()->Collision()->IntersectNoLaser(m_Pos, pTarget->m_Pos, 0, 0);
|
||||
// This check is necessary because the check in CDragger::LookForPlayersToDrag only happens every 150ms
|
||||
if(!IsReachable ||
|
||||
distance(pTarget->m_Pos, m_Pos) >= g_Config.m_SvDraggerRange || !pTarget->IsAlive())
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ class CDraggerBeam : public CEntity
|
|||
bool m_Active;
|
||||
|
||||
public:
|
||||
CDraggerBeam(CGameWorld *pGameWorld, CDragger *pDragger, vec2 Pos, float Strength, bool IgnoreWalls, int ForClientID);
|
||||
CDraggerBeam(CGameWorld *pGameWorld, CDragger *pDragger, vec2 Pos, float Strength, bool IgnoreWalls, int ForClientID, int Layer, int Number);
|
||||
|
||||
void SetPos(vec2 Pos);
|
||||
|
||||
|
|
Loading…
Reference in a new issue