summaryrefslogtreecommitdiffstats
path: root/src/objects
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2020-02-27 17:07:36 +0100
committereray orçunus <erayorcunus@gmail.com>2020-02-27 17:38:35 +0100
commit750d3229a38cfa449ebb51e4936ca9b33e581695 (patch)
tree84f3dc2642869bc046888c24683cc80712652ba7 /src/objects
parentscript fixes (diff)
downloadre3-750d3229a38cfa449ebb51e4936ca9b33e581695.tar
re3-750d3229a38cfa449ebb51e4936ca9b33e581695.tar.gz
re3-750d3229a38cfa449ebb51e4936ca9b33e581695.tar.bz2
re3-750d3229a38cfa449ebb51e4936ca9b33e581695.tar.lz
re3-750d3229a38cfa449ebb51e4936ca9b33e581695.tar.xz
re3-750d3229a38cfa449ebb51e4936ca9b33e581695.tar.zst
re3-750d3229a38cfa449ebb51e4936ca9b33e581695.zip
Diffstat (limited to '')
-rw-r--r--src/objects/Object.cpp40
-rw-r--r--src/objects/Object.h3
2 files changed, 42 insertions, 1 deletions
diff --git a/src/objects/Object.cpp b/src/objects/Object.cpp
index de98a2d6..357d67d7 100644
--- a/src/objects/Object.cpp
+++ b/src/objects/Object.cpp
@@ -55,6 +55,21 @@ CObject::CObject(int32 mi, bool createRW)
Init();
}
+CObject::CObject(CDummyObject *dummy)
+{
+ SetModelIndexNoCreate(dummy->m_modelIndex);
+
+ if (dummy->m_rwObject)
+ AttachToRwObject(dummy->m_rwObject);
+ else
+ GetMatrix() = dummy->GetMatrix();
+
+ m_objectMatrix = dummy->GetMatrix();
+ dummy->DetachFromRwObject();
+ Init();
+ m_level = dummy->m_level;
+}
+
CObject::~CObject(void)
{
CRadar::ClearBlipForEntity(BLIP_OBJECT, CPools::GetObjectPool()->GetIndex(this));
@@ -109,14 +124,37 @@ CObject::RefModelInfo(int32 modelId)
CModelInfo::GetModelInfo(modelId)->AddRef();
}
+bool
+CObject::CanBeDeleted(void)
+{
+ switch (ObjectCreatedBy) {
+ case GAME_OBJECT:
+ return true;
+ case MISSION_OBJECT:
+ return false;
+ case TEMP_OBJECT:
+ return true;
+ case CUTSCENE_OBJECT:
+ return false;
+ default:
+ return true;
+ }
+}
+
class CObject_ : public CObject
{
public:
- void dtor(void) { this->CObject::~CObject(); }
+ CObject *ctor(void) { return ::new (this) CObject(); }
+ CObject *ctor(int32 mi, bool createRW) { return ::new (this) CObject(mi, createRW); }
+ CObject *ctor(CDummyObject *dummy) { return ::new (this) CObject(dummy); }
+ void dtor(void) { CObject::~CObject(); }
void Render_(void) { CObject::Render(); }
};
STARTPATCHES
+ InjectHook(0x4BABD0, (CObject* (CObject::*)(void)) &CObject_::ctor, PATCH_JUMP);
+ InjectHook(0x4BACE0, (CObject* (CObject::*)(int32, bool)) &CObject_::ctor, PATCH_JUMP);
+ InjectHook(0x4BAD50, (CObject* (CObject::*)(CDummyObject*)) &CObject_::ctor, PATCH_JUMP);
InjectHook(0x4BAE00, &CObject_::dtor, PATCH_JUMP);
InjectHook(0x4BB1E0, &CObject_::Render_, PATCH_JUMP);
ENDPATCHES
diff --git a/src/objects/Object.h b/src/objects/Object.h
index c07bb233..1c33b07f 100644
--- a/src/objects/Object.h
+++ b/src/objects/Object.h
@@ -1,6 +1,7 @@
#pragma once
#include "Physical.h"
+#include "DummyObject.h"
enum {
GAME_OBJECT = 1,
@@ -69,6 +70,7 @@ public:
CObject(void);
CObject(int32, bool);
+ CObject(CDummyObject*);
~CObject(void);
void ProcessControl(void);
@@ -80,6 +82,7 @@ public:
void ObjectDamage(float amount);
void RefModelInfo(int32 modelId);
void Init(void);
+ bool CanBeDeleted(void);
static void DeleteAllTempObjectInArea(CVector, float);
};