Evaluation, and bounds checking with structures/linked lists.

From: Web Remedies Network (webremedies@home.com)
Date: 04/06/01


The first section below works fine display a list similar to:

0) [heal         ] [100] [0] [5]
1) [burning hands] [95 ] [5] [0]
2) [remove curse ] [75 ] [0] [0]

However the second section even if:

struct trainer_data *demp;

is defined at the top only seems to output (mob vals)
the heal value, it doesn't list the other ones, which also
makes it impossible to do bounds checking on spells/skills
a builder may be designating it, seeing as though it only
picks up on the first one in the list, for example: (heal).
nothing else seems to be displayed and the loop seems to
exit.

Wondering why it would work perfectly for one occurance, and
then fail on the second?  or rather or read the first value than
exit.

Any help is appreciated,

Bill.
--------------------------------------------------------------------

void trainer_disp(struct descriptor_data *d)

  struct trainer_data *temp;
  int i;

  if(IS_TRAINER(OLC_MOB(d))) {
   sprintf(buf, "    &g[&w  Spell&g/&wSkill  &g]      [&wPercent
Taught&g]
[&wCost&g]     [&wQP Cost&g]\r\n");
   send_to_char(buf, d->character);
   for(temp = IS_TRAINER((OLC_MOB(d))), i = 0; temp; temp = temp->next,
i++) {
     sprintf(buf, "&g%d&w)   &g[&w%-17s&g]          [&w%3d&g]
[&w%7d&g]     [&w%6d&g]&n\r\n", i,
skill_name(((int)temp->spell_number)),
temp->percent, temp->$     send_to_char(buf, d->character);
   }
   sprintf(buf, "&gA&w) Add a new training ability.\r\n");
   send_to_char(buf, d->character);
  send_to_char("Enter selection (Enter to quit): ", d->character);
  }
  else {
  sprintf(buf, "Not completed!\r\n");
  send_to_char(buf, d->character);
 }

----------------------------------------------------
  case MEDIT_TRAINER_MAIN2:
  i = atoi(arg);
  if(i == 0)
   break;
  if(strcmp(skill_name(i), "!UNUSED!")) {
   for(demp = IS_TRAINER((OLC_MOB(d))); demp; demp = demp->next) {
     sprintf(buf, "%d (mob vals)\r\n%s (same)\r\n%d (your vals)\r\n%s
(same)\r\n", (((int)demp->spell_number)),
skill_name(((int)demp->spell_number)), i, skill_nam$
send_to_char(buf,
d->character);
     if(skill_name(((int)demp->spell_number)) == skill_name(i))
      send_to_char("Already assigned!\r\n", d->character);
      break;
   }
   break;
  }
  else {
  send_to_char("Error, trying to assign non-existant spell/skill!\r\n",
d->character);
  break;
  }
  return;
---------------------------------------------------------------------

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST