Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to "verify" your details, 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.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ 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
| Fri 04 Mar 2005 02:32 AM (UTC) Amended on Fri 04 Mar 2005 07:27 PM (UTC) by Asean Novari
|
Message
| I would appreciate some assistance in adding this snippet to swr1fuss..
/*
* stripclr - removes the color codes from a string.
*
* Notice: currently setup for the default smaug/swr color code system,
* if you do not use these, then you will have to do some editing.
*
* This function should properly remove the color codes from a string
* Not sure if its any use to anyone, but i thought i'd give it out.
*
* I'm not asking for my name to be displayed, but i would like to have my name at
* least still attached to this function. Altho, it certainly would be nice.
*
* Feel free to contact me if you have any problems.
*
* - Gavin - ur_gavin@hotmail.com
* - Unknown Regions - http://ur.lynker.com
*/
* - Gavin - ur_gavin@hotmail.com
* - Unknown Regions - http://ur.lynker.com
*/
char *stripclr( char *text )
{
int i = 0, j = 0;
if (!text || text[0] == '\0')
{
return NULL;
}
else
{
char *buf;
static char done[MAX_INPUT_LENGTH*2];
done[0] = '\0';
if ( (buf = (char *)malloc( strlen(text) * sizeof(text) )) == NULL)
return text;
/* Loop through until you've hit your terminating 0 */
while (text[i] != '\0')
{
while (text[i] == '&')
{
i += 2;
}
if ( text[i] != '\0' )
{
if ( isspace(text[i]) )
{
buf[j] = ' ';
i++;
j++;
}
else
{
buf[j] = text[i];
i++;
j++;
}
}
else
buf[j] = '\0';
}
buf[j] = '\0';
sprintf(done, "%s", buf);
buf = realloc(buf, j*sizeof(char));
free( buf);
return done;
}
}
currently this code is in a file called stripclr.c
do i add this to my src directory and then put stripclr into the includes in the makefile?... |
| Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #1 on Fri 04 Mar 2005 02:51 AM (UTC) |
Message
|
Quote: then put stripclr into the includes in the makefile I'm not sure what exactly you mean by this, but if you mean adding it to the lists of files at the top of the makefile, yes, that's what you have to do. |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Asean Novari
USA (82 posts) Bio
|
Date
| Reply #2 on Fri 04 Mar 2005 03:11 AM (UTC) |
Message
| Ok ive done that now.. When i Try to makefile.. i get this series of errors..
Administrator@Home ~/swr1fuss/src
$ make
make -s swreality
Compiling o/stripclr.o....
stripclr.c: In function `stripclr':
stripclr.c:24: error: `NULL' undeclared (first use in this function)
stripclr.c:24: error: (Each undeclared identifier is reported only once
stripclr.c:24: error: for each function it appears in.)
stripclr.c:29: error: `MAX_INPUT_LENGTH' undeclared (first use in this function)
stripclr.c:33: warning: implicit declaration of function `malloc'
stripclr.c:33: warning: implicit declaration of function `strlen'
stripclr.c:45: warning: implicit declaration of function `isspace'
stripclr.c:64: warning: implicit declaration of function `sprintf'
stripclr.c:65: warning: implicit declaration of function `realloc'
stripclr.c:65: warning: assignment makes pointer from integer without a cast
stripclr.c:66: warning: implicit declaration of function `free'
stripclr.c:29: warning: unused variable `done'
stripclr.c:29: error: storage size of `done' isn't known
make[1]: *** [o/stripclr.o] Error 1
make: *** [all] Error 2
Once again I am a novice coder and apologize if i do not understand the errors right away.
|
| Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #3 on Fri 04 Mar 2005 03:21 AM (UTC) |
Message
| What did the instructions say to do? Did the code come with the function in its own file?
This would go away if you included mud.h at the top of the .c file but please also answer the questions. :) |
David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone
http://david.the-haleys.org | Top |
|
Posted by
| Asean Novari
USA (82 posts) Bio
|
Date
| Reply #4 on Fri 04 Mar 2005 03:37 AM (UTC) Amended on Fri 04 Mar 2005 03:42 AM (UTC) by Asean Novari
|
Message
| No instructions were given as to how to install it..
This is the site i got it from http://www.geocities.com/gendi_uk/areas.html
The code was all in a file called stripclr.c
Trying your suggestion on the #include "mud.h" thing it gave more errors upon trying to make..
Administrator@Home ~/swr1fuss/src
$ make
make -s swreality
Compiling o/stripclr.o....
In file included from mud.h:294,
from stripclr.c:19:
i3.h:388: error: parse error before "FILE"
i3.h:388: warning: function declaration isn't a prototype
i3.h:389: error: parse error before "FILE"
i3.h:389: warning: function declaration isn't a prototype
In file included from mud.h:297,
from stripclr.c:19:
imc.h:406: error: parse error before "FILE"
imc.h:406: warning: function declaration isn't a prototype
imc.h:407: error: parse error before "FILE"
imc.h:407: warning: function declaration isn't a prototype
In file included from stripclr.c:19:
mud.h:3167: error: parse error before '*' token
mud.h:3167: warning: type defaults to `int' in declaration of `fpArea'
mud.h:3167: warning: data definition has no type or storage class
mud.h:3299: error: parse error before '*' token
mud.h:3299: warning: type defaults to `int' in declaration of `fpReserve'
mud.h:3299: warning: data definition has no type or storage class
mud.h:3300: error: parse error before '*' token
mud.h:3300: warning: type defaults to `int' in declaration of `fpLOG'
mud.h:3300: warning: data definition has no type or storage class
mud.h:4155: error: parse error before '*' token
mud.h:4155: warning: function declaration isn't a prototype
mud.h:4156: error: parse error before '*' token
mud.h:4156: warning: function declaration isn't a prototype
mud.h:4157: error: parse error before '*' token
mud.h:4157: warning: function declaration isn't a prototype
mud.h:4158: error: parse error before '*' token
mud.h:4158: warning: function declaration isn't a prototype
mud.h:4159: error: parse error before '*' token
mud.h:4159: warning: function declaration isn't a prototype
mud.h:4160: error: parse error before '*' token
mud.h:4160: warning: function declaration isn't a prototype
mud.h:4161: error: parse error before '*' token
mud.h:4161: warning: function declaration isn't a prototype
mud.h:4472: error: parse error before "FILE"
mud.h:4472: warning: function declaration isn't a prototype
mud.h:4473: error: parse error before "FILE"
mud.h:4473: warning: function declaration isn't a prototype
stripclr.c: In function `stripclr':
stripclr.c:36: warning: implicit declaration of function `strlen'
stripclr.c:48: warning: implicit declaration of function `isspace'
stripclr.c:67: warning: implicit declaration of function `sprintf'
make[1]: *** [o/stripclr.o] Error 1
make: *** [all] Error 2
|
| Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #5 on Fri 04 Mar 2005 03:53 PM (UTC) |
Message
| Well how about moving the function to an existing file? Like comm.c or the sort. That way you don't need to include mud.h and so on. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| David Haley
USA (3,881 posts) Bio
|
Date
| Reply #6 on Fri 04 Mar 2005 05:09 PM (UTC) |
Message
| 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
http://david.the-haleys.org | Top |
|
Posted by
| Asean Novari
USA (82 posts) Bio
|
Date
| Reply #7 on Fri 04 Mar 2005 07:16 PM (UTC) 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..
|
| Top |
|
Posted by
| Nick Cash
USA (626 posts) Bio
|
Date
| Reply #8 on Fri 04 Mar 2005 07:23 PM (UTC) |
Message
| 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.
|
~Nick Cash
http://www.nick-cash.com | Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #9 on Fri 04 Mar 2005 07:46 PM (UTC) |
Message
| This'll support Smaug too right? I don't see any SWR specific functions. I've been meaning to make a strclr function. |
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Asean Novari
USA (82 posts) Bio
|
Date
| Reply #10 on Fri 04 Mar 2005 09:38 PM (UTC) |
Message
| 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..
|
| Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #11 on Fri 04 Mar 2005 09:51 PM (UTC) |
Message
| Just add the function at the bottom of any file. Add this at the top of the file:
|
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Asean Novari
USA (82 posts) Bio
|
Date
| Reply #12 on Fri 04 Mar 2005 10:17 PM (UTC) |
Message
| 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..
|
| Top |
|
Posted by
| Zeno
USA (2,871 posts) Bio
|
Date
| Reply #13 on Fri 04 Mar 2005 10:33 PM (UTC) |
Message
| 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:
|
Zeno McDohl,
Owner of Bleached InuYasha Galaxy
http://www.biyg.org | Top |
|
Posted by
| Greven
Canada (835 posts) Bio
|
Date
| Reply #14 on Fri 04 Mar 2005 11:18 PM (UTC) 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.
However, I suggest you take a look at this:
http://www.swreality.net/color.htm |
Nobody ever expects the spanish inquisition!
darkwarriors.net:4848
http://darkwarriors.net | 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.
51,803 views.
This is page 1, subject is 2 pages long: 1 2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top