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) ? "--" :
pc_class_types[(int)GET_CLASS(ch)])
so to make a name for the remort the best way I think is to make in utils.h
a
#define REMORT_TYPE(ch) (IS_NPC(ch) ? "--" :
pc_class_types[(int)GET_REMORT(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));
}
Malcor
-----Original Message-----
From: Andrew <object@ALPHALINK.COM.AU>
To: CIRCLE@post.queensu.ca <CIRCLE@post.queensu.ca>
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
>[snip]
>
>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
class,
>instead of returning the actual name of the class. That is why you get a
number
>instead of an actual string of characters. To work out which number
corresponds
>to which class, look at the defines in structs.h. This should fix it for
you:
>
>/* 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;
> case CLASS_THIEF:
> sprintf(buf + strlen(buf), "Thief\r\n");
> break;
> case CLASS_WARRIOR:
> 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
>overwriting
>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, object@alphalink.com.au.
>
>
> +------------------------------------------------------------+
> | Ensure that you have read the CircleMUD Mailing List FAQ: |
> | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
> +------------------------------------------------------------+
>
+------------------------------------------------------------+
| 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