Levelsorting Spells

From: Søren P. Skou (serces@MUD.DK)
Date: 09/18/97


Hi everyone..

I just decided to get rid of the help for spells, so that when I put in
new spells The list will autoupdate. This seemed like no problem, since
in the code there is allready a list of skills (Prac or my own
SKILL/SPELL list).  Problem is when I try to sort it on level, it
definately doesnt work. Might be me, but anyway. If anyone has an Idea
to what *might* be wrong.. :)

int sort_info2[MAX_SPELLS+1];
extern char *spells[];
extern spell_info_type spell_info[];

void sort_for_skillstat(void)
{
  int a, b, tmp;

  /* initialize array */
  for (a = 1; a < MAX_SPELLS; a++)
    sort_info2[a] = a;

  /* Sort.  'a' starts at 1, not 0, to remove 'RESERVED' */
  for (a = 1; a < MAX_SPELLS - 1; a++)
    for (b = a + 1; b < MAX_SPELLS; b++)
if (spell_info[sort_info2[a]].min_level[CLASS_WIZARD] <
     spell_info[sort_info2[b]].min_level[CLASS_WIZARD]) {
        tmp = sort_info2[a];
        sort_info2[a] = sort_info2[b];
        sort_info2[b] = tmp;
      }
}

ACMD(do_wiz_spell)
{
 int i, sortpos;

 strcpy(buf, "The Spell list for your class\r\n");
 sprintf(buf2, buf);

 for (sortpos = 1; sortpos < MAX_SPELLS;sortpos++) {
  i = sort_info2[sortpos];
  sprintf(buf, "%sLevel:%s %s%d%s %s%-20s%s\r\n",
  CCWHT(ch, C_NRM), CCNRM(ch, C_NRM),
  CCBGRN(ch, C_NRM), spell_info[sort_info2[i]].min_level[CLASS_WIZARD],
  CCNRM(ch, C_NRM),
  CCBGRN(ch, C_NRM), spells[sort_info2[i]], CCNRM(ch, C_NRM));
  strcat(buf2, buf);
 }
 page_string(ch->desc, buf2, 1);
}

anyone with an Idea of why this doesn't work? (And a hint to how I can
make it work? :)

/Serces is a little bit frustrated.


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/08/00 PST