Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #403: make colshapes cloneable #1214

Merged
merged 2 commits into from
Jan 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Server/mods/deathmatch/logic/CColCircle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ CColCircle::CColCircle(CColManager* pManager, CElement* pParent, const CVector2D
UpdateSpatialData();
}

CElement* CColCircle::Clone(bool* bAddEntity, CResource* pResource)
{
CColCircle* pColCircle = new CColCircle(m_pManager, GetParentEntity(), m_vecPosition, m_fRadius);
return pColCircle;
}

bool CColCircle::DoHitDetection(const CVector& vecNowPosition)
{
// Do a simple distance check between now position and our position
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CColCircle.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CColCircle : public CColShape
{
public:
CColCircle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, float fRadius, bool bIsPartnered = false);
CElement* Clone(bool* bAddEntity, CResource* pResource) override;

virtual CSphere GetWorldBoundingSphere();

Expand Down
6 changes: 6 additions & 0 deletions Server/mods/deathmatch/logic/CColCuboid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ CColCuboid::CColCuboid(CColManager* pManager, CElement* pParent, const CVector&
UpdateSpatialData();
}

CElement* CColCuboid::Clone(bool* bAddEntity, CResource* pResource)
{
CColCuboid* pColCuboid = new CColCuboid(m_pManager, GetParentEntity(), m_vecPosition, m_vecSize);
return pColCuboid;
}

bool CColCuboid::DoHitDetection(const CVector& vecNowPosition)
{
// FIXME: What about radius?
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CColCuboid.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CColCuboid : public CColShape
{
public:
CColCuboid(CColManager* pManager, CElement* pParent, const CVector& vecPosition, const CVector& vecSize);
CElement* Clone(bool* bAddEntity, CResource* pResource) override;

virtual CSphere GetWorldBoundingSphere();

Expand Down
9 changes: 9 additions & 0 deletions Server/mods/deathmatch/logic/CColPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ CColPolygon::CColPolygon(CColManager* pManager, CElement* pParent, const CVector
m_fRadius = 0.0f;
}

CElement* CColPolygon::Clone(bool* bAddEntity, CResource* pResource)
{
CColPolygon* pColPolygon = new CColPolygon(m_pManager, GetParentEntity(), m_vecPosition);
pColPolygon->m_Points = m_Points;
pColPolygon->m_fRadius = m_fRadius;
pColPolygon->SizeChanged();
return pColPolygon;
}

bool CColPolygon::DoHitDetection(const CVector& vecNowPosition)
{
if (!IsInBounds(vecNowPosition))
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CColPolygon.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class CColPolygon : public CColShape
{
public:
CColPolygon(CColManager* pManager, CElement* pParent, const CVector& vecPosition);
CElement* Clone(bool* bAddEntity, CResource* pResource) override;

virtual CSphere GetWorldBoundingSphere();

Expand Down
6 changes: 6 additions & 0 deletions Server/mods/deathmatch/logic/CColRectangle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ CColRectangle::CColRectangle(CColManager* pManager, CElement* pParent, const CVe
UpdateSpatialData();
}

CElement* CColRectangle::Clone(bool* bAddEntity, CResource* pResource)
{
CColRectangle* pColRectangle = new CColRectangle(m_pManager, GetParentEntity(), m_vecPosition, m_vecSize);
return pColRectangle;
}

bool CColRectangle::DoHitDetection(const CVector& vecNowPosition)
{
// FIXME: What about radius?
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CColRectangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class CColRectangle : public CColShape
{
public:
CColRectangle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, const CVector2D& vecSize);
CElement* Clone(bool* bAddEntity, CResource* pResource) override;

virtual CSphere GetWorldBoundingSphere();

Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CColShape.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,10 @@ class CColShape : public CElement

protected:
CVector m_vecPosition;
class CColManager* m_pManager;

private:
bool m_bIsEnabled;
class CColManager* m_pManager;
class CColCallback* m_pCallback;
bool m_bAutoCallEvent;

Expand Down
6 changes: 6 additions & 0 deletions Server/mods/deathmatch/logic/CColSphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ CColSphere::CColSphere(CColManager* pManager, CElement* pParent, const CVector&
UpdateSpatialData();
}

CElement* CColSphere::Clone(bool* bAddEntity, CResource* pResource)
{
CColSphere* pColSphere = new CColSphere(m_pManager, GetParentEntity(), m_vecPosition, m_fRadius, IsPartnered());
return pColSphere;
}

bool CColSphere::DoHitDetection(const CVector& vecNowPosition)
{
// Do a simple distance check between now position and our position
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CColSphere.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CColSphere : public CColShape
{
public:
CColSphere(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, bool bIsPartnered = false);
CElement* Clone(bool* bAddEntity, CResource* pResource) override;

virtual CSphere GetWorldBoundingSphere();

Expand Down
6 changes: 6 additions & 0 deletions Server/mods/deathmatch/logic/CColTube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ CColTube::CColTube(CColManager* pManager, CElement* pParent, const CVector& vecP
UpdateSpatialData();
}

CElement* CColTube::Clone(bool* bAddEntity, CResource* pResource)
{
CColTube* pColTube = new CColTube(m_pManager, GetParentEntity(), m_vecPosition, m_fRadius, m_fHeight);
return pColTube;
}

bool CColTube::DoHitDetection(const CVector& vecNowPosition)
{
// FIXME: What about radius in height?
Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CColTube.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CColTube : public CColShape
{
public:
CColTube(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, float fHeight);
CElement* Clone(bool* bAddEntity, CResource* pResource) override;

virtual CSphere GetWorldBoundingSphere();

Expand Down
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ bool CElement::IsCloneable()
case CElement::PICKUP:
case CElement::RADAR_AREA:
case CElement::PATH_NODE_UNUSED:
case CElement::COLSHAPE:
return true;
default:
return false;
Expand Down