Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ stripclr snippet

stripclr snippet

It is now over 60 days since the last post. This thread is closed.     Refresh page


Pages: 1  2 

Posted by Asean Novari   USA  (82 posts)  Bio
Date Reply #15 on Sat 05 Mar 2005 01:22 AM (UTC)
Message
Thanks for that website Greven... works great..



Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #16 on Mon 05 Sep 2005 03:48 AM (UTC)
Message
Ugh, I just had a crash with this snippet.
#0  0x008a7402 in __kernel_vsyscall ()
#1  0x00979118 in raise () from /lib/libc.so.6
#2  0x0097a888 in abort () from /lib/libc.so.6
#3  0x009ae22a in __libc_message () from /lib/libc.so.6
#4  0x009b6045 in _int_realloc () from /lib/libc.so.6
#5  0x009b6a30 in realloc () from /lib/libc.so.6
#6  0x080c33bb in stripclr (text=0xbffc5349 "ok ^.^&") at comm.c:4929
#7  0x0804a29f in talk_channel (ch=0x9ca52d8, argument=0xbffc5349 "ok ^.^&", channel=2048, verb=0x81c6563 "clantalk")
    at act_comm.c:425
#8  0x0804b1f4 in do_clantalk (ch=0x9ca52d8, argument=0xbffc5349 "ok ^.^&") at act_comm.c:740
#9  0x080e9ea1 in interpret (ch=0x9ca52d8, argument=0xbffc5349 "ok ^.^&") at interp.c:585
#10 0x080bcb46 in game_loop () at comm.c:1226
#11 0x080bbee7 in main (argc=2, argv=0xbffc68a4) at comm.c:590

frame 6:
(gdb) info local
buf = 0x9f06c68 "ok ^.^ me and take me to the fire u dork"
done = "ok ^.^ me and take me to the fire u dork\000k\000rth\000eak in front of such beauty\000and over the glass to hear him\000third <if any> then I will start placing my rooms/links/names/desc and such", '\0' <repeats 1866 times>
i = 42
j = 40

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #17 on Mon 05 Sep 2005 07:31 AM (UTC)
Message
Looks like it barfs when the '&' is at the end of the string and doesn't have a color code following it. The snippet doesn't check for edge cases, which is a big nono. Fixing it is a relatively simple matter of making sure that as you traverse the string, you don't stop over the bounds.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Zeno   USA  (2,871 posts)  Bio
Date Reply #18 on Mon 05 Sep 2005 07:35 AM (UTC)
Message
Ah yes that explains it, I understand why it crashed now. How would I check it? Something like:
if (text[i++] != '\0')

Should do it?

Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Top

Posted by halkeye   Canada  (28 posts)  Bio
Date Reply #19 on Mon 05 Sep 2005 07:50 AM (UTC)
Message
Sorry ^^

That was really old code, i write better stuff now :)

Gavin
Dark Warriors - Coder
http://darkwars.wolfpaw.net
telnet://darkwars.wolfpaw.net:4848
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #20 on Mon 05 Sep 2005 08:36 PM (UTC)
Message
Zeno: I would personally get the length of the string at the beginning and use that as a reference, e.g. i < len. You have to be very careful when you do things like i++.

It has while str\[i\] == &, i+=2. But, what if the last character is &? You'll end up stepping right over the end of the string ... including the \0 at the end of it.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
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.


56,322 views.

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

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.