From 739e80614db70f726c47180173ba19688bec5167 Mon Sep 17 00:00:00 2001
From: aap <aap@papnet.eu>
Date: Sat, 28 Mar 2020 09:37:04 +0100
Subject: [PATCH] remove include <new> from common.h

---
 src/animation/AnimBlendAssociation.cpp | 15 ++++++++++++---
 src/animation/AnimBlendAssociation.h   |  4 ----
 src/animation/AnimBlendClumpData.cpp   | 14 ++++++++++++--
 src/animation/AnimBlendClumpData.h     |  4 ----
 src/core/Collision.cpp                 | 19 ++++++++++++++++---
 src/core/Collision.h                   |  4 ----
 src/core/Placeable.cpp                 |  2 ++
 src/core/common.h                      |  2 --
 src/entities/Building.cpp              |  2 ++
 src/entities/Entity.cpp                |  2 ++
 src/objects/DummyObject.cpp            |  2 ++
 src/objects/Object.cpp                 |  2 ++
 src/objects/Projectile.cpp             |  2 ++
 src/peds/CivilianPed.cpp               |  2 ++
 src/peds/CopPed.cpp                    |  2 ++
 src/peds/EmergencyPed.cpp              |  2 ++
 src/peds/Ped.cpp                       |  2 ++
 src/peds/PlayerPed.cpp                 |  2 ++
 src/vehicles/Automobile.cpp            |  2 ++
 src/vehicles/Boat.cpp                  |  2 ++
 src/vehicles/Heli.cpp                  |  1 +
 src/vehicles/Plane.cpp                 |  1 +
 src/vehicles/Train.cpp                 |  2 ++
 23 files changed, 70 insertions(+), 22 deletions(-)

diff --git a/src/animation/AnimBlendAssociation.cpp b/src/animation/AnimBlendAssociation.cpp
index ec42191b..246322ba 100644
--- a/src/animation/AnimBlendAssociation.cpp
+++ b/src/animation/AnimBlendAssociation.cpp
@@ -203,6 +203,15 @@ CAnimBlendAssociation::UpdateBlend(float timeDelta)
 	return true;
 }
 
+#include <new>
+
+class CAnimBlendAssociation_ : public CAnimBlendAssociation
+{
+public:
+	CAnimBlendAssociation *ctor1(void) { return ::new (this) CAnimBlendAssociation(); }
+	CAnimBlendAssociation *ctor2(CAnimBlendAssociation &other) { return ::new (this) CAnimBlendAssociation(other); }
+	void dtor(void) { this->CAnimBlendAssociation::~CAnimBlendAssociation(); }
+};
 
 STARTPATCHES
 	InjectHook(0x4016A0, &CAnimBlendAssociation::AllocateAnimBlendNodeArray, PATCH_JUMP);
@@ -219,7 +228,7 @@ STARTPATCHES
 	InjectHook(0x4031F0, &CAnimBlendAssociation::UpdateTime, PATCH_JUMP);
 	InjectHook(0x4032B0, &CAnimBlendAssociation::UpdateBlend, PATCH_JUMP);
 
-	InjectHook(0x401460, &CAnimBlendAssociation::ctor1, PATCH_JUMP);
-	InjectHook(0x4014C0, &CAnimBlendAssociation::ctor2, PATCH_JUMP);
-	InjectHook(0x401520, &CAnimBlendAssociation::dtor, PATCH_JUMP);
+	InjectHook(0x401460, &CAnimBlendAssociation_::ctor1, PATCH_JUMP);
+	InjectHook(0x4014C0, &CAnimBlendAssociation_::ctor2, PATCH_JUMP);
+	InjectHook(0x401520, &CAnimBlendAssociation_::dtor, PATCH_JUMP);
 ENDPATCHES
diff --git a/src/animation/AnimBlendAssociation.h b/src/animation/AnimBlendAssociation.h
index aec28f56..d35db1db 100644
--- a/src/animation/AnimBlendAssociation.h
+++ b/src/animation/AnimBlendAssociation.h
@@ -85,9 +85,5 @@ public:
 	static CAnimBlendAssociation *FromLink(CAnimBlendLink *l) {
 		return (CAnimBlendAssociation*)((uint8*)l - offsetof(CAnimBlendAssociation, link));
 	}
-
-	CAnimBlendAssociation *ctor1(void) { return ::new (this) CAnimBlendAssociation(); }
-	CAnimBlendAssociation *ctor2(CAnimBlendAssociation &other) { return ::new (this) CAnimBlendAssociation(other); }
-	void dtor(void) { this->CAnimBlendAssociation::~CAnimBlendAssociation(); }
 };
 static_assert(sizeof(CAnimBlendAssociation) == 0x40, "CAnimBlendAssociation: error");
diff --git a/src/animation/AnimBlendClumpData.cpp b/src/animation/AnimBlendClumpData.cpp
index 06625eb5..cc4281d6 100644
--- a/src/animation/AnimBlendClumpData.cpp
+++ b/src/animation/AnimBlendClumpData.cpp
@@ -36,9 +36,19 @@ CAnimBlendClumpData::ForAllFrames(void (*cb)(AnimBlendFrameData*, void*), void *
 		cb(&frames[i], arg);
 }
 
+#include <new>
+
+class CAnimBlendClumpData_ : public CAnimBlendClumpData
+{
+public:
+	CAnimBlendClumpData *ctor(void) { return ::new (this) CAnimBlendClumpData(); }
+	void dtor(void) { this->CAnimBlendClumpData::~CAnimBlendClumpData(); }
+};
+
+
 STARTPATCHES
-	InjectHook(0x401880, &CAnimBlendClumpData::ctor, PATCH_JUMP);
-	InjectHook(0x4018B0, &CAnimBlendClumpData::dtor, PATCH_JUMP);
+	InjectHook(0x401880, &CAnimBlendClumpData_::ctor, PATCH_JUMP);
+	InjectHook(0x4018B0, &CAnimBlendClumpData_::dtor, PATCH_JUMP);
 	InjectHook(0x4018F0, &CAnimBlendClumpData::SetNumberOfFrames, PATCH_JUMP);
 	InjectHook(0x401930, &CAnimBlendClumpData::ForAllFrames, PATCH_JUMP);
 ENDPATCHES
diff --git a/src/animation/AnimBlendClumpData.h b/src/animation/AnimBlendClumpData.h
index df2fbc56..1c8c391d 100644
--- a/src/animation/AnimBlendClumpData.h
+++ b/src/animation/AnimBlendClumpData.h
@@ -49,9 +49,5 @@ public:
 	void SetNumberOfBones(int n) { SetNumberOfFrames(n); }
 #endif
 	void ForAllFrames(void (*cb)(AnimBlendFrameData*, void*), void *arg);
-
-
-	CAnimBlendClumpData *ctor(void) { return ::new (this) CAnimBlendClumpData(); }
-	void dtor(void) { this->CAnimBlendClumpData::~CAnimBlendClumpData(); }
 };
 static_assert(sizeof(CAnimBlendClumpData) == 0x14, "CAnimBlendClumpData: error");
diff --git a/src/core/Collision.cpp b/src/core/Collision.cpp
index fc8428be..94ef769e 100644
--- a/src/core/Collision.cpp
+++ b/src/core/Collision.cpp
@@ -2061,6 +2061,19 @@ CColModel::operator=(const CColModel &other)
 	return *this;
 }
 
+#include <new>
+struct CColLine_ : public CColLine
+{
+	CColLine *ctor(CVector *p0, CVector *p1) { return ::new (this) CColLine(*p0, *p1); }
+};
+
+struct CColModel_ : public CColModel
+{
+	CColModel *ctor(void) { return ::new (this) CColModel(); }
+	void dtor(void) { this->CColModel::~CColModel(); }
+};
+
+
 STARTPATCHES
 	InjectHook(0x4B9C30, (CMatrix& (*)(const CMatrix &src, CMatrix &dst))Invert, PATCH_JUMP);
 
@@ -2099,15 +2112,15 @@ STARTPATCHES
 
 	InjectHook(0x411E40, (void (CColSphere::*)(float, const CVector&, uint8, uint8))&CColSphere::Set, PATCH_JUMP);
 	InjectHook(0x40B2A0, &CColBox::Set, PATCH_JUMP);
-	InjectHook(0x40B320, &CColLine::ctor, PATCH_JUMP);
+	InjectHook(0x40B320, &CColLine_::ctor, PATCH_JUMP);
 	InjectHook(0x40B350, &CColLine::Set, PATCH_JUMP);
 	InjectHook(0x411E70, &CColTriangle::Set, PATCH_JUMP);
 
 	InjectHook(0x411EA0, &CColTrianglePlane::Set, PATCH_JUMP);
 	InjectHook(0x412140, &CColTrianglePlane::GetNormal, PATCH_JUMP);
 
-	InjectHook(0x411680, &CColModel::ctor, PATCH_JUMP);
-	InjectHook(0x4116E0, &CColModel::dtor, PATCH_JUMP);
+	InjectHook(0x411680, &CColModel_::ctor, PATCH_JUMP);
+	InjectHook(0x4116E0, &CColModel_::dtor, PATCH_JUMP);
 	InjectHook(0x411D80, &CColModel::RemoveCollisionVolumes, PATCH_JUMP);
 	InjectHook(0x411CB0, &CColModel::CalculateTrianglePlanes, PATCH_JUMP);
 	InjectHook(0x411D10, &CColModel::RemoveTrianglePlanes, PATCH_JUMP);
diff --git a/src/core/Collision.h b/src/core/Collision.h
index 9597a181..429fc17f 100644
--- a/src/core/Collision.h
+++ b/src/core/Collision.h
@@ -35,8 +35,6 @@ struct CColLine
 	CColLine(void) { };
 	CColLine(const CVector &p0, const CVector &p1) { this->p0 = p0; this->p1 = p1; };
 	void Set(const CVector &p0, const CVector &p1);
-
-	CColLine *ctor(CVector *p0, CVector *p1) { return ::new (this) CColLine(*p0, *p1); }
 };
 
 struct CColTriangle
@@ -106,8 +104,6 @@ struct CColModel
 	void SetLinkPtr(CLink<CColModel*>*);
 	void GetTrianglePoint(CVector &v, int i) const;
 
-	CColModel *ctor(void) { return ::new (this) CColModel(); }
-	void dtor(void) { this->CColModel::~CColModel(); }
 	CColModel& operator=(const CColModel& other);
 };
 
diff --git a/src/core/Placeable.cpp b/src/core/Placeable.cpp
index d2cec82b..c882fc27 100644
--- a/src/core/Placeable.cpp
+++ b/src/core/Placeable.cpp
@@ -63,6 +63,8 @@ CPlaceable::IsWithinArea(float x1, float y1, float z1, float x2, float y2, float
 	       z1 <= GetPosition().z && GetPosition().z <= z2;
 }
 
+#include <new>
+
 class CPlaceable_ : public CPlaceable
 {
 public:
diff --git a/src/core/common.h b/src/core/common.h
index 0cdff871..7b4ff4a0 100644
--- a/src/core/common.h
+++ b/src/core/common.h
@@ -10,8 +10,6 @@
 #include <stdint.h>
 #include <string.h>
 #include <math.h>
-//#include <assert.h>
-#include <new>
 
 #ifdef WITHWINDOWS
 #include <Windows.h>
diff --git a/src/entities/Building.cpp b/src/entities/Building.cpp
index 188cbfe7..7813c87f 100644
--- a/src/entities/Building.cpp
+++ b/src/entities/Building.cpp
@@ -21,6 +21,8 @@ CBuilding::ReplaceWithNewModel(int32 id)
 			CStreaming::RequestModel(id, STREAMFLAGS_DONT_REMOVE);
 }
 
+#include <new>
+
 class CBuilding_ : public CBuilding
 {
 public:
diff --git a/src/entities/Entity.cpp b/src/entities/Entity.cpp
index 04a93420..8bec1ac8 100644
--- a/src/entities/Entity.cpp
+++ b/src/entities/Entity.cpp
@@ -865,6 +865,8 @@ CEntity::ModifyMatrixForBannerInWind(void)
 	UpdateRwFrame();
 }
 
+#include <new>
+
 class CEntity_ : public CEntity
 {
 public:
diff --git a/src/objects/DummyObject.cpp b/src/objects/DummyObject.cpp
index 9649cf7a..ba09ac3e 100644
--- a/src/objects/DummyObject.cpp
+++ b/src/objects/DummyObject.cpp
@@ -12,6 +12,8 @@ CDummyObject::CDummyObject(CObject *obj)
 	m_level = obj->m_level;
 }
 
+#include <new>
+
 class CDummyObject_ : public CDummyObject
 {
 public:
diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp
index 357d67d7..809ba971 100644
--- a/src/objects/Object.cpp
+++ b/src/objects/Object.cpp
@@ -141,6 +141,8 @@ CObject::CanBeDeleted(void)
 	}
 }
 
+#include <new>
+
 class CObject_ : public CObject
 {
 public:
diff --git a/src/objects/Projectile.cpp b/src/objects/Projectile.cpp
index 0f6542e7..32bc6bdb 100644
--- a/src/objects/Projectile.cpp
+++ b/src/objects/Projectile.cpp
@@ -14,6 +14,8 @@ CProjectile::CProjectile(int32 model) : CObject()
 	ObjectCreatedBy = MISSION_OBJECT;
 }
 
+#include <new>
+
 class CProjectile_ : public CProjectile
 {
 public:
diff --git a/src/peds/CivilianPed.cpp b/src/peds/CivilianPed.cpp
index bb61e086..2e6166be 100644
--- a/src/peds/CivilianPed.cpp
+++ b/src/peds/CivilianPed.cpp
@@ -377,6 +377,8 @@ CCivilianPed::ProcessControl(void)
 		Avoid();
 }
 
+#include <new>
+
 class CCivilianPed_ : public CCivilianPed
 {
 public:
diff --git a/src/peds/CopPed.cpp b/src/peds/CopPed.cpp
index dae866a4..94acac05 100644
--- a/src/peds/CopPed.cpp
+++ b/src/peds/CopPed.cpp
@@ -551,6 +551,8 @@ CCopPed::CopAI(void)
 	}
 }
 
+#include <new>
+
 class CCopPed_ : public CCopPed
 {
 public:
diff --git a/src/peds/EmergencyPed.cpp b/src/peds/EmergencyPed.cpp
index ee559f57..0d27a532 100644
--- a/src/peds/EmergencyPed.cpp
+++ b/src/peds/EmergencyPed.cpp
@@ -413,6 +413,8 @@ CEmergencyPed::MedicAI(void)
 	}
 }
 
+#include <new>
+
 class CEmergencyPed_ : public CEmergencyPed
 {
 public:
diff --git a/src/peds/Ped.cpp b/src/peds/Ped.cpp
index c8e8c4e4..05cac3a7 100644
--- a/src/peds/Ped.cpp
+++ b/src/peds/Ped.cpp
@@ -17455,6 +17455,8 @@ CPed::SetExitBoat(CVehicle *boat)
 	CWaterLevel::FreeBoatWakeArray();
 }
 
+#include <new>
+
 class CPed_ : public CPed
 {
 public:
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index c6580d32..49d0183e 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -1414,6 +1414,8 @@ CPlayerPed::ProcessControl(void)
 	}
 }
 
+#include <new>
+
 class CPlayerPed_ : public CPlayerPed
 {
 public:
diff --git a/src/vehicles/Automobile.cpp b/src/vehicles/Automobile.cpp
index a05a1236..44ff6b6d 100644
--- a/src/vehicles/Automobile.cpp
+++ b/src/vehicles/Automobile.cpp
@@ -4483,6 +4483,8 @@ CAutomobile::SetAllTaxiLights(bool set)
 	m_sAllTaxiLights = set;
 }
 
+#include <new>
+
 class CAutomobile_ : public CAutomobile
 {
 public:
diff --git a/src/vehicles/Boat.cpp b/src/vehicles/Boat.cpp
index 7dbd7080..6d584017 100644
--- a/src/vehicles/Boat.cpp
+++ b/src/vehicles/Boat.cpp
@@ -299,6 +299,8 @@ CBoat::FillBoatList()
 	}
 }
 
+#include <new>
+
 class CBoat_ : public CBoat
 {
 public:
diff --git a/src/vehicles/Heli.cpp b/src/vehicles/Heli.cpp
index aab9dd0d..9fc50651 100644
--- a/src/vehicles/Heli.cpp
+++ b/src/vehicles/Heli.cpp
@@ -1034,6 +1034,7 @@ bool CHeli::HasCatalinaBeenShotDown(void) { return CatalinaHasBeenShotDown; }
 
 void CHeli::ActivateHeli(bool activate) { ScriptHeliOn = activate; }
 
+#include <new>
 
 class CHeli_ : public CHeli
 {
diff --git a/src/vehicles/Plane.cpp b/src/vehicles/Plane.cpp
index b4d80581..e44ff996 100644
--- a/src/vehicles/Plane.cpp
+++ b/src/vehicles/Plane.cpp
@@ -964,6 +964,7 @@ bool CPlane::HasCesnaLanded(void) { return CesnaMissionStatus == CESNA_STATUS_LA
 bool CPlane::HasCesnaBeenDestroyed(void) { return CesnaMissionStatus == CESNA_STATUS_DESTROYED; }
 bool CPlane::HasDropOffCesnaBeenShotDown(void) { return DropOffCesnaMissionStatus == CESNA_STATUS_DESTROYED; }
 
+#include <new>
 
 class CPlane_ : public CPlane
 {
diff --git a/src/vehicles/Train.cpp b/src/vehicles/Train.cpp
index 1c73ed05..6446e6d1 100644
--- a/src/vehicles/Train.cpp
+++ b/src/vehicles/Train.cpp
@@ -691,6 +691,8 @@ CTrain::UpdateTrains(void)
 	}
 }
 
+#include <new>
+
 class CTrain_ : public CTrain
 {
 public: