Re: Race/Class Snippet

From: Thomas Arp (
Date: 11/09/00

From: "Lewis, Jason" <>
> I am trying to install the race/class snippet and I am getting undeclared ch
> errors in this code.
> void display_classes(struct descriptor_data *d) {
>   int x;
>   send_to_char("Class selection menu - please choose a
> class\r\n---------------
> -----\r\n", d->character);
>   for (x = 0; x < NUM_CLASSES; x++)
--    if (class_ok_race[(int)GET_RACE(ch)][x]])
++    if (class_ok_race[(int)GET_RACE(d->character)][x]])
>       send_to_char(class_display[x], d->character);
>       send_to_char("\nClass: ", d->character);
> }
> I cannot figure out why I am getting this error as GET_RACE(ch) is the
> variable not ch, When I added races I added
> #define GET_RACE(ch)    ((ch)->player.race)

This MACRO is substituted everytime you compile, before the syntax
check. This means that the following is equivalent (though harder to
read and understand):

#define GET_RACE(XY123456789LSD) ((XY123456789LSD)-player.race)

in other words - in the code above you're trying to find the race
element of a given 'character-structure'. In this context this
'character-structure' isn't known as 'ch', but as a sub-element of the
'descriptor-structure' 'd'. Therefore you must use the
correct name - in this case 'd->character' to reference the

This is very basic C, and you might want to have a look at some tutorials (this one is on the university of Hull, whereever that is):

Hope my answer cleared things up for you.


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

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