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

From: Malcor (digital@TOGETHER.NET)
Date: 11/07/98

I use a little different method,

My do_score calls the class name as %s, CLASS_TYPE(ch)
This is defined in utils.h as being

<all on one line mind you :) I hate wordwrap>
#define CLASS_TYPE(ch) (IS_NPC(ch) ? "--" :

so to make a name for the remort the best way I think is to make in utils.h
#define REMORT_TYPE(ch) (IS_NPC(ch) ? "--" :

Then in act.informative.c under do_score

sprintf(buf, "Class: %s", CLASS_TYPE(ch));
  if (GET_REMORT(ch) >= 0) {
  sprintf(buf,  "   Dual: %s", REMORT_TYPE(ch));

-----Original Message-----
From: Andrew <object@ALPHALINK.COM.AU>
To: <>
Date: Saturday, November 07, 1998 2: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));
>> }
>>Now I have no compiling problems, but when you type score now it displays
>>a number instead of a class name.  I have this same problem when I call
>>GET_NAME(ch) in a mudlog command, it just displays a number.  Can anyone
>Ok. A %d basically stands for an integer, not a string of characters. Also,
>the GET_CLASS(ch) macro returns a number which corresponds to a player's
>instead of returning the actual name of the class. That is why you get a
>instead of an actual string of characters. To work out which number
>to which class, look at the defines in structs.h. This should fix it for
>/* Start code here */
> sprintf(buf + strlen(buf), "Class: ");
> switch(GET_CLASS(ch)) {
>      sprintf(buf + strlen(buf), "Magic User\r\n");
>      break;
>      sprintf(buf + strlen(buf), "Cleric\r\n");
>      break;
>      sprintf(buf + strlen(buf), "Thief\r\n");
>      break;
>      sprintf(buf + strlen(buf), "Warrior\r\n");
>      break;
> default:
>      log("Invalid class parsed to do_score.");
>      break;
>/* End code */
>That should fix your problem. Remember, whenever you use sprintf() you are
>whatever was in buf beforehand. To append to buf, use sprintf(buf +
>strlen(buf), "Blah").
>Just watch that with your remort thing. As with your GET_NAME(ch) macro,
>make sure that
>you use %s instead of %d, because GET_NAME(ch) actually refers to a string,
>not an integer
>like GET_CLASS(ch). If it still doesn't work, send me a copy of your
>GET_NAME macro.
>-- Andrew Ritchie.
>| Andrew Ritchie,
>     +------------------------------------------------------------+
>     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>     | |
>     +------------------------------------------------------------+

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

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