With cordite in the air, splintered steel, shell casings and powder burns, there’s only one explanation...
Discuss & improve the game engine.

Moderators: sparcdr, torhu, Tequila

Postby Tequila » Sun Apr 12, 2009 11:11 pm

Hi Allied,

I just committed your work in the r189 release, in the 1.1 branch.

Thanks a lot for your contribution.

Now we need an UI interface to set it easily ;)

I just add one cast and few other stuff to have it compiled cleanly on linux. That's pretty cool to integrate clean code like that.
8)

Btw can you explain quickly how to use it here, thx ?
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Allied » Mon Apr 13, 2009 5:49 pm

Hey Tequila,

Thanks! I'm glad to help this awesome game :).

It's just a comma separated cvar, eg:
/set cg_filterWords "word1,word2"
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby /dev/random » Mon Apr 13, 2009 8:07 pm

Why is the variable name prefixed with cg while it actually part of cl?
And why is it part of cl anyways? As this is a systemcall, you could aswell filter everything inside cgame.
User avatar
/dev/random
Smokin' Amigo!
 
Posts: 410
Joined: Thu Jan 22, 2009 1:58 pm



Postby Allied » Mon Apr 13, 2009 8:27 pm

/dev/random wrote:Why is the variable name prefixed with cg while it actually part of cl?
And why is it part of cl anyways? As this is a systemcall, you could aswell filter everything inside cgame.


Prefixed with cg because I was (and still am a little) confused about the different game parts.

I made it in cl because I wanted it to be a pure compatible mod.
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby Lucky Bro » Sun Aug 16, 2009 10:30 am

Hi Allied and Tequila,

I see you already merged the patch into source.
I found the code during demo improvements investigation.
So I made my fix for this options for 1.1.
The code for discussion:
Index: code/client/cl_cgame.c
===================================================================
--- code/client/cl_cgame.c (revision 263)
+++ code/client/cl_cgame.c (working copy)
@@ -34,10 +34,6 @@
extern void startCamera(int time);
extern qboolean getCameraInfo(int time, vec3_t *origin, vec3_t *angles);

-#ifdef SMOKINGUNS
-char **badWords = NULL;
-int numWords;
-#endif
/*
====================
CL_GetGameState
@@ -416,37 +412,40 @@

====================
*/
-#ifdef SMOKINGUNS
char* fixBadWords(char *str)
{
- char *at;
- char wordBuf[4096];
- int cIndex;
+ char *pos;
+ char *wordStart;
+ char *wordEnd;
+ int wordLen;
int i;

- for( i=0;i<numWords;++i )
- {
- at = str;
+ wordStart = cl_filterWords->string;

- while( ( at = (char *)Q_stristr( at, badWords[i] ) ) )
- {
-#ifndef min
-#define min(a, b) (a) < (b) ? a : b
-#endif
- cIndex = min( strspn( at, "ABCDEFGHIIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" ), sizeof( wordBuf ) - 1 );
- memcpy( wordBuf, at, cIndex );
- wordBuf[cIndex] = '\0';
-
- if( ( Q_stricmp(badWords[i], wordBuf) == 0 ) && ( at == str || ( at[-1] == ' ' ) || ( at > ( str + 1 ) && at[-2] == '^' ) ) )
- Com_Memset( at, ' ', cIndex );
-
- ++at;
- }
+ while (*wordStart) {
+ wordLen = 0;
+ wordEnd = wordStart;
+ //Word length
+ while (*wordEnd) {
+ if (*wordEnd++ == ',')
+ break;
+ wordLen++;
+ }
+ pos = str;
+ while (*pos) {
+ if (Q_stricmpn(wordStart,pos,wordLen)==0){
+ //Replace word with *
+ for (i=0;i<wordLen;i++){
+ *pos = '*';
+ pos++;
+ }
+ }
+ pos++;
+ }
+ wordStart = wordEnd;
}
-
return str;
}
-#endif

/*
====================
@@ -458,11 +457,11 @@
intptr_t CL_CgameSystemCalls( intptr_t *args ) {
switch( args[0] ) {
case CG_PRINT:
-#ifndef SMOKINGUNS
- Com_Printf( "%s", (const char*)VMA(1) );
-#else
- Com_Printf( "%s", (const char*)fixBadWords( VMA(1) ) );
-#endif
+ if(cl_useFilterWords->integer) {
+ Com_Printf( "%s", (const char*)fixBadWords( VMA(1) ) );
+ } else {
+ Com_Printf( "%s", (const char*)VMA(1) );
+ }
return 0;
case CG_ERROR:
Com_Error( ERR_DROP, "%s", (const char*)VMA(1) );
@@ -773,61 +772,9 @@
const char *mapname;
int t1, t2;
vmInterpret_t interpret;
-#ifdef SMOKINGUNS
- int l;
- char *at;
- char blockThis[255];
- char *buf;
- char **tempBuf;
- int capacity = 40;
-#endif

t1 = Sys_Milliseconds();

- // Load language filter
-#ifdef SMOKINGUNS
- if( !badWords )
- {
- numWords = 0;
-
- buf = Cvar_VariableString( "cg_filterWords" );
-
- if( strlen( buf ) > 0 )
- {
- l = 0;
-
- badWords = Z_Malloc( capacity * sizeof( char* ) );
-
- at = buf;
- while( ( at = strchr( buf, ',' ) ) )
- {
- if( ( l-1 ) > capacity ) // ( l-1 ) because we want to leave room for the last word
- {
- tempBuf = Z_Malloc( ( capacity + 40 ) * sizeof( char** ) );
- Com_Memcpy( tempBuf, badWords, capacity * sizeof( char** ) );
- Z_Free( badWords );
- badWords = tempBuf;
-
- capacity += 40;
- }
-
- strncpy( blockThis, buf, ( strchr( buf, ',' ) - buf ) );
- blockThis[( strchr( buf, ',' ) - buf )] = '\0';
- badWords[l] = strdup( blockThis );
- buf = at + 1;
- ++l;
- }
-
- badWords[l] = strdup( buf );
- ++l;
-
- numWords = l;
- }
- else
- Com_Printf( "No filter loaded.\n" );
- }
-#endif
-
// put away the console
Con_Close();

Index: code/client/cl_main.c
===================================================================
--- code/client/cl_main.c (revision 263)
+++ code/client/cl_main.c (working copy)
@@ -99,6 +99,9 @@

cvar_t *cl_consoleKeys;

+cvar_t *cl_useFilterWords;
+cvar_t *cl_filterWords;
+
clientActive_t cl;
clientConnection_t clc;
clientStatic_t cls;
@@ -3125,6 +3128,9 @@

cl_showMouseRate = Cvar_Get ("cl_showmouserate", "0", 0);

+ cl_useFilterWords = Cvar_Get ("cl_useFilterWords", "0", CVAR_ARCHIVE);
+ cl_filterWords = Cvar_Get ("cl_filterWords", "", CVAR_ARCHIVE);
+
cl_allowDownload = Cvar_Get ("cl_allowDownload", "0", CVAR_ARCHIVE);
#ifdef USE_CURL
cl_cURLLib = Cvar_Get("cl_cURLLib", DEFAULT_CURL_LIB, CVAR_ARCHIVE);
Index: code/client/client.h
===================================================================
--- code/client/client.h (revision 263)
+++ code/client/client.h (working copy)
@@ -408,6 +408,9 @@

extern cvar_t *cl_consoleKeys;

+extern cvar_t *cl_useFilterWords;
+extern cvar_t *cl_filterWords;
+
#ifdef USE_MUMBLE
extern cvar_t *cl_useMumble;
extern cvar_t *cl_mumbleScale;


The patch file: FilterFix.patch

Two values:
cl_useFilterWords - on/off the feature (I don't need it for example, I'll think to code teamchatonly instead - I hate to read my opponents jokes, I'm really tired of it)
cl_filterWords - the words to filter. The words separated by ',' char.
If you want to filter complete word you have to put space characters before and after it, like that:
/cl_filterWords " wholeWord ,usualWord,complicated thing"

Feel free to ask questions about the fix.
Also I haven't seen the patch file by Allied (it is expired so I can't download it to be sure I fixed all), so maybe it was much better than merged one. But the current one merged to SVN isn't looking like good one to me. Especially because of messing with memory, some redundant variables and taking filter only once at the CL_init which isn't right.

The picture with working filter:
Image

EDIT: Also it would be nice if you, Allied, would update your first post with actual information.

Have a good day!
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Postby Allied » Mon Aug 17, 2009 4:30 pm

Howdy Bro,

I did this a while ago and can't remember that much of it. However I've updated the 1.1 download link so you'll be able to get that. I don't think I did any changes past then.

Hope that helps,
Allied
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby Lucky Bro » Mon Aug 17, 2009 4:39 pm

Yeah, a lot. Thank you, Allied.
Everything is ok after the patch.
Are you coding for SG still? There are lot of things to do.
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Postby FisherofMen » Tue Aug 18, 2009 6:50 pm

Ok, I have read through this thread and am now totally confused.

Is there a language filter? If yes, how do I use it?


I play as "The Duke" on SG and my son also plays alot. He goes by "[SbG] Dodo"

The problem is that my son is 13 years old and I find the language terribly offensive when my son is on.

Is this filter something I can do on my end? This is my only complaint about the game.
User avatar
FisherofMen
Drifter
 
Posts: 19
Joined: Tue Jul 14, 2009 2:38 pm



Postby Lucky Bro » Tue Aug 18, 2009 7:07 pm

Oh, sad to hear..

Now this filter is done for 1.1 client only :(

But I can do the quick patch for 1.0 in day or so (I'm just busy with enemyModel now).
I'll post it here within a day.
Then you'll just need to replace your binary with new one.
I can do only windows one. If you are using *nix system inform me here, then I'll ask Conq` to build *nix binary for you.
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Postby Allied » Tue Aug 18, 2009 7:31 pm

I haven't done any coding for SG since then, as a matter of fact I haven't even been able to play too much SG into the bargain :).

Fisher, as Bro said - right now there's only a language filter for 1.1, and the filter is in the official builds. It would probably be simplest to upgrade to 1.1 if you don't have it already.

If you do, bring up the console and type in:
Code: Select all
/seta cg_filterWords "word1,word2,..."


Naturally, replace word1, etc with whatever you want. For extra clarification, if you want to filter "swear" and "curse", then you'd do this:

Code: Select all
/seta cg_filterWords "swear,curse"


To add words later, you'll either have to retype in the entire filter string, or edit your q3config (I recommend the latter).
Last edited by Allied on Tue Aug 18, 2009 7:38 pm, edited 1 time in total.
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby FisherofMen » Tue Aug 18, 2009 7:36 pm

Thanks guys!!


Windows user. :D
User avatar
FisherofMen
Drifter
 
Posts: 19
Joined: Tue Jul 14, 2009 2:38 pm



Postby Lucky Bro » Wed Aug 19, 2009 10:08 am

FisherofMen,

Here your stuff:
smokingunsWF.exe
smokingunsWFnoOpenAL.exe
(Grab the first one if you have openAl installed or second if you don't have openAl installed)
Don't replace anything! Just pup them near your main exe and launch the game from them.
If you want to prevent your son to play usual one - rename old exe to smokinguns.exe.old and rename the new one as smokinguns.exe.
To configure the filter check my previous post (with screenshot).
If you have any suggestions/questions - feel free to ask :)
If you don't like '*' char and want it to be ' ' - let me or Allied know - it is one line to fix :) But I prefer '*'.
Also you won't ever know what your opponent have said to you. Even in logs :( I think we could figure out something about it, but just not now. I'm not interesting in that to be honest.
Also I think you have to know how the filter is working to make it more powerful:
It just takes the words divided by ',' character from cl_filterWords variable (space characters are part of "words" too). And each time when you got any message in console it will be filtered by replacing these words with asterisks.
So, actually about separated word it won't be so easy like to place space characters before and after (because such word could be at the beginning or end of the string) - don't use such techniques :(
Just for now it will sometimes replace parts of good words if bad word is included in good one :( We'll need to implement whole grep (*nix one tool) tool for such proposes :)
And one more note - the variable cl_filterWords are not endless, so be aware about it.

About configuration file - it will be in your configuration file once you'll set it in console. Just don't explain your son how to do it.. or we'll have to do some parental control :)

The patch source code (the same as for 1.1):
FilterWords1.0.patch

Have a good day!
"You should know that the lies won't hide your flaws/No sense in hiding all of yours/You gave up on your dreams along the way" (c) "Fake it" by Seether
P.S. English isn't my native language.
User avatar
Lucky Bro
Gunslinger
 
Posts: 143
Joined: Mon Mar 09, 2009 4:12 pm



Previous

Return to Code

Show Sidebar
Show Sidebar

User Control Panel

cron