> tch = NULL; > for (d = descriptor_list; d; d = d->next) { > if (d->character) > if ((GET_LEVEL(d->character) > lvl)&&(GET_LEVEL(d->character) < LVL_HERO)) > { > lvl = GET_LEVEL(d->character); > tch = d->character; > } > } Firstly, the "tch = NULL;" is not neccessary (I don't believe so anyhow, because if there's no-one on, "tch = descriptor_list" will equal "tch = NULL". "connected" is ZERO (0) when the person is playing. There are so many loops in the code that do this same thing, you should check for similar things in the code before asking here (but I digress). Here's how I'd write the code (I actually DID write this code before, I made it a seperate function because I wanted to use it more than one place. int HighestLevel (int Max) { int lvl = 0; struct char_data * tch; struct descriptor_data * d; for (d = descriptor_list; d; d=d->next) if ((tch = d->character) && !d->connected) if (GET_LEVEL(tch) > lvl && GET_LEVEL(tch) < Max) lvl = GET_LEVEL(tch) return (lvl); } Then you can drop this code in any thing that searchs for a person UNDER level Max, this adds some functionality; in my code I used a minimum and maximum. It's not that difficult... :) -- Daniel Koepke
This archive was generated by hypermail 2b30 : 12/07/00 PST