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
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
#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
Amended on Fri 04 Mar 2005 11:20 PM (UTC) by Greven
Message
Well, in SWR, for example, on of the problems was when people put colored names to items with the engineering skills. A fix is to do this in do_makecontainer
if ( obj->name )
STRFREE(obj->name);
obj->name = STRALLOC(stripclr(arg1) );
Now, don't quote me on the exact argument variables since I'm at work, but thats basically how its used.
BTW, Gavin codes on the same mud as me, so I'll let him know and, if possible, see if he can get it updated for gendi's site.
How are you making the object? If you're using colors in the name field, you shouldn't. The name field on objects are the keywords for the object. If you want to use color, use it with the short and long desc. As for the function, something like this can be done:
stripclr( buf );
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org
Ok thanks Zeno doing that made it compile without any errors.. but now how do i use it?...
I make an item with color codes in it but it also puts those
color codes in the name where they shouldnt be.. Otherwise
you have to enter the color codes with the name of the item
when you try to do anything with it..
I have given up with placing it anywhere else other than
Color.c as the other locations give too many errors that I do
not wish to deal with.
Administrator@Home ~/swr1fuss/src
$ make
make -s swreality
Compiling o/color.o....
color.c: In function `stripclr':
color.c:1454: warning: implicit declaration of function `isspace'
make[1]: *** [o/color.o] Error 1
make: *** [all] Error 2
*snippet placed at end of color.c*
Any help with getting rid of this error would be greatly appreciated..
If that was the whole file you pasted then you are missing a few things. The include to mud.h is one of them, though it may not be important. Secondly you need:
#include <stdio.h>
As I believe that it is not included in mud.h and it will give you errors such as what you posted. Try throwing that into the top and see how things go.
Amended on Fri 04 Mar 2005 09:39 PM (UTC) by Asean Novari
Message
Where in comm.c do i stick it?.. I put it in in more or less
a random spot in between functions and when i try to make i
get over 4k redundancy warnings for ALL of the different
commands in the game and on top of that i also get alot of
errors..
Interesting random note regarding Firefox and code tags. As I read this thread, the first code block was normal, second small, third normal. As I reply to it, the first and second are small and the third is normal. Very, very weird...
As for the problem, the simplest is to just stick it into comm.c if you don't want to figure out and fix the mistakes.
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
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.