Re: race parsing

From: Brian Pape (bpape@ezl.com)
Date: 03/16/96


> The problem I had was how to let the mud know that the race/class
> combination was invalid without adding an aditional parameter to the
> function call.

> const bool race_class_ok[NUM_RACES][NUM_CLASSES] = {
>   /* Race/Class     Nec, Wil, Ele, Ran, Pal, Ber, Mon, Dru, Rog, Ass, Bla */
>   /* Human - 10 */ { 1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  1 ,  0 },

> /*
>  * Jurko, 24.02.1996
>  * Returns RACE_x if race is found and race/class combination matches
>  * Returns RACE_x + NUM_RACES if race is found but r/c comb. doesn't match
>  * Returns RACE_UNDEFINED if race is not found
>  */
> int parse_race(char *arg, int class)

Why do you need to constantly check for valid race/class combos in the
code?  The only time you should need to do this is for a new character-
when they choose race [ogre] for instance, they should be presented with a
menu listing only valid classes for ogres.  Once they have created their
new character, you can assume their race and class are valid.  Most places
in the code refer to race and class seperately otherwise (i.e.  items that
cannot be used by a certain class), where the race of the character is
irrelevant...  Incidentally I have stat initialization tables for the
different races with one of the values being 'valid_classes', it's merely
a bitmapped field... 

#define B_MU 1
#define B_CL 2
...
#define B_DR 64   /* (1<<6) */
...

struct race_init_table race_init = {
  {0,0,0,0,B_MU|B_CL|B_DR},
  ...
}

this is only checked as the character is created since it's the only time 
it matters.

Brian Pape
bpape@ezl.com
Reign of Towers



This archive was generated by hypermail 2b30 : 12/07/00 PST