Move actor ref header somewhere more appropriate

This commit is contained in:
robojumper
2024-06-25 20:11:44 +02:00
parent 3be14367f8
commit 58483211c9
2 changed files with 35 additions and 27 deletions
+35
View File
@@ -25,6 +25,41 @@ struct SoundInfo {
SoundInfo *prev;
};
/**
* A list node that will automatically unlink upon destruction.
*/
class dAcRefBase_c : public fLiNdBa_c {
public:
dAcRefBase_c(fBase_c *owner) : fLiNdBa_c(owner) {}
~dAcRefBase_c() {
unlink();
}
};
/**
* A type-safe list node that can hold a specific actor reference.
* Unlinks upon destruction. This setup is inferred from
* double null checks in inline dtors and instantiated ctors/dtors
* for arrays of these nodes in classes.
*/
template <typename T>
class dAcRef_c : dAcRefBase_c {
public:
dAcRef_c(T *owner) : dAcRefBase_c(owner) {}
dAcRef_c() : dAcRefBase_c(nullptr) {}
~dAcRef_c() {}
void link(T *ref) {
fLiNdBa_c::link(ref);
}
void unlink() {
fLiNdBa_c::unlink();
}
T *get() {
return static_cast<T *>(p_owner);
}
};
template <typename T, int offset>
struct TList {
T *GetOffset() {
-27
View File
@@ -28,31 +28,4 @@ public:
fBase_c *p_owner;
};
// TODO unofficial, move these to a more appropriate place
class fLiNdBaAutoUnlink_c : public fLiNdBa_c {
public:
fLiNdBaAutoUnlink_c(fBase_c *owner) : fLiNdBa_c(owner) {}
~fLiNdBaAutoUnlink_c() {
unlink();
}
};
template <typename T>
class dAcRef_c : fLiNdBaAutoUnlink_c {
public:
dAcRef_c(T *owner) : fLiNdBaAutoUnlink_c(owner) {}
dAcRef_c() : fLiNdBaAutoUnlink_c(nullptr) {}
~dAcRef_c() {}
void link(T *ref) {
p_owner = ref;
}
void unlink() {
fLiNdBa_c::unlink();
}
T *get() {
return static_cast<T *>(p_owner);
}
};
#endif