X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Fintrusivelist.qh;h=524c6bec7d4334793b088633f9e43718c9e36247;hb=1a463f974e1c026a16a76dd042ebccb1085ad985;hp=10de3e9630e8c55ba1ba86455ce4a530cd908e85;hpb=cff3504ad5e8ace014ea44de7ad04ad6e246a277;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/intrusivelist.qh b/qcsrc/lib/intrusivelist.qh index 10de3e963..524c6bec7 100644 --- a/qcsrc/lib/intrusivelist.qh +++ b/qcsrc/lib/intrusivelist.qh @@ -4,8 +4,11 @@ const int IL_MAX = 128; +[[eraseable]] void IL_INIT(entity this); +[[eraseable]] void IL_DTOR(entity this); +[[eraseable]] void IL_ENDFRAME(); /** @@ -16,8 +19,8 @@ void IL_ENDFRAME(); * freed entities must be removed from the list */ CLASS(IntrusiveList, Object) - ATTRIB(IntrusiveList, il_head, entity, NULL); - ATTRIB(IntrusiveList, il_tail, entity, NULL); + ATTRIB(IntrusiveList, il_head, entity); + ATTRIB(IntrusiveList, il_tail, entity); ATTRIB(IntrusiveList, il_nextfld, .entity, nil); ATTRIB(IntrusiveList, il_prevfld, .entity, nil); INIT(IntrusiveList) { IL_INIT(this); } @@ -37,6 +40,7 @@ ENDCLASS(IntrusiveList) #define IL_LAST(this) (this.il_tail) #define IL_PEEK(this) (this.il_tail) +[[eraseable]] bool IL_CONTAINS(IntrusiveList this, entity it) { assert(this, return false); @@ -46,6 +50,7 @@ bool IL_CONTAINS(IntrusiveList this, entity it) /** * Push to tail */ +[[eraseable]] entity IL_PUSH(IntrusiveList this, entity it) { assert(this, return NULL); @@ -64,6 +69,7 @@ entity IL_PUSH(IntrusiveList this, entity it) /** * Push to head */ +[[eraseable]] entity IL_UNSHIFT(IntrusiveList this, entity it) { assert(this, return NULL); @@ -82,6 +88,7 @@ entity IL_UNSHIFT(IntrusiveList this, entity it) /** * Pop from tail */ +[[eraseable]] entity IL_POP(IntrusiveList this) { assert(this, return NULL); @@ -99,6 +106,7 @@ entity IL_POP(IntrusiveList this) /** * Pop from head */ +[[eraseable]] entity IL_SHIFT(IntrusiveList this) { assert(this, return NULL); @@ -116,18 +124,20 @@ entity IL_SHIFT(IntrusiveList this) /** * Remove any element, anywhere in the list */ +[[eraseable]] void IL_REMOVE(IntrusiveList this, entity it) { assert(this, return); .entity il_next = this.il_nextfld; .entity il_prev = this.il_prevfld; + //assert(!IL_CONTAINS(this, it), return); entity next = it.(il_next); entity prev = it.(il_prev); entity ohead = this.il_head; entity otail = this.il_tail; next ? next.(il_prev) = prev : this.il_tail = prev; prev ? prev.(il_next) = next : this.il_head = next; - LOG_DEBUGF("remove %i (%i :: %i), head: %i -> %i, tail: %i -> %i\n", it, it.(il_prev), it.(il_next), ohead, this.il_head, otail, this.il_tail); + LOG_DEBUGF("remove %i (%i :: %i), head: %i -> %i, tail: %i -> %i", it, it.(il_prev), it.(il_next), ohead, this.il_head, otail, this.il_tail); it.(il_next) = it.(il_prev) = NULL; } @@ -147,7 +157,7 @@ void IL_REMOVE(IntrusiveList this, entity it) /** * Delete the list */ -#define IL_DELETE(this, dtor) \ +#define IL_DELETE(this) \ MACRO_BEGIN \ { \ delete(this); \ @@ -179,6 +189,7 @@ int il_links_ptr; #define IL_LISTS_PER_BIT IL_CEIL(IL_MAX / (3 * 24)) +[[eraseable]] void IL_INIT(IntrusiveList this) { .entity nextfld, prevfld; @@ -204,15 +215,17 @@ void IL_INIT(IntrusiveList this) return; } } - LOG_WARNINGF("IntrusiveList overflow"); + LOG_WARNF("IntrusiveList overflow"); } +[[eraseable]] void IL_DTOR(IntrusiveList this) { IL_CLEAR(this); il_links[this.il_id] = NULL; } +[[eraseable]] void IL_ENDFRAME() { #if 0 @@ -232,6 +245,7 @@ void IL_ENDFRAME() #endif } +[[eraseable]] void ONREMOVE(entity this) { if (this.il_lists) {