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

Language filter

Postby Allied » Wed Apr 08, 2009 12:25 am

Howdy all,

Thought I'd contribute my mod for general benefit. Perhaps the devs would like to add it to the next release :).

The provided .C source file is the one from the ioQuake 3 backport. Yes, I have tested it. I created the patch file using TortoiseSVN. I hope someone finds these useful.

Please see further posts for download link. Updated for 1.1.
Last edited by Allied on Mon Aug 17, 2009 4:26 pm, edited 1 time in total.
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby -]DES[- Player_3 » Wed Apr 08, 2009 6:31 pm

A Language Filter? That's awesome man! I was on a server one time and some guy on there was swearing up a storm :(

is it client side or server side?
User avatar
-]DES[- Player_3
Quick Draw
 
Posts: 61
Joined: Fri Sep 19, 2008 3:31 am



Postby Allied » Wed Apr 08, 2009 6:38 pm

Client side. You just have to compile SG with either a patched cl_cgame.c, or with the cl_cgame.c I have provided. If you're compiling the non-io version, use the patch.
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby sparcdr » Wed Apr 08, 2009 8:37 pm

Send Tequila a pm about it, and if he takes too long I'll see about merging it if I find it complete enough.
sparcdr
SG Team
 
Posts: 334
Joined: Wed Jun 13, 2007 3:41 pm



Postby Tequila » Wed Apr 08, 2009 9:17 pm

Yep guys, I still checked a little the code this morning ;)
It looks clean. I will try to merge it checking if we can use still existing API btw.

Allied can you provide some example of filtering data file ?
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Allied » Wed Apr 08, 2009 9:55 pm

Here is a sample filter, I created it using WordPad for "generic" usage. As you probably know, it loads it from the base game folder.

Glad to be of some help!

Sample Filter
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby Allied » Thu Apr 09, 2009 1:33 am

After doing some more tests with my build, I found a small problem. Sometimes after the second or third map load it would crash. I believe I have fixed it and have updated the ZIP file accordingly. Please redownload before using ;).
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby Tequila » Thu Apr 09, 2009 5:49 pm

Then I tried to integrate your mod in the 1.1 branch. I got a lot of compilation problems. I look a little more on the code and here are few comments I want you to consider ;)
1. Can you try the current 1.1 branch ?
2. Can you try then to use Q_stristr instead of adding your own stristr in cl_cgame.c ?
3. Can you check to use Q_stricmp also ?
4. On which platform are you modding ? It seems mine (Linux) knows nothing of "strnset", then can you find a way to replace it ?
5. Can you take a look at Sys_ListFiles and try to use the same APIs for memory allocations ?
6. Why did you focus on a filter file ? Why not using a dedicated cvar we can edit directly in the game ? Even if we are limited in size, your cvar will be stored in standard configuration.
7. Why not simply discard a message which contains a badword ?
8. You should check eventually to use the Q_CleanStr API before parsing the message so you won't have color pollution.
9. Finally, can you active compiler warnings when you build your engine ? You'll see some important casting warnings that I don't want to see before merging a code ;)

For you to know, here is the result of my compilation with a simple merging process:
Code: Select all
CC code/client/cl_cgame.c
code/client/cl_cgame.c: In function 'stristr':
code/client/cl_cgame.c:431: warning: implicit declaration of function 'strupr'
code/client/cl_cgame.c: In function 'fixBadWords':
code/client/cl_cgame.c:456: warning: suggest parentheses around assignment used as truth value
code/client/cl_cgame.c:458: warning: implicit declaration of function 'min'
code/client/cl_cgame.c:462: warning: implicit declaration of function 'stricmp'
code/client/cl_cgame.c:463: warning: implicit declaration of function 'strnset'
code/client/cl_cgame.c: In function 'CL_InitCGame':
code/client/cl_cgame.c:828: warning: pointer targets in assignment differ in signedness
code/client/cl_cgame.c:829: warning: pointer targets in passing argument 1 of '__builtin_strchr' differ in signedness
code/client/cl_cgame.c:829: warning: suggest parentheses around assignment used as truth value
code/client/cl_cgame.c:833: warning: pointer targets in passing argument 1 of '__builtin_strchr' differ in signedness
code/client/cl_cgame.c:833: error: invalid operands to binary - (have 'char *' and 'byte *')
code/client/cl_cgame.c:833: warning: pointer targets in passing argument 2 of '__builtin_strncpy' differ in signedness
code/client/cl_cgame.c:834: warning: pointer targets in passing argument 1 of '__builtin_strchr' differ in signedness
code/client/cl_cgame.c:834: error: invalid operands to binary - (have 'char *' and 'byte *')
code/client/cl_cgame.c:836: warning: pointer targets in assignment differ in signedness
code/client/cl_cgame.c:842: warning: pointer targets in passing argument 1 of 'strlen' differ in signedness
code/client/cl_cgame.c:842: warning: pointer targets in passing argument 1 of '__strdup' differ in signedness
make[2]: *** [build/release-linux-x86_64/client/cl_cgame.o] Error 1

I can manage to remove some but that won't be your code any more then.
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Allied » Thu Apr 09, 2009 7:03 pm

Tequila wrote:Then I tried to integrate your mod in the 1.1 branch. I got a lot of compilation problems. I look a little more on the code and here are few comments I want you to consider ;)
1. Can you try the current 1.1 branch ?


How do I merge it with the trunk in order to compile it? There appear to be significant changes, such as q_shared being moved to qcommon.

Tequila wrote:2. Can you try then to use Q_stristr instead of adding your own stristr in cl_cgame.c ?
3. Can you check to use Q_stricmp also ?


Done, because I haven't got 1.1 compiling I placed the necessary code into cl_cgame to test it. I have now changed it to those.

Tequila wrote:...4. On which platform are you modding ? It seems mine (Linux) knows nothing of "strnset", then can you find a way to replace it ?


Windows Vista, Visual C++ Express Edition 2008. I've replaced strnset with Com_Memset.

Tequila wrote:5. Can you take a look at Sys_ListFiles and try to use the same APIs for memory allocations ?


Done, replaced with Z_Malloc and a change in method of working instead of realloc.

Tequila wrote:6. Why did you focus on a filter file ? Why not using a dedicated cvar we can edit directly in the game ? Even if we are limited in size, your cvar will be stored in standard configuration.


I didn't think of doing this, my first idea was just a file.

I've now changed it to use cg_filterWords. A much better implementation, thank you :). This has changed some of it quite a bit. I'll update the ZIP when we've sorted out the 1.1 question - if that is still necessary.

Tequila wrote:7. Why not simply discard a message which contains a badword ?
8. You should check eventually to use the Q_CleanStr API before parsing the message so you won't have color pollution.


Because perhaps it's a team game, and there may be useable information as well. I don't think I could use Q_CleanStr too easily, since I really don't think a discarding method would be good.

Tequila wrote:9. Finally, can you active compiler warnings when you build your engine ? You'll see some important casting warnings that I don't want to see before merging a code ;)


Due to the restructuring and removing of stristr, there is no more casting and the warnings are gone :).

Tequila wrote:I can manage to remove some but that won't be your code any more then.


"My" code or not doesn't really matter - but you have more important things to be working on and this was my contribution - intended to help and not hinder active development :).
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby sparcdr » Sat Apr 11, 2009 2:40 am

1.1 builds on Windows now (VC9) but QVM build process is broken. The engine itself does build, so you can go ahead and try and merge with revision 182 and see how that goes.
sparcdr
SG Team
 
Posts: 334
Joined: Wed Jun 13, 2007 3:41 pm



Postby Allied » Sat Apr 11, 2009 7:55 am

sparcdr wrote:1.1 builds on Windows now (VC9) but QVM build process is broken. The engine itself does build, so you can go ahead and try and merge with revision 182 and see how that goes.


How will I get the project to build correctly with the changed structure? The existing trunk project uses the old file locations, such as q_shared in game not qcommon.
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby sparcdr » Sat Apr 11, 2009 8:37 am

The current trunk is the "stable" release (1.0) whereas the 1.1 branch is located in /branches/1.1. You would want to use something like WinMerge to compare differences on the key files you view you're going to have problems with. Bits which were merged can be compared against differing source files because these code segments exist in both.
sparcdr
SG Team
 
Posts: 334
Joined: Wed Jun 13, 2007 3:41 pm



Postby Allied » Sat Apr 11, 2009 10:50 pm

Well I've been unable to get it to compile, I tried merging with the latest 1.1 branch. Loads of errors while compiling. However I was able to get a 1.1 branch cl_cgame.c to compile in the 1.0 project. I had to bring in several 1.1 files and hack them a little but it does compile. I put my new mod into that and it's compiling without any casting warnings ;).

Here is the ZIP with the patch to 1.1 cl_cgame.c and the modded cl_cgame.c from 1.1:
Updated LF

This ought to go in without any problems, at least judging by Tequila's comments.
Last edited by Allied on Mon Aug 17, 2009 4:26 pm, edited 1 time in total.
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Postby Tequila » Sat Apr 11, 2009 11:00 pm

:D
Well it looks prettier then, but did you forget something ?
How is the badWords array loaded ?

Thanks to have followed my advice ;)
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Allied » Sat Apr 11, 2009 11:26 pm

Tequila wrote::D
Well it looks prettier then, but did you forget something ?
How is the badWords array loaded ?

Thanks to have followed my advice ;)


How embarrassing :), yes I did forget to put back the Cvar load. ZIP file updated, you can redownload now.
User avatar
Allied
Quick Draw
 
Posts: 67
Joined: Tue Feb 24, 2009 8:27 pm



Next

Return to Code

Show Sidebar
Show Sidebar

User Control Panel

cron