How/Why to avoid findchain() ============================ By Marco Hladik Last updated: 8th of August 2018 If you're a QuakeC progs programmer you will have come across bits of code, similar to the one here: // Cycle through all the player entities and set their health to 100 entity b = findchain( classname, "player" ); while ( b ) { b.health = 100; b = b.chain; } .chain is a field used by every entity in the stock Quake progs code. It's a linked list created by whenever you call findchain() - it might seem harmless to you, but it's generally a bad practice using it. For example, you cannot call findchain() inside an ongoing chain loop. It also conflicts with findradius(), which shared the same field .chain as well to point to the next entity in the linked list. Those entities are most likely going to be related to players. So they'll override the existing entity reference from the loop that hasn't finished. It'll result in uncontrollable garbage. So you can never combine findchain() with findradius(). Ever. However, there are ways to avoid using findchain() AND findradius() altogether, by just using find(). This is possible because find()'s first parameter tells the builtin which entity to start from in the entity list. This is quite clever, as it allows us to simply route the output of the last result into a new find() call - thus jumping from one entity to the next. // Does the same thing as the above code, while avoiding .chain for ( entity b = world; ( b = find( b, classname, "player" ) ); ) { b.health = 100; } Now, you can also replace findradius() by using the for loop above, while manually checking whether or not the entities are within a specified radius. // Set the health of everyone to 100, 500 units around `somevector` for ( entity b = world; ( b = find( b, classname, "player" ) ); ) { if ( vlen( b.origin - somevector ) < 500 ) { b.health = 100; } } findchainfloat(), which was a Darkplaces addition, has the same problems. If your loops don't work right, it might be a chain conflict. These happen more often you think! Someone might call a function inside a loop that contains a findradius() call or a findchain()/findchainfloat() one. It'll screw things up. Don't risk it! Say no to these :)