Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Nanny class display problems
Nanny class display problems
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Rash
United Kingdom (56 posts) Bio
|
Date
| Sun 10 Jan 2010 11:08 PM (UTC) Amended on Sun 10 Jan 2010 11:09 PM (UTC) by Rash
|
Message
| I'm currently having problems stopping my Remort Classes from been displayed upon player creation.
Here's the output I currently get;
Select a class, or type help [class] to learn more about that class.
[Warlock Assassin Elementalist Knight Sorcerer NecromancerSamurai Mystic
BarbarianshogunBerserkerRangerPaladinBlademasterDruidCultistArchmagedaemonologistDefilerBishopAdept]
Everything after Barbarian is a remort class (Set RemortClass 1 within the class file)
Here's the offending code;
write_to_buffer( d, "\n\rSelect a class, or type help [class] to learn more about that class.\n\r[", 0 );
buf[0] = '\0';
/*
* Take this out SHADDAI
*/
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name && !class_table[iClass]->remort_class == 1 && class_table[iClass]->who_name[0] != '\0')
{
if ( iClass > 0 )
{
if ( strlen(buf)+strlen(class_table[iClass]->who_name) > 77 )
{
strcat( buf, "\n\r" );
write_to_buffer( d, buf, 0 );
buf[0] = '\0';
}
else
strcat( buf, " " );
}
}
strcat( buf, class_table[iClass]->who_name );
}
strcat( buf, "]\n\r: " );
write_to_buffer( d, buf, 0 );
d->connected = CON_GET_NEW_CLASS;
break;
case CON_GET_NEW_CLASS:
argument = one_argument(argument, arg);
if (!str_cmp(arg, "help"))
{
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name && !class_table[iClass]->remort_class == 1 && class_table[iClass]->who_name[0] != '\0')
{
if (toupper(argument[0])==toupper(class_table[iClass]->who_name[0])
&& !str_prefix( argument, class_table[iClass]->who_name ) )
{
do_help(ch, argument);
write_to_buffer( d, "Please choose a class: ", 0 );
return;
}
}
}
write_to_buffer( d, "No such help topic. Please choose a class: ", 0 );
return;
}
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name &&
class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)
{
if ( toupper(arg[0]) == toupper(class_table[iClass]->who_name[0])
&& !str_prefix( arg, class_table[iClass]->who_name ) )
{
ch->class = iClass;
break;
}
}
}
Can anyone spot what the problem is? It's probably something simple. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #1 on Sun 10 Jan 2010 11:38 PM (UTC) |
Message
|
!class_table[iClass]->remort_class == 1
This strikes me as wrong. The ! is likely applied to the value of remort_class and not the expression. Change it to:
class_table[iClass]->remort_class != 1
And see what it does. Of course this may also be wrong if remort_class is used for more then a flag value. |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Rash
United Kingdom (56 posts) Bio
|
Date
| Reply #2 on Mon 11 Jan 2010 03:20 PM (UTC) |
Message
| Applied your suggestion and as you can see below, nothing has changed.
Select a class, or type help [class] to learn more about that class.
[Warlock Assassin Elementalist Knight Sorcerer NecromancerSamurai Mystic
BarbarianshogunBerserkerRangerPaladinBlademasterDruidCultistArchmagedaemonologis
tDefilerBishopAdept]
I'm so very much stumped on this. It does stop the player picking a Remort Class correctly. I just need to stop it displaying them. Can't quite figure this out.
Here's some more code to see if it sheads more light;
Tables.c - from load_class_file
KEY( "RemortClass", class->remort_class, fread_number(fp));
Tables.c - from write_class_file
fprintf( fpout, "RemortClass %d\n", class->remort_class);
Mud.h - struc class_type
This may or may not help. Hopefully it will. | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #3 on Mon 11 Jan 2010 09:45 PM (UTC) Amended on Tue 12 Jan 2010 05:51 PM (UTC) by Nick Cash
|
Message
|
Rash said:
Applied your suggestion and as you can see below, nothing has changed.
Did you apply the fix to the correct if statement? There are two that are the same, and one only handles the help. You should update both, but obviously display is your issue.
If so, there must be a small disconnect within the if statements. Does the code allow you to do a help on the remort classes? This seems likely, since it uses the same if as the class display.
Rash said:
It does stop the player picking a Remort Class correctly.
I believe you can attribute that to this line:
if ( class_table[iClass]->who_name && class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)
Which seems to work, while this does not:
if ( class_table[iClass]->who_name && !class_table[iClass]->remort_class == 1 && class_table[iClass]->who_name[0] != '\0')
and apparently neither does my proposed solution. In any case, try updating the similar if statements to use the same format. If it correctly stops them from choosing the class, you could try:
write_to_buffer( d, "\n\rSelect a class, or type help [class] to learn more about that class.\n\r[", 0 );
buf[0] = '\0';
/*
* Take this out SHADDAI
*/
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name && class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)
{
if ( iClass > 0 )
{
if ( strlen(buf)+strlen(class_table[iClass]->who_name) > 77 )
{
strcat( buf, "\n\r" );
write_to_buffer( d, buf, 0 );
buf[0] = '\0';
}
else
strcat( buf, " " );
}
}
strcat( buf, class_table[iClass]->who_name );
}
strcat( buf, "]\n\r: " );
write_to_buffer( d, buf, 0 );
d->connected = CON_GET_NEW_CLASS;
break;
case CON_GET_NEW_CLASS:
argument = one_argument(argument, arg);
if (!str_cmp(arg, "help"))
{
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name && class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)
{
if ( toupper(argument[0])==toupper(class_table[iClass]->who_name[0]) && !str_prefix( argument, class_table[iClass]->who_name ) )
{
do_help(ch, argument);
write_to_buffer( d, "Please choose a class: ", 0 );
return;
}
}
}
write_to_buffer( d, "No such help topic. Please choose a class: ", 0 );
return;
}
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name &&
class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)
{
if ( toupper(arg[0]) == toupper(class_table[iClass]->who_name[0])
&& !str_prefix( arg, class_table[iClass]->who_name ) )
{
ch->class = iClass;
break;
}
}
}
|
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Rash
United Kingdom (56 posts) Bio
|
Date
| Reply #4 on Tue 12 Jan 2010 02:50 PM (UTC) |
Message
|
Nick Cash said:
Did you apply the fix to the correct if statement? There are two that are the same, and one only handles the help. You should update both, but obviously display is your issue.
If so, there must be a small disconnect within the if statements. Does the code allow you to do a help on the remort classes? This seems likely, since it uses the same if as the class display.
I had updated them both. I can do 'help Blademaster' or 'help defiler' both of which are remort classes.
Nick Cash said:
Apparently neither does my proposed solution. In any case, try updating the similar if statements to use the same format. If it correctly stops them from choosing the class, you could try:
write_to_buffer( d, "\n\rSelect a class, or type help [class] to learn more about that class.\n\r[", 0 );
buf[0] = '\0';
/*
* Take this out SHADDAI
*/
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name && class_table[iClass]->who_name[0] != '\0' && class_table[iClass]->remort_class)
{
if ( iClass > 0 )
{
if ( strlen(buf)+strlen(class_table[iClass]->who_name) > 77 )
{
strcat( buf, "\n\r" );
write_to_buffer( d, buf, 0 );
buf[0] = '\0';
}
else
strcat( buf, " " );
}
}
strcat( buf, class_table[iClass]->who_name );
}
strcat( buf, "]\n\r: " );
write_to_buffer( d, buf, 0 );
d->connected = CON_GET_NEW_CLASS;
break;
case CON_GET_NEW_CLASS:
argument = one_argument(argument, arg);
if (!str_cmp(arg, "help"))
{
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name && class_table[iClass]->remort_class == 1 && class_table[iClass]->who_name[0] != '\0')
{
if ( class_table[iClass]->who_name && class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)
{
do_help(ch, argument);
write_to_buffer( d, "Please choose a class: ", 0 );
return;
}
}
}
write_to_buffer( d, "No such help topic. Please choose a class: ", 0 );
return;
}
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name &&
class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)
{
if ( toupper(arg[0]) == toupper(class_table[iClass]->who_name[0])
&& !str_prefix( arg, class_table[iClass]->who_name ) )
{
ch->class = iClass;
break;
}
}
}
Tried this idea and the output has changed slightly;
Select a class, or type help [class] to learn more about that class.
[WarlockAssassinElementalistKnightSorcererNecromancer SamuraiMysticBarbarian
shogun Berserker Ranger Paladin Blademaster Druid Cultist Archmage
daemonologist Defiler Bishop Adept]
Notice how the Remort Classes are now spaced differently where as the standard classes are no longer spaced as they once where.
Some how it's reading the classes, noticing that some are remort classes and ignoring that fact and using them anyway. You have pointed out the line (That I believe anyway) that is responsible for that problem but I cant figure out why its displaying those classes anyway, unless of cause it HAS to dump all classes.
Perhaps it would be better to do a check on remort classes first (At the start of the if check?) Granted that shouldn't really effect anything...
Rash | Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #5 on Tue 12 Jan 2010 06:01 PM (UTC) Amended on Tue 12 Jan 2010 06:04 PM (UTC) by Nick Cash
|
Message
| Apparently the code got mangled when I was editing the formatting. The ever important ! symbols were somehow deleted in my post, and the if ended up in the wrong place. I have corrected it above, but wait! That error should have made it only print remort classes, and then I saw the real problem:
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name && class_table[iClass]->who_name[0] != '\0' && class_table[iClass]->remort_class)
{
if ( iClass > 0 )
{
if ( strlen(buf)+strlen(class_table[iClass]->who_name) > 77 )
{
strcat( buf, "\n\r" );
write_to_buffer( d, buf, 0 );
buf[0] = '\0';
}
else
strcat( buf, " " );
}
}
strcat( buf, class_table[iClass]->who_name );
}
Note that the last strcat is outside the if blocks, which is why it prints everything and does not space them correctly. To fix, you'll want to mod that section to be:
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( !class_table[iClass]->remort_class )
{
if ( class_table[iClass]->who_name && class_table[iClass]->who_name[0] != '\0' )
{
if ( iClass > 0 )
{
if ( strlen(buf)+strlen(class_table[iClass]->who_name) > 77 )
{
strcat( buf, "\n\r" );
write_to_buffer( d, buf, 0 );
buf[0] = '\0';
}
else
strcat( buf, " " );
}
}
strcat( buf, class_table[iClass]->who_name );
}
}
And the help section should be:
if (!str_cmp(arg, "help"))
{
for ( iClass = 0; iClass < MAX_PC_CLASS; iClass++ )
{
if ( class_table[iClass]->who_name && class_table[iClass]->who_name[0] != '\0' && !class_table[iClass]->remort_class)
{
if ( toupper(argument[0])==toupper(class_table[iClass]->who_name[0]) && !str_prefix( argument, class_table[iClass]->who_name ) )
{
do_help(ch, argument);
write_to_buffer( d, "Please choose a class: ", 0 );
return;
}
}
}
write_to_buffer( d, "No such help topic. Please choose a class: ", 0 );
return;
}
Sorry I didn't catch it the first time! |
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Rash
United Kingdom (56 posts) Bio
|
Date
| Reply #6 on Tue 12 Jan 2010 06:24 PM (UTC) |
Message
| I noticed it just before when I was formatting the code better to see how it flows.
strcat( buf, class_table[iClass]->who_name );
I added this ifcheck to only show non-remort classes.
if (class_table[iClass]->remort_class != 1)
{
strcat( buf, class_table[iClass]->who_name );
}
Would seem that no matter what, that bit of code just outputted the class list. After all
thats what that line says for it to do. Din't think that it would be the cause of printing the
classes out. Late nights make you miss things it would seem =) Anyway thank you for the help.
Oh and a quick addon. This also helped me solve a similar problem with selecting non-remort
classes when remorting which I've now corrected.
Anyway thank you for the help. Problem solved :) | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
19,107 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top