Hey... I've read all the stuff and every seems to be doing things their own
way with cursing which is cool, I figuredI'd show you what I did. I made a
point in pcdata that points to some user defined curse words, and then the
generic ones already in a filter. This way the user can add ones that he or
she finds offensive. Personally I dont allow OOC insults, orracials slurs
or such, OOC, but anything not directed at someone or anything thats
obviously IC is ok with me. SO I dont censor things in general unless its
OOC but i dont stop my players from having code that does it. everything
that is sent to a character is put through a filer() function, that doesnt
touch it, if the player doesnt have filter active. I was planning on
sometime making a filter PG, PG-13, R, and X too but haven't gotten around
to levels of it right now. what it does is replaces the the generic swear
words, and any use defined ones with %$#%#*.
void filter( CHAR_DATA *ch, char *txt)
{
int i,len;
char rand_letter[7] = { '!','@','#','$','%','&','*' };
if(!IS_SET(ch->act,PLR_FILTER))
return;
while(*txt)
{
if( (len = has_swear(ch, txt)) != 0 )
{
for(i = 1 ; i <= len ; i++)
*txt++ = rand_letter[number_range(0,6)];
}
else
txt++;
}
return;
}
and then the has_swear function is this:
#define NO_SWEAR 0
int has_swear(CHAR_DATA *ch, char *txt)
{
int i;
char cpy[MSL];;
char *user_sw;
char swear[MSL];
strcpy(cpy,txt);
if(cpy[0] =='\0')
return NO_SWEAR;
for(i = 0; cpy[i] ; i++)
{
if(cpy[i] != LOWER(cpy[i]) )
cpy[i] = LOWER(cpy[i]);
}
user_sw = ch->pcdata->curses;
while(*user_sw)
{
user_sw = one_argument(user_sw, swear);
if(!str_prefix(swear, cpy))
return strlen(swear);
}
switch(cpy[0])
{
case 'a';
if(!str_prefix("(the a-word goes here)",cpy))
return 3;
break;
case 'f':
if(!str_prefix("(the f-word goes here)",cpy))
return 4;
break;
default:
break; /*i think you get the picture without going into
graphic detail*/
}
return NO_SWEAR;
}
That was my way of handling it... hope it helps someone... might not be the
best code, but i'm not exactly the best coder;) Of coruse theres a
toggleable filter command, and a add_curse command too... you can figure
those out.
-Josh