for (count = 0, ent = master; ent; ent = ent->chain, count++) ;
for (count = 0, ent = master; count < choice; ent = ent->chain, count++) ;
void DoRespawn(edict_t* ent){ if (ent == NULL) { gi.dprintf("NULL ent passed to %s\n", __func__); return; } if (ent->team) { edict_t* master; unsigned count; unsigned choice; master = ent->teammaster; if (master == NULL) return; count = 0; for (ent = master; ent; ent = ent->chain) count++; assert(count != 0); choice = rand() % count; count = 0; for (ent = master; count < choice; ent = ent->chain) count++; } if (ent) { ent->svflags &= ~SVF_NOCLIENT; ent->solid = SOLID_TRIGGER; gi.linkentity(ent); // send an effect ent->s.event = EV_ITEM_RESPAWN; }}