Re: [Win98] Score Bug?

From: Daniel A. Koepke (dkoepke@california.com)
Date: 10/30/00


On Mon, 30 Oct 2000, Andrew Straw wrote:

> ACMD(do_score)
> {
>   struct time_info_data playing_time;
>
>   if (IS_NPC(ch))
>     return;

You've removed some code here, such as the person's name.  It's related to
your problem, which occurs here:

>   sprintf(buf + strlen(buf), "You are a %d year old %d.", GET_AGE(ch),
> GET_RACE(ch));

If you really don't want anything above this, change this to,

    sprintf(buf, "You are a ...);

It seems likely to me that you're overflowing the global buffer, buf, as
it already contains text you probably want to overwrite, rather than
append to.  This is the affect of the change: you now overwrite the old
contents of 'buf', instead of appending to a buffer which contains text
from other sources (such as 'look', etc.).  So you either want to make the
above change, or put the code you've removed back in.

In addition, for the race, you probably don't want to print a number.  I
take it that GET_RACE(ch) returns a numeric index that refers to a race,
e.g., 0 for human (RACE_HUMAN).  You probably have an array of character
pointers with race names somewhere in your code, maybe named race_names.
You would want to use this, as an example:

    sprintf(buf, "You are a %d year old %s.", GET_AGE(ch),
            race_names[GET_RACE(ch)]);

This is unrelated to your crash, unless you have a problem with your
implementation of GET_RACE.  The first part of this message is a
legitimate bug regardless of any others, so you should be sure to fix that
and retest.

If problems persist, hit a good book on C, work on it a bit yourself, and
if you just can't seem to crack the case, return to the list for further
instruction.

This message will self-destruct in 10 seconds.

-dak


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



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