Skip to content

Commit

Permalink
Remove XML from element class constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
botder committed Sep 29, 2018
1 parent c7f208e commit a63e65c
Show file tree
Hide file tree
Showing 49 changed files with 286 additions and 293 deletions.
16 changes: 8 additions & 8 deletions Server/mods/deathmatch/logic/CBlip.cpp
Expand Up @@ -11,7 +11,7 @@

#include "StdInc.h"

CBlip::CBlip(CElement* pParent, CXMLNode* pNode, CBlipManager* pBlipManager) : CPerPlayerEntity(pParent, pNode)
CBlip::CBlip(CElement* pParent, CBlipManager* pBlipManager) : CPerPlayerEntity(pParent)
{
// Init
m_iType = CElement::BLIP;
Expand Down Expand Up @@ -55,26 +55,26 @@ void CBlip::Unlink(void)
m_pBlipManager->m_List.remove(this);
}

bool CBlip::ReadSpecialData(void)
bool CBlip::ReadSpecialData(const int iLine)
{
// Grab the "posX" data
if (!GetCustomDataFloat("posX", m_vecPosition.fX, true))
{
CLogger::ErrorPrintf("Bad/missing 'posX' attribute in <blip> (line %u)\n", m_uiLine);
CLogger::ErrorPrintf("Bad/missing 'posX' attribute in <blip> (line %d)\n", iLine);
return false;
}

// Grab the "posY" data
if (!GetCustomDataFloat("posY", m_vecPosition.fY, true))
{
CLogger::ErrorPrintf("Bad/missing 'posY' attribute in <blip> (line %u)\n", m_uiLine);
CLogger::ErrorPrintf("Bad/missing 'posY' attribute in <blip> (line %d)\n", iLine);
return false;
}

// Grab the "posZ" data
if (!GetCustomDataFloat("posZ", m_vecPosition.fZ, true))
{
CLogger::ErrorPrintf("Bad/missing 'posZ' attribute in <blip> (line %u)\n", m_uiLine);
CLogger::ErrorPrintf("Bad/missing 'posZ' attribute in <blip> (line %d)\n", iLine);
return false;
}

Expand All @@ -88,7 +88,7 @@ bool CBlip::ReadSpecialData(void)
}
else
{
CLogger::ErrorPrintf("Bad 'icon' id specified in <blip> (line %u)\n", m_uiLine);
CLogger::ErrorPrintf("Bad 'icon' id specified in <blip> (line %d)\n", iLine);
return false;
}
}
Expand All @@ -104,7 +104,7 @@ bool CBlip::ReadSpecialData(void)
// Convert it to RGBA
if (!XMLColorToInt(szColor, m_Color.R, m_Color.G, m_Color.B, m_Color.A))
{
CLogger::ErrorPrintf("Bad 'color' value specified in <blip> (line %u)\n", m_uiLine);
CLogger::ErrorPrintf("Bad 'color' value specified in <blip> (line %d)\n", iLine);
return false;
}
}
Expand All @@ -125,7 +125,7 @@ bool CBlip::ReadSpecialData(void)
}
else
{
CLogger::ErrorPrintf("Bad 'ordering' id specified in <blip> (line %u)\n", m_uiLine);
CLogger::ErrorPrintf("Bad 'ordering' id specified in <blip> (line %d)\n", iLine);
return false;
}
}
Expand Down
6 changes: 4 additions & 2 deletions Server/mods/deathmatch/logic/CBlip.h
Expand Up @@ -18,12 +18,11 @@ class CBlip;
class CBlip : public CPerPlayerEntity
{
public:
CBlip(CElement* pParent, CXMLNode* pNode, class CBlipManager* pBlipManager);
CBlip(CElement* pParent, class CBlipManager* pBlipManager);
~CBlip(void);
CElement* Clone(bool* bAddEntity, CResource* pResource) override;

void Unlink(void);
bool ReadSpecialData(void);

const CVector& GetPosition(void);
void SetPosition(const CVector& vecPosition);
Expand All @@ -33,6 +32,9 @@ class CBlip : public CPerPlayerEntity

void AttachTo(CElement* pElement);

protected:
bool ReadSpecialData(const int iLine) override;

private:
class CBlipManager* m_pBlipManager;
CVector m_vecPosition;
Expand Down
6 changes: 3 additions & 3 deletions Server/mods/deathmatch/logic/CColCircle.cpp
Expand Up @@ -13,8 +13,8 @@

using namespace std;

CColCircle::CColCircle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, float fRadius, CXMLNode* pNode, bool bIsPartnered)
: CColShape(pManager, pParent, pNode, bIsPartnered)
CColCircle::CColCircle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, float fRadius, bool bIsPartnered)
: CColShape(pManager, pParent, bIsPartnered)
{
m_vecPosition.fX = vecPosition.fX;
m_vecPosition.fY = vecPosition.fY;
Expand All @@ -29,7 +29,7 @@ bool CColCircle::DoHitDetection(const CVector& vecNowPosition)
return IsPointNearPoint2D(vecNowPosition, m_vecPosition, m_fRadius);
}

bool CColCircle::ReadSpecialData(void)
bool CColCircle::ReadSpecialData(const int iLine)
{
int iTemp;
if (GetCustomDataInt("dimension", iTemp, true))
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CColCircle.h
Expand Up @@ -16,7 +16,7 @@
class CColCircle : public CColShape
{
public:
CColCircle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, float fRadius, CXMLNode* pNode = NULL, bool bIsPartnered = false);
CColCircle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, float fRadius, bool bIsPartnered = false);

virtual CSphere GetWorldBoundingSphere(void);

Expand All @@ -32,7 +32,7 @@ class CColCircle : public CColShape
};

protected:
bool ReadSpecialData(void);
bool ReadSpecialData(const int iLine) override;

float m_fRadius;
};
6 changes: 3 additions & 3 deletions Server/mods/deathmatch/logic/CColCuboid.cpp
Expand Up @@ -11,8 +11,8 @@

#include "StdInc.h"

CColCuboid::CColCuboid(CColManager* pManager, CElement* pParent, const CVector& vecPosition, const CVector& vecSize, CXMLNode* pNode)
: CColShape(pManager, pParent, pNode)
CColCuboid::CColCuboid(CColManager* pManager, CElement* pParent, const CVector& vecPosition, const CVector& vecSize)
: CColShape(pManager, pParent)
{
m_vecPosition = vecPosition;
m_vecSize = vecSize;
Expand All @@ -30,7 +30,7 @@ bool CColCuboid::DoHitDetection(const CVector& vecNowPosition)
vecNowPosition.fZ <= m_vecPosition.fZ + m_vecSize.fZ);
}

bool CColCuboid::ReadSpecialData(void)
bool CColCuboid::ReadSpecialData(const int iLine)
{
int iTemp;
if (GetCustomDataInt("dimension", iTemp, true))
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CColCuboid.h
Expand Up @@ -16,7 +16,7 @@
class CColCuboid : public CColShape
{
public:
CColCuboid(CColManager* pManager, CElement* pParent, const CVector& vecPosition, const CVector& vecSize, CXMLNode* pNode = NULL);
CColCuboid(CColManager* pManager, CElement* pParent, const CVector& vecPosition, const CVector& vecSize);

virtual CSphere GetWorldBoundingSphere(void);

Expand All @@ -32,7 +32,7 @@ class CColCuboid : public CColShape
};

protected:
bool ReadSpecialData(void);
bool ReadSpecialData(const int iLine) override;

CVector m_vecSize;
};
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CColPolygon.cpp
Expand Up @@ -11,7 +11,7 @@

#include "StdInc.h"

CColPolygon::CColPolygon(CColManager* pManager, CElement* pParent, const CVector& vecPosition, CXMLNode* pNode) : CColShape(pManager, pParent, pNode)
CColPolygon::CColPolygon(CColManager* pManager, CElement* pParent, const CVector& vecPosition) : CColShape(pManager, pParent)
{
m_vecPosition = vecPosition;

Expand Down Expand Up @@ -51,7 +51,7 @@ bool CColPolygon::DoHitDetection(const CVector& vecNowPosition)
return collides;
}

bool CColPolygon::ReadSpecialData(void)
bool CColPolygon::ReadSpecialData(const int iLine)
{
int iTemp;
if (GetCustomDataInt("dimension", iTemp, true))
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CColPolygon.h
Expand Up @@ -18,7 +18,7 @@
class CColPolygon : public CColShape
{
public:
CColPolygon(CColManager* pManager, CElement* pParent, const CVector& vecPosition, CXMLNode* pNode = NULL);
CColPolygon(CColManager* pManager, CElement* pParent, const CVector& vecPosition);

virtual CSphere GetWorldBoundingSphere(void);

Expand All @@ -37,7 +37,7 @@ class CColPolygon : public CColShape
protected:
std::vector<CVector2D> m_Points;

bool ReadSpecialData(void);
bool ReadSpecialData(const int iLine) override;

bool IsInBounds(CVector vecPoint);

Expand Down
6 changes: 3 additions & 3 deletions Server/mods/deathmatch/logic/CColRectangle.cpp
Expand Up @@ -11,8 +11,8 @@

#include "StdInc.h"

CColRectangle::CColRectangle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, const CVector2D& vecSize, CXMLNode* pNode)
: CColShape(pManager, pParent, pNode)
CColRectangle::CColRectangle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, const CVector2D& vecSize)
: CColShape(pManager, pParent)
{
m_vecPosition.fX = vecPosition.fX;
m_vecPosition.fY = vecPosition.fY;
Expand All @@ -31,7 +31,7 @@ bool CColRectangle::DoHitDetection(const CVector& vecNowPosition)
vecNowPosition.fY <= m_vecPosition.fY + m_vecSize.fY);
}

bool CColRectangle::ReadSpecialData(void)
bool CColRectangle::ReadSpecialData(const int iLine)
{
int iTemp;
if (GetCustomDataInt("dimension", iTemp, true))
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CColRectangle.h
Expand Up @@ -17,7 +17,7 @@
class CColRectangle : public CColShape
{
public:
CColRectangle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, const CVector2D& vecSize, CXMLNode* pNode = NULL);
CColRectangle(CColManager* pManager, CElement* pParent, const CVector2D& vecPosition, const CVector2D& vecSize);

virtual CSphere GetWorldBoundingSphere(void);

Expand All @@ -33,7 +33,7 @@ class CColRectangle : public CColShape
};

protected:
bool ReadSpecialData(void);
bool ReadSpecialData(const int iLine) override;

CVector2D m_vecSize;
};
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CColShape.cpp
Expand Up @@ -11,7 +11,7 @@

#include "StdInc.h"

CColShape::CColShape(CColManager* pManager, CElement* pParent, CXMLNode* pNode, bool bIsPartnered) : CElement(pParent, pNode)
CColShape::CColShape(CColManager* pManager, CElement* pParent, bool bIsPartnered) : CElement(pParent)
{
// Init
m_bIsEnabled = true;
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CColShape.h
Expand Up @@ -26,7 +26,7 @@ enum eColShapeType
class CColShape : public CElement
{
public:
CColShape(class CColManager* pManager, CElement* pParent, CXMLNode* pNode = NULL, bool bIsPartnered = false);
CColShape(class CColManager* pManager, CElement* pParent, bool bIsPartnered = false);
virtual ~CColShape(void);

virtual eColShapeType GetShapeType(void) = 0;
Expand Down
8 changes: 4 additions & 4 deletions Server/mods/deathmatch/logic/CColSphere.cpp
Expand Up @@ -13,8 +13,8 @@

using namespace std;

CColSphere::CColSphere(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, CXMLNode* pNode, bool bIsPartnered)
: CColShape(pManager, pParent, pNode, bIsPartnered)
CColSphere::CColSphere(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, bool bIsPartnered)
: CColShape(pManager, pParent, bIsPartnered)
{
m_vecPosition = vecPosition;
m_fRadius = fRadius;
Expand All @@ -27,7 +27,7 @@ bool CColSphere::DoHitDetection(const CVector& vecNowPosition)
return IsPointNearPoint3D(vecNowPosition, m_vecPosition, m_fRadius);
}

bool CColSphere::ReadSpecialData(void)
bool CColSphere::ReadSpecialData(const int iLine)
{
int iTemp;
if (GetCustomDataInt("dimension", iTemp, true))
Expand All @@ -41,4 +41,4 @@ bool CColSphere::ReadSpecialData(void)
CSphere CColSphere::GetWorldBoundingSphere(void)
{
return CSphere(m_vecPosition, m_fRadius);
}
}
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CColSphere.h
Expand Up @@ -16,7 +16,7 @@
class CColSphere : public CColShape
{
public:
CColSphere(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, CXMLNode* pNode = NULL, bool bIsPartnered = false);
CColSphere(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, bool bIsPartnered = false);

virtual CSphere GetWorldBoundingSphere(void);

Expand All @@ -32,7 +32,7 @@ class CColSphere : public CColShape
};

protected:
bool ReadSpecialData(void);
bool ReadSpecialData(const int iLine) override;

float m_fRadius;
};
6 changes: 3 additions & 3 deletions Server/mods/deathmatch/logic/CColTube.cpp
Expand Up @@ -11,8 +11,8 @@

#include "StdInc.h"

CColTube::CColTube(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, float fHeight, CXMLNode* pNode)
: CColShape(pManager, pParent, pNode)
CColTube::CColTube(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, float fHeight)
: CColShape(pManager, pParent)
{
m_vecPosition = vecPosition;
m_fRadius = fRadius;
Expand All @@ -29,7 +29,7 @@ bool CColTube::DoHitDetection(const CVector& vecNowPosition)
vecNowPosition.fZ <= m_vecPosition.fZ + m_fHeight);
}

bool CColTube::ReadSpecialData(void)
bool CColTube::ReadSpecialData(const int iLine)
{
int iTemp;
if (GetCustomDataInt("dimension", iTemp, true))
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CColTube.h
Expand Up @@ -16,7 +16,7 @@
class CColTube : public CColShape
{
public:
CColTube(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, float fHeight, CXMLNode* pNode = NULL);
CColTube(CColManager* pManager, CElement* pParent, const CVector& vecPosition, float fRadius, float fHeight);

virtual CSphere GetWorldBoundingSphere(void);

Expand All @@ -37,7 +37,7 @@ class CColTube : public CColShape
};

protected:
bool ReadSpecialData(void);
bool ReadSpecialData(const int iLine) override;

float m_fRadius;
float m_fHeight;
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CConsoleClient.cpp
Expand Up @@ -11,7 +11,7 @@

#include "StdInc.h"

CConsoleClient::CConsoleClient(CConsole* pConsole) : CElement(pConsole->GetMapManager()->GetRootElement(), NULL), CClient(false)
CConsoleClient::CConsoleClient(CConsole* pConsole) : CElement(pConsole->GetMapManager()->GetRootElement()), CClient(false)
{
m_pAccount = g_pGame->GetAccountManager()->AddConsoleAccount(CONSOLE_ACCOUNT_NAME);
m_iType = CElement::CONSOLE;
Expand Down
4 changes: 3 additions & 1 deletion Server/mods/deathmatch/logic/CConsoleClient.h
Expand Up @@ -29,7 +29,9 @@ class CConsoleClient : public CElement, public CClient
void SendConsole(const char* szEcho) { CLogger::LogPrintf("%s\n", szEcho); };

void Unlink(void){};
bool ReadSpecialData(void) { return false; };

protected:
bool ReadSpecialData(const int iLine) override { return false; }

protected:
SString m_strNick;
Expand Down
4 changes: 2 additions & 2 deletions Server/mods/deathmatch/logic/CCustomWeapon.cpp
Expand Up @@ -10,8 +10,8 @@

#include "StdInc.h"

CCustomWeapon::CCustomWeapon(CElement* pParent, CXMLNode* pNode, CObjectManager* pObjectManager, CCustomWeaponManager* pWeaponManager, eWeaponType weaponType)
: CObject(pParent, pNode, pObjectManager, false)
CCustomWeapon::CCustomWeapon(CElement* pParent, CObjectManager* pObjectManager, CCustomWeaponManager* pWeaponManager, eWeaponType weaponType)
: CObject(pParent, pObjectManager, false)
{
// Init
m_iType = CElement::WEAPON;
Expand Down
2 changes: 1 addition & 1 deletion Server/mods/deathmatch/logic/CCustomWeapon.h
Expand Up @@ -57,7 +57,7 @@ struct SWeaponConfiguration
class CCustomWeapon : public CObject
{
public:
CCustomWeapon(CElement* pParent, CXMLNode* pNode, CObjectManager* pObjectManager, CCustomWeaponManager* pWeaponManager, eWeaponType weaponType);
CCustomWeapon(CElement* pParent, CObjectManager* pObjectManager, CCustomWeaponManager* pWeaponManager, eWeaponType weaponType);
~CCustomWeapon(void);

void SetWeaponTarget(CElement* pTarget, int subTarget);
Expand Down
4 changes: 3 additions & 1 deletion Server/mods/deathmatch/logic/CDatabaseManager.h
Expand Up @@ -190,11 +190,13 @@ class CDatabaseConnectionElement : public CElement

// CElement
virtual void Unlink(void) { g_pGame->GetDatabaseManager()->Disconnect(m_Connection); }
virtual bool ReadSpecialData(void) { return false; }

// CDatabaseConnectionElement
SConnectionHandle GetConnectionHandle(void) { return m_Connection; }

protected:
bool ReadSpecialData(const int iLine) override { return false; }

protected:
SConnectionHandle m_Connection;
};

0 comments on commit a63e65c

Please sign in to comment.