diff options
author | Nikolay Korolev <nickvnuk@gmail.com> | 2020-03-01 12:19:42 +0100 |
---|---|---|
committer | Nikolay Korolev <nickvnuk@gmail.com> | 2020-03-01 12:19:42 +0100 |
commit | ceab73a053d1513c8a40354a3e502bc1c3f01819 (patch) | |
tree | 80db097ad3fe1e56ab0d72b9dbe6a7d0d3fbb6c1 /src/objects | |
parent | removed debug leftovers (diff) | |
parent | Merge pull request #339 from erorcun/erorcun (diff) | |
download | re3-ceab73a053d1513c8a40354a3e502bc1c3f01819.tar re3-ceab73a053d1513c8a40354a3e502bc1c3f01819.tar.gz re3-ceab73a053d1513c8a40354a3e502bc1c3f01819.tar.bz2 re3-ceab73a053d1513c8a40354a3e502bc1c3f01819.tar.lz re3-ceab73a053d1513c8a40354a3e502bc1c3f01819.tar.xz re3-ceab73a053d1513c8a40354a3e502bc1c3f01819.tar.zst re3-ceab73a053d1513c8a40354a3e502bc1c3f01819.zip |
Diffstat (limited to 'src/objects')
-rw-r--r-- | src/objects/Object.cpp | 40 | ||||
-rw-r--r-- | src/objects/Object.h | 3 |
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); }; |