Well, gratz on fixing it I guess. But that is somewhat irritating to accidentally fix a bug and not know why. That's how I felt after awhile realzing we never see the infamous room_is_dark bug. :)
SmaugMuds.org: http://www.smaugmuds.org - The Smaug MUDs Community Center
"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
Hm. Just thought I'd update: The problem appears to be resolved.
No idea what exactly was causing it, or how I fixed it, though.
While rewriting several functions for greater efficiency, the error just dissapeared...
ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com
Drop by the area archives and find something for your mud. http://areaarchives.servegame.com
Maybe those strange pbuf[i-1] lines in comm.c should be investigated, because those are likely suspects to do something before the beginning of the buffer, especially since your color codes are occuring at the very beginning of the line.
Can't be of much help though without all the code in front of me. What you can try doing is to contrive a situation in which the MUD prints out the score line, and then directly displays the prompt, and see what happens.
But the fact that 'you' is turning into 'jeou' is sign that something very unwanted is occurring.
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
The only problem Valgrind seems to identify is this:
==17739== Use of uninitialised value of size 4
==17739== at 0x1B9DB3F5: mempcpy (in /lib/libc-2.3.4.so)
==17739== by 0x1B9D1E11: _IO_default_xsputn (in /lib/libc-2.3.4.so)
==17739== by 0x1B9AF874: vfprintf (in /lib/libc-2.3.4.so)
==17739== by 0x1B9CD85F: vsnprintf (in /lib/libc-2.3.4.so)
==17739== by 0x80F7B7E: pager_printf (color.c:1354)
==17739== by 0x8174F41: do_score (player.c:183)
==17739== by 0x8137E7A: interpret (interp.c:562)
==17739== by 0x80F8A71: game_loop (comm.c:646)
==17739== by 0x80F8046: main (comm.c:302)
This message appears a few times, but the bold line only appears shortly before someone gets a color error in their prompt.
The line in question in player.c is
pager_printf(ch, "&GPlayed&g: &w%d hours &GSaved&g: &w%s\r",
(get_age(ch) - 17) * 2), (ch->save_time ? ctime(&(ch->save_time)) : "no save this session\n");
ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com
Drop by the area archives and find something for your mud. http://areaarchives.servegame.com
Screwed up strings like that are indicators of over/underruns on the buffers. There really isn't any other way for "you" to turn into "jeou". Valgrind will catch overwrites, but I'm not sure if it knows how to catch "underwrites" where you access something before string[0] in a char. This kind of thing can be incredibly difficult to track down too. But I can tell you with a reasonable degree of certainty that the color code is not to blame for the problem since it's being used widely in many muds. It may simply have exposed the problem for you.
SmaugMuds.org: http://www.smaugmuds.org - The Smaug MUDs Community Center
"The past was erased, the erasure was forgotten, the lie became truth." -- George Orwell, 1984
Amended on Fri 17 Feb 2006 08:54 AM (UTC) by Dace K
Message
Ah, Thanks.
I just got some information from a couple players.
The color bug most often occurs in the prompt, but a couple have received them outside prompt, where there is no % sign, even at the start of a line.
ch_printf( ch, "&gYou %s run along a treadmill at %d mph.\n\r", buf2, number_fuzzy(get_curr_con(ch) + 2));
became
[0;N jeou shakily run along a treadmill at 7 mph.
Perhaps it's not liking \033 calling ANSI instead of \x1b?
I am incredibly confused at this point. I ran a compare of my color.c and .h with the distro copy from AFKmud's homepage, and could find no significant differences. I suppose tomorrow I'll give replacing the files a try, but I doubt it will help.
ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com
Drop by the area archives and find something for your mud. http://areaarchives.servegame.com
Amended on Thu 16 Feb 2006 10:15 PM (UTC) by Dace K
Message
The color code is an almost completely unmodified copy of Samson's code included in SmaugFUSS. Contains no references to % that I can see.
You're right about the extra case '%'.
It's quite weird - its only purpose seems to add a *pbuf = '\0'.
What does the line
pstat = 0x80000000;
do?
Note: I think you're on the right track about the % affecting the code badly. It only happens on the first value called with %% in the string.
Note 2: Out of curiosity, I removed the int percent check from the prompt value. It seems to have decreased the frequency of the prompt errors, but it still occurs...
ASJ Games - .Dimension 2, Resident Evil, and snippets - oh my!
http://asj.mudmagic.com
Drop by the area archives and find something for your mud. http://areaarchives.servegame.com
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.