Re: Added Field to spell_info struct

From: Kras Kresh (kras_kresh@hotmail.com)
Date: 07/01/02


>From: Gicker <gicker42@HOTMAIL.COM>
>Hi, I added a new field to the spell_info struct and now it won't set the
>name properly.
>
>Example
>
>I type practice and I see:
>
>*************************************************************************
>*                                 SKILLS                                *
>*************************************************************************
>* !UNUSED!                      100 * !UNUSED!                      100 *
>* !UNUSED!                      100 * !UNUSED!                      100 *
>* !UNUSED!                      100 * !UNUSED!                      100 *
>* !UNUSED!                      100 * !UNUSED!                      100 *
>* !UNUSED!                      100 * !UNUSED!                      100 *
>* !UNUSED!                      100 *                                   *
>*************************************************************************
>* Skill Points: 0000                                                    *
>*************************************************************************
>
>Here are some snippets from my code:


>void list_skills(struct char_data * ch) // Reconstructed by Jason Yarber
>{
>   int i, sortpos, pracs, side = 0;
>
>   strcpy(buf, "\n");
>   sprintf(buf,
>"&y*************************************************************************
>&n\r\n");
>   sprintf(buf, "%s&y*                                 &WSKILLS
>&y*&n\r\n", buf);
>   sprintf(buf,
>"%s&y***********************************************************************
>**&n\r\n", buf);
>
>   strcpy(buf2, buf);
>
>   for (sortpos = MAX_SPELLS + 1; sortpos <= SKILLS_IN; sortpos++) {
>     i = spell_sort_info[sortpos];
>     if (strlen(buf2) >= MAX_STRING_LENGTH - 32) {
>       strcat(buf2, "**OVERFLOW**\r\n");
>       break;
>     }
>     if (GET_SKILL(ch, i) >= 0) {
>       if(side == 0) {
>         sprintf(buf, "&y* &C%-20.20s  &c%11d ", spell_info[i].name,
>GET_SKILL(ch, i));
>         strcat(buf2, buf); // The above, ^ should always be safe to do.
>         side++;
>       }
>       else {
>         sprintf(buf, "&y* &C%-20.20s  &c%11d &y*&n\r\n",
>spell_info[i].name,
>GET_SKILL(ch, i));
>         strcat(buf2, buf);
>         side = 0;
>       }
>     }
>   }
>
>   if(side == 1) {
>     sprintf(buf, "&y*                                   *&n\r\n");
>     strcat(buf2, buf);
>   }
>   if (!GET_SKILL_POINTS(ch))
>     pracs = 0;
>   else
>     pracs = GET_SKILL_POINTS(ch);
>   sprintf(buf,
>"&y*************************************************************************
>&n\r\n");
>   sprintf(buf, "%s&y* &WSkill Points: &w%-4.4d
>&y*&n\r\n", buf, pracs);
>   sprintf(buf,
>"%s&y***********************************************************************
>**&n\r\n", buf);
>   strcat(buf2, buf);
>   page_string(ch->desc, buf2, 1);
>}

Well, obviously you changed your list_skill function.
Your problem lies in the loop above that strcats/sprintf into buf.
All you have to do is go over the old code and see what check you removed.

This is the check you probably missed:

if (spell_info[i].name != unused_spellname)


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT