Merge branch 'osxnetradiant'
authorRudolf Polzer <rpolzer@grawp.(none)>
Sun, 28 Mar 2010 17:32:53 +0000 (19:32 +0200)
committerRudolf Polzer <rpolzer@grawp.(none)>
Sun, 28 Mar 2010 17:32:53 +0000 (19:32 +0200)
Conflicts:
contrib/bobtoolz/DPatch.cpp
contrib/bobtoolz/bobToolz-GTK.cpp
contrib/bobtoolz/funchandlers-GTK.cpp
install-dylibs.sh
setup/data/osx/NetRadiant.app/Contents/MacOS/netradiant.sh

52 files changed:
COMPILING
Makefile
Makefile.conf
contrib/bkgrnd2d/plugin.cpp
contrib/bobtoolz/bobToolz-GTK.cpp
contrib/bobtoolz/funchandlers-GTK.cpp
contrib/gtkgensurf/bitmap.cpp
contrib/gtkgensurf/dec.cpp
contrib/gtkgensurf/font.cpp
contrib/gtkgensurf/gendlgs.cpp
contrib/gtkgensurf/gensurf.cpp
download-gamepacks.sh [new file with mode: 0644]
include/ientity.h
include/ifilter.h
install-gamepack.sh [new file with mode: 0644]
libs/entitylib.h
libs/imagelib.h
libs/l_net/l_net.c
libs/uniquenames.h
mingw-Makefile.conf [new file with mode: 0644]
plugins/entity/entity.cpp
plugins/entity/generic.cpp
plugins/imagepng/plugin.cpp
plugins/vfspk3/vfs.cpp
radiant/brushmanip.cpp
radiant/entity.cpp
radiant/filters.cpp
radiant/xywindow.cpp
tools/quake3/common/vfs.c
tools/quake3/common/vfs.h
tools/quake3/q3map2/game_darkplaces.h
tools/quake3/q3map2/game_dq.h
tools/quake3/q3map2/game_ef.h
tools/quake3/q3map2/game_etut.h
tools/quake3/q3map2/game_ja.h
tools/quake3/q3map2/game_jk2.h
tools/quake3/q3map2/game_nexuiz.h
tools/quake3/q3map2/game_prophecy.h
tools/quake3/q3map2/game_qfusion.h
tools/quake3/q3map2/game_quake3.h
tools/quake3/q3map2/game_quakelive.h
tools/quake3/q3map2/game_sof2.h
tools/quake3/q3map2/game_tenebrae.h
tools/quake3/q3map2/game_tremulous.h
tools/quake3/q3map2/game_wolf.h
tools/quake3/q3map2/game_wolfet.h
tools/quake3/q3map2/light.c
tools/quake3/q3map2/light_bounce.c
tools/quake3/q3map2/light_ydnar.c
tools/quake3/q3map2/q3map2.h
tools/quake3/q3map2/surface.c
tools/quake3/q3map2/surface_meta.c

index e6840ba..9ac19a8 100644 (file)
--- a/COMPILING
+++ b/COMPILING
@@ -14,11 +14,9 @@ The subversion client can be obtained from the Subversion site.
 
 To get a copy of the source using the commandline Subversion client:
   Change the current directory to the desired location for the source.
-  svn checkout http://emptyset.endoftheinternet.org/svn/radiant15/trunk/ ./GtkRadiant
-  svn checkout -r29 https://zerowing.idsoftware.com/svn/radiant.gamepacks/Q3Pack/trunk/ ./GtkRadiant/games/Q3Pack
-  svn checkout https://zerowing.idsoftware.com/svn/radiant.gamepacks/UFOAIPack/branches/1.5/ ./GtkRadiant/games/UFOAIPack
-  For other game packs, see https://zerowing.idsoftware.com/svn/radiant.gamepacks/
-  Note that they must be in GtkRadiant 1.5's format (like the ones in a branches/1.5 subfolder)!
+  svn checkout http://svn.icculus.org/netradiant/trunk/ NetRadiant
+  cd NetRadiant
+  sh download-gamepacks.sh
 
 
 
@@ -53,33 +51,36 @@ environment:
 - fink installed
 - the following fink packages installed:
   gtkglext1 pkgconfig glib2-dev libxml2 gtk+2-dev pango1-xft2-dev atk-dev atk1 gettext-dev
+- Subversion must be installed and available in PATH to download the game packs
 
 build:
 run 'make'
 
 run:
-???
+Switch into the install folder, and run NetRadiant.app
 
-Jva32 (2000, KC be Ivfgn)
+Win32 (2000, XP, Vista or Windows 7)
 ==================
 
-raivebazrag:
-- ivfhny fghqvb 2005
-- clguba 2.3.0 be yngre (fbzr ohvyq fgrcf hfr clguba)
-- fhoirefvba 1.1 be yngre (fbzr ohvyq fgrcf hfr fia)
-
-qrcraqrapvrf ner cercnpxntrq nepuvirf, rkgenpg gurz gb gur qverpgbel nobir TgxEnqvnag.fya:
-- uggc://mrebjvat.vqfbsgjner.pbz/svyrf/enqvnag/qrirybcre/1.5/tgxenqvnag-1.5-qrcraqrapvrf-1.0.mvc
-
-ohvyq:
-Bcra TgxEnqvnag.fya.
-Va gbbyf > bcgvbaf > cebwrpgf > IP++ Qverpgbevrf > rkrphgnoyrf, nqq gur cnguf gb clguba.rkr (r.t. p:\clguba23\) naq fia.rkr (r.t. p:\fia\)
-Uvg 'Ohvyq > Ohvyq Fbyhgvba' (S7)
+environment:
+- MinGW
+  http://www.mingw.org/wiki/HOWTO_Install_the_MinGW_GCC_Compiler_Suite (the installer link)
+  Install this to c:\mingw, and select the components C compiler, C++ compiler, Make
+- MSYS
+  http://www.mingw.org/wiki/msys (you need the installer MSYS-versionnumber.exe)
+  Install this to c:\msys\1.0
+- Prepackaged Radiant dependencies (Gtk and other stuff):
+  http://www.icculus.org/netradiant/files/radiant-deps-mingw32.zip
+  Preferably extract this one to c:\mingw\radiant-deps-mingw32
+- Subversion must be installed and available in PATH to download the game packs
 
-vafgnyy:
-eha 'clguba ./TgxEnqvnag/vafgnyy.cl'
-abgr - guvf fpevcg fubhyq or eha nsgre rnpu gvzr lbh hcqngr sebz fia
+build:
+- Start the MSYS shell (to be found in c:\msys\1.0\msys.bat)
+- Switch to the directory with NetRadiant source
+- cp mingw-Makefile.conf Makefile.conf
+- (edit mingw-Makefile.conf in case you installed anything to other locations
+  than the recommended ones)
+- make
 
-eha:
-frg Cebwrpg > Cebcregvrf > Qrohttvat > Pbzznaq gb "$(FbyhgvbaQve)vafgnyy/$(GnetrgSvyrAnzr)"
-uvg 'Qroht > Fgneg' (S5)
+run:
+- in the "install" directory, double click netradiant.exe
index 17e2b66..f3778e4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -910,12 +910,12 @@ $(INSTALLDIR)/plugins/ufoaiplug.$(DLL): \
        contrib/ufoaiplug/ufoai_level.o \
        contrib/ufoaiplug/ufoai.o \
 
-#$(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
-#$(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
-#$(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): \
-#      contrib/bkgrnd2d/bkgrnd2d.o \
-#      contrib/bkgrnd2d/dialog.o \
-#      contrib/bkgrnd2d/plugin.o \
+$(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): LIBS_EXTRA := $(LIBS_GLIB) $(LIBS_GTK)
+$(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): CPPFLAGS_EXTRA := $(CPPFLAGS_GLIB) $(CPPFLAGS_GTK) -Ilibs -Iinclude
+$(INSTALLDIR)/plugins/bkgrnd2d.$(DLL): \
+       contrib/bkgrnd2d/bkgrnd2d.o \
+       contrib/bkgrnd2d/dialog.o \
+       contrib/bkgrnd2d/plugin.o \
 
 $(INSTALLDIR)/heretic2/h2data.$(EXE): LIBS_EXTRA := $(LIBS_XML)
 $(INSTALLDIR)/heretic2/h2data.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) -Itools/quake2/qdata_heretic2/common -Itools/quake2/qdata_heretic2/qcommon -Itools/quake2/qdata_heretic2 -Itools/quake2/common -Ilibs -Iinclude
@@ -960,15 +960,13 @@ install-data: binaries
        [ "$(OS)" != "Darwin" ] || $(CP_R) setup/data/osx/NetRadiant.app/* $(INSTALLDIR_BASE)/NetRadiant.app/
        set -ex; \
        for GAME in games/*; do \
-               if [ -d "$$GAME/tools" ]; then \
-                       GAME=$$GAME/tools; \
+               if [ "$$GAME" = "games/*" ]; then \
+                       $(ECHO) "Game packs not found, please run"; \
+                       $(ECHO) "  ./download-gamepacks.sh"; \
+                       $(ECHO) "and then try again!"; \
+               else \
+                       CP="$(CP)" CP_R="$(CP_R)" $(SH) install-gamepack.sh "$$GAME" "$(INSTALLDIR)"; \
                fi; \
-               for GAMEFILE in $$GAME/games/*.game; do \
-                       $(CP) "$$GAMEFILE" $(INSTALLDIR)/games/; \
-               done; \
-               for GAMEDIR in $$GAME/*.game; do \
-                       $(CP_R) "$$GAMEDIR" $(INSTALLDIR)/; \
-               done; \
        done
        $(ECHO) $(RADIANT_MINOR_VERSION) > $(INSTALLDIR)/RADIANT_MINOR
        $(ECHO) $(RADIANT_MAJOR_VERSION) > $(INSTALLDIR)/RADIANT_MAJOR
index 0f5fa92..2986545 100644 (file)
@@ -1 +1,18 @@
 # empty Makefile.conf template
+
+## OS X:
+# BUILD=debug
+# RADIANT_ABOUTMSG=Custom build
+# EXE=ub
+#
+## MacPorts:
+# CPPFLAGS=-I/opt/local/include/ -I/usr/X11R6/include/ 
+# LDFLAGS=-L/opt/local/lib -L/usr/X11R6/lib
+# MACLIBDIR=/opt/local/lib
+
+## Fink
+## (-arch ppc can combined with -arch 386, I read somewhere. However does work fine like this on OSX 10.6) 
+# LDFLAGS=-arch i386
+# CFLAGS=-arch i386
+# TARGET_ARCH=-arch i386
+# MACLIBDIR=/sw/lib
index 09e9ed7..a37882c 100644 (file)
@@ -97,9 +97,9 @@ void DoBkgrndToggleYZ();
 #define NUM_TOOLBAR_BUTTONS 4
 struct toolbar_button_info_s
 {
-       char *image;
-       char *text;
-       char *tip;
+       const char *image;
+       const char *text;
+       const char *tip;
        void (*func)();
        IToolbarButton::EType type;
 };
index 07f7dae..78f4a5b 100644 (file)
@@ -62,7 +62,7 @@ void BobToolz_destroy()
 char* PLUGIN_NAME = "bobToolz";
 
 // commands in the menu
-static char* PLUGIN_COMMANDS = "About...,-,Vis Viewer,Path Plotter...,-,Stair Builder...,PitOMatic,Make Chain...,Door Builder...,-,Texture Reset...,Intersect...";
+static char* PLUGIN_COMMANDS = "About...,-,Reset Textures...,PitOMatic,-,Vis Viewer,Brush Cleanup,Polygon Builder,Caulk Selection,-,Tree Planter,Drop Entity,Plot Splines,-,Merge Patches,Split patches,Split patches cols,Split patches rows,Turn edge";
 
 // globals
 GtkWidget *g_pRadiantWnd = NULL;
@@ -90,7 +90,29 @@ extern "C" const char* QERPlug_GetCommandList() {
 extern "C" void QERPlug_Dispatch (const char *p, vec3_t vMin, vec3_t vMax, bool bSingleBrush) {
        LoadLists();
 
-       if( string_equal_nocase(p, "texture reset...") ) {
+       if( string_equal_nocase( p, "brush cleanup" ) ) {
+    DoFixBrushes();
+  } else if( string_equal_nocase( p, "polygon builder" ) ) {
+    DoPolygonsTB();
+  } else if( string_equal_nocase( p, "caulk selection" ) ) {
+    DoCaulkSelection();
+  } else if( string_equal_nocase( p, "tree planter" ) ) {
+    DoTreePlanter();
+  } else if( string_equal_nocase( p, "plot splines" ) ) {
+    DoTrainPathPlot();
+  } else if( string_equal_nocase( p, "drop entity" ) ) {
+    DoDropEnts();
+  } else if( string_equal_nocase( p, "merge patches" ) ) {
+    DoMergePatches();
+  } else if( string_equal_nocase( p, "split patches" ) ) {
+    DoSplitPatch();
+  } else if( string_equal_nocase( p, "split patches rows" ) ) {
+       DoSplitPatchRows();
+  } else if( string_equal_nocase( p, "split patches cols" ) ) {
+       DoSplitPatchCols();
+  } else if( string_equal_nocase( p, "turn edge" ) ) {
+    DoFlipTerrain();
+  } else if( string_equal_nocase(p, "reset textures...") ) {
                DoResetTextures();
        } else if( string_equal_nocase(p, "pitomatic") ) {
                DoPitBuilder();
index 8f26d71..2e4fce1 100644 (file)
@@ -599,6 +599,64 @@ void DoSplitPatchRows() {
        Path_deleteTop(instance.path());
 }
 
+void DoSplitPatchCols() {
+       UndoableCommand undo("bobToolz.splitPatchCols");
+       
+       DPatch patch;
+       
+       // ensure we have something selected
+       if( GlobalSelectionSystem().countSelected() != 1 )
+       {
+               DoMessageBox("Invalid number of patches selected, choose 1 only", "Error", eMB_OK);
+               return; 
+       }
+       
+       scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
+       
+       if( !Node_isPatch(instance.path().top()) ) {
+               DoMessageBox("You must select ONLY patches", "Error", eMB_OK);
+               return; 
+       }
+       
+       patch.LoadFromPatch(instance);
+       
+       std::list<DPatch> patchList = patch.SplitCols();
+       for(std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++) {
+               (*patches).BuildInRadiant();
+       }
+       
+       Path_deleteTop(instance.path());
+}
+
+void DoSplitPatchRows() {
+       UndoableCommand undo("bobToolz.splitPatchRows");
+       
+       DPatch patch;
+       
+       // ensure we have something selected
+       if( GlobalSelectionSystem().countSelected() != 1 )
+       {
+               DoMessageBox("Invalid number of patches selected, choose 1 only", "Error", eMB_OK);
+               return; 
+       }
+       
+       scene::Instance& instance = GlobalSelectionSystem().ultimateSelected();
+       
+       if( !Node_isPatch(instance.path().top()) ) {
+               DoMessageBox("You must select ONLY patches", "Error", eMB_OK);
+               return; 
+       }
+       
+       patch.LoadFromPatch(instance);
+       
+       std::list<DPatch> patchList = patch.SplitRows();
+       for(std::list<DPatch>::iterator patches = patchList.begin(); patches != patchList.end(); patches++) {
+               (*patches).BuildInRadiant();
+       }
+       
+       Path_deleteTop(instance.path());
+}
+
 void DoVisAnalyse()
 {
        char filename[1024];
index 044f43c..038d93a 100644 (file)
@@ -77,86 +77,89 @@ void GenerateBitmapMapping ()
 
 static unsigned char* OpenBitmapFile ()
 {
-  int bmWidth;
-  int bmHeight;
-  unsigned char bmPlanes;
-  unsigned char bmBitsPixel;
-  unsigned char m1,m2;
-  unsigned long sizeimage;
-  short res1,res2;
-  long filesize, pixoff;
-  long bmisize, compression;
-  long xscale, yscale;
-  long colors, impcol;
-  unsigned long m_bytesRead = 0;
+#define INVALID_FORMAT do{\
+  fprintf(stderr,"%s:%d: Error file '%s' is malformed.\n",__FILE__,__LINE__,gbmp.name);\
+  fclose(fp);\
+  return NULL;\
+}while(0);
+
+  int32_t bmWidth;
+  int32_t bmHeight;
+  uint16_t bmPlanes;
+  uint16_t bmBitsPixel;
+  uint8_t m1,m2;
+  uint32_t sizeimage;
+  int16_t res1,res2;
+  int32_t filesize, pixoff;
+  int32_t bmisize, compression;
+  int32_t xscale, yscale;
+  int32_t colors, impcol;
+  uint32_t m_bytesRead = 0;
   unsigned char *image;
   FILE *fp;
 
   fp = fopen (gbmp.name, "rb");
   if (fp == NULL)
-    return NULL;
+  {
+         fprintf(stderr,"Error: Invalid filename '%s'\n",gbmp.name);
+         return NULL;
+  }
 
   long rc;
   rc = fread(&m1, 1, 1, fp);
   m_bytesRead++;
   if (rc == -1)
-  {
-    fclose(fp);
-    return NULL;
-  }
+  INVALID_FORMAT;
 
   rc = fread(&m2, 1, 1, fp);
   m_bytesRead++;
   if ((m1 != 'B') || (m2 != 'M'))
-  {
-    fclose(fp);
-    return NULL;
-  }
+  INVALID_FORMAT;
 
-  rc = fread((long*)&(filesize),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(filesize),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((int*)&(res1),2,1,fp); m_bytesRead+=2;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint16_t*)&(res1),2,1,fp); m_bytesRead+=2;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((int*)&(res2),2,1,fp); m_bytesRead+=2;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint16_t*)&(res2),2,1,fp); m_bytesRead+=2;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(pixoff),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(pixoff),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(bmisize),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(bmisize),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long  *)&(bmWidth),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t  *)&(bmWidth),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(bmHeight),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(bmHeight),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((int*)&(bmPlanes),2,1,fp); m_bytesRead+=2;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint16_t*)&(bmPlanes),2,1,fp); m_bytesRead+=2;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((int*)&(bmBitsPixel),2,1,fp); m_bytesRead+=2;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint16_t*)&(bmBitsPixel),2,1,fp); m_bytesRead+=2;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(compression),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(compression),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(sizeimage),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) {fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(sizeimage),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(xscale),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(xscale),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(yscale),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(yscale),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(colors),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(colors),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
-  rc = fread((long*)&(impcol),4,1,fp); m_bytesRead+=4;
-  if (rc != 1) { fclose(fp); return NULL; }
+  rc = fread((uint32_t*)&(impcol),4,1,fp); m_bytesRead+=4;
+  if (rc != 1) INVALID_FORMAT;
 
   if (bmBitsPixel != 8)
   {
@@ -180,40 +183,35 @@ static unsigned char* OpenBitmapFile ()
       m_bytesRead++;
       if (rc!=1)
       {
-        fclose(fp);
-        return NULL;
+              INVALID_FORMAT;
       }
 
       rc = fread(&g, 1, 1, fp); 
       m_bytesRead++;
       if (rc!=1)
       {
-        fclose(fp);
-        return NULL;
+              INVALID_FORMAT;
       }
 
       rc = fread(&r, 1, 1, fp); 
       m_bytesRead++;
       if (rc != 1)
       {
-        fclose(fp);
-        return NULL;
+              INVALID_FORMAT;
       }
 
       rc = fread(&dummy, 1, 1, fp); 
       m_bytesRead++;
       if (rc != 1)
       {
-        fclose(fp);
-        return NULL;
+              INVALID_FORMAT;
       }
     }
   }
 
   if ((long)m_bytesRead > pixoff)
   {
-    fclose(fp);
-    return NULL;
+          INVALID_FORMAT;
   }
 
   while ((long)m_bytesRead < pixoff)
@@ -231,8 +229,6 @@ static unsigned char* OpenBitmapFile ()
 
   if (image != NULL) 
   {
-    gbmp.width = w;
-    gbmp.height = h;
     unsigned char* outbuf = image;
     long row = 0;
     long rowOffset = 0;
@@ -261,8 +257,7 @@ static unsigned char* OpenBitmapFile ()
               if (fread(&inbyte,1,1,fp) != 1)
               {
                 free(image);
-                fclose(fp);
-                return NULL;
+                INVALID_FORMAT;
               }
               m_bytesRead++;
             }
@@ -283,8 +278,7 @@ static unsigned char* OpenBitmapFile ()
             if (fread(&dummy,1,1,fp)!=1)
             {
               free(image);
-              fclose(fp);
-              return NULL;
+              INVALID_FORMAT;
             }
             m_bytesRead++;
           }
@@ -402,15 +396,21 @@ static unsigned char* OpenBitmapFile ()
     }
   }
   fclose(fp);
+
+  gbmp.width = w;
+  gbmp.height = h;
+  if(gbmp.colors)
+       free(gbmp.colors);
+  gbmp.colors = image;
   return image;
+
+
 }
 
 bool OpenBitmap ()
 {
-  if (gbmp.colors)
-    free (gbmp.colors);
 
-  gbmp.colors = OpenBitmapFile ();
+  OpenBitmapFile ();
 
   if (!gbmp.colors)
   {
index 5055c03..cc9083d 100644 (file)
@@ -47,7 +47,7 @@ void MakeDecimatedMap(int *NumNodes, int *NumTris, NODE **pNode, TRI **pTri)
        int Bisect(NODE *, int, int, int);
        void CalcAngles(NODE *, int *, float *);
        void EdgeOnSide(int *, int *, int *);
-       int tricall(int, NODE *, int *, TRI **, TRI **, char *);
+       int tricall(int, NODE *, int *, TRI **, TRI **, const char *);
        int CheckBorders(int *,int,NODE *,int *,TRI **);
 
        float       biggesterror;
@@ -195,7 +195,7 @@ void MakeDecimatedMap(int *NumNodes, int *NumTris, NODE **pNode, TRI **pTri)
                        Tri = *pTri;
                        // Sliver-check along borders. Since borders are often linear, the errors
                        // along borders will often be zero, so no new points will be added. This
-                       // tends to produce long, thin brushes. For all border triangles, check 
+                       // tends to produce long, thin brushes. For all border triangles, check
                        // that minimum angle isn't less than SLIVER_ANGLE. If it is, add another
                        // vertex.
                        while(CheckBorders(&NumNodesUsed,NumNodes[0],Node,NumTris,pTri) > 0)
@@ -323,9 +323,8 @@ void MakeDecimatedMap(int *NumNodes, int *NumTris, NODE **pNode, TRI **pTri)
 /*  tricall Takes an array of nodes, spits out an array of triangles         */
 /*                                                                           */
 /*****************************************************************************/
-int tricall(int NumNodes, NODE *Node, int *NumTris, TRI **inTri, TRI **Tri, LPSTR Options)
+int tricall(int NumNodes, NODE *Node, int *NumTris, TRI **inTri, TRI **Tri, const char *Options)
 {
-
        struct triangulateio in, out;
        int    i, N;
        int    NumUsedNodes;
@@ -426,18 +425,18 @@ int tricall(int NumNodes, NODE *Node, int *NumTris, TRI **inTri, TRI **Tri, LPST
 
        /* Make necessary initializations */
        out.pointlist          = (REAL *) NULL;  /* Not needed if -N switch used. */
-       out.pointattributelist = (REAL *) NULL;  /* Not needed if -N switch used or 
+       out.pointattributelist = (REAL *) NULL;  /* Not needed if -N switch used or
                                                    number of point attributes is zero: */
        out.pointmarkerlist    = (int *) NULL;   /* Not needed if -N or -B switch used. */
        out.trianglelist       = (int *) NULL;   /* Not needed if -E switch used. */
-       out.triangleattributelist = (REAL *) NULL;   /* Not needed if -E switch used or 
-                                                       number of triangle attributes is 
+       out.triangleattributelist = (REAL *) NULL;   /* Not needed if -E switch used or
+                                                       number of triangle attributes is
                                                     zero: */
        out.trianglearealist   = (REAL *) NULL;
        out.neighborlist       = (int *) NULL;   /* Needed only if -n switch used. */
-       out.segmentlist        = (int *) NULL;   /* Needed only if segments are output 
+       out.segmentlist        = (int *) NULL;   /* Needed only if segments are output
                                                    (-p or -c) and -P not used: */
-       out.segmentmarkerlist  = (int *) NULL;   /* Needed only if segments are output 
+       out.segmentmarkerlist  = (int *) NULL;   /* Needed only if segments are output
                                                    (-p or -c) and -P and -B not used: */
        out.edgelist           = (int *) NULL;   /* Needed only if -e switch used. */
        out.edgemarkerlist     = (int *) NULL;   /* Needed if -e used and -B not used. */
@@ -715,7 +714,7 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                if(UseDetail) contents += CONTENTS_DETAIL;
                if(UseLadder) contents += CONTENTS_LADDER;
        }
-       
+
        OpenFuncGroup();
        for(i=0; i<NumTris; i++)
        {
@@ -725,11 +724,11 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                brush.face[0].v[0][0] = Node[Tri[i].v[0]].p[0];
                brush.face[0].v[0][1] = Node[Tri[i].v[0]].p[1];
                brush.face[0].v[0][2] = Node[Tri[i].v[0]].p[2];
-               
+
                brush.face[0].v[1][0] = Node[Tri[i].v[2]].p[0];
                brush.face[0].v[1][1] = Node[Tri[i].v[2]].p[1];
                brush.face[0].v[1][2] = Node[Tri[i].v[2]].p[2];
-               
+
                brush.face[0].v[2][0] = Node[Tri[i].v[1]].p[0];
                brush.face[0].v[2][1] = Node[Tri[i].v[1]].p[1];
                brush.face[0].v[2][2] = Node[Tri[i].v[1]].p[2];
@@ -778,50 +777,50 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                        brush.face[1].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[1].v[0][1] = (float)backface;
                        brush.face[1].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[1].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[1].v[1][1] = (float)backface;
                        brush.face[1].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[1].v[2][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[1].v[2][1] = (float)backface;
                        brush.face[1].v[2][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        // 0-1 side
                        brush.face[2].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[2].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[2].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[2].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[2].v[2][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[2][1] = (float)backface;
                        brush.face[2].v[2][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        // 1-2 side
                        brush.face[3].v[0][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[3].v[0][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[3].v[0][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[3].v[1][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[1][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[1][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[3].v[2][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[2][1] = (float)backface;
                        brush.face[3].v[2][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        // 2-0 side
                        brush.face[4].v[0][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[4].v[0][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[4].v[0][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[4].v[1][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[1][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[1][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[4].v[2][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[2][1] = (float)backface;
                        brush.face[4].v[2][2] = Node[Tri[i].v[0]].p[2];
@@ -832,50 +831,50 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                        brush.face[1].v[0][0] = (float)backface;
                        brush.face[1].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[1].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[1].v[1][0] = (float)backface;
                        brush.face[1].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[1].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[1].v[2][0] = (float)backface;
                        brush.face[1].v[2][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[1].v[2][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        // 0-1 side
                        brush.face[2].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[2].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[2].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[2].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[2].v[2][0] = (float)backface;
                        brush.face[2].v[2][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[2][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        // 1-2 side
                        brush.face[3].v[0][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[3].v[0][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[3].v[0][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[3].v[1][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[1][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[1][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[3].v[2][0] = (float)backface;
                        brush.face[3].v[2][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[2][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        // 2-0 side
                        brush.face[4].v[0][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[4].v[0][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[4].v[0][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[4].v[1][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[1][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[1][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[4].v[2][0] = (float)backface;
                        brush.face[4].v[2][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[2][2] = Node[Tri[i].v[0]].p[2];
@@ -885,55 +884,55 @@ void MakeBrushes(int NumTris, NODE *Node, TRI *Tri,bool surf,
                        brush.face[1].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[1].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[1].v[0][2] = (float)backface;
-                       
+
                        brush.face[1].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[1].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[1].v[1][2] = (float)backface;
-                       
+
                        brush.face[1].v[2][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[1].v[2][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[1].v[2][2] = (float)backface;
-                       
+
                        // 0-1 side
                        brush.face[2].v[0][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[2].v[0][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[2].v[0][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[2].v[1][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[1][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[1][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[2].v[2][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[2].v[2][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[2].v[2][2] = (float)backface;
-                       
+
                        // 1-2 side
                        brush.face[3].v[0][0] = Node[Tri[i].v[1]].p[0];
                        brush.face[3].v[0][1] = Node[Tri[i].v[1]].p[1];
                        brush.face[3].v[0][2] = Node[Tri[i].v[1]].p[2];
-                       
+
                        brush.face[3].v[1][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[1][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[1][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[3].v[2][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[3].v[2][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[3].v[2][2] = (float)backface;
-                       
+
                        // 2-0 side
                        brush.face[4].v[0][0] = Node[Tri[i].v[2]].p[0];
                        brush.face[4].v[0][1] = Node[Tri[i].v[2]].p[1];
                        brush.face[4].v[0][2] = Node[Tri[i].v[2]].p[2];
-                       
+
                        brush.face[4].v[1][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[1][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[1][2] = Node[Tri[i].v[0]].p[2];
-                       
+
                        brush.face[4].v[2][0] = Node[Tri[i].v[0]].p[0];
                        brush.face[4].v[2][1] = Node[Tri[i].v[0]].p[1];
                        brush.face[4].v[2][2] = (float)backface;
                }
-               
+
                for(j=0; j<5; j++)
                {
                        strcpy(brush.face[j].texture,
@@ -1052,10 +1051,10 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                default:
                        front  = MoreThan(zmax,32.);
                }
-               
+
                for(i=0; i<NumTris; i++)
                        Tri[i].flag = 0;
-               
+
                switch(Plane)
                {
                case PLANE_XZ0:
@@ -1075,7 +1074,7 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                        j1 = 0;
                        j2 = 1;
                }
-               
+
                brush.Number = 0;
                brush.NumFaces = 6;
                MaxHints = NH*NV-1;
@@ -1131,41 +1130,41 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                                                        brush.face[0].v[0][0] = Node[q[2]].p[0];
                                                        brush.face[0].v[0][1] = (float)front;
                                                        brush.face[0].v[0][2] = Node[q[2]].p[2];
-                                                       
+
                                                        brush.face[0].v[1][0] = Node[q[1]].p[0];
                                                        brush.face[0].v[1][1] = (float)front;
                                                        brush.face[0].v[1][2] = Node[q[1]].p[2];
-                                                       
+
                                                        brush.face[0].v[2][0] = Node[q[0]].p[0];
                                                        brush.face[0].v[2][1] = (float)front;
                                                        brush.face[0].v[2][2] = Node[q[0]].p[2];
-                                                       
+
                                                        // back
                                                        brush.face[1].v[0][0] = Node[q[0]].p[0];
                                                        brush.face[1].v[0][1] = (float)backface;
                                                        brush.face[1].v[0][2] = Node[q[0]].p[2];
-                                                       
+
                                                        brush.face[1].v[1][0] = Node[q[1]].p[0];
                                                        brush.face[1].v[1][1] = (float)backface;
                                                        brush.face[1].v[1][2] = Node[q[1]].p[2];
-                                                       
+
                                                        brush.face[1].v[2][0] = Node[q[2]].p[0];
                                                        brush.face[1].v[2][1] = (float)backface;
                                                        brush.face[1].v[2][2] = Node[q[2]].p[2];
-                                                       
+
                                                        for(k0=0; k0<brush.NumFaces-2; k0++)
                                                        {
                                                                k =k0+2;
                                                                k1=(k0+1) % (brush.NumFaces-2);
-                                                               
+
                                                                brush.face[k].v[0][0] = Node[q[k0]].p[0];
                                                                brush.face[k].v[0][1] = (float)front;
                                                                brush.face[k].v[0][2] = Node[q[k0]].p[2];
-                                                               
+
                                                                brush.face[k].v[1][0] = Node[q[k1]].p[0];
                                                                brush.face[k].v[1][1] = (float)front;
                                                                brush.face[k].v[1][2] = Node[q[k1]].p[2];
-                                                               
+
                                                                brush.face[k].v[2][0] = Node[q[k1]].p[0];
                                                                brush.face[k].v[2][1] = (float)backface;
                                                                brush.face[k].v[2][2] = Node[q[k1]].p[2];
@@ -1177,41 +1176,41 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                                                        brush.face[0].v[0][0] = (float)front;
                                                        brush.face[0].v[0][1] = Node[q[2]].p[1];
                                                        brush.face[0].v[0][2] = Node[q[2]].p[2];
-                                                       
+
                                                        brush.face[0].v[1][0] = (float)front;
                                                        brush.face[0].v[1][1] = Node[q[1]].p[1];
                                                        brush.face[0].v[1][2] = Node[q[1]].p[2];
-                                                       
+
                                                        brush.face[0].v[2][0] = (float)front;
                                                        brush.face[0].v[2][1] = Node[q[0]].p[1];
                                                        brush.face[0].v[2][2] = Node[q[0]].p[2];
-                                                       
+
                                                        // back
                                                        brush.face[1].v[0][0] = (float)backface;
                                                        brush.face[1].v[0][1] = Node[q[0]].p[1];
                                                        brush.face[1].v[0][2] = Node[q[0]].p[2];
-                                                       
+
                                                        brush.face[1].v[1][0] = (float)backface;
                                                        brush.face[1].v[1][1] = Node[q[1]].p[1];
                                                        brush.face[1].v[1][2] = Node[q[1]].p[2];
-                                                       
+
                                                        brush.face[1].v[2][0] = (float)backface;
                                                        brush.face[1].v[2][1] = Node[q[2]].p[1];
                                                        brush.face[1].v[2][2] = Node[q[2]].p[2];
-                                                       
+
                                                        for(k0=0; k0<brush.NumFaces-2; k0++)
                                                        {
                                                                k =k0+2;
                                                                k1=(k0+1) % (brush.NumFaces-2);
-                                                               
+
                                                                brush.face[k].v[0][0] = (float)front;
                                                                brush.face[k].v[0][1] = Node[q[k0]].p[1];
                                                                brush.face[k].v[0][2] = Node[q[k0]].p[2];
-                                                               
+
                                                                brush.face[k].v[1][0] = (float)front;
                                                                brush.face[k].v[1][1] = Node[q[k1]].p[1];
                                                                brush.face[k].v[1][2] = Node[q[k1]].p[2];
-                                                               
+
                                                                brush.face[k].v[2][0] = (float)backface;
                                                                brush.face[k].v[2][1] = Node[q[k1]].p[1];
                                                                brush.face[k].v[2][2] = Node[q[k1]].p[2];
@@ -1222,41 +1221,41 @@ void MapOut(int NumNodes,int NumTris, NODE *Node, TRI *Tri)
                                                        brush.face[0].v[0][0] = Node[q[2]].p[0];
                                                        brush.face[0].v[0][1] = Node[q[2]].p[1];
                                                        brush.face[0].v[0][2] = (float)front;
-                                                       
+
                                                        brush.face[0].v[1][0] = Node[q[1]].p[0];
                                                        brush.face[0].v[1][1] = Node[q[1]].p[1];
                                                        brush.face[0].v[1][2] = (float)front;
-                                                       
+
                                                        brush.face[0].v[2][0] = Node[q[0]].p[0];
                                                        brush.face[0].v[2][1] = Node[q[0]].p[1];
                                                        brush.face[0].v[2][2] = (float)front;
-                                                       
+
                                                        // back
                                                        brush.face[1].v[0][0] = Node[q[0]].p[0];
                                                        brush.face[1].v[0][1] = Node[q[0]].p[1];
                                                        brush.face[1].v[0][2] = (float)backface;
-                                                       
+
                                                        brush.face[1].v[1][0] = Node[q[1]].p[0];
                                                        brush.face[1].v[1][1] = Node[q[1]].p[1];
                                                        brush.face[1].v[1][2] = (float)backface;
-                                                       
+
                                                        brush.face[1].v[2][0] = Node[q[2]].p[0];
                                                        brush.face[1].v[2][1] = Node[q[2]].p[1];
                                                        brush.face[1].v[2][2] = (float)backface;
-                                                       
+
                                                        for(k0=0; k0<brush.NumFaces-2; k0++)
                                                        {
                                                                k =k0+2;
                                                                k1=(k0+1) % (brush.NumFaces-2);
-                                                               
+
                                                                brush.face[k].v[0][0] = Node[q[k0]].p[0];
                                                                brush.face[k].v[0][1] = Node[q[k0]].p[1];
                                                                brush.face[k].v[0][2] = (float)front;
-                                                               
+
                                                                brush.face[k].v[1][0] = Node[q[k1]].p[0];
                                                                brush.face[k].v[1][1] = Node[q[k1]].p[1];
                                                                brush.face[k].v[1][2] = (float)front;
-                                                               
+
                                                                brush.face[k].v[2][0] = Node[q[k1]].p[0];
                                                                brush.face[k].v[2][1] = Node[q[k1]].p[1];
                                                                brush.face[k].v[2][2] = (float)backface;
index dabb72d..c31741d 100644 (file)
@@ -176,7 +176,7 @@ void texfont_init ()
 
   int i, j, x, y;
   float inv = 1.0f/128;
-  char *charlines[16] = { 
+  const char *charlines[16] = { 
     "abcdefghijklmn", "opqrstuvwxyz0", "123456789ABC", "DEFGHIJKLMN", 
     "OPQRSTUVWX", "YZ,.!;:<>/?{}@$%", "&*()-+=_[] #" };
   unsigned char lefts[7][17] = { 
index 9481570..dcda98a 100644 (file)
@@ -890,11 +890,6 @@ static gint bitmap_file_entryfocusout(GtkWidget* widget, GdkEventFocus* event, g
   strcpy (filename, gtk_entry_get_text (GTK_ENTRY(widget)));
   if(strcmp (filename,gbmp.name))
   {
-    if (gbmp.colors)
-    {
-      free(gbmp.colors);
-      gbmp.colors=NULL;
-    }
     strcpy (gbmp.name,filename);
     if (strlen(gbmp.name) )
       OpenBitmap ();
@@ -1389,10 +1384,10 @@ GtkWidget* create_main_dialog ()
   GtkObject *adj;
   GSList *group;
   int i;
-  char *games[] = { "Quake 2", "Half-Life", "SiN", "Heretic 2", "Kingpin", "Genesis3D", "Quake 3 Arena" };
-  char *waveforms[] = { "Alternating hill/valley", "Cylindrical left-to-right", "Cylindrical top-to-bottom",
+  const char *games[] = { "Quake 2", "Half-Life", "SiN", "Heretic 2", "Kingpin", "Genesis3D", "Quake 3 Arena" };
+  const char *waveforms[] = { "Alternating hill/valley", "Cylindrical left-to-right", "Cylindrical top-to-bottom",
                         "From bitmap", "Fractal" };
-  char *orientations[] = { "Ground surface", "Ceiling", "Wall facing 0", "Wall facing 90",
+  const char *orientations[] = { "Ground surface", "Ceiling", "Wall facing 0", "Wall facing 90",
                            "Wall facing 180","Wall facing 270" }; 
 
   g_pWnd = dlg = gtk_window_new (GTK_WINDOW_TOPLEVEL);
index 32b54b5..3c3107a 100644 (file)
@@ -133,11 +133,12 @@ bool GenSurfInit ()
   else */
     Game = QUAKE3;
 
-  ReadIniFile (gszIni);
 
   if (g_pWnd == NULL)
     g_pWnd = create_main_dialog ();
 
+  ReadIniFile (gszIni);
+
   return true;
 }
 
@@ -291,9 +292,10 @@ void ReadIniFile (const char *file)
   if(!strlen(Texture[GENESIS3D][0])) strcpy(Texture[GENESIS3D][0],"textures/rock13");
   if(!strlen(Texture[QUAKE3][0]))    strcpy(Texture[QUAKE3][0],   "textures/organics/grass3");
   if(!strlen(Texture[QUAKE3][1]))    strcpy(Texture[QUAKE3][1],   "textures/common/caulk");
-
   strcpy (gbmp.name, g_FuncTable.m_pfnProfileLoadString (file, "Bitmap","Filename",""));
 
+
+  gbmp.colors = NULL;
   if (strlen(gbmp.name))
     OpenBitmap ();
 
@@ -321,7 +323,7 @@ varargs versions of all text functions.
 FIXME: make this buffer size safe someday
 ============
 */
-char *va (char *format, ...)
+char *va (const char *format, ...)
 {
   va_list argptr;
   static char string[1024];
diff --git a/download-gamepacks.sh b/download-gamepacks.sh
new file mode 100644 (file)
index 0000000..f6b86dc
--- /dev/null
@@ -0,0 +1,119 @@
+#!/bin/sh
+
+# Usage:
+#   sh download-gamepack.sh
+#   LICENSEFILTER=GPL BATCH=1 sh download-gamepack.sh
+
+set -e
+
+pack()
+{
+       pack=$1; shift
+       license=$1; shift
+       sourcetype=$1; shift
+       source=$1; shift
+
+       if [ -d "games/$pack" ]; then
+               echo "Updating $pack..."
+               case "$sourcetype" in
+                       svn)
+                               svn update "games/$pack" "$@"
+                               ;;
+                       zip1)
+                               rm -rf zipdownload
+                               mkdir zipdownload
+                               cd zipdownload
+                               wget "$source" "$@"
+                               unzip *
+                               cd ..
+                               rm -rf "games/$pack"
+                               mkdir "games/$pack"
+                               mv zipdownload/*/* "games/$pack/"
+                               rm -rf zipdownload
+                               ;;
+                       gitdir)
+                               rm -rf "games/$pack"
+                               git archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
+                               ;;
+               esac
+               return
+       fi
+
+       echo
+       echo "Available pack: $pack"
+       echo "  License: $license"
+       echo "  Download via $sourcetype from $source"
+       echo
+       case " $PACKFILTER " in
+               "  ")
+                       ;;
+               *" $pack "*)
+                       ;;
+               *)
+                       echo "Pack $pack rejected because it is not in PACKFILTER."
+                       return
+                       ;;
+       esac
+       case " $LICENSEFILTER " in
+               "  ")
+                       ;;
+               *" $license "*)
+                       ;;
+               *)
+                       echo "Pack $pack rejected because its license is not in LICENSEFILTER."
+                       return
+                       ;;
+       esac
+       case "$BATCH" in
+               '')
+                       while :; do
+                               echo "Download this pack? (y/n)"
+                               read -r P
+                               case "$P" in
+                                       y*)
+                                               break
+                                               ;;
+                                       n*)
+                                               return
+                                               ;;
+                               esac
+                       done
+                       ;;
+               *)
+                       ;;
+       esac
+       
+       echo "Downloading $pack..."
+       case "$sourcetype" in
+               svn)
+                       svn checkout "$source" "games/$pack" "$@"
+                       ;;
+               zip1)
+                       rm -rf zipdownload
+                       mkdir zipdownload
+                       cd zipdownload
+                       wget "$source" "$@"
+                       unzip *
+                       cd ..
+                       mkdir "games/$pack"
+                       mv zipdownload/*/* "games/$pack/"
+                       rm -rf zipdownload
+                       ;;
+               gitdir)
+                       rm -rf "games/$pack"
+                       git archive --remote="$source" --prefix="$pack/" "$2":"$1" | tar xvf -
+                       ;;
+       esac
+}
+
+mkdir -p games
+pack DarkPlacesPack  GPL         svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/DarkPlacesPack/branches/1.5/
+pack NexuizPack      GPL         gitdir git://git.icculus.org/divverent/nexuiz.git misc/netradiant-NexuizPack master
+pack OpenArenaPack   unknown     zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/OpenArenaPack.zip
+pack Q3Pack          proprietary svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/Q3Pack/trunk/ -r29
+pack Quake2Pack      proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/Quake2Pack.zip
+pack Quake2WorldPack GPL         svn    svn://jdolan.dyndns.org/quake2world/trunk/gtkradiant
+pack QuakePack       proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/QuakePack.zip
+pack TremulousPack   proprietary zip1   http://ingar.satgnu.net/files/gtkradiant/gamepacks/TremulousPack.zip
+pack UFOAIPack       proprietary svn    https://zerowing.idsoftware.com/svn/radiant.gamepacks/UFOAIPack/branches/1.5/
+pack WarsowPack      GPL         svn    http://opensvn.csie.org/warsowgamepack/netradiant/games/WarsowPack/
index 444e377..c74ed7c 100644 (file)
@@ -124,7 +124,7 @@ public:
 
   virtual void setCounter(Counter* counter) = 0;
 
-  virtual void connectEntities(const scene::Path& e1, const scene::Path& e2) = 0;
+  virtual void connectEntities(const scene::Path& e1, const scene::Path& e2, int index) = 0;
 
   virtual void setLightRadii(bool lightRadii) = 0;
   virtual bool getLightRadii() = 0;
index 9061967..3da2f1d 100644 (file)
@@ -46,6 +46,7 @@ enum
    EXCLUDE_STRUCTURAL       = 0x00020000,
    EXCLUDE_BOTCLIP          = 0x00040000,
    EXCLUDE_VISPORTALS       = 0x00080000,
+   EXCLUDE_DECALS                  = 0x00100000,
 };
 
 class Filter
diff --git a/install-gamepack.sh b/install-gamepack.sh
new file mode 100644 (file)
index 0000000..4073d40
--- /dev/null
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+# installs a game pack
+# Usage:
+#   install-gamepack.sh gamepack installdir
+
+set -ex
+
+: ${CP:=cp}
+: ${CP_R:=cp -r}
+
+pack=$1
+dest=$2
+
+if [ -d "$pack/tools" ]; then
+       pack="$pack/tools"
+fi
+for GAMEFILE in "$pack/games"/*.game; do
+       $CP "$GAMEFILE" "$dest/games/"
+done
+for GAMEDIR in "$pack"/*.game/; do
+       $CP_R "$GAMEDIR" "$dest/"
+done
index 4a34f0a..6b63174 100644 (file)
@@ -43,17 +43,14 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #include <list>
 #include <set>
 
-inline void arrow_draw(const Vector3& origin, const Vector3& direction)
+inline void arrow_draw(const Vector3& origin, const Vector3& direction_forward, const Vector3& direction_left, const Vector3& direction_up)
 {
-  Vector3 up(0, 0, 1);
-  Vector3 left(-direction[1], direction[0], 0);
+       Vector3 endpoint(vector3_added(origin, vector3_scaled(direction_forward, 32.0)));
 
-       Vector3 endpoint(vector3_added(origin, vector3_scaled(direction, 32.0)));
-
-  Vector3 tip1(vector3_added(vector3_added(endpoint, vector3_scaled(direction, -8.0)), vector3_scaled(up, -4.0)));
-       Vector3 tip2(vector3_added(tip1, vector3_scaled(up, 8.0)));
-  Vector3 tip3(vector3_added(vector3_added(endpoint, vector3_scaled(direction, -8.0)), vector3_scaled(left, -4.0)));
-       Vector3 tip4(vector3_added(tip3, vector3_scaled(left, 8.0)));
+  Vector3 tip1(vector3_added(vector3_added(endpoint, vector3_scaled(direction_forward, -8.0)), vector3_scaled(direction_up, -4.0)));
+       Vector3 tip2(vector3_added(tip1, vector3_scaled(direction_up, 8.0)));
+  Vector3 tip3(vector3_added(vector3_added(endpoint, vector3_scaled(direction_forward, -8.0)), vector3_scaled(direction_left, -4.0)));
+       Vector3 tip4(vector3_added(tip3, vector3_scaled(direction_left, 8.0)));
 
   glBegin (GL_LINES);
 
index b5f95b7..5a1afa6 100644 (file)
@@ -46,7 +46,7 @@ public:
   }
   ~RGBAImage()
   {
-    delete pixels;
+    delete[] pixels;
   }
 
   void release()
index 558ec21..878e6a4 100644 (file)
@@ -480,7 +480,7 @@ void NMSG_WriteString(netmessage_t *msg, char *string)
                WinPrint("NMSG_WriteString: overflow\n");
                return;
        } //end if
-       strcpy(&msg->data[msg->size], string);
+       memcpy(&msg->data[msg->size], string, strlen(string) + 1);
        msg->size += strlen(string) + 1;
 } //end of the function NMSG_WriteString
 //===========================================================================
@@ -502,7 +502,7 @@ void NMSG_ReadStart(netmessage_t *msg)
 //===========================================================================
 int NMSG_ReadChar(netmessage_t *msg)
 {
-       if (msg->size + 1 > msg->size)
+       if (msg->read + 1 > msg->size)
        {
                msg->readoverflow = qtrue;
                WinPrint("NMSG_ReadChar: read overflow\n");
index 868336d..8ab72f5 100644 (file)
@@ -39,7 +39,7 @@ public:
   {
     return m_value;
   }
-  void write(char* buffer)
+  void write(char* buffer) const
   {
     sprintf(buffer, "%u", m_value);
   }
@@ -136,9 +136,11 @@ inline name_t name_read(const char* name)
 
 class PostFixes
 {
+public:
   typedef std::map<Postfix, unsigned int> postfixes_t;
   postfixes_t m_postfixes;
 
+private:
   Postfix find_first_empty() const
   {
     Postfix postfix("1");
@@ -207,15 +209,33 @@ class UniqueNames
 public:
   name_t make_unique(const name_t& name) const
   {
+    char buf[80];
+    name_t r("","");
+       name_write(buf, name);
+    globalErrorStream() << "find unique name for " << buf << "\n";
+       globalErrorStream() << "> currently registered names:\n";
+       for(names_t::const_iterator i = m_names.begin(); i != m_names.end(); ++i)
+       {
+               globalErrorStream() << ">> " << i->first.c_str() << ": ";
+               for(PostFixes::postfixes_t::const_iterator j = i->second.m_postfixes.begin(); j != i->second.m_postfixes.end(); ++j)
+               {
+                       j->first.write(buf);
+                       globalErrorStream() << " '" << buf << "'";
+               }
+               globalErrorStream() << "\n";
+       }
     names_t::const_iterator i = m_names.find(name.first);
     if(i == m_names.end())
     {
-      return name;
+      r = name;
     }
     else
     {
-      return name_t(name.first, (*i).second.make_unique(name.second));
+      r = name_t(name.first, (*i).second.make_unique(name.second));
     }
+       name_write(buf, r);
+    globalErrorStream() << "> unique name is " << buf << "\n";
+       return r;
   }
 
   void insert(const name_t& name)
diff --git a/mingw-Makefile.conf b/mingw-Makefile.conf
new file mode 100644 (file)
index 0000000..652421a
--- /dev/null
@@ -0,0 +1,29 @@
+# Usage:
+# copy this file to Makefile.conf
+# edit the paths in here
+
+# how to call the mingw tools
+MINGW_EXEC_PREFIX = 
+
+# where the dependencies package is extracted
+RADIANT_DEPENDENCIES_PREFIX = /c/mingw/radiant-deps-mingw32/
+
+# run the prefix fixing tool
+IGNORETHIS := $(shell cd $(RADIANT_DEPENDENCIES_PREFIX) && ./fixprefix.sh)
+
+# set the environment for make
+OS = Win32
+CFLAGS +=
+CXXFLAGS +=
+CPPFLAGS += -I$(RADIANT_DEPENDENCIES_PREFIX)/radiantdeps/include
+LDFLAGS += -L$(RADIANT_DEPENDENCIES_PREFIX)/radiantdeps/lib
+PKG_CONFIG_PATH := $(RADIANT_DEPENDENCIES_PREFIX)/gtk/lib/pkgconfig:$(RADIANT_DEPENDENCIES_PREFIX)/radiantdeps/lib/pkgconfig:$(PKG_CONFIG_PATH)
+WHICHDLL = $(RADIANT_DEPENDENCIES_PREFIX)/whichdll.sh
+
+CC = $(MINGW_EXEC_PREFIX)gcc
+CXX = $(MINGW_EXEC_PREFIX)g++
+LDD =
+RANLIB = $(MINGW_EXEC_PREFIX)ranlib
+AR = $(MINGW_EXEC_PREFIX)ar
+WINDRES = $(MINGW_EXEC_PREFIX)windres
+PKGCONFIG = $(RADIANT_DEPENDENCIES_PREFIX)/gtk/bin/pkg-config
index 441481d..16dd774 100644 (file)
@@ -132,12 +132,23 @@ class ConnectEntities
 public:
   Entity* m_e1;
   Entity* m_e2;
-  ConnectEntities(Entity* e1, Entity* e2) : m_e1(e1), m_e2(e2)
+  int m_index;
+  ConnectEntities(Entity* e1, Entity* e2, int index) : m_e1(e1), m_e2(e2), m_index(index)
   {
   }
+  const char *keyname()
+  {
+    StringOutputStream key(16);
+    if(m_index <= 0)
+      return "target";
+    if(m_index == 1)
+      return "killtarget";
+    key << "target" << m_index;
+    return key.c_str();
+  }
   void connect(const char* name)
   {
-         m_e1->setKeyValue("target", name);
+         m_e1->setKeyValue(keyname(), name);
          m_e2->setKeyValue("targetname", name);
   }
   typedef MemberCaller1<ConnectEntities, const char*, &ConnectEntities::connect> ConnectCaller;
@@ -168,7 +179,7 @@ public:
   {
     EntityKeyValues::setCounter(counter);
   }
-  void connectEntities(const scene::Path& path, const scene::Path& targetPath)
+  void connectEntities(const scene::Path& path, const scene::Path& targetPath, int index)
   {
     Entity* e1 = ScenePath_getEntity(path);
     Entity* e2 = ScenePath_getEntity(targetPath);
@@ -191,29 +202,42 @@ public:
     if(g_gameType == eGameTypeDoom3)
     {
       StringOutputStream key(16);
-      for(unsigned int i = 0; ; ++i)
+      if(index >= 0)
       {
-        key << "target";
-        if(i != 0)
-        {
-           key << i;
-        }
-        const char* value = e1->getKeyValue(key.c_str());
-        if(string_empty(value))
-        {
-          e1->setKeyValue(key.c_str(), e2->getKeyValue("name"));
-          break;
-        }
-        key.clear();
+         key << "target";
+         if(index != 0)
+         {
+           key << index;
+         }
+         e1->setKeyValue(key.c_str(), e2->getKeyValue("name"));
+         key.clear();
+      }
+      else
+      {
+       for(unsigned int i = 0; ; ++i)
+       {
+         key << "target";
+         if(i != 0)
+         {
+           key << i;
+         }
+         const char* value = e1->getKeyValue(key.c_str());
+         if(string_empty(value))
+         {
+           e1->setKeyValue(key.c_str(), e2->getKeyValue("name"));
+           break;
+         }
+         key.clear();
+       }
       }
     }
     else
     {
-      ConnectEntities connector(e1, e2);
+      ConnectEntities connector(e1, e2, index);
       const char* value = e2->getKeyValue("targetname");
       if(string_empty(value))
       {
-        value = e1->getKeyValue("target");
+        value = e1->getKeyValue(connector.keyname());
       }
       if(!string_empty(value))
       {
index bc8a6b7..f93c45a 100644 (file)
@@ -41,7 +41,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 #include "targetable.h"
 #include "origin.h"
-#include "angle.h"
+#include "angles.h"
 #include "filters.h"
 #include "namedentity.h"
 #include "keyobservers.h"
@@ -53,17 +53,19 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
 class RenderableArrow : public OpenGLRenderable
 {
-  const Ray& m_ray;
+  const Vector3& m_origin;
+  const Vector3& m_angles;
 
 public:
-  RenderableArrow(const Ray& ray)
-    : m_ray(ray)
+  RenderableArrow(const Vector3& origin, const Vector3& angles)
+    : m_origin(origin), m_angles(angles)
   {
   }
 
   void render(RenderStateFlags state) const
   {
-    arrow_draw(m_ray.origin, m_ray.direction);
+    Matrix4 mat = matrix4_rotation_for_euler_xyz_degrees(m_angles);
+    arrow_draw(m_origin, matrix4_transformed_direction(mat, Vector3(1, 0, 0)), matrix4_transformed_direction(mat, Vector3(0, 1, 0)), matrix4_transformed_direction(mat, Vector3(0, 0, 1)));
   }
 };
 
@@ -84,15 +86,14 @@ class GenericEntity :
 
   OriginKey m_originKey;
   Vector3 m_origin;
-  AngleKey m_angleKey;
-  float m_angle;
+  AnglesKey m_anglesKey;
+  Vector3 m_angles;
 
   ClassnameFilter m_filter;
   NamedEntity m_named;
   NameKeys m_nameKeys;
 
   AABB m_aabb_local;
-  Ray m_ray;
 
   RenderableArrow m_arrow;
   RenderableSolidAABB m_aabb_solid;
@@ -105,14 +106,11 @@ class GenericEntity :
   void construct()
   {
     read_aabb(m_aabb_local, m_entity.getEntityClass());
-    m_ray.origin = m_aabb_local.origin;
-    m_ray.direction[0] = 1;
-    m_ray.direction[1] = 0;
-    m_ray.direction[2] = 0;
 
     m_keyObservers.insert("classname", ClassnameFilter::ClassnameChangedCaller(m_filter));
     m_keyObservers.insert(Static<KeyIsName>::instance().m_nameKey, NamedEntity::IdentifierChangedCaller(m_named));
-    m_keyObservers.insert("angle", AngleKey::AngleChangedCaller(m_angleKey));
+    m_keyObservers.insert("angle", AnglesKey::AngleChangedCaller(m_anglesKey));
+    m_keyObservers.insert("angles", AnglesKey::AnglesChangedCaller(m_anglesKey));
     m_keyObservers.insert("origin", OriginKey::OriginChangedCaller(m_originKey));
   }
 
@@ -125,7 +123,6 @@ class GenericEntity :
   {
     m_transform.localToParent() = g_matrix4_identity;
     matrix4_translate_by_vec3(m_transform.localToParent(), m_origin);
-    m_ray.direction = matrix4_transformed_direction(matrix4_rotation_for_z(degrees_to_radians(m_angle)), Vector3(1, 0, 0));
     m_transformChanged();
   }
   typedef MemberCaller<GenericEntity, &GenericEntity::updateTransform> UpdateTransformCaller;
@@ -135,24 +132,24 @@ class GenericEntity :
     updateTransform();
   }
   typedef MemberCaller<GenericEntity, &GenericEntity::originChanged> OriginChangedCaller;
-  void angleChanged()
+  void anglesChanged()
   {
-    m_angle = m_angleKey.m_angle;
+    m_angles = m_anglesKey.m_angles;
     updateTransform();
   }
-  typedef MemberCaller<GenericEntity, &GenericEntity::angleChanged> AngleChangedCaller;
+  typedef MemberCaller<GenericEntity, &GenericEntity::anglesChanged> AnglesChangedCaller;
 public:
 
   GenericEntity(EntityClass* eclass, scene::Node& node, const Callback& transformChanged, const Callback& evaluateTransform) :
     m_entity(eclass),
     m_originKey(OriginChangedCaller(*this)),
     m_origin(ORIGINKEY_IDENTITY),
-    m_angleKey(AngleChangedCaller(*this)),
-    m_angle(ANGLEKEY_IDENTITY),
+    m_anglesKey(AnglesChangedCaller(*this)),
+    m_angles(ANGLESKEY_IDENTITY),
     m_filter(m_entity, node),
     m_named(m_entity),
     m_nameKeys(m_entity),
-    m_arrow(m_ray),
+    m_arrow(m_aabb_local.origin, m_angles),
     m_aabb_solid(m_aabb_local),
     m_aabb_wire(m_aabb_local),
     m_renderName(m_named, g_vector3_identity),
@@ -165,12 +162,12 @@ public:
     m_entity(other.m_entity),
     m_originKey(OriginChangedCaller(*this)),
     m_origin(ORIGINKEY_IDENTITY),
-    m_angleKey(AngleChangedCaller(*this)),
-    m_angle(ANGLEKEY_IDENTITY),
+    m_anglesKey(AnglesChangedCaller(*this)),
+    m_angles(ANGLESKEY_IDENTITY),
     m_filter(m_entity, node),
     m_named(m_entity),
     m_nameKeys(m_entity),
-    m_arrow(m_ray),
+    m_arrow(m_aabb_local.origin, m_angles),
     m_aabb_solid(m_aabb_local),
     m_aabb_wire(m_aabb_local),
     m_renderName(m_named, g_vector3_identity),
@@ -275,7 +272,7 @@ public:
   }
   void rotate(const Quaternion& rotation)
   {
-    m_angle = angle_rotated(m_angle, rotation);
+    m_angles = angles_rotated(m_angles, rotation);
   }
   void snapto(float snap)
   {
@@ -285,14 +282,14 @@ public:
   void revertTransform()
   {
     m_origin = m_originKey.m_origin;
-    m_angle = m_angleKey.m_angle;
+    m_angles = m_anglesKey.m_angles;
   }
   void freezeTransform()
   {
     m_originKey.m_origin = m_origin;
     m_originKey.write(&m_entity);
-    m_angleKey.m_angle = m_angle;
-    m_angleKey.write(&m_entity);
+    m_anglesKey.m_angles = m_angles;
+    m_anglesKey.write(&m_entity);
   }
   void transformChanged()
   {
index 426c4f0..3b76144 100644 (file)
@@ -41,7 +41,7 @@ void user_warning_fn(png_structp png_ptr, png_const_charp warning_msg)
 void user_error_fn(png_structp png_ptr, png_const_charp error_msg)
 {
   globalErrorStream() << "libpng error: " << error_msg << "\n";
-  longjmp(png_ptr->jmpbuf, 0);
+  longjmp(png_jmpbuf(png_ptr), 0);
 }
 
 void user_read_data(png_structp png_ptr, png_bytep data, png_uint_32 length)
@@ -89,7 +89,7 @@ Image* LoadPNGBuff (unsigned char* fbuffer)
   // configure the read function
   png_set_read_fn(png_ptr, (voidp)&p_fbuffer, (png_rw_ptr)&user_read_data);
 
-  if (setjmp(png_ptr->jmpbuf)) {
+  if (setjmp(png_jmpbuf(png_ptr))) {
     png_destroy_read_struct(&png_ptr, &info_ptr,
       &end_info);
     return 0;
@@ -108,7 +108,7 @@ Image* LoadPNGBuff (unsigned char* fbuffer)
    png_set_palette_to_rgb(png_ptr);
 
   if (color_type == PNG_COLOR_TYPE_GRAY && bit_depth < 8)
-    png_set_gray_1_2_4_to_8(png_ptr);
+    png_set_expand_gray_1_2_4_to_8(png_ptr);
 
   if (png_get_valid(png_ptr, info_ptr, PNG_INFO_tRNS))
     png_set_tRNS_to_alpha(png_ptr);
@@ -153,7 +153,7 @@ Image* LoadPNGBuff (unsigned char* fbuffer)
   png_read_end(png_ptr, info_ptr);
 
   /* free up the memory structure */
-  png_destroy_read_struct(&png_ptr, &info_ptr, png_infopp_NULL);
+  png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
 
   free(row_pointers);
 
index 6883748..6220f77 100644 (file)
@@ -353,6 +353,26 @@ void InitDirectory(const char* directory, ArchiveModules& archiveModules)
           break;
 
         const char *ext = strrchr (name, '.');
+
+       if(ext && !string_compare_nocase_upper(ext, ".pk3dir"))
+       {
+         if (g_numDirs == (VFS_MAXDIRS-1))
+           continue;
+         snprintf(g_strDirs[g_numDirs], PATH_MAX, "%s%s/", path, name);
+         g_strDirs[g_numDirs][PATH_MAX] = '\0';
+         FixDOSName (g_strDirs[g_numDirs]);
+         AddSlash (g_strDirs[g_numDirs]);
+         g_numDirs++;
+
+         {
+           archive_entry_t entry;
+           entry.name = g_strDirs[g_numDirs-1];
+           entry.archive = OpenArchive(g_strDirs[g_numDirs-1]);
+           entry.is_pakfile = false;
+           g_archives.push_back(entry);
+         }
+       }
+
         if ((ext == 0) || *(++ext) == '\0' || GetArchiveTable(archiveModules, ext) == 0)
           continue;
 
index ab83f39..ca36710 100644 (file)
@@ -1083,6 +1083,12 @@ filter_brush_all_faces g_filter_brush_clip_q2(&g_filter_face_clip_q2);
 filter_face_shader g_filter_face_weapclip("textures/common/weapclip");
 filter_brush_all_faces g_filter_brush_weapclip(&g_filter_face_weapclip);
 
+filter_face_shader g_filter_face_commonclip("textures/common/clip");
+filter_brush_all_faces g_filter_brush_commonclip(&g_filter_face_commonclip);
+
+filter_face_shader g_filter_face_fullclip("textures/common/fullclip");
+filter_brush_all_faces g_filter_brush_fullclip(&g_filter_face_fullclip);
+
 filter_face_shader g_filter_face_botclip("textures/common/botclip");
 filter_brush_all_faces g_filter_brush_botclip(&g_filter_face_botclip);
 
@@ -1122,12 +1128,17 @@ filter_brush_all_faces g_filter_brush_translucent(&g_filter_face_translucent);
 filter_face_contents g_filter_face_detail(BRUSH_DETAIL_MASK);
 filter_brush_all_faces g_filter_brush_detail(&g_filter_face_detail);
 
+filter_face_shader_prefix g_filter_face_decals("textures/decals/");
+filter_brush_any_face g_filter_brush_decals(&g_filter_face_decals);
+
 
 void BrushFilters_construct()
 {
   add_brush_filter(g_filter_brush_clip, EXCLUDE_CLIP);
   add_brush_filter(g_filter_brush_clip_q2, EXCLUDE_CLIP);
   add_brush_filter(g_filter_brush_weapclip, EXCLUDE_CLIP);
+  add_brush_filter(g_filter_brush_fullclip, EXCLUDE_CLIP);
+  add_brush_filter(g_filter_brush_commonclip, EXCLUDE_CLIP);
   add_brush_filter(g_filter_brush_botclip, EXCLUDE_BOTCLIP);
   add_brush_filter(g_filter_brush_caulk, EXCLUDE_CAULK);
   add_brush_filter(g_filter_brush_caulk_ja, EXCLUDE_CAULK);
@@ -1144,6 +1155,7 @@ void BrushFilters_construct()
   add_brush_filter(g_filter_brush_detail, EXCLUDE_DETAILS);
   add_brush_filter(g_filter_brush_detail, EXCLUDE_STRUCTURAL, true);
   add_brush_filter(g_filter_brush_lightgrid, EXCLUDE_LIGHTGRID);
+  add_brush_filter(g_filter_brush_decals, EXCLUDE_DECALS);
 }
 
 #if 0
index 4fa32ee..a572539 100644 (file)
@@ -258,7 +258,8 @@ void Entity_connectSelected()
   {
     GlobalEntityCreator().connectEntities(
       GlobalSelectionSystem().penultimateSelected().path(),
-      GlobalSelectionSystem().ultimateSelected().path()
+      GlobalSelectionSystem().ultimateSelected().path(),
+      0
     );
   }
   else
@@ -267,6 +268,22 @@ void Entity_connectSelected()
   }
 }
 
+void Entity_killconnectSelected()
+{
+  if(GlobalSelectionSystem().countSelected() == 2)
+  {
+    GlobalEntityCreator().connectEntities(
+      GlobalSelectionSystem().penultimateSelected().path(),
+      GlobalSelectionSystem().ultimateSelected().path(),
+      1
+    );
+  }
+  else
+  {
+    globalErrorStream() << "entityKillConnectSelected: exactly two instances must be selected\n";
+  }
+}
+
 AABB Doom3Light_getBounds(const AABB& workzone)
 {
   AABB aabb(workzone);
@@ -419,7 +436,7 @@ void Entity_createFromSelection(const char* name, const Vector3& origin)
   }
 }
 
-
+#if 0
 bool DoNormalisedColor(Vector3& color)
 {
   if(!color_dialog(GTK_WIDGET(MainFrame_getWindow()), color))
@@ -454,13 +471,75 @@ bool DoNormalisedColor(Vector3& color)
 
   return true;
 }
+#endif 
+
+void NormalizeColor(Vector3& color)
+{
+  // scale colors so that at least one component is at 1.0F 
+
+  float largest = 0.0F;
+
+  if ( color[0] > largest )
+    largest = color[0];
+  if ( color[1] > largest )
+    largest = color[1];
+  if ( color[2] > largest )
+    largest = color[2];
+
+  if ( largest == 0.0F )
+  {
+    color[0] = 1.0F;
+    color[1] = 1.0F;
+    color[2] = 1.0F;
+  }
+  else
+  {
+    float scaler = 1.0F / largest;
+
+    color[0] *= scaler;
+    color[1] *= scaler;
+    color[2] *= scaler;
+  }
+}
+
+void Entity_normalizeColor()
+{
+       if(GlobalSelectionSystem().countSelected() != 0)
+       {
+               const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
+               Entity* entity = Node_getEntity(path.top());
+
+               if(entity != 0)
+               {
+                       const char* strColor = entity->getKeyValue("_color");
+                       if(!string_empty(strColor))
+                       {
+                               Vector3 rgb;
+                               if (string_parse_vector3(strColor, rgb))
+                               {
+                                       g_entity_globals.color_entity = rgb;
+                                       NormalizeColor(g_entity_globals.color_entity);
+
+                                       char buffer[128];
+                                       sprintf(buffer, "%g %g %g", g_entity_globals.color_entity[0],
+                                               g_entity_globals.color_entity[1],
+                                               g_entity_globals.color_entity[2]);
+
+                                       Scene_EntitySetKeyValue_Selected("_color", buffer);
+                               }
+                       }
+               }
+       }
+}
 
 void Entity_setColour()
 {
   if(GlobalSelectionSystem().countSelected() != 0)
   {
+       bool normalize = false;
     const scene::Path& path = GlobalSelectionSystem().ultimateSelected().path();
     Entity* entity = Node_getEntity(path.top());
+
     if(entity != 0)
     {
       const char* strColor = entity->getKeyValue("_color");
@@ -473,17 +552,21 @@ void Entity_setColour()
         }
       }
 
-      if(g_pGameDescription->mGameType == "doom3"
-        ? color_dialog(GTK_WIDGET(MainFrame_getWindow()), g_entity_globals.color_entity)
-        : DoNormalisedColor(g_entity_globals.color_entity))
-      {
-        char buffer[128];
-        sprintf(buffer, "%g %g %g", g_entity_globals.color_entity[0],
-                g_entity_globals.color_entity[1],
-                g_entity_globals.color_entity[2]);
+         if( g_pGameDescription->mGameType == "doom3" )
+                 normalize = false;
 
-        Scene_EntitySetKeyValue_Selected("_color", buffer);
-      }
+         if(color_dialog(GTK_WIDGET(MainFrame_getWindow()), g_entity_globals.color_entity))
+         {
+                 if( normalize )
+                         NormalizeColor(g_entity_globals.color_entity);
+
+                 char buffer[128];
+                 sprintf(buffer, "%g %g %g", g_entity_globals.color_entity[0],
+                         g_entity_globals.color_entity[1],
+                         g_entity_globals.color_entity[2]);
+
+                 Scene_EntitySetKeyValue_Selected("_color", buffer);
+         }
     }
   }
 }
@@ -552,7 +635,9 @@ void Entity_constructMenu(GtkMenu* menu)
   create_menu_item_with_mnemonic(menu, "_Regroup", "GroupSelection");
   create_menu_item_with_mnemonic(menu, "_Ungroup", "UngroupSelection");
   create_menu_item_with_mnemonic(menu, "_Connect", "ConnectSelection");
+  create_menu_item_with_mnemonic(menu, "_KillConnect", "KillConnectSelection");
   create_menu_item_with_mnemonic(menu, "_Select Color...", "EntityColor");
+  create_menu_item_with_mnemonic(menu, "_Normalize Color...", "NormalizeColor");
 }
 
 
@@ -563,7 +648,9 @@ void Entity_constructMenu(GtkMenu* menu)
 void Entity_Construct()
 {
   GlobalCommands_insert("EntityColor", FreeCaller<Entity_setColour>(), Accelerator('K'));
+  GlobalCommands_insert("NormalizeColor", FreeCaller<Entity_normalizeColor>());
   GlobalCommands_insert("ConnectSelection", FreeCaller<Entity_connectSelected>(), Accelerator('K', (GdkModifierType)GDK_CONTROL_MASK));
+  GlobalCommands_insert("KillConnectSelection", FreeCaller<Entity_killconnectSelected>(), Accelerator('K', (GdkModifierType)(GDK_SHIFT_MASK)));
   GlobalCommands_insert("GroupSelection", FreeCaller<Entity_groupSelected>());
   GlobalCommands_insert("UngroupSelection", FreeCaller<Entity_ungroupSelected>());
 
index 74e7774..235e291 100644 (file)
@@ -227,6 +227,7 @@ void Filters_constructMenu(GtkMenu* menu_in_menu)
   if(g_pGameDescription->mGameType != "doom3")
   {
     create_check_menu_item_with_mnemonic(menu_in_menu, "Botclips", "FilterBotClips");
+       create_check_menu_item_with_mnemonic(menu_in_menu, "Decals", "FilterDecals");
   }
   // filter manipulation
   menu_separator(menu_in_menu);
@@ -278,6 +279,7 @@ void ConstructFilters()
   if(g_pGameDescription->mGameType != "doom3")
   {
     add_filter_command(EXCLUDE_BOTCLIP, "FilterBotClips", Accelerator('M', (GdkModifierType)GDK_MOD1_MASK));
+       add_filter_command(EXCLUDE_DECALS, "FilterDecals", Accelerator('D', (GdkModifierType)GDK_SHIFT_MASK));
   }
 
   PerformFiltering();
index 7820694..567d17f 100644 (file)
@@ -390,7 +390,7 @@ struct xywindow_globals_private_t
 
     m_bCamXYUpdate(true),
     m_bChaseMouse(true),
-    m_bSizePaint(false)
+    m_bSizePaint(true)
   {
   }
 
@@ -2587,7 +2587,7 @@ void XY_Split_Focus()
 
 void XY_Focus()
 {
-  if (g_pParentWnd->CurrentStyle() == MainFrame::eSplit || g_pParentWnd->CurrentStyle() == MainFrame::eFloating)
+  if (g_pParentWnd->CurrentStyle() == MainFrame::eSplit)
   {
          // cannot do this in a split window
          // do something else that the user may want here
index 2586566..f706aee 100644 (file)
@@ -195,6 +195,18 @@ void vfsInitDirectory (const char *path)
 
         {
           char *ext = strrchr (dirlist, '.');
+
+         if(ext && !Q_stricmp(ext, ".pk3dir"))
+         {
+           if (g_numDirs == (VFS_MAXDIRS-1))
+             continue;
+           snprintf(g_strDirs[g_numDirs], PATH_MAX, "%s/%s", path, name);
+           g_strDirs[g_numDirs][PATH_MAX] = '\0';
+           vfsFixDOSName (g_strDirs[g_numDirs]);
+           vfsAddSlash (g_strDirs[g_numDirs]);
+           ++g_numDirs;
+         }
+
           if ((ext == NULL) || (Q_stricmp (ext, ".pk3") != 0))
             continue;
         }
index 44b3ffa..d2e4d6f 100644 (file)
@@ -31,7 +31,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #ifndef _VFS_H_
 #define _VFS_H_
 
-#define VFS_MAXDIRS 8
+#define VFS_MAXDIRS 64
 
 void vfsInitDirectory (const char *path);
 void vfsShutdown ();
index 04699d4..d6bae51 100644 (file)
@@ -58,6 +58,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */\r
        0.3f,                           /* lightgrid scale */\r
        0.6f,                           /* lightgrid ambient scale */\r
+       qfalse,                         /* light angle attenuation uses half-lambert curve */\r
        qtrue,                          /* disable shader lightstyles hack */\r
        qtrue,                          /* keep light entities on bsp */\r
        4,                                      /* default patchMeta subdivisions tolerance */\r
index d9f7fd5..1c42633 100644 (file)
@@ -58,6 +58,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */\r
        0.3f,                           /* lightgrid scale */\r
        0.6f,                           /* lightgrid ambient scale */\r
+       qfalse,                         /* light angle attenuation uses half-lambert curve */\r
        qtrue,                          /* disable shader lightstyles hack */\r
        qtrue,                          /* keep light entities on bsp */\r
        4,                                      /* default patchMeta subdivisions tolerance */\r
index 3617180..84ea664 100644 (file)
@@ -117,6 +117,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index 8f2f297..87d32b5 100644 (file)
@@ -152,6 +152,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index f63429d..3d25129 100644 (file)
@@ -71,6 +71,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index 0ce673e..056baf0 100644 (file)
@@ -68,6 +68,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index 2e205d2..4d496c3 100644 (file)
@@ -67,6 +67,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qtrue,                          /* disable shader lightstyles hack */
        qtrue,                          /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index f16a515..704c997 100644 (file)
@@ -58,6 +58,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */\r
        0.4f,                           /* lightgrid scale */\r
        0.6f,                           /* lightgrid ambient scale */\r
+       qfalse,                         /* light angle attenuation uses half-lambert curve */\r
        qtrue,                          /* disable shader lightstyles hack */\r
        qtrue,                          /* keep light entities on bsp */\r
        4,                                      /* default patchMeta subdivisions tolerance */\r
index 185680b..7645ad0 100644 (file)
@@ -119,11 +119,12 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
-       qfalse,                         /* disable shader lightstyles hack */
-       qfalse,                         /* keep light entities on bsp */
+       qtrue,                          /* light angle attenuation uses half-lambert curve */
+       qtrue,                          /* disable shader lightstyles hack */
+       qtrue,                          /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
-       qfalse,                         /* patch casting enabled */
-       qfalse,                         /* compile deluxemaps */
+       qtrue,                          /* patch casting enabled */
+       qtrue,                          /* compile deluxemaps */
        0,                                      /* deluxemaps default mode */
        256,                /* minimap size */
        1.0f,               /* minimap sharpener */
index 949cffd..98d4c4b 100644 (file)
@@ -116,6 +116,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index 0a0e48c..1a50927 100644 (file)
@@ -68,6 +68,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index db96aa5..931ec69 100644 (file)
@@ -143,6 +143,7 @@ game_t struct
        1.0f,                                   /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index e6d6637..ab31215 100644 (file)
@@ -116,6 +116,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qtrue,                          /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index 3228d64..5d42262 100644 (file)
@@ -74,6 +74,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index 300d884..157bfe3 100644 (file)
@@ -133,6 +133,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index cd92401..3495f0d 100644 (file)
@@ -70,6 +70,7 @@ game_t struct
        1.0f,                           /* lightmap compensate */
        1.0f,                           /* lightgrid scale */
        1.0f,                           /* lightgrid ambient scale */
+       qfalse,                         /* light angle attenuation uses half-lambert curve */
        qfalse,                         /* disable shader lightstyles hack */
        qfalse,                         /* keep light entities on bsp */
        8,                                      /* default patchMeta subdivisions tolerance */
index 4339286..deff967 100644 (file)
@@ -865,7 +865,33 @@ int LightContributionToSample( trace_t *trace )
                        dist = 16.0f;
                
                /* angle attenuation */
-               angle = (light->flags & LIGHT_ATTEN_ANGLE) ? DotProduct( trace->normal, trace->direction ) : 1.0f;
+               if( light->flags & LIGHT_ATTEN_ANGLE )
+               {
+                       /* standard Lambert attenuation */
+                       float dot = DotProduct( trace->normal, trace->direction ); 
+
+                       /* twosided lighting */
+                       if( trace->twoSided )
+                               dot = fabs( dot );
+
+                       /* jal: optional half Lambert attenuation (http://developer.valvesoftware.com/wiki/Half_Lambert) */
+                       if( lightAngleHL )
+                       {
+                               if( dot > 0.001f ) // skip coplanar
+                               {
+                                       if( dot > 1.0f ) dot = 1.0f;
+                                       dot = ( dot * 0.5f ) + 0.5f;
+                                       dot *= dot;
+                               }
+                               else
+                                       dot = 0;
+                       }
+
+                       angle = dot;
+               }
+               else
+                       angle = 1.0f;
+
                if( light->angleScale != 0.0f )
                {
                        angle /= light->angleScale;
@@ -873,10 +899,6 @@ int LightContributionToSample( trace_t *trace )
                                angle = 1.0f;
                }
                
-               /* twosided lighting */
-               if( trace->twoSided )
-                       angle = fabs( angle );
-               
                /* attenuate */
                if( light->flags & LIGHT_ATTEN_LINEAR )
                {
@@ -918,15 +940,34 @@ int LightContributionToSample( trace_t *trace )
                /* get origin and direction */
                VectorAdd( trace->origin, light->origin, trace->end );
                dist = SetupTrace( trace );
-               
+
                /* angle attenuation */
-               angle = (light->flags & LIGHT_ATTEN_ANGLE)
-                       ? DotProduct( trace->normal, trace->direction )
-                       : 1.0f;
-               
-               /* twosided lighting */
-               if( trace->twoSided )
-                       angle = fabs( angle );
+               if( light->flags & LIGHT_ATTEN_ANGLE )
+               {
+                       /* standard Lambert attenuation */
+                       float dot = DotProduct( trace->normal, trace->direction ); 
+
+                       /* twosided lighting */
+                       if( trace->twoSided )
+                               dot = fabs( dot );
+
+                       /* jal: optional half Lambert attenuation (http://developer.valvesoftware.com/wiki/Half_Lambert) */
+                       if( lightAngleHL )
+                       {
+                               if( dot > 0.001f ) // skip coplanar
+                               {
+                                       if( dot > 1.0f ) dot = 1.0f;
+                                       dot = ( dot * 0.5f ) + 0.5f;
+                                       dot *= dot;
+                               }
+                               else
+                                       dot = 0;
+                       }
+                       
+                       angle = dot;
+               }
+               else
+                       angle = 1.0f;
                
                /* attenuate */
                add = light->photons * angle;
@@ -1324,7 +1365,7 @@ void TraceGrid( int num )
                }
                
                /* can't find a valid point at all */
-               if( step > 0.5 )
+               if( step > 1.0 )
                        return;
        }
        
@@ -1880,6 +1921,10 @@ int LightMain( int argc, char **argv )
        gridAmbientScale = game->gridAmbientScale;
        Sys_Printf( " lightgrid ambient scale: %f\n", gridAmbientScale );
 
+       lightAngleHL = game->lightAngleHL;
+       if( lightAngleHL )
+               Sys_Printf( " half lambert light angle attenuation enabled \n" );
+
        noStyles = game->noStyles;
        if (noStyles == qtrue)
                Sys_Printf( " shader lightstyles hack: disabled\n" );
@@ -2416,6 +2461,17 @@ int LightMain( int argc, char **argv )
                        loMem = qtrue;
                        Sys_Printf( "Enabling low-memory (potentially slower) lighting mode\n" );
                }
+               else if( !strcmp( argv[ i ], "-lightanglehl" ) )
+               {
+                       if( ( atoi( argv[ i + 1 ] ) != 0 ) != lightAngleHL )
+                       {
+                               lightAngleHL = ( atoi( argv[ i + 1 ] ) != 0 );
+                               if( lightAngleHL )
+                                       Sys_Printf( "Enabling half lambert light angle attenuation\n" );
+                               else
+                                       Sys_Printf( "Disabling half lambert light angle attenuation\n" );
+                       }
+               }
                else if( !strcmp( argv[ i ], "-nostyle" ) || !strcmp( argv[ i ], "-nostyles" ) )
                {
                        noStyles = qtrue;
index dba5b13..6d7c54f 100644 (file)
@@ -836,6 +836,9 @@ void RadLight( int num )
        /* find nodraw bit */
        contentFlags = surfaceFlags = compileFlags = 0;
        ApplySurfaceParm( "nodraw", &contentFlags, &surfaceFlags, &compileFlags );
+
+       // jal : avoid bouncing on trans surfaces
+       ApplySurfaceParm( "trans", &contentFlags, &surfaceFlags, &compileFlags );
        
        /* early outs? */
        if( scale <= 0.0f || (si->compileFlags & C_SKY) || si->autosprite ||
index 4b02805..3207928 100644 (file)
@@ -1425,7 +1425,7 @@ float DirtForSample( trace_t *trace )
        VectorCopy( trace->normal, normal );
        
        /* check if the normal is aligned to the world-up */
-       if( normal[ 0 ] == 0.0f && normal[ 1 ] == 0.0f )
+       if( normal[ 0 ] == 0.0f && normal[ 1 ] == 0.0f && ( normal[ 2 ] == 1.0f || normal[ 2 ] == -1.0f ) )
        {
                if( normal[ 2 ] == 1.0f )               
                {
index 44425df..498f656 100644 (file)
@@ -562,6 +562,7 @@ typedef struct game_s
        float                           lightmapCompensate;                             /* default lightmap compensate value */
        float                           gridScale;                                              /* vortex: default lightgrid scale (affects both directional and ambient spectres) */
        float                           gridAmbientScale;                               /* vortex: default lightgrid ambient spectre scale */
+       qboolean                        lightAngleHL;                                   /* jal: use half-lambert curve for light angle attenuation */
        qboolean                        noStyles;                                               /* use lightstyles hack or not */
        qboolean                        keepLights;                                             /* keep light entities on bsp */
        int                                     patchSubdivisions;                              /* default patch subdivisions tolerance */
@@ -2217,6 +2218,9 @@ Q_EXTERN float                            pointScale Q_ASSIGN( 7500.0f );
 Q_EXTERN float                         areaScale Q_ASSIGN( 0.25f );
 Q_EXTERN float                         skyScale Q_ASSIGN( 1.0f );
 Q_EXTERN float                         bounceScale Q_ASSIGN( 0.25f );
+
+/* jal: alternative angle attenuation curve */
+Q_EXTERN qboolean                      lightAngleHL Q_ASSIGN( qfalse );
  
 /* vortex: gridscale and gridambientscale */
 Q_EXTERN float                         gridScale Q_ASSIGN( 1.0f );
index a99c580..f17f7c3 100644 (file)
@@ -1965,6 +1965,51 @@ int FilterPointIntoTree_r( vec3_t point, mapDrawSurface_t *ds, node_t *node )
        return AddReferenceToLeaf( ds, node );
 }
 
+/*
+FilterPointConvexHullIntoTree_r() - ydnar
+filters the convex hull of multiple points from a surface into the tree
+*/
+
+int FilterPointConvexHullIntoTree_r( vec3_t **points, int npoints, mapDrawSurface_t *ds, node_t *node )
+{
+       float                   d, dmin, dmax;
+       plane_t                 *plane;
+       int                             refs = 0;
+       int                             i;
+
+       if(!points)
+               return 0;
+       
+       /* is this a decision node? */
+       if( node->planenum != PLANENUM_LEAF )
+       {
+               /* classify the point in relation to the plane */
+               plane = &mapplanes[ node->planenum ];
+
+               dmin = dmax = DotProduct( *(points[0]), plane->normal ) - plane->dist;
+               for(i = 1; i < npoints; ++i)
+               {
+                       d = DotProduct( *(points[i]), plane->normal ) - plane->dist;
+                       if(d > dmax)
+                               dmax = d;
+                       if(d < dmin)
+                               dmin = d;
+               }
+               
+               /* filter by this plane */
+               refs = 0;
+               if( dmax >= -ON_EPSILON )
+                       refs += FilterPointConvexHullIntoTree_r( points, npoints, ds, node->children[ 0 ] );
+               if( dmin <= ON_EPSILON )
+                       refs += FilterPointConvexHullIntoTree_r( points, npoints, ds, node->children[ 1 ] );
+               
+               /* return */
+               return refs;
+       }
+       
+       /* add a reference */
+       return AddReferenceToLeaf( ds, node );
+}
 
 
 /*
@@ -2091,48 +2136,24 @@ subdivides a patch into an approximate curve and filters it into the tree
 
 static int FilterPatchIntoTree( mapDrawSurface_t *ds, tree_t *tree )
 {
-       int                                     i, x, y, refs;
-       mesh_t                          src, *mesh;
-       winding_t                       *w;
+       int                                     x, y, refs;
        
-       
-       /* subdivide the surface */
-       src.width = ds->patchWidth;
-       src.height = ds->patchHeight;
-       src.verts = ds->verts;
-       mesh = SubdivideMesh( src, FILTER_SUBDIVISION, 32 );
-       
-       
-       /* filter each quad into the tree (fixme: use new patch x-triangulation code?) */
-       refs = 0;
-       for( y = 0; y < (mesh->height - 1); y++ )
-       {
-               for( x = 0; x < (mesh->width - 1); x++ )
+       for(y = 0; y + 2 < ds->patchHeight; y += 2)
+               for(x = 0; x + 2 < ds->patchWidth; x += 2)
                {
-                       /* triangle 1 */
-                       w = AllocWinding( 3 );
-                       w->numpoints = 3;
-                       VectorCopy( mesh->verts[ y * mesh->width + x ].xyz, w->p[ 0 ] );
-                       VectorCopy( mesh->verts[ y * mesh->width + x + 1 ].xyz, w->p[ 1 ] );
-                       VectorCopy( mesh->verts[ (y + 1) * mesh->width + x ].xyz, w->p[ 2 ] );
-                       refs += FilterWindingIntoTree_r( w, ds, tree->headnode );
-                       
-                       /* triangle 2 */
-                       w = AllocWinding( 3 );
-                       w->numpoints = 3;
-                       VectorCopy( mesh->verts[ y * mesh->width + x + 1 ].xyz, w->p[ 0 ] );
-                       VectorCopy( mesh->verts[ (y + 1 ) * mesh->width + x + 1 ].xyz, w->p[ 1 ] );
-                       VectorCopy( mesh->verts[ (y + 1 ) * mesh->width + x ].xyz, w->p[ 2 ] );
-                       refs += FilterWindingIntoTree_r( w, ds, tree->headnode );
+                       vec3_t *points[9];
+                       points[0] = &ds->verts[(y+0) * ds->patchWidth + (x+0)].xyz;
+                       points[1] = &ds->verts[(y+0) * ds->patchWidth + (x+1)].xyz;
+                       points[2] = &ds->verts[(y+0) * ds->patchWidth + (x+2)].xyz;
+                       points[3] = &ds->verts[(y+1) * ds->patchWidth + (x+0)].xyz;
+                       points[4] = &ds->verts[(y+1) * ds->patchWidth + (x+1)].xyz;
+                       points[5] = &ds->verts[(y+1) * ds->patchWidth + (x+2)].xyz;
+                       points[6] = &ds->verts[(y+2) * ds->patchWidth + (x+0)].xyz;
+                       points[7] = &ds->verts[(y+2) * ds->patchWidth + (x+1)].xyz;
+                       points[8] = &ds->verts[(y+2) * ds->patchWidth + (x+2)].xyz;
+                       refs += FilterPointConvexHullIntoTree_r(points, 9, ds, tree->headnode);
                }
-       }
-       
-       /* use point filtering as well */
-       for( i = 0; i < (mesh->width * mesh->height); i++ )
-               refs += FilterPointIntoTree_r( mesh->verts[ i ].xyz, ds, tree->headnode );
-       
-       /* free the subdivided mesh and return */
-       FreeMesh( mesh );
+
        return refs;
 }
 
index b0a49a4..315b67d 100644 (file)
@@ -1267,8 +1267,8 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri,
        }
 
 #if MAX_BBOX_DISTANCE > 0
-       VectorCopy( mins, ds->mins );
-       VectorCopy( maxs, ds->maxs );
+       VectorCopy( ds->mins, mins );
+       VectorCopy( ds->maxs, maxs );
        mins[0] -= MAX_BBOX_DISTANCE;
        mins[1] -= MAX_BBOX_DISTANCE;
        mins[2] -= MAX_BBOX_DISTANCE;
@@ -1277,13 +1277,13 @@ static int AddMetaTriangleToSurface( mapDrawSurface_t *ds, metaTriangle_t *tri,
        maxs[2] += MAX_BBOX_DISTANCE;
 #define CHECK_1D(mins, v, maxs) ((mins) <= (v) && (v) <= (maxs))
 #define CHECK_3D(mins, v, maxs) (CHECK_1D((mins)[0], (v)[0], (maxs)[0]) && CHECK_1D((mins)[1], (v)[1], (maxs)[1]) && CHECK_1D((mins)[2], (v)[2], (maxs)[2]))
-       VectorCopy(p, metaVerts[ tri->indexes[ 0 ] ].xyz);
+       VectorCopy(metaVerts[ tri->indexes[ 0 ] ].xyz, p);
        if(!CHECK_3D(mins, p, maxs))
        {
-               VectorCopy(p, metaVerts[ tri->indexes[ 1 ] ].xyz);
+               VectorCopy(metaVerts[ tri->indexes[ 1 ] ].xyz, p);
                if(!CHECK_3D(mins, p, maxs))
                {
-                       VectorCopy(p, metaVerts[ tri->indexes[ 2 ] ].xyz);
+                       VectorCopy(metaVerts[ tri->indexes[ 2 ] ].xyz, p);
                        if(!CHECK_3D(mins, p, maxs))
                                return 0;
                }