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

A few patches

Postby Conq » Sun May 31, 2009 5:00 pm

Hello world !

I discovered smokin' guns a few weeks ago.
As I found this game wonderful, I decided to browse a little bit the code & modify a few things :-).

First, I would like to answer to VBO's thread.
Tremfusion dev team did a patch (not perfect for the moment) about it for their codebase.
If you're interested in, here is the thread about it, & tremfusion's code.
P.S: There are still problems with intel chipsets with this patch.

I also did a few patches from release 229 of 1.1 branch.

The first files that I modified were Makefile & Makefile.local in order to have the power to compile with our own cflags if USE_CUSTOM_CFLAGS is equal to 1.

Code: Select all
Index: Makefile
===================================================================
--- Makefile   (révision 229)
+++ Makefile   (copie de travail)
@@ -46,8 +46,8 @@
   BUILD_MISSIONPACK=
 endif
 
-ifneq ($(PLATFORM),darwin)
-  BUILD_CLIENT_SMP = 0
+ifndef USE_CUSTOM_CFLAGS
+  USE_CUSTOM_CFLAGS=0
 endif
 
 #############################################################################
@@ -148,6 +148,10 @@
 USE_LOCAL_HEADERS=1
 endif
 
+ifneq ($(PLATFORM),darwin)
+  BUILD_CLIENT_SMP = 0
+endif
+
 #############################################################################
 
 BD=$(BUILD_DIR)/debug-$(PLATFORM)-$(ARCH)
@@ -272,19 +276,31 @@
     BASE_CFLAGS += -DUSE_CODEC_VORBIS
   endif
 
-  OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer
+  ifeq ($(USE_CUSTOM_CFLAGS),0)
+    OPTIMIZE = -O3 -ffast-math -funroll-loops -fomit-frame-pointer
+  else
+    OPTIMIZE = ${CUSTOM_CFLAGS}
+  endif
 
   ifeq ($(ARCH),x86_64)
-    OPTIMIZE = -O3 -fomit-frame-pointer -ffast-math -funroll-loops \
-      -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
-      -fstrength-reduce
+    ifeq ($(USE_CUSTOM_CFLAGS),0)
+      OPTIMIZE = -O3 -fomit-frame-pointer -ffast-math -funroll-loops \
+        -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
+        -fstrength-reduce
+    else
+      OPTIMIZE = ${CUSTOM_CFLAGS}
+    endif
     # experimental x86_64 jit compiler! you need GNU as
     HAVE_VM_COMPILED = true
   else
   ifeq ($(ARCH),i386)
-    OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \
-      -funroll-loops -falign-loops=2 -falign-jumps=2 \
-      -falign-functions=2 -fstrength-reduce
+    ifeq ($(USE_CUSTOM_CFLAGS),0)
+      OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \
+        -funroll-loops -falign-loops=2 -falign-jumps=2 \
+        -falign-functions=2 -fstrength-reduce
+    else
+      OPTIMIZE = ${CUSTOM_CFLAGS}
+    endif
     HAVE_VM_COMPILED=true
   else
   ifeq ($(ARCH),ppc)
@@ -471,9 +487,13 @@
     BASE_CFLAGS += -DUSE_CODEC_VORBIS
   endif
 
-  OPTIMIZE = -O3 -march=i586 -fno-omit-frame-pointer -ffast-math \
-    -falign-loops=2 -funroll-loops -falign-jumps=2 -falign-functions=2 \
-    -fstrength-reduce
+  ifeq ($(USE_CUSTOM_CFLAGS),0)
+    OPTIMIZE = -O3 -march=i586 -fno-omit-frame-pointer -ffast-math \
+      -falign-loops=2 -funroll-loops -falign-jumps=2 -falign-functions=2 \
+      -fstrength-reduce
+  else
+    OPTIMIZE = ${CUSTOM_CFLAGS}
+  endif
 
   HAVE_VM_COMPILED = true
 
@@ -562,10 +582,16 @@
       -fomit-frame-pointer -fexpensive-optimizations
   else
   ifeq ($(ARCH),i386)
-    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 -mtune=pentiumpro \
-      -march=pentium -fomit-frame-pointer -pipe -ffast-math \
-      -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
-      -funroll-loops -fstrength-reduce
+    ifeq ($(USE_CUSTOM_CFLAGS),0)
+      OPTIMIZE= -O3 -mtune=pentiumpro -march=pentium \
+        -fomit-frame-pointer -pipe -ffast-math \
+        -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
+        -funroll-loops -fstrength-reduce
+    else
+      OPTIMIZE= ${CUSTOM_CFLAGS}
+    endif
+
+    RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE)
     HAVE_VM_COMPILED=true
   else
     BASE_CFLAGS += -DNO_VM_COMPILED
@@ -623,10 +649,16 @@
   endif
 
   BASE_CFLAGS += -DNO_VM_COMPILED -I/usr/X11R6/include -I/usr/local/include
-  RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3 \
-    -march=pentium -fomit-frame-pointer -pipe -ffast-math \
-    -falign-loops=2 -falign-jumps=2 -falign-functions=2 \
-    -funroll-loops -fstrength-reduce
+
+  ifeq ($(USE_CUSTOM_CFLAGS),0)
+    OPTIMIZE = -O3 -march=pentium -fomit-frame-pointer -pipe \
+      -ffast-math -falign-loops=2 -falign-jumps=2 \
+      -falign-functions=2 -funroll-loops -fstrength-reduce
+  else
+    OPTIMIZE = ${CUSTOM_CFLAGS}
+  endif
+
+  RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG $(OPTIMIZE)
   HAVE_VM_COMPILED=false
 
   DEBUG_CFLAGS=$(BASE_CFLAGS) -g
@@ -696,7 +728,14 @@
 
   BASE_CFLAGS=-Dstricmp=strcasecmp -Xcpluscomm -woff 1185 \
     -I. $(SDL_CFLAGS) -I$(ROOT)/usr/include -DNO_VM_COMPILED
-  RELEASE_CFLAGS=$(BASE_CFLAGS) -O3
+
+  ifeq ($(USE_CUSTOM_CFLAGS),0)
+    OPTIMIZE = -O3
+  else
+    OPTIMIZE = ${CUSTOM_CFLAGS}
+  endif
+
+  RELEASE_CFLAGS=$(BASE_CFLAGS) $(OPTIMIZE)
   DEBUG_CFLAGS=$(BASE_CFLAGS) -g
 
   SHLIBEXT=so
@@ -736,19 +775,31 @@
   BASE_CFLAGS = -Wall -fno-strict-aliasing -Wimplicit -Wstrict-prototypes \
     -pipe -DUSE_ICON $(SDL_CFLAGS)
 
-  OPTIMIZE = -O3 -ffast-math -funroll-loops
+  ifeq ($(USE_CUSTOM_CFLAGS),0)
+    OPTIMIZE = -O3 -ffast-math -funroll-loops
+  else
+    OPTIMIZE = ${CUSTOM_CFLAGS}
+  endif
 
   ifeq ($(ARCH),sparc)
-    OPTIMIZE = -O3 -ffast-math \
-      -fstrength-reduce -falign-functions=2 \
-      -mtune=ultrasparc3 -mv8plus -mno-faster-structs \
-      -funroll-loops #-mv8plus
+    ifeq ($(USE_CUSTOM_CFLAGS),0)
+      OPTIMIZE = -O3 -ffast-math \
+        -fstrength-reduce -falign-functions=2 \
+        -mtune=ultrasparc3 -mv8plus -mno-faster-structs \
+        -funroll-loops #-mv8plus
+    else
+      OPTIMIZE = ${CUSTOM_CFLAGS}
+    endif
     HAVE_VM_COMPILED=true
   else
   ifeq ($(ARCH),i386)
-    OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \
-      -funroll-loops -falign-loops=2 -falign-jumps=2 \
-      -falign-functions=2 -fstrength-reduce
+    ifeq ($(USE_CUSTOM_CFLAGS),0)
+      OPTIMIZE = -O3 -march=i586 -fomit-frame-pointer -ffast-math \
+        -funroll-loops -falign-loops=2 -falign-jumps=2 \
+        -falign-functions=2 -fstrength-reduce
+    else
+      OPTIMIZE = ${CUSTOM_CFLAGS}
+    endif
     HAVE_VM_COMPILED=true
     BASE_CFLAGS += -m32
     BASE_CFLAGS += -I/usr/X11/include/NVIDIA
@@ -782,7 +833,7 @@
 #############################################################################
   BASE_CFLAGS=-DNO_VM_COMPILED
   DEBUG_CFLAGS=$(BASE_CFLAGS) -g
-  RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG -O3
+  RELEASE_CFLAGS=$(BASE_CFLAGS) -DNDEBUG
 
   SHLIBEXT=so
   SHLIBCFLAGS=-fPIC

Code: Select all
Index: Makefile.local
===================================================================
--- Makefile.local   (révision 229)
+++ Makefile.local   (copie de travail)
@@ -12,7 +12,7 @@
 endif
 ifeq ($(BUILD_SERVER),)
   # Build server by default
-  BUILD_SERVER     = 1
+  BUILD_SERVER     = 0
 endif
 ifeq ($(BUILD_GAME_SO),)
   # Don't build binary game by default
@@ -20,8 +20,13 @@
 endif
 ifeq ($(BUILD_GAME_QVM),)
   # Build QVM game by default
-  BUILD_GAME_QVM   = 1
+  BUILD_GAME_QVM   = 0
 endif
+
+ifeq ($(USE_CUSTOM_CFLAGS),1)
+  CUSTOM_CFLAGS=$(CFLAGS)
+endif
+
 ########################################################################
 # Don't modify the following or the build will just be broken
 BUILD_STANDALONE  = 1


I also applied a cellshading patch which I found in games/iourbanterror port's extra files. But he looks to work only with r_celoutline (I'll fix it later).

As I had to cross-compile a 1.1 client for friends who use windows ( :? ), I had to apply tremfusion's patches for cross-make-mingw.sh.
Here it is :
Code: Select all
Index: cross-make-mingw.sh
===================================================================
--- cross-make-mingw.sh   (révision 229)
+++ cross-make-mingw.sh   (copie de travail)
@@ -1,6 +1,24 @@
 #!/bin/sh
 
-export CC=i586-mingw32msvc-gcc
-export WINDRES=i586-mingw32msvc-windres
-export PLATFORM=mingw32
-exec make $*
+COMPILE_PLATFORM=`uname|sed -e s/_.*//|tr '[:upper:]' '[:lower:]'`
+
+if [ "$COMPILE_PLATFORM" = "darwin" ]
+then
+ export CC=i386-mingw32msvc-gcc
+ export WINDRES=i386-mingw32msvc-windres
+ export PLATFORM=mingw32
+ MAKE=make
+elif [ "$COMPILE_PLATFORM" = "freebsd" ]
+then
+ export CC=mingw32-gcc
+ export WINDRES=mingw32-windres
+ export PLATFORM=mingw32
+ MAKE=gmake
+else
+ export CC=i586-mingw32msvc-gcc
+ export WINDRES=i586-mingw32msvc-windres
+ export PLATFORM=mingw32
+fi
+
+exec $MAKE $*
+


I'll propose more client/server patches later. :wink:
Conq
Drifter
 
Posts: 13
Joined: Sun May 31, 2009 9:37 am



Postby Tequila » Sun May 31, 2009 11:49 pm

Welcome Conq and thanks for your proposition.

Btw, I don't like your patch as the Makefile one modifies parts I want to keep as close as possible from the ioQuake3 engine sources. Also you're proposing to modify default settings without good explanation, be careful about that.

About the Makefile.local, it is a convenient place for everyone to modify some defaults used to build the engine and the game in their environment. So you can just use it as an example and we will only change it if really needed. You may have noticed there is here a STANDALONE_CFLAGS, maybe you should have just use it for your own CFLAGS. Try it and tell us.

Then for the cross-make-mingw.sh, I think I may merge it with my own I'm using to cross compile on Fedora 10 ;) But have you the original reference from Tremfusion ?

About cellshading, wtf with your link ? Don't propose to download a big file with only a very little useful part :P Didn't you find that patch elsewhere ? Btw for such stuff you should really propose a screenshot result that we can see if it is really interesting... I still tried the one from ioQuake3 extra patches page but the result was not so excellent with SG and maps where very much long to load... If you really want to try port something like that, can you try the one proposed in that ioQuake enhancement proposal ? It's about to use GLSL buffer with a rotoscope rendering effect !!! I think EvilFutsin will be totally amazed if you do it :D I would love to do it myself, but I may be later... after I have finished to fix some really annoying bugs and we have released the next update ;)

If you want to propose other client/server patch, take a look at the kicking stuff for which some people are complaining it doesn't work as it is expected (search the forum for that or maybe rane will point you to the right threads ;) ).

Thanks for your contribution ;)
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Tequila » Sun May 31, 2009 11:55 pm

Tequila wrote:Then for the cross-make-mingw.sh, I think I may merge it with my own I'm using to cross compile on Fedora 10 ;) But have you the original reference from Tremfusion ?

In fact I just found the reference, but it seems you made a little mistake, here is the original patch:
http://www.tremfusion.net/hg/tremfusion ... e-mingw.sh
8)
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Conq » Mon Jun 01, 2009 8:45 am

Hello Tequila.

Unfortunately, I didn't see the STANDALONE_CFLAGS variable when I tried to compile a client with my own CFLAGS. That's why I modified the Makefile :D.
Edit: I tried to compile a client with my CFLAGS in STANDALONE_CFLAGS. That seems to don't work because my cflags are first, so they are erased by OPTIMIZE :/. I think the solution could be to place STANDALONE_CFLAGS at the end of RELEASE/DEBUG_CFLAGS.

Concerning the cross-make-mingw.sh, I modified the one from tremfusion in order to don't repeat code, have less lines (5 less for the same result). This is not a mistake :)
edit: Woops, I forgot the "MAKE=make" for default, here is the correction.

About cellshading, I had this very bad result while loading map too. The patch that I tried was the one for ioUrbanTerror that you can find there. Btw, I'll try the ioQuake3 patch ;p.
I also know that tremfusion included a bunch of new graphical effects in their renderer like r_bloom & co. I think I'll port them too.

The QVM build perfectly works on my system. I obtain the three : ui, cgame & qagame.qvm that are needed by the game. I think I'll do a perl/python script to propose to the user to build them & install them in a mod directory like "~/.smokinguns/myFantasticMod/vm", or better : Compress them into a "$modname-$version-vms.pk3" & install it in the mod directory.
However, I can't run any mod with the current dedicated server build : It crashes (Even with default ! ><)

Concerning the game code, I think we could provide more mod diversity by grouping all the constants needed by smokinguns into a "code/game/smokinguns.h". (I already did an example file that you can found here
I also think that we could put all the weapon animation stuff into a file that will be parsed during loading, so weapon animations would no longer need to rebuild QVMs :).
Conq
Drifter
 
Posts: 13
Joined: Sun May 31, 2009 9:37 am



Postby Tequila » Mon Jun 01, 2009 3:03 pm

Conq wrote:Unfortunately, I didn't see the STANDALONE_CFLAGS variable when I tried to compile a client with my own CFLAGS. That's why I modified the Makefile :D.
Edit: I tried to compile a client with my CFLAGS in STANDALONE_CFLAGS. That seems to don't work because my cflags are first, so they are erased by OPTIMIZE :/. I think the solution could be to place STANDALONE_CFLAGS at the end of RELEASE/DEBUG_CFLAGS.

Well, have you noticed the "debug" & "release" targets in the Makefile ? They are just showing you how you can use your own CFLAGS... I really think that's the way you should use.

Conq wrote:Concerning the cross-make-mingw.sh, I modified the one from tremfusion in order to don't repeat code, have less lines (5 less for the same result). This is not a mistake :)
edit: Woops, I forgot the "MAKE=make" for default, here is the correction.

You're still wrong in one case... the "$COMPILE_PLATFORM" = "darwin" case, mac users may want to cross-compile too ;)

Conq wrote:About cellshading, I had this very bad result while loading map too. The patch that I tried was the one for ioUrbanTerror that you can find there. Btw, I'll try the ioQuake3 patch ;p.
I also know that tremfusion included a bunch of new graphical effects in their renderer like r_bloom & co. I think I'll port them too.

Remember we want to support good old computer config as many players still have old but good computer... If your patches are so great (but you need to show some results) we may accept them in an "experimental" and definitively not official new branch.

Conq wrote:The QVM build perfectly works on my system. I obtain the three : ui, cgame & qagame.qvm that are needed by the game. I think I'll do a perl/python script to propose to the user to build them & install them in a mod directory like "~/.smokinguns/myFantasticMod/vm", or better : Compress them into a "$modname-$version-vms.pk3" & install it in the mod directory.
However, I can't run any mod with the current dedicated server build : It crashes (Even with default ! ><)

Are you talking about using 1.1 game QVM with 1.0 engine ? That makes no sens and is not supported by 1.0 engine.
By the way, don't waste your time with the perl/python tool as you can just improve the "copyfiles" target in the main Makefile if you want.

Conq wrote:Concerning the game code, I think we could provide more mod diversity by grouping all the constants needed by smokinguns into a "code/game/smokinguns.h". (I already did an example file that you can found here
I also think that we could put all the weapon animation stuff into a file that will be parsed during loading, so weapon animations would no longer need to rebuild QVMs :).

That could be a good idea. But today we really need to focus on fixing the last annoying bugs. Smokin' Guns game really need that fixes if we want to enhance definitively the new players faithfulness ;)
You know, I'm working on the annoying stucked respawn bug as good players like rane complains often about that. On such bug, we need help. That's not always sexy but you'll obtain general recognition. Tell me that's what you want :D

But please, just try to focus on one thing at a time. I know it's difficult as I have sometime difficulties to work like that myself :P but try !
User avatar
Tequila
SG Team
 
Posts: 1100
Joined: Thu Nov 15, 2007 11:33 pm
Location: Montpellier, France



Postby Conq » Mon Jun 01, 2009 4:49 pm

Well, the result I obtained in SG's build was with the release way, the one that allow people to use RELEASE_CFLAGS combined with OPTIMIZE variable unlike the debug way which only allow people to build with -g, -O0 & some needed cflags :\.

Concerning darwin cross-compilation, I don't see were it could be false because variable's values are the one of a mac OS user (& tremfusion's cross-make-mingw by the way). If tremfusion's script is correct, mac user can cross-compile too :D (I don't use linux & mac os, so I don't know exactly what works & what doesn't on those systems :s).

About tremfusion's renderer, the modifications will not ask too much if you don't use them by setting the variables to 1 or more ;-).

By the way, the qvms that I tried to build were based on 1.1 branch, & they worked with 1.1 client, but not with the dedicated binary.

Anyway, do you have a list of bugs to fix ? That would be great to know what are the prior things to do :D

P.S: By the way, I finished a code improvement for g_cmds.c inspired by tremfusion. That set the commands in a command_t table which allows you to set flags on it like "CMD_CHEAT, CMD_LIVING ...". If you're interested, here is the code. ;-). Besides I did only a few tests on those commands & I know them only by the code, there are maybe many mistakes that I didn't spot yet :s.
Conq
Drifter
 
Posts: 13
Joined: Sun May 31, 2009 9:37 am




Return to Code

Show Sidebar
Show Sidebar

User Control Panel