From cf8037b6949e9af563c628a76d08e27a3528815a Mon Sep 17 00:00:00 2001 From: terencehill Date: Sat, 8 Apr 2023 16:35:32 +0200 Subject: [PATCH] Optimize IL_REMOVE_RAW. It fixes #2827 (a map with a huge amount of entities crashes on start) --- qcsrc/lib/intrusivelist.qh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/qcsrc/lib/intrusivelist.qh b/qcsrc/lib/intrusivelist.qh index d3a56ba4d..385f7b3b1 100644 --- a/qcsrc/lib/intrusivelist.qh +++ b/qcsrc/lib/intrusivelist.qh @@ -274,9 +274,12 @@ void IL_ENDFRAME() // it should be used only in very particular cases such as after a copyentity call void IL_REMOVE_RAW(entity it) { - it.il_lists = '0 0 0'; - for (int i = 0; i < IL_MAX * 2; ++i) - it.il_links_flds[i] = nil; + if (it.il_lists) + { + it.il_lists = '0 0 0'; + for (int i = 0; i < IL_MAX * 2; ++i) + it.il_links_flds[i] = nil; + } } // called when an entity is deleted with delete() / remove() -- 2.39.2