[Home] [Downloads] [Search] [Help/forum]

Gammon Software Solutions forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  SMAUG
. -> [Folder]  SMAUG coding
. . -> [Subject]  Samson's color code and escape characters

Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?
(New message)
Subject: Samson's color code and escape characters
Name:
Your forum user name.
Register forum user name
Password:
Your forum password.
Forgotten password?
Message:
Message to be posted (in English, please).
Forum codes:
Check this if your message uses 'forum codes' or templates (auto-detected for new posts).
Forum codes Templates

Save this message ...


Subject review (reverse sequence)

Pages: 1 2  

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Tue 28 Feb 2006 01:21 AM (UTC)  quote  ]
Message
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
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Mon 27 Feb 2006 06:58 PM (UTC)  quote  ]
Message
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
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Tue 21 Feb 2006 10:31 PM (UTC)  quote  ]
Message
No luck on Ksilyan's suggestion.
Just got a very odd msg indeed though:

<Health: 100mHea1;36mEnergy: 100%  Ammo: 9266>


Looks almost as if the buf's being overwritten *as* it's being written.

I've compiled a list of the occasions where people see these bugs, and they ALL occur in char *buf s..
Going to look at strcpy next, I suppose.

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
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Mon 20 Feb 2006 06:14 PM (UTC)  quote  ]
Message
Will give it a try, thanks.

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
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sun 19 Feb 2006 10:56 PM (UTC)  quote  ]
Message
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

http://david.the-haleys.org
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Sun 19 Feb 2006 07:14 PM (UTC)  quote  ]
Message
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
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Sun 19 Feb 2006 06:27 PM (UTC)  quote  ]

Amended on Sun 19 Feb 2006 06:45 PM (UTC) by Dace K

Message
Yeah, I've used your color code before with no problems.

So basically, I should just look for DISPOSE/str_dup/fread_string_nohash STRFREE/STRALLOC/fread_string mismatches?

Ugh. I suspect I wasn't using Valgrind properly. Will try again for a few hours.

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
[Go to top] top

Posted by Samson   USA  (683 posts)  [Biography] bio
Date Sun 19 Feb 2006 03:17 PM (UTC)  quote  ]
Message
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
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Sun 19 Feb 2006 09:25 AM (UTC)  quote  ]

Amended on Sun 19 Feb 2006 09:27 AM (UTC) by Dace K

Message
I wish I knew.

Just replaced my color.c and color.h with fresh copies from the AFKmud webpage - the color bug, however, is still alive and kicking :(

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
[Go to top] top

Posted by David Haley   USA  (3,881 posts)  [Biography] bio   Moderator
Date Sun 19 Feb 2006 01:12 AM (UTC)  quote  ]
Message
Also, how did "you" get turned into "jeou"?

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Sat 18 Feb 2006 10:33 PM (UTC)  quote  ]
Message
That first unprintable character is your \1B so that is working OK.

What you have there is:


\1B [0;N je


There is no "m" so the client is not displaying it as a colour sequence. Why there is no "m" is the mystery.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Sat 18 Feb 2006 07:56 PM (UTC)  quote  ]
Message
Valgrind returned no memory leaks, even after the color bug had cropped up a few times. Will try replacing the color code with something stock.

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
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Fri 17 Feb 2006 05:23 AM (UTC)  quote  ]

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

 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
[Go to top] top

Posted by Nick Gammon   Australia  (18,772 posts)  [Biography] bio   Forum Administrator
Date Fri 17 Feb 2006 03:25 AM (UTC)  quote  ]
Message
Quote:

What does the line

pstat = 0x80000000;

do?


It sets pstat to some value unlikely to occur in normal numbers. Then later on if it is changed to a "real" number, like:


pstat = ch->move;


... it does this:


sprintf(pbuf, "%d", pstat);


Effectively, simple numbers are simply output to the prompt line.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Dace K   Canada  (169 posts)  [Biography] bio
Date Thu 16 Feb 2006 06:41 AM (UTC)  quote  ]

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
[Go to top] top

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.


6,475 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

[Reply to this subject]  Reply to this subject   [New subject]  Start a new subject   [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

[Home]

Written by Nick Gammon - 5K

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( http://www.gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Internet Contents Rating Association (ICRA) - 2K]    [Web site powered by FutureQuest.Net]