summaryrefslogtreecommitdiffstats
path: root/src/core
diff options
context:
space:
mode:
authorSergeanur <s.anureev@yandex.ua>2020-12-29 12:55:15 +0100
committerSergeanur <s.anureev@yandex.ua>2020-12-29 12:55:15 +0100
commitf75460fc1d83f82b088aaf69d6fba869fc1569f5 (patch)
treeae2bde9908a773eef046c10f8635129dac7b1c2a /src/core
parentMerge pull request #904 from Sergeanur/bvf (diff)
downloadre3-f75460fc1d83f82b088aaf69d6fba869fc1569f5.tar
re3-f75460fc1d83f82b088aaf69d6fba869fc1569f5.tar.gz
re3-f75460fc1d83f82b088aaf69d6fba869fc1569f5.tar.bz2
re3-f75460fc1d83f82b088aaf69d6fba869fc1569f5.tar.lz
re3-f75460fc1d83f82b088aaf69d6fba869fc1569f5.tar.xz
re3-f75460fc1d83f82b088aaf69d6fba869fc1569f5.tar.zst
re3-f75460fc1d83f82b088aaf69d6fba869fc1569f5.zip
Diffstat (limited to 'src/core')
-rw-r--r--src/core/References.cpp60
-rw-r--r--src/core/World.cpp14
2 files changed, 72 insertions, 2 deletions
diff --git a/src/core/References.cpp b/src/core/References.cpp
index 52abbc3e..6b0c868c 100644
--- a/src/core/References.cpp
+++ b/src/core/References.cpp
@@ -22,6 +22,66 @@ CReferences::Init(void)
}
void
+CEntity::RegisterReference(CEntity **pent)
+{
+ if(IsBuilding())
+ return;
+ CReference *ref;
+ // check if already registered
+ for(ref = m_pFirstReference; ref; ref = ref->next)
+ if(ref->pentity == pent)
+ return;
+ // have to allocate new reference
+ ref = CReferences::pEmptyList;
+ if(ref){
+ CReferences::pEmptyList = ref->next;
+
+ ref->pentity = pent;
+ ref->next = m_pFirstReference;
+ m_pFirstReference = ref;
+ return;
+ }
+ return;
+}
+
+// Clear all references to this entity
+void
+CEntity::ResolveReferences(void)
+{
+ CReference *ref;
+ // clear pointers to this entity
+ for(ref = m_pFirstReference; ref; ref = ref->next)
+ if(*ref->pentity == this)
+ *ref->pentity = nil;
+ // free list
+ if(m_pFirstReference){
+ for(ref = m_pFirstReference; ref->next; ref = ref->next)
+ ;
+ ref->next = CReferences::pEmptyList;
+ CReferences::pEmptyList = m_pFirstReference;
+ m_pFirstReference = nil;
+ }
+}
+
+// Free all references that no longer point to this entity
+void
+CEntity::PruneReferences(void)
+{
+ CReference *ref, *next, **lastnextp;
+ lastnextp = &m_pFirstReference;
+ for(ref = m_pFirstReference; ref; ref = next){
+ next = ref->next;
+ if(*ref->pentity == this)
+ lastnextp = &ref->next;
+ else{
+ *lastnextp = ref->next;
+ ref->next = CReferences::pEmptyList;
+ CReferences::pEmptyList = ref;
+ }
+ }
+}
+
+void
CReferences::RemoveReferencesToPlayer(void)
{
if(FindPlayerVehicle())
diff --git a/src/core/World.cpp b/src/core/World.cpp
index b2c1696c..dc99f015 100644
--- a/src/core/World.cpp
+++ b/src/core/World.cpp
@@ -1600,14 +1600,24 @@ CWorld::ExtinguishAllCarFiresInArea(CVector point, float range)
}
}
+inline void
+AddSteamsFromGround(CPtrList& list)
+{
+ CPtrNode *pNode = list.first;
+ while (pNode) {
+ ((CEntity*)pNode->item)->AddSteamsFromGround(nil);
+ pNode = pNode->next;
+ }
+}
+
void
CWorld::AddParticles(void)
{
for(int32 y = 0; y < NUMSECTORS_Y; y++) {
for(int32 x = 0; x < NUMSECTORS_X; x++) {
CSector *pSector = GetSector(x, y);
- CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_BUILDINGS]);
- CEntity::AddSteamsFromGround(pSector->m_lists[ENTITYLIST_DUMMIES]);
+ AddSteamsFromGround(pSector->m_lists[ENTITYLIST_BUILDINGS]);
+ AddSteamsFromGround(pSector->m_lists[ENTITYLIST_DUMMIES]);
}
}
}