summaryrefslogtreecommitdiffstats
path: root/src/entities/Dummy.cpp
diff options
context:
space:
mode:
authoreray orçunus <erayorcunus@gmail.com>2019-06-29 15:55:19 +0200
committereray orçunus <erayorcunus@gmail.com>2019-06-29 15:55:19 +0200
commit0974447f585a457ea7d68187db28bcec5aa269e2 (patch)
tree6f7cf38dc4ea9a17b1bc6125fcc69758cf535e34 /src/entities/Dummy.cpp
parentMerge branch 'master' of git://github.com/GTAmodding/re3 into erorcun (diff)
parentfix (diff)
downloadre3-0974447f585a457ea7d68187db28bcec5aa269e2.tar
re3-0974447f585a457ea7d68187db28bcec5aa269e2.tar.gz
re3-0974447f585a457ea7d68187db28bcec5aa269e2.tar.bz2
re3-0974447f585a457ea7d68187db28bcec5aa269e2.tar.lz
re3-0974447f585a457ea7d68187db28bcec5aa269e2.tar.xz
re3-0974447f585a457ea7d68187db28bcec5aa269e2.tar.zst
re3-0974447f585a457ea7d68187db28bcec5aa269e2.zip
Diffstat (limited to 'src/entities/Dummy.cpp')
-rw-r--r--src/entities/Dummy.cpp52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/entities/Dummy.cpp b/src/entities/Dummy.cpp
index a4880175..68b67b5c 100644
--- a/src/entities/Dummy.cpp
+++ b/src/entities/Dummy.cpp
@@ -1,7 +1,57 @@
#include "common.h"
#include "patcher.h"
-#include "Dummy.h"
#include "Pools.h"
+#include "World.h"
+#include "Dummy.h"
void *CDummy::operator new(size_t sz) { return CPools::GetDummyPool()->New(); }
void CDummy::operator delete(void *p, size_t sz) { CPools::GetDummyPool()->Delete((CDummy*)p); }
+
+void
+CDummy::Add(void)
+{
+ int x, xstart, xmid, xend;
+ int y, ystart, ymid, yend;
+ CSector *s;
+ CPtrList *list;
+
+ CRect bounds = GetBoundRect();
+ xstart = CWorld::GetSectorIndexX(bounds.left);
+ xend = CWorld::GetSectorIndexX(bounds.right);
+ xmid = CWorld::GetSectorIndexX((bounds.left + bounds.right)/2.0f);
+ ystart = CWorld::GetSectorIndexY(bounds.top);
+ yend = CWorld::GetSectorIndexY(bounds.bottom);
+ ymid = CWorld::GetSectorIndexY((bounds.top + bounds.bottom)/2.0f);
+ assert(xstart >= 0);
+ assert(xend < NUMSECTORS_X);
+ assert(ystart >= 0);
+ assert(yend < NUMSECTORS_Y);
+
+ for(y = ystart; y <= yend; y++)
+ for(x = xstart; x <= xend; x++){
+ s = CWorld::GetSector(x, y);
+ if(x == xmid && y == ymid)
+ list = &s->m_lists[ENTITYLIST_OBJECTS];
+ else
+ list = &s->m_lists[ENTITYLIST_DUMMIES_OVERLAP];
+ CPtrNode *node = list->InsertItem(this);
+ assert(node);
+ m_entryInfoList.InsertItem(list, node, s);
+ }
+}
+
+void
+CDummy::Remove(void)
+{
+ CEntryInfoNode *node, *next;
+ for(node = m_entryInfoList.first; node; node = next){
+ next = node->next;
+ node->list->DeleteNode(node->listnode);
+ m_entryInfoList.DeleteNode(node);
+ }
+}
+
+STARTPATCHES
+ InjectHook(0x473860, &CDummy::Add_, PATCH_JUMP);
+ InjectHook(0x473AD0, &CDummy::Remove_, PATCH_JUMP);
+ENDPATCHES