[CODE] VisionMUD class_spells_index buffer overflows

From: Torgny Bjers (tb@sbbs.se)
Date: 08/07/00

Hello again,

  Server: CircleMUD 3.0, bpl 17
 Add-ons: OasisOLC 2.0, Races, Classes, liblist,
          aedit 16, hedit, zone builder list, DG Scripts pl 7
      OS: Windows NT 4.0 Server
Hardware: Dell Precision 210 Workstation, Dual Processor
Compiler: Microsoft Developer Studio 97, C++ 5.0

I am having some problems when trying out the class_spells_index that
creates a list of all the spells and skills for a given class and prints
this little nice list out in when the player selects a class when creating a
new char.

It works as far as booting the system and everything, but, there is a
problem when it creates the strings that it later prints out.

When it comes to about 240-250 characters in the string (STR I presume) it
overflows or something and doesn't print anything else into the string, can
any one help me out here?

Kind Regards,

void class_spells_index(int chclass, char *str)
  int i, spellnum, num;
  int n_spells, n_skills;
  *str = '\0';
  sprinttype(chclass, pc_class_types, buf1);
  sprintf(str,"&CSpells & Skills available for &G%ss&C.\r\n", buf1);
  sprintf(str,"%s&WLevel          Spell/Skill   Name&w\r\n", str);

  n_spells = 0;
  n_skills = 0;
  for (i = 1; i <= MAX_MORT_LEVEL; i++) {
    sprintf(str,"%s&Y%2d&w   ", str, i);
    num = 0;
    for (spellnum = 1; spellnum < TOP_SPELLS; spellnum++) {
      if (SINFO.min_level[chclass] == i) {
        if (num >= 3) strcat(str, "\r\n     ");
        if (spellnum >= 1 && spellnum <= MAX_SPELLS) {
          strcpy(buf1, "&m");
        } else if (spellnum > MAX_SPELLS  && spellnum <
          strcpy(buf1, "&c");
        } else
          strcpy(buf1, "&R");
        sprintf(str, "%s%s%-22s", str, buf1, spells[spellnum]);

  strcat(str, "\r\n");
  sprintf(buf1, "&mSpells: &Y%d&w, &cSkills: &Y%d&w, &WTotal: &Y%d&w\r\n",
n_spells, n_skills, n_spells+n_skills);
  strcat(str, buf1);

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

This archive was generated by hypermail 2b30 : 04/11/01 PDT