]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add back support for nested intrusive list loops
authorterencehill <piuntn@gmail.com>
Sun, 19 Mar 2023 23:19:39 +0000 (00:19 +0100)
committerterencehill <piuntn@gmail.com>
Fri, 24 Mar 2023 21:10:18 +0000 (22:10 +0100)
.gitlab-ci.yml
qcsrc/lib/intrusivelist.qh

index 887b0691ef2e1423e6d9642be74126d733985390..8646ed6553390ae9cb400c22f5f4a34712dc980e 100644 (file)
@@ -75,7 +75,7 @@ test_sv_game:
     - wget -nv -O data/maps/stormkeep.waypoints https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints\r
     - wget -nv -O data/maps/stormkeep.waypoints.cache https://gitlab.com/xonotic/xonotic-maps.pk3dir/raw/master/maps/stormkeep.waypoints.cache\r
 \r
-    - EXPECT=55338fabce73c671336171e6cb055f74\r
+    - EXPECT=5223e8f614f63ee8d0914e2244aff3d4\r
     - HASH=$(${ENGINE} +timestamps 1 +exec serverbench.cfg\r
       | tee /dev/stderr\r
       | sed -e 's,^\[[^]]*\] ,,'\r
index 3dee9ca38823011ee7fc27313efcf23d01480f4e..d3a56ba4df9f0b1e499bf0efc1f67d980487635e 100644 (file)
@@ -188,6 +188,8 @@ void IL_REMOVE(IntrusiveList this, entity it)
                assert(_il); \
                .entity il_next = _il.il_nextfld; \
                noref int i = 0; \
+               entity il_loop_item_save = this.il_loop_item; \
+               this.il_loop_item = NULL; \
                for (entity _next, _it = _il.il_head; _it; (_it = _next, ++i)) \
                { \
                        const noref entity it = _it; \
@@ -199,7 +201,7 @@ void IL_REMOVE(IntrusiveList this, entity it)
                        else \
                                _next = it.(il_next); /* in case next item has changed */ \
                } \
-               this.il_loop_item = NULL; \
+               this.il_loop_item = il_loop_item_save; \
        MACRO_END
 
 .int il_id;
@@ -343,6 +345,25 @@ TEST(intrusivelist, ModificationsWhileLooping)
        });
        EXPECT_TRUE(s == "1234");
 
+       IL_TEST_BUILD();
+       IL_EACH(il_test, true,
+       {
+               s = strcat(s, it.classname);
+               if (it == ent2)
+                       IL_EACH(il_test, true,
+                       {
+                               s = strcat(s, it.classname);
+                               if (it == ent3)
+                                       IL_EACH(il_test, true,
+                                       {
+                                               s = strcat(s, it.classname);
+                                       });
+                               if (it == ent4)
+                                       break;
+                       });
+       });
+       EXPECT_TRUE(s == "12123123454345");
+
        IL_DELETE(il_test);
        delete(ent1); delete(ent2); delete(ent3); delete(ent4); delete(ent5);