-#define spawn() __spawn("entity", __FILE__, __LINE__, false)
+/** entities you care about seeing (.origin works) */
+#define new(class) _new(class, false)
+/** purely logical entities (.origin doesn't work) */
+#define new_pure(class) _new(class, true)
+#define spawn() __spawn("entity", __FILE__ ":" STR(__LINE__), false)
+
+[[accumulate]] void ONREMOVE(entity this) {}
+
+#ifndef SVQC
+ #define delete_fn builtin_remove
+#endif
+
+#define delete(this) MACRO_BEGIN { \
+ entity _this = (this); \
+ void(entity) _dtor = _this.dtor; \
+ ONREMOVE(this); \
+ if (_dtor) _dtor(_this); else delete_fn(_this); \
+ /* this = NULL; */ \
+} MACRO_END
+
+entity _clearentity_ent;
+STATIC_INIT(clearentity)
+{
+ _clearentity_ent = new_pure(clearentity);
+}
+void clearentity(entity e)
+{
+#ifdef CSQC
+ int n = e.entnum;
+#endif
+ bool was_pure = is_pure(e);
+ copyentity(_clearentity_ent, e);
+ if (!was_pure) make_impure(e);
+#ifdef CSQC
+ e.entnum = n;
+#endif
+}