Skip to content

Commit 90f4296

Browse files
saml1ercodenulls
andauthored
Potential fix for #1683 (#1693)
* Fix #1683: build r20653 crashing randomly without dump * safely delete marker's colshape in CClientMarker * Remove attaching code in CMarker This was added by Lopsided. It shouldn't be here. Co-authored-by: saml1er <[email protected]>
1 parent d99e553 commit 90f4296

File tree

4 files changed

+21
-32
lines changed

4 files changed

+21
-32
lines changed

Client/mods/deathmatch/logic/CClientMarker.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,15 @@ CClientMarker::CClientMarker(CClientManager* pManager, ElementID ID, int iMarker
3939

4040
CClientMarker::~CClientMarker()
4141
{
42+
AttachTo(nullptr);
43+
4244
// Unlink
4345
Unlink();
4446

4547
// Make sure nothing is still referencing us
4648
m_pManager->UnreferenceEntity(this);
4749

48-
// Remove the colshape
49-
if (m_pCollision)
50-
delete m_pCollision;
50+
SAFE_DELETE(m_pCollision)
5151

5252
// Stream out first so the element counter is correct
5353
StreamOut();
@@ -74,26 +74,33 @@ void CClientMarker::GetPosition(CVector& vecPosition) const
7474
}
7575
else
7676
{
77-
vecPosition = CVector();
77+
vecPosition = m_vecPosition;
7878
}
7979
}
8080

8181
void CClientMarker::SetPosition(const CVector& vecPosition)
8282
{
83-
if (m_pMarker)
84-
m_pMarker->SetPosition(vecPosition);
85-
if (m_pCollision)
86-
m_pCollision->SetPosition(vecPosition);
87-
88-
// Update our streaming position
89-
UpdateStreamPosition(vecPosition);
83+
if (m_vecPosition != vecPosition)
84+
{
85+
m_vecPosition = vecPosition;
86+
if (m_pMarker)
87+
m_pMarker->SetPosition(vecPosition);
88+
if (m_pCollision)
89+
m_pCollision->SetPosition(vecPosition);
90+
91+
// Update our streaming position
92+
UpdateStreamPosition(vecPosition);
93+
}
9094
}
9195

9296
void CClientMarker::AttachTo(CClientEntity* pEntity)
9397
{
9498
CClientEntity::AttachTo(pEntity);
95-
if (m_pCollision)
96-
m_pCollision->AttachTo(this);
99+
if (m_pAttachedToEntity)
100+
{
101+
DoAttaching();
102+
UpdateStreamPosition(m_vecPosition);
103+
}
97104
}
98105

99106
void CClientMarker::SetAttachedOffsets(CVector& vecPosition, CVector& vecRotation)

Client/mods/deathmatch/logic/CClientMarker.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ class CClientMarker : public CClientStreamElement, private CClientColCallback
9494
CClientMarkerManager* m_pMarkerManager;
9595
CClientMarkerCommon* m_pMarker;
9696

97+
CVector m_vecPosition;
9798
static unsigned int m_uiStreamedInMarkers;
9899

99100
CClientColShape* m_pCollision;

Server/mods/deathmatch/logic/CMarker.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -171,22 +171,6 @@ void CMarker::SetPosition(const CVector& vecPosition)
171171
}
172172
}
173173

174-
void CMarker::AttachTo(CElement* pElement)
175-
{
176-
CElement::AttachTo(pElement);
177-
if (m_pCollision)
178-
m_pCollision->AttachTo(this);
179-
}
180-
181-
void CMarker::SetAttachedOffsets(CVector& vecPosition, CVector& vecRotation)
182-
{
183-
CElement::SetAttachedOffsets(vecPosition, vecRotation);
184-
if (m_pCollision)
185-
{
186-
m_pCollision->SetAttachedOffsets(vecPosition, vecRotation);
187-
}
188-
}
189-
190174
void CMarker::SetTarget(const CVector* pTargetVector)
191175
{
192176
// Got a target vector?

Server/mods/deathmatch/logic/CMarker.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ class CMarker : public CPerPlayerEntity, private CColCallback
6161
void SetSize(float fSize);
6262
void SetColor(const SColor color);
6363

64-
void AttachTo(CElement* pElement);
65-
void SetAttachedOffsets(CVector& vecPosition, CVector& vecRotation);
66-
6764
void SetIcon(unsigned char ucIcon);
6865

6966
CColShape* GetColShape() { return m_pCollision; }

0 commit comments

Comments
 (0)