Ok, I'm having a small problem that crashes the mud. For lack of knowledge about the "For" loops, I'm not sure what is going on.
Here's the code:
I have 9 spell levels for my spells. The output should look like this when done correctly:
The problem is the line:
This is what crashes the mud. if I comment it out, it works, but I do not get the desired affect. I get this:
Any thoughts on what if statement is doing wrong?
I'm guessin
Here's the code:
for (level = 9; level > 0; level--)
{
marker = FALSE;
for (sn = 1; sn < MAX_SKILL; sn++)
{
if (skill_table[sn]->spell_level != level) <---trouble line
continue;
total = 0;
for (i = 0; i < MAX_MEM_SPELLS; i++)
{
if ((ch->pcdata->memorized[i] != 0)
&& (ch->pcdata->memorized[i] == sn))
{
total++;
none = 0;
}
}
if (total == 0)
continue;
if (marker)
{
if (total < 2)
sprintf(buf, "%s %s\r\n", buf,
skill_table[sn]->name);
else
sprintf(buf, "%s %s (x%d)\r\n",buf,
skill_table[sn]->name, total);
}
else
{
if (total < 2)
sprintf(buf, "%s (level %2d) %s\r\n", buf,
skill_table[sn]->spell_level,
skill_table[sn]->name);
else
sprintf(buf, "%s (level %2d) %s (x%d)\r\n",buf,
skill_table[sn]->spell_level,
skill_table[sn]->name, total);
marker = TRUE;
}
}
}
I have 9 spell levels for my spells. The output should look like this when done correctly:
You have memorized the following spells:
(level 5) blindness (x2)
And you are currently memorizing the following spells:
1 seconds ( 5) blindness.
21 seconds ( 5) blindness.
25 seconds ( 1) armor.
29 seconds ( 1) armor.
You can memorize, 10 1st, 9 2nd, 8 3rd, 8 4th, 3 5th, 6 6th, 6 7th, 6 8th, 5 9th level spell(s).
The problem is the line:
if (skill_table[sn]->spell_level != level)
This is what crashes the mud. if I comment it out, it works, but I do not get the desired affect. I get this:
You have memorized the following spells:
(level 5) blindness (x2)
(level 5) blindness (x2)
(level 5) blindness (x2)
(level 5) blindness (x2)
(level 5) blindness (x2)
(level 5) blindness (x2)
(level 5) blindness (x2)
(level 5) blindness (x2)
(level 5) blindness (x2)
And you are currently memorizing the following spells:
1 seconds ( 5) blindness.
21 seconds ( 5) blindness.
25 seconds ( 1) armor.
29 seconds ( 1) armor.
You can memorize, 10 1st, 9 2nd, 8 3rd, 8 4th, 3 5th, 6 6th, 6 7th, 6 8th, 5 9th level spell(s).
Any thoughts on what if statement is doing wrong?
I'm guessin