summaryrefslogtreecommitdiffstats
path: root/src/core/References.cpp
diff options
context:
space:
mode:
authorFire_Head <Fire-Head@users.noreply.github.com>2020-12-29 18:51:37 +0100
committerGitHub <noreply@github.com>2020-12-29 18:51:37 +0100
commit89e27093040067ca80ce2e174c19427222167e8e (patch)
treebf4183a78beb0c3e747fbc1f6a8c4f3c1e114d5c /src/core/References.cpp
parentmaster gxt (diff)
parentReorder CEntity functions into their original order (diff)
downloadre3-89e27093040067ca80ce2e174c19427222167e8e.tar
re3-89e27093040067ca80ce2e174c19427222167e8e.tar.gz
re3-89e27093040067ca80ce2e174c19427222167e8e.tar.bz2
re3-89e27093040067ca80ce2e174c19427222167e8e.tar.lz
re3-89e27093040067ca80ce2e174c19427222167e8e.tar.xz
re3-89e27093040067ca80ce2e174c19427222167e8e.tar.zst
re3-89e27093040067ca80ce2e174c19427222167e8e.zip
Diffstat (limited to 'src/core/References.cpp')
-rw-r--r--src/core/References.cpp60
1 files changed, 60 insertions, 0 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())