Re: [code] [NEWBIE] Question about calling GET_CLASS(ch)

From: Rick Glover (magik@THEGRID.NET)
Date: 11/07/98


-----Original Message-----
From: Andrew <object@ALPHALINK.COM.AU>
To: CIRCLE@post.queensu.ca <CIRCLE@post.queensu.ca>
Date: Saturday, November 07, 1998 12:51 AM
Subject: Re:  [code] [NEWBIE] Question about calling GET_CLASS(ch)


>>do_score in act.informative.c The below is what I tried to use:
>>  sprintf(buf, "Class: %d", GET_CLASS(ch));
>>  if (GET_REMORT(ch) >= 0) {
>>  sprintf(buf,  "   Dual: %d", GET_REMORT(ch));
>> }

>>

<snip>
>/* Start code here */
> sprintf(buf + strlen(buf), "Class: ");
>
> switch(GET_CLASS(ch)) {
> case CLASS_MAGIC_USER:
>      sprintf(buf + strlen(buf), "Magic User\r\n");
>      break;
> case CLASS_CLERIC:
>      sprintf(buf + strlen(buf), "Cleric\r\n");
>      break;
<snip>

Actually, since class.c contains a nice constant called pc_class_types[],
you can use that to convert the decimal to string.  The include at the top
of act.informative.c gives you the external declaration that you need for
it, so just:

Change your:
  sprintf(buf, "Class: %d", GET_CLASS(ch));
to:
  sprintf(buf, "Class: %s\r\n", pc_class_types[(int)GET_CLASS(ch)]);
  send_to_char(buf, ch);

Rick

P.S. I added the \r\n so you'd go down to another line and send_to_char() so
that you can see it.  :)


     +------------------------------------------------------------+
     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
     +------------------------------------------------------------+



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