2019-06-02 15:13:56 +00:00
|
|
|
#include "common.h"
|
2020-04-17 13:31:11 +00:00
|
|
|
|
2019-06-02 15:13:56 +00:00
|
|
|
#include "Pools.h"
|
2019-06-29 09:09:33 +00:00
|
|
|
#include "World.h"
|
|
|
|
#include "Dummy.h"
|
2019-06-02 15:13:56 +00:00
|
|
|
|
2020-10-09 09:02:21 +00:00
|
|
|
// --MIAMI: file done
|
|
|
|
|
2019-06-02 15:13:56 +00:00
|
|
|
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); }
|
2019-06-29 09:09:33 +00:00
|
|
|
|
|
|
|
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)
|
2019-06-29 16:36:31 +00:00
|
|
|
list = &s->m_lists[ENTITYLIST_DUMMIES];
|
2019-06-29 09:09:33 +00:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
2020-05-18 22:49:09 +00:00
|
|
|
|
|
|
|
bool
|
|
|
|
IsDummyPointerValid(CDummy* pDummy)
|
|
|
|
{
|
|
|
|
if (!pDummy)
|
|
|
|
return false;
|
|
|
|
int index = CPools::GetDummyPool()->GetJustIndex(pDummy);
|
|
|
|
#ifdef FIX_BUGS
|
|
|
|
if (index < 0 || index >= CPools::GetDummyPool()->GetSize())
|
|
|
|
#else
|
|
|
|
if (index < 0 || index > CPools::GetDummyPool()->GetSize())
|
|
|
|
#endif
|
|
|
|
return false;
|
|
|
|
return pDummy->m_entryInfoList.first;
|
|
|
|
}
|