Browse Source

added some info and buildtools

Shane Spies 5 years ago
parent
commit
4502689ba5
100 changed files with 32502 additions and 0 deletions
  1. 91 0
      build/Compile_MeckRain_HIGH.bat
  2. 91 0
      build/Compile_MeckRain_LOW.bat
  3. 77 0
      build/MecklenburgV-B5a5.bat
  4. 82 0
      build/MeckrainV5B1.bat
  5. 82 0
      build/MeckrainVB5A.bat
  6. 18 0
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/example-batch-file.bat
  7. 72 0
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/shlt.fgd
  8. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/hlbsp.exe
  9. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/hlcsg.exe
  10. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/hlrad.exe
  11. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/hlvis.exe
  12. 101 0
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/lights.rad
  13. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/ripent.exe
  14. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/hlbsp.exe
  15. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/hlcsg.exe
  16. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/hlrad.exe
  17. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/hlvis.exe
  18. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/ripent.exe
  19. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlbsp.exe
  20. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlcsg.exe
  21. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlfix.exe
  22. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlrad.exe
  23. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlvis.exe
  24. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/ripent.exe
  25. 9 0
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/thecompilator(GoldSource).bat
  26. 4 0
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/wad.txt
  27. BIN
      build/SHLT-3.9/SHLT 3.9 Binaries and Resources/zhlt.wad
  28. 54 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/Terms of Use.txt
  29. 49 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/TimeCounter.h
  30. 649 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/anorms.h
  31. 158 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/blockmem.cpp
  32. 20 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/blockmem.h
  33. 149 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/boundingbox.h
  34. 1696 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/bspfile.cpp
  35. 422 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/bspfile.h
  36. 578 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/cmdlib.cpp
  37. 170 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/cmdlib.h
  38. 228 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/filelib.cpp
  39. 22 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/filelib.h
  40. 0 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/files.cpp
  41. 40 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/hlassert.h
  42. 684 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/log.cpp
  43. 104 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/log.h
  44. 9 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/mathlib.cpp
  45. 278 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/mathlib.h
  46. 17 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/mathtypes.h
  47. 109 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/messages.cpp
  48. 96 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/messages.h
  49. 61 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/resourcelock.cpp
  50. 11 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/resourcelock.h
  51. 362 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/scriplib.cpp
  52. 26 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/scriplib.h
  53. 682 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/threads.cpp
  54. 49 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/threads.h
  55. 58 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/win32fix.h
  56. 1103 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/winding.cpp
  57. 82 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/winding.h
  58. 5 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/copy_executables_here.bat
  59. 278 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/bsp5.h
  60. 624 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/hlbsp.mak
  61. 721 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/hlbsp.vcproj
  62. 177 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/hlbsp.vcproj.SILENCERSPC.Administrator.user
  63. 48 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/make.inc
  64. 259 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/merge.cpp
  65. 553 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/outside.cpp
  66. 325 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/portals.cpp
  67. 1533 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/qbsp.cpp
  68. 1164 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/solidbsp.cpp
  69. 309 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/surfaces.cpp
  70. 558 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/tjunc.cpp
  71. 351 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/writebsp.cpp
  72. 458 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/autowad.cpp
  73. 1131 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/brush.cpp
  74. 361 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/brushunion.cpp
  75. 312 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/csg.h
  76. 688 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/hlcsg.mak
  77. 746 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/hlcsg.vcproj
  78. 177 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/hlcsg.vcproj.SILENCERSPC.Administrator.user
  79. 102 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/hullfile.cpp
  80. 45 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/make.inc
  81. 660 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/map.cpp
  82. 0 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/netvis_in_vis.cpp
  83. 50 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/properties.cpp
  84. 1895 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/qcsg.cpp
  85. 849 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/textures.cpp
  86. 461 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/wadcfg.cpp
  87. 203 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/wadinclude.cpp
  88. 132 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/wadpath.cpp
  89. 24 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/wadpath.h
  90. 709 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/hlrad.mak
  91. 761 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/hlrad.vcproj
  92. 177 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/hlrad.vcproj.SILENCERSPC.Administrator.user
  93. 640 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/lerp.cpp
  94. 2450 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/lightmap.cpp
  95. 57 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/make.inc
  96. 246 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/mathutil.cpp
  97. 124 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/nomatrix.cpp
  98. 3023 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/qrad.cpp
  99. 523 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/qrad.h
  100. 0 0
      build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/qradutil.cpp

+ 91 - 0
build/Compile_MeckRain_HIGH.bat

@@ -0,0 +1,91 @@
+@echo off
+echo.
+echo Steven, modify the batch script to fit your settings. The original map name is Meckrainig1, so change it.
+echo.
+
+set WADROOT=F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\wads
+
+
+echo ###################################################
+echo #           Batch  Compiler -MeckVR-              #
+echo ###################################################
+echo ###################################################
+echo #  MecklenburgV_rain by FUNJOB Batch Compiler V5  #
+echo ###################################################
+echo #  This toolset is ment for HIGH quality builds   #
+echo ###################################################
+echo.
+echo Written At: 6/8/2009 3:22 PM
+echo BC Version: 3.1.2.0
+echo.
+
+echo Hey steven, don't give this script away, it's very crucial for compiling the mecklenburg series
+echo Also, don't give out any of the files like the lights.rad. That's also modded by me.
+
+"hlcsg.exe" -wadautodetect -cliptype Precise -chart -estimate -texdata 15000 -lightdata 15000 "Meckraing1"
+if ERRORLEVEL 1 goto failed
+"hlbsp.exe" -maxnodesize 8192.0 -chart -estimate -texdata 15000 -lightdata 15000 -wadinclude <INSTERT EMDEDED.WAD> "Meckraing1"
+if ERRORLEVEL 1 goto failed
+"hlvis.exe" -full -chart -estimate -texdata 15000 -lightdata 15000 "Meckraing1"
+if ERRORLEVEL 1 goto failed
+"hlrad.exe" -sparse -chart -estimate -texdata 15000 -lightdata 15000 -chop 16 -extra "Meckraing1"
+if ERRORLEVEL 1 goto failed
+if ERRORLEVEL 1 goto failed
+if not exist "Meckraing1.wic" goto nodelwic
+del "Meckraing1.wic"
+echo Meckraing1.wic deleted.
+:nodelwic
+if not exist "Meckraing1.lin" goto nodellin
+del "Meckraing1.lin"
+echo Meckraing1.lin deleted.
+:nodellin
+if not exist "Meckraing1.p0" goto nodelp0
+del "Meckraing1.p0"
+echo Meckraing1.p0 deleted.
+:nodelp0
+if not exist "Meckraing1.p1" goto nodelp1
+del "Meckraing1.p1"
+echo Meckraing1.p1 deleted.
+:nodelp1
+if not exist "Meckraing1.p2" goto nodelp2
+del "Meckraing1.p2"
+echo Meckraing1.p2 deleted.
+:nodelp2
+if not exist "Meckraing1.p3" goto nodelp3
+del "Meckraing1.p3"
+echo Meckraing1.p3 deleted.
+:nodelp3
+if not exist "Meckraing1.prt" goto nodelprt
+del "Meckraing1.prt"
+echo Meckraing1.prt deleted.
+:nodelprt
+if not exist "Meckraing1.err" goto nodelerr
+del "Meckraing1.err"
+echo Meckraing1.err deleted.
+:nodelerr
+if not exist "Meckraing1.ent.bak" goto nodelentbac
+del "Meckraing1.ent.bak"
+echo Meckraing1.ent.bak deleted.
+:nodelentbac
+if not exist "Meckraing1.bsp" goto nocopybsp
+copy "Meckraing1.bsp" "C:\Steam\steamapps\_Funjob_\half-life\ts\maps"
+echo Meckraing1.bsp copied to C:\Steam\steamapps\_Funjob_\half-life\ts\maps.
+:nocopybsp
+if not exist "Meckraing1.res" goto nocopyres
+copy "Meckraing1.res" "C:\Steam\steamapps\_Funjob_\half-life\ts\maps"
+echo Meckraing1.res copied to C:\Steam\steamapps\_Funjob_\half-life\ts\maps.
+:nocopyres
+if not exist "Meckraing1.pts" goto nocopypts
+copy "Meckraing1.pts" "C:\Steam\steamapps\_Funjob_\half-life\ts\maps"
+echo Meckraing1.pts copied to C:\Steam\steamapps\_Funjob_\half-life\ts\maps.
+:nocopypts
+
+goto succeeded
+:failed
+echo.
+echo There was a problem compiling Mecklenburg, check your log file for errors.
+:succeeded
+echo.
+if exist "Meckraing1.log" "%windir%/NOTEPAD.EXE" "Meckraing1.log"
+
+echo Congrats, Mecklenburg Rain compiled with no fatal issues!

+ 91 - 0
build/Compile_MeckRain_LOW.bat

@@ -0,0 +1,91 @@
+@echo off
+echo.
+echo Steven, modify the batch script to fit your settings. The original map name is Meckrainig1, so change it.
+echo.
+
+set WADROOT=F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\wads
+
+
+echo ###################################################
+echo #           Batch  Compiler -MeckVR-              #
+echo ###################################################
+echo ###################################################
+echo #  MecklenburgV_rain by FUNJOB Batch Compiler V5  #
+echo ###################################################
+echo #   This toolset is ment for low quality builds   #
+echo ###################################################
+echo.
+echo Written At: 6/8/2009 3:22 PM
+echo BC Version: 3.1.2.0
+echo.
+
+echo Hey steven, don't give this script away, it's very crucial for compiling the mecklenburg series
+echo Also, don't give out any of the files like the lights.rad. That's also modded by me.
+
+"hlcsg.exe" -wadautodetect -cliptype Precise -chart -estimate -texdata 15000 -lightdata 15000 "Meckraing1"
+if ERRORLEVEL 1 goto failed
+"hlbsp.exe" -maxnodesize 2048.0 -chart -estimate -texdata 15000 -lightdata 15000 "Meckraing1"
+if ERRORLEVEL 1 goto failed
+"hlvis.exe" -full -chart -estimate -texdata 15000 -lightdata 15000 "Meckraing1"
+if ERRORLEVEL 1 goto failed
+"hlrad.exe" -sparse -chart -estimate -texdata 15000 -lightdata 15000  "Meckraing1"
+if ERRORLEVEL 1 goto failed
+if ERRORLEVEL 1 goto failed
+if not exist "Meckraing1.wic" goto nodelwic
+del "Meckraing1.wic"
+echo Meckraing1.wic deleted.
+:nodelwic
+if not exist "Meckraing1.lin" goto nodellin
+del "Meckraing1.lin"
+echo Meckraing1.lin deleted.
+:nodellin
+if not exist "Meckraing1.p0" goto nodelp0
+del "Meckraing1.p0"
+echo Meckraing1.p0 deleted.
+:nodelp0
+if not exist "Meckraing1.p1" goto nodelp1
+del "Meckraing1.p1"
+echo Meckraing1.p1 deleted.
+:nodelp1
+if not exist "Meckraing1.p2" goto nodelp2
+del "Meckraing1.p2"
+echo Meckraing1.p2 deleted.
+:nodelp2
+if not exist "Meckraing1.p3" goto nodelp3
+del "Meckraing1.p3"
+echo Meckraing1.p3 deleted.
+:nodelp3
+if not exist "Meckraing1.prt" goto nodelprt
+del "Meckraing1.prt"
+echo Meckraing1.prt deleted.
+:nodelprt
+if not exist "Meckraing1.err" goto nodelerr
+del "Meckraing1.err"
+echo Meckraing1.err deleted.
+:nodelerr
+if not exist "Meckraing1.ent.bak" goto nodelentbac
+del "Meckraing1.ent.bak"
+echo Meckraing1.ent.bak deleted.
+:nodelentbac
+if not exist "Meckraing1.bsp" goto nocopybsp
+copy "Meckraing1.bsp" "C:\Steam\steamapps\_Funjob_\half-life\ts\maps"
+echo Meckraing1.bsp copied to C:\Steam\steamapps\_Funjob_\half-life\ts\maps.
+:nocopybsp
+if not exist "Meckraing1.res" goto nocopyres
+copy "Meckraing1.res" "C:\Steam\steamapps\_Funjob_\half-life\ts\maps"
+echo Meckraing1.res copied to C:\Steam\steamapps\_Funjob_\half-life\ts\maps.
+:nocopyres
+if not exist "Meckraing1.pts" goto nocopypts
+copy "Meckraing1.pts" "C:\Steam\steamapps\_Funjob_\half-life\ts\maps"
+echo Meckraing1.pts copied to C:\Steam\steamapps\_Funjob_\half-life\ts\maps.
+:nocopypts
+
+goto succeeded
+:failed
+echo.
+echo There was a problem compiling Mecklenburg, check your log file for errors.
+:succeeded
+echo.
+if exist "Meckraing1.log" "%windir%/NOTEPAD.EXE" "Meckraing1.log"
+
+echo Congrats, Mecklenburg Rain compiled with no fatal issues!

+ 77 - 0
build/MecklenburgV-B5a5.bat

@@ -0,0 +1,77 @@
+@echo off
+set WADROOT=D:\Hammer
+echo ###################################################
+echo #                 Batch  Compiler                 #
+echo ###################################################
+echo ###################################################
+echo #  Please report bugs to: [email protected]  #
+echo ###################################################
+echo.
+echo Written At: 3/3/2007 4:27 PM
+echo BC Version: 3.1.2.0
+echo.
+"D:\Hammer\batch2\Tools\hlcsg.exe" -wadautodetect -cliptype Simple -wadinclude embeded.wad -chart -estimate -texdata 15000 -lightdata 15000 "D:\Hammer\Mecklenburg\vfinal\meckv_final"
+if ERRORLEVEL 1 goto failed
+"D:\Hammer\batch2\Tools\hlbsp.exe" -maxnodesize 8192.0 -chart -estimate -texdata 15000 -lightdata 15000 "D:\Hammer\Mecklenburg\vfinal\meckv_final"
+if ERRORLEVEL 1 goto failed
+"D:\Hammer\batch2\Tools\hlvis.exe" -chart -estimate -texdata 15000 -lightdata 15000 "D:\Hammer\Mecklenburg\vfinal\meckv_final"
+if ERRORLEVEL 1 goto failed
+"D:\Hammer\batch2\Tools\hlrad.exe" -chop 70 -sparse -chart -estimate -texdata 15000 -lightdata 15000  "D:\Hammer\Mecklenburg\vfinal\meckv_final"
+if ERRORLEVEL 1 goto failed
+if ERRORLEVEL 1 goto failed
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.wic" goto nodelwic
+del "D:\Hammer\Mecklenburg\vfinal\meckv_final.wic"
+echo D:\Hammer\Mecklenburg\vfinal\meckv_final.wic deleted.
+:nodelwic
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.lin" goto nodellin
+del "D:\Hammer\Mecklenburg\vfinal\meckv_final.lin"
+echo D:\Hammer\Mecklenburg\vfinal\meckv_final.lin deleted.
+:nodellin
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.p0" goto nodelp0
+del "D:\Hammer\Mecklenburg\vfinal\meckv_final.p0"
+echo D:\Hammer\Mecklenburg\vfinal\meckv_final.p0 deleted.
+:nodelp0
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.p1" goto nodelp1
+del "D:\Hammer\Mecklenburg\vfinal\meckv_final.p1"
+echo D:\Hammer\Mecklenburg\vfinal\meckv_final.p1 deleted.
+:nodelp1
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.p2" goto nodelp2
+del "D:\Hammer\Mecklenburg\vfinal\meckv_final.p2"
+echo D:\Hammer\Mecklenburg\vfinal\meckv_final.p2 deleted.
+:nodelp2
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.p3" goto nodelp3
+del "D:\Hammer\Mecklenburg\vfinal\meckv_final.p3"
+echo D:\Hammer\Mecklenburg\vfinal\meckv_final.p3 deleted.
+:nodelp3
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.prt" goto nodelprt
+del "D:\Hammer\Mecklenburg\vfinal\meckv_final.prt"
+echo D:\Hammer\Mecklenburg\vfinal\meckv_final.prt deleted.
+:nodelprt
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.err" goto nodelerr
+del "D:\Hammer\Mecklenburg\vfinal\meckv_final.err"
+echo D:\Hammer\Mecklenburg\vfinal\meckv_final.err deleted.
+:nodelerr
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.ent.bak" goto nodelentbac
+del "D:\Hammer\Mecklenburg\vfinal\meckv_final.ent.bak"
+echo D:\Hammer\Mecklenburg\vfinal\meckv_final.ent.bak deleted.
+:nodelentbac
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.bsp" goto nocopybsp
+copy "D:\Hammer\Mecklenburg\vfinal\meckv_final.bsp" "C:\Steam\SteamApps\_funjob_\half-life\ts\maps"
+echo meckv_final.bsp copied to C:\Steam\SteamApps\_funjob_\half-life\ts\maps.
+:nocopybsp
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.res" goto nocopyres
+copy "D:\Hammer\Mecklenburg\vfinal\meckv_final.res" "C:\Steam\SteamApps\_funjob_\half-life\ts\maps"
+echo meckv_final.res copied to C:\Steam\SteamApps\_funjob_\half-life\ts\maps.
+:nocopyres
+if not exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.pts" goto nocopypts
+copy "D:\Hammer\Mecklenburg\vfinal\meckv_final.pts" "C:\Steam\SteamApps\_funjob_\half-life\ts\maps"
+echo meckv_final.pts copied to C:\Steam\SteamApps\_funjob_\half-life\ts\maps.
+:nocopypts
+
+goto succeeded
+:failed
+echo.
+echo There was a problem compiling your map, check your meckv_final.log file for errors.
+:succeeded
+echo.
+if exist "D:\Hammer\Mecklenburg\vfinal\meckv_final.log" "C:\WINDOWS\system32\notepad.exe" "D:\Hammer\Mecklenburg\vfinal\meckv_final.log"

+ 82 - 0
build/MeckrainV5B1.bat

@@ -0,0 +1,82 @@
+@echo off
+echo ###################################################
+echo #                 Batch  Compiler                 #
+echo ###################################################
+echo ###################################################
+echo #  Please report bugs to: [email protected]  #
+echo ###################################################
+echo.
+echo Written At: 2/13/2010 11:08 PM
+echo BC Version: 3.1.2.0
+echo.
+if ERRORLEVEL 1 goto failed
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\hlcsg.exe" -wadautodetect -cliptype Simple -chart -estimate -texdata 8192 -lightdata 6144 "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\hlbsp.exe" -maxnodesize 2048 -chart -estimate -texdata 8192 -lightdata 6144 "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\hlvis.exe" -chart -estimate -texdata 8192 -lightdata 6144 "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\hlrad.exe" -nopaque -notexscale -chop 128.0 -dscale 1.0 -chart -estimate -texdata 8192 -lightdata 6144  "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\ripent.exe" -export -chart -texdata 8192 -lightdata 6144 "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\resgen.exe" -k -o -f "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.wic" goto nodelwic
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.wic"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.wic deleted.
+:nodelwic
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.lin" goto nodellin
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.lin"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.lin deleted.
+:nodellin
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p0" goto nodelp0
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p0"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p0 deleted.
+:nodelp0
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p1" goto nodelp1
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p1"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p1 deleted.
+:nodelp1
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p2" goto nodelp2
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p2"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p2 deleted.
+:nodelp2
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p3" goto nodelp3
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p3"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p3 deleted.
+:nodelp3
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.prt" goto nodelprt
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.prt"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.prt deleted.
+:nodelprt
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.err" goto nodelerr
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.err"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.err deleted.
+:nodelerr
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.ent.bak" goto nodelentbac
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.ent.bak"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.ent.bak deleted.
+:nodelentbac
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.bsp" goto nocopybsp
+copy "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.bsp" "C:\steam\steamapps\_funjob_\half-life\ts\maps"
+echo MecklenburgV_RainB5.bsp copied to C:\steam\steamapps\_funjob_\half-life\ts\maps.
+:nocopybsp
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.res" goto nocopyres
+copy "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.res" "C:\steam\steamapps\_funjob_\half-life\ts\maps"
+echo MecklenburgV_RainB5.res copied to C:\steam\steamapps\_funjob_\half-life\ts\maps.
+:nocopyres
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.pts" goto nocopypts
+copy "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.pts" "C:\steam\steamapps\_funjob_\half-life\ts\maps"
+echo MecklenburgV_RainB5.pts copied to C:\steam\steamapps\_funjob_\half-life\ts\maps.
+:nocopypts
+
+goto succeeded
+:failed
+echo.
+echo There was a problem compiling your map, check your MecklenburgV_RainB5.log file for errors.
+:succeeded
+echo.
+if exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.log" "F:\WINDOWS\NOTEPAD.EXE" "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.log"

+ 82 - 0
build/MeckrainVB5A.bat

@@ -0,0 +1,82 @@
+@echo off
+echo ###################################################
+echo #                 Batch  Compiler                 #
+echo ###################################################
+echo ###################################################
+echo #  Please report bugs to: [email protected]  #
+echo ###################################################
+echo.
+echo Written At: 2/13/2010 11:10 PM
+echo BC Version: 3.1.2.0
+echo.
+if ERRORLEVEL 1 goto failed
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\hlcsg.exe" -wadautodetect -cliptype Simple -chart -estimate -texdata 8192 -lightdata 6144 "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\hlbsp.exe" -maxnodesize 2048 -chart -estimate -texdata 8192 -lightdata 6144 "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\hlvis.exe" -chart -estimate -texdata 8192 -lightdata 6144 "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\hlrad.exe" -extra -notexscale -chop 128.0 -dscale 1.0 -chart -estimate -texdata 8192 -lightdata 6144  "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\batch2\SHLT3.7\x86-SSE2\ripent.exe" -export -chart -texdata 8192 -lightdata 6144 "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+if ERRORLEVEL 1 goto failed
+"F:\HLDev\Goldsource\Hammer\resgen.exe" -k -o -f "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5"
+if ERRORLEVEL 1 goto failed
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.wic" goto nodelwic
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.wic"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.wic deleted.
+:nodelwic
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.lin" goto nodellin
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.lin"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.lin deleted.
+:nodellin
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p0" goto nodelp0
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p0"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p0 deleted.
+:nodelp0
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p1" goto nodelp1
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p1"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p1 deleted.
+:nodelp1
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p2" goto nodelp2
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p2"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p2 deleted.
+:nodelp2
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p3" goto nodelp3
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p3"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.p3 deleted.
+:nodelp3
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.prt" goto nodelprt
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.prt"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.prt deleted.
+:nodelprt
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.err" goto nodelerr
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.err"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.err deleted.
+:nodelerr
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.ent.bak" goto nodelentbac
+del "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.ent.bak"
+echo F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.ent.bak deleted.
+:nodelentbac
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.bsp" goto nocopybsp
+copy "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.bsp" "C:\steam\steamapps\_funjob_\half-life\ts\maps"
+echo MecklenburgV_RainB5.bsp copied to C:\steam\steamapps\_funjob_\half-life\ts\maps.
+:nocopybsp
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.res" goto nocopyres
+copy "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.res" "C:\steam\steamapps\_funjob_\half-life\ts\maps"
+echo MecklenburgV_RainB5.res copied to C:\steam\steamapps\_funjob_\half-life\ts\maps.
+:nocopyres
+if not exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.pts" goto nocopypts
+copy "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.pts" "C:\steam\steamapps\_funjob_\half-life\ts\maps"
+echo MecklenburgV_RainB5.pts copied to C:\steam\steamapps\_funjob_\half-life\ts\maps.
+:nocopypts
+
+goto succeeded
+:failed
+echo.
+echo There was a problem compiling your map, check your MecklenburgV_RainB5.log file for errors.
+:succeeded
+echo.
+if exist "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.log" "F:\WINDOWS\NOTEPAD.EXE" "F:\HLDev\Goldsource\Hammer\Mecklenburg\Rain\MecklenburgV_RainB5.log"

+ 18 - 0
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/example-batch-file.bat

@@ -0,0 +1,18 @@
+@echo OFF
+
+SET MAP_PATH="D:\Programs\Hammer\maps\hl\mymap.map"
+SET TOOLS_PATH="D:\Programs\SHLT\SHLT 3.7 Binaries and Resources\x86 (32 bit) SSE2"
+
+SET CSG_PARAMS=-wadautodetect -cliptype precise
+SET BSP_PARAMS=
+SET VIS_PARAMS=-full
+SET RAD_PARAMS=-bounce 1 -extra -sparse -dscale 1
+SET ALL_PARAMS=-estimate -threads 2 -chart -low
+
+%TOOLS_PATH%\HLCSG.exe %MAP_PATH% %ALL_PARAMS% %CSG_PARAMS%
+%TOOLS_PATH%\HLBSP.exe %MAP_PATH% %ALL_PARAMS% %BSP_PARAMS%
+%TOOLS_PATH%\HLVIS.exe %MAP_PATH% %ALL_PARAMS% %VIS_PARAMS%
+%TOOLS_PATH%\HLRAD.exe %MAP_PATH% %ALL_PARAMS% %RAD_PARAMS%
+
+@echo End of compiler.bat.
+@pause>nul

+ 72 - 0
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/shlt.fgd

@@ -0,0 +1,72 @@
+// phlt_copy_brush information, from the official release thread,
+// ( http://www.svencoop.com/forums/showthread.php?t=36733 ) :
+// Added a new point entity, phlt_copy_brush, which allows to change
+// its classname to any you want upon map compilation, e.g. func_wall,
+// and then take the model/appearance of an existing unique brush entity
+// by targetname. With this, you can, for example, make many clones of
+// some prefab you are using a lot, without furtherly approaching map
+// limits. Any additional keyvalues added with SmartEdit disabled will
+// be kept, allowing for perfect copies which are indistinguishable from
+// the original in appearance and function. It is adviced, that the entity
+// which's appearance you are copying over possesses an origin brush. If
+// you want to rotate the copy, have the new classname be func_rotating.
+// Func_walls are blind for angles. Furthermore, note that some entities
+// will cause massive errors when having an origin brush, e.g. func_water.
+// For such cases, look at the offset of the original entity to where
+// the copy is supposed to be, and offset the phlt_copy_brush entity that
+// much from the origin of the coordinate system (0, 0, 0). Also, note
+// that the copies will look exactly as the original, including its
+// lighting and decals placed on it, no matter whether from map start or
+// while the map is running (bullet holes, sprays, blood, etc.), and that
+// the copies cannot emit texturelights.
+@PointClass size(-4 -4 -4, 4 4 4) color(96 240 16) = phlt_copy_brush : "Copies models from other entities"
+[
+	spawnflags(flags) =
+	[
+		1 : "Bit #1 (1)" : 0
+		2 : "Bit #2 (2)" : 0
+		4 : "Bit #3 (4)" : 0
+		8 : "Bit #4 (8)" : 0
+		16 : "Bit #5 (16)" : 0
+		32 : "Bit #6 (32)" : 0
+		64 : "Bit #7 (64)" : 0
+		128 : "Bit #8 (128)" : 0
+		256 : "Bit #9 (256)" : 0
+		512 : "Bit #10 (512)" : 0
+		1024 : "Bit #11 (1024)" : 0
+		2048 : "Bit #12 (2048)" : 0
+		4096 : "Bit #13 (4096)" : 0
+		8192 : "Bit #14 (8192)" : 0
+		16384 : "Bit #15 (16384)" : 0
+		32768 : "Bit #16 (32768)" : 0
+		65536 : "Bit #17 (65536)" : 0
+		131072 : "Bit #18 (131072)" : 0
+		262144 : "Bit #19 (262144)" : 0
+		524288 : "Bit #20 (524288)" : 0
+		1048576 : "Bit #21 (1048576)" : 0
+		2097152 : "Bit #22 (2097152)" : 0
+		4194304 : "Bit #23 (4194304)" : 0
+		8388608 : "Bit #24 (8388608)" : 0
+	]
+	phlt_cpm_target(string) : "PHLT Copy Target"
+	phlt_cpm_class(string) : "PHLT New Classname" : "func_rotating"
+	targetname(target_source) : "Name"
+	target(target_destination) : "Target"
+	angles(string) : "Pitch Yaw Roll (X Z Y)" : "0 0 0"
+]
+
+// shlt_entity_wildcard information, from the official release thread,
+// ( http://www.svencoop.com/forums/showthread.php?t=36733 ) :
+// This entity, upon compile, emits "wildcard_amount" - 1 info_targets,
+// and morphs this shlt_entity_wildcard into a trigger_auto, which
+// killtargets the emitted info_targets "delay" seconds after map start
+// and also removes itself.
+// The purpose of this is to prevent a crash from too many entities in
+// the middle of the map. Instead, the server would crash on map load,
+// and prevent frustration among players from a crash in the middle of play.
+@PointClass size(-24 -24 -24, 24 24 24) color(32 96 255) = shlt_entity_wildcard : "Edicts-Wildcard"
+[
+	killtarget(string) : "Wildcard name" : "shlt_wildcards"
+	wildcard_amount(integer) : "Wildcard size (Entities) (>=1)" : 50
+	delay(string) : "Delay before removal (>=0.5)" : "1.0"
+]

BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/hlbsp.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/hlcsg.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/hlrad.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/hlvis.exe


+ 101 - 0
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/lights.rad

@@ -0,0 +1,101 @@
+//lights.rad
+//Add any custom "Texture light" Values into the end of this file
+//Example - 
+//custcompscn		255 255 255 1000
+//This would make the texture "mycustomcomputerscreen" have a yellow light, and emit 1000 brightness
+//Texture light bright values also tend to be less powerful then there point light sisters, so keep this in mind
+//when you are complieing your map
+
++0~tnnl_lgt5	255 255 255 1
+gravsh_flr		0 0 255 75
++0~fifts_lght06	255 255 255 100
++0fun_hypjump	255	255	0 32
++0~generic78b	0 202 35 500
+fun_gradred		255 0 0 500
+gravsh_wall		0 0 255 100
++0generic_109	64 64 255 100
+sv_porta		0 0 255 75
+SCROLL_hyperspa	255 255 255 5
+fun_nerv		255 255 255 40
+fun_meccreditsn	255 255 255 200
+fun_meccreditra	255 255 255 200
+fun_credgray	255 255 255 200
+gp_credit_grey	255 255 255 200
+!howater		255 255 255 200
+gp_hospitalsig2	255 255 255 200
+pkf_sign8a		255 255 255 100
+fap-machine10	255 255 255 200
+fap-machine07	255 255 255 100
+fap-machine11	255 255 255 200
+gp_meck_credits   255 255 255 1000
+gp_skyscrwindow	255 255 255 100
+gp_teakwon		255 255 255 3000
+~spotblue		164 164 255 1000
+~trn_lt1		255 255 255 1000
+freezer_meat		255 255 255 200
+exit1			255 255 255 200
+~light4a		255 255 255 5000
+sv_hosign2		255 255 255 700
+sv_hotel		255 255 255 450
+gp_windowlight		255 255 255 60
+gp_711sign		255 255 255 450
+gp_whitelight		255 255 255 6000
++0~WHITE		255 255 255 6000
++0~GENERIC65 		255 255 255 750
++0~GENERIC85		110 140 235 1000 
++0~GENERIC86		255 230 125 1000
++0~GENERIC86B		60 220 170 1000
++0~GENERIC86R		128 0 0 6000
+GENERIC87A		100  255 100 1000
+GENERIC88A		255 100 100 1000
+GENERIC89A		40 40 130 1000
+GENERIC90A		200 255 200 1000
+GENERIC105		255 100 100 1000
+GENERIC106		120 120 100 1000
+GENERIC107		180 50 180 1000
+GEN_VEND1		50 180 50 1000
+EMERGLIGHT		255 200 100 50000
++0~FIFTS_LGHT01 	160 170 220 4000
++0~FIFTIES_LGT2 	160 170 220 5000
++0~FIFTS_LGHT4		160 170 220 4000
++0~LIGHT1		40 60 150 3000
++0~LIGHT3A		180 180 230 10000
++0~LIGHT4A		200 190 130 11000
++0~LIGHT5A		80 150 200 10000
++0~LIGHT6A		150 5 5 25000
++0~TNNL_LGT1		240 230 100 1000
++0~TNNL_LGT2		190 255 255 12000
++0~TNNL_LGT3		150 150 210 17000
++0~TNNL_LGT4		170 90 40 10000
++0LAB1_W6D		165 230 255 4000
++0LAB1_W6		150 160 210 8800
++0LAB1_W7		245 240 210 4000
+SKKYLITE		165 230 255 1000
++0~DRKMTLS1		205 0 0 6000
++0~DRKMTLGT1		200 200 180 6000
++0~DRKMTLS2		150 120 20 30000
++0~DRKMTLS2C		255 200 100 50000
++0DRKMTL_SCRN		60 80 255 10000
+~LAB_CRT9A		225 150 150 100
+~LAB_CRT9B		100 100 255 100
+~LAB_CRT9C		100 200 150 100
+~LIGHT3A		190 20 20 3000
+~LIGHT3B		155 155 235 2000
+~LIGHT3C		220 210 150 2500
+~LIGHT3E		90 190 140 6000
+C1A3C_MAP		100 100 255 100
+FIFTIES_MON1B		100 100 180 30
++0~LAB_CRT8		50 50 255 100
+ELEV2_CIEL		255 200 100 800
+YELLOW			255 200 100 2000
+RED			255 0 0 1000
+C14_LIGHT_BIG00		160 170 220 567
+SUBWAY_LIGHTS		160 170 220 8000
+grate_light_ury		160 170 220 8888
+quaintLight1bar		160 170 220 8888
+C14_LIGHT_null		160 170 220 200
+comp_lights2		255 200 100 200
+light_newblue		123 123 255 2222
+C3A2_LIGHT		255 255 128 4567
+hera_light1		0 128 255 2000
+LITEPANEL1		160 170 220 4000

BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x64 (64 bit)/ripent.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/hlbsp.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/hlcsg.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/hlrad.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/hlvis.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) No SSE/ripent.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlbsp.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlcsg.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlfix.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlrad.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/hlvis.exe


BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/ripent.exe


+ 9 - 0
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/thecompilator(GoldSource).bat

@@ -0,0 +1,9 @@
+hlfix.exe "I:\Hammah\zm_arena\arena1.rmf" -w "I:\Hammah\Valve Hammer Editor\SHLT-3.9\SHLT 3.9 Binaries and Resources\x86 (32 bit) SSE2\wad.txt"
+
+hlcsg.exe "I:\Hammah\zm_arena\arena1.map" -wadinclude "I:\Hammah\q3evil6.wad" -wadinclude "I:\Hammah\graphtallica6.wad" -wadinclude "I:\Hammah\graphtallica8.wad" -wadinclude "I:\Hammah\zhlt.wad" -cliptype Simple -texdata 8192 -lightdata 6144 -low -chart 
+
+hlbsp.exe "I:\Hammah\zm_arena\arena1.map" -maxnodesize 512.0 -subdivide 240.0 -texdata 8192 -lightdata 6144 -low -chart 
+
+hlvis.exe "I:\Hammah\zm_arena\arena1.map" -full -texdata 8192 -lightdata 6144 -low -chart 
+
+hlrad.exe "I:\Hammah\zm_arena\arena1.map" -extra -texdata 8192 -lightdata 6144 -low -chart 

+ 4 - 0
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/x86 (32 bit) SSE2/wad.txt

@@ -0,0 +1,4 @@
+I:\Hammah\q3evil6.wad
+I:\Hammah\graphtallica6.wad
+I:\Hammah\graphtallica8.wad
+I:\Hammah\zhlt.wad

BIN
build/SHLT-3.9/SHLT 3.9 Binaries and Resources/zhlt.wad


+ 54 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/Terms of Use.txt

@@ -0,0 +1,54 @@
+Super Half Life Tools (SHLT)
+Version 3.9
+Read me File
+10/04/2009
+
+----------
+
+About This Document: 
+
+This document contains last-minute information about SHLT, including questions you may have concerning the tools or your computer. If you have a question, check to see if it is addressed here first: you may save yourself an email to me at a latter date.
+
+----------
+
+I.	GENERAL TECHNICAL ISSUES
+II.	LICENCE
+III.	CONTACTING ME
+
+----------
+
+I. GENERAL TECHNICAL ISSUES
+
+To get the code to run you should have a copy of VS 2005 Final (Pro). The code has not been tested in the betas and the freeware issue of VS 2005 (C++) has no support to compile 64bit.
+
+There are allot of "warnings" when you do compile, but these should be ignored - as fixing them causes compile errors, such as hull holes, and invisible walls - along with bad lighting, and slower compiles.
+
+The code should work with a *nix complier that has support for Microsoft secure memory commands.
+
+----------
+
+II. LICENCE
+
+0) This code is protected by the GPL, a link to the GPL can be found at the end of this page.
+
+1) In addition to the GPL, the Valve SDK 2.3 EULA overrides any rights you may have obtained in the GPL, when needed.
+
+2) The iD Quake 2 Licence overrides portions of both the Valve EULA, and the GPL where needed, please contact iD for information on this subject.
+
+Copy of the GPL
+http://www.gnu.org/copyleft/gpl.html
+
+Valve SDK EULA
+http://valvesoftware.com/business.html
+
+Quake II Source EULA
+http://www.idsoftware.com/business/technology/techlicense.php#The%20Quake%20II%20Engine
+
+----------
+
+III. CONTACTING ME
+
+I can be contacted via
+
+Email
[email protected]

+ 49 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/TimeCounter.h

@@ -0,0 +1,49 @@
+#ifndef TIMECOUNTER_H__
+#define TIMECOUNTER_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#include "cmdlib.h"
+
+class TimeCounter
+{
+public:
+    void start()
+    {
+        start = I_FloatTime();
+    }
+
+    void stop()
+    {
+        double stop = I_FloatTime();
+        accum += stop - start;
+    }
+
+    double getTotal() const
+    {
+        return accum;
+    }
+
+    void reset()
+    {
+        memset(this, 0, sizeof(*this));
+    }
+
+// Construction
+public:
+    TimeCounter()
+    {
+        reset();
+    }
+    // Default Destructor ok
+    // Default Copy Constructor ok
+    // Default Copy Operator ok
+
+protected:
+    double start;
+    double accum;
+};
+
+#endif//TIMECOUNTER_H__

+ 649 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/anorms.h

@@ -0,0 +1,649 @@
+
+{
+-0.525731, 0.000000, 0.850651}
+
+,
+{
+-0.442863, 0.238856, 0.864188}
+
+,
+{
+-0.295242, 0.000000, 0.955423}
+
+,
+{
+-0.309017, 0.500000, 0.809017}
+
+,
+{
+-0.162460, 0.262866, 0.951056}
+
+,
+{
+0.000000, 0.000000, 1.000000}
+
+,
+{
+0.000000, 0.850651, 0.525731}
+
+,
+{
+-0.147621, 0.716567, 0.681718}
+
+,
+{
+0.147621, 0.716567, 0.681718}
+
+,
+{
+0.000000, 0.525731, 0.850651}
+
+,
+{
+0.309017, 0.500000, 0.809017}
+
+,
+{
+0.525731, 0.000000, 0.850651}
+
+,
+{
+0.295242, 0.000000, 0.955423}
+
+,
+{
+0.442863, 0.238856, 0.864188}
+
+,
+{
+0.162460, 0.262866, 0.951056}
+
+,
+{
+-0.681718, 0.147621, 0.716567}
+
+,
+{
+-0.809017, 0.309017, 0.500000}
+
+,
+{
+-0.587785, 0.425325, 0.688191}
+
+,
+{
+-0.850651, 0.525731, 0.000000}
+
+,
+{
+-0.864188, 0.442863, 0.238856}
+
+,
+{
+-0.716567, 0.681718, 0.147621}
+
+,
+{
+-0.688191, 0.587785, 0.425325}
+
+,
+{
+-0.500000, 0.809017, 0.309017}
+
+,
+{
+-0.238856, 0.864188, 0.442863}
+
+,
+{
+-0.425325, 0.688191, 0.587785}
+
+,
+{
+-0.716567, 0.681718, -0.147621}
+
+,
+{
+-0.500000, 0.809017, -0.309017}
+
+,
+{
+-0.525731, 0.850651, 0.000000}
+
+,
+{
+0.000000, 0.850651, -0.525731}
+
+,
+{
+-0.238856, 0.864188, -0.442863}
+
+,
+{
+0.000000, 0.955423, -0.295242}
+
+,
+{
+-0.262866, 0.951056, -0.162460}
+
+,
+{
+0.000000, 1.000000, 0.000000}
+
+,
+{
+0.000000, 0.955423, 0.295242}
+
+,
+{
+-0.262866, 0.951056, 0.162460}
+
+,
+{
+0.238856, 0.864188, 0.442863}
+
+,
+{
+0.262866, 0.951056, 0.162460}
+
+,
+{
+0.500000, 0.809017, 0.309017}
+
+,
+{
+0.238856, 0.864188, -0.442863}
+
+,
+{
+0.262866, 0.951056, -0.162460}
+
+,
+{
+0.500000, 0.809017, -0.309017}
+
+,
+{
+0.850651, 0.525731, 0.000000}
+
+,
+{
+0.716567, 0.681718, 0.147621}
+
+,
+{
+0.716567, 0.681718, -0.147621}
+
+,
+{
+0.525731, 0.850651, 0.000000}
+
+,
+{
+0.425325, 0.688191, 0.587785}
+
+,
+{
+0.864188, 0.442863, 0.238856}
+
+,
+{
+0.688191, 0.587785, 0.425325}
+
+,
+{
+0.809017, 0.309017, 0.500000}
+
+,
+{
+0.681718, 0.147621, 0.716567}
+
+,
+{
+0.587785, 0.425325, 0.688191}
+
+,
+{
+0.955423, 0.295242, 0.000000}
+
+,
+{
+1.000000, 0.000000, 0.000000}
+
+,
+{
+0.951056, 0.162460, 0.262866}
+
+,
+{
+0.850651, -0.525731, 0.000000}
+
+,
+{
+0.955423, -0.295242, 0.000000}
+
+,
+{
+0.864188, -0.442863, 0.238856}
+
+,
+{
+0.951056, -0.162460, 0.262866}
+
+,
+{
+0.809017, -0.309017, 0.500000}
+
+,
+{
+0.681718, -0.147621, 0.716567}
+
+,
+{
+0.850651, 0.000000, 0.525731}
+
+,
+{
+0.864188, 0.442863, -0.238856}
+
+,
+{
+0.809017, 0.309017, -0.500000}
+
+,
+{
+0.951056, 0.162460, -0.262866}
+
+,
+{
+0.525731, 0.000000, -0.850651}
+
+,
+{
+0.681718, 0.147621, -0.716567}
+
+,
+{
+0.681718, -0.147621, -0.716567}
+
+,
+{
+0.850651, 0.000000, -0.525731}
+
+,
+{
+0.809017, -0.309017, -0.500000}
+
+,
+{
+0.864188, -0.442863, -0.238856}
+
+,
+{
+0.951056, -0.162460, -0.262866}
+
+,
+{
+0.147621, 0.716567, -0.681718}
+
+,
+{
+0.309017, 0.500000, -0.809017}
+
+,
+{
+0.425325, 0.688191, -0.587785}
+
+,
+{
+0.442863, 0.238856, -0.864188}
+
+,
+{
+0.587785, 0.425325, -0.688191}
+
+,
+{
+0.688191, 0.587785, -0.425325}
+
+,
+{
+-0.147621, 0.716567, -0.681718}
+
+,
+{
+-0.309017, 0.500000, -0.809017}
+
+,
+{
+0.000000, 0.525731, -0.850651}
+
+,
+{
+-0.525731, 0.000000, -0.850651}
+
+,
+{
+-0.442863, 0.238856, -0.864188}
+
+,
+{
+-0.295242, 0.000000, -0.955423}
+
+,
+{
+-0.162460, 0.262866, -0.951056}
+
+,
+{
+0.000000, 0.000000, -1.000000}
+
+,
+{
+0.295242, 0.000000, -0.955423}
+
+,
+{
+0.162460, 0.262866, -0.951056}
+
+,
+{
+-0.442863, -0.238856, -0.864188}
+
+,
+{
+-0.309017, -0.500000, -0.809017}
+
+,
+{
+-0.162460, -0.262866, -0.951056}
+
+,
+{
+0.000000, -0.850651, -0.525731}
+
+,
+{
+-0.147621, -0.716567, -0.681718}
+
+,
+{
+0.147621, -0.716567, -0.681718}
+
+,
+{
+0.000000, -0.525731, -0.850651}
+
+,
+{
+0.309017, -0.500000, -0.809017}
+
+,
+{
+0.442863, -0.238856, -0.864188}
+
+,
+{
+0.162460, -0.262866, -0.951056}
+
+,
+{
+0.238856, -0.864188, -0.442863}
+
+,
+{
+0.500000, -0.809017, -0.309017}
+
+,
+{
+0.425325, -0.688191, -0.587785}
+
+,
+{
+0.716567, -0.681718, -0.147621}
+
+,
+{
+0.688191, -0.587785, -0.425325}
+
+,
+{
+0.587785, -0.425325, -0.688191}
+
+,
+{
+0.000000, -0.955423, -0.295242}
+
+,
+{
+0.000000, -1.000000, 0.000000}
+
+,
+{
+0.262866, -0.951056, -0.162460}
+
+,
+{
+0.000000, -0.850651, 0.525731}
+
+,
+{
+0.000000, -0.955423, 0.295242}
+
+,
+{
+0.238856, -0.864188, 0.442863}
+
+,
+{
+0.262866, -0.951056, 0.162460}
+
+,
+{
+0.500000, -0.809017, 0.309017}
+
+,
+{
+0.716567, -0.681718, 0.147621}
+
+,
+{
+0.525731, -0.850651, 0.000000}
+
+,
+{
+-0.238856, -0.864188, -0.442863}
+
+,
+{
+-0.500000, -0.809017, -0.309017}
+
+,
+{
+-0.262866, -0.951056, -0.162460}
+
+,
+{
+-0.850651, -0.525731, 0.000000}
+
+,
+{
+-0.716567, -0.681718, -0.147621}
+
+,
+{
+-0.716567, -0.681718, 0.147621}
+
+,
+{
+-0.525731, -0.850651, 0.000000}
+
+,
+{
+-0.500000, -0.809017, 0.309017}
+
+,
+{
+-0.238856, -0.864188, 0.442863}
+
+,
+{
+-0.262866, -0.951056, 0.162460}
+
+,
+{
+-0.864188, -0.442863, 0.238856}
+
+,
+{
+-0.809017, -0.309017, 0.500000}
+
+,
+{
+-0.688191, -0.587785, 0.425325}
+
+,
+{
+-0.681718, -0.147621, 0.716567}
+
+,
+{
+-0.442863, -0.238856, 0.864188}
+
+,
+{
+-0.587785, -0.425325, 0.688191}
+
+,
+{
+-0.309017, -0.500000, 0.809017}
+
+,
+{
+-0.147621, -0.716567, 0.681718}
+
+,
+{
+-0.425325, -0.688191, 0.587785}
+
+,
+{
+-0.162460, -0.262866, 0.951056}
+
+,
+{
+0.442863, -0.238856, 0.864188}
+
+,
+{
+0.162460, -0.262866, 0.951056}
+
+,
+{
+0.309017, -0.500000, 0.809017}
+
+,
+{
+0.147621, -0.716567, 0.681718}
+
+,
+{
+0.000000, -0.525731, 0.850651}
+
+,
+{
+0.425325, -0.688191, 0.587785}
+
+,
+{
+0.587785, -0.425325, 0.688191}
+
+,
+{
+0.688191, -0.587785, 0.425325}
+
+,
+{
+-0.955423, 0.295242, 0.000000}
+
+,
+{
+-0.951056, 0.162460, 0.262866}
+
+,
+{
+-1.000000, 0.000000, 0.000000}
+
+,
+{
+-0.850651, 0.000000, 0.525731}
+
+,
+{
+-0.955423, -0.295242, 0.000000}
+
+,
+{
+-0.951056, -0.162460, 0.262866}
+
+,
+{
+-0.864188, 0.442863, -0.238856}
+
+,
+{
+-0.951056, 0.162460, -0.262866}
+
+,
+{
+-0.809017, 0.309017, -0.500000}
+
+,
+{
+-0.864188, -0.442863, -0.238856}
+
+,
+{
+-0.951056, -0.162460, -0.262866}
+
+,
+{
+-0.809017, -0.309017, -0.500000}
+
+,
+{
+-0.681718, 0.147621, -0.716567}
+
+,
+{
+-0.681718, -0.147621, -0.716567}
+
+,
+{
+-0.850651, 0.000000, -0.525731}
+
+,
+{
+-0.688191, 0.587785, -0.425325}
+
+,
+{
+-0.587785, 0.425325, -0.688191}
+
+,
+{
+-0.425325, 0.688191, -0.587785}
+
+,
+{
+-0.425325, -0.688191, -0.587785}
+
+,
+{
+-0.587785, -0.425325, -0.688191}
+
+,
+{
+-0.688191, -0.587785, -0.425325}
+
+,

+ 158 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/blockmem.cpp

@@ -0,0 +1,158 @@
+
+/// ********* WIN32 **********
+
+#ifdef SYSTEM_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <malloc.h>
+#include "cmdlib.h"
+#include "messages.h"
+#include "log.h"
+#include "hlassert.h"
+#include "blockmem.h"
+
+// =====================================================================================
+//  AllocBlock
+// =====================================================================================
+void*           AllocBlock(const unsigned long size)
+{
+    void*           pointer;
+    HANDLE          h;
+
+    if (!size)
+    {
+        Warning("Attempting to allocate 0 bytes");
+    }
+
+    h = GlobalAlloc(GMEM_FIXED | GMEM_ZEROINIT, size);
+
+    if (h)
+    {
+        pointer = GlobalLock(h);
+    }
+    else
+    {
+        return NULL;
+    }
+
+    return pointer;
+}
+
+// =====================================================================================
+//  FreeBlock
+// =====================================================================================
+bool            FreeBlock(void* pointer)
+{
+    HANDLE          h;
+
+    if (!pointer)
+    {
+        Warning("Freeing a null pointer");
+    }
+
+    h = GlobalHandle(pointer);
+
+    if (h)
+    {
+        GlobalUnlock(h);
+        GlobalFree(h);
+        return true;
+    }
+    else
+    {
+        Warning("Could not translate pointer into handle");
+        return false;
+    }
+}
+
+#ifdef CHECK_HEAP
+// =====================================================================================
+//  HeapCheck
+// =====================================================================================
+void            HeapCheck()
+{
+    if (_heapchk() != _HEAPOK)
+        hlassert(false);
+}
+#endif
+
+// =====================================================================================
+//  AllocBlock
+// =====================================================================================
+// HeapAlloc/HeapFree is thread safe by default
+void*           Alloc(const unsigned long size)
+{
+    HeapCheck();
+    return calloc(1, size);
+}
+
+// =====================================================================================
+//  AllocBlock
+// =====================================================================================
+bool            Free(void* pointer)
+{
+    HeapCheck();
+    free(pointer);
+    return true;
+}
+
+#endif /// ********* WIN32 **********
+
+
+
+
+/// ********* POSIX **********
+
+#ifdef SYSTEM_POSIX
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#ifdef STDC_HEADERS
+#include <stdlib.h>
+#endif
+#include "cmdlib.h"
+#include "messages.h"
+#include "log.h"
+
+// =====================================================================================
+//  AllocBlock
+// =====================================================================================
+void*           AllocBlock(const unsigned long size)
+{
+    if (!size)
+    {
+        Warning("Attempting to allocate 0 bytes");
+    }
+    return calloc(1, size);
+}
+
+// =====================================================================================
+//  FreeBlock
+// =====================================================================================
+bool            FreeBlock(void* pointer)
+{
+    if (!pointer)
+    {
+        Warning("Freeing a null pointer");
+    }
+    free(pointer);
+    return true;
+}
+
+// =====================================================================================
+//  Alloc
+// =====================================================================================
+void*           Alloc(const unsigned long size)
+{
+    return AllocBlock(size);
+}
+
+// =====================================================================================
+//  Free
+// =====================================================================================
+bool            Free(void* pointer)
+{
+    return FreeBlock(pointer);
+}
+
+#endif /// ********* POSIX **********

+ 20 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/blockmem.h

@@ -0,0 +1,20 @@
+#ifndef BLOCKMEM_H__
+#define BLOCKMEM_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+extern void*    AllocBlock(unsigned long size);
+extern bool     FreeBlock(void* pointer);
+
+extern void*    Alloc(unsigned long size);
+extern bool     Free(void* pointer);
+
+#if defined(CHECK_HEAP)
+extern void     HeapCheck();
+#else
+#define HeapCheck()
+#endif
+
+#endif // BLOCKMEM_H__

+ 149 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/boundingbox.h

@@ -0,0 +1,149 @@
+// Copyright (C) 2000  Sean Cavanaugh
+// This file is licensed under the terms of the Lesser GNU Public License
+// (see LPGL.txt, or http://www.gnu.org/copyleft/lesser.txt)
+
+// AJM:
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4305) // truncation from 'const double' to 'float'
+#endif
+
+#ifndef BOUNDINGBOX_H__
+#define BOUNDINGBOX_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+class BoundingBox
+{
+public:
+    typedef enum
+    {
+        eDisjoint,      // neither boxes touch
+        eUnion,         // this box intersects with the other box
+        eSubset,        // this box is inside the other box
+        eSuperset       // this box is completly envelops the other box
+    } eBoundingState;
+
+    // Tests if other box is completely outside of this box
+    bool testDisjoint(const BoundingBox& other) const
+    {
+        if ((m_Mins[0] > other.m_Maxs[0]) ||
+            (m_Mins[1] > other.m_Maxs[1]) ||
+            (m_Mins[2] > other.m_Maxs[2]) ||
+            (m_Maxs[0] < other.m_Mins[0]) ||
+            (m_Maxs[1] < other.m_Mins[1]) ||
+            (m_Maxs[2] < other.m_Mins[2]))
+        {
+            return true;
+        }
+        return false;
+    }
+    // returns true if this box is completely inside other box
+    bool testSubset(const BoundingBox& other) const
+    {
+        if (
+                (m_Mins[0] >= other.m_Mins[0]) &&
+                (m_Maxs[0] <= other.m_Maxs[0]) &&
+                (m_Mins[1] >= other.m_Mins[1]) &&
+                (m_Maxs[1] <= other.m_Maxs[1]) &&
+                (m_Mins[2] >= other.m_Mins[2]) &&
+                (m_Maxs[2] <= other.m_Maxs[2])
+           )
+        {
+            return true;
+        }
+        return false;
+    }
+    // returns true if this box contains the other box completely
+    bool testSuperset(const BoundingBox& other) const
+    {
+        return other.testSubset(*this);
+    }
+    // returns true if this box partially intersects the other box
+    bool testUnion(const BoundingBox& other) const
+    {
+        BoundingBox tmpBox;
+        tmpBox.m_Mins[0] = max(m_Mins[0], other.m_Mins[0]);
+        tmpBox.m_Mins[1] = max(m_Mins[1], other.m_Mins[1]);
+        tmpBox.m_Mins[2] = max(m_Mins[2], other.m_Mins[2]);
+        tmpBox.m_Maxs[0] = min(m_Maxs[0], other.m_Maxs[0]);
+        tmpBox.m_Maxs[1] = min(m_Maxs[1], other.m_Maxs[1]);
+        tmpBox.m_Maxs[2] = min(m_Maxs[2], other.m_Maxs[2]);
+
+        if ((tmpBox.m_Mins[0] > tmpBox.m_Maxs[0]) ||
+            (tmpBox.m_Mins[1] > tmpBox.m_Maxs[1]) ||
+            (tmpBox.m_Mins[2] > tmpBox.m_Maxs[2]))
+        {
+            return false;
+        }   
+        return true;
+    }
+    eBoundingState test(const BoundingBox& other) const
+    {
+        eBoundingState rval;
+        if (testDisjoint(other))
+        {
+            rval = eDisjoint;
+        }
+        else if (testSubset(other))
+        {
+            rval = eSubset;
+        }
+        else if (testSuperset(other))
+        {
+            rval = eSuperset;
+        }
+        else
+        {
+            rval = eUnion;
+        }
+        return rval;
+    }
+
+    void set(const vec3_t mins, const vec3_t maxs)
+    {
+        VectorCopy(mins, m_Mins);
+        VectorCopy(maxs, m_Maxs);
+    }
+    void reset()
+    {
+        VectorFill(m_Mins,  999999999.999);
+        VectorFill(m_Maxs, -999999999.999);
+    }
+    void add(const vec3_t point)
+    {
+        m_Mins[0] = min(m_Mins[0], point[0]);
+        m_Maxs[0] = max(m_Maxs[0], point[0]);
+        m_Mins[1] = min(m_Mins[1], point[1]);
+        m_Maxs[1] = max(m_Maxs[1], point[1]);
+        m_Mins[2] = min(m_Mins[2], point[2]);
+        m_Maxs[2] = max(m_Maxs[2], point[2]);
+    }
+    void add(const BoundingBox& other)
+    {
+        add(other.m_Mins);
+        add(other.m_Maxs);
+    }
+
+public:
+    // BoundingBox(const BoundingBox& other) // Default copy constructor ok
+    // BoundingBox& operator=(const BoundingBox& other); // Default copy operator ok
+    BoundingBox()
+    {
+        reset();
+    }
+    BoundingBox(const vec3_t& mins, const vec3_t& maxs)
+    {
+        VectorCopy(mins, m_Mins);
+        VectorCopy(maxs, m_Maxs);
+    }
+    ~BoundingBox() {}
+
+public:
+    // Bounding box
+    vec3_t m_Mins;
+    vec3_t m_Maxs;
+};
+
+#endif//BOUNDINGBOX_H__

File diff suppressed because it is too large
+ 1696 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/bspfile.cpp


+ 422 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/bspfile.h

@@ -0,0 +1,422 @@
+#ifndef BSPFILE_H__
+#define BSPFILE_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+// upper design bounds
+#define MAX_MAP_HULLS            4
+// hard limit
+
+#define MAX_MAP_MODELS         512		//400	//PROTECTOR
+// variable, but 400 brush entities is very stressful on the engine and network code as it is.
+// note that 512 is the absolute limit - maps won't load if that many models are precached.
+// models include unqiue *.mdl- and *.spr-files appearing in the map as well as one model for
+// each unique brush entity. For the *.mdl and *.spr-files, there are exceptions, though.
+// E.g., player models and HUD sprites & targas don't fall under the limit.
+
+#define MAX_MAP_BRUSHES			131072	//32768 //SILENCER
+// arbitrary, but large numbers of brushes generally require more lightmap's than the compiler can handle
+
+#define MAX_ENGINE_ENTITIES   523264		//1024	//SILENCER
+#define MAX_MAP_ENTITIES      1046528		//2048	//SILENCER
+// variable, since the -num_edcits # parameter has been added
+// in actuallity it is too much, as temporary entities in the game plus static map entities can overflow
+
+#define MAX_MAP_ENTSTRING   16384*1024	//(512*1024) //SILENCER
+// abitrary, 512Kb of string data should be plenty even with TFC FGD's
+// SILENCER: You can NEVER have enough of this,
+// especially not in Sven Co-op, with all those squadmakers and game_text entities
+
+// SILENCER: The following two are hard limits. Tried doing more, but just as said in that
+// mail from ages ago, some faces just don't show up and ocassionally, the game crashes.
+// Note: The integrated plane optimization by XP-Cagey takes action before the limit check.
+#define MAX_MAP_PLANES      32767 //32768 //SILENCER: Considering the high chance of shorts being used for this
+#define MAX_INTERNAL_MAP_PLANES 256*1024
+// (from email): I have been building a rather complicated map, and using your latest 
+// tools (1.61) it seemed to compile fine.  However, in game, the engine was dropping
+// a lot of faces from almost every FUNC_WALL, and also caused a strange texture 
+// phenomenon in software mode (see attached screen shot).  When I compiled with v1.41,
+// I noticed that it hit the MAX_MAP_PLANES limit of 32k.  After deleting some brushes
+// I was able to bring the map under the limit, and all of the previous errors went away.
+
+#define MAX_MAP_NODES        32767
+// hard limit (negative short's are used as contents values)
+#define MAX_MAP_CLIPNODES    65535 //32767 //SILENCER
+// hard limit (negative short's are used as contents values)
+// SILENCER: If you go over the clipnodes limit, some brushes
+// in your map won't be solid, so you can fall outside world.
+// Sending a warning to the mapper if he exceeds the limit,
+// but not stopping the compiler later, so he can see how far he is
+// over the limit.
+
+#define MAX_MAP_LEAFS         32767	//8192
+// Old: ( 8192 is hard limit - halflife depends on it to setup pvs bits correctly )
+// SILENCER: This is not a straight hard limit (anymore (?))
+// At least it is true that I made a testmap with ca. 16000
+// leafs and it did not crash or show weird problems at any point.
+// Added a warning being thrown at the user when he exceeds 8192, though.
+
+#define MAX_MAP_VERTS        65535
+#define MAX_MAP_FACES        65535
+#define MAX_MAP_MARKSURFACES 65535
+// hard limit (data structures store them as unsigned shorts)
+
+#define MAX_MAP_TEXTURES       512
+// hard limit (halflife limitation)
+
+#define MAX_MAP_TEXINFO      32767
+// hard limit (face.texinfo is signed short)
+
+#define MAX_MAP_EDGES       524287	//256000	//SILENCER
+#define MAX_MAP_SURFEDGES	1048575	//512000	//SILENCER
+// (not so(?)) arbitrary
+
+#define DEFAULT_MAX_MAP_MIPTEX      0x2000000	//0x400000	//PROTECTOR//SILENCER
+// 4Mb of textures is enough especially considering the number of people playing the game
+// still with voodoo 1 and 2 class cards with limited local memory.
+//PROTECTOR: blahblahblah voodoo foo. welcome to the 21st century, buy yourself a graphics card with 1024mb ram for 100$.
+//SILENCER: We don't have to overdo it THAT much. It still is just Goldsource. Lowered to 32 MB.
+
+#define DEFAULT_MAX_MAP_LIGHTDATA	0x2000000	//0x600000 (6 MB) //SILENCER: New is 32 MB
+// arbitrary
+
+#define MAX_MAP_VISIBILITY  0x1000000	//0x200000	//SILENCER
+// arbitrary
+
+// these are for entity key:value pairs
+#define MAX_KEY                 64	//32	//SILENCER
+#define ZHLT3_MAX_VALUE             4096
+// quote from yahn: 'probably can raise these values if needed'
+
+// texture size limit
+#define MAX_TEXTURE_SIZE   (256 * 256 * sizeof(short) * 3) / 2
+// this is arbitrary, and needs space for the largest realistic texture plus
+// room for its mipmaps. This value is primarily used to catch damaged or
+// invalid textures in a wad file
+
+//=============================================================================
+
+#define BSPVERSION  30
+#define TOOLVERSION 2
+
+
+//
+// BSP File Structures
+//
+
+
+typedef struct
+{
+    int             fileofs, filelen;
+}
+lump_t;
+
+#define LUMP_ENTITIES      0
+#define LUMP_PLANES        1
+#define LUMP_TEXTURES      2
+#define LUMP_VERTEXES      3
+#define LUMP_VISIBILITY    4
+#define LUMP_NODES         5
+#define LUMP_TEXINFO       6
+#define LUMP_FACES         7
+#define LUMP_LIGHTING      8
+#define LUMP_CLIPNODES     9
+#define LUMP_LEAFS        10
+#define LUMP_MARKSURFACES 11
+#define LUMP_EDGES        12
+#define LUMP_SURFEDGES    13
+#define LUMP_MODELS       14
+#define HEADER_LUMPS      15
+
+//#define LUMP_MISCPAD      -1
+//#define LUMP_ZEROPAD      -2
+
+typedef struct
+{
+    float           mins[3], maxs[3];
+    float           origin[3];
+    int             headnode[MAX_MAP_HULLS];
+    int             visleafs;                              // not including the solid leaf 0
+    int             firstface, numfaces;
+}
+dmodel_t;
+
+typedef struct
+{
+    int             version;
+    lump_t          lumps[HEADER_LUMPS];
+}
+dheader_t;
+
+typedef struct
+{
+    int             nummiptex;
+    int             dataofs[4];                            // [nummiptex]
+}
+dmiptexlump_t;
+
+#define MIPLEVELS   4
+typedef struct miptex_s
+{
+    char            name[16];
+    unsigned        width, height;
+    unsigned        offsets[MIPLEVELS];                    // four mip maps stored
+}
+miptex_t;
+
+typedef struct
+{
+    float           point[3];
+}
+dvertex_t;
+
+typedef struct
+{
+    float           normal[3];
+    float           dist;
+    planetypes      type;                                  // PLANE_X - PLANE_ANYZ ?remove? trivial to regenerate
+}
+dplane_t;
+
+typedef enum
+{
+    CONTENTS_EMPTY = -1,
+    CONTENTS_SOLID = -2,
+    CONTENTS_WATER = -3,
+    CONTENTS_SLIME = -4,
+    CONTENTS_LAVA = -5,
+    CONTENTS_SKY = -6,
+    CONTENTS_ORIGIN = -7,                                  // removed at csg time
+    CONTENTS_CLIP = -8,                                    // changed to contents_solid
+
+    CONTENTS_CURRENT_0 = -9,
+    CONTENTS_CURRENT_90 = -10,
+    CONTENTS_CURRENT_180 = -11,
+    CONTENTS_CURRENT_270 = -12,
+    CONTENTS_CURRENT_UP = -13,
+    CONTENTS_CURRENT_DOWN = -14,
+
+    CONTENTS_TRANSLUCENT = -15,
+    CONTENTS_HINT = -16,     // Filters down to CONTENTS_EMPTY by bsp, ENGINE SHOULD NEVER SEE THIS
+
+#ifdef ZHLT_NULLTEX
+    CONTENTS_NULL = -17,     // AJM  // removed in csg and bsp, VIS or RAD shouldnt have to deal with this, only clip planes!
+#endif
+
+#ifdef ZHLT_DETAIL   // AJM
+    CONTENTS_DETAIL = -18,  
+#endif
+}
+contents_t;
+
+// !!! if this is changed, it must be changed in asm_i386.h too !!!
+typedef struct
+{
+    int             planenum;
+    short           children[2];                           // negative numbers are -(leafs+1), not nodes
+    short           mins[3];                               // for sphere culling
+    short           maxs[3];
+    unsigned short  firstface;
+    unsigned short  numfaces;                              // counting both sides
+}
+dnode_t;
+
+typedef struct
+{
+    int             planenum;
+    short           children[2];                           // negative numbers are contents
+}
+dclipnode_t;
+
+typedef struct texinfo_s
+{
+    float           vecs[2][4];                            // [s/t][xyz offset]
+    int             miptex;
+    int             flags;
+}
+texinfo_t;
+
+#define TEX_SPECIAL     1                                  // sky or slime or null, no lightmap or 256 subdivision
+
+// note that edge 0 is never used, because negative edge nums are used for
+// counterclockwise use of the edge in a face
+typedef struct
+{
+    unsigned short  v[2];                                  // vertex numbers
+}
+dedge_t;
+
+#define MAXLIGHTMAPS    4
+typedef struct
+{
+    unsigned short	planenum;
+    short           side;
+
+    int             firstedge;                             // we must support > 64k edges
+    short           numedges;
+    short           texinfo;
+
+    // lighting info
+    byte            styles[MAXLIGHTMAPS];
+    int             lightofs;                              // start of [numstyles*surfsize] samples
+}
+dface_t;
+
+#define AMBIENT_WATER   0
+#define AMBIENT_SKY     1
+#define AMBIENT_SLIME   2
+#define AMBIENT_LAVA    3
+
+#define NUM_AMBIENTS            4                  // automatic ambient sounds
+
+// leaf 0 is the generic CONTENTS_SOLID leaf, used for all solid areas
+// all other leafs need visibility info
+typedef struct
+{
+    int             contents;
+    int             visofs;                                // -1 = no visibility info
+
+    short           mins[3];                               // for frustum culling
+    short           maxs[3];
+
+    unsigned short  firstmarksurface;
+    unsigned short  nummarksurfaces;
+
+    byte            ambient_level[NUM_AMBIENTS];
+}
+dleaf_t;
+
+//============================================================================
+
+#define ANGLE_UP    -1
+#define ANGLE_DOWN  -2
+
+//
+// BSP File Data
+//
+
+extern int      g_nummodels;
+extern dmodel_t g_dmodels[MAX_MAP_MODELS];
+extern int      g_dmodels_checksum;
+
+extern int      g_visdatasize;
+extern byte     g_dvisdata[MAX_MAP_VISIBILITY];
+extern int      g_dvisdata_checksum;
+
+extern int      g_lightdatasize;
+extern byte*    g_dlightdata;
+extern int      g_dlightdata_checksum;
+
+extern int      g_texdatasize;
+extern byte*    g_dtexdata;                                  // (dmiptexlump_t)
+extern int      g_dtexdata_checksum;
+
+extern int      g_entdatasize;
+extern char     g_dentdata[MAX_MAP_ENTSTRING];
+extern int      g_dentdata_checksum;
+
+extern int      g_numleafs;
+extern dleaf_t  g_dleafs[MAX_MAP_LEAFS];
+extern int      g_dleafs_checksum;
+
+extern int      g_numplanes;
+extern dplane_t g_dplanes[MAX_INTERNAL_MAP_PLANES];
+extern int      g_dplanes_checksum;
+
+extern int      g_numvertexes;
+extern dvertex_t g_dvertexes[MAX_MAP_VERTS];
+extern int      g_dvertexes_checksum;
+
+extern int      g_numnodes;
+extern dnode_t  g_dnodes[MAX_MAP_NODES];
+extern int      g_dnodes_checksum;
+
+extern int      g_numtexinfo;
+extern texinfo_t g_texinfo[MAX_MAP_TEXINFO];
+extern int      g_texinfo_checksum;
+
+extern int      g_numfaces;
+extern dface_t  g_dfaces[MAX_MAP_FACES];
+extern int      g_dfaces_checksum;
+
+extern int      g_numclipnodes;
+extern dclipnode_t g_dclipnodes[MAX_MAP_CLIPNODES];
+extern int      g_dclipnodes_checksum;
+
+extern int      g_numedges;
+extern dedge_t  g_dedges[MAX_MAP_EDGES];
+extern int      g_dedges_checksum;
+
+extern int      g_nummarksurfaces;
+extern unsigned short g_dmarksurfaces[MAX_MAP_MARKSURFACES];
+extern int      g_dmarksurfaces_checksum;
+
+extern int      g_numsurfedges;
+extern int      g_dsurfedges[MAX_MAP_SURFEDGES];
+extern int      g_dsurfedges_checksum;
+
+extern void     DecompressVis(const byte* src, byte* const dest, const unsigned int dest_length);
+extern int      CompressVis(const byte* const src, const unsigned int src_length, byte* dest, unsigned int dest_length);
+
+extern void     LoadBSPImage(dheader_t* header);
+extern void     LoadBSPFile(const char* const filename);
+extern void     WriteBSPFile(const char* const filename);
+extern void     PrintBSPFileSizes();
+
+//
+// Entity Related Stuff
+//
+
+typedef struct epair_s
+{
+    struct epair_s* next;
+    char*           key;
+    char*           value;
+}
+epair_t;
+
+typedef struct
+{
+    vec3_t          origin;
+    int             firstbrush;
+    int             numbrushes;
+    epair_t*        epairs;
+}
+entity_t;
+
+extern int      g_numentities;
+extern entity_t g_entities[MAX_MAP_ENTITIES];
+
+extern void            ParseEntities(int * lNumAddress, int * lListAddress);
+extern void            UnparseEntities();
+
+extern void            strins(char* srcDestStr, const int maxNewLen, const char* insStr, const int insAtPos, const bool overwrite, const char fillGap);
+extern void            MarkEntityAsRedundant(entity_t* ent);
+extern entity_t*       AddEntity(const char* const classname, int neworigin[3]);
+extern void            RemoveKeyValue(entity_t* ent, const char* const key);
+extern void            SetKeyValue(entity_t* ent, const char* const key, const char* const value);
+extern const char*     ValueForKey(const entity_t* const ent, const char* const key);
+extern int             IntForKey(const entity_t* const ent, const char* const key);
+extern vec_t           FloatForKey(const entity_t* const ent, const char* const key);
+extern bool            BoolForKey(const entity_t* const ent, const char* const key);
+extern void            GetVectorForKey(const entity_t* const ent, const char* const key, vec3_t vec);
+extern void            GetIntVectorForKey(const entity_t* const ent, const char* const key, int vec[3]);
+
+extern entity_t* FindTargetEntity(const char* const target);
+extern epair_t* ParseEpair();
+extern entity_t* EntityForModel(int modnum);
+
+//
+// Texture Related Stuff
+//
+
+extern int      g_max_map_miptex;
+extern int		g_max_map_lightdata;
+extern void     dtexdata_init();
+extern void CDECL dtexdata_free();
+
+extern char*    GetTextureByNumber(int texturenumber);
+
+#endif //BSPFILE_H__

+ 578 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/cmdlib.cpp

@@ -0,0 +1,578 @@
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4996)
+#endif
+
+#ifdef SYSTEM_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
+#include "cmdlib.h"
+#include "messages.h"
+#include "hlassert.h"
+#include "blockmem.h"
+#include "log.h"
+
+#ifdef SYSTEM_POSIX
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#endif
+
+#define PATHSEPARATOR(c) ((c) == '\\' || (c) == '/')
+
+/*
+ * ================
+ * I_FloatTime
+ * ================
+ */
+
+double          I_FloatTime()
+{
+#ifdef SYSTEM_WIN32
+    FILETIME        ftime;
+    double rval;
+
+    GetSystemTimeAsFileTime(&ftime);
+
+    rval = ftime.dwLowDateTime;
+    rval += ((__int64)ftime.dwHighDateTime) << 32;
+
+    return (rval / 10000000.0);
+#endif
+
+#ifdef SYSTEM_POSIX
+    struct timeval  tp;
+    struct timezone tzp;
+    static int      secbase;
+
+    gettimeofday(&tp, &tzp);
+
+    if (!secbase)
+    {
+        secbase = tp.tv_sec;
+        return tp.tv_usec / 1000000.0;
+    }
+
+    return (tp.tv_sec - secbase) + tp.tv_usec / 1000000.0;
+#endif
+}
+
+#ifdef SYSTEM_POSIX
+char*           strupr(char* string)
+{
+    int             i;
+    int             len = strlen(string);
+
+    for (i = 0; i < len; i++)
+    {
+        string[i] = toupper(string[i]);
+    }
+    return string;
+}
+
+char*           strlwr(char* string)
+{
+    int             i;
+    int             len = strlen(string);
+
+    for (i = 0; i < len; i++)
+    {
+        string[i] = tolower(string[i]);
+    }
+    return string;
+}
+#endif
+
+// Case Insensitive substring matching
+const char*     stristr(const char* const string, const char* const substring)
+{
+    char*           string_copy;
+    char*           substring_copy;
+    const char*     match;
+
+    string_copy = _strdup(string);
+    _strlwr(string_copy);
+
+    substring_copy = _strdup(substring);
+    _strlwr(substring_copy);
+
+    match = strstr(string_copy, substring_copy);
+    if (match)
+    {
+        match = (string + (match - string_copy));
+    }
+
+    free(string_copy);
+    free(substring_copy);
+    return match;
+}
+
+/*--------------------------------------------------------------------
+// New implementation of FlipSlashes, DefaultExtension, StripFilename, 
+// StripExtension, ExtractFilePath, ExtractFile, ExtractFileBase, etc.
+----------------------------------------------------------------------*/
+#ifdef ZHLT_NEW_FILE_FUNCTIONS
+
+//Since all of these functions operate around either the extension 
+//or the directory path, centralize getting both numbers here so we
+//can just reference them everywhere else.  Use strrchr to give a
+//speed boost while we're at it.
+inline void getFilePositions(char* path, int* extension_position, int* directory_position)
+{
+	char* ptr = strrchr(path,'.');
+	if(ptr == 0)
+	{ *extension_position = -1; }
+	else
+	{ *extension_position = ptr - path; }
+
+	ptr = max(strrchr(path,'/'),strrchr(path,'\\'));
+	if(ptr == 0)
+	{ *directory_position = -1; }
+	else
+	{ 
+		*directory_position = ptr - path;
+		if(*directory_position > *extension_position)
+		{ *extension_position = -1; }
+		
+		//cover the case where we were passed a directory - get 2nd-to-last slash
+		if(*directory_position == strlen(path) - 1)
+		{
+			do
+			{
+				--(*directory_position);
+			}
+			while(*directory_position > -1 && path[*directory_position] != '/' && path[*directory_position] != '\\');
+		}
+	}
+}
+
+char* FlipSlashes(char* string)
+{
+	char* ptr = string;
+	if(SYSTEM_SLASH_CHAR == '\\')
+	{
+		while(ptr = strchr(ptr,'/'))
+		{ *ptr = SYSTEM_SLASH_CHAR; }
+	}
+	else
+	{
+		while(ptr = strchr(ptr,'\\'))
+		{ *ptr = SYSTEM_SLASH_CHAR; }
+	}
+	return string;
+}
+
+void DefaultExtension(char* path, const char* extension)
+{
+	int extension_pos, directory_pos;
+	getFilePositions(path,&extension_pos,&directory_pos);
+	if(extension_pos == -1)
+	{ strcat(path,extension); }
+}
+
+void StripFilename(char* path)
+{
+	int extension_pos, directory_pos;
+	getFilePositions(path,&extension_pos,&directory_pos);
+	if(directory_pos == -1)
+	{ path[0] = 0; }
+	else
+	{ path[directory_pos] = 0; }
+}
+
+void StripExtension(char* path)
+{
+	int extension_pos, directory_pos;
+	getFilePositions(path,&extension_pos,&directory_pos);
+	if(extension_pos != -1)
+	{ path[extension_pos] = 0; }
+}
+
+void ExtractFilePath(char* const path, char* dest)
+{
+	int extension_pos, directory_pos;
+	getFilePositions(path,&extension_pos,&directory_pos);
+	if(directory_pos != -1)
+	{
+	    memcpy(dest,path,directory_pos+1); //include directory slash
+	    dest[directory_pos+1] = 0;
+	}
+	else
+	{ dest[0] = 0; }
+}
+
+void ExtractFile(char* const path, char* dest)
+{
+	int extension_pos, directory_pos;
+	getFilePositions(path,&extension_pos,&directory_pos);
+
+	int length = (int)strlen(path);
+
+	if(directory_pos == -1)	{ directory_pos = 0; }
+	else { length -= directory_pos + 1; }
+
+    memcpy(dest,path+directory_pos+1,length); //exclude directory slash
+    dest[length] = 0;
+}
+
+void ExtractFileBase(char* const path, char* dest)
+{
+	int extension_pos, directory_pos;
+	getFilePositions(path,&extension_pos,&directory_pos);
+	int length = extension_pos == -1 ? (int)strlen(path) : extension_pos;
+
+	if(directory_pos == -1)	{ directory_pos = 0; }
+	else { length -= directory_pos + 1; }
+
+    memcpy(dest,path+directory_pos+1,length); //exclude directory slash
+    dest[length] = 0;
+}
+
+void ExtractFileExtension(char* const path, char* dest)
+{
+	int extension_pos, directory_pos;
+	getFilePositions(path,&extension_pos,&directory_pos);
+	if(extension_pos != -1)
+	{
+		int length = (int)strlen(path) - extension_pos;
+	    memcpy(dest,path+extension_pos,length); //include extension '.'
+	    dest[length] = 0;
+	}
+	else
+	{ dest[0] = 0; }
+}
+//-------------------------------------------------------------------
+#else //old cmdlib functions
+
+char*           FlipSlashes(char* string)
+{
+    while (*string)
+    {
+        if (PATHSEPARATOR(*string))
+        {
+            *string = SYSTEM_SLASH_CHAR;
+        }
+        string++;
+    }
+    return string;
+}
+
+void            DefaultExtension(char* path, const char* extension)
+{
+    char*           src;
+
+    //
+    // if path doesn't have a .EXT, append extension
+    // (extension should include the .)
+    //
+    src = path + strlen(path) - 1;
+
+    while (!PATHSEPARATOR(*src) && src != path)
+    {
+        if (*src == '.')
+            return;                                        // it has an extension
+        src--;
+    }
+
+    strcat(path, extension);
+}
+
+void            StripFilename(char* path)
+{
+    int             length;
+
+    length = strlen(path) - 1;
+    while (length > 0 && !PATHSEPARATOR(path[length]))
+        length--;
+    path[length] = 0;
+}
+
+void            StripExtension(char* path)
+{
+    int             length;
+
+    length = strlen(path) - 1;
+    while (length > 0 && path[length] != '.')
+    {
+        length--;
+        if (PATHSEPARATOR(path[length]))
+            return;                                        // no extension
+    }
+    if (length)
+        path[length] = 0;
+}
+
+/*
+ * ====================
+ * Extract file parts
+ * ====================
+ */
+void            ExtractFilePath(const char* const path, char* dest)
+{
+    hlassert (path != dest);
+
+    const char*           src;
+
+    src = path + strlen(path) - 1;
+
+    //
+    // back up until a \ or the start
+    //
+    while (src != path && !PATHSEPARATOR(*(src - 1)))
+        src--;
+
+    memcpy(dest, path, src - path);
+    dest[src - path] = 0;
+}
+
+void            ExtractFile(const char* const path, char* dest)
+{
+    hlassert (path != dest);
+
+    const char*           src;
+
+    src = path + strlen(path) - 1;
+
+    while (src != path && !PATHSEPARATOR(*(src - 1)))
+        src--;
+
+    while (*src)
+    {
+        *dest++ = *src++;
+    }
+    *dest = 0;
+}
+
+void            ExtractFileBase(const char* const path, char* dest)
+{
+    hlassert (path != dest);
+
+    const char*           src;
+
+    src = path + strlen(path) - 1;
+
+    //
+    // back up until a \ or the start
+    //
+    while (src != path && !PATHSEPARATOR(*(src - 1)))
+        src--;
+
+    while (*src && *src != '.')
+    {
+        *dest++ = *src++;
+    }
+    *dest = 0;
+}
+
+void            ExtractFileExtension(const char* const path, char* dest)
+{
+    hlassert (path != dest);
+
+    const char*           src;
+
+    src = path + strlen(path) - 1;
+
+    //
+    // back up until a . or the start
+    //
+    while (src != path && *(src - 1) != '.')
+        src--;
+    if (src == path)
+    {
+        *dest = 0;                                         // no extension
+        return;
+    }
+
+    strcpy_s(dest, src);
+}
+
+#endif
+
+/*
+ * ============================================================================
+ * 
+ * BYTE ORDER FUNCTIONS
+ * 
+ * ============================================================================
+ */
+
+#ifdef WORDS_BIGENDIAN
+
+short           LittleShort(const short l)
+{
+    byte            b1, b2;
+
+    b1 = l & 255;
+    b2 = (l >> 8) & 255;
+
+    return (b1 << 8) + b2;
+}
+
+short           BigShort(const short l)
+{
+    return l;
+}
+
+int             LittleLong(const int l)
+{
+    byte            b1, b2, b3, b4;
+
+    b1 = l & 255;
+    b2 = (l >> 8) & 255;
+    b3 = (l >> 16) & 255;
+    b4 = (l >> 24) & 255;
+
+    return ((int)b1 << 24) + ((int)b2 << 16) + ((int)b3 << 8) + b4;
+}
+
+int             BigLong(const int l)
+{
+    return l;
+}
+
+float           LittleFloat(const float l)
+{
+    union
+    {
+        byte            b[4];
+        float           f;
+    }
+    in             , out;
+
+    in.f = l;
+    out.b[0] = in.b[3];
+    out.b[1] = in.b[2];
+    out.b[2] = in.b[1];
+    out.b[3] = in.b[0];
+
+    return out.f;
+}
+
+float           BigFloat(const float l)
+{
+    return l;
+}
+
+#else // Little endian (Intel, etc)
+
+short           BigShort(const short l)
+{
+    byte            b1, b2;
+
+    b1 = (byte) (l & 255);
+    b2 = (byte) ((l >> 8) & 255);
+
+    return (short)((b1 << 8) + b2);
+}
+
+short           LittleShort(const short l)
+{
+    return l;
+}
+
+int             BigLong(const int l)
+{
+    byte            b1, b2, b3, b4;
+
+    b1 = (byte) (l & 255);
+    b2 = (byte) ((l >> 8) & 255);
+    b3 = (byte) ((l >> 16) & 255);
+    b4 = (byte) ((l >> 24) & 255);
+
+    return ((int)b1 << 24) + ((int)b2 << 16) + ((int)b3 << 8) + b4;
+}
+
+int             LittleLong(const int l)
+{
+    return l;
+}
+
+float           BigFloat(const float l)
+{
+    union
+    {
+        byte            b[4];
+        float           f;
+    }
+    in             , out;
+
+    in.f = l;
+    out.b[0] = in.b[3];
+    out.b[1] = in.b[2];
+    out.b[2] = in.b[1];
+    out.b[3] = in.b[0];
+
+    return out.f;
+}
+
+float           LittleFloat(const float l)
+{
+    return l;
+}
+
+#endif
+
+//=============================================================================
+
+bool CDECL      safe_snprintf(char* const dest, const size_t count, const char* const args, ...)
+{
+    size_t          amt;
+    va_list         argptr;
+
+    hlassert(count > 0);
+
+    va_start(argptr, args);
+    amt = vsnprintf(dest, count, args, argptr);
+    va_end(argptr);
+
+    // truncated (bad!, snprintf doesn't null terminate the string when this happens)
+    if (amt == count)
+    {
+        dest[count - 1] = 0;
+        return false;
+    }
+
+    return true;
+}
+
+bool            safe_strncpy(char* const dest, const char* const src, const size_t count)
+{
+    return safe_snprintf(dest, count, "%s", src);
+}
+
+bool            safe_strncat(char* const dest, const char* const src, const size_t count)
+{
+    if (count)
+    {
+        strncat(dest, src, count);
+
+        dest[count - 1] = 0;                               // Ensure it is null terminated
+        return true;
+    }
+    else
+    {
+        Warning("safe_strncat passed empty count");
+        return false;
+    }
+}
+
+bool            TerminatedString(const char* buffer, const int size)
+{
+    int             x;
+
+    for (x = 0; x < size; x++, buffer++)
+    {
+        if ((*buffer) == 0)
+        {
+            return true;
+        }
+    }
+    return false;
+}

+ 170 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/cmdlib.h

@@ -0,0 +1,170 @@
+#ifndef CMDLIB_H__
+#define CMDLIB_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#ifdef __MINGW32__
+#include <io.h>
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+// AJM: gnu compiler fix
+#ifdef __GNUC__
+#define _alloca __builtin_alloca
+#define alloca __builtin_alloca
+#endif
+
+#include "win32fix.h"
+#include "mathtypes.h"
+
+#ifdef _DEBUG
+#define ZHLT_VERSIONSTRING "v3.9"
+#else
+#define ZHLT_VERSIONSTRING "3.9"
+#endif
+
+// SILENCER -->
+#if !defined(_WIN64)
+
+#if _M_IX86_FP == 0
+#define HACK_VERSIONSTRING "x86 (32b) SSE OFF"
+#endif
+
+#if _M_IX86_FP == 1
+#define HACK_VERSIONSTRING "x86 (32b) SSE1 ON"
+#endif
+
+#if _M_IX86_FP == 2
+#define HACK_VERSIONSTRING "x86 (32b) SSE2 ON"
+#endif
+
+#else
+#define HACK_VERSIONSTRING "x64 (64b)        "
+#endif
+// <-- SILENCER
+
+
+//=====================================================================
+// AJM: Different features of the tools can be undefined here
+//      these are not officially beta tested, but seem to work okay
+
+// ZHLT_* features are spread across more than one tool. Hence, changing
+//      one of these settings probably means recompiling the whole set
+#define ZHLT_INFO_COMPILE_PARAMETERS        // ALL TOOLS
+#define ZHLT_NULLTEX                        // HLCSG, HLBSP
+#define ZHLT_TEXLIGHT                       // HLCSG, HLRAD - triggerable texlights by LRC
+#define ZHLT_GENERAL                        // ALL TOOLS - general changes
+#define ZHLT_NEW_FILE_FUNCTIONS				// ALL TOOLS - file path/extension extraction functions
+//#define ZHLT_DETAIL                         // HLCSG, HLBSP - detail brushes    
+//#define ZHLT_PROGRESSFILE                   // ALL TOOLS - estimate progress reporting to -progressfile
+//#define ZHLT_NSBOB
+
+#define ZHLT_VectorMA_FIX //--vluzacn
+
+#define ZHLT_PLANETYPE_FIX // Very Important !! --vluzacn
+
+#define COMMON_HULLU // winding optimisations by hullu
+
+// tool specific settings below only mean a recompile of the tool affected
+#define HLCSG_CLIPECONOMY
+#define HLCSG_WADCFG
+#define HLCSG_AUTOWAD
+
+#define HLCSG_PRECISIONCLIP
+#define HLCSG_FASTFIND
+#ifdef ZHLT_NULLTEX
+	#define HLCSG_NULLIFY_INVISIBLE //requires null textures as prerequisite
+#endif
+
+#define HLCSG_SORTBRUSH_FIX
+
+//#define HLBSP_THREADS // estimate for hlbsp
+
+#define HLVIS_MAXDIST
+
+#define HLRAD_INFO_TEXLIGHTS
+#define HLRAD_WHOME // encompases all of Adam Foster's changes
+#define HLRAD_HULLU // semi-opaque brush based entities and effects by hullu
+#define HLRAD_FASTMATH // optimized mathutil.cpp by KGP
+
+//=====================================================================
+
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4127 4115 4244 4786 4305 4800)
+#endif
+
+
+#ifdef STDC_HEADERS
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <ctype.h>
+#include <time.h>
+#include <stdarg.h>
+#include <limits.h>
+#endif
+
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef ZHLT_NETVIS
+#include "c2cpp.h"
+#endif
+
+#ifdef SYSTEM_WIN32
+#define SYSTEM_SLASH_CHAR  '\\'
+#define SYSTEM_SLASH_STR   "\\"
+#endif
+#ifdef SYSTEM_POSIX
+#define SYSTEM_SLASH_CHAR  '/'
+#define SYSTEM_SLASH_STR   "/"
+#endif
+
+// the dec offsetof macro doesn't work very well...
+#define myoffsetof(type,identifier) ((size_t)&((type*)0)->identifier)
+#define sizeofElement(type,identifier) (sizeof((type*)0)->identifier)
+
+#ifdef SYSTEM_POSIX
+extern char*    strupr(char* string);
+extern char*    strlwr(char* string);
+#endif
+extern const char* stristr(const char* const string, const char* const substring);
+extern bool CDECL safe_snprintf(char* const dest, const size_t count, const char* const args, ...);
+extern bool     safe_strncpy(char* const dest, const char* const src, const size_t count);
+extern bool     safe_strncat(char* const dest, const char* const src, const size_t count);
+extern bool     TerminatedString(const char* buffer, const int size);
+
+extern char*    FlipSlashes(char* string);
+
+extern double   I_FloatTime();
+
+extern int      CheckParm(char* check);
+
+extern void     DefaultExtension(char* path, const char* extension);
+extern void     DefaultPath(char* path, char* basepath);
+extern void     StripFilename(char* path);
+extern void     StripExtension(char* path);
+
+extern void     ExtractFile(const char* const path, char* dest);
+extern void     ExtractFilePath(const char* const path, char* dest);
+extern void     ExtractFileBase(const char* const path, char* dest);
+extern void     ExtractFileExtension(const char* const path, char* dest);
+
+extern short    BigShort(short l);
+extern short    LittleShort(short l);
+extern int      BigLong(int l);
+extern int      LittleLong(int l);
+extern float    BigFloat(float l);
+extern float    LittleFloat(float l);
+
+#endif //CMDLIB_H__

+ 228 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/filelib.cpp

@@ -0,0 +1,228 @@
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4996)
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef SYSTEM_WIN32
+#include <sys/stat.h>
+#include <io.h>
+#include <fcntl.h>
+#endif
+
+#ifdef SYSTEM_POSIX
+#ifdef HAVE_SYS_STAT_H
+#include <sys/stat.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+#endif
+
+#include "cmdlib.h"
+#include "messages.h"
+#include "log.h"
+#include "mathtypes.h"
+#include "mathlib.h"
+#include "blockmem.h"
+
+/*
+ * ==============
+ * getfiletime        
+ * ==============
+ */
+
+time_t          getfiletime(const char* const filename)
+{
+    time_t          filetime = 0;
+    struct stat     filestat;
+
+    if (stat(filename, &filestat) == 0)
+        filetime = max(filestat.st_mtime, filestat.st_ctime);
+
+    return filetime;
+}
+
+/*
+ * ==============      
+ * getfilesize
+ * ==============
+ */
+long            getfilesize(const char* const filename)
+{
+    long            size = 0;
+    struct stat     filestat;
+
+    if (stat(filename, &filestat) == 0)
+        size = filestat.st_size;
+
+    return size;
+}
+
+/*
+ * ==============
+ * getfiledata
+ * ==============
+ */
+long            getfiledata(const char* const filename, char* buffer, const int buffersize)
+{
+    long            size = 0;
+    int             handle;
+    time_t            start, end;
+
+    time(&start);
+
+    if ((handle = (int)fopen(filename, O_RDONLY)) != -1)
+    {
+        int             bytesread;
+
+        Log("%-20s Restoring [%-13s - ", "BuildVisMatrix:", filename);
+        while ((bytesread = _read(handle, buffer, min(32 * 1024, buffersize - size))) > 0)
+        {
+            size += bytesread;
+            buffer += bytesread;
+        }
+        _close(handle);
+        time(&end);
+        Log("%10.3fMB] (%d)\n", size / (1024.0 * 1024.0), end - start);
+    }
+
+    if (buffersize != size)
+    {
+        Warning("Invalid file [%s] found.  File will be rebuilt!\n", filename);
+        _unlink(filename);
+    }
+
+    return size;
+}
+
+/*
+ * ================
+ * filelength
+ * ================
+ */
+int             q_filelength(FILE* f)
+{
+    int             pos;
+    int             end;
+
+    pos = ftell(f);
+    fseek(f, 0, SEEK_END);
+    end = ftell(f);
+    fseek(f, pos, SEEK_SET);
+
+    return end;
+}
+
+/*
+ * ================
+ * exists
+ * ================
+ */
+bool            q_exists(const char* const filename)
+{
+    FILE*           f;
+
+    f = fopen(filename, "rb");
+
+    if (!f)
+    {
+        IfDebug(Developer(DEVELOPER_LEVEL_SPAM, "Checking for existance of file %s (failed)\n", filename));
+        return false;
+    }
+    else
+    {
+        fclose(f);
+        IfDebug(Developer(DEVELOPER_LEVEL_SPAM, "Checking for existance of file %s (success)\n", filename));
+        return true;
+    }
+}
+
+
+
+
+FILE*           SafeOpenWrite(const char* const filename)
+{
+    FILE*           f;
+
+    f = fopen(filename, "wb");
+
+    if (!f)
+        Error("Error opening %s: %s", filename, strerror(errno));
+
+    return f;
+}
+
+FILE*           SafeOpenRead(const char* const filename)
+{
+    FILE*           f;
+
+    f = fopen(filename, "rb");
+
+    if (!f)
+        Error("Error opening %s: %s", filename, strerror(errno));
+
+    return f;
+}
+
+void            SafeRead(FILE* f, void* buffer, int count)
+{
+	if (fread(buffer, 1, count, f) != (size_t) count) {
+		Log("\n");
+        Error("File read failure.\n");
+	}
+}
+
+void            SafeWrite(FILE* f, const void* const buffer, int count)
+{
+	if (fwrite(buffer, 1, count, f) != (size_t) count) {
+		Log("\n");
+		Error("File write failure.\n"
+		      "       Maybe you exceeded a critical map limit? (E.g.: Leafs)\n"
+		      "       Check above. (Some objects, as a result of exceeding a\n"
+		      "       limit, may be negative bogus)\n");
+	}
+}
+
+/*
+ * ==============
+ * LoadFile
+ * ==============
+ */
+int             LoadFile(const char* const filename, char** bufferptr)
+{
+    FILE*           f;
+    int             length;
+    char*           buffer;
+
+    f = SafeOpenRead(filename);
+    length = q_filelength(f);
+    buffer = (char*)Alloc(length + 1);
+    SafeRead(f, buffer, length);
+    fclose(f);
+
+    *bufferptr = buffer;
+    return length;
+}
+
+/*
+ * ==============
+ * SaveFile
+ * ==============
+ */
+void            SaveFile(const char* const filename, const void* const buffer, int count)
+{
+    FILE*           f;
+
+    f = SafeOpenWrite(filename);
+    SafeWrite(f, buffer, count);
+    fclose(f);
+}
+

+ 22 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/filelib.h

@@ -0,0 +1,22 @@
+#ifndef FILELIB_H__
+#define FILELIB_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+extern time_t   getfiletime(const char* const filename);
+extern long     getfilesize(const char* const filename);
+extern long     getfiledata(const char* const filename, char* buffer, const int buffersize);
+extern bool     q_exists(const char* const filename);
+extern int      q_filelength(FILE* f);
+
+extern FILE*    SafeOpenWrite(const char* const filename);
+extern FILE*    SafeOpenRead(const char* const filename);
+extern void     SafeRead(FILE* f, void* buffer, int count);
+extern void     SafeWrite(FILE* f, const void* const buffer, int count);
+
+extern int      LoadFile(const char* const filename, char** bufferptr);
+extern void     SaveFile(const char* const filename, const void* const buffer, int count);
+
+#endif //**/ FILELIB_H__

+ 0 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/files.cpp


+ 40 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/hlassert.h

@@ -0,0 +1,40 @@
+#ifndef HLASSERT_H__
+#define HLASSERT_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#ifdef SYSTEM_WIN32
+#ifdef _DEBUG
+
+#include "log.h"
+
+#define assume(exp, message) {if (!(exp)) {Log("\n***** ERROR *****\nAssume '%s' failed\n at %s:%d\n %s\n\n", #exp, __FILE__, __LINE__, message);  __asm{int 3} }}
+#define hlassert(exp) assume(exp, "")
+
+#else // _DEBUG
+
+#define assume(exp, message) {if (!(exp)) {Error("\nAssume '%s' failed\n at %s:%d\n %s\n\n", #exp, __FILE__, __LINE__, message);}}
+#define hlassert(exp)
+
+#endif // _DEBUG
+#endif // SYSTEM_WIN32
+
+#ifdef SYSTEM_POSIX
+#ifdef _DEBUG
+
+#include "log.h"
+
+#define assume(exp, message) {if (!(exp)) {Log("\n***** ERROR *****\nAssume '%s' failed\n at %s:%d\n %s\n\n", #exp, __FILE__, __LINE__, message);  exit(-1); }}
+#define hlassert(exp) assume(exp, "")
+
+#else // _DEBUG
+
+#define assume(exp, message) {if (!(exp)) {Error("\nAssume '%s' failed\n\n", #exp, __FILE__, __LINE__, message);}}
+#define hlassert(exp)
+
+#endif // _DEBUG
+#endif // SYSTEM_POSIX
+
+#endif // SYSTEM_POSIX HLASSERT_H__

+ 684 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/log.cpp

@@ -0,0 +1,684 @@
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4996)
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef ZHLT_NETVIS
+#ifdef SYSTEM_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+#endif
+
+#ifdef STDC_HEADERS
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdarg.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef ZHLT_NETVIS
+#include "../netvis/c2cpp.h"
+#endif
+
+#include "cmdlib.h"
+#include "messages.h"
+#include "hlassert.h"
+#include "log.h"
+#include "filelib.h"
+#include <windows.h>
+
+char*           g_Program = "Uninitialized variable ::g_Program";
+char            g_Mapname[_MAX_PATH] = "Uninitialized variable ::g_Mapname";
+
+developer_level_t g_developer = DEFAULT_DEVELOPER;
+bool            g_verbose = DEFAULT_VERBOSE;
+bool            g_log = DEFAULT_LOG;
+
+unsigned long   g_clientid = 0;
+unsigned long   g_nextclientid = 0;
+
+static FILE*    CompileLog = NULL;
+static bool     fatal = false;
+
+bool g_noConColors = false;
+
+////////
+
+void            ResetTmpFiles()
+{
+    if (g_log)
+    {
+        char            filename[_MAX_PATH];
+
+        safe_snprintf(filename, _MAX_PATH, "%s.bsp", g_Mapname);
+        _unlink(filename);
+
+        safe_snprintf(filename, _MAX_PATH, "%s.inc", g_Mapname);
+        _unlink(filename);
+
+        safe_snprintf(filename, _MAX_PATH, "%s.p0", g_Mapname);
+        _unlink(filename);
+
+        safe_snprintf(filename, _MAX_PATH, "%s.p1", g_Mapname);
+        _unlink(filename);
+
+        safe_snprintf(filename, _MAX_PATH, "%s.p2", g_Mapname);
+        _unlink(filename);
+
+        safe_snprintf(filename, _MAX_PATH, "%s.p3", g_Mapname);
+        _unlink(filename);
+
+        safe_snprintf(filename, _MAX_PATH, "%s.prt", g_Mapname);
+        _unlink(filename);
+
+        safe_snprintf(filename, _MAX_PATH, "%s.pts", g_Mapname);
+        _unlink(filename);
+
+        safe_snprintf(filename, _MAX_PATH, "%s.lin", g_Mapname);
+        _unlink(filename);
+
+        safe_snprintf(filename, _MAX_PATH, "%s.wic", g_Mapname);
+        _unlink(filename);
+    }
+}
+
+void            ResetLog()
+{
+    if (g_log)
+    {
+        char            logfilename[_MAX_PATH];
+
+        safe_snprintf(logfilename, _MAX_PATH, "%s.log", g_Mapname);
+        _unlink(logfilename);
+    }
+}
+
+void            ResetErrorLog()
+{
+    if (g_log)
+    {
+        char            logfilename[_MAX_PATH];
+
+        safe_snprintf(logfilename, _MAX_PATH, "%s.err", g_Mapname);
+        _unlink(logfilename);
+    }
+}
+
+void            CheckForErrorLog()
+{
+    if (g_log)
+    {
+        char            logfilename[_MAX_PATH];
+
+        safe_snprintf(logfilename, _MAX_PATH, "%s.err", g_Mapname);
+        if (q_exists(logfilename))
+        {
+            Log(">> There was a problem compiling the map.\n"
+                ">> Check the file %s.log for the cause.\n",
+                 g_Mapname);
+            exit(1);
+        }
+    }
+}
+
+///////
+
+void            LogError(const char* const message)
+{
+    if (g_log && CompileLog)
+    {
+        char            logfilename[_MAX_PATH];
+        FILE*           ErrorLog = NULL;
+
+        safe_snprintf(logfilename, _MAX_PATH, "%s.err", g_Mapname);
+        ErrorLog = fopen(logfilename, "a");
+
+        if (ErrorLog)
+        {
+            fprintf(ErrorLog, "%s: %s\n", g_Program, message);
+            fflush(ErrorLog);
+            fclose(ErrorLog);
+            ErrorLog = NULL;
+        }
+        else
+        {
+            fprintf(stderr, "ERROR: Could not open error logfile %s", logfilename);
+            fflush(stderr);
+        }
+    }
+}
+
+void CDECL      OpenLog(const int clientid)
+{
+    if (g_log)
+    {
+        char            logfilename[_MAX_PATH];
+
+#ifdef ZHLT_NETVIS
+    #ifdef SYSTEM_WIN32
+        if (clientid)
+        {
+            char            computername[MAX_COMPUTERNAME_LENGTH + 1];
+            unsigned long   size = sizeof(computername);
+
+            if (!GetComputerName(computername, &size))
+            {
+                safe_strncpy(computername, "unknown", sizeof(computername));
+            }
+            safe_snprintf(logfilename, _MAX_PATH, "%s-%s-%d.log", g_Mapname, computername, clientid);
+        }
+        else
+    #endif
+    #ifdef SYSTEM_POSIX
+        if (clientid)
+        {
+            char            computername[_MAX_PATH];
+            unsigned long   size = sizeof(computername);
+
+            if (gethostname(computername, size))
+            {
+                safe_strncpy(computername, "unknown", sizeof(computername));
+            }
+            safe_snprintf(logfilename, _MAX_PATH, "%s-%s-%d.log", g_Mapname, computername, clientid);
+        }
+    #endif
+#endif
+        {
+            safe_snprintf(logfilename, _MAX_PATH, "%s.log", g_Mapname);
+        }
+        CompileLog = fopen(logfilename, "a");
+
+        if (!CompileLog)
+        {
+            fprintf(stderr, "ERROR: Could not open logfile %s", logfilename);
+            fflush(stderr);
+        }
+    }
+}
+
+void CDECL      CloseLog()
+{
+    if (g_log && CompileLog)
+    {
+        LogEnd();
+        fflush(CompileLog);
+        fclose(CompileLog);
+        CompileLog = NULL;
+    }
+}
+
+//
+//  Every function up to this point should check g_log, the functions below should not
+//
+
+#ifdef SYSTEM_WIN32
+// AJM: fprintf/flush wasnt printing newline chars correctly (prefixed with \r) under win32
+//      due to the fact that those streams are in byte mode, so this function prefixes 
+//      all \n with \r automatically.
+//      NOTE: system load may be more with this method, but there isnt that much logging going
+//      on compared to the time taken to compile the map, so its negligable.
+void            Safe_WriteLog(const char* const message)
+{
+    const char* c;
+    
+    if (!CompileLog)
+        return;
+
+    c = &message[0];
+
+    while (1)
+    {
+        if (!*c)
+            return; // end of string
+
+        if (*c == '\n')
+            fputc('\r', CompileLog);
+
+        fputc(*c, CompileLog);
+
+        c++;
+    }
+}
+#endif
+
+void            WriteLog(const char* const message)
+{
+
+#ifndef SYSTEM_WIN32
+    if (CompileLog)
+    {
+        fprintf(CompileLog, message);
+        fflush(CompileLog);
+    }
+#else
+    Safe_WriteLog(message);
+#endif
+
+    fprintf(stdout, message);
+    fflush(stdout);
+}
+
+// =====================================================================================
+//  CheckFatal 
+// =====================================================================================
+void            CheckFatal()
+{
+    if (fatal)
+    {
+        hlassert(false);
+        exit(1);
+    }
+}
+
+#define MAX_ERROR   2048
+#define MAX_WARNING 2048
+#define MAX_MESSAGE 2048
+
+// =====================================================================================
+//  Error
+//      for formatted error messages, fatals out
+// =====================================================================================
+void CDECL      Error(const char* const error, ...)
+{
+    char            message[MAX_ERROR];
+    char            message2[MAX_ERROR];
+    va_list         argptr;
+    
+ /*#if defined( SYSTEM_WIN32 ) && !defined( __MINGW32__ ) && !defined( __BORLANDC__ )
+    {
+        char* wantint3 = getenv("WANTINT3");
+		if (wantint3)
+		{
+			if (atoi(wantint3))
+			{
+				__asm
+				{
+					int 3;
+				}
+			}
+		}
+    }
+#endif*/
+
+    va_start(argptr, error);
+    _vsnprintf_s(message, MAX_ERROR, error, argptr);
+    va_end(argptr);
+
+    safe_snprintf(message2, MAX_MESSAGE, "Error: %s\n", message);
+
+	ConColor(CONCOLOR_RED, CONCOLOR_BGDEF_BLACK); //SILENCER
+    WriteLog(message2);
+	ConColor(CONCOLOR_TXTDEF_WHITE, CONCOLOR_BGDEF_BLACK); //SILENCER
+
+    LogError(message2);
+
+    fatal = 1;
+    CheckFatal();
+}
+
+// =====================================================================================
+//  Fatal
+//      For formatted 'fatal' warning messages
+//      automatically appends an extra newline to the message
+//      This function sets a flag that the compile should abort before completing
+// =====================================================================================
+void CDECL      Fatal(assume_msgs msgid, const char* const warning, ...)
+{
+    char            message[MAX_WARNING];
+    char            message2[MAX_WARNING];
+
+    va_list         argptr;
+
+    va_start(argptr, warning);
+    _vsnprintf_s(message, MAX_WARNING, warning, argptr);
+    va_end(argptr);
+
+    safe_snprintf(message2, MAX_MESSAGE, "Error: %s\n", message);
+
+	ConColor(CONCOLOR_RED, CONCOLOR_BGDEF_BLACK); //SILENCER
+    WriteLog(message2);
+	ConColor(CONCOLOR_TXTDEF_WHITE, CONCOLOR_BGDEF_BLACK); //SILENCER
+
+    LogError(message2);
+
+    {
+        char            message[MAX_MESSAGE];
+        const MessageTable_t* msg = GetAssume(msgid);
+
+        safe_snprintf(message, MAX_MESSAGE, "%s\nDescription: %s\nHowto Fix: %s\n", msg->title, msg->text, msg->howto);
+        PrintOnce(message);
+    }
+
+    fatal = 1;
+}
+
+// =====================================================================================
+//  PrintOnce
+//      This function is only callable one time. Further calls will be ignored
+// =====================================================================================
+void CDECL      PrintOnce(const char* const warning, ...)
+{
+    char            message[MAX_WARNING];
+    char            message2[MAX_WARNING];
+    va_list         argptr;
+    static int      count = 0;
+
+    if (count > 0) // make sure it only gets called once
+    {
+        return;
+    }
+    count++;
+
+    va_start(argptr, warning);
+    _vsnprintf_s(message, MAX_WARNING, warning, argptr);
+    va_end(argptr);
+
+    safe_snprintf(message2, MAX_MESSAGE, "Error: %s\n", message);
+    WriteLog(message2);
+    LogError(message2);
+}
+
+// =====================================================================================
+//  Warning
+//      For formatted warning messages
+//      automatically appends an extra newline to the message
+// =====================================================================================
+void CDECL      Warning(const char* const warning, ...)
+{
+    char            message[MAX_WARNING];
+    char            message2[MAX_WARNING];
+
+    va_list         argptr;
+
+    va_start(argptr, warning);
+    _vsnprintf_s(message, MAX_WARNING, warning, argptr);
+    va_end(argptr);
+
+    safe_snprintf(message2, MAX_MESSAGE, "Warning: %s\n", message);
+	ConColor(CONCOLOR_YELLOW, CONCOLOR_BGDEF_BLACK); //SILENCER
+    WriteLog(message2);
+	ConColor(CONCOLOR_TXTDEF_WHITE, CONCOLOR_BGDEF_BLACK); //SILENCER
+}
+
+// =====================================================================================
+//  Verbose
+//      Same as log but only prints when in verbose mode
+// =====================================================================================
+void CDECL      Verbose(const char* const warning, ...)
+{
+    if (g_verbose)
+    {
+        char            message[MAX_MESSAGE];
+
+        va_list         argptr;
+
+        va_start(argptr, warning);
+        _vsnprintf_s(message, MAX_MESSAGE, warning, argptr);
+        va_end(argptr);
+
+        WriteLog(message);
+    }
+}
+
+// =====================================================================================
+//  Developer
+//      Same as log but only prints when in developer mode
+// =====================================================================================
+void CDECL      Developer(developer_level_t level, const char* const warning, ...)
+{
+    if (level <= g_developer)
+    {
+        char            message[MAX_MESSAGE];
+
+        va_list         argptr;
+
+        va_start(argptr, warning);
+        _vsnprintf_s(message, MAX_MESSAGE, warning, argptr);
+        va_end(argptr);
+
+        WriteLog(message);
+    }
+}
+
+// =====================================================================================
+//  DisplayDeveloperLevel
+// =====================================================================================
+static void     DisplayDeveloperLevel()
+{
+    char            message[MAX_MESSAGE];
+
+    safe_strncpy(message, "Developer messages enabled : [", MAX_MESSAGE);
+    if (g_developer >= DEVELOPER_LEVEL_MEGASPAM)
+    {
+        safe_strncat(message, "MegaSpam ", MAX_MESSAGE);
+    }
+    if (g_developer >= DEVELOPER_LEVEL_SPAM)
+    {
+        safe_strncat(message, "Spam ", MAX_MESSAGE);
+    }
+    if (g_developer >= DEVELOPER_LEVEL_FLUFF)
+    {
+        safe_strncat(message, "Fluff ", MAX_MESSAGE);
+    }
+    if (g_developer >= DEVELOPER_LEVEL_MESSAGE)
+    {
+        safe_strncat(message, "Message ", MAX_MESSAGE);
+    }
+    if (g_developer >= DEVELOPER_LEVEL_WARNING)
+    {
+        safe_strncat(message, "Warning ", MAX_MESSAGE);
+    }
+    if (g_developer >= DEVELOPER_LEVEL_ERROR)
+    {
+        safe_strncat(message, "Error", MAX_MESSAGE);
+    }
+    if (g_developer)
+    {
+        safe_strncat(message, "]\n", MAX_MESSAGE);
+        Log(message);
+    }
+}
+
+// =====================================================================================
+//  Log
+//      For formatted log output messages
+// =====================================================================================
+void CDECL      Log(const char* const warning, ...)
+{
+    char            message[MAX_MESSAGE];
+
+    va_list         argptr;
+
+    va_start(argptr, warning);
+    _vsnprintf_s(message, MAX_MESSAGE, warning, argptr);
+    va_end(argptr);
+
+    WriteLog(message);
+}
+
+// =====================================================================================
+//  LogArgs
+// =====================================================================================
+static void     LogArgs(int argc, char** argv)
+{
+    int             i;
+    Log("Command line: ");
+    for (i = 0; i < argc; i++) {
+        if (strchr(argv[i], ' ')) {
+            Log("\"%s\"", argv[i]);
+        } else {
+            Log("%s ", argv[i]);
+        }
+    }
+    Log("\n");
+}
+
+// =====================================================================================
+//  Banner
+// =====================================================================================
+void            Banner()
+{
+	// SILENCER -->
+	// Made this whole section a lot better, as in, more dynamic
+	// Message block - keep line lengths the same or the code below will screw up
+	char message_block[] =
+		" Super Half-Life Compilation Tools -- Custom Build.      \n"
+		" Based on code modifications by Sean 'Zoner' Cavanaugh.  \n"
+		" Based on Valve's version, modified with permission.     \n"
+		" Further development done by Silencer and Protector.     \n"
+		" Submit detailed bug reports to [email protected].       ";
+	
+	int linelength = 0;
+	int lines = 1;
+	bool gotlength = false;
+	const int msgblen = (int)strlen(message_block);
+	for(int i = 0; i < msgblen; i++) {
+		if(message_block[i] != '\n') {
+			if(!gotlength) {
+				linelength++;
+			}
+		} else {
+			lines++;
+			gotlength = true;
+		}
+	}
+	
+	ConColor(CONCOLOR_BGDEF_BLACK, CONCOLOR_TXTDEF_WHITE);
+    Log("         %s " ZHLT_VERSIONSTRING " " HACK_VERSIONSTRING " (%s)           ", g_Program, __DATE__);
+	ConColor(CONCOLOR_TXTDEF_WHITE, CONCOLOR_BGDEF_BLACK);
+	Log("\n");
+	
+	for(int i = 0; i < lines; i++) {
+		ConColor(CONCOLOR_BGDEF_BLACK, CONCOLOR_TXTDEF_WHITE);
+		Log("  ");
+		ConColor(CONCOLOR_TXTDEF_WHITE, CONCOLOR_BGDEF_BLACK);
+		char line[128];
+		int j = 0;
+		while(j < linelength && j < 127) {
+			line[j] = message_block[(i * (linelength + 1)) + j];
+			j++;
+		}
+		line[j] = '\0';
+		Log(line);
+		ConColor(CONCOLOR_BGDEF_BLACK, CONCOLOR_TXTDEF_WHITE);
+		Log("  ");
+		ConColor(CONCOLOR_TXTDEF_WHITE, CONCOLOR_BGDEF_BLACK);
+		Log("\n");
+	}
+	// <-- SILENCER
+}
+
+// =====================================================================================
+//  LogStart
+// =====================================================================================
+void            LogStart(int argc, char** argv)
+{
+    Banner();
+	ConColor(CONCOLOR_BGDEF_BLACK, CONCOLOR_TXTDEF_WHITE); //SILENCER
+    Log("                  -----  BEGIN  %s -----                  ", g_Program);
+	ConColor(CONCOLOR_TXTDEF_WHITE, CONCOLOR_BGDEF_BLACK); //SILENCER
+	Log("\n\n");
+    LogArgs(argc, argv);
+    DisplayDeveloperLevel();
+}
+
+// =====================================================================================
+//  LogEnd
+// =====================================================================================
+void            LogEnd()
+{
+    Log("\n-----   END   %s -----\n\n\n\n", g_Program);
+}
+
+// =====================================================================================
+//  hlassume
+// =====================================================================================
+
+void hlassume(bool exp, assume_msgs msgid) // Removed option to append info messages again, because it slowed down tools
+{
+    if (!exp)
+	{
+		/*//SILENCER: Commenting this feature out// SILENCER -->
+		char* check;
+		char appendmsgdefault[2048] = "Info: No additional information given.";
+
+		va_list p_args;
+
+		va_start(p_args, msgid);
+
+		if((check = va_arg(p_args, char*)) != NULL) {
+			safe_snprintf(appendmsg, 2047, "Info: %s", check);
+		}
+
+		va_end(p_args);
+		// <-- SILENCER*/
+
+		char            message[MAX_MESSAGE];
+		const MessageTable_t* msg = GetAssume(msgid);
+
+		safe_snprintf(message, MAX_MESSAGE, "%s\nDescription: %s\nHowto Fix: %s\n", msg->title, msg->text, msg->howto);
+		Error(message);
+    }
+}
+
+// =====================================================================================
+//  seconds_to_hhmm
+// =====================================================================================
+static void seconds_to_hhmm(unsigned int elapsed_time, unsigned& days, unsigned& hours, unsigned& minutes, unsigned& seconds)
+{
+    seconds = elapsed_time % 60;
+    elapsed_time /= 60;
+
+    minutes = elapsed_time % 60;
+    elapsed_time /= 60;
+
+    hours = elapsed_time % 24;
+    elapsed_time /= 24;
+
+    days = elapsed_time;
+}
+
+// =====================================================================================
+//  LogTimeElapsed
+// =====================================================================================
+void LogTimeElapsed(float elapsed_time)
+{
+    unsigned days = 0;
+    unsigned hours = 0;
+    unsigned minutes = 0;
+    unsigned seconds = 0;
+
+    seconds_to_hhmm(elapsed_time, days, hours, minutes, seconds);
+
+    if (days)
+    {
+        Log("%.2f seconds elapsed [%ud %uh %um %us]\n", elapsed_time, days, hours, minutes, seconds);
+    }
+    else if (hours)
+    {
+        Log("%.2f seconds elapsed [%uh %um %us]\n", elapsed_time, hours, minutes, seconds);
+    }
+    else if (minutes)
+    {
+        Log("%.2f seconds elapsed [%um %us]\n", elapsed_time, minutes, seconds);
+    }
+    else
+    {
+        Log("%.2f seconds elapsed\n", elapsed_time);
+    }
+}
+
+// SILENCER -->
+void ConColor(const short c_text_color, const short c_background_color) {
+	if(!g_noConColors) {
+		SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), (16 * c_background_color) + c_text_color);
+	}
+}
+// <-- SILENCER

+ 104 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/log.h

@@ -0,0 +1,104 @@
+#ifndef LOG_H__
+#define LOG_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#include "mathtypes.h"
+#include "messages.h"
+
+typedef enum
+{
+    DEVELOPER_LEVEL_ALWAYS,
+    DEVELOPER_LEVEL_ERROR,
+    DEVELOPER_LEVEL_WARNING,
+    DEVELOPER_LEVEL_MESSAGE,
+    DEVELOPER_LEVEL_FLUFF,
+    DEVELOPER_LEVEL_SPAM,
+    DEVELOPER_LEVEL_MEGASPAM
+}
+developer_level_t;
+
+//
+// log.c globals
+//
+
+extern char*    g_Program;
+extern char     g_Mapname[_MAX_PATH];
+
+#define DEFAULT_DEVELOPER   DEVELOPER_LEVEL_ALWAYS
+#define DEFAULT_VERBOSE     false
+#define DEFAULT_LOG         true
+
+extern developer_level_t g_developer;
+extern bool          g_verbose;
+extern bool          g_log;
+extern unsigned long g_clientid;                           // Client id of this program
+extern unsigned long g_nextclientid;                       // Client id of next client to spawn from this server
+
+//
+// log.c Functions
+//
+
+extern void     ResetTmpFiles();
+extern void     ResetLog();
+extern void     ResetErrorLog();
+extern void     CheckForErrorLog();
+
+extern void CDECL OpenLog(int clientid);
+extern void CDECL CloseLog();
+extern void     WriteLog(const char* const message);
+
+extern void     CheckFatal();
+
+extern void CDECL Developer(developer_level_t level, const char* const message, ...);
+
+#ifdef _DEBUG
+#define IfDebug(x) (x)
+#else
+#define IfDebug(x)
+#endif
+
+extern void CDECL Verbose(const char* const message, ...);
+extern void CDECL Log(const char* const message, ...);
+extern void CDECL Error(const char* const error, ...);
+extern void CDECL Fatal(assume_msgs msgid, const char* const error, ...);
+extern void CDECL Warning(const char* const warning, ...);
+
+extern void CDECL PrintOnce(const char* const message, ...);
+
+extern void     LogStart(const int argc, char** argv);
+extern void     LogEnd();
+extern void     Banner();
+
+extern void     LogTimeElapsed(float elapsed_time);
+
+// SILENCER -->
+// Note: When compile tools are run through a batch-file, some colors will
+// be different from Windows defaults; since you'd usually only run through
+// a batch file, these colors shall be used here:
+#define CONCOLOR_BGDEF_BLACK    0x0
+#define CONCOLOR_DBLUE          0x1
+#define CONCOLOR_DGREEN         0x2
+#define CONCOLOR_BLUEGREEN      0x3
+#define CONCOLOR_DRED           0x4
+#define CONCOLOR_DMAGENTA       0x5
+#define CONCOLOR_DYELLOW        0x6
+#define CONCOLOR_LGREY          0x7
+#define CONCOLOR_LGREEN         0x8
+#define CONCOLOR_BLUE           0x9
+#define CONCOLOR_GREEN          0xA
+#define CONCOLOR_CYAN           0xB
+#define CONCOLOR_RED            0xC
+#define CONCOLOR_MAGENTA        0xD
+#define CONCOLOR_YELLOW         0xE
+#define CONCOLOR_TXTDEF_WHITE   0xF
+extern bool g_noConColors; // Windows' console text coloring
+extern void ConColor(const short c_text_color, const short c_background_color);
+// <-- SILENCER
+
+// Should be in hlassert.h, but well so what
+extern void     hlassume(bool exp, assume_msgs msgid);
+
+#endif // Should be in hlassert.h, but well so what LOG_H__

+ 9 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/mathlib.cpp

@@ -0,0 +1,9 @@
+#include "cmdlib.h"
+#include "messages.h"
+#include "log.h"
+#include "hlassert.h"
+#include "mathtypes.h"
+#include "mathlib.h"
+#include "win32fix.h"
+
+const vec3_t    vec3_origin = { 0, 0, 0 };

+ 278 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/mathlib.h

@@ -0,0 +1,278 @@
+//amckern - 64bit - double to vec_t
+#pragma warning(disable:4244)
+
+#ifndef MATHLIB_H__
+#define MATHLIB_H__
+#include "cmdlib.h" //--vluzacn
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#ifdef STDC_HEADERS
+#include <math.h>
+#include <float.h>
+#endif
+
+#include <algorithm>
+
+#if !defined(max) 
+#define max(a,b)            (((a) > (b)) ? (a) : (b))
+#endif
+
+#if !defined(min)
+#define min(a,b)            (((a) < (b)) ? (a) : (b))
+#endif
+
+#define	Q_PI	3.14159265358979323846
+
+extern const vec3_t vec3_origin;
+
+//SILENCER
+
+//0.00001
+#define NORMAL_EPSILON   0.00001
+
+//0.01
+#define ON_EPSILON       0.01
+
+//0.001
+#define EQUAL_EPSILON    0.001
+
+
+//
+// Vector Math
+//
+
+
+#define DotProduct(x,y) ( (x)[0] * (y)[0] + (x)[1] * (y)[1]  +  (x)[2] * (y)[2])
+#define CrossProduct(a, b, dest) \
+{ \
+    (dest)[0] = (a)[1] * (b)[2] - (a)[2] * (b)[1]; \
+    (dest)[1] = (a)[2] * (b)[0] - (a)[0] * (b)[2]; \
+    (dest)[2] = (a)[0] * (b)[1] - (a)[1] * (b)[0]; \
+}
+
+#define VectorMidpoint(a,b,c)    { (c)[0]=((a)[0]+(b)[0])/2; (c)[1]=((a)[1]+(b)[1])/2; (c)[2]=((a)[2]+(b)[2])/2; }
+
+#define VectorFill(a,b)          { (a)[0]=(b); (a)[1]=(b); (a)[2]=(b);}
+#define VectorAvg(a)             ( ( (a)[0] + (a)[1] + (a)[2] ) / 3 )
+
+#define VectorSubtract(a,b,c)    { (c)[0]=(a)[0]-(b)[0]; (c)[1]=(a)[1]-(b)[1]; (c)[2]=(a)[2]-(b)[2]; }
+#define VectorAdd(a,b,c)         { (c)[0]=(a)[0]+(b)[0]; (c)[1]=(a)[1]+(b)[1]; (c)[2]=(a)[2]+(b)[2]; }
+#define VectorMultiply(a,b,c)    { (c)[0]=(a)[0]*(b)[0]; (c)[1]=(a)[1]*(b)[1]; (c)[2]=(a)[2]*(b)[2]; }
+#define VectorDivide(a,b,c)      { (c)[0]=(a)[0]/(b)[0]; (c)[1]=(a)[1]/(b)[1]; (c)[2]=(a)[2]/(b)[2]; }
+
+#define VectorSubtractVec(a,b,c) { (c)[0]=(a)[0]-(b); (c)[1]=(a)[1]-(b); (c)[2]=(a)[2]-(b); }
+#define VectorAddVec(a,b,c)      { (c)[0]=(a)[0]+(b); (c)[1]=(a)[1]+(b); (c)[2]=(a)[2]+(b); }
+#define VecSubtractVector(a,b,c) { (c)[0]=(a)-(b)[0]; (c)[1]=(a)-(b)[1]; (c)[2]=(a)-(b)[2]; }
+#define VecAddVector(a,b,c)      { (c)[0]=(a)+(b)[0]; (c)[1]=(a)[(b)[1]; (c)[2]=(a)+(b)[2]; }
+
+#define VectorMultiplyVec(a,b,c) { (c)[0]=(a)[0]*(b);(c)[1]=(a)[1]*(b);(c)[2]=(a)[2]*(b); }
+#define VectorDivideVec(a,b,c)   { (c)[0]=(a)[0]/(b);(c)[1]=(a)[1]/(b);(c)[2]=(a)[2]/(b); }
+
+#define VectorScale(a,b,c)       { (c)[0]=(a)[0]*(b);(c)[1]=(a)[1]*(b);(c)[2]=(a)[2]*(b); }
+
+#define VectorCopy(a,b) { (b)[0]=(a)[0]; (b)[1]=(a)[1]; (b)[2]=(a)[2]; }
+#define VectorClear(a)  { (a)[0] = (a)[1] = (a)[2] = 0.0; }
+
+#define VectorMaximum(a) ( max( (a)[0], max( (a)[1], (a)[2] ) ) )
+#define VectorMinimum(a) ( min( (a)[0], min( (a)[1], (a)[2] ) ) )
+
+#define VectorInverse(a) \
+{ \
+    (a)[0] = -((a)[0]); \
+    (a)[1] = -((a)[1]); \
+    (a)[2] = -((a)[2]); \
+}
+#define VectorRound(a) floor((a) + 0.5)
+#ifdef ZHLT_VectorMA_FIX
+#define VectorMA(a, scale, b, dest) \
+{ \
+    (dest)[0] = (a)[0] + (scale) * (b)[0]; \
+    (dest)[1] = (a)[1] + (scale) * (b)[1]; \
+    (dest)[2] = (a)[2] + (scale) * (b)[2]; \
+}
+#else
+#define VectorMA(a, scale, b, dest) \
+{ \
+    (dest)[0] = (a)[0] + scale * (b)[0]; \
+    (dest)[1] = (a)[1] + scale * (b)[1]; \
+    (dest)[2] = (a)[2] + scale * (b)[2]; \
+}
+#endif
+#define VectorLength(a)  sqrt((double) ((double)((a)[0] * (a)[0]) + (double)( (a)[1] * (a)[1]) + (double)( (a)[2] * (a)[2])) )
+#define VectorCompareMinimum(a,b,c) { (c)[0] = min((a)[0], (b)[0]); (c)[1] = min((a)[1], (b)[1]); (c)[2] = min((a)[2], (b)[2]); }
+#define VectorCompareMaximum(a,b,c) { (c)[0] = max((a)[0], (b)[0]); (c)[1] = max((a)[1], (b)[1]); (c)[2] = max((a)[2], (b)[2]); }
+
+inline vec_t   VectorNormalize(vec3_t v)
+{
+    double          length;
+
+    length = DotProduct(v, v);
+    length = sqrt(length);
+    if (length < NORMAL_EPSILON)
+    {
+        VectorClear(v);
+        return 0.0;
+    }
+
+    v[0] /= length;
+    v[1] /= length;
+    v[2] /= length;
+
+    return length;
+}
+
+inline bool     VectorCompare(const vec3_t v1, const vec3_t v2)
+{
+    int             i;
+
+    for (i = 0; i < 3; i++)
+    {
+        if (fabs(v1[i] - v2[i]) > EQUAL_EPSILON)
+        {
+            return false;
+        }
+    }
+    return true;
+}
+
+
+//
+// Portable bit rotation
+//
+
+
+#ifdef SYSTEM_POSIX
+#undef rotl
+#undef rotr
+
+inline unsigned int rotl(unsigned value, unsigned int amt)
+{
+    unsigned        t1, t2;
+
+    t1 = value >> ((sizeof(unsigned) * CHAR_BIT) - amt);
+
+    t2 = value << amt;
+    return (t1 | t2);
+}
+
+inline unsigned int rotr(unsigned value, unsigned int amt)
+{
+    unsigned        t1, t2;
+
+    t1 = value << ((sizeof(unsigned) * CHAR_BIT) - amt);
+
+    t2 = value >> amt;
+    return (t1 | t2);
+}
+#endif
+
+
+//
+// Misc
+//
+
+
+inline bool    isPointFinite(const vec_t* p)
+{
+    if (finite(p[0]) && finite(p[1]) && finite(p[2]))
+    {
+        return true;
+    }
+    return false;
+}
+
+
+//
+// Planetype Math
+//
+
+
+typedef enum
+{
+    plane_x = 0,
+    plane_y,
+    plane_z,
+    plane_anyx,
+    plane_anyy,
+    plane_anyz
+}
+planetypes;
+
+#define last_axial plane_z
+
+#ifdef ZHLT_PLANETYPE_FIX
+inline planetypes PlaneTypeForNormal(vec3_t normal)
+{
+    vec_t           ax, ay, az;
+
+    ax = fabs(normal[0]);
+    ay = fabs(normal[1]);
+    az = fabs(normal[2]);
+    if (ax >= 1.0 - NORMAL_EPSILON && ay <= NORMAL_EPSILON && az <= NORMAL_EPSILON)
+    {
+        return plane_x;
+    }
+
+    if (ay >= 1.0 - NORMAL_EPSILON && az <= NORMAL_EPSILON && ax <= NORMAL_EPSILON)
+    {
+        return plane_y;
+    }
+
+    if (az >= 1.0 - NORMAL_EPSILON && ax <= NORMAL_EPSILON && ay <= NORMAL_EPSILON)
+    {
+        return plane_z;
+    }
+
+    if ((ax >= ay) && (ax >= az))
+    {
+        return plane_anyx;
+    }
+    if ((ay >= ax) && (ay >= az))
+    {
+        return plane_anyy;
+    }
+    return plane_anyz;
+}
+#else
+inline planetypes PlaneTypeForNormal(vec3_t normal)
+{
+    vec_t           ax, ay, az;
+
+    ax = fabs(normal[0]);
+    if (ax == 1.0)
+    {
+        return plane_x;
+    }
+
+    ay = fabs(normal[1]);
+    if (ay == 1.0)
+    {
+        return plane_y;
+    }
+
+    az = fabs(normal[2]);
+    if (az == 1.0)
+    {
+        return plane_z;
+    }
+
+    if ((ax > ay) && (ax > az))
+    {
+        return plane_anyx;
+    }
+    if ((ay > ax) && (ay > az))
+    {
+        return plane_anyy;
+    }
+    return plane_anyz;
+}
+#endif
+
+#endif //MATHLIB_H__

+ 17 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/mathtypes.h

@@ -0,0 +1,17 @@
+#ifndef MATHTYPES_H__
+#define MATHTYPES_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+typedef unsigned char byte;
+
+#ifdef DOUBLEVEC_T
+typedef double vec_t;
+#else
+typedef float vec_t;
+#endif
+typedef vec_t   vec3_t[3];                                 // x,y,z
+
+#endif //MATHTYPES_H__

+ 109 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/messages.cpp

@@ -0,0 +1,109 @@
+#include "messages.h"
+
+// AJM: because these are repeated, they use up redundant memory. 
+//  consequently ive made them into const strings which each occurance can point to.
+
+// Common descriptions
+const char* const internallimit = "The compiler tool hit an internal limit.";
+const char* const internalerror = "The compiler tool had an internal error.";
+const char* const maperror      = "The map has a problem which must be fixed.";
+
+// Common explanations
+#define contact contactmerl //"contact [email protected] immidiately"
+const char* const selfexplanitory = "self explanitory";
+const char* const reference       = "Check the files http://www.zhlt.info/common-mapping-problems.html\n           and http://www.slackiller.com/tommy14/errors.htm for a detailed\n           explanation of this problem.";
+const char* const simplify        = "The map is too complex for the game engine/compile tools to handle.  Simplify";
+const char* const contactmerl     = "contact [email protected] concerning this issue.";
+
+static const MessageTable_t assumes[assume_last] = {
+    {"invalid assume message", "This message should never be printed.", contact},
+
+    // generic
+    {"Memory allocation failure", "The program failed to allocate a block of memory.",
+     "Likely causes are (in order of likeliness) : the partition holding the swapfile is full; swapfile size is smaller than required; memory fragmentation; heap corruption"},
+    {"NULL Pointer", internalerror, contact},
+    {"Bad Thread Workcount", internalerror, contact},
+
+    // qcsg
+    {"Missing '[' in texturedef (U)", maperror, reference},
+    {"plane with no normal", maperror, reference},
+    {"brush with coplanar faces", maperror, reference},
+    {"brush outside world", maperror, reference},
+    {"mixed face contents", maperror, reference},
+    {"Brush type not allowed in world", maperror, reference},
+    {"Brush type not allowed in entity", maperror, reference},
+    {"No visible brushes", "All brushes are CLIP or ORIGIN (at least one must be normal/visible)", selfexplanitory},
+    {"Entity with ONLY an ORIGIN brush", "All entities need at least one visible brush to function properly.  CLIP, HINT, ORIGIN, do not count as visible brushes.", selfexplanitory},
+    {"Could not find WAD file", "The compile tools could not locate a wad file that the map was referencing.", "Make sure the wads listed in the level editor actually all exist."},
+    {"Exceeded MAX_TRIANGLES", internallimit, contact},
+    {"Exceeded MAX_SWITCHED_LIGHTS", "The maximum number of switchable light entities has been reached", selfexplanitory},
+    {"Exceeded MAX_TEXFILES", internallimit, contact},
+
+    // qbsp
+    {"LEAK in the map", maperror, reference},
+    {"Exceeded MAX_LEAF_FACES", "This error is almost always caused by an invalid brush, by having huge rooms, or scaling a texture down to extremely small values (between -1 and 1)",
+     "Find the invalid brush.  Any imported prefabs, carved brushes, or vertex manipulated brushes should be suspect"},
+    {"Exceeded MAX_WEDGES", internallimit, contact},
+    {"Exceeded MAX_WVERTS", internallimit, contact},
+    {"Exceeded MAX_SUPERFACEEDGES", internallimit, contact},
+    {"Empty Solid Entity", "A solid entity in the map (func_wall for example) has no brushes.",  "If using Worldcraft, do a check for problems and fix any occurences of 'Empty solid'"},
+
+    // vis
+    {"Leaf portal saw into leaf", maperror, reference},
+    {"Exceeded MAX_PORTALS_ON_LEAF", maperror, reference},
+    {"Invalid client/server state", internalerror, contact},
+
+    // qrad
+    {"Exceeded MAX_TEXLIGHTS", "The maximum number of texture lights in use by a single map has been reached",
+     "Use fewer texture lights."},
+    {"Exceeded MAX_PATCHES", maperror, reference},
+    {"Transfer < 0", internalerror, contact},
+    {"Bad Surface Extents", maperror, reference},
+    {"Malformed face normal", "The texture alignment of a visible face is unusable", "If using Worldcraft, do a check for problems and fix any occurences of 'Texture axis perpindicular to face'"},
+    {"No Lights!", "lighting of map halted (I assume you do not want a pitch black map!)", "Put some lights in the map."},
+    {"Bad Light Type", internalerror, contact},
+    {"Exceeded MAX_SINGLEMAP", internallimit, contact},
+
+    // common
+    {"Unable to create thread", internalerror, contact},
+    {"Exceeded MAX_MAP_PLANES", "The maximum number of plane definitions has been reached",
+     "The map has grown too complex"},
+    {"Exceeded MAX_MAP_TEXTURES", "The maximum number of textures for a map has been reached", selfexplanitory},
+
+    {"Exceeded MAX_MAP_MIPTEX", "Texture memory usage on the map has exceeded the limit",
+     "Merge similar textures, remove unused textures from the map"},
+    {"Exceeded MAX_MAP_TEXINFO", internallimit, contact},
+    {"Exceeded MAX_MAP_SIDES", internallimit, contact},
+    {"Exceeded MAX_MAP_BRUSHES", "The maximum number of brushes for a map has been reached", selfexplanitory},
+    {"Exceeded MAX_MAP_ENTITIES", "The maximum number of entities for the compile tools has been reached", selfexplanitory},
+    {"Exceeded MAX_ENGINE_ENTITIES", "The maximum number of entities for the half-life engine has been reached", selfexplanitory},
+
+    {"Exceeded MAX_MAP_MODELS", "The maximum number of brush based entities has been reached",
+     "Remove unnecessary brush entities, consolidate similar entities into a single entity"},
+    {"Exceeded MAX_MAP_VERTS", internallimit, contact},
+    {"Exceeded MAX_MAP_EDGES", internallimit, contact},
+
+    {"Exceeded MAX_MAP_CLIPNODES", maperror, reference},
+    {"Exceeded MAX_MAP_MARKSURFACES", internallimit, contact},
+    {"Exceeded MAX_MAP_FACES", "The maximum number of faces for a map has been reached", "This error is typically caused by having a large face with a small texture scale on it, or overly complex maps."},
+    {"Exceeded MAX_MAP_SURFEDGES", internallimit, contact},
+    {"Exceeded MAX_MAP_NODES", "The maximum number of nodes for a map has been reached", simplify},
+    {"CompressVis Overflow", internalerror, contact},
+    {"DecompressVis Overflow", internalerror, contact},
+    {"Execution Cancelled", "Tool execution was cancelled either by the user or due to a fatal compile setting", selfexplanitory},
+    {"Internal Error", internalerror, contact},
+	//KGP added
+	{"Exceeded MAX_MAP_LIGHTING","You have run out of light data memory" ,"Use the -lightdata <#> command line option to increase your maximum light memory.  The default is 16384 (KB)."},
+    {"Exceeded MAX_INTERNAL_MAP_PLANES", "The maximum number of plane definitions has been reached", "The map has grown too complex"}
+}; 
+
+const MessageTable_t* GetAssume(assume_msgs id)
+{
+    if (!(id > assume_first) && (id < assume_last))
+    {
+        id = assume_first;
+    }
+    return &assumes[id];
+}
+
+

+ 96 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/messages.h

@@ -0,0 +1,96 @@
+#ifndef MESSAGES_H__
+#define MESSAGES_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+typedef struct
+{
+    const char*     title;
+    const char*     text;
+    const char*     howto;
+}
+MessageTable_t;
+
+typedef enum
+{
+    assume_first = 0,
+
+    // generic
+    assume_NoMemory,
+    assume_ValidPointer,
+    assume_BadWorkcount,
+
+    // qcsg
+    assume_MISSING_BRACKET_IN_TEXTUREDEF,
+    assume_PLANE_WITH_NO_NORMAL,
+    assume_BRUSH_WITH_COPLANAR_FACES,
+    assume_BRUSH_OUTSIDE_WORLD,
+    assume_MIXED_FACE_CONTENTS,
+    assume_BRUSH_NOT_ALLOWED_IN_WORLD,
+    assume_BRUSH_NOT_ALLOWED_IN_ENTITY,
+    assume_NO_VISIBILE_BRUSHES,
+    assume_ONLY_ORIGIN,
+    assume_COULD_NOT_FIND_WAD,
+    assume_MAX_TRIANGLES,
+    assume_MAX_SWITCHED_LIGHTS,
+    assume_MAX_TEXFILES,
+
+    // qbsp
+    assume_LEAK,
+    assume_MAX_LEAF_FACES,
+    assume_MAX_WEDGES,
+    assume_MAX_WVERTS,
+    assume_MAX_SUPERFACEEDGES,
+    assume_EmptySolid,
+
+    // vis
+    assume_LEAF_PORTAL_SAW_INTO_LEAF,
+    assume_MAX_PORTALS_ON_LEAF,
+    assume_VALID_NETVIS_STATE,
+
+    // qrad
+    assume_MAX_TEXLIGHTS,
+    assume_MAX_PATCHES,
+    assume_TransferError,
+    assume_BadSurfaceExtents,
+    assume_MalformedTextureFace,
+    assume_NoLights,
+    assume_BadLightType,
+    assume_MAX_SINGLEMAP,
+
+    // common
+    assume_THREAD_ERROR,
+    assume_MAX_MAP_PLANES,
+    assume_MAX_MAP_TEXTURES,
+    assume_MAX_MAP_MIPTEX,
+    assume_MAX_MAP_TEXINFO,
+    assume_MAX_MAP_SIDES,
+    assume_MAX_MAP_BRUSHES,
+    assume_MAX_MAP_ENTITIES,
+    assume_MAX_ENGINE_ENTITIES,
+    assume_MAX_MAP_MODELS,
+    assume_MAX_MAP_VERTS,
+    assume_MAX_MAP_EDGES,
+    assume_MAX_MAP_CLIPNODES,
+    assume_MAX_MAP_MARKSURFACES,
+    assume_MAX_MAP_FACES,
+    assume_MAX_MAP_SURFEDGES,
+    assume_MAX_MAP_NODES,
+    assume_COMPRESSVIS_OVERFLOW,
+    assume_DECOMPRESSVIS_OVERFLOW,
+    // AJM: added in
+    assume_TOOL_CANCEL,
+    assume_GENERIC,
+	// KGP: added
+	assume_MAX_MAP_LIGHTING,
+	assume_MAX_INTERNAL_MAP_PLANES,
+
+    assume_last
+}
+assume_msgs;
+
+extern const MessageTable_t* GetAssume(assume_msgs id);
+
+#endif // commonc MESSAGES_H__

+ 61 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/resourcelock.cpp

@@ -0,0 +1,61 @@
+#ifdef SYSTEM_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#endif
+
+#include "cmdlib.h"
+#include "messages.h"
+#include "log.h"
+#include "blockmem.h"
+
+#include "resourcelock.h"
+
+#ifdef SYSTEM_WIN32
+
+typedef struct
+{
+    HANDLE          Mutex;
+}
+ResourceLock_t;
+
+void*           CreateResourceLock(int LockNumber)
+{
+    char            lockname[_MAX_PATH];
+    char            mapname[_MAX_PATH];
+    ResourceLock_t* lock = (ResourceLock_t*)Alloc(sizeof(ResourceLock_t));
+
+    ExtractFile(g_Mapname, mapname);
+    safe_snprintf(lockname, _MAX_PATH, "%d%s", LockNumber, mapname);
+
+    lock->Mutex = CreateMutex(NULL, FALSE, lockname);
+
+    if (lock->Mutex == NULL)
+    {
+        LPVOID          lpMsgBuf;
+
+        Log("lock->Mutex is NULL! [%s]", lockname);
+        FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                      FORMAT_MESSAGE_FROM_SYSTEM |
+                      FORMAT_MESSAGE_IGNORE_INSERTS,
+                      NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) & lpMsgBuf, 0, NULL);
+        Error((LPCTSTR)lpMsgBuf);
+    }
+
+    WaitForSingleObject(lock->Mutex, INFINITE);
+
+    return lock;
+}
+
+void            ReleaseResourceLock(void** lock)
+{
+    ResourceLock_t* lockTmp = (ResourceLock_t*)*lock;
+
+    if (!ReleaseMutex(lockTmp->Mutex))
+    {
+        Error("Failed to release mutex");
+    }
+    Free(lockTmp);
+    *lock = NULL;
+}
+
+#endif

+ 11 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/resourcelock.h

@@ -0,0 +1,11 @@
+#ifndef RESOURCELOCK_H__
+#define RESOURCELOCK_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+extern void*    CreateResourceLock(int LockNumber);
+extern void     ReleaseResourceLock(void** lock);
+
+#endif // RESOURCE_LOCK_H__

+ 362 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/scriplib.cpp

@@ -0,0 +1,362 @@
+#include "cmdlib.h"
+#include "filelib.h"
+#include "messages.h"
+#include "log.h"
+#include "scriplib.h"
+
+char            g_token[MAXTOKEN];
+char            g_TXcommand;
+
+typedef struct
+{
+    char            filename[_MAX_PATH];
+    char*           buffer;
+    char*           script_p;
+    char*           end_p;
+    int             line;
+}
+script_t;
+
+
+#define	MAX_INCLUDES	8
+
+
+static script_t s_scriptstack[MAX_INCLUDES];
+script_t*       s_script;
+int             s_scriptline;
+bool            s_endofscript;
+bool            s_tokenready;                                // only true if UnGetToken was just called
+
+
+//  AddScriptToStack
+//  LoadScriptFile
+//  ParseFromMemory
+//  UnGetToken
+//  EndOfScript
+//  GetToken
+//  TokenAvailable
+
+// =====================================================================================
+//  AddScriptToStack
+// =====================================================================================
+static void     AddScriptToStack(const char* const filename)
+{
+    int             size;
+
+    s_script++;
+
+    if (s_script == &s_scriptstack[MAX_INCLUDES])
+        Error("s_script file exceeded MAX_INCLUDES");
+
+    strcpy_s(s_script->filename, filename);
+
+    size = LoadFile(s_script->filename, (char**)&s_script->buffer);
+
+    Log("Entering %s\n", s_script->filename);
+
+    s_script->line = 1;
+    s_script->script_p = s_script->buffer;
+    s_script->end_p = s_script->buffer + size;
+}
+
+// =====================================================================================
+//  LoadScriptFile
+// =====================================================================================
+void            LoadScriptFile(const char* const filename)
+{
+    s_script = s_scriptstack;
+    AddScriptToStack(filename);
+
+    s_endofscript = false;
+    s_tokenready = false;
+}
+
+// =====================================================================================
+//  ParseFromMemory
+// =====================================================================================
+void            ParseFromMemory(char* buffer, const int size)
+{
+    s_script = s_scriptstack;
+    s_script++;
+
+    if (s_script == &s_scriptstack[MAX_INCLUDES])
+        Error("s_script file exceeded MAX_INCLUDES");
+
+    strcpy_s(s_script->filename, "memory buffer");
+
+    s_script->buffer = buffer;
+    s_script->line = 1;
+    s_script->script_p = s_script->buffer;
+    s_script->end_p = s_script->buffer + size;
+
+    s_endofscript = false;
+    s_tokenready = false;
+}
+
+// =====================================================================================
+//  UnGetToken
+/*
+ * Signals that the current g_token was not used, and should be reported
+ * for the next GetToken.  Note that
+ * 
+ * GetToken (true);
+ * UnGetToken ();
+ * GetToken (false);
+ * 
+ * could cross a line boundary.
+ */
+// =====================================================================================
+void            UnGetToken()
+{
+    s_tokenready = true;
+}
+
+// =====================================================================================
+//  EndOfScript
+// =====================================================================================
+bool            EndOfScript(const bool crossline)
+{
+    if (!crossline)
+        Error("Line %i is incomplete (did you place a \" inside an entity string?) \n", s_scriptline);
+
+    if (!strcmp(s_script->filename, "memory buffer"))
+    {
+        s_endofscript = true;
+        return false;
+    }
+
+    free(s_script->buffer);
+
+    if (s_script == s_scriptstack + 1)
+    {
+        s_endofscript = true;
+        return false;
+    }
+
+    s_script--;
+    s_scriptline = s_script->line;
+
+    Log("returning to %s\n", s_script->filename);
+
+    return GetToken(crossline);
+}
+
+// =====================================================================================
+//  GetToken
+// =====================================================================================
+bool            GetToken(const bool crossline)
+{
+    char           *token_p;
+
+    if (s_tokenready)                                        // is a g_token allready waiting?
+    {
+        s_tokenready = false;
+        return true;
+    }
+
+    if (s_script->script_p >= s_script->end_p)
+        return EndOfScript(crossline);
+
+    // skip space
+skipspace:
+    while (*s_script->script_p <= 32)
+    {
+        if (s_script->script_p >= s_script->end_p)
+            return EndOfScript(crossline);
+
+        if (*s_script->script_p++ == '\n')
+        {
+            if (!crossline)
+                Error("Line %i is incomplete (did you place a \" inside an entity string?) \n", s_scriptline);
+            s_scriptline = s_script->line++;
+        }
+    }
+
+    if (s_script->script_p >= s_script->end_p)
+        return EndOfScript(crossline);
+
+    // comment fields
+    if (*s_script->script_p == ';' || *s_script->script_p == '#' || // semicolon and # is comment field
+        (*s_script->script_p == '/' && *((s_script->script_p) + 1) == '/')) // also make // a comment field
+    {
+        if (!crossline)
+            Error("Line %i is incomplete (did you place a \" inside an entity string?) \n", s_scriptline);
+
+        //ets+++
+        if (*s_script->script_p == '/')
+            s_script->script_p++;
+        if (s_script->script_p[1] == 'T' && s_script->script_p[2] == 'X')
+            g_TXcommand = s_script->script_p[3];             // AR: "//TX#"-style comment
+
+        //ets---
+        while (*s_script->script_p++ != '\n')
+        {
+            if (s_script->script_p >= s_script->end_p)
+                return EndOfScript(crossline);
+        }
+        //ets+++
+        s_scriptline = s_script->line++;                       // AR: this line was missing
+        //ets---
+        goto skipspace;
+    }
+
+    // copy g_token
+    token_p = g_token;
+
+    if (*s_script->script_p == '"')
+    {
+        // quoted token
+        s_script->script_p++;
+        while (*s_script->script_p != '"')
+        {
+            *token_p++ = *s_script->script_p++;
+
+            if (s_script->script_p == s_script->end_p)
+                break;
+
+            if (token_p == &g_token[MAXTOKEN])
+                Error("Token too large on line %i\n", s_scriptline);
+        }
+        s_script->script_p++;
+    }
+    else
+    {
+        // regular token
+        while (*s_script->script_p > 32 && *s_script->script_p != ';')
+        {
+            *token_p++ = *s_script->script_p++;
+
+            if (s_script->script_p == s_script->end_p)
+                break;
+
+            if (token_p == &g_token[MAXTOKEN])
+                Error("Token too large on line %i\n", s_scriptline);
+        }
+    }
+
+    *token_p = 0;
+
+    if (!strcmp(g_token, "$include"))
+    {
+        GetToken(false);
+        AddScriptToStack(g_token);
+        return GetToken(crossline);
+    }
+
+    return true;
+}
+
+#if 0
+// AJM: THIS IS REDUNDANT
+// =====================================================================================
+//  ParseWadToken
+//      basically the same as gettoken, except it isnt limited by MAXTOKEN and is
+//      specificaly designed to parse out the wadpaths from the wad keyvalue and dump
+//      them into the wadpaths list
+//      this was implemented as a hack workaround for Token Too Large errors caused by
+//      having long wadpaths or lots of wads in the map editor.
+extern void        PushWadPath(const char* const path, bool inuse);
+// =====================================================================================
+void            ParseWadToken(const bool crossline)
+{
+    // code somewhat copied from GetToken()
+    int             i, j;
+    char*           token_p;
+    char            temp[_MAX_PATH];
+
+    if (s_script->script_p >= s_script->end_p)
+        return;
+
+    // skip space
+    while (*s_script->script_p <= 32)
+    {
+        if (s_script->script_p >= s_script->end_p)
+            return;
+
+        if (*s_script->script_p++ == '\n')
+        {
+            if (!crossline)
+                Error("Line %i is incomplete (did you place a \" inside an entity string?) \n", s_scriptline);
+            s_scriptline = s_script->line++;
+        }
+    }
+
+    // EXPECT A QUOTE
+    if (*s_script->script_p++ != '"')
+        Error("Line %i: Expected a wadpaths definition, got '%s'\n", s_scriptline, *--s_script->script_p);
+
+    // load wadpaths manually
+    bool    endoftoken = false;
+    for (i = 0; !endoftoken; i++)
+    {
+        // get the path
+        for (j = 0; ; j++)
+        {
+            token_p = ++s_script->script_p;
+            
+            // assert max path length
+            if (j > _MAX_PATH)
+                Error("Line %i: Wadpath definition %i is too long (%s)\n", s_scriptline, temp);
+
+            if (*token_p == '\n')
+                Error("Line %i: Expected a wadpaths definition, got linebreak\n", s_scriptline);
+
+            if (*token_p == '"')            // end of wadpath definition
+            {
+                if (i == 0 && j == 0)       // no wadpaths!
+                {
+                    Warning("No wadpaths specified.\n");
+                    return;
+                }
+
+                endoftoken = true;
+                break;
+            }
+
+            if (*token_p == ';')            // end of this wadpath
+                break;
+
+            temp[j] = *token_p;
+            temp[j + 1] = 0;
+        }
+
+        // push it into the list
+        PushWadPath(temp, true);
+        temp[0] = 0;
+    }
+
+    for (; *s_script->script_p != '\n'; s_script->script_p++)
+    {
+    }
+}
+#endif
+
+// =====================================================================================
+//  TokenAvailable
+//      returns true if there is another token on the line
+// =====================================================================================
+bool            TokenAvailable()
+{
+    char           *search_p;
+
+    search_p = s_script->script_p;
+
+    if (search_p >= s_script->end_p)
+        return false;
+
+    while (*search_p <= 32)
+    {
+        if (*search_p == '\n')
+            return false;
+
+        search_p++;
+
+        if (search_p == s_script->end_p)
+            return false;
+    }
+
+    if (*search_p == ';')
+        return false;
+
+    return true;
+}

+ 26 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/scriplib.h

@@ -0,0 +1,26 @@
+#ifndef SCRIPLIB_H__
+#define SCRIPLIB_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#include "cmdlib.h"
+
+#define	MAXTOKEN 4096
+
+extern char     g_token[MAXTOKEN];
+extern char     g_TXcommand;                               // global for Quark maps texture alignment hack
+
+extern void     LoadScriptFile(const char* const filename);
+extern void     ParseFromMemory(char* buffer, int size);
+
+extern bool     GetToken(bool crossline);
+extern void     UnGetToken();
+extern bool     TokenAvailable();
+
+#define MAX_WAD_PATHS   42
+extern char         g_szWadPaths[MAX_WAD_PATHS][_MAX_PATH];
+extern int          g_iNumWadPaths;
+
+#endif //**/ SCRIPLIB_H__

+ 682 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/threads.cpp

@@ -0,0 +1,682 @@
+#ifdef SYSTEM_WIN32
+#pragma warning(push)
+#pragma warning(disable:4100)                             // unreferenced formal parameter
+#endif
+
+#ifdef SYSTEM_WIN32
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+#include <malloc.h>
+#endif
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "cmdlib.h"
+#include "messages.h"
+#include "log.h"
+#include "threads.h"
+#include "blockmem.h"
+
+#ifdef SYSTEM_POSIX
+#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_RESOURCE_H
+#include <sys/resource.h>
+#include <pthread.h>
+#endif
+#ifdef HAVE_PTHREAD_H
+#include <pthread.h>
+#endif
+#endif
+
+#include "hlassert.h"
+
+q_threadpriority g_threadpriority = DEFAULT_THREAD_PRIORITY;
+
+#define THREADTIMES_SIZE 100
+#define THREADTIMES_SIZEf (float)(THREADTIMES_SIZE)
+
+static int      dispatch = 0;
+static int      workcount = 0;
+static int      oldf = 0;
+static bool     pacifier = false;
+static bool     threaded = false;
+static double   threadstart = 0;
+static double   threadtimes[THREADTIMES_SIZE];
+
+int             GetThreadWork()
+{
+    int             r, f, i;
+    double          ct, finish, finish2, finish3;
+
+    ThreadLock();
+
+    if (dispatch == 0)
+    {
+        oldf = 0;
+    }
+
+    if (dispatch > workcount)
+    {
+        Developer(DEVELOPER_LEVEL_ERROR, "dispatch > workcount!!!\n");
+        ThreadUnlock();
+        return -1;
+    }
+    if (dispatch == workcount)
+    {
+        Developer(DEVELOPER_LEVEL_MESSAGE, "dispatch == workcount, work is complete\n");
+        ThreadUnlock();
+        return -1;
+    }
+    if (dispatch < 0)
+    {
+        Developer(DEVELOPER_LEVEL_ERROR, "negative dispatch!!!\n");
+        ThreadUnlock();
+        return -1;
+    }
+
+    f = THREADTIMES_SIZE * dispatch / workcount;
+    if (pacifier)
+    {
+        printf("\r%6d /%6d", dispatch, workcount);
+#ifdef ZHLT_PROGRESSFILE // AJM
+        if (g_progressfile)
+        {
+            
+
+        }
+#endif
+
+        if (f != oldf)
+        {
+            ct = I_FloatTime();
+            /* Fill in current time for threadtimes record */
+            for (i = oldf; i <= f; i++)
+            {
+                if (threadtimes[i] < 1)
+                {
+                    threadtimes[i] = ct;
+                }
+            }
+            oldf = f;
+
+            if (f > 10)
+            {
+                finish = (ct - threadtimes[0]) * (THREADTIMES_SIZEf - f) / f;
+                finish2 = 10.0 * (ct - threadtimes[f - 10]) * (THREADTIMES_SIZEf - f) / THREADTIMES_SIZEf;
+                finish3 = THREADTIMES_SIZEf * (ct - threadtimes[f - 1]) * (THREADTIMES_SIZEf - f) / THREADTIMES_SIZEf;
+
+                if (finish > 1.0)
+                {
+                    printf("  (%d%%: est. time to completion %ld/%ld/%ld secs)   ", f, (long)(finish), (long)(finish2),
+                           (long)(finish3));
+#ifdef ZHLT_PROGRESSFILE // AJM
+                    if (g_progressfile)
+                    {
+
+
+                    }
+#endif
+                }
+                else
+                {
+                    printf("  (%d%%: est. time to completion <1 sec)   ", f);
+
+#ifdef ZHLT_PROGRESSFILE // AJM
+                    if (g_progressfile)
+                    {
+
+
+                    }
+#endif
+                }
+            }
+        }
+    }
+    else
+    {
+        if (f != oldf)
+        {
+            oldf = f;
+            switch (f)
+            {
+            case 10:
+            case 20:
+            case 30:
+            case 40:
+            case 50:
+            case 60:
+            case 70:
+            case 80:
+            case 90:
+            case 100:
+/*
+            case 5:
+            case 15:
+            case 25:
+            case 35:
+            case 45:
+            case 55:
+            case 65:
+            case 75:
+            case 85:
+            case 95:
+*/
+                printf("%d%%...", f);
+            default:
+                break;
+            }
+        }
+    }
+
+    r = dispatch;
+    dispatch++;
+
+    ThreadUnlock();
+    return r;
+}
+
+q_threadfunction workfunction;
+
+static void     ThreadWorkerFunction(int unused)
+{
+    int             work;
+
+    while ((work = GetThreadWork()) != -1)
+    {
+        workfunction(work);
+    }
+}
+
+#ifdef SYSTEM_WIN32
+#pragma warning(pop)
+#endif
+
+void            RunThreadsOnIndividual(int workcnt, bool showpacifier, q_threadfunction func)
+{
+    workfunction = func;
+    RunThreadsOn(workcnt, showpacifier, ThreadWorkerFunction);
+}
+
+#ifndef SINGLE_THREADED
+
+/*====================
+| Begin SYSTEM_WIN32
+=*/
+#ifdef SYSTEM_WIN32
+
+#define	USED
+#include <windows.h>
+
+int             g_numthreads = DEFAULT_NUMTHREADS;
+static CRITICAL_SECTION crit;
+static int      enter;
+
+void            ThreadSetPriority(q_threadpriority type)
+{
+    int             val;
+
+    g_threadpriority = type;
+
+    switch (g_threadpriority)
+    {
+    case eThreadPriorityLow:
+        val = IDLE_PRIORITY_CLASS;
+        break;
+
+    case eThreadPriorityHigh:
+        val = HIGH_PRIORITY_CLASS;
+        break;
+
+    case eThreadPriorityNormal:
+    default:
+        val = NORMAL_PRIORITY_CLASS;
+        break;
+    }
+
+    SetPriorityClass(GetCurrentProcess(), val);
+}
+
+#if 0
+static void     AdjustPriority(HANDLE hThread)
+{
+    int             val;
+
+    switch (g_threadpriority)
+    {
+    case eThreadPriorityLow:
+        val = THREAD_PRIORITY_HIGHEST;
+        break;
+
+    case eThreadPriorityHigh:
+        val = THREAD_PRIORITY_LOWEST;
+        break;
+
+    case eThreadPriorityNormal:
+    default:
+        val = THREAD_PRIORITY_NORMAL;
+        break;
+    }
+    SetThreadPriority(hThread, val);
+}
+#endif
+
+void            ThreadSetDefault()
+{
+    SYSTEM_INFO     info;
+
+    if (g_numthreads == -1)                                // not set manually
+    {
+        GetSystemInfo(&info);
+        g_numthreads = info.dwNumberOfProcessors;
+        if (g_numthreads < 1 || g_numthreads > 32)
+        {
+            g_numthreads = 1;
+        }
+    }
+}
+
+void            ThreadLock()
+{
+    if (!threaded)
+    {
+        return;
+    }
+    EnterCriticalSection(&crit);
+    if (enter)
+    {
+        Warning("Recursive ThreadLock\n");
+    }
+    enter++;
+}
+
+void            ThreadUnlock()
+{
+    if (!threaded)
+    {
+        return;
+    }
+    if (!enter)
+    {
+        Error("ThreadUnlock without lock\n");
+    }
+    enter--;
+    LeaveCriticalSection(&crit);
+}
+
+q_threadfunction q_entry;
+
+static DWORD WINAPI ThreadEntryStub(LPVOID pParam)
+{
+    q_entry((int)pParam);
+    return 0;
+}
+
+void            threads_InitCrit()
+{
+    InitializeCriticalSection(&crit);
+    threaded = true;
+}
+
+void            threads_UninitCrit()
+{
+    DeleteCriticalSection(&crit);
+}
+
+void            RunThreadsOn(int workcnt, bool showpacifier, q_threadfunction func)
+{
+    DWORD           threadid[MAX_THREADS];
+    HANDLE          threadhandle[MAX_THREADS];
+    int             i;
+    double          start, end;
+
+    threadstart = I_FloatTime();
+    start = threadstart;
+    for (i = 0; i < THREADTIMES_SIZE; i++)
+    {
+        threadtimes[i] = 0;
+    }
+    dispatch = 0;
+    workcount = workcnt;
+    oldf = -1;
+    pacifier = showpacifier;
+    threaded = true;
+    q_entry = func;
+
+    if (workcount < dispatch)
+    {
+        Developer(DEVELOPER_LEVEL_ERROR, "RunThreadsOn: Workcount(%i) < dispatch(%i)\n", workcount, dispatch);
+    }
+    hlassume(workcount >= dispatch, assume_BadWorkcount);
+
+    //
+    // Create all the threads (suspended)
+    //
+    threads_InitCrit();
+    for (i = 0; i < g_numthreads; i++)
+    {
+        HANDLE          hThread = CreateThread(NULL,
+                                               0,
+                                               (LPTHREAD_START_ROUTINE) ThreadEntryStub,
+                                               (LPVOID) i,
+                                               CREATE_SUSPENDED,
+                                               &threadid[i]);
+
+        if (hThread != NULL)
+        {
+            threadhandle[i] = hThread;
+        }
+        else
+        {
+            LPVOID          lpMsgBuf;
+
+            FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                          FORMAT_MESSAGE_FROM_SYSTEM |
+                          FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),       // Default language
+                          (LPTSTR) & lpMsgBuf, 0, NULL);
+            // Process any inserts in lpMsgBuf.
+            // ...
+            // Display the string.
+            Developer(DEVELOPER_LEVEL_ERROR, "CreateThread #%d [%08X] failed : %s\n", i, threadhandle[i], lpMsgBuf);
+            Fatal(assume_THREAD_ERROR, "Unable to create thread #%d", i);
+            // Free the buffer.
+            LocalFree(lpMsgBuf);
+        }
+    }
+    CheckFatal();
+
+    // Start all the threads
+    for (i = 0; i < g_numthreads; i++)
+    {
+        if (ResumeThread(threadhandle[i]) == 0xFFFFFFFF)
+        {
+            LPVOID          lpMsgBuf;
+
+            FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+                          FORMAT_MESSAGE_FROM_SYSTEM |
+                          FORMAT_MESSAGE_IGNORE_INSERTS, NULL, GetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),       // Default language
+                          (LPTSTR) & lpMsgBuf, 0, NULL);
+            // Process any inserts in lpMsgBuf.
+            // ...
+            // Display the string.
+            Developer(DEVELOPER_LEVEL_ERROR, "ResumeThread #%d [%08X] failed : %s\n", i, threadhandle[i], lpMsgBuf);
+            Fatal(assume_THREAD_ERROR, "Unable to start thread #%d", i);
+            // Free the buffer.
+            LocalFree(lpMsgBuf);
+        }
+    }
+    CheckFatal();
+
+    // Wait for threads to complete
+    for (i = 0; i < g_numthreads; i++)
+    {
+        Developer(DEVELOPER_LEVEL_MESSAGE, "WaitForSingleObject on thread #%d [%08X]\n", i, threadhandle[i]);
+        WaitForSingleObject(threadhandle[i], INFINITE);
+    }
+    threads_UninitCrit();
+
+    q_entry = NULL;
+    threaded = false;
+    end = I_FloatTime();
+    if (pacifier)
+    {
+        printf("\r%60s\r", "");
+    }
+    Log(" (%.2f seconds)\n", end - start);
+}
+
+#endif
+
+/*=
+| End SYSTEM_WIN32
+=====================*/
+
+/*====================
+| Begin SYSTEM_POSIX
+=*/
+#ifdef SYSTEM_POSIX
+
+#define	USED
+
+int             g_numthreads = DEFAULT_NUMTHREADS;
+
+void            ThreadSetPriority(q_threadpriority type)
+{
+    int             val;
+
+    g_threadpriority = type;
+
+    // Currently in Linux land users are incapable of raising the priority level of their processes
+    // Unless you are root -high is useless . . . 
+    switch (g_threadpriority)
+    {
+    case eThreadPriorityLow:
+        val = PRIO_MAX;
+        break;
+
+    case eThreadPriorityHigh:
+        val = PRIO_MIN;
+        break;
+
+    case eThreadPriorityNormal:
+    default:
+        val = 0;
+        break;
+    }
+    setpriority(PRIO_PROCESS, 0, val);
+}
+
+void            ThreadSetDefault()
+{
+    if (g_numthreads == -1)
+    {
+        g_numthreads = 1;
+    }
+}
+
+typedef void*    pthread_addr_t;
+pthread_mutex_t* my_mutex;
+
+void            ThreadLock()
+{
+    if (my_mutex)
+    {
+        pthread_mutex_lock(my_mutex);
+    }
+}
+
+void            ThreadUnlock()
+{
+    if (my_mutex)
+    {
+        pthread_mutex_unlock(my_mutex);
+    }
+}
+
+q_threadfunction q_entry;
+
+static void*    CDECL ThreadEntryStub(void* pParam)
+{
+    q_entry((int)pParam);
+    return NULL;
+}
+
+void            threads_InitCrit()
+{
+    pthread_mutexattr_t mattrib;
+
+    if (!my_mutex)
+    {
+        my_mutex = (pthread_mutex_t*)Alloc(sizeof(*my_mutex));
+        if (pthread_mutexattr_init(&mattrib) == -1)
+        {
+            Error("pthread_mutex_attr_init failed");
+        }
+        if (pthread_mutex_init(my_mutex, &mattrib) == -1)
+        {
+            Error("pthread_mutex_init failed");
+        }
+    }
+}
+
+void            threads_UninitCrit()
+{
+    Free(my_mutex);
+    my_mutex = NULL;
+}
+
+/*
+ * =============
+ * RunThreadsOn
+ * =============
+ */
+void            RunThreadsOn(int workcnt, bool showpacifier, q_threadfunction func)
+{
+    int             i;
+    pthread_t       work_threads[MAX_THREADS];
+    pthread_addr_t  status;
+    pthread_attr_t  attrib;
+    double          start, end;
+
+    threadstart = I_FloatTime();
+    start = threadstart;
+    for (i = 0; i < THREADTIMES_SIZE; i++)
+    {
+        threadtimes[i] = 0;
+    }
+
+    dispatch = 0;
+    workcount = workcnt;
+    oldf = -1;
+    pacifier = showpacifier;
+    threaded = true;
+    q_entry = func;
+
+    if (pacifier)
+    {
+        setbuf(stdout, NULL);
+    }
+
+    threads_InitCrit();
+
+    if (pthread_attr_init(&attrib) == -1)
+    {
+        Error("pthread_attr_init failed");
+    }
+#ifdef _POSIX_THREAD_ATTR_STACKSIZE
+    if (pthread_attr_setstacksize(&attrib, 0x400000) == -1)
+    {
+        Error("pthread_attr_setstacksize failed");
+    }
+#endif
+
+    for (i = 0; i < g_numthreads; i++)
+    {
+        if (pthread_create(&work_threads[i], &attrib, ThreadEntryStub, (void*)i) == -1)
+        {
+            Error("pthread_create failed");
+        }
+    }
+
+    for (i = 0; i < g_numthreads; i++)
+    {
+        if (pthread_join(work_threads[i], &status) == -1)
+        {
+            Error("pthread_join failed");
+        }
+    }
+
+    threads_UninitCrit();
+
+    q_entry = NULL;
+    threaded = false;
+
+    end = I_FloatTime();
+    if (pacifier)
+    {
+        printf("\r%60s\r", "");
+    }
+
+    Log(" (%.2f seconds)\n", end - start);
+}
+
+#endif /*SYSTEM_POSIX */
+
+/*=
+| End SYSTEM_POSIX
+=====================*/
+
+#endif /*SINGLE_THREADED */
+
+/*====================
+| Begin SINGLE_THREADED
+=*/
+#ifdef SINGLE_THREADED
+
+int             g_numthreads = 1;
+
+void            ThreadSetPriority(q_threadpriority type)
+{
+}
+
+void            threads_InitCrit()
+{
+}
+
+void            threads_UninitCrit()
+{
+}
+
+void            ThreadSetDefault()
+{
+    g_numthreads = 1;
+}
+
+void            ThreadLock()
+{
+}
+
+void            ThreadUnlock()
+{
+}
+
+void            RunThreadsOn(int workcnt, bool showpacifier, q_threadfunction func)
+{
+    int             i;
+    double          start, end;
+
+    dispatch = 0;
+    workcount = workcnt;
+    oldf = -1;
+    pacifier = showpacifier;
+    threadstart = I_FloatTime();
+    start = threadstart;
+    for (i = 0; i < THREADTIMES_SIZE; i++)
+    {
+        threadtimes[i] = 0.0;
+    }
+
+    if (pacifier)
+    {
+        setbuf(stdout, NULL);
+    }
+    func(0);
+
+    end = I_FloatTime();
+
+    if (pacifier)
+    {
+        printf("\r%60s\r", "");
+    }
+
+    Log(" (%.2f seconds)\n", end - start);
+}
+
+#endif
+
+/*=
+| End SINGLE_THREADED
+=====================*/

+ 49 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/threads.h

@@ -0,0 +1,49 @@
+#ifndef THREADS_H__
+#define THREADS_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#define	MAX_THREADS	64
+
+typedef enum
+{
+    eThreadPriorityLow = -1,
+    eThreadPriorityNormal,
+    eThreadPriorityHigh
+}
+q_threadpriority;
+
+typedef void    (*q_threadfunction) (int);
+
+#ifdef SYSTEM_WIN32
+#define DEFAULT_NUMTHREADS -1
+#endif
+#ifdef SYSTEM_POSIX
+#define DEFAULT_NUMTHREADS 1
+#endif
+
+#define DEFAULT_THREAD_PRIORITY eThreadPriorityNormal
+
+extern int      g_numthreads;
+extern q_threadpriority g_threadpriority;
+
+extern void     ThreadSetPriority(q_threadpriority type);
+extern void     ThreadSetDefault();
+extern int      GetThreadWork();
+extern void     ThreadLock();
+extern void     ThreadUnlock();
+
+extern void     RunThreadsOnIndividual(int workcnt, bool showpacifier, q_threadfunction);
+extern void     RunThreadsOn(int workcnt, bool showpacifier, q_threadfunction);
+
+#ifdef ZHLT_NETVIS
+extern void     threads_InitCrit();
+extern void     threads_UninitCrit();
+#endif
+
+#define NamedRunThreadsOn(n,p,f) { Log("%s\n", #f ":"); RunThreadsOn(n,p,f); }
+#define NamedRunThreadsOnIndividual(n,p,f) { Log("%s\n", #f ":"); RunThreadsOnIndividual(n,p,f); }
+
+#endif //**/ THREADS_H__

+ 58 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/win32fix.h

@@ -0,0 +1,58 @@
+#ifndef WIN32FIX_H__
+#define WIN32FIX_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#include <malloc.h>
+
+/////////////////////////////
+#ifdef SYSTEM_WIN32
+
+#define alloca      _alloca
+
+#define strncasecmp _strnicmp
+#define strcasecmp  _stricmp
+
+#if !defined(_MSC_VER) || defined(__MINGW32__)
+#define snprintf _snprintf
+#define vsnprintf _vsnprintf
+#endif
+
+#define finite    _finite
+
+#define rotl      _rotl
+#define rotr      _rotr
+
+#undef STDCALL
+#undef FASTCALL
+#undef CDECL
+
+#define STDCALL     __stdcall
+#define FASTCALL    __fastcall
+#define CDECL       __cdecl
+
+#define INLINE      __inline
+
+#endif
+/////////////////////////////
+
+/////////////////////////////
+#ifdef SYSTEM_POSIX
+#define _MAX_PATH  4096
+#define _MAX_DRIVE 4096
+#define _MAX_DIR   4096
+#define _MAX_FNAME 4096
+#define _MAX_EXT   4096
+
+#define STDCALL
+#define FASTCALL
+#define CDECL
+
+#define INLINE inline
+
+#endif
+/////////////////////////////
+
+#endif ///////////////////////////// WIN32FIX_H__

File diff suppressed because it is too large
+ 1103 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/winding.cpp


+ 82 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/common/winding.h

@@ -0,0 +1,82 @@
+#ifndef WINDING_H__
+#define WINDING_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#include "basictypes.h"
+#include "mathtypes.h"
+#include "win32fix.h"
+#include "mathlib.h"
+#include "bspfile.h"
+#include "boundingbox.h"
+
+#define MAX_POINTS_ON_WINDING 128
+// TODO: FIX THIS STUPID SHIT (MAX_POINTS_ON_WINDING)
+
+#define BASE_WINDING_DISTANCE 9000
+
+#define	SIDE_FRONT		0
+#define	SIDE_ON			2
+#define	SIDE_BACK		1
+#define	SIDE_CROSS		-2
+
+class Winding
+{
+public:
+    // General Functions
+    void            Print() const;
+    void            getPlane(dplane_t& plane) const;
+    void            getPlane(vec3_t& normal, vec_t& dist) const;
+    vec_t           getArea() const;
+    void            getBounds(BoundingBox& bounds) const;
+    void            getBounds(vec3_t& mins, vec3_t& maxs) const;
+    void            getCenter(vec3_t& center) const;
+    Winding*        Copy() const;
+    void            Check() const;  // Developer check for validity
+    bool            Valid() const;  // Runtime/user/normal check for validity
+    void            addPoint(const vec3_t newpoint);
+    void            insertPoint(const vec3_t newpoint, const unsigned int offset);
+
+    // Specialized Functions
+    void            RemoveColinearPoints();
+    bool            Clip(const dplane_t& split, bool keepon); // For hlbsp
+    void            Clip(const dplane_t& split, Winding** front, Winding** back);
+    void            Clip(const vec3_t normal, const vec_t dist, Winding** front, Winding** back);
+    bool            Chop(const vec3_t normal, const vec_t dist);
+    void            Divide(const dplane_t& split, Winding** front, Winding** back);
+    int             WindingOnPlaneSide(const vec3_t normal, const vec_t dist);
+	void			CopyPoints(vec3_t *points, int &numpoints);
+
+	void			initFromPoints(vec3_t *points, UINT32 numpoints);
+	void			Reset(void);	// Resets the structure
+
+protected:
+    void            resize(UINT32 newsize);
+
+public:
+    // Construction
+	Winding();										// Do nothing :)
+	Winding(vec3_t *points, UINT32 numpoints);		// Create from raw points
+    Winding(const dface_t& face);
+    Winding(const dplane_t& face);
+    Winding(const vec3_t normal, const vec_t dist);
+    Winding(UINT32 points);
+    Winding(const Winding& other);
+    virtual ~Winding();
+    Winding& operator=(const Winding& other);
+
+    // Misc
+private:
+    void initFromPlane(const vec3_t normal, const vec_t dist);
+
+public:
+    // Data
+    UINT32  m_NumPoints;
+    vec3_t* m_Points;
+protected:
+    UINT32  m_MaxPoints;
+};
+
+#endif

+ 5 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/copy_executables_here.bat

@@ -0,0 +1,5 @@
+copy hlbsp\Release\hlbsp.exe hlbsp.exe
+copy hlvis\Release\hlvis.exe hlvis.exe
+copy hlrad\Release\hlrad.exe hlrad.exe
+copy hlcsg\Release\hlcsg.exe hlcsg.exe
+copy ripent\Release\ripent.exe ripent.exe

+ 278 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/bsp5.h

@@ -0,0 +1,278 @@
+#ifndef HLBSP_H__
+#define HLBSP_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#include "cmdlib.h"
+#include "messages.h"
+#include "win32fix.h"
+#include "log.h"
+#include "hlassert.h"
+#include "mathlib.h"
+#include "bspfile.h"
+#include "blockmem.h"
+#include "filelib.h"
+#include "threads.h"
+#include "winding.h"
+
+#define ENTITIES_VOID "entities.void"
+#define ENTITIES_VOID_EXT ".void"
+
+#define	BOGUS_RANGE	18000
+
+// the exact bounding box of the brushes is expanded some for the headnode
+// volume.  is this still needed?
+#define	SIDESPACE	24
+
+//============================================================================
+
+#define MIN_SUBDIVIDE_SIZE      64
+
+#ifdef ZHLT_GENERAL
+#define MAX_SUBDIVIDE_SIZE      512
+#else
+#define MAX_SUBDIVIDE_SIZE      240
+#endif
+
+#define DEFAULT_SUBDIVIDE_SIZE  240
+
+#define MIN_MAXNODE_SIZE        64
+#define MAX_MAXNODE_SIZE        8192
+#define DEFAULT_MAXNODE_SIZE    1024
+
+#define DEFAULT_NOFILL          false
+#define DEFAULT_NOTJUNC         false
+#define DEFAULT_NOCLIP          false
+#define DEFAULT_NOOPT			false
+#define DEFAULT_LEAKONLY        false
+#define DEFAULT_WATERVIS        false
+#define DEFAULT_CHART           false
+#define DEFAULT_INFO            true
+
+#ifdef ZHLT_NULLTEX // AJM
+#define DEFAULT_NULLTEX             true
+#endif
+
+#ifdef ZHLT_PROGRESSFILE // AJM
+#define DEFAULT_PROGRESSFILE NULL // progress file is only used if g_progressfile is non-null
+#endif
+
+#ifdef SYSTEM_WIN32
+#define DEFAULT_ESTIMATE        false
+#endif
+
+#ifdef SYSTEM_POSIX
+#define DEFAULT_ESTIMATE        true
+#endif
+
+#ifdef ZHLT_DETAIL // AJM
+#define DEFAULT_DETAIL      true
+#endif
+
+#define	MAXEDGES			48                 // 32
+#define	MAXPOINTS			28                 // don't let a base face get past this
+                                                                              // because it can be split more later
+#define MAXNODESIZE     1024                               // Valve default is 1024
+
+typedef enum
+{
+    face_normal = 0,
+    face_hint,
+    face_skip,
+#ifdef ZHLT_NULLTEX // AJM
+    face_null,
+#endif
+#ifdef ZHLT_DETAIL // AJM
+    face_detail
+#endif
+	//face_blocklight
+}
+facestyle_e;
+
+typedef struct face_s                                      // This structure is layed out so 'pts' is on a quad-word boundary (and the pointers are as well)
+{
+    struct face_s*  next;
+    int             planenum;
+    int             texturenum;
+    int             contents;                              // contents in front of face
+
+    struct face_s*  original;                              // face on node
+    int             outputnumber;                          // only valid for original faces after write surfaces
+    int             numpoints;
+    facestyle_e     facestyle;
+
+    // vector quad word aligned
+    vec3_t          pts[MAXEDGES];                         // FIXME: change to use winding_t
+
+}
+face_t;
+
+typedef struct surface_s
+{
+    struct surface_s* next;
+    int             planenum;
+    vec3_t          mins, maxs;
+    struct node_s*  onnode;                                // true if surface has already been used
+    // as a splitting node
+    face_t*         faces;                                 // links to all the faces on either side of the surf
+}
+surface_t;
+
+typedef struct
+{
+    vec3_t          mins, maxs;
+    surface_t*      surfaces;
+}
+surfchain_t;
+
+//
+// there is a node_t structure for every node and leaf in the bsp tree
+//
+#define	PLANENUM_LEAF		-1
+
+typedef struct node_s
+{
+    surface_t*      surfaces;
+
+    vec3_t          mins, maxs;                            // bounding volume of portals;
+
+    // information for decision nodes
+    int             planenum;                              // -1 = leaf node
+    struct node_s*  children[2];                           // only valid for decision nodes
+    face_t*         faces;                                 // decision nodes only, list for both sides
+
+    // information for leafs
+    int             contents;                              // leaf nodes (0 for decision nodes)
+    face_t**        markfaces;                             // leaf nodes only, point to node faces
+    struct portal_s* portals;
+    int             visleafnum;                            // -1 = solid
+    int             valid;                                 // for flood filling
+    int             occupied;                              // light number in leaf for outside filling
+}
+node_t;
+
+#define	NUM_HULLS		4
+
+//=============================================================================
+// solidbsp.c
+extern void     SubdivideFace(face_t* f, face_t** prevptr);
+extern node_t*  SolidBSP(const surfchain_t* const surfhead, bool report_progress);
+
+//=============================================================================
+// merge.c
+extern void     MergePlaneFaces(surface_t* plane);
+extern void     MergeAll(surface_t* surfhead);
+
+//=============================================================================
+// surfaces.c
+extern void     MakeFaceEdges();
+extern int      GetEdge(const vec3_t p1, const vec3_t p2, face_t* f);
+
+//=============================================================================
+// portals.c
+typedef struct portal_s
+{
+    dplane_t        plane;
+    node_t*         onnode;                                // NULL = outside box
+    node_t*         nodes[2];                              // [0] = front side of plane
+    struct portal_s* next[2];
+    Winding*        winding;
+}
+portal_t;
+
+extern node_t   g_outside_node;                            // portals outside the world face this
+
+extern void     AddPortalToNodes(portal_t* p, node_t* front, node_t* back);
+extern void     RemovePortalFromNode(portal_t* portal, node_t* l);
+extern void     MakeHeadnodePortals(node_t* node, const vec3_t mins, const vec3_t maxs);
+
+extern void     FreePortals(node_t* node);
+extern void     WritePortalfile(node_t* headnode);
+
+//=============================================================================
+// tjunc.c
+void            tjunc(node_t* headnode);
+
+//=============================================================================
+// writebsp.c
+extern void     WriteClipNodes(node_t* headnode);
+extern void     WriteDrawNodes(node_t* headnode);
+
+extern void     BeginBSPFile();
+extern void     FinishBSPFile();
+
+//=============================================================================
+// outside.c
+extern node_t*  FillOutside(node_t* node, bool leakfile, unsigned hullnum);
+extern void     LoadAllowableOutsideList(const char* const filename);
+extern void     FreeAllowableOutsideList();
+
+//=============================================================================
+// misc functions
+extern void     GetParamsFromEnt(entity_t* mapent);
+
+extern face_t*  AllocFace();
+extern void     FreeFace(face_t* f);
+
+extern struct portal_s* AllocPortal();
+extern void     FreePortal(struct portal_s* p);
+
+extern surface_t* AllocSurface();
+extern void     FreeSurface(surface_t* s);
+
+extern node_t*  AllocNode();
+
+extern bool     CheckFaceForHint(const face_t* const f);
+extern bool     CheckFaceForSkip(const face_t* const f);
+#ifdef ZHLT_NULLTEX// AJM
+extern bool     CheckFaceForNull(const face_t* const f);
+#endif
+
+
+// =====================================================================================
+//Cpt_Andrew - UTSky Check
+// =====================================================================================
+extern bool     CheckFaceForEnv_Sky(const face_t* const f);
+// =====================================================================================
+
+
+#ifdef ZHLT_DETAIL // AJM
+extern bool     CheckFaceForDetail(const face_t* const f);
+#endif
+
+//=============================================================================
+// cull.c
+extern void     CullStuff();
+
+//=============================================================================
+// qbsp.c
+extern bool     g_nofill;
+extern bool     g_notjunc;
+extern bool     g_watervis;
+extern bool     g_chart;
+extern bool     g_estimate;
+extern int      g_maxnode_size;
+extern int      g_subdivide_size;
+extern int      g_hullnum;
+extern bool     g_bLeakOnly;
+extern bool     g_bLeaked;
+extern char     g_portfilename[_MAX_PATH];
+extern char     g_pointfilename[_MAX_PATH];
+extern char     g_linefilename[_MAX_PATH];
+extern char     g_bspfilename[_MAX_PATH];
+
+
+#ifdef ZHLT_DETAIL // AJM
+extern bool g_bDetailBrushes;
+#endif
+
+#ifdef ZHLT_NULLTEX // AJM
+extern bool     g_bUseNullTex;
+#endif
+
+extern face_t*  NewFaceFromFace(const face_t* const in);
+extern void     SplitFace(face_t* in, const dplane_t* const split, face_t** front, face_t** back);
+
+#endif // qbsp.c====================================================================== HLBSP_H__

+ 624 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/hlbsp.mak

@@ -0,0 +1,624 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on hlbsp.dsp
+!IF "$(CFG)" == ""
+CFG=hlbsp - Win32 Super_Debug
+!MESSAGE No configuration specified. Defaulting to hlbsp - Win32 Super_Debug.
+!ENDIF 
+
+!IF "$(CFG)" != "hlbsp - Win32 Release" && "$(CFG)" != "hlbsp - Win32 Debug" && "$(CFG)" != "hlbsp - Win32 Release w Symbols" && "$(CFG)" != "hlbsp - Win32 Super_Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "hlbsp.mak" CFG="hlbsp - Win32 Super_Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "hlbsp - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "hlbsp - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "hlbsp - Win32 Release w Symbols" (based on "Win32 (x86) Console Application")
+!MESSAGE "hlbsp - Win32 Super_Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "hlbsp - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlbsp.exe" "$(OUTDIR)\hlbsp.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\merge.obj"
+	-@erase "$(INTDIR)\merge.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\outside.obj"
+	-@erase "$(INTDIR)\outside.sbr"
+	-@erase "$(INTDIR)\portals.obj"
+	-@erase "$(INTDIR)\portals.sbr"
+	-@erase "$(INTDIR)\qbsp.obj"
+	-@erase "$(INTDIR)\qbsp.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\solidbsp.obj"
+	-@erase "$(INTDIR)\solidbsp.sbr"
+	-@erase "$(INTDIR)\surfaces.obj"
+	-@erase "$(INTDIR)\surfaces.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\tjunc.obj"
+	-@erase "$(INTDIR)\tjunc.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(INTDIR)\writebsp.obj"
+	-@erase "$(INTDIR)\writebsp.sbr"
+	-@erase "$(OUTDIR)\hlbsp.bsc"
+	-@erase "$(OUTDIR)\hlbsp.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\common" /I "..\template" /D "NDEBUG" /D "DOUBLEVEC_T" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /D "STDC_HEADERS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlbsp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlbsp.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\writebsp.sbr" \
+	"$(INTDIR)\merge.sbr" \
+	"$(INTDIR)\outside.sbr" \
+	"$(INTDIR)\portals.sbr" \
+	"$(INTDIR)\qbsp.sbr" \
+	"$(INTDIR)\solidbsp.sbr" \
+	"$(INTDIR)\surfaces.sbr" \
+	"$(INTDIR)\tjunc.sbr" \
+	"$(INTDIR)\winding.sbr"
+
+"$(OUTDIR)\hlbsp.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x400000,0x100000 /subsystem:console /incremental:no /pdb:"$(OUTDIR)\hlbsp.pdb" /machine:I386 /out:"$(OUTDIR)\hlbsp.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\writebsp.obj" \
+	"$(INTDIR)\merge.obj" \
+	"$(INTDIR)\outside.obj" \
+	"$(INTDIR)\portals.obj" \
+	"$(INTDIR)\qbsp.obj" \
+	"$(INTDIR)\solidbsp.obj" \
+	"$(INTDIR)\surfaces.obj" \
+	"$(INTDIR)\tjunc.obj" \
+	"$(INTDIR)\winding.obj"
+
+"$(OUTDIR)\hlbsp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "hlbsp - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlbsp.exe" "$(OUTDIR)\hlbsp.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\merge.obj"
+	-@erase "$(INTDIR)\merge.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\outside.obj"
+	-@erase "$(INTDIR)\outside.sbr"
+	-@erase "$(INTDIR)\portals.obj"
+	-@erase "$(INTDIR)\portals.sbr"
+	-@erase "$(INTDIR)\qbsp.obj"
+	-@erase "$(INTDIR)\qbsp.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\solidbsp.obj"
+	-@erase "$(INTDIR)\solidbsp.sbr"
+	-@erase "$(INTDIR)\surfaces.obj"
+	-@erase "$(INTDIR)\surfaces.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\tjunc.obj"
+	-@erase "$(INTDIR)\tjunc.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(INTDIR)\writebsp.obj"
+	-@erase "$(INTDIR)\writebsp.sbr"
+	-@erase "$(OUTDIR)\hlbsp.bsc"
+	-@erase "$(OUTDIR)\hlbsp.exe"
+	-@erase "$(OUTDIR)\hlbsp.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /Gm /GX /Zi /Od /I "..\common" /I "..\template" /D "DOUBLEVEC_T" /D "_DEBUG" /D "STDC_HEADERS" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlbsp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlbsp.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\writebsp.sbr" \
+	"$(INTDIR)\merge.sbr" \
+	"$(INTDIR)\outside.sbr" \
+	"$(INTDIR)\portals.sbr" \
+	"$(INTDIR)\qbsp.sbr" \
+	"$(INTDIR)\solidbsp.sbr" \
+	"$(INTDIR)\surfaces.sbr" \
+	"$(INTDIR)\tjunc.sbr" \
+	"$(INTDIR)\winding.sbr"
+
+"$(OUTDIR)\hlbsp.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x1000000,0x100000 /subsystem:console /profile /map:"$(INTDIR)\hlbsp.map" /debug /machine:I386 /out:"$(OUTDIR)\hlbsp.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\writebsp.obj" \
+	"$(INTDIR)\merge.obj" \
+	"$(INTDIR)\outside.obj" \
+	"$(INTDIR)\portals.obj" \
+	"$(INTDIR)\qbsp.obj" \
+	"$(INTDIR)\solidbsp.obj" \
+	"$(INTDIR)\surfaces.obj" \
+	"$(INTDIR)\tjunc.obj" \
+	"$(INTDIR)\winding.obj"
+
+"$(OUTDIR)\hlbsp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "hlbsp - Win32 Release w Symbols"
+
+OUTDIR=.\Release_w_Symbols
+INTDIR=.\Release_w_Symbols
+# Begin Custom Macros
+OutDir=.\Release_w_Symbols
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlbsp.exe" "$(OUTDIR)\hlbsp.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\merge.obj"
+	-@erase "$(INTDIR)\merge.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\outside.obj"
+	-@erase "$(INTDIR)\outside.sbr"
+	-@erase "$(INTDIR)\portals.obj"
+	-@erase "$(INTDIR)\portals.sbr"
+	-@erase "$(INTDIR)\qbsp.obj"
+	-@erase "$(INTDIR)\qbsp.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\solidbsp.obj"
+	-@erase "$(INTDIR)\solidbsp.sbr"
+	-@erase "$(INTDIR)\surfaces.obj"
+	-@erase "$(INTDIR)\surfaces.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\tjunc.obj"
+	-@erase "$(INTDIR)\tjunc.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(INTDIR)\writebsp.obj"
+	-@erase "$(INTDIR)\writebsp.sbr"
+	-@erase "$(OUTDIR)\hlbsp.bsc"
+	-@erase "$(OUTDIR)\hlbsp.exe"
+	-@erase "$(OUTDIR)\hlbsp.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /GX /Zi /O2 /I "..\common" /I "..\template" /D "NDEBUG" /D "DOUBLEVEC_T" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /D "STDC_HEADERS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlbsp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlbsp.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\writebsp.sbr" \
+	"$(INTDIR)\merge.sbr" \
+	"$(INTDIR)\outside.sbr" \
+	"$(INTDIR)\portals.sbr" \
+	"$(INTDIR)\qbsp.sbr" \
+	"$(INTDIR)\solidbsp.sbr" \
+	"$(INTDIR)\surfaces.sbr" \
+	"$(INTDIR)\tjunc.sbr" \
+	"$(INTDIR)\winding.sbr"
+
+"$(OUTDIR)\hlbsp.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x400000,0x100000 /subsystem:console /pdb:none /map:"$(INTDIR)\hlbsp.map" /debug /machine:I386 /out:"$(OUTDIR)\hlbsp.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\writebsp.obj" \
+	"$(INTDIR)\merge.obj" \
+	"$(INTDIR)\outside.obj" \
+	"$(INTDIR)\portals.obj" \
+	"$(INTDIR)\qbsp.obj" \
+	"$(INTDIR)\solidbsp.obj" \
+	"$(INTDIR)\surfaces.obj" \
+	"$(INTDIR)\tjunc.obj" \
+	"$(INTDIR)\winding.obj"
+
+"$(OUTDIR)\hlbsp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "hlbsp - Win32 Super_Debug"
+
+OUTDIR=.\Super_Debug
+INTDIR=.\Super_Debug
+# Begin Custom Macros
+OutDir=.\Super_Debug
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlbsp.exe" "$(OUTDIR)\hlbsp.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\merge.obj"
+	-@erase "$(INTDIR)\merge.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\outside.obj"
+	-@erase "$(INTDIR)\outside.sbr"
+	-@erase "$(INTDIR)\portals.obj"
+	-@erase "$(INTDIR)\portals.sbr"
+	-@erase "$(INTDIR)\qbsp.obj"
+	-@erase "$(INTDIR)\qbsp.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\solidbsp.obj"
+	-@erase "$(INTDIR)\solidbsp.sbr"
+	-@erase "$(INTDIR)\surfaces.obj"
+	-@erase "$(INTDIR)\surfaces.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\tjunc.obj"
+	-@erase "$(INTDIR)\tjunc.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(INTDIR)\writebsp.obj"
+	-@erase "$(INTDIR)\writebsp.sbr"
+	-@erase "$(OUTDIR)\hlbsp.bsc"
+	-@erase "$(OUTDIR)\hlbsp.exe"
+	-@erase "$(OUTDIR)\hlbsp.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\common" /I "..\template" /D "DOUBLEVEC_T" /D "_DEBUG" /D "STDC_HEADERS" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlbsp.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlbsp.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\writebsp.sbr" \
+	"$(INTDIR)\merge.sbr" \
+	"$(INTDIR)\outside.sbr" \
+	"$(INTDIR)\portals.sbr" \
+	"$(INTDIR)\qbsp.sbr" \
+	"$(INTDIR)\solidbsp.sbr" \
+	"$(INTDIR)\surfaces.sbr" \
+	"$(INTDIR)\tjunc.sbr" \
+	"$(INTDIR)\winding.sbr"
+
+"$(OUTDIR)\hlbsp.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x1000000,0x100000 /subsystem:console /profile /map:"$(INTDIR)\hlbsp.map" /debug /machine:I386 /out:"$(OUTDIR)\hlbsp.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\writebsp.obj" \
+	"$(INTDIR)\merge.obj" \
+	"$(INTDIR)\outside.obj" \
+	"$(INTDIR)\portals.obj" \
+	"$(INTDIR)\qbsp.obj" \
+	"$(INTDIR)\solidbsp.obj" \
+	"$(INTDIR)\surfaces.obj" \
+	"$(INTDIR)\tjunc.obj" \
+	"$(INTDIR)\winding.obj"
+
+"$(OUTDIR)\hlbsp.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("hlbsp.dep")
+!INCLUDE "hlbsp.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "hlbsp.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "hlbsp - Win32 Release" || "$(CFG)" == "hlbsp - Win32 Debug" || "$(CFG)" == "hlbsp - Win32 Release w Symbols" || "$(CFG)" == "hlbsp - Win32 Super_Debug"
+SOURCE=..\common\blockmem.cpp
+
+"$(INTDIR)\blockmem.obj"	"$(INTDIR)\blockmem.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\bspfile.cpp
+
+"$(INTDIR)\bspfile.obj"	"$(INTDIR)\bspfile.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\cmdlib.cpp
+
+"$(INTDIR)\cmdlib.obj"	"$(INTDIR)\cmdlib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\filelib.cpp
+
+"$(INTDIR)\filelib.obj"	"$(INTDIR)\filelib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\log.cpp
+
+"$(INTDIR)\log.obj"	"$(INTDIR)\log.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\mathlib.cpp
+
+"$(INTDIR)\mathlib.obj"	"$(INTDIR)\mathlib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\messages.cpp
+
+"$(INTDIR)\messages.obj"	"$(INTDIR)\messages.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\scriplib.cpp
+
+"$(INTDIR)\scriplib.obj"	"$(INTDIR)\scriplib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\threads.cpp
+
+"$(INTDIR)\threads.obj"	"$(INTDIR)\threads.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\writebsp.cpp
+
+"$(INTDIR)\writebsp.obj"	"$(INTDIR)\writebsp.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\merge.cpp
+
+"$(INTDIR)\merge.obj"	"$(INTDIR)\merge.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\outside.cpp
+
+"$(INTDIR)\outside.obj"	"$(INTDIR)\outside.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\portals.cpp
+
+"$(INTDIR)\portals.obj"	"$(INTDIR)\portals.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\qbsp.cpp
+
+"$(INTDIR)\qbsp.obj"	"$(INTDIR)\qbsp.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\solidbsp.cpp
+
+"$(INTDIR)\solidbsp.obj"	"$(INTDIR)\solidbsp.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\surfaces.cpp
+
+"$(INTDIR)\surfaces.obj"	"$(INTDIR)\surfaces.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\tjunc.cpp
+
+"$(INTDIR)\tjunc.obj"	"$(INTDIR)\tjunc.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=..\common\winding.cpp
+
+"$(INTDIR)\winding.obj"	"$(INTDIR)\winding.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+
+!ENDIF 
+

+ 721 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/hlbsp.vcproj

@@ -0,0 +1,721 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="hlbsp"
+	ProjectGUID="{367AE0F7-CD4D-44E0-A2E2-34B9C6A3E51A}"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+		<Platform
+			Name="x64"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\Debug"
+			IntermediateDirectory=".\Debug"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\Debug/hlbsp.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\common,..\template"
+				PreprocessorDefinitions="DOUBLEVEC_T,_DEBUG,STDC_HEADERS,WIN32,_CONSOLE,SYSTEM_WIN32"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Debug/hlbsp.pch"
+				AssemblerListingLocation=".\Debug/"
+				ObjectFile=".\Debug/"
+				ProgramDataBaseFileName=".\Debug/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Debug/hlbsp.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\Debug/hlbsp.pdb"
+				GenerateMapFile="true"
+				MapFileName=".\Debug/hlbsp.map"
+				SubSystem="1"
+				StackReserveSize="16777216"
+				StackCommitSize="1048576"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|x64"
+			OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+				TypeLibraryName=".\Debug/hlbsp.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\common,..\template"
+				PreprocessorDefinitions="DOUBLEVEC_T,_DEBUG,STDC_HEADERS,WIN32,_CONSOLE,SYSTEM_WIN32"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Debug/hlbsp.pch"
+				AssemblerListingLocation=".\Debug/"
+				ObjectFile=".\Debug/"
+				ProgramDataBaseFileName=".\Debug/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Debug/hlbsp.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\Debug/hlbsp.pdb"
+				GenerateMapFile="true"
+				MapFileName=".\Debug/hlbsp.map"
+				SubSystem="1"
+				StackReserveSize="16777216"
+				StackCommitSize="1048576"
+				TargetMachine="17"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\Release"
+			IntermediateDirectory=".\Release"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			UseOfATL="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="0"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\Release/hlbsp.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				UseUnicodeResponseFiles="false"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="..\common,..\template"
+				PreprocessorDefinitions="NDEBUG,DOUBLEVEC_T,WIN32,_CONSOLE,SYSTEM_WIN32,STDC_HEADERS"
+				StringPooling="true"
+				ExceptionHandling="1"
+				BufferSecurityCheck="false"
+				EnableFunctionLevelLinking="false"
+				EnableEnhancedInstructionSet="2"
+				FloatingPointModel="0"
+				RuntimeTypeInfo="false"
+				OpenMP="false"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Release/hlbsp.pch"
+				AssemblerListingLocation=".\Release/"
+				ObjectFile=".\Release/"
+				ProgramDataBaseFileName=".\Release/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Release/hlbsp.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\Release/hlbsp.pdb"
+				SubSystem="1"
+				StackReserveSize="4194304"
+				StackCommitSize="1048576"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="0"
+				LinkTimeCodeGeneration="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|x64"
+			OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			UseOfATL="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="0"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+				TypeLibraryName=".\Release/hlbsp.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				UseUnicodeResponseFiles="false"
+				Optimization="3"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="..\common,..\template"
+				PreprocessorDefinitions="NDEBUG,DOUBLEVEC_T,WIN32,_CONSOLE,SYSTEM_WIN32,STDC_HEADERS"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				BufferSecurityCheck="false"
+				EnableFunctionLevelLinking="true"
+				EnableEnhancedInstructionSet="0"
+				FloatingPointModel="0"
+				RuntimeTypeInfo="false"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Release/hlbsp.pch"
+				AssemblerListingLocation=".\Release/"
+				ObjectFile=".\Release/"
+				ProgramDataBaseFileName=".\Release/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				Detect64BitPortabilityProblems="false"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Release/hlbsp.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\Release/hlbsp.pdb"
+				SubSystem="1"
+				StackReserveSize="4194304"
+				StackCommitSize="1048576"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				LinkTimeCodeGeneration="1"
+				TargetMachine="17"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\Release/hlbsp.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalOptions="/machine:x64"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				AdditionalIncludeDirectories="D:\Programs\MSPlatformSDKServer2003\Include\atl;..\common;..\template"
+				PreprocessorDefinitions="NDEBUG,DOUBLEVEC_T,WIN32,_CONSOLE,SYSTEM_WIN32,STDC_HEADERS"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				EnableEnhancedInstructionSet="2"
+				FloatingPointModel="0"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Release/hlbsp.pch"
+				AssemblerListingLocation=".\Release/"
+				ObjectFile=".\Release/"
+				ProgramDataBaseFileName=".\Release/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				Detect64BitPortabilityProblems="false"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/machine:x64"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Release/hlbsp.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\Release/hlbsp.pdb"
+				SubSystem="1"
+				StackReserveSize="4194304"
+				StackCommitSize="1048576"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|x64"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
+			>
+			<File
+				RelativePath=".\merge.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\outside.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\portals.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\qbsp.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\solidbsp.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\surfaces.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\tjunc.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\common\winding.cpp"
+				>
+			</File>
+			<Filter
+				Name="common"
+				>
+				<File
+					RelativePath="..\common\blockmem.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\bspfile.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\cmdlib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\filelib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\log.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\mathlib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\messages.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\scriplib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\threads.cpp"
+					>
+				</File>
+				<File
+					RelativePath=".\writebsp.cpp"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;fi;fd"
+			>
+			<File
+				RelativePath="..\common\blockmem.h"
+				>
+			</File>
+			<File
+				RelativePath=".\bsp5.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\bspfile.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\cmdlib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\filelib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\hlassert.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\log.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\mathlib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\mathtypes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\messages.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\scriplib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\threads.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\win32fix.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 177 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/hlbsp.vcproj.SILENCERSPC.Administrator.user

@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="9.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|x64"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|x64"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|x64"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>

+ 48 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/make.inc

@@ -0,0 +1,48 @@
+HLBSP_DEFINES+=-D DOUBLEVEC_T
+HLBSP:=$(OUTDIR)/hlbsp$(EXEEXT)
+HLBSP_SRCDIR:=hlbsp
+HLBSP_OUTDIR:=$(HLBSP_SRCDIR)/$(OUTDIR)
+
+
+HLBSP_INPUT := \
+$(HLBSP_SRCDIR)/merge.cpp \
+$(HLBSP_SRCDIR)/outside.cpp \
+$(HLBSP_SRCDIR)/portals.cpp \
+$(HLBSP_SRCDIR)/qbsp.cpp \
+$(HLBSP_SRCDIR)/solidbsp.cpp \
+$(HLBSP_SRCDIR)/surfaces.cpp \
+$(HLBSP_SRCDIR)/tjunc.cpp \
+$(HLBSP_SRCDIR)/writebsp.cpp \
+$(COMMON_SRCDIR)/blockmem.cpp \
+$(COMMON_SRCDIR)/bspfile.cpp \
+$(COMMON_SRCDIR)/cmdlib.cpp \
+$(COMMON_SRCDIR)/filelib.cpp \
+$(COMMON_SRCDIR)/log.cpp \
+$(COMMON_SRCDIR)/mathlib.cpp \
+$(COMMON_SRCDIR)/messages.cpp \
+$(COMMON_SRCDIR)/scriplib.cpp \
+$(COMMON_SRCDIR)/threads.cpp \
+$(COMMON_SRCDIR)/winding.cpp \
+
+
+HLBSP_OUTPUT := \
+$(HLBSP_OUTDIR)/merge$(OBJEXT) \
+$(HLBSP_OUTDIR)/outside$(OBJEXT) \
+$(HLBSP_OUTDIR)/portals$(OBJEXT) \
+$(HLBSP_OUTDIR)/qbsp$(OBJEXT) \
+$(HLBSP_OUTDIR)/solidbsp$(OBJEXT) \
+$(HLBSP_OUTDIR)/surfaces$(OBJEXT) \
+$(HLBSP_OUTDIR)/tjunc$(OBJEXT) \
+$(HLBSP_OUTDIR)/writebsp$(OBJEXT) \
+$(HLBSP_OUTDIR)/blockmem$(OBJEXT) \
+$(HLBSP_OUTDIR)/bspfile$(OBJEXT) \
+$(HLBSP_OUTDIR)/cmdlib$(OBJEXT) \
+$(HLBSP_OUTDIR)/filelib$(OBJEXT) \
+$(HLBSP_OUTDIR)/log$(OBJEXT) \
+$(HLBSP_OUTDIR)/mathlib$(OBJEXT) \
+$(HLBSP_OUTDIR)/messages$(OBJEXT) \
+$(HLBSP_OUTDIR)/scriplib$(OBJEXT) \
+$(HLBSP_OUTDIR)/threads$(OBJEXT) \
+$(HLBSP_OUTDIR)/winding$(OBJEXT) \
+
+

+ 259 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/merge.cpp

@@ -0,0 +1,259 @@
+#include "bsp5.h"
+
+//  TryMerge
+//  MergeFaceToList
+//  FreeMergeListScraps
+//  MergePlaneFaces
+//  MergeAll
+
+#define CONTINUOUS_EPSILON	ON_EPSILON
+
+// =====================================================================================
+//  TryMerge
+//      If two polygons share a common edge and the edges that meet at the
+//      common points are both inside the other polygons, merge them
+//      Returns NULL if the faces couldn't be merged, or the new face.
+//      The originals will NOT be freed.
+// =====================================================================================
+static face_t*  TryMerge(face_t* f1, face_t* f2)
+{
+    vec_t*          p1;
+    vec_t*          p2;
+    vec_t*          p3;
+    vec_t*          p4;
+    vec_t*          back;
+    face_t*         newf;
+    int             i;
+    int             j;
+    int             k;
+    int             l;
+    vec3_t          normal;
+    vec3_t          delta;
+    vec3_t          planenormal;
+    vec_t           dot;
+    dplane_t*       plane;
+    bool            keep1;
+    bool            keep2;
+
+    if (f1->numpoints == -1 || f2->numpoints == -1)
+    {
+        return NULL;
+    }    
+    if (f1->texturenum != f2->texturenum)
+    {
+        return NULL;
+    }
+    if (f1->contents != f2->contents)
+    {
+        return NULL;
+    }
+
+    //
+    // find a common edge
+    //      
+    p1 = p2 = NULL;                                        // shut up the compiler
+    j = 0;
+
+    for (i = 0; i < f1->numpoints; i++)
+    {
+        p1 = f1->pts[i];
+        p2 = f1->pts[(i + 1) % f1->numpoints];
+        for (j = 0; j < f2->numpoints; j++)
+        {
+            p3 = f2->pts[j];
+            p4 = f2->pts[(j + 1) % f2->numpoints];
+            for (k = 0; k < 3; k++)
+            {
+                if (fabs(p1[k] - p4[k]) > EQUAL_EPSILON)
+                {
+                    break;
+                }
+                if (fabs(p2[k] - p3[k]) > EQUAL_EPSILON)
+                {
+                    break;
+                }
+            }
+            if (k == 3)
+            {
+                break;
+            }
+        }
+        if (j < f2->numpoints)
+        {
+            break;
+        }
+    }
+
+    if (i == f1->numpoints)
+    {
+        return NULL;                                       // no matching edges
+    }
+
+    //
+    // check slope of connected lines
+    // if the slopes are colinear, the point can be removed
+    //
+    plane = &g_dplanes[f1->planenum];
+    VectorCopy(plane->normal, planenormal);
+
+    back = f1->pts[(i + f1->numpoints - 1) % f1->numpoints];
+    VectorSubtract(p1, back, delta);
+    CrossProduct(planenormal, delta, normal);
+    VectorNormalize(normal);
+
+    back = f2->pts[(j + 2) % f2->numpoints];
+    VectorSubtract(back, p1, delta);
+    dot = DotProduct(delta, normal);
+    if (dot > CONTINUOUS_EPSILON)
+    {
+        return NULL;                                       // not a convex polygon
+    }
+    keep1 = dot < -CONTINUOUS_EPSILON;
+
+    back = f1->pts[(i + 2) % f1->numpoints];
+    VectorSubtract(back, p2, delta);
+    CrossProduct(planenormal, delta, normal);
+    VectorNormalize(normal);
+
+    back = f2->pts[(j + f2->numpoints - 1) % f2->numpoints];
+    VectorSubtract(back, p2, delta);
+    dot = DotProduct(delta, normal);
+    if (dot > CONTINUOUS_EPSILON)
+    {
+        return NULL;                                       // not a convex polygon
+    }
+    keep2 = dot < -CONTINUOUS_EPSILON;
+
+    //
+    // build the new polygon
+    //
+    if (f1->numpoints + f2->numpoints > MAXEDGES)
+    {
+        //              Error ("TryMerge: too many edges!");
+        return NULL;
+    }
+
+    newf = NewFaceFromFace(f1);
+
+    // copy first polygon
+    for (k = (i + 1) % f1->numpoints; k != i; k = (k + 1) % f1->numpoints)
+    {
+        if (k == (i + 1) % f1->numpoints && !keep2)
+        {
+            continue;
+        }
+
+        VectorCopy(f1->pts[k], newf->pts[newf->numpoints]);
+        newf->numpoints++;
+    }
+
+    // copy second polygon
+    for (l = (j + 1) % f2->numpoints; l != j; l = (l + 1) % f2->numpoints)
+    {
+        if (l == (j + 1) % f2->numpoints && !keep1)
+        {
+            continue;
+        }
+        VectorCopy(f2->pts[l], newf->pts[newf->numpoints]);
+        newf->numpoints++;
+    }
+
+    return newf;
+}
+
+// =====================================================================================
+//  MergeFaceToList
+// =====================================================================================
+static face_t*  MergeFaceToList(face_t* face, face_t* list)
+{
+    face_t*         newf;
+    face_t*         f;
+
+    for (f = list; f; f = f->next)
+    {
+        //CheckColinear (f);            
+        newf = TryMerge(face, f);
+        if (!newf)
+        {
+            continue;
+        }
+        FreeFace(face);
+        f->numpoints = -1;                                 // merged out
+        return MergeFaceToList(newf, list);
+    }
+
+    // didn't merge, so add at start
+    face->next = list;
+    return face;
+}
+
+// =====================================================================================
+//  FreeMergeListScraps
+// =====================================================================================
+static face_t*  FreeMergeListScraps(face_t* merged)
+{
+    face_t*         head;
+    face_t*         next;
+
+    head = NULL;
+    for (; merged; merged = next)
+    {
+        next = merged->next;
+        if (merged->numpoints == -1)
+        {
+            FreeFace(merged);
+        }
+        else
+        {
+            merged->next = head;
+            head = merged;
+        }
+    }
+
+    return head;
+}
+
+// =====================================================================================
+//  MergePlaneFaces
+// =====================================================================================
+void            MergePlaneFaces(surface_t* plane)
+{
+    face_t*         f1;
+    face_t*         next;
+    face_t*         merged;
+
+    merged = NULL;
+
+    for (f1 = plane->faces; f1; f1 = next)
+    {
+        next = f1->next;
+        merged = MergeFaceToList(f1, merged);
+    }
+
+    // chain all of the non-empty faces to the plane
+    plane->faces = FreeMergeListScraps(merged);
+}
+
+// =====================================================================================
+//  MergeAll
+// =====================================================================================
+void            MergeAll(surface_t* surfhead)
+{
+    surface_t*      surf;
+    int             mergefaces;
+    face_t*         f;
+
+    Verbose("---- MergeAll ----\n");
+
+    mergefaces = 0;
+    for (surf = surfhead; surf; surf = surf->next)
+    {
+        MergePlaneFaces(surf);
+        for (f = surf->faces; f; f = f->next)
+        {
+            mergefaces++;
+        }
+    }
+
+    Verbose("%i mergefaces\n", mergefaces);
+}

+ 553 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/outside.cpp

@@ -0,0 +1,553 @@
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4267 4996) // 'size_t' to 'unsigned int', possible loss of data
+#endif
+
+#include "bsp5.h"
+
+//  PointInLeaf
+//  PlaceOccupant
+//  MarkLeakTrail
+//  RecursiveFillOutside
+//  ClearOutFaces_r
+//  isClassnameAllowableOutside
+//  FreeAllowableOutsideList
+//  LoadAllowableOutsideList
+//  FillOutside
+
+static int      outleafs;
+static int      valid;
+static int      c_falsenodes;
+static int      c_free_faces;
+static int      c_keep_faces;
+
+// =====================================================================================
+//  PointInLeaf
+// =====================================================================================
+static node_t*  PointInLeaf(node_t* node, const vec3_t point)
+{
+    vec_t           d;
+
+    if (node->contents)
+    {
+        //Log("PointInLeaf::node->contents == %i\n", node->contents);
+        return node;
+    }
+
+    d = DotProduct(g_dplanes[node->planenum].normal, point) - g_dplanes[node->planenum].dist;
+
+    if (d > 0)
+        return PointInLeaf(node->children[0], point);
+
+    return PointInLeaf(node->children[1], point);
+}
+
+// =====================================================================================
+//  PlaceOccupant
+// =====================================================================================
+static bool     PlaceOccupant(const int num, const vec3_t point, node_t* headnode)
+{
+    node_t*         n;
+
+    n = PointInLeaf(headnode, point);
+    if (n->contents == CONTENTS_SOLID)
+    {
+        return false;
+    }
+    //Log("PlaceOccupant::n->contents == %i\n", n->contents);
+
+    n->occupied = num;
+    return true;
+}
+
+// =====================================================================================
+//  MarkLeakTrail
+// =====================================================================================
+static portal_t* prevleaknode;
+static FILE*    pointfile;
+static FILE*    linefile;
+
+static void     MarkLeakTrail(portal_t* n2)
+{
+    int             i;
+    vec3_t          p1, p2, dir;
+    float           len;
+    portal_t*       n1;
+
+    n1 = prevleaknode;
+    prevleaknode = n2;
+
+    if (!n1)
+    {
+        return;
+    }
+
+    n2->winding->getCenter(p1);
+    n1->winding->getCenter(p2);
+
+    // Linefile
+    fprintf(linefile, "%f %f %f - %f %f %f\n", p1[0], p1[1], p1[2], p2[0], p2[1], p2[2]);
+
+    // Pointfile
+    fprintf(pointfile, "%f %f %f\n", p1[0], p1[1], p1[2]);
+
+    VectorSubtract(p2, p1, dir);
+    len = VectorLength(dir);
+    VectorNormalize(dir);
+
+    while (len > 2)
+    {
+        fprintf(pointfile, "%f %f %f\n", p1[0], p1[1], p1[2]);
+        for (i = 0; i < 3; i++)
+            p1[i] += dir[i] * 2;
+        len -= 2;
+    }
+}
+
+// =====================================================================================
+//  RecursiveFillOutside
+//      Returns true if an occupied leaf is reached
+//      If fill is false, just check, don't fill 
+// =====================================================================================
+static int      hit_occupied;
+static int      backdraw;
+static bool     RecursiveFillOutside(node_t* l, const bool fill)
+{
+    portal_t*       p;
+    int             s;
+
+    if ((l->contents == CONTENTS_SOLID) || (l->contents == CONTENTS_SKY) 
+#ifdef ZHLT_DETAIL
+        || (l->contents == CONTENTS_DETAIL)
+#endif
+        )
+	{
+        /*if (l->contents != CONTENTS_SOLID)
+            Log("RecursiveFillOutside::l->contents == %i \n", l->contents);*/
+
+        return false;
+    }
+
+    if (l->valid == valid)
+    {
+        return false;
+    }
+
+    if (l->occupied)
+    {
+        hit_occupied = l->occupied;
+        backdraw = 1000;
+        return true;
+    }
+
+    l->valid = valid;
+
+    // fill it and it's neighbors
+    if (fill)
+    {
+        l->contents = CONTENTS_SOLID;
+        l->planenum = -1;
+    }
+    outleafs++;
+
+    for (p = l->portals; p;)
+    {
+        s = (p->nodes[0] == l);
+
+        if (RecursiveFillOutside(p->nodes[s], fill))
+        {                                                  // leaked, so stop filling
+            if (backdraw-- > 0)
+            {
+                MarkLeakTrail(p);
+            }
+            return true;
+        }
+        p = p->next[!s];
+    }
+
+    return false;
+}
+
+// =====================================================================================
+//  ClearOutFaces_r
+//      Removes unused nodes
+// =====================================================================================
+static node_t*  ClearOutFaces_r(node_t* node)
+{
+    face_t*         f;
+    face_t*         fnext;
+    face_t**        fp;
+    portal_t*       p;
+
+    // mark the node and all it's faces, so they
+    // can be removed if no children use them
+
+    node->valid = 0;                                       // will be set if any children touch it
+    for (f = node->faces; f; f = f->next)
+    {
+        f->outputnumber = -1;
+    }
+
+    // go down the children
+    if (node->planenum != -1)
+    {
+        //
+        // decision node
+        //
+        node->children[0] = ClearOutFaces_r(node->children[0]);
+        node->children[1] = ClearOutFaces_r(node->children[1]);
+
+        // free any faces not in open child leafs
+        f = node->faces;
+        node->faces = NULL;
+
+        for (; f; f = fnext)
+        {
+            fnext = f->next;
+            if (f->outputnumber == -1)
+            {                                              // never referenced, so free it
+                c_free_faces++;
+                FreeFace(f);
+            }
+            else
+            {
+                c_keep_faces++;
+                f->next = node->faces;
+                node->faces = f;
+            }
+        }
+
+        if (!node->valid)
+        {
+            // this node does not touch any interior leafs
+
+            // if both children are solid, just make this node solid
+            if (node->children[0]->contents == CONTENTS_SOLID && node->children[1]->contents == CONTENTS_SOLID)
+            {
+                node->contents = CONTENTS_SOLID;
+                node->planenum = -1;
+                return node;
+            }
+
+            // if one child is solid, shortcut down the other side
+            if (node->children[0]->contents == CONTENTS_SOLID)
+            {
+                return node->children[1];
+            }
+            if (node->children[1]->contents == CONTENTS_SOLID)
+            {
+                return node->children[0];
+            }
+
+            c_falsenodes++;
+        }
+        return node;
+    }
+
+    //
+    // leaf node
+    //
+    if (node->contents != CONTENTS_SOLID)
+    {
+        // this node is still inside
+
+        // mark all the nodes used as portals
+        for (p = node->portals; p;)
+        {
+            if (p->onnode)
+            {
+                p->onnode->valid = 1;
+            }
+            if (p->nodes[0] == node)                       // only write out from first leaf
+            {
+                p = p->next[0];
+            }
+            else
+            {
+                p = p->next[1];
+            }
+        }
+
+        // mark all of the faces to be drawn
+        for (fp = node->markfaces; *fp; fp++)
+        {
+            (*fp)->outputnumber = 0;
+        }
+
+        return node;
+    }
+
+    // this was a filled in node, so free the markfaces
+    if (node->planenum != -1)
+    {
+        free(node->markfaces);
+    }
+
+    return node;
+}
+
+// =====================================================================================
+//  isClassnameAllowableOutside
+// =====================================================================================
+#define  MAX_ALLOWABLE_OUTSIDE_GROWTH_SIZE 64
+
+unsigned        g_nAllowableOutside = 0;
+unsigned        g_maxAllowableOutside = 0;
+char**          g_strAllowableOutsideList;
+
+bool            isClassnameAllowableOutside(const char* const classname)
+{
+    if (g_strAllowableOutsideList)
+    {
+        unsigned        x;
+        char**          list = g_strAllowableOutsideList;
+
+        for (x = 0; x < g_nAllowableOutside; x++, list++)
+        {
+            if (list)
+            {
+                if (!strcasecmp(classname, *list))
+                {
+                    return true;
+                }
+            }
+        }
+    }
+
+    return false;
+}
+
+// =====================================================================================
+//  FreeAllowableOutsideList
+// =====================================================================================
+void            FreeAllowableOutsideList()
+{
+    if (g_strAllowableOutsideList)
+    {
+        free(g_strAllowableOutsideList);
+        g_strAllowableOutsideList = NULL;
+    }
+}
+
+// =====================================================================================
+//  LoadAllowableOutsideList
+// =====================================================================================
+void            LoadAllowableOutsideList(const char* const filename)
+{
+    char*           fname;
+    int             i, x, y;
+    char*           pData;
+    char*           pszData;
+
+    if (!filename)
+    {
+        return;
+    }
+    else
+    {
+        unsigned        len = strlen(filename) + 5;
+
+        fname = (char*)Alloc(len);
+        safe_snprintf(fname, len, "%s", filename);
+    }
+
+    if (q_exists(fname))
+    {
+        if ((i = LoadFile(fname, &pData)))
+        {
+            Log("Reading allowable void entities from file '%s'\n", fname);
+            g_nAllowableOutside = 0;
+            for (pszData = pData, y = 0, x = 0; x < i; x++)
+            {
+                if ((pData[x] == '\n') || (pData[x] == '\r'))
+                {
+                    pData[x] = 0;
+                    if (strlen(pszData))
+                    {
+                        if (g_nAllowableOutside == g_maxAllowableOutside)
+                        {
+                            g_maxAllowableOutside += MAX_ALLOWABLE_OUTSIDE_GROWTH_SIZE;
+                            g_strAllowableOutsideList =
+
+                                (char**)realloc(g_strAllowableOutsideList, sizeof(char*) * g_maxAllowableOutside);
+                        }
+
+                        g_strAllowableOutsideList[y++] = pszData;
+                        g_nAllowableOutside++;
+
+                        Verbose("Adding entity '%s' to the allowable void list\n", pszData);
+                    }
+                    pszData = pData + x + 1;
+                }
+            }
+        }
+    }
+}
+
+// =====================================================================================
+//  FillOutside
+// =====================================================================================
+node_t*         FillOutside(node_t* node, const bool leakfile, const unsigned hullnum)
+{
+    int             s;
+    int             i;
+    bool            inside;
+    bool            ret;
+    vec3_t          origin;
+    const char*     cl;
+
+    Verbose("----- FillOutside ----\n");
+
+    if (g_nofill)
+    {
+        Log("skipped\n");
+        return node;
+    }
+
+    //
+    // place markers for all entities so
+    // we know if we leak inside
+    //
+    inside = false;
+    for (i = 1; i < g_numentities; i++)
+    {
+        GetVectorForKey(&g_entities[i], "origin", origin);
+        cl = ValueForKey(&g_entities[i], "classname");
+        if (!isClassnameAllowableOutside(cl))
+        {
+            if (!VectorCompare(origin, vec3_origin))
+            {
+                origin[2] += 1;                            // so objects on floor are ok
+
+                // nudge playerstart around if needed so clipping hulls allways
+                // have a vlaid point
+                if (!strcmp(cl, "info_player_start"))
+                {
+                    int             x, y;
+
+                    for (x = -16; x <= 16; x += 16)
+                    {
+                        for (y = -16; y <= 16; y += 16)
+                        {
+                            origin[0] += x;
+                            origin[1] += y;
+                            if (PlaceOccupant(i, origin, node))
+                            {
+                                inside = true;
+                                goto gotit;
+                            }
+                            origin[0] -= x;
+                            origin[1] -= y;
+                        }
+                    }
+                  gotit:;
+                }
+                else
+                {
+                    if (PlaceOccupant(i, origin, node))
+                        inside = true;
+                }
+            }
+        }
+    }
+
+    if (!inside)
+    {
+        Warning("No entities exist in hull %i, no filling performed for this hull", hullnum);
+        return node;
+    }
+
+	if(!g_outside_node.portals)
+	{
+		Warning("No outside node portal found in hull %i, no filling performed for this hull",hullnum);
+		return node;
+	}
+
+    s = !(g_outside_node.portals->nodes[1] == &g_outside_node);
+
+    // first check to see if an occupied leaf is hit
+    outleafs = 0;
+    valid++;
+
+    prevleaknode = NULL;
+
+    if (leakfile)
+    {
+        pointfile = fopen(g_pointfilename, "w");
+        if (!pointfile)
+        {
+            Error("Couldn't open pointfile %s\n", g_pointfilename);
+        }
+
+        linefile = fopen(g_linefilename, "w");
+        if (!linefile)
+        {
+            Error("Couldn't open linefile %s\n", g_linefilename);
+        }
+    }
+
+    ret = RecursiveFillOutside(g_outside_node.portals->nodes[s], false);
+
+    if (leakfile)
+    {
+        fclose(pointfile);
+        fclose(linefile);
+    }
+
+    if (ret)
+    {
+        GetVectorForKey(&g_entities[hit_occupied], "origin", origin);
+
+
+        {
+            Warning("=== LEAK in hull %i ===\nEntity %s @ (%4.0f,%4.0f,%4.0f)",
+                 hullnum, ValueForKey(&g_entities[hit_occupied], "classname"), origin[0], origin[1], origin[2]);
+            PrintOnce(
+                "\n  A LEAK is a hole in the map, where the inside of it is exposed to the\n"
+                "(unwanted) outside region.  The entity listed in the error is just a helpful\n"
+                "indication of where the beginning of the leak pointfile starts, so the\n"
+                "beginning of the line can be quickly found and traced to until reaching the\n"
+                "outside. Unless this entity is accidentally on the outside of the map, it\n"
+                "probably should not be deleted.  Some complex rotating objects entities need\n"
+                "their origins outside the map.  To deal with these, just enclose the origin\n"
+                "brush with a solid world brush\n");
+        }
+
+        if (!g_bLeaked)
+        {
+            // First leak spits this out
+            Log("Leak pointfile generated\n\n");
+        }
+
+        if (g_bLeakOnly)
+        {
+            Error("Stopped by leak.");
+        }
+
+        g_bLeaked = true;
+            
+        return node;
+    }
+
+    // now go back and fill things in
+    valid++;
+    RecursiveFillOutside(g_outside_node.portals->nodes[s], true);
+
+    // remove faces and nodes from filled in leafs  
+    c_falsenodes = 0;
+    c_free_faces = 0;
+    c_keep_faces = 0;
+    node = ClearOutFaces_r(node);
+
+    Verbose("%5i outleafs\n", outleafs);
+    Verbose("%5i freed faces\n", c_free_faces);
+    Verbose("%5i keep faces\n", c_keep_faces);
+    Verbose("%5i falsenodes\n", c_falsenodes);
+
+    // save portal file for vis tracing
+    if ((hullnum == 0) && leakfile)
+    {
+        WritePortalfile(node);
+    }
+
+    return node;
+}

+ 325 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/portals.cpp

@@ -0,0 +1,325 @@
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4996)
+#endif
+
+#pragma warning(disable:4018) // '<' : signed/unsigned mismatch
+
+#include "bsp5.h"
+
+node_t          g_outside_node;                            // portals outside the world face this
+
+//=============================================================================
+
+/*
+ * =============
+ * AddPortalToNodes
+ * =============
+ */
+void            AddPortalToNodes(portal_t* p, node_t* front, node_t* back)
+{
+    if (p->nodes[0] || p->nodes[1])
+    {
+        Error("AddPortalToNode: allready included");
+    }
+
+    p->nodes[0] = front;
+    p->next[0] = front->portals;
+    front->portals = p;
+
+    p->nodes[1] = back;
+    p->next[1] = back->portals;
+    back->portals = p;
+}
+
+/*
+ * =============
+ * RemovePortalFromNode
+ * =============
+ */
+void            RemovePortalFromNode(portal_t* portal, node_t* l)
+{
+    portal_t**      pp;
+    portal_t*       t;
+
+    // remove reference to the current portal
+    pp = &l->portals;
+    while (1)
+    {
+        t = *pp;
+        if (!t)
+        {
+            Error("RemovePortalFromNode: portal not in leaf");
+        }
+
+        if (t == portal)
+        {
+            break;
+        }
+
+        if (t->nodes[0] == l)
+        {
+            pp = &t->next[0];
+        }
+        else if (t->nodes[1] == l)
+        {
+            pp = &t->next[1];
+        }
+        else
+        {
+            Error("RemovePortalFromNode: portal not bounding leaf");
+        }
+    }
+
+    if (portal->nodes[0] == l)
+    {
+        *pp = portal->next[0];
+        portal->nodes[0] = NULL;
+    }
+    else if (portal->nodes[1] == l)
+    {
+        *pp = portal->next[1];
+        portal->nodes[1] = NULL;
+    }
+}
+
+//============================================================================
+
+/*
+ * ================
+ * MakeHeadnodePortals
+ * 
+ * The created portals will face the global g_outside_node
+ * ================
+ */
+void            MakeHeadnodePortals(node_t* node, const vec3_t mins, const vec3_t maxs)
+{
+    vec3_t          bounds[2];
+    int             i, j, n;
+    portal_t*       p;
+    portal_t*       portals[6];
+    dplane_t        bplanes[6];
+    dplane_t*       pl;
+
+    // pad with some space so there will never be null volume leafs
+    for (i = 0; i < 3; i++)
+    {
+        bounds[0][i] = mins[i] - SIDESPACE;
+        bounds[1][i] = maxs[i] + SIDESPACE;
+    }
+
+    g_outside_node.contents = CONTENTS_SOLID;
+    g_outside_node.portals = NULL;
+
+    for (i = 0; i < 3; i++)
+    {
+        for (j = 0; j < 2; j++)
+        {
+            n = j * 3 + i;
+
+            p = AllocPortal();
+            portals[n] = p;
+
+            pl = &bplanes[n];
+            memset(pl, 0, sizeof(*pl));
+            if (j)
+            {
+                pl->normal[i] = -1;
+                pl->dist = -bounds[j][i];
+            }
+            else
+            {
+                pl->normal[i] = 1;
+                pl->dist = bounds[j][i];
+            }
+            p->plane = *pl;
+            p->winding = new Winding(*pl);
+            AddPortalToNodes(p, node, &g_outside_node);
+        }
+    }
+
+    // clip the basewindings by all the other planes
+    for (i = 0; i < 6; i++)
+    {
+        for (j = 0; j < 6; j++)
+        {
+            if (j == i)
+            {
+                continue;
+            }
+            portals[i]->winding->Clip(bplanes[j], true);
+        }
+    }
+}
+
+/*
+ * ==============================================================================
+ * 
+ * PORTAL FILE GENERATION
+ * 
+ * ==============================================================================
+ */
+
+static FILE*    pf;
+static int      num_visleafs;                              // leafs the player can be in
+static int      num_visportals;
+
+static void     WritePortalFile_r(const node_t* const node)
+{
+    int             i;
+    portal_t*       p;
+    Winding*        w;
+    dplane_t        plane2;
+
+    if (!node->contents)
+    {
+        WritePortalFile_r(node->children[0]);
+        WritePortalFile_r(node->children[1]);
+        return;
+    }
+
+    if (node->contents == CONTENTS_SOLID)
+    {
+        return;
+    }
+
+    for (p = node->portals; p;)
+    {
+        w = p->winding;
+        if (w && p->nodes[0] == node)
+        {
+            if (p->nodes[0]->contents == p->nodes[1]->contents)
+            {
+                // write out to the file
+
+                // sometimes planes get turned around when they are very near
+                // the changeover point between different axis.  interpret the
+                // plane the same way vis will, and flip the side orders if needed
+                w->getPlane(plane2);
+                if (DotProduct(p->plane.normal, plane2.normal) < 1.0 - ON_EPSILON)
+                {                                          // backwards...
+                    fprintf(pf, "%u %i %i ", w->m_NumPoints, p->nodes[1]->visleafnum, p->nodes[0]->visleafnum);
+                }
+                else
+                {
+                    fprintf(pf, "%u %i %i ", w->m_NumPoints, p->nodes[0]->visleafnum, p->nodes[1]->visleafnum);
+                }
+
+                for (i = 0; i < w->m_NumPoints; i++)
+                {
+                    fprintf(pf, "(%f %f %f) ", w->m_Points[i][0], w->m_Points[i][1], w->m_Points[i][2]);
+                }
+                fprintf(pf, "\n");
+            }
+        }
+
+        if (p->nodes[0] == node)
+        {
+            p = p->next[0];
+        }
+        else
+        {
+            p = p->next[1];
+        }
+    }
+
+}
+
+/*
+ * ================
+ * NumberLeafs_r
+ * ================
+ */
+static void     NumberLeafs_r(node_t* node)
+{
+    portal_t*       p;
+
+    if (!node->contents)
+    {                                                      // decision node
+        node->visleafnum = -99;
+        NumberLeafs_r(node->children[0]);
+        NumberLeafs_r(node->children[1]);
+        return;
+    }
+
+    if (node->contents == CONTENTS_SOLID)
+    {                                                      // solid block, viewpoint never inside
+        node->visleafnum = -1;
+        return;
+    }
+
+    node->visleafnum = num_visleafs++;
+
+    for (p = node->portals; p;)
+    {
+        if (p->nodes[0] == node)                           // only write out from first leaf
+        {
+            if (p->nodes[0]->contents == p->nodes[1]->contents)
+            {
+                num_visportals++;
+            }
+            p = p->next[0];
+        }
+        else
+        {
+            p = p->next[1];
+        }
+    }
+}
+
+/*
+ * ================
+ * WritePortalfile
+ * ================
+ */
+void            WritePortalfile(node_t* headnode)
+{
+    // set the visleafnum field in every leaf and count the total number of portals
+    num_visleafs = 0;
+    num_visportals = 0;
+    NumberLeafs_r(headnode);
+
+    // write the file
+    pf = fopen(g_portfilename, "w");
+    if (!pf)
+    {
+        Error("Error writing portal file %s", g_portfilename);
+    }
+
+    fprintf(pf, "%i\n", num_visleafs);
+    fprintf(pf, "%i\n", num_visportals);
+
+    WritePortalFile_r(headnode);
+    fclose(pf);
+    Log("BSP generation successful, writing portal file '%s'\n", g_portfilename);
+}
+
+//===================================================
+
+void            FreePortals(node_t* node)
+{
+    portal_t*       p;
+    portal_t*       nextp;
+
+    if (node->planenum != -1)
+    {
+        FreePortals(node->children[0]);
+        FreePortals(node->children[1]);
+        return;
+    }
+
+    for (p = node->portals; p; p = nextp)
+    {
+        if (p->nodes[0] == node)
+        {
+            nextp = p->next[0];
+        }
+        else
+        {
+            nextp = p->next[1];
+        }
+        RemovePortalFromNode(p, p->nodes[0]);
+        RemovePortalFromNode(p, p->nodes[1]);
+        delete p->winding;
+        FreePortal(p);
+    }
+}

File diff suppressed because it is too large
+ 1533 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/qbsp.cpp


File diff suppressed because it is too large
+ 1164 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/solidbsp.cpp


+ 309 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/surfaces.cpp

@@ -0,0 +1,309 @@
+#include "bsp5.h"
+
+//  SubdivideFace
+
+//  InitHash
+//  HashVec
+
+//  GetVertex
+//  GetEdge
+//  MakeFaceEdges
+
+static int      subdivides;
+
+/* a surface has all of the faces that could be drawn on a given plane
+   the outside filling stage can remove some of them so a better bsp can be generated */
+
+// =====================================================================================
+//  SubdivideFace
+//      If the face is >256 in either texture direction, carve a valid sized
+//      piece off and insert the remainder in the next link
+// =====================================================================================
+void            SubdivideFace(face_t* f, face_t** prevptr)
+{
+    vec_t           mins, maxs;
+    vec_t           v;
+    int             axis;
+    int             i;
+    dplane_t        plane;
+    face_t*         front;
+    face_t*         back;
+    face_t*         next;
+    texinfo_t*      tex;
+    vec3_t          temp;
+
+    // special (non-surface cached) faces don't need subdivision
+
+    tex = &g_texinfo[f->texturenum];
+
+    if (tex->flags & TEX_SPECIAL) 
+    {
+        return;
+    }
+
+    if (f->facestyle == face_hint)
+    {
+        return;
+    }
+    if (f->facestyle == face_skip)
+    {
+        return;
+    }
+
+#ifdef ZHLT_NULLTEX    // AJM
+    if (f->facestyle == face_null)
+        return; // ideally these should have their tex_special flag set, so its here jic
+#endif
+
+	//SILENCER: Not yet implemented - just altered copypasta here
+	/*if (f->facestyle == face_blocklight)
+		return;*/
+
+    for (axis = 0; axis < 2; axis++)
+    {
+        while (1)
+        {
+            mins = 999999;
+            maxs = -999999;
+
+            for (i = 0; i < f->numpoints; i++)
+            {
+                v = DotProduct(f->pts[i], tex->vecs[axis]);
+                if (v < mins)
+                {
+                    mins = v;
+                }
+                if (v > maxs)
+                {
+                    maxs = v;
+                }
+            }
+
+            if ((maxs - mins) <= g_subdivide_size)
+            {
+                break;
+            }
+                
+            // split it
+            subdivides++;
+
+            VectorCopy(tex->vecs[axis], temp);
+            v = VectorNormalize(temp);
+
+            VectorCopy(temp, plane.normal);
+            plane.dist = (mins + g_subdivide_size - 16) / v;
+            next = f->next;
+            SplitFace(f, &plane, &front, &back);
+            if (!front || !back)
+            {
+                Developer(DEVELOPER_LEVEL_SPAM, "SubdivideFace: didn't split the %d-sided polygon @(%.0f,%.0f,%.0f)",
+                        f->numpoints, f->pts[0][0], f->pts[0][1], f->pts[0][2]);
+                break;
+            }
+            *prevptr = back;
+            back->next = front;
+            front->next = next;
+            f = back;
+        }
+    }
+}
+
+//===========================================================================
+
+typedef struct hashvert_s
+{
+    struct hashvert_s* next;
+    vec3_t          point;
+    int             num;
+    int             numplanes;                             // for corner determination
+    int             planenums[2];
+    int             numedges;
+}
+hashvert_t;
+
+// #define      POINT_EPSILON   0.01
+#define POINT_EPSILON	ON_EPSILON
+
+static hashvert_t hvertex[MAX_MAP_VERTS];
+static hashvert_t* hvert_p;
+
+static face_t*  edgefaces[MAX_MAP_EDGES][2];
+static int      firstmodeledge = 1;
+static int      firstmodelface;
+
+//============================================================================
+
+#define	NUM_HASH	4096
+
+static hashvert_t* hashverts[NUM_HASH];
+
+static vec3_t   hash_min;
+static vec3_t   hash_scale;
+
+// =====================================================================================
+//  InitHash
+// =====================================================================================
+static void     InitHash()
+{
+    vec3_t          size;
+    vec_t           volume;
+    vec_t           scale;
+    int             newsize[2];
+    int             i;
+
+    memset(hashverts, 0, sizeof(hashverts));
+
+    for (i = 0; i < 3; i++)
+    {
+        hash_min[i] = -8000;
+        size[i] = 16000;
+    }
+
+    volume = size[0] * size[1];
+
+    scale = sqrt(volume / NUM_HASH);
+
+    newsize[0] = size[0] / scale;
+    newsize[1] = size[1] / scale;
+
+    hash_scale[0] = newsize[0] / size[0];
+    hash_scale[1] = newsize[1] / size[1];
+    hash_scale[2] = newsize[1];
+
+    hvert_p = hvertex;
+}
+
+// =====================================================================================
+//  HashVec
+// =====================================================================================
+static unsigned HashVec(const vec3_t vec)
+{
+    unsigned        h;
+
+    h = hash_scale[0] * (vec[0] - hash_min[0]) * hash_scale[2] + hash_scale[1] * (vec[1] - hash_min[1]);
+    if (h >= NUM_HASH)
+    {
+        return NUM_HASH - 1;
+    }
+    return h;
+}
+
+// =====================================================================================
+//  GetVertex
+// =====================================================================================
+static int      GetVertex(const vec3_t in, const int planenum)
+{
+    int             h;
+    int             i;
+    hashvert_t*     hv;
+    vec3_t          vert;
+
+    for (i = 0; i < 3; i++)
+    {
+        if (fabs(in[i] - VectorRound(in[i])) < 0.001)
+        {
+            vert[i] = VectorRound(in[i]);
+        }
+        else
+        {
+            vert[i] = in[i];
+        }
+    }
+
+    h = HashVec(vert);
+
+    for (hv = hashverts[h]; hv; hv = hv->next)
+    {
+        if (fabs(hv->point[0] - vert[0]) < POINT_EPSILON
+            && fabs(hv->point[1] - vert[1]) < POINT_EPSILON && fabs(hv->point[2] - vert[2]) < POINT_EPSILON)
+        {
+            hv->numedges++;
+            if (hv->numplanes == 3)
+            {
+                return hv->num;                            // allready known to be a corner
+            }
+            for (i = 0; i < hv->numplanes; i++)
+            {
+                if (hv->planenums[i] == planenum)
+                {
+                    return hv->num;                        // allready know this plane
+                }
+            }
+            if (hv->numplanes != 2)
+            {
+                hv->planenums[hv->numplanes] = planenum;
+            }
+            hv->numplanes++;
+            return hv->num;
+        }
+    }
+
+    hv = hvert_p;
+    hv->numedges = 1;
+    hv->numplanes = 1;
+    hv->planenums[0] = planenum;
+    hv->next = hashverts[h];
+    hashverts[h] = hv;
+    VectorCopy(vert, hv->point);
+    hv->num = g_numvertexes;
+    hlassume(hv->num != MAX_MAP_VERTS, assume_MAX_MAP_VERTS);
+    hvert_p++;
+
+    // emit a vertex
+    hlassume(g_numvertexes < MAX_MAP_VERTS, assume_MAX_MAP_VERTS);
+
+    g_dvertexes[g_numvertexes].point[0] = vert[0];
+    g_dvertexes[g_numvertexes].point[1] = vert[1];
+    g_dvertexes[g_numvertexes].point[2] = vert[2];
+    g_numvertexes++;
+
+    return hv->num;
+}
+
+//===========================================================================
+
+// =====================================================================================
+//  GetEdge
+//      Don't allow four way edges
+// =====================================================================================
+int             GetEdge(const vec3_t p1, const vec3_t p2, face_t* f)
+{
+    int             v1;
+    int             v2;
+    dedge_t*        edge;
+    int             i;
+
+    hlassert(f->contents);
+
+    v1 = GetVertex(p1, f->planenum);
+    v2 = GetVertex(p2, f->planenum);
+    for (i = firstmodeledge; i < g_numedges; i++)
+    {
+        edge = &g_dedges[i];
+        if (v1 == edge->v[1] && v2 == edge->v[0] && !edgefaces[i][1] && edgefaces[i][0]->contents == f->contents)
+        {
+            edgefaces[i][1] = f;
+            return -i;
+        }
+    }
+
+    // emit an edge
+    hlassume(g_numedges < MAX_MAP_EDGES, assume_MAX_MAP_EDGES);
+    edge = &g_dedges[g_numedges];
+    g_numedges++;
+    edge->v[0] = v1;
+    edge->v[1] = v2;
+    edgefaces[i][0] = f;
+
+    return i;
+}
+
+// =====================================================================================
+//  MakeFaceEdges
+// =====================================================================================
+void            MakeFaceEdges()
+{
+    InitHash();
+    firstmodeledge = g_numedges;
+    firstmodelface = g_numfaces;
+}

+ 558 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/tjunc.cpp

@@ -0,0 +1,558 @@
+#include "bsp5.h"
+
+typedef struct wvert_s
+{
+    vec_t           t;
+    struct wvert_s* prev;
+    struct wvert_s* next;
+}
+wvert_t;
+
+typedef struct wedge_s
+{
+    struct wedge_s* next;
+    vec3_t          dir;
+    vec3_t          origin;
+    wvert_t         head;
+}
+wedge_t;
+
+static int      numwedges;
+static int      numwverts;
+static int      tjuncs;
+static int      tjuncfaces;
+
+#define MAX_WVERTS   0x40000
+#define MAX_WEDGES   0x20000
+
+static wvert_t  wverts[MAX_WVERTS];
+static wedge_t  wedges[MAX_WEDGES];
+
+//============================================================================
+
+#define	NUM_HASH	1024
+
+wedge_t*        wedge_hash[NUM_HASH];
+
+static vec3_t   hash_min;
+static vec3_t   hash_scale;
+
+static void     InitHash(const vec3_t mins, const vec3_t maxs)
+{
+    vec3_t          size;
+    vec_t           volume;
+    vec_t           scale;
+    int             newsize[2];
+
+    VectorCopy(mins, hash_min);
+    VectorSubtract(maxs, mins, size);
+    memset(wedge_hash, 0, sizeof(wedge_hash));
+
+    volume = size[0] * size[1];
+
+    scale = sqrt(volume / NUM_HASH);
+
+    newsize[0] = size[0] / scale;
+    newsize[1] = size[1] / scale;
+
+    hash_scale[0] = newsize[0] / size[0];
+    hash_scale[1] = newsize[1] / size[1];
+    hash_scale[2] = newsize[1];
+}
+
+static unsigned HashVec(const vec3_t vec)
+{
+    unsigned        h;
+
+    h = hash_scale[0] * (vec[0] - hash_min[0]) * hash_scale[2] + hash_scale[1] * (vec[1] - hash_min[1]);
+    if (h >= NUM_HASH)
+    {
+        return NUM_HASH - 1;
+    }
+    return h;
+}
+
+//============================================================================
+
+static bool     CanonicalVector(vec3_t vec)
+{
+    if (VectorNormalize(vec))
+    {
+        if (vec[0] > NORMAL_EPSILON )
+        {
+            return true;
+        }
+        else if (vec[0] < -NORMAL_EPSILON )
+        {
+            VectorSubtract(vec3_origin, vec, vec);
+            return true;
+        }
+        else
+        {
+            vec[0] = 0;
+        }
+    
+        if (vec[1] > NORMAL_EPSILON )
+        {
+            return true;
+        }
+        else if (vec[1] < -NORMAL_EPSILON )
+        {
+            VectorSubtract(vec3_origin, vec, vec);
+            return true;
+        }
+        else
+        {
+            vec[1] = 0;
+        }
+
+        if (vec[2] > NORMAL_EPSILON )
+        {
+            return true;
+        }
+        else if (vec[2] < -NORMAL_EPSILON )
+        {
+            VectorSubtract(vec3_origin, vec, vec);
+            return true;
+        }
+        else
+        {
+            vec[2] = 0;
+        }
+//        hlassert(false);
+        return false;
+    }
+//    hlassert(false);
+    return false;
+}
+
+static wedge_t *FindEdge(const vec3_t p1, const vec3_t p2, vec_t* t1, vec_t* t2)
+{
+    vec3_t          origin;
+    vec3_t          dir;
+    wedge_t*        w;
+    vec_t           temp;
+    int             h;
+
+    VectorSubtract(p2, p1, dir);
+    if (!CanonicalVector(dir))
+    {
+#if _DEBUG
+        Warning("CanonicalVector: degenerate @ (%4.3f %4.3f %4.3f )\n", p1[0], p1[1], p1[2]);
+#endif
+    }
+
+    *t1 = DotProduct(p1, dir);
+    *t2 = DotProduct(p2, dir);
+
+    VectorMA(p1, -*t1, dir, origin);
+
+    if (*t1 > *t2)
+    {
+        temp = *t1;
+        *t1 = *t2;
+        *t2 = temp;
+    }
+
+    h = HashVec(origin);
+
+    for (w = wedge_hash[h]; w; w = w->next)
+    {
+        temp = w->origin[0] - origin[0];
+        if (temp < -EQUAL_EPSILON || temp > EQUAL_EPSILON)
+        {
+            continue;
+        }
+        temp = w->origin[1] - origin[1];
+        if (temp < -EQUAL_EPSILON || temp > EQUAL_EPSILON)
+        {
+            continue;
+        }
+        temp = w->origin[2] - origin[2];
+        if (temp < -EQUAL_EPSILON || temp > EQUAL_EPSILON)
+        {
+            continue;
+        }
+
+        temp = w->dir[0] - dir[0];
+        if (temp < -EQUAL_EPSILON || temp > EQUAL_EPSILON)
+        {
+            continue;
+        }
+        temp = w->dir[1] - dir[1];
+        if (temp < -EQUAL_EPSILON || temp > EQUAL_EPSILON)
+        {
+            continue;
+        }
+        temp = w->dir[2] - dir[2];
+        if (temp < -EQUAL_EPSILON || temp > EQUAL_EPSILON)
+        {
+            continue;
+        }
+
+        return w;
+    }
+
+    hlassume(numwedges < MAX_WEDGES, assume_MAX_WEDGES);
+    w = &wedges[numwedges];
+    numwedges++;
+
+    w->next = wedge_hash[h];
+    wedge_hash[h] = w;
+
+    VectorCopy(origin, w->origin);
+    VectorCopy(dir, w->dir);
+    w->head.next = w->head.prev = &w->head;
+    w->head.t = 99999;
+    return w;
+}
+
+/*
+ * ===============
+ * AddVert
+ * 
+ * ===============
+ */
+#define T_EPSILON	ON_EPSILON
+
+static void     AddVert(const wedge_t* const w, const vec_t t)
+{
+    wvert_t*        v;
+    wvert_t*        newv;
+
+    v = w->head.next;
+    do
+    {
+        if (fabs(v->t - t) < T_EPSILON)
+        {
+            return;
+        }
+        if (v->t > t)
+        {
+            break;
+        }
+        v = v->next;
+    }
+    while (1);
+
+    // insert a new wvert before v
+    hlassume(numwverts < MAX_WVERTS, assume_MAX_WVERTS);
+
+    newv = &wverts[numwverts];
+    numwverts++;
+
+    newv->t = t;
+    newv->next = v;
+    newv->prev = v->prev;
+    v->prev->next = newv;
+    v->prev = newv;
+}
+
+/*
+ * ===============
+ * AddEdge
+ * ===============
+ */
+static void     AddEdge(const vec3_t p1, const vec3_t p2)
+{
+    wedge_t*        w;
+    vec_t           t1;
+    vec_t           t2;
+
+    w = FindEdge(p1, p2, &t1, &t2);
+    AddVert(w, t1);
+    AddVert(w, t2);
+}
+
+/*
+ * ===============
+ * AddFaceEdges
+ * 
+ * ===============
+ */
+static void     AddFaceEdges(const face_t* const f)
+{
+    int             i, j;
+
+    for (i = 0; i < f->numpoints; i++)
+    {
+        j = (i + 1) % f->numpoints;
+        AddEdge(f->pts[i], f->pts[j]);
+    }
+}
+
+//============================================================================
+
+static byte     superfacebuf[1024 * 16];
+static face_t*  superface = (face_t*)superfacebuf;
+static int      MAX_SUPERFACEEDGES = (sizeof(superfacebuf) - sizeof(face_t) + sizeof(superface->pts)) / sizeof(vec3_t);
+static face_t*  newlist;
+
+static void     SplitFaceForTjunc(face_t* f, face_t* original)
+{
+    int             i;
+    face_t*         newface;
+    face_t*         chain;
+    vec3_t          dir, test;
+    vec_t           v;
+    int             firstcorner, lastcorner;
+
+#ifdef _DEBUG
+    static int      counter = 0;
+
+    Log("SplitFaceForTjunc %d\n", counter++);
+#endif
+
+    chain = NULL;
+    do
+    {
+        hlassume(f->original == NULL, assume_ValidPointer);     // "SplitFaceForTjunc: f->original"
+
+        if (f->numpoints <= MAXPOINTS)
+        {                                                  // the face is now small enough without more cutting
+            // so copy it back to the original
+            *original = *f;
+            original->original = chain;
+            original->next = newlist;
+            newlist = original;
+            return;
+        }
+
+        tjuncfaces++;
+
+restart:
+        // find the last corner 
+        VectorSubtract(f->pts[f->numpoints - 1], f->pts[0], dir);
+        VectorNormalize(dir);
+        for (lastcorner = f->numpoints - 1; lastcorner > 0; lastcorner--)
+        {
+            VectorSubtract(f->pts[lastcorner - 1], f->pts[lastcorner], test);
+            VectorNormalize(test);
+            v = DotProduct(test, dir);
+            if (v < 1.0 - ON_EPSILON || v > 1.0 + ON_EPSILON)
+            {
+                break;
+            }
+        }
+
+        // find the first corner        
+        VectorSubtract(f->pts[1], f->pts[0], dir);
+        VectorNormalize(dir);
+        for (firstcorner = 1; firstcorner < f->numpoints - 1; firstcorner++)
+        {
+            VectorSubtract(f->pts[firstcorner + 1], f->pts[firstcorner], test);
+            VectorNormalize(test);
+            v = DotProduct(test, dir);
+            if (v < 1.0 - ON_EPSILON || v > 1.0 + ON_EPSILON)
+            {
+                break;
+            }
+        }
+
+        if (firstcorner + 2 >= MAXPOINTS)
+        {
+            // rotate the point winding
+            VectorCopy(f->pts[0], test);
+            for (i = 1; i < f->numpoints; i++)
+            {
+                VectorCopy(f->pts[i], f->pts[i - 1]);
+            }
+            VectorCopy(test, f->pts[f->numpoints - 1]);
+            goto restart;
+        }
+
+        // cut off as big a piece as possible, less than MAXPOINTS, and not
+        // past lastcorner
+
+        newface = NewFaceFromFace(f);
+
+        hlassume(f->original == NULL, assume_ValidPointer);     // "SplitFaceForTjunc: f->original"
+
+        newface->original = chain;
+        chain = newface;
+        newface->next = newlist;
+        newlist = newface;
+        if (f->numpoints - firstcorner <= MAXPOINTS)
+        {
+            newface->numpoints = firstcorner + 2;
+        }
+        else if (lastcorner + 2 < MAXPOINTS && f->numpoints - lastcorner <= MAXPOINTS)
+        {
+            newface->numpoints = lastcorner + 2;
+        }
+        else
+        {
+            newface->numpoints = MAXPOINTS;
+        }
+
+        for (i = 0; i < newface->numpoints; i++)
+        {
+            VectorCopy(f->pts[i], newface->pts[i]);
+        }
+
+        for (i = newface->numpoints - 1; i < f->numpoints; i++)
+        {
+            VectorCopy(f->pts[i], f->pts[i - (newface->numpoints - 2)]);
+        }
+        f->numpoints -= (newface->numpoints - 2);
+    }
+    while (1);
+
+}
+
+/*
+ * ===============
+ * FixFaceEdges
+ * 
+ * ===============
+ */
+static void     FixFaceEdges(face_t* f)
+{
+    int             i;
+    int             j;
+    int             k;
+    wedge_t*        w;
+    wvert_t*        v;
+    vec_t           t1;
+    vec_t           t2;
+
+    *superface = *f;
+
+restart:
+    for (i = 0; i < superface->numpoints; i++)
+    {
+        j = (i + 1) % superface->numpoints;
+
+        w = FindEdge(superface->pts[i], superface->pts[j], &t1, &t2);
+
+        for (v = w->head.next; v->t < t1 + T_EPSILON; v = v->next)
+        {
+        }
+
+        if (v->t < t2 - T_EPSILON)
+        {
+            tjuncs++;
+            // insert a new vertex here
+            for (k = superface->numpoints; k > j; k--)
+            {
+                VectorCopy(superface->pts[k - 1], superface->pts[k]);
+            }
+            VectorMA(w->origin, v->t, w->dir, superface->pts[j]);
+            superface->numpoints++;
+            hlassume(superface->numpoints < MAX_SUPERFACEEDGES, assume_MAX_SUPERFACEEDGES);
+            goto restart;
+        }
+    }
+
+    if (superface->numpoints <= MAXPOINTS)
+    {
+        *f = *superface;
+        f->next = newlist;
+        newlist = f;
+        return;
+    }
+
+    // the face needs to be split into multiple faces because of too many edges
+
+    SplitFaceForTjunc(superface, f);
+
+}
+
+//============================================================================
+
+static void     tjunc_find_r(node_t* node)
+{
+    face_t*         f;
+
+    if (node->planenum == PLANENUM_LEAF)
+    {
+        return;
+    }
+
+    for (f = node->faces; f; f = f->next)
+    {
+        AddFaceEdges(f);
+    }
+
+    tjunc_find_r(node->children[0]);
+    tjunc_find_r(node->children[1]);
+}
+
+static void     tjunc_fix_r(node_t* node)
+{
+    face_t*         f;
+    face_t*         next;
+
+    if (node->planenum == PLANENUM_LEAF)
+    {
+        return;
+    }
+
+    newlist = NULL;
+
+    for (f = node->faces; f; f = next)
+    {
+        next = f->next;
+        FixFaceEdges(f);
+    }
+
+    node->faces = newlist;
+
+    tjunc_fix_r(node->children[0]);
+    tjunc_fix_r(node->children[1]);
+}
+
+/*
+ * ===========
+ * tjunc
+ * 
+ * ===========
+ */
+void            tjunc(node_t* headnode)
+{
+    vec3_t          maxs, mins;
+    int             i;
+
+    Verbose("---- tjunc ----\n");
+
+    if (g_notjunc)
+    {
+        return;
+    }
+
+    //
+    // identify all points on common edges
+    //
+
+    // origin points won't allways be inside the map, so extend the hash area 
+    for (i = 0; i < 3; i++)
+    {
+        if (fabs(headnode->maxs[i]) > fabs(headnode->mins[i]))
+        {
+            maxs[i] = fabs(headnode->maxs[i]);
+        }
+        else
+        {
+            maxs[i] = fabs(headnode->mins[i]);
+        }
+    }
+    VectorSubtract(vec3_origin, maxs, mins);
+
+    InitHash(mins, maxs);
+
+    numwedges = numwverts = 0;
+
+    tjunc_find_r(headnode);
+
+    Verbose("%i world edges  %i edge points\n", numwedges, numwverts);
+
+    //
+    // add extra vertexes on edges where needed
+    //
+    tjuncs = tjuncfaces = 0;
+
+    tjunc_fix_r(headnode);
+
+    Verbose("%i edges added by tjunctions\n", tjuncs);
+    Verbose("%i faces added by tjunctions\n", tjuncfaces);
+}

+ 351 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlbsp/writebsp.cpp

@@ -0,0 +1,351 @@
+#include "bsp5.h"
+
+//  WriteClipNodes_r
+//  WriteClipNodes
+//  WriteDrawLeaf
+//  WriteFace
+//  WriteDrawNodes_r
+//  FreeDrawNodes_r
+//  WriteDrawNodes
+//  BeginBSPFile
+//  FinishBSPFile
+
+#include <map>
+
+typedef std::map<int,int> PlaneMap;
+static PlaneMap gPlaneMap;
+static int gNumMappedPlanes;
+static dplane_t gMappedPlanes[MAX_MAP_PLANES];
+extern bool g_noopt;
+
+// =====================================================================================
+//  WritePlane
+//  hook for plane optimization
+// =====================================================================================
+static int WritePlane(int planenum)
+{
+	planenum = planenum & (~1);
+
+	if(g_noopt)
+	{
+		return planenum;
+	}
+
+	PlaneMap::iterator item = gPlaneMap.find(planenum);
+	if(item != gPlaneMap.end())
+	{
+		return item->second;
+	}
+	//add plane to BSP
+	hlassume(gNumMappedPlanes < MAX_MAP_PLANES, assume_MAX_MAP_PLANES);
+	gMappedPlanes[gNumMappedPlanes] = g_dplanes[planenum];
+	gPlaneMap.insert(PlaneMap::value_type(planenum,gNumMappedPlanes));
+
+	return gNumMappedPlanes++;
+}
+
+// =====================================================================================
+//  WriteClipNodes_r
+// =====================================================================================
+static int      WriteClipNodes_r(node_t* node)
+{
+    int             i, c;
+    dclipnode_t*    cn;
+    int             num;
+
+    if (node->planenum == -1)
+    {
+        num = node->contents;
+        free(node->markfaces);
+        free(node);
+        return num;
+    }
+
+	hlassume(g_numclipnodes < MAX_MAP_CLIPNODES, assume_MAX_MAP_CLIPNODES);
+
+	// emit a clipnode
+    c = g_numclipnodes;
+    cn = &g_dclipnodes[g_numclipnodes];
+    g_numclipnodes++;
+    if (node->planenum & 1)
+    {
+        Error("WriteClipNodes_r: odd planenum");
+    }
+    
+#ifdef ZHLT_PLANETYPE_FIX //debug
+	{
+		dplane_t *plane = &g_dplanes[node->planenum];
+		if (plane->normal[(plane->type)%3] < 0)
+			if (plane->type < 3)
+				Warning ("WriteClipNodes_r: negative plane");
+			else
+				Developer (DEVELOPER_LEVEL_MESSAGE, "Warning: WriteClipNodes_r: negative plane\n");
+	}
+#endif
+    
+    cn->planenum = WritePlane(node->planenum);
+    for (i = 0; i < 2; i++)
+    {
+        cn->children[i] = WriteClipNodes_r(node->children[i]);
+    }
+
+    free(node);
+    return c;
+}
+
+// =====================================================================================
+//  WriteClipNodes
+//      Called after the clipping hull is completed.  Generates a disk format
+//      representation and frees the original memory.
+// =====================================================================================
+void            WriteClipNodes(node_t* nodes)
+{
+    WriteClipNodes_r(nodes);
+}
+
+// =====================================================================================
+//  WriteDrawLeaf
+// =====================================================================================
+static void     WriteDrawLeaf(const node_t* const node)
+{
+    face_t**        fp;
+    face_t*         f;
+    dleaf_t*        leaf_p;
+
+    // emit a leaf
+    leaf_p = &g_dleafs[g_numleafs];
+    g_numleafs++;
+
+    leaf_p->contents = node->contents;
+
+    //
+    // write bounding box info
+    //
+    VectorCopy(node->mins, leaf_p->mins);
+    VectorCopy(node->maxs, leaf_p->maxs);
+
+    leaf_p->visofs = -1;                                   // no vis info yet
+
+    //
+    // write the marksurfaces
+    //
+    leaf_p->firstmarksurface = g_nummarksurfaces;
+
+    hlassume(node->markfaces != NULL, assume_EmptySolid);
+
+    for (fp = node->markfaces; *fp; fp++)
+    {
+        // emit a marksurface
+        f = *fp;
+        do
+        {
+            g_dmarksurfaces[g_nummarksurfaces] = f->outputnumber;
+            hlassume(g_nummarksurfaces < MAX_MAP_MARKSURFACES, assume_MAX_MAP_MARKSURFACES);
+            g_nummarksurfaces++;
+            f = f->original;                               // grab tjunction split faces
+        }
+        while (f);
+    }
+    free(node->markfaces);
+
+    leaf_p->nummarksurfaces = g_nummarksurfaces - leaf_p->firstmarksurface;
+}
+
+// =====================================================================================
+//  WriteFace
+// =====================================================================================
+static void     WriteFace(face_t* f)
+{
+    dface_t*        df;
+    int             i;
+    int             e;
+
+    if (    CheckFaceForHint(f)
+        ||  CheckFaceForSkip(f)
+#ifdef ZHLT_NULLTEX
+        ||  CheckFaceForNull(f)  // AJM
+#endif
+
+// =====================================================================================
+//Cpt_Andrew - Env_Sky Check
+// =====================================================================================
+       ||  CheckFaceForEnv_Sky(f)
+// =====================================================================================
+
+       )
+    {
+        return;
+    }
+
+    f->outputnumber = g_numfaces;
+
+    df = &g_dfaces[g_numfaces];
+    hlassume(g_numfaces < MAX_MAP_FACES, assume_MAX_MAP_FACES);
+    g_numfaces++;
+
+	df->planenum = WritePlane(f->planenum);
+	df->side = f->planenum & 1;
+    df->firstedge = g_numsurfedges;
+    df->numedges = f->numpoints;
+    df->texinfo = f->texturenum;
+    for (i = 0; i < f->numpoints; i++)
+    {
+        e = GetEdge(f->pts[i], f->pts[(i + 1) % f->numpoints], f);
+        hlassume(g_numsurfedges < MAX_MAP_SURFEDGES, assume_MAX_MAP_SURFEDGES);
+        g_dsurfedges[g_numsurfedges] = e;
+        g_numsurfedges++;
+    }
+}
+
+// =====================================================================================
+//  WriteDrawNodes_r
+// =====================================================================================
+static void     WriteDrawNodes_r(const node_t* const node)
+{
+    dnode_t*        n;
+    int             i;
+    face_t*         f;
+
+    // emit a node
+    hlassume(g_numnodes < MAX_MAP_NODES, assume_MAX_MAP_NODES);
+    n = &g_dnodes[g_numnodes];
+    g_numnodes++;
+
+    VectorCopy(node->mins, n->mins);
+    VectorCopy(node->maxs, n->maxs);
+
+    if (node->planenum & 1)
+    {
+        Error("WriteDrawNodes_r: odd planenum");
+    }
+    n->planenum = WritePlane(node->planenum);
+    n->firstface = g_numfaces;
+
+    for (f = node->faces; f; f = f->next)
+    {
+        WriteFace(f);
+    }
+
+    n->numfaces = g_numfaces - n->firstface;
+
+    //
+    // recursively output the other nodes
+    //
+    for (i = 0; i < 2; i++)
+    {
+        if (node->children[i]->planenum == -1)
+        {
+            if (node->children[i]->contents == CONTENTS_SOLID)
+            {
+                n->children[i] = -1;
+            }
+            else
+            {
+                n->children[i] = -(g_numleafs + 1);
+                WriteDrawLeaf(node->children[i]);
+            }
+        }
+        else
+        {
+            n->children[i] = g_numnodes;
+            WriteDrawNodes_r(node->children[i]);
+        }
+    }
+}
+
+// =====================================================================================
+//  FreeDrawNodes_r
+// =====================================================================================
+static void     FreeDrawNodes_r(node_t* node)
+{
+    int             i;
+    face_t*         f;
+    face_t*         next;
+
+    for (i = 0; i < 2; i++)
+    {
+        if (node->children[i]->planenum != -1)
+        {
+            FreeDrawNodes_r(node->children[i]);
+        }
+    }
+
+    //
+    // free the faces on the node
+    //
+    for (f = node->faces; f; f = next)
+    {
+        next = f->next;
+        FreeFace(f);
+    }
+
+    free(node);
+}
+
+// =====================================================================================
+//  WriteDrawNodes
+//      Called after a drawing hull is completed
+//      Frees all nodes and faces
+// =====================================================================================
+void            WriteDrawNodes(node_t* headnode)
+{
+    if (headnode->contents < 0)
+    {
+        WriteDrawLeaf(headnode);
+    }
+    else
+    {
+        WriteDrawNodes_r(headnode);
+        FreeDrawNodes_r(headnode);
+    }
+}
+
+
+// =====================================================================================
+//  BeginBSPFile
+// =====================================================================================
+void            BeginBSPFile()
+{
+    // these values may actually be initialized
+    // if the file existed when loaded, so clear them explicitly
+	gNumMappedPlanes = 0;
+	gPlaneMap.clear();
+    g_nummodels = 0;
+    g_numfaces = 0;
+    g_numnodes = 0;
+    g_numclipnodes = 0;
+    g_numvertexes = 0;
+    g_nummarksurfaces = 0;
+    g_numsurfedges = 0;
+
+    // edge 0 is not used, because 0 can't be negated
+    g_numedges = 1;
+
+    // leaf 0 is common solid with no faces
+    g_numleafs = 1;
+    g_dleafs[0].contents = CONTENTS_SOLID;
+}
+
+// =====================================================================================
+//  FinishBSPFile
+// =====================================================================================
+void            FinishBSPFile()
+{
+    Verbose("--- FinishBSPFile ---\n");
+
+	if(!g_noopt)
+	{
+		for(int counter = 0; counter < gNumMappedPlanes; counter++)
+		{
+			g_dplanes[counter] = gMappedPlanes[counter];
+		}
+		g_numplanes = gNumMappedPlanes;
+	}
+
+	if (g_chart)
+    {
+        PrintBSPFileSizes();
+    }
+
+    WriteBSPFile(g_bspfilename);
+}

+ 458 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/autowad.cpp

@@ -0,0 +1,458 @@
+// AJM: Added this file in
+#include "csg.h"
+#include "cmdlib.h"
+
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4996)
+#endif
+
+#ifdef HLCSG_AUTOWAD
+
+#define MAX_AUTOWAD_TEXNAME 32  // 32 char limit in array size in brush_texture_t struct
+
+int g_numUsedTextures = 0;
+
+typedef struct autowad_texname_s         // non-dupicate list of textures used in map
+{
+    char        name[MAX_AUTOWAD_TEXNAME];
+    autowad_texname_s*  next;
+} autowad_texname_t;
+
+autowad_texname_t* g_autowad_texname;
+
+// =====================================================================================
+//  Extract File stuff (ExtractFile | ExtractFilePath | ExtractFileBase)
+//
+// With VS 2005 - and the 64 bit build, i had to pull 3 classes over from
+// cmdlib.cpp even with the proper includes to get rid of the lnk2001 error
+//
+// amckern - [email protected]
+// =====================================================================================
+
+#define PATHSEPARATOR(c) ((c) == '\\' || (c) == '/')
+
+void            ExtractFileBase(const char* const path, char* dest)
+{
+    hlassert (path != dest);
+
+    const char*           src;
+
+    src = path + strlen(path) - 1;
+
+    //
+    // back up until a \ or the start
+    //
+    while (src != path && !PATHSEPARATOR(*(src - 1)))
+        src--;
+
+    while (*src && *src != '.')
+    {
+        *dest++ = *src++;
+    }
+    *dest = 0;
+}
+
+void            ExtractFilePath(const char* const path, char* dest)
+{
+    hlassert (path != dest);
+
+    const char*           src;
+
+    src = path + strlen(path) - 1;
+
+    //
+    // back up until a \ or the start
+    //
+    while (src != path && !PATHSEPARATOR(*(src - 1)))
+        src--;
+
+    memcpy(dest, path, src - path);
+    dest[src - path] = 0;
+}
+
+void            ExtractFile(const char* const path, char* dest)
+{
+    hlassert (path != dest);
+
+    const char*           src;
+
+    src = path + strlen(path) - 1;
+
+    while (src != path && !PATHSEPARATOR(*(src - 1)))
+        src--;
+
+    while (*src)
+    {
+        *dest++ = *src++;
+    }
+    *dest = 0;
+}
+
+// =====================================================================================
+//  autowad_PushName
+//      adds passed texname as an entry to autowad_wadnames list, without duplicates
+// =====================================================================================
+void        autowad_PushName(const char* const texname)
+{
+    autowad_texname_t*  tex;
+
+    if (!g_autowad_texname)
+    {
+        // first texture, make an entry
+        tex = (autowad_texname_t*)malloc(sizeof(autowad_texname_t));
+        tex->next = NULL;
+        strcpy_s(tex->name, texname);
+
+        g_autowad_texname = tex;
+        g_numUsedTextures++;
+
+#ifdef _DEBUG
+        Log("[dbg] Used texture: %i[%s]\n", g_numUsedTextures, texname);
+#endif
+        return;
+    }
+    
+    // otherwise, see if texname isnt already in the list
+    for (tex = g_autowad_texname; ;tex = tex->next)
+    {
+        if (!strcmp(tex->name, texname))
+            return; // dont bother adding it again
+
+        if (!tex->next)
+            break;  // end of list
+    }
+
+    // unique texname
+    g_numUsedTextures++;
+    autowad_texname_t*  last;
+    last = tex;
+    tex = (autowad_texname_t*)malloc(sizeof(autowad_texname_t));
+    strcpy_s(tex->name, texname);
+    tex->next = NULL;
+    last->next = tex;
+
+#ifdef _DEBUG
+    Log("[dbg] Used texture: %i[%s]\n", g_numUsedTextures, texname);
+#endif
+}
+
+// =====================================================================================
+//  autowad_PurgeName
+// =====================================================================================
+void        autowad_PurgeName(const char* const texname)
+{
+    autowad_texname_t*  prev;
+    autowad_texname_t*  current;
+
+    if (!g_autowad_texname)
+        return;
+
+    current = g_autowad_texname;
+    prev = NULL;
+    for (; ;)
+    {
+        if (!strcmp(current->name, texname))
+        {
+            if (!prev)      // start of the list
+            {   
+                g_autowad_texname = current->next;
+            }
+            else            // middle of list
+            {
+                prev->next = current->next;
+            }
+
+            free(current);
+            return;
+        }
+
+        if (!current->next)
+        {
+            //Log(" AUTOWAD: Purge Tex: texname '%s' does not exist\n", texname);
+            return; // end of list
+        }
+
+        // move along
+        prev = current;
+        current = current->next;
+    }
+}
+
+// =====================================================================================
+//  autowad_PopName
+//      removes a name from the autowad list, puts it in memory and retuns pointer (which 
+//      shoudl be destructed by the calling function later)
+// =====================================================================================
+char*      autowad_PopName()
+{
+    // todo: code
+    return NULL;
+}
+
+// =====================================================================================
+//  autowad_cleanup
+//      frees memory used by autowad procedure
+// =====================================================================================
+void        autowad_cleanup()
+{
+    if (g_autowad_texname != NULL)
+    {
+        autowad_texname_t*  current;
+        autowad_texname_t*  next;
+
+        for (current = g_autowad_texname; ; current = next)
+        {
+            if (!current)
+                break;
+
+            //Log("[aw] removing tex %s\n", current->name);
+            next = current->next;
+            free(current);
+        }
+    }
+}
+
+// =====================================================================================
+//  autowad_IsUsedTexture
+//      is this texture in the autowad list?
+// =====================================================================================
+bool        autowad_IsUsedTexture(const char* const texname)
+{
+    autowad_texname_t*  current;
+
+    if (!g_autowad_texname)
+        return false;  
+
+    for (current = g_autowad_texname; ; current = current->next)
+    {
+        //Log("atw: IUT: Comparing: '%s' with '%s'\n", current->name, texname);
+        if (!strcmp(current->name, texname))
+            return true;
+
+        if (!current->next)
+            return false; // reached end of list
+    }
+
+    return false;
+}
+
+// =====================================================================================
+//  GetUsedTextures
+// =====================================================================================
+void        GetUsedTextures()
+{
+    int             i;
+    side_t*         bs;
+
+    for (i = 0; i < g_numbrushsides; i++)
+    {
+        bs = &g_brushsides[i];
+        autowad_PushName(bs->td.name);
+    }
+}
+
+// =====================================================================================
+//  autowad_UpdateUsedWads
+// =====================================================================================
+
+// yes, these should be in a header/common lib, but i cant be bothered
+
+#define MAXWADNAME 16
+
+typedef struct
+{
+    char            identification[4];                     // should be WAD2/WAD3
+    int             numlumps;
+    int             infotableofs;
+} wadinfo_t;
+
+typedef struct
+{
+    int             filepos;
+    int             disksize;
+    int             size;                                  // uncompressed
+    char            type;
+    char            compression;
+    char            pad1, pad2;
+    char            name[MAXWADNAME];                      // must be null terminated
+
+    int             iTexFile;                              // index of the wad this texture is located in
+
+} lumpinfo_t;
+
+static void     CleanupName(const char* const in, char* out)
+{
+    int             i;
+
+    for (i = 0; i < MAXWADNAME; i++)
+    {
+        if (!in[i])
+        {
+            break;
+        }
+
+        out[i] = toupper(in[i]);
+    }
+
+    for (; i < MAXWADNAME; i++)
+    {
+        out[i] = 0;
+    }
+}
+
+void        autowad_UpdateUsedWads()
+{
+    // see which wadfiles are needed
+    // code for this wad loop somewhat copied from below
+    wadinfo_t       thiswad;
+    lumpinfo_t*     thislump = NULL;
+    wadpath_t*      currentwad;
+    char*           pszWadFile;
+    FILE*           texfile;
+    const char*     pszWadroot = getenv("WADROOT");
+    int             i, j;
+    int             nTexLumps = 0;
+
+#ifdef _DEBUG
+    Log("[dbg] Starting wad dependency check\n");
+#endif
+
+    // open each wadpath and sort though its contents
+    for (i = 0; i < g_iNumWadPaths; i++)
+    {
+        currentwad = g_pWadPaths[i];
+        pszWadFile = currentwad->path;
+        currentwad->usedbymap = false;  // guilty until proven innocent
+
+#ifdef _DEBUG
+        Log(" Parsing wad: '%s'\n", pszWadFile);
+#endif
+
+        texfile = fopen(pszWadFile, "rb");
+
+        #ifdef SYSTEM_WIN32
+        if (!texfile)
+        {
+            // cant find it, maybe this wad file has a hard code drive
+            if (pszWadFile[1] == ':')
+            {
+                pszWadFile += 2;                           // skip past the drive
+                texfile = fopen(pszWadFile, "rb");
+            }
+        }
+        #endif
+
+        char            szTmp[_MAX_PATH];
+        if (!texfile && pszWadroot)
+        {
+            char            szFile[_MAX_PATH];
+            char            szSubdir[_MAX_PATH];
+
+            ExtractFile(pszWadFile, szFile);
+        
+            ExtractFilePath(pszWadFile, szTmp);
+            ExtractFile(szTmp, szSubdir);
+
+            // szSubdir will have a trailing separator
+            safe_snprintf(szTmp, _MAX_PATH, "%s" SYSTEM_SLASH_STR "%s%s", pszWadroot, szSubdir, szFile);
+            texfile = fopen(szTmp, "rb");
+        
+            #ifdef SYSTEM_POSIX
+            if (!texfile)
+            {
+                // cant find it, Convert to lower case and try again
+                strlwr(szTmp);
+                texfile = fopen(szTmp, "rb");
+            }
+            #endif
+        }
+
+        if (!texfile) // still cant find it, skip this one
+		{
+			if(pszWadroot)
+			{
+				Warning("Wad file '%s' not found, also tried '%s'",pszWadFile,szTmp);
+			}
+			else
+			{
+				Warning("Wad file '%s' not found",pszWadFile);
+			}
+            continue;
+		}
+
+        // look and see if we're supposed to include the textures from this WAD in the bsp.
+        {
+            WadInclude_i    it;
+            bool            including = false;
+            for (it = g_WadInclude.begin(); it != g_WadInclude.end(); it++)
+            {
+                if (stristr(pszWadFile, it->c_str()))
+                {
+                    #ifdef _DEBUG
+                    Log("  - including wad\n");
+                    #endif
+                    including = true;
+                    currentwad->usedbymap = true;
+                    break;
+                }
+            }
+            if (including)
+            {
+                //fclose(texfile);
+                //continue;
+            }
+        }
+
+        // read in this wadfiles information
+        SafeRead(texfile, &thiswad, sizeof(thiswad));
+
+        // make sure its a valid format
+        if (strncmp(thiswad.identification, "WAD2", 4) && strncmp(thiswad.identification, "WAD3", 4))
+        {
+            fclose(texfile);
+            continue;
+        }
+
+        thiswad.numlumps        = LittleLong(thiswad.numlumps);
+        thiswad.infotableofs    = LittleLong(thiswad.infotableofs);
+
+        // read in lump
+        if (fseek(texfile, thiswad.infotableofs, SEEK_SET))
+        {
+            fclose(texfile);
+            continue;   // had trouble reading, skip this wad
+        }
+
+        // memalloc for this lump
+        thislump = (lumpinfo_t*)realloc(thislump, (nTexLumps + thiswad.numlumps) * sizeof(lumpinfo_t));
+        // BUGBUG: is this destructed?
+
+        // for each texlump
+        for (j = 0; j < thiswad.numlumps; j++, nTexLumps++)
+        {
+            SafeRead(texfile, &thislump[nTexLumps], (sizeof(lumpinfo_t) - sizeof(int)) );  // iTexFile is NOT read from file
+
+            CleanupName(thislump[nTexLumps].name, thislump[nTexLumps].name);
+        
+            if (autowad_IsUsedTexture(thislump[nTexLumps].name))
+            {
+                currentwad->usedbymap = true;
+                currentwad->usedtextures++;
+                #ifdef _DEBUG
+                Log("    - Used wadfile: [%s]\n", thislump[nTexLumps].name);
+                #endif
+                autowad_PurgeName(thislump[nTexLumps].name);
+            }
+        }
+
+        fclose(texfile);
+    }
+
+#ifdef _DEBUG
+    Log("[dbg] End wad dependency check\n\n");
+#endif
+    return;
+}
+
+
+#endif // HLCSG_AUTOWAD

File diff suppressed because it is too large
+ 1131 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/brush.cpp


+ 361 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/brushunion.cpp

@@ -0,0 +1,361 @@
+#include "csg.h"
+
+vec_t           g_BrushUnionThreshold = DEFAULT_BRUSH_UNION_THRESHOLD;
+
+static Winding* NewWindingFromPlane(const brushhull_t* const hull, const int planenum)
+{
+    Winding*        winding;
+    Winding*        front;
+    Winding*        back;
+    bface_t*        face;
+    plane_t*        plane;
+
+    plane = &g_mapplanes[planenum];
+    winding = new Winding(plane->normal, plane->dist);
+
+    for (face = hull->faces; face; face = face->next)
+    {
+        plane = &g_mapplanes[face->planenum];
+        winding->Clip(plane->normal, plane->dist, &front, &back);
+        delete winding;
+
+        if (front)
+        {
+            delete front;
+        }
+        if (back)
+        {
+            winding = back;
+        }
+        else
+        {
+            Developer(DEVELOPER_LEVEL_ERROR, "NewFaceFromPlane returning NULL");
+            return NULL;
+        }
+    }
+
+    return winding;
+}
+
+static void     AddFaceToList(bface_t** head, bface_t* newface)
+{
+    hlassert(newface);
+    hlassert(newface->w);
+    if (!*head)
+    {
+        *head = newface;
+        return;
+    }
+    else
+    {
+        bface_t*        node = *head;
+
+        while (node->next)
+        {
+            node = node->next;
+        }
+        node->next = newface;
+        newface->next = NULL;
+    }
+}
+
+static int      NumberOfHullFaces(const brushhull_t* const hull)
+{
+    int             x;
+    bface_t*        face;
+
+    if (!hull->faces)
+    {
+        return 0;
+    }
+
+    for (x = 0, face = hull->faces; face; face = face->next, x++)
+    {                                                  // counter
+    }
+
+    return x;
+}
+
+// Returns false if union of brushes is obviously zero
+static void     AddPlaneToUnion(brushhull_t* hull, const int planenum)
+{
+    bool            need_new_face = false;
+
+    bface_t*        new_face_list;
+
+    bface_t*        face;
+    bface_t*        next;
+
+    plane_t*        split;
+    Winding*        front;
+    Winding*        back;
+
+    new_face_list = NULL;
+
+    next = NULL;
+
+    hlassert(hull);
+
+    if (!hull->faces)
+    {
+        return;
+    }
+    hlassert(hull->faces->w);
+
+    for (face = hull->faces; face; face = next)
+    {
+        hlassert(face->w);
+        next = face->next;
+
+        // Duplicate plane, ignore
+        if (face->planenum == planenum)
+        {
+            AddFaceToList(&new_face_list, CopyFace(face));
+            continue;
+        }
+
+        split = &g_mapplanes[planenum];
+        face->w->Clip(split->normal, split->dist, &front, &back);
+
+        if (front)
+        {
+            delete front;
+            need_new_face = true;
+
+            if (back)
+            {                                              // Intersected the face
+                delete face->w;
+                face->w = back;
+                AddFaceToList(&new_face_list, CopyFace(face));
+            }
+        }
+        else
+        {
+            // Completely missed it, back is identical to face->w so it is destroyed
+            if (back)
+            {
+                delete back;
+                AddFaceToList(&new_face_list, CopyFace(face));
+            }
+        }
+        hlassert(face->w);
+    }
+
+    FreeFaceList(hull->faces);
+    hull->faces = new_face_list;
+
+    if (need_new_face && (NumberOfHullFaces(hull) > 2))
+    {
+        Winding*        new_winding = NewWindingFromPlane(hull, planenum);
+
+        if (new_winding)
+        {
+            bface_t*        new_face = (bface_t*)Alloc(sizeof(bface_t));
+
+            new_face->planenum = planenum;
+            new_face->w = new_winding;
+
+            new_face->next = hull->faces;
+            hull->faces = new_face;
+        }
+    }
+}
+
+static vec_t    CalculateSolidVolume(const brushhull_t* const hull)
+{
+    // calculate polyhedron origin
+    // subdivide face winding into triangles
+
+    // for each face
+    // calculate volume of triangle of face to origin
+    // add subidivided volume chunk to total
+
+    int             x = 0;
+    vec_t           volume = 0.0;
+    vec_t           inverse;
+    vec3_t          midpoint = { 0.0, 0.0, 0.0 };
+
+    bface_t*        face;
+
+    for (face = hull->faces; face; face = face->next, x++)
+    {
+        vec3_t          facemid;
+
+        face->w->getCenter(facemid);
+        VectorAdd(midpoint, facemid, midpoint);
+        Developer(DEVELOPER_LEVEL_MESSAGE, "Midpoint for face %d is %f %f %f\n", x, facemid[0], facemid[1], facemid[2]);
+    }
+
+    inverse = 1.0 / x;
+
+    VectorScale(midpoint, inverse, midpoint);
+
+    Developer(DEVELOPER_LEVEL_MESSAGE, "Midpoint for hull is %f %f %f\n", midpoint[0], midpoint[1], midpoint[2]);
+
+    for (face = hull->faces; face; face = face->next, x++)
+    {
+        plane_t*        plane = &g_mapplanes[face->planenum];
+        vec_t           area = face->w->getArea();
+        vec_t           dist = DotProduct(plane->normal, midpoint);
+
+        dist -= plane->dist;
+        dist = fabs(dist);
+
+        volume += area * dist / 3.0;
+    }
+
+    Developer(DEVELOPER_LEVEL_MESSAGE, "Volume for brush is %f\n", volume);
+
+    return volume;
+}
+
+static void     DumpHullWindings(const brushhull_t* const hull)
+{
+    int             x = 0;
+    bface_t*        face;
+
+    for (face = hull->faces; face; face = face->next)
+    {
+        Developer(DEVELOPER_LEVEL_MEGASPAM, "Winding %d\n", x++);
+        face->w->Print();
+        Developer(DEVELOPER_LEVEL_MEGASPAM, "\n");
+    }
+}
+
+static bool     isInvalidHull(const brushhull_t* const hull)
+{
+    int             x = 0;
+    bface_t*        face;
+
+    vec3_t          mins = { 99999.0, 99999.0, 99999.0 };
+    vec3_t          maxs = { -99999.0, -99999.0, -99999.0 };
+
+    for (face = hull->faces; face; face = face->next)
+    {
+        unsigned int    y;
+        Winding*        winding = face->w;
+
+        for (y = 0; y < winding->m_NumPoints; y++)
+        {
+            VectorCompareMinimum(mins, winding->m_Points[y], mins);
+            VectorCompareMaximum(maxs, winding->m_Points[y], maxs);
+        }
+    }
+
+    for (x = 0; x < 3; x++)
+    {
+        if ((mins[x] < (-BOGUS_RANGE / 2)) || (maxs[x] > (BOGUS_RANGE / 2)))
+        {
+            return true;
+        }
+    }
+    return false;
+}
+
+void            CalculateBrushUnions(const int brushnum)
+{
+    int             bn, hull;
+    brush_t*        b1;
+    brush_t*        b2;
+    brushhull_t*    bh1;
+    brushhull_t*    bh2;
+    entity_t*       e;
+
+    b1 = &g_mapbrushes[brushnum];
+    e = &g_entities[b1->entitynum];
+
+    for (hull = 0; hull < 1 /* NUM_HULLS */ ; hull++)
+    {
+        bh1 = &b1->hulls[hull];
+        if (!bh1->faces)                                   // Skip it if it is not in this hull
+        {
+            continue;
+        }
+
+        for (bn = brushnum + 1; bn < e->numbrushes; bn++)
+        {                                                  // Only compare if b2 > b1, tests are communitive
+            b2 = &g_mapbrushes[e->firstbrush + bn];
+            bh2 = &b2->hulls[hull];
+
+            if (!bh2->faces)                               // Skip it if it is not in this hull
+            {
+                continue;
+            }
+            if (b1->contents != b2->contents)
+            {
+                continue;                                  // different contents, ignore
+            }
+
+            Developer(DEVELOPER_LEVEL_SPAM, "Processing hull %d brush %d and brush %d\n", hull, brushnum, bn);
+
+            {
+                brushhull_t     union_hull;
+                bface_t*        face;
+
+                union_hull.bounds = bh1->bounds;
+
+                union_hull.faces = CopyFaceList(bh1->faces);
+
+                for (face = bh2->faces; face; face = face->next)
+                {
+                    AddPlaneToUnion(&union_hull, face->planenum);
+                }
+
+                // union was clipped away (no intersection)
+                if (!union_hull.faces)
+                {
+                    continue;
+                }
+
+                if (g_developer >= DEVELOPER_LEVEL_MESSAGE)
+                {
+                    Log("\nUnion windings\n");
+                    DumpHullWindings(&union_hull);
+
+                    Log("\nBrush %d windings\n", brushnum);
+                    DumpHullWindings(bh1);
+
+                    Log("\nBrush %d windings\n", bn);
+                    DumpHullWindings(bh2);
+                }
+
+
+                {
+                    vec_t           volume_brush_1;
+                    vec_t           volume_brush_2;
+                    vec_t           volume_brush_union;
+                    vec_t           volume_ratio_1;
+                    vec_t           volume_ratio_2;
+
+                    if (isInvalidHull(&union_hull))
+                    {
+                        FreeFaceList(union_hull.faces);
+                        continue;
+                    }
+
+                    volume_brush_union = CalculateSolidVolume(&union_hull);
+                    volume_brush_1 = CalculateSolidVolume(bh1);
+                    volume_brush_2 = CalculateSolidVolume(bh2);
+
+                    volume_ratio_1 = volume_brush_union / volume_brush_1;
+                    volume_ratio_2 = volume_brush_union / volume_brush_2;
+
+                    if ((volume_ratio_1 > g_BrushUnionThreshold) || (g_developer >= DEVELOPER_LEVEL_MESSAGE))
+                    {
+                        volume_ratio_1 *= 100.0;
+                        Warning("Entity %d : Brush %d intersects with brush %d by %2.3f percent", b1->entitynum,
+                                brushnum, bn, volume_ratio_1);
+                    }
+                    if ((volume_ratio_2 > g_BrushUnionThreshold) || (g_developer >= DEVELOPER_LEVEL_MESSAGE))
+                    {
+                        volume_ratio_2 *= 100.0;
+                        Warning("Entity %d : Brush %d intersects with brush %d by %2.3f percent", b1->entitynum, bn,
+                                brushnum, volume_ratio_2);
+                    }
+                }
+
+                FreeFaceList(union_hull.faces);
+            }
+        }
+    }
+}

+ 312 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/csg.h

@@ -0,0 +1,312 @@
+#ifndef HLCSG_H__
+#define HLCSG_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#include <deque>
+#include <string>
+#include <map>
+
+#include "cmdlib.h"
+#include "messages.h"
+#include "win32fix.h"
+#include "log.h"
+#include "hlassert.h"
+#include "mathlib.h"
+#include "scriplib.h"
+#include "winding.h"
+#include "threads.h"
+#include "bspfile.h"
+#include "blockmem.h"
+#include "filelib.h"
+#include "boundingbox.h"
+// AJM: added in
+#include "wadpath.h"
+
+#ifndef DOUBLEVEC_T
+#error you must add -dDOUBLEVEC_T to the project!
+#endif
+
+#define DEFAULT_BRUSH_UNION_THRESHOLD 0.0f
+#define DEFAULT_TINY_THRESHOLD        0.5
+#define DEFAULT_NOCLIP      false
+#define DEFAULT_ONLYENTS    false
+#define DEFAULT_WADTEXTURES true
+#define DEFAULT_SKYCLIP     true
+#define DEFAULT_CHART       false
+#define DEFAULT_INFO        true
+
+#ifdef HLCSG_PRECISIONCLIP // KGP
+#define FLOOR_Z 0.5
+#define DEFAULT_CLIPTYPE clip_legacy
+#endif
+
+#ifdef ZHLT_NULLTEX // AJM
+#define DEFAULT_NULLTEX     true
+#endif
+
+#ifdef HLCSG_CLIPECONOMY // AJM
+#define DEFAULT_CLIPNAZI    true
+#endif
+
+#ifdef HLCSG_AUTOWAD //  AJM
+#define DEFAULT_WADAUTODETECT false
+#endif
+
+#ifdef ZHLT_DETAIL // AJM
+#define DEFAULT_DETAIL      true
+#endif
+
+#ifdef ZHLT_PROGRESSFILE // AJM
+#define DEFAULT_PROGRESSFILE NULL // progress file is only used if g_progressfile is non-null
+#endif
+
+// AJM: added in
+#define UNLESS(a)  if (!(a))
+
+#ifdef SYSTEM_WIN32
+#define DEFAULT_ESTIMATE    false
+#endif
+
+#ifdef SYSTEM_POSIX
+#define DEFAULT_ESTIMATE    true
+#endif
+
+#define BOGUS_RANGE    8192
+
+typedef struct
+{
+    vec3_t          normal;
+    vec3_t          origin;
+    vec_t           dist;
+    planetypes      type;
+} plane_t;
+
+
+
+typedef struct
+{
+    vec3_t          UAxis;
+    vec3_t          VAxis;
+    vec_t           shift[2];
+    vec_t           rotate;
+    vec_t           scale[2];
+} valve_vects;
+
+typedef struct
+{
+    float           vects[2][4];
+} quark_vects;
+
+typedef union
+{
+    valve_vects     valve;
+    quark_vects     quark;
+}
+vects_union;
+
+extern int      g_nMapFileVersion;                         // map file version * 100 (ie 201), zero for pre-Worldcraft 2.0.1 maps
+
+typedef struct
+{
+    char            txcommand;
+    vects_union     vects;
+    char            name[32];
+} brush_texture_t;
+
+typedef struct side_s
+{
+    brush_texture_t td;
+    vec_t           planepts[3][3];
+} side_t;
+
+typedef struct bface_s
+{
+    struct bface_s* next;
+    int             planenum;
+    plane_t*        plane;
+    Winding*        w;
+    int             texinfo;
+    bool            used;                                  // just for face counting
+    int             contents;
+    int             backcontents;
+    BoundingBox     bounds;
+} bface_t;
+
+// NUM_HULLS should be no larger than MAX_MAP_HULLS
+#define NUM_HULLS 4
+
+typedef struct
+{
+    BoundingBox     bounds;
+    bface_t*        faces;
+} brushhull_t;
+
+typedef struct brush_s
+{
+    int             entitynum;
+    int             brushnum;
+
+    int             firstside;
+    int             numsides;
+
+#ifdef HLCSG_CLIPECONOMY // AJM
+    unsigned int    noclip; // !!!FIXME: this should be a flag bitfield so we can use it for other stuff (ie. is this a detail brush...)
+#endif
+
+    int             contents;
+    brushhull_t     hulls[NUM_HULLS];
+} brush_t;
+
+
+//=============================================================================
+// map.c
+
+extern int      g_nummapbrushes;
+extern brush_t  g_mapbrushes[MAX_MAP_BRUSHES];
+
+#define MAX_MAP_SIDES   (MAX_MAP_BRUSHES*6)
+
+extern int      g_numbrushsides;
+extern side_t   g_brushsides[MAX_MAP_SIDES];
+
+extern void     TextureAxisFromPlane(const plane_t* const pln, vec3_t xv, vec3_t yv);
+extern void     LoadMapFile(const char* const filename);
+
+//=============================================================================
+// textures.c
+
+typedef std::deque< std::string >::iterator WadInclude_i;
+extern std::deque< std::string > g_WadInclude;  // List of substrings to wadinclude
+
+extern void     WriteMiptex();
+extern int      TexinfoForBrushTexture(const plane_t* const plane, brush_texture_t* bt, const vec3_t origin);
+
+//=============================================================================
+// brush.c
+
+extern brush_t* Brush_LoadEntity(entity_t* ent, int hullnum);
+extern contents_t CheckBrushContents(const brush_t* const b);
+
+extern void     CreateBrush(int brushnum);
+
+//=============================================================================
+// csg.c
+
+extern bool     g_chart;
+extern bool     g_onlyents;
+extern bool     g_noclip;
+extern bool     g_wadtextures;
+extern bool     g_skyclip;
+extern bool     g_estimate;         
+extern const char* g_hullfile;        
+
+#ifdef ZHLT_NULLTEX // AJM:
+extern bool     g_bUseNullTex; 
+#endif
+
+#ifdef ZHLT_DETAIL // AJM
+extern bool g_bDetailBrushes;
+#endif
+
+#ifdef HLCSG_CLIPECONOMY // AJM:
+extern bool     g_bClipNazi; 
+#endif
+
+#ifdef HLCSG_PRECISIONCLIP // KGP
+#define EnumPrint(a) #a
+typedef enum{clip_smallest,clip_normalized,clip_simple,clip_precise,clip_legacy} cliptype;
+extern cliptype g_cliptype;
+extern const char*	GetClipTypeString(cliptype);
+#define TEX_BEVEL 32768
+#endif
+
+#ifdef ZHLT_PROGRESSFILE // AJM
+extern char*    g_progressfile ;
+#endif
+
+extern vec_t    g_tiny_threshold;
+extern vec_t    g_BrushUnionThreshold;
+
+extern plane_t  g_mapplanes[MAX_INTERNAL_MAP_PLANES];
+extern int      g_nummapplanes;
+
+extern bface_t* NewFaceFromFace(const bface_t* const in);
+extern bface_t* CopyFace(const bface_t* const f);
+
+extern void     FreeFace(bface_t* f);
+
+extern bface_t* CopyFaceList(bface_t* f);
+extern void     FreeFaceList(bface_t* f);
+
+extern void     GetParamsFromEnt(entity_t* mapent);
+
+//=============================================================================
+// wadinclude.c
+// passed 'filename' is extensionless, the function cats ".wic" at runtime
+
+extern void     LoadWadincludeFile(const char* const filename);
+extern void     SaveWadincludeFile(const char* const filename);
+extern void     HandleWadinclude();
+
+//=============================================================================
+// brushunion.c
+void            CalculateBrushUnions(int brushnum);
+ 
+//============================================================================
+// hullfile.cpp
+extern vec3_t   g_hull_size[NUM_HULLS][2];
+extern void     LoadHullfile(const char* filename);
+
+#ifdef HLCSG_WADCFG // AJM: 
+//============================================================================
+// wadcfg.cpp
+
+extern void     LoadWadConfigFile();
+extern void     ProcessWadConfiguration();
+extern bool     g_bWadConfigsLoaded;
+extern void     WadCfg_cleanup();
+
+#define MAX_WAD_CFG_NAME 32
+extern char     wadconfigname[MAX_WAD_CFG_NAME];
+
+//JK: needed in wadcfg.cpp for *nix..
+#ifndef SYSTEM_WIN32
+extern char *g_apppath;
+#endif
+
+//JK: 
+extern char *g_wadcfgfile;
+
+#endif // HLCSG_WADCFG
+
+#ifdef HLCSG_AUTOWAD
+//============================================================================
+// autowad.cpp      AJM
+
+extern bool     g_bWadAutoDetect; 
+extern int      g_numUsedTextures;
+
+extern void     GetUsedTextures();
+extern bool     autowad_IsUsedTexture(const char* const texname);
+//extern bool     autowad_IsUsedWad(const char* const path);
+//extern void     autowad_PurgeName(const char* const texname);
+extern void     autowad_cleanup();
+extern void     autowad_UpdateUsedWads();
+
+#endif // HLCSG_AUTOWAD
+
+//=============================================================================
+// properties.cpp
+
+#ifdef HLCSG_NULLIFY_INVISIBLE // KGP
+#include <string>
+#include <set>
+extern void properties_initialize(const char* filename);
+extern std::set<std::string> g_invisible_items;
+#endif
+
+//============================================================================
+#endif//HLCSG_H__

+ 688 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/hlcsg.mak

@@ -0,0 +1,688 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on hlcsg.dsp
+!IF "$(CFG)" == ""
+CFG=hlcsg - Win32 Super_Debug
+!MESSAGE No configuration specified. Defaulting to hlcsg - Win32 Super_Debug.
+!ENDIF 
+
+!IF "$(CFG)" != "hlcsg - Win32 Release" && "$(CFG)" != "hlcsg - Win32 Debug" && "$(CFG)" != "hlcsg - Win32 Release w Symbols" && "$(CFG)" != "hlcsg - Win32 Super_Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "hlcsg.mak" CFG="hlcsg - Win32 Super_Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "hlcsg - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "hlcsg - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "hlcsg - Win32 Release w Symbols" (based on "Win32 (x86) Console Application")
+!MESSAGE "hlcsg - Win32 Super_Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "hlcsg - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlcsg.exe" "$(OUTDIR)\hlcsg.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\autowad.obj"
+	-@erase "$(INTDIR)\autowad.sbr"
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\brush.obj"
+	-@erase "$(INTDIR)\brush.sbr"
+	-@erase "$(INTDIR)\brushunion.obj"
+	-@erase "$(INTDIR)\brushunion.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\files.obj"
+	-@erase "$(INTDIR)\files.sbr"
+	-@erase "$(INTDIR)\hullfile.obj"
+	-@erase "$(INTDIR)\hullfile.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\map.obj"
+	-@erase "$(INTDIR)\map.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\qcsg.obj"
+	-@erase "$(INTDIR)\qcsg.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\textures.obj"
+	-@erase "$(INTDIR)\textures.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\wadcfg.obj"
+	-@erase "$(INTDIR)\wadcfg.sbr"
+	-@erase "$(INTDIR)\wadinclude.obj"
+	-@erase "$(INTDIR)\wadinclude.sbr"
+	-@erase "$(INTDIR)\wadpath.obj"
+	-@erase "$(INTDIR)\wadpath.sbr"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(OUTDIR)\hlcsg.bsc"
+	-@erase "$(OUTDIR)\hlcsg.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\common" /I "..\template" /D "NDEBUG" /D "HLCSG" /D "_MBCS" /D "DOUBLEVEC_T" /D "STDC_HEADERS" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlcsg.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlcsg.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\files.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\winding.sbr" \
+	"$(INTDIR)\autowad.sbr" \
+	"$(INTDIR)\brush.sbr" \
+	"$(INTDIR)\brushunion.sbr" \
+	"$(INTDIR)\hullfile.sbr" \
+	"$(INTDIR)\map.sbr" \
+	"$(INTDIR)\qcsg.sbr" \
+	"$(INTDIR)\textures.sbr" \
+	"$(INTDIR)\wadcfg.sbr" \
+	"$(INTDIR)\wadinclude.sbr" \
+	"$(INTDIR)\wadpath.sbr"
+
+"$(OUTDIR)\hlcsg.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x400000,0x100000 /subsystem:console /incremental:no /pdb:"$(OUTDIR)\hlcsg.pdb" /machine:I386 /out:"$(OUTDIR)\hlcsg.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\files.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\winding.obj" \
+	"$(INTDIR)\autowad.obj" \
+	"$(INTDIR)\brush.obj" \
+	"$(INTDIR)\brushunion.obj" \
+	"$(INTDIR)\hullfile.obj" \
+	"$(INTDIR)\map.obj" \
+	"$(INTDIR)\qcsg.obj" \
+	"$(INTDIR)\textures.obj" \
+	"$(INTDIR)\wadcfg.obj" \
+	"$(INTDIR)\wadinclude.obj" \
+	"$(INTDIR)\wadpath.obj"
+
+"$(OUTDIR)\hlcsg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "hlcsg - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlcsg.exe" "$(OUTDIR)\hlcsg.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\autowad.obj"
+	-@erase "$(INTDIR)\autowad.sbr"
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\brush.obj"
+	-@erase "$(INTDIR)\brush.sbr"
+	-@erase "$(INTDIR)\brushunion.obj"
+	-@erase "$(INTDIR)\brushunion.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\files.obj"
+	-@erase "$(INTDIR)\files.sbr"
+	-@erase "$(INTDIR)\hullfile.obj"
+	-@erase "$(INTDIR)\hullfile.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\map.obj"
+	-@erase "$(INTDIR)\map.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\qcsg.obj"
+	-@erase "$(INTDIR)\qcsg.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\textures.obj"
+	-@erase "$(INTDIR)\textures.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(INTDIR)\wadcfg.obj"
+	-@erase "$(INTDIR)\wadcfg.sbr"
+	-@erase "$(INTDIR)\wadinclude.obj"
+	-@erase "$(INTDIR)\wadinclude.sbr"
+	-@erase "$(INTDIR)\wadpath.obj"
+	-@erase "$(INTDIR)\wadpath.sbr"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(OUTDIR)\hlcsg.bsc"
+	-@erase "$(OUTDIR)\hlcsg.exe"
+	-@erase "$(OUTDIR)\hlcsg.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /Gm /GX /Zi /Od /I "..\template" /I "..\common" /D "_DEBUG" /D "_MBCS" /D "DOUBLEVEC_T" /D "STDC_HEADERS" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /D "HLCSG" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlcsg.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlcsg.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\files.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\winding.sbr" \
+	"$(INTDIR)\autowad.sbr" \
+	"$(INTDIR)\brush.sbr" \
+	"$(INTDIR)\brushunion.sbr" \
+	"$(INTDIR)\hullfile.sbr" \
+	"$(INTDIR)\map.sbr" \
+	"$(INTDIR)\qcsg.sbr" \
+	"$(INTDIR)\textures.sbr" \
+	"$(INTDIR)\wadcfg.sbr" \
+	"$(INTDIR)\wadinclude.sbr" \
+	"$(INTDIR)\wadpath.sbr"
+
+"$(OUTDIR)\hlcsg.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x1000000,0x100000 /subsystem:console /profile /map:"$(INTDIR)\hlcsg.map" /debug /machine:I386 /out:"$(OUTDIR)\hlcsg.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\files.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\winding.obj" \
+	"$(INTDIR)\autowad.obj" \
+	"$(INTDIR)\brush.obj" \
+	"$(INTDIR)\brushunion.obj" \
+	"$(INTDIR)\hullfile.obj" \
+	"$(INTDIR)\map.obj" \
+	"$(INTDIR)\qcsg.obj" \
+	"$(INTDIR)\textures.obj" \
+	"$(INTDIR)\wadcfg.obj" \
+	"$(INTDIR)\wadinclude.obj" \
+	"$(INTDIR)\wadpath.obj"
+
+"$(OUTDIR)\hlcsg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "hlcsg - Win32 Release w Symbols"
+
+OUTDIR=.\Release_w_Symbols
+INTDIR=.\Release_w_Symbols
+# Begin Custom Macros
+OutDir=.\Release_w_Symbols
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlcsg.exe" "$(OUTDIR)\hlcsg.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\autowad.obj"
+	-@erase "$(INTDIR)\autowad.sbr"
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\brush.obj"
+	-@erase "$(INTDIR)\brush.sbr"
+	-@erase "$(INTDIR)\brushunion.obj"
+	-@erase "$(INTDIR)\brushunion.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\files.obj"
+	-@erase "$(INTDIR)\files.sbr"
+	-@erase "$(INTDIR)\hullfile.obj"
+	-@erase "$(INTDIR)\hullfile.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\map.obj"
+	-@erase "$(INTDIR)\map.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\qcsg.obj"
+	-@erase "$(INTDIR)\qcsg.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\textures.obj"
+	-@erase "$(INTDIR)\textures.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(INTDIR)\wadcfg.obj"
+	-@erase "$(INTDIR)\wadcfg.sbr"
+	-@erase "$(INTDIR)\wadinclude.obj"
+	-@erase "$(INTDIR)\wadinclude.sbr"
+	-@erase "$(INTDIR)\wadpath.obj"
+	-@erase "$(INTDIR)\wadpath.sbr"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(OUTDIR)\hlcsg.bsc"
+	-@erase "$(OUTDIR)\hlcsg.exe"
+	-@erase "$(OUTDIR)\hlcsg.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /GX /Zi /O2 /I "..\common" /I "..\template" /D "NDEBUG" /D "_MBCS" /D "DOUBLEVEC_T" /D "STDC_HEADERS" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /D "HLCSG" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlcsg.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlcsg.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\files.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\winding.sbr" \
+	"$(INTDIR)\autowad.sbr" \
+	"$(INTDIR)\brush.sbr" \
+	"$(INTDIR)\brushunion.sbr" \
+	"$(INTDIR)\hullfile.sbr" \
+	"$(INTDIR)\map.sbr" \
+	"$(INTDIR)\qcsg.sbr" \
+	"$(INTDIR)\textures.sbr" \
+	"$(INTDIR)\wadcfg.sbr" \
+	"$(INTDIR)\wadinclude.sbr" \
+	"$(INTDIR)\wadpath.sbr"
+
+"$(OUTDIR)\hlcsg.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x400000,0x100000 /subsystem:console /pdb:none /map:"$(INTDIR)\hlcsg.map" /debug /machine:I386 /out:"$(OUTDIR)\hlcsg.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\files.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\winding.obj" \
+	"$(INTDIR)\autowad.obj" \
+	"$(INTDIR)\brush.obj" \
+	"$(INTDIR)\brushunion.obj" \
+	"$(INTDIR)\hullfile.obj" \
+	"$(INTDIR)\map.obj" \
+	"$(INTDIR)\qcsg.obj" \
+	"$(INTDIR)\textures.obj" \
+	"$(INTDIR)\wadcfg.obj" \
+	"$(INTDIR)\wadinclude.obj" \
+	"$(INTDIR)\wadpath.obj"
+
+"$(OUTDIR)\hlcsg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "hlcsg - Win32 Super_Debug"
+
+OUTDIR=.\Super_Debug
+INTDIR=.\Super_Debug
+# Begin Custom Macros
+OutDir=.\Super_Debug
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlcsg.exe" "$(OUTDIR)\hlcsg.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\autowad.obj"
+	-@erase "$(INTDIR)\autowad.sbr"
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\brush.obj"
+	-@erase "$(INTDIR)\brush.sbr"
+	-@erase "$(INTDIR)\brushunion.obj"
+	-@erase "$(INTDIR)\brushunion.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\files.obj"
+	-@erase "$(INTDIR)\files.sbr"
+	-@erase "$(INTDIR)\hullfile.obj"
+	-@erase "$(INTDIR)\hullfile.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\map.obj"
+	-@erase "$(INTDIR)\map.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\qcsg.obj"
+	-@erase "$(INTDIR)\qcsg.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\textures.obj"
+	-@erase "$(INTDIR)\textures.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(INTDIR)\wadcfg.obj"
+	-@erase "$(INTDIR)\wadcfg.sbr"
+	-@erase "$(INTDIR)\wadinclude.obj"
+	-@erase "$(INTDIR)\wadinclude.sbr"
+	-@erase "$(INTDIR)\wadpath.obj"
+	-@erase "$(INTDIR)\wadpath.sbr"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(OUTDIR)\hlcsg.bsc"
+	-@erase "$(OUTDIR)\hlcsg.exe"
+	-@erase "$(OUTDIR)\hlcsg.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\common" /I "..\template" /D "_DEBUG" /D "HLCSG" /D "_MBCS" /D "DOUBLEVEC_T" /D "STDC_HEADERS" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlcsg.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlcsg.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\files.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\winding.sbr" \
+	"$(INTDIR)\autowad.sbr" \
+	"$(INTDIR)\brush.sbr" \
+	"$(INTDIR)\brushunion.sbr" \
+	"$(INTDIR)\hullfile.sbr" \
+	"$(INTDIR)\map.sbr" \
+	"$(INTDIR)\qcsg.sbr" \
+	"$(INTDIR)\textures.sbr" \
+	"$(INTDIR)\wadcfg.sbr" \
+	"$(INTDIR)\wadinclude.sbr" \
+	"$(INTDIR)\wadpath.sbr"
+
+"$(OUTDIR)\hlcsg.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x1000000,0x100000 /subsystem:console /profile /map:"$(INTDIR)\hlcsg.map" /debug /machine:I386 /out:"$(OUTDIR)\hlcsg.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\files.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\winding.obj" \
+	"$(INTDIR)\autowad.obj" \
+	"$(INTDIR)\brush.obj" \
+	"$(INTDIR)\brushunion.obj" \
+	"$(INTDIR)\hullfile.obj" \
+	"$(INTDIR)\map.obj" \
+	"$(INTDIR)\qcsg.obj" \
+	"$(INTDIR)\textures.obj" \
+	"$(INTDIR)\wadcfg.obj" \
+	"$(INTDIR)\wadinclude.obj" \
+	"$(INTDIR)\wadpath.obj"
+
+"$(OUTDIR)\hlcsg.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("hlcsg.dep")
+!INCLUDE "hlcsg.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "hlcsg.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "hlcsg - Win32 Release" || "$(CFG)" == "hlcsg - Win32 Debug" || "$(CFG)" == "hlcsg - Win32 Release w Symbols" || "$(CFG)" == "hlcsg - Win32 Super_Debug"
+SOURCE=..\common\blockmem.cpp
+
+"$(INTDIR)\blockmem.obj"	"$(INTDIR)\blockmem.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\bspfile.cpp
+
+"$(INTDIR)\bspfile.obj"	"$(INTDIR)\bspfile.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\cmdlib.cpp
+
+"$(INTDIR)\cmdlib.obj"	"$(INTDIR)\cmdlib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\filelib.cpp
+
+"$(INTDIR)\filelib.obj"	"$(INTDIR)\filelib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\files.cpp
+
+"$(INTDIR)\files.obj"	"$(INTDIR)\files.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\log.cpp
+
+"$(INTDIR)\log.obj"	"$(INTDIR)\log.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\mathlib.cpp
+
+"$(INTDIR)\mathlib.obj"	"$(INTDIR)\mathlib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\messages.cpp
+
+"$(INTDIR)\messages.obj"	"$(INTDIR)\messages.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\scriplib.cpp
+
+"$(INTDIR)\scriplib.obj"	"$(INTDIR)\scriplib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\threads.cpp
+
+"$(INTDIR)\threads.obj"	"$(INTDIR)\threads.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\winding.cpp
+
+"$(INTDIR)\winding.obj"	"$(INTDIR)\winding.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\autowad.cpp
+
+"$(INTDIR)\autowad.obj"	"$(INTDIR)\autowad.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\brush.cpp
+
+"$(INTDIR)\brush.obj"	"$(INTDIR)\brush.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\brushunion.cpp
+
+"$(INTDIR)\brushunion.obj"	"$(INTDIR)\brushunion.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\hullfile.cpp
+
+"$(INTDIR)\hullfile.obj"	"$(INTDIR)\hullfile.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\map.cpp
+
+"$(INTDIR)\map.obj"	"$(INTDIR)\map.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\qcsg.cpp
+
+"$(INTDIR)\qcsg.obj"	"$(INTDIR)\qcsg.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\textures.cpp
+
+"$(INTDIR)\textures.obj"	"$(INTDIR)\textures.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\wadcfg.cpp
+
+"$(INTDIR)\wadcfg.obj"	"$(INTDIR)\wadcfg.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\wadinclude.cpp
+
+"$(INTDIR)\wadinclude.obj"	"$(INTDIR)\wadinclude.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\wadpath.cpp
+
+"$(INTDIR)\wadpath.obj"	"$(INTDIR)\wadpath.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+
+!ENDIF 
+

+ 746 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/hlcsg.vcproj

@@ -0,0 +1,746 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="hlcsg"
+	ProjectGUID="{6A4E6C36-5342-46CF-BB1C-A4FF993AEA3F}"
+	RootNamespace="hlcsg"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+		<Platform
+			Name="x64"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\Release"
+			IntermediateDirectory=".\Release"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			UseOfATL="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="0"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\Release/hlcsg.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				UseUnicodeResponseFiles="false"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="D:\Programs\MSPlatformSDKServer2003\Include\atl;..\common;..\template"
+				PreprocessorDefinitions="NDEBUG,HLCSG,DOUBLEVEC_T,STDC_HEADERS,WIN32,_CONSOLE,SYSTEM_WIN32"
+				StringPooling="true"
+				ExceptionHandling="1"
+				BufferSecurityCheck="false"
+				EnableFunctionLevelLinking="false"
+				EnableEnhancedInstructionSet="2"
+				FloatingPointModel="0"
+				RuntimeTypeInfo="false"
+				OpenMP="false"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Release/hlcsg.pch"
+				AssemblerListingLocation=".\Release/"
+				ObjectFile=".\Release/"
+				ProgramDataBaseFileName=".\Release/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Release/hlcsg.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\Release/hlcsg.pdb"
+				SubSystem="1"
+				StackReserveSize="4194304"
+				StackCommitSize="1048576"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="0"
+				LinkTimeCodeGeneration="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|x64"
+			OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			UseOfATL="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="0"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+				TypeLibraryName=".\Release/hlcsg.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				UseUnicodeResponseFiles="false"
+				Optimization="3"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="D:\Programs\MSPlatformSDKServer2003\Include\atl;..\common;..\template"
+				PreprocessorDefinitions="NDEBUG,HLCSG,DOUBLEVEC_T,STDC_HEADERS,WIN32,_CONSOLE,SYSTEM_WIN32"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				BufferSecurityCheck="false"
+				EnableFunctionLevelLinking="true"
+				EnableEnhancedInstructionSet="0"
+				FloatingPointModel="0"
+				RuntimeTypeInfo="false"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Release/hlcsg.pch"
+				AssemblerListingLocation=".\Release/"
+				ObjectFile=".\Release/"
+				ProgramDataBaseFileName=".\Release/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				Detect64BitPortabilityProblems="false"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Release/hlcsg.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\Release/hlcsg.pdb"
+				SubSystem="1"
+				StackReserveSize="4194304"
+				StackCommitSize="1048576"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				LinkTimeCodeGeneration="1"
+				TargetMachine="17"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\Debug"
+			IntermediateDirectory=".\Debug"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\Debug/hlcsg.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\template,..\common"
+				PreprocessorDefinitions="_DEBUG,DOUBLEVEC_T,STDC_HEADERS,WIN32,_CONSOLE,SYSTEM_WIN32,HLCSG"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Debug/hlcsg.pch"
+				AssemblerListingLocation=".\Debug/"
+				ObjectFile=".\Debug/"
+				ProgramDataBaseFileName=".\Debug/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Debug/hlcsg.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\Debug/hlcsg.pdb"
+				GenerateMapFile="true"
+				MapFileName=".\Debug/hlcsg.map"
+				SubSystem="1"
+				StackReserveSize="16777216"
+				StackCommitSize="1048576"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|x64"
+			OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+				TypeLibraryName=".\Debug/hlcsg.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\template,..\common"
+				PreprocessorDefinitions="_DEBUG,DOUBLEVEC_T,STDC_HEADERS,WIN32,_CONSOLE,SYSTEM_WIN32,HLCSG"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Debug/hlcsg.pch"
+				AssemblerListingLocation=".\Debug/"
+				ObjectFile=".\Debug/"
+				ProgramDataBaseFileName=".\Debug/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Debug/hlcsg.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\Debug/hlcsg.pdb"
+				GenerateMapFile="true"
+				MapFileName=".\Debug/hlcsg.map"
+				SubSystem="1"
+				StackReserveSize="16777216"
+				StackCommitSize="1048576"
+				TargetMachine="17"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\Release/hlcsg.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				AdditionalIncludeDirectories="D:\Programs\MSPlatformSDKServer2003\Include\atl;..\common;..\template"
+				PreprocessorDefinitions="NDEBUG,HLCSG,DOUBLEVEC_T,STDC_HEADERS,WIN32,_CONSOLE,SYSTEM_WIN32"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				EnableEnhancedInstructionSet="2"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Release/hlcsg.pch"
+				AssemblerListingLocation=".\Release/"
+				ObjectFile=".\Release/"
+				ProgramDataBaseFileName=".\Release/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				Detect64BitPortabilityProblems="false"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Release/hlcsg.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\Release/hlcsg.pdb"
+				SubSystem="1"
+				StackReserveSize="4194304"
+				StackCommitSize="1048576"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|x64"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
+			>
+			<File
+				RelativePath=".\autowad.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\brush.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\brushunion.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\hullfile.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\map.cpp"
+				>
+			</File>
+			<File
+				RelativePath="properties.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\qcsg.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\textures.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\wadcfg.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\wadinclude.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\wadpath.cpp"
+				>
+			</File>
+			<Filter
+				Name="common"
+				>
+				<File
+					RelativePath="..\common\blockmem.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\bspfile.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\cmdlib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\filelib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\files.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\log.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\mathlib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\messages.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\threads.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\winding.cpp"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;fi;fd"
+			>
+			<File
+				RelativePath="..\common\blockmem.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\boundingbox.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\bspfile.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\cmdlib.h"
+				>
+			</File>
+			<File
+				RelativePath=".\csg.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\filelib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\hlassert.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\log.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\mathlib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\mathtypes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\messages.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\scriplib.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\common\scriplib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\threads.h"
+				>
+			</File>
+			<File
+				RelativePath=".\wadpath.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\win32fix.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\winding.h"
+				>
+			</File>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 177 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/hlcsg.vcproj.SILENCERSPC.Administrator.user

@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="9.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|x64"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|x64"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|x64"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>

+ 102 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/hullfile.cpp

@@ -0,0 +1,102 @@
+#include "csg.h"
+
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4996)
+#endif
+
+vec3_t          g_hull_size[NUM_HULLS][2] = 
+{
+    {// 0x0x0
+        {0, 0, 0},          {0, 0, 0}
+    }
+    ,
+    {// 32x32x72
+        {-16, -16, -36},    {16, 16, 36}
+    }
+    ,                                                      
+    {// 64x64x64
+        {-32, -32, -32},    {32, 32, 32}
+    }
+    ,                                                      
+    {// 32x32x36
+        {-16, -16, -18},    {16, 16, 18}
+    }                                                     
+};
+
+void        LoadHullfile(const char* filename)
+{
+    if (filename == NULL)
+    {
+        return;
+    }
+
+    if (q_exists(filename))
+    {
+        Log("Loading hull definitions from '%s'\n", filename);
+    }
+    else
+    {
+        Error("Could not find hull definition file '%s'\n", filename);
+        return;
+    }
+
+    float x1,y1,z1;
+	float x2,y2,z2;
+	char magic;
+
+    FILE* file = fopen(filename, "r");
+
+    int count;
+    int i;
+
+	magic = (char)fgetc(file);
+	rewind(file);
+
+	if(magic == '(')
+	{   // Test for old-style hull-file
+
+		for (i=0; i < NUM_HULLS; i++)
+		{
+			count = fscanf(file, "( %f %f %f ) ( %f %f %f )\n", &x1, &y1, &z1, &x2, &y2, &z2);
+			if (count != 6)
+			{
+				Error("Could not parse old hull definition file '%s' (%d, %d)\n", filename, i, count);
+			}
+
+			g_hull_size[i][0][0] = x1;
+			g_hull_size[i][0][1] = y1;
+			g_hull_size[i][0][2] = z1;
+
+			g_hull_size[i][1][0] = x2;
+			g_hull_size[i][1][1] = y2;
+			g_hull_size[i][1][2] = z2;			
+
+		}
+		
+	}
+	else
+	{
+		// Skip hull 0 (visibile polygons)
+		for (i=1; i<NUM_HULLS; i++)
+		{
+			count = fscanf(file, "%f %f %f\n", &x1, &y1, &z1);
+			if (count != 3)
+			{
+				Error("Could not parse new hull definition file '%s' (%d, %d)\n", filename, i, count);
+			}
+			x1 *= 0.5;
+			y1 *= 0.5;
+			z1 *= 0.5;
+
+			g_hull_size[i][0][0] = -x1;
+			g_hull_size[i][0][1] = -y1;
+			g_hull_size[i][0][2] = -z1;
+
+			g_hull_size[i][1][0] = x1;
+			g_hull_size[i][1][1] = y1;
+			g_hull_size[i][1][2] = z1;
+		}
+    }
+
+    fclose(file);
+}

+ 45 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/make.inc

@@ -0,0 +1,45 @@
+HLCSG_DEFINES+=-D DOUBLEVEC_T
+HLCSG:=$(OUTDIR)/hlcsg$(EXEEXT)
+HLCSG_SRCDIR:=hlcsg
+HLCSG_OUTDIR:=$(HLCSG_SRCDIR)/$(OUTDIR)
+
+
+HLCSG_INPUT := \
+$(HLCSG_SRCDIR)/brush.cpp \
+$(HLCSG_SRCDIR)/map.cpp \
+$(HLCSG_SRCDIR)/qcsg.cpp \
+$(HLCSG_SRCDIR)/textures.cpp \
+$(HLCSG_SRCDIR)/wadinclude.cpp \
+$(HLCSG_SRCDIR)/brushunion.cpp \
+$(HLCSG_SRCDIR)/hullfile.cpp \
+$(COMMON_SRCDIR)/blockmem.cpp \
+$(COMMON_SRCDIR)/bspfile.cpp \
+$(COMMON_SRCDIR)/cmdlib.cpp \
+$(COMMON_SRCDIR)/filelib.cpp \
+$(COMMON_SRCDIR)/log.cpp \
+$(COMMON_SRCDIR)/mathlib.cpp \
+$(COMMON_SRCDIR)/messages.cpp \
+$(COMMON_SRCDIR)/scriplib.cpp \
+$(COMMON_SRCDIR)/threads.cpp \
+$(COMMON_SRCDIR)/winding.cpp \
+
+
+HLCSG_OUTPUT := \
+$(HLCSG_OUTDIR)/brush$(OBJEXT) \
+$(HLCSG_OUTDIR)/map$(OBJEXT) \
+$(HLCSG_OUTDIR)/qcsg$(OBJEXT) \
+$(HLCSG_OUTDIR)/textures$(OBJEXT) \
+$(HLCSG_OUTDIR)/wadinclude$(OBJEXT) \
+$(HLCSG_OUTDIR)/brushunion$(OBJEXT) \
+$(HLCSG_OUTDIR)/hullfile$(OBJEXT) \
+$(HLCSG_OUTDIR)/blockmem$(OBJEXT) \
+$(HLCSG_OUTDIR)/bspfile$(OBJEXT) \
+$(HLCSG_OUTDIR)/cmdlib$(OBJEXT) \
+$(HLCSG_OUTDIR)/filelib$(OBJEXT) \
+$(HLCSG_OUTDIR)/log$(OBJEXT) \
+$(HLCSG_OUTDIR)/mathlib$(OBJEXT) \
+$(HLCSG_OUTDIR)/messages$(OBJEXT) \
+$(HLCSG_OUTDIR)/scriplib$(OBJEXT) \
+$(HLCSG_OUTDIR)/threads$(OBJEXT) \
+$(HLCSG_OUTDIR)/winding$(OBJEXT) \
+

+ 660 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/map.cpp

@@ -0,0 +1,660 @@
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4996)
+#endif
+
+#pragma warning(disable:4018) // '<' : signed/unsigned mismatch
+
+#include "csg.h"
+
+int             g_nummapbrushes;
+brush_t         g_mapbrushes[MAX_MAP_BRUSHES];
+
+int             g_numbrushsides;
+side_t          g_brushsides[MAX_MAP_SIDES];
+
+int             g_nMapFileVersion;
+
+static const vec3_t   s_baseaxis[18] = {
+    {0, 0, 1}, {1, 0, 0}, {0, -1, 0},                      // floor
+    {0, 0, -1}, {1, 0, 0}, {0, -1, 0},                     // ceiling
+    {1, 0, 0}, {0, 1, 0}, {0, 0, -1},                      // west wall
+    {-1, 0, 0}, {0, 1, 0}, {0, 0, -1},                     // east wall
+    {0, 1, 0}, {1, 0, 0}, {0, 0, -1},                      // south wall
+    {0, -1, 0}, {1, 0, 0}, {0, 0, -1},                     // north wall
+};
+
+// =====================================================================================
+//  TextureAxisFromPlane
+// =====================================================================================
+void            TextureAxisFromPlane(const plane_t* const pln, vec3_t xv, vec3_t yv)
+{
+    int             bestaxis;
+    vec_t           dot, best;
+    int             i;
+
+    best = 0;
+    bestaxis = 0;
+
+    for (i = 0; i < 6; i++)
+    {
+        dot = DotProduct(pln->normal, s_baseaxis[i * 3]);
+        if (dot > best)
+        {
+            best = dot;
+            bestaxis = i;
+        }
+    }
+
+    VectorCopy(s_baseaxis[bestaxis * 3 + 1], xv);
+    VectorCopy(s_baseaxis[bestaxis * 3 + 2], yv);
+}
+
+#define ScaleCorrection	(1.0/128.0)
+
+// =====================================================================================
+//  CopySKYtoCLIP
+//      clips a particluar sky brush
+// =====================================================================================
+static void     CopySKYtoCLIP(const brush_t* const b)
+{
+    int             i;
+    entity_t*       mapent;
+    brush_t*        newbrush;
+
+    if (b->contents != CONTENTS_SKY)
+		Error("[MOD] CopySKYtoCLIP: Got a NON-SKY for passed brush! (%s)",b->contents ); 
+
+    hlassert(b->contents == CONTENTS_SKY);                 // Only SKY brushes should be passed down to this function(sanity check)
+    hlassert(b->entitynum == 0);                           // SKY must be in worldspawn entity
+
+    mapent = &g_entities[b->entitynum];
+    mapent->numbrushes++;
+
+    newbrush = &g_mapbrushes[g_nummapbrushes];
+    newbrush->entitynum = b->entitynum;
+    newbrush->brushnum = g_nummapbrushes - mapent->firstbrush;
+    newbrush->firstside = g_numbrushsides;
+    newbrush->numsides = b->numsides;
+    newbrush->contents = CONTENTS_CLIP;
+    newbrush->noclip = 0;
+
+    for (i = 0; i < b->numsides; i++)
+    {
+        int             j;
+
+        side_t*         side = &g_brushsides[g_numbrushsides];
+
+        *side = g_brushsides[b->firstside + i];
+        safe_strncpy(side->td.name, "CLIP", sizeof(side->td.name));
+
+        for (j = 0; j < NUM_HULLS; j++)
+        {
+            newbrush->hulls[j].faces = NULL;
+            newbrush->hulls[j].bounds = b->hulls[j].bounds;
+        }
+
+        g_numbrushsides++;
+        hlassume(g_numbrushsides < MAX_MAP_SIDES, assume_MAX_MAP_SIDES);
+    }
+
+    g_nummapbrushes++;
+    hlassume(g_nummapbrushes < MAX_MAP_BRUSHES, assume_MAX_MAP_BRUSHES);
+}
+
+// =====================================================================================
+//  HandleSKYCLIP
+//      clips the whole sky, unconditional of g_skyclip
+// =====================================================================================
+static void     HandleSKYCLIP()
+{
+    int             i;
+    int             last;
+    entity_t*       e = &g_entities[0];
+
+    for (i = e->firstbrush, last = e->firstbrush + e->numbrushes; i < last; i++)
+    {
+        if (g_mapbrushes[i].contents == CONTENTS_SKY)
+        {
+            CopySKYtoCLIP(&g_mapbrushes[i]);
+        }
+    }
+}
+
+// =====================================================================================
+//  CheckForInvisible
+//      see if a brush is part of an invisible entity (KGP)
+// =====================================================================================
+#ifdef HLCSG_NULLIFY_INVISIBLE
+static bool CheckForInvisible(entity_t* mapent)
+{
+	using namespace std;
+
+	string keyval(ValueForKey(mapent,"classname"));
+	if(g_invisible_items.count(keyval))
+	{ return true; }
+
+	keyval.assign(ValueForKey(mapent,"targetname"));
+	if(g_invisible_items.count(keyval))
+	{ return true; }
+
+	keyval.assign(ValueForKey(mapent,"zhlt_invisible"));
+	if(!keyval.empty() && strcmp(keyval.c_str(),"0"))
+	{ return true; }
+
+	return false;
+}
+#endif
+// =====================================================================================
+//  ParseBrush
+//      parse a brush from script
+// =====================================================================================
+static contents_t ParseBrush(entity_t* mapent)
+{
+    brush_t*        b;
+    int             i, j;
+    side_t*         side;
+    contents_t      contents;
+    bool            ok;
+#ifdef HLCSG_NULLIFY_INVISIBLE // KGP
+	bool nullify = CheckForInvisible(mapent);
+#endif
+    hlassume(g_nummapbrushes < MAX_MAP_BRUSHES, assume_MAX_MAP_BRUSHES);
+
+    b = &g_mapbrushes[g_nummapbrushes];
+    g_nummapbrushes++;
+    b->firstside = g_numbrushsides;
+    b->entitynum = g_numentities - 1;
+    b->brushnum = g_nummapbrushes - mapent->firstbrush - 1;
+
+#ifdef HLCSG_CLIPECONOMY // AJM
+    b->noclip = 0;
+#endif
+
+    mapent->numbrushes++;
+
+	ok = GetToken(true);
+    while (ok)
+    {
+        g_TXcommand = 0;
+        if (!strcmp(g_token, "}"))
+        {
+            break;
+        }
+
+        hlassume(g_numbrushsides < MAX_MAP_SIDES, assume_MAX_MAP_SIDES);
+        side = &g_brushsides[g_numbrushsides];
+        g_numbrushsides++;
+
+        b->numsides++;
+
+        // read the three point plane definition
+        for (i = 0; i < 3; i++)
+        {
+            if (i != 0)
+            {
+                GetToken(true);
+            }
+            if (strcmp(g_token, "("))
+            {
+                Error("Parsing Entity %i, Brush %i, Side %i : Expecting '(' got '%s'",
+                      b->entitynum, b->brushnum, b->numsides, g_token);
+            }
+
+            for (j = 0; j < 3; j++)
+            {
+                GetToken(false);
+                side->planepts[i][j] = atof(g_token);
+            }
+
+            GetToken(false);
+            if (strcmp(g_token, ")"))
+            {
+                Error("Parsing	Entity %i, Brush %i, Side %i : Expecting ')' got '%s'",
+                      b->entitynum, b->brushnum, b->numsides, g_token);
+            }
+        }
+
+        // read the     texturedef
+        GetToken(false);
+        _strupr(g_token);
+#ifdef HLCSG_NULLIFY_INVISIBLE
+		if(nullify && strncmp(g_token,"BEVEL",5) && strncmp(g_token,"ORIGIN",6))
+		{ safe_strncpy(g_token,"NULL",sizeof(g_token)); }
+#endif
+        safe_strncpy(side->td.name, g_token, sizeof(side->td.name));
+
+        if (g_nMapFileVersion < 220)                       // Worldcraft 2.1-, Radiant
+        {
+            GetToken(false);
+            side->td.vects.valve.shift[0] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.shift[1] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.rotate = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.scale[0] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.scale[1] = atof(g_token);
+        }
+        else                                               // Worldcraft 2.2+
+        {
+            // texture U axis
+            GetToken(false);
+            if (strcmp(g_token, "["))
+            {
+                hlassume(false, assume_MISSING_BRACKET_IN_TEXTUREDEF);
+            }
+
+            GetToken(false);
+            side->td.vects.valve.UAxis[0] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.UAxis[1] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.UAxis[2] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.shift[0] = atof(g_token);
+
+            GetToken(false);
+            if (strcmp(g_token, "]"))
+            {
+                Error("missing ']' in texturedef (U)");
+            }
+
+            // texture V axis
+            GetToken(false);
+            if (strcmp(g_token, "["))
+            {
+                Error("missing '[' in texturedef (V)");
+            }
+
+            GetToken(false);
+            side->td.vects.valve.VAxis[0] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.VAxis[1] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.VAxis[2] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.shift[1] = atof(g_token);
+
+            GetToken(false);
+            if (strcmp(g_token, "]"))
+            {
+                Error("missing ']' in texturedef (V)");
+            }
+
+            // Texture rotation is implicit in U/V axes.
+            GetToken(false);
+            side->td.vects.valve.rotate = 0;
+
+            // texure scale
+            GetToken(false);
+            side->td.vects.valve.scale[0] = atof(g_token);
+            GetToken(false);
+            side->td.vects.valve.scale[1] = atof(g_token);
+        }
+
+        ok = GetToken(true);                               // Done with line, this reads the first item from the next line
+
+        if ((g_TXcommand == '1' || g_TXcommand == '2'))
+        {
+            // We are QuArK mode and need to translate some numbers to align textures its way
+            // from QuArK, the texture vectors are given directly from the three points
+            vec3_t          TexPt[2];
+            int             k;
+            float           dot22, dot23, dot33, mdet, aa, bb, dd;
+
+            k = g_TXcommand - '0';
+            for (j = 0; j < 3; j++)
+            {
+                TexPt[1][j] = (side->planepts[k][j] - side->planepts[0][j]) * ScaleCorrection;
+            }
+            k = 3 - k;
+            for (j = 0; j < 3; j++)
+            {
+                TexPt[0][j] = (side->planepts[k][j] - side->planepts[0][j]) * ScaleCorrection;
+            }
+
+            dot22 = DotProduct(TexPt[0], TexPt[0]);
+            dot23 = DotProduct(TexPt[0], TexPt[1]);
+            dot33 = DotProduct(TexPt[1], TexPt[1]);
+            mdet = dot22 * dot33 - dot23 * dot23;
+            if (mdet < 1E-6 && mdet > -1E-6)
+            {
+                aa = bb = dd = 0;
+                Warning
+                    ("Degenerate QuArK-style brush texture : Entity %i, Brush %i @ (%f,%f,%f) (%f,%f,%f)	(%f,%f,%f)",
+                     b->entitynum, b->brushnum, side->planepts[0][0], side->planepts[0][1], side->planepts[0][2],
+                     side->planepts[1][0], side->planepts[1][1], side->planepts[1][2], side->planepts[2][0],
+                     side->planepts[2][1], side->planepts[2][2]);
+            }
+            else
+            {
+                mdet = 1.0 / mdet;
+                aa = dot33 * mdet;
+                bb = -dot23 * mdet;
+                //cc = -dot23*mdet;             // cc = bb
+                dd = dot22 * mdet;
+            }
+
+            for (j = 0; j < 3; j++)
+            {
+                side->td.vects.quark.vects[0][j] = aa * TexPt[0][j] + bb * TexPt[1][j];
+                side->td.vects.quark.vects[1][j] = -( /*cc */ bb * TexPt[0][j] + dd * TexPt[1][j]);
+            }
+
+            side->td.vects.quark.vects[0][3] = -DotProduct(side->td.vects.quark.vects[0], side->planepts[0]);
+            side->td.vects.quark.vects[1][3] = -DotProduct(side->td.vects.quark.vects[1], side->planepts[0]);
+        }
+
+        side->td.txcommand = g_TXcommand;                  // Quark stuff, but needs setting always
+    };
+
+    b->contents = contents = CheckBrushContents(b);
+
+    //
+    // origin brushes are removed, but they set
+    // the rotation origin for the rest of the brushes
+    // in the entity
+    //
+
+    if (contents == CONTENTS_ORIGIN)
+    {
+        char            string[MAXTOKEN];
+        vec3_t          origin;
+
+        b->contents = CONTENTS_SOLID;
+        CreateBrush(mapent->firstbrush + b->brushnum);     // to get sizes
+        b->contents = contents;
+
+        for (i = 0; i < NUM_HULLS; i++)
+        {
+            b->hulls[i].faces = NULL;
+        }
+
+        if (b->entitynum != 0)  // Ignore for WORLD (code elsewhere enforces no ORIGIN in world message)
+        {
+            VectorAdd(b->hulls[0].bounds.m_Mins, b->hulls[0].bounds.m_Maxs, origin);
+            VectorScale(origin, 0.5, origin);
+    
+            safe_snprintf(string, MAXTOKEN, "%i %i %i", (int)origin[0], (int)origin[1], (int)origin[2]);
+            SetKeyValue(&g_entities[b->entitynum], "origin", string);
+        }
+    }
+
+    return contents;
+}
+
+
+// =====================================================================================
+//  ParseMapEntity
+//      parse an entity from script
+// =====================================================================================
+bool            ParseMapEntity()
+{
+    bool            all_clip = true;
+    int             this_entity;
+    entity_t*       mapent;
+    epair_t*        e;
+
+    if (!GetToken(true))
+    {
+        return false;
+    }
+
+    this_entity = g_numentities;
+
+    if (strcmp(g_token, "{"))
+    {
+        Error("Parsing Entity %i, expected '{' got '%s'", this_entity, g_token);
+    }
+
+    hlassume(g_numentities < MAX_MAP_ENTITIES, assume_MAX_MAP_ENTITIES);
+    g_numentities++;
+
+    mapent = &g_entities[this_entity];
+    mapent->firstbrush = g_nummapbrushes;
+    mapent->numbrushes = 0;
+
+    while (1)
+    {
+        if (!GetToken(true))
+            Error("ParseEntity: EOF without closing brace");
+
+        if (!strcmp(g_token, "}"))  // end of our context
+            break;
+
+        if (!strcmp(g_token, "{"))  // must be a brush
+        {
+            contents_t contents = ParseBrush(mapent);
+
+            if ((contents != CONTENTS_CLIP) && (contents != CONTENTS_ORIGIN))
+                all_clip = false;
+        }
+        else                        // else assume an epair
+        {
+            e = ParseEpair();
+
+            if (!strcmp(e->key, "mapversion"))
+            {
+                g_nMapFileVersion = atoi(e->value);
+            }
+
+            e->next = mapent->epairs;
+            mapent->epairs = e;
+        }
+    }
+
+
+    if (mapent->numbrushes && all_clip)
+        Fatal(assume_NO_VISIBILE_BRUSHES, "Entity %i has no visible brushes\n", this_entity);
+
+    CheckFatal();
+
+    
+#ifdef ZHLT_DETAIL // AJM
+    if (!strcmp(ValueForKey(mapent, "classname"), "info_detail") && g_bDetailBrushes && this_entity != 0)
+    {
+        // mark all of the brushes in this entity as contents_detail
+        for (int i = mapent->firstbrush; i < mapent->firstbrush + mapent->numbrushes; i++)
+        {
+            g_mapbrushes[i].contents = CONTENTS_DETAIL;
+        }
+
+        // move these brushes to worldspawn
+        {
+            brush_t*        temp;
+            int             newbrushes;
+            int             worldbrushes;
+            int             i;
+
+            newbrushes = mapent->numbrushes;
+            worldbrushes = g_entities[0].numbrushes;
+
+            temp = (brush_t*)Alloc(newbrushes * sizeof(brush_t));
+            memcpy(temp, g_mapbrushes + mapent->firstbrush, newbrushes * sizeof(brush_t));
+
+            for (i = 0; i < newbrushes; i++)
+            {
+                temp[i].entitynum = 0;
+            }
+
+            // make space to move the brushes (overlapped copy)
+            memmove(g_mapbrushes + worldbrushes + newbrushes,
+                    g_mapbrushes + worldbrushes, sizeof(brush_t) * (g_nummapbrushes - worldbrushes - newbrushes));
+
+            // copy the new brushes down
+            memcpy(g_mapbrushes + worldbrushes, temp, sizeof(brush_t) * newbrushes);
+
+            // fix up indexes
+            g_numentities--;
+            g_entities[0].numbrushes += newbrushes;
+            for (i = 1; i < g_numentities; i++)
+            {
+                g_entities[i].firstbrush += newbrushes;
+            }
+            memset(mapent, 0, sizeof(*mapent));
+            Free(temp);
+        }
+
+        // delete this entity
+        g_numentities--;
+        return true;
+    }
+#endif
+
+
+#ifdef ZHLT_INFO_COMPILE_PARAMETERS // AJM
+    if (!strcmp(ValueForKey(mapent, "classname"), "info_compile_parameters"))
+    {
+        GetParamsFromEnt(mapent);
+    }
+#endif
+
+    // if its the worldspawn entity and we need to skyclip, then do it
+    if ((this_entity == 0) && g_skyclip)                  // first entitiy
+    {
+        HandleSKYCLIP();
+    }
+
+    // if the given entity only has one brush and its an origin brush
+    if ((mapent->numbrushes == 1) && (g_mapbrushes[mapent->firstbrush].contents == CONTENTS_ORIGIN))
+    {
+        brushhull_t*    hull = g_mapbrushes[mapent->firstbrush].hulls;
+
+        Error("Entity %i, contains ONLY an origin brush near (%.0f,%.0f,%.0f)\n",
+              this_entity, hull->bounds.m_Mins[0], hull->bounds.m_Mins[1], hull->bounds.m_Mins[2]);
+    }
+
+    GetVectorForKey(mapent, "origin", mapent->origin);
+
+    // group entities are just for editor convenience
+    // toss all brushes into the world entity
+    if (!g_onlyents && !strcmp("func_group", ValueForKey(mapent, "classname")))
+    {
+        // this is pretty gross, because the brushes are expected to be
+        // in linear order for each entity
+        brush_t*        temp;
+        int             newbrushes;
+        int             worldbrushes;
+        int             i;
+
+        newbrushes = mapent->numbrushes;
+        worldbrushes = g_entities[0].numbrushes;
+
+        temp = (brush_t*)Alloc(newbrushes * sizeof(brush_t));
+        memcpy(temp, g_mapbrushes + mapent->firstbrush, newbrushes * sizeof(brush_t));
+
+        for (i = 0; i < newbrushes; i++)
+        {
+            temp[i].entitynum = 0;
+        }
+
+        // make space to move the brushes (overlapped copy)
+        memmove(g_mapbrushes + worldbrushes + newbrushes,
+                g_mapbrushes + worldbrushes, sizeof(brush_t) * (g_nummapbrushes - worldbrushes - newbrushes));
+
+        // copy the new brushes down
+        memcpy(g_mapbrushes + worldbrushes, temp, sizeof(brush_t) * newbrushes);
+
+        // fix up indexes
+        g_numentities--;
+        g_entities[0].numbrushes += newbrushes;
+        for (i = 1; i < g_numentities; i++)
+        {
+            g_entities[i].firstbrush += newbrushes;
+        }
+        memset(mapent, 0, sizeof(*mapent));
+        Free(temp);
+    }
+
+    return true;
+}
+
+// =====================================================================================
+//  CountEngineEntities
+// =====================================================================================
+unsigned int    CountEngineEntities()
+{
+    unsigned int x;
+    unsigned num_engine_entities = 0;
+    entity_t*       mapent = g_entities;
+
+    // for each entity in the map
+    for (x=0; x<g_numentities; x++, mapent++)
+    {
+        const char* classname = ValueForKey(mapent, "classname");
+
+        // if its a light_spot or light_env, dont include it as an engine entity!
+        if (classname)
+        {
+            if (   !strncasecmp(classname, "light", 5) 
+                || !strncasecmp(classname, "light_spot", 10) 
+                || !strncasecmp(classname, "light_environment", 17)
+               )
+            {
+                const char* style = ValueForKey(mapent, "style");
+                const char* targetname = ValueForKey(mapent, "targetname");
+
+                // lightspots and lightenviroments dont have a targetname or style
+                if (!strlen(targetname) && !atoi(style))
+                {
+                    continue;
+                }
+            }
+        }
+
+        num_engine_entities++;
+    }
+
+    return num_engine_entities;
+}
+
+// =====================================================================================
+//  LoadMapFile
+//      wrapper for LoadScriptFile
+//      parse in script entities
+// =====================================================================================
+const char*     ContentsToString(const contents_t type);
+
+void            LoadMapFile(const char* const filename)
+{
+    unsigned num_engine_entities;
+
+    LoadScriptFile(filename);
+
+    g_numentities = 0;
+
+    while (ParseMapEntity())
+    {
+    }
+
+    // AJM debug
+    /*
+    for (int i = 0; i < g_numentities; i++)
+    {
+        Log("entity: %i - %i brushes - %s\n", i, g_entities[i].numbrushes, ValueForKey(&g_entities[i], "classname"));
+    }
+    Log("total entities: %i\ntotal brushes: %i\n\n", g_numentities, g_nummapbrushes);
+
+    for (i = g_entities[0].firstbrush; i < g_entities[0].firstbrush + g_entities[0].numbrushes; i++)
+    {
+        Log("worldspawn brush %i: contents %s\n", i, ContentsToString((contents_t)g_mapbrushes[i].contents)); 
+    }
+    */
+
+    num_engine_entities = CountEngineEntities();
+
+    hlassume(num_engine_entities < MAX_ENGINE_ENTITIES, assume_MAX_ENGINE_ENTITIES);
+
+    CheckFatal();
+
+    Verbose("Load map:%s\n", filename);
+    Verbose("%5i brushes\n", g_nummapbrushes);
+    Verbose("%5i map entities \n", g_numentities - num_engine_entities);
+    Verbose("%5i engine entities\n", num_engine_entities);
+
+    // AJM: added in 
+#ifdef HLCSG_AUTOWAD
+    GetUsedTextures();
+#endif
+}

+ 0 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/netvis_in_vis.cpp


+ 50 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/properties.cpp

@@ -0,0 +1,50 @@
+//KGP -- added in for use with HLCSG_NULLIFY_INVISIBLE
+
+#include "csg.h"
+
+#ifdef HLCSG_NULLIFY_INVISIBLE
+#include <fstream>
+#include <istream>
+using namespace std;
+
+set<string> g_invisible_items;
+
+void properties_initialize(const char* filename)
+{
+    if (filename == NULL)
+    { return; }
+
+    if (q_exists(filename))
+    { Log("Loading null entity list from '%s'\n", filename); }
+    else
+    {
+		Error("Could not find null entity list file '%s'\n", filename);
+        return;
+    }
+
+	ifstream file(filename,ios::in);
+	if(!file)
+	{ 
+		file.close();
+		return; 
+	}
+
+
+	//begin reading list of items
+	char line[ZHLT3_MAX_VALUE];
+	memset(line,0,sizeof(char)*4096);
+	int numitems = 0;
+	char* str = NULL;
+	char** list = NULL;
+	while(!file.eof())
+	{
+		string str;
+		getline(file,str);
+		if(str.size() < 1)
+		{ continue; }
+		g_invisible_items.insert(str);
+	}
+	file.close();
+}
+
+#endif

File diff suppressed because it is too large
+ 1895 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/qcsg.cpp


+ 849 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/textures.cpp

@@ -0,0 +1,849 @@
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4996)
+#endif
+
+#include "csg.h"
+
+#define MAXWADNAME 16
+#define MAX_TEXFILES 128
+
+//  FindMiptex
+//  TEX_InitFromWad
+//  FindTexture
+//  LoadLump
+//  AddAnimatingTextures
+
+
+typedef struct
+{
+    char            identification[4];                     // should be WAD2/WAD3
+    int             numlumps;
+    int             infotableofs;
+} wadinfo_t;
+
+typedef struct
+{
+    int             filepos;
+    int             disksize;
+    int             size;                                  // uncompressed
+    char            type;
+    char            compression;
+    char            pad1, pad2;
+    char            name[MAXWADNAME];                      // must be null terminated
+
+    int             iTexFile;                              // index of the wad this texture is located in
+
+} lumpinfo_t;
+
+std::deque< std::string > g_WadInclude;
+std::map< int, bool > s_WadIncludeMap;
+
+static int      nummiptex = 0;
+static lumpinfo_t miptex[MAX_MAP_TEXTURES];
+static int      nTexLumps = 0;
+static lumpinfo_t* lumpinfo = NULL;
+static int      nTexFiles = 0;
+static FILE*    texfiles[MAX_TEXFILES];
+
+// fix for 64 bit machines
+#if SIZEOF_CHARP == 8
+    static char* texmap64[MAX_MAP_BRUSHES];
+    static int   tex_max64=0;
+
+    static inline int texmap64_store(char *texname)
+    {
+        int curr_tex;
+        ThreadLock();
+        if (tex_max64 >= MAX_MAP_BRUSHES)   // no assert?
+        {
+            printf("MAX_MAP_BRUSHES exceeded!\n");
+            exit(-1);
+        }
+        curr_tex = tex_max64;
+        texmap64[tex_max64] = texname;
+        tex_max64++;
+        ThreadUnlock();
+        return curr_tex;
+    }
+
+    static inline char* texmap64_retrieve( int index)
+    {
+        if(index > tex_max64)
+        {
+            printf("retrieving bogus texture index %d\n", index);
+            exit(-1);
+        }
+        return texmap64[index];
+    }
+
+#else // SIZEOF_CHARP != 8, almost certainly 4
+    #define texmap64_store( A ) ( (int) A)
+    #define texmap64_retrieve( A ) ( (char*) A)
+#endif // SIZEOF_CHARP
+
+// =====================================================================================
+//  CleanupName
+// =====================================================================================
+static void     CleanupName(const char* const in, char* out)
+{
+    int             i;
+
+    for (i = 0; i < MAXWADNAME; i++)
+    {
+        if (!in[i])
+        {
+            break;
+        }
+
+        out[i] = toupper(in[i]);
+    }
+
+    for (; i < MAXWADNAME; i++)
+    {
+        out[i] = 0;
+    }
+}
+
+// =====================================================================================
+//  lump_sorters
+// =====================================================================================
+
+static int CDECL lump_sorter_by_wad_and_name(const void* lump1, const void* lump2)
+{
+    lumpinfo_t*     plump1 = (lumpinfo_t*)lump1;
+    lumpinfo_t*     plump2 = (lumpinfo_t*)lump2;
+
+    if (plump1->iTexFile == plump2->iTexFile)
+    {
+        return strcmp(plump1->name, plump2->name);
+    }
+    else
+    {
+        return plump1->iTexFile - plump2->iTexFile;
+    }
+}
+
+static int CDECL lump_sorter_by_name(const void* lump1, const void* lump2)
+{
+    lumpinfo_t*     plump1 = (lumpinfo_t*)lump1;
+    lumpinfo_t*     plump2 = (lumpinfo_t*)lump2;
+
+    return strcmp(plump1->name, plump2->name);
+}
+
+// =====================================================================================
+//  FindMiptex
+//      Find and allocate a texture into the lump data
+// =====================================================================================
+static int      FindMiptex(const char* const name)
+{
+    int             i;
+
+    ThreadLock();
+    for (i = 0; i < nummiptex; i++)
+    {
+        if (!strcmp(name, miptex[i].name))
+        {
+            ThreadUnlock();
+            return i;
+        }
+    }
+
+    hlassume(nummiptex < MAX_MAP_TEXTURES, assume_MAX_MAP_TEXTURES);
+    safe_strncpy(miptex[i].name, name, MAXWADNAME);
+    nummiptex++;
+    ThreadUnlock();
+    return i;
+}
+
+// =====================================================================================
+//  TEX_InitFromWad
+// =====================================================================================
+bool            TEX_InitFromWad()
+{
+    int             i, j;
+    wadinfo_t       wadinfo;
+    char            szTmpWad[1024]; // arbitrary, but needs to be large.
+    char*           pszWadFile;
+    const char*     pszWadroot;
+    wadpath_t*      currentwad;
+
+	Log("\n\nChecking Wadfiles (max. expected texture size is %i bytes):\n\n", MAX_TEXTURE_SIZE); //SILENCER //Indentation and blank lines make it much easier to view
+
+    szTmpWad[0] = 0;
+    pszWadroot = getenv("WADROOT");
+
+#ifdef HLCSG_AUTOWAD
+    autowad_UpdateUsedWads();
+#endif
+
+    // for eachwadpath
+    for (i = 0; i < g_iNumWadPaths; i++)
+    {
+        FILE*           texfile;                           // temporary used in this loop
+        bool            bExcludeThisWad = false;
+
+        currentwad = g_pWadPaths[i];
+        pszWadFile = currentwad->path;
+
+
+#ifdef HLCSG_AUTOWAD
+        #ifdef _DEBUG
+        Log("[dbg] Attempting to parse wad: '%s'\n", pszWadFile);
+        #endif
+
+        if (g_bWadAutoDetect && !currentwad->usedtextures)
+            continue;
+
+        #ifdef _DEBUG
+        Log("[dbg] Parsing wad\n");
+        #endif
+#endif
+
+        texfiles[nTexFiles] = fopen(pszWadFile, "rb");
+
+        #ifdef SYSTEM_WIN32
+        if (!texfiles[nTexFiles])
+        {
+            // cant find it, maybe this wad file has a hard code drive
+            if (pszWadFile[1] == ':')
+            {
+                pszWadFile += 2;                           // skip past the drive
+                texfiles[nTexFiles] = fopen(pszWadFile, "rb");
+            }
+        }
+        #endif
+
+        if (!texfiles[nTexFiles] && pszWadroot)
+        {
+            char            szTmp[_MAX_PATH];
+            char            szFile[_MAX_PATH];
+            char            szSubdir[_MAX_PATH];
+
+            ExtractFile(pszWadFile, szFile);
+
+            ExtractFilePath(pszWadFile, szTmp);
+            ExtractFile(szTmp, szSubdir);
+
+            // szSubdir will have a trailing separator
+            safe_snprintf(szTmp, _MAX_PATH, "%s" SYSTEM_SLASH_STR "%s%s", pszWadroot, szSubdir, szFile);
+            texfiles[nTexFiles] = fopen(szTmp, "rb");
+
+            #ifdef SYSTEM_POSIX
+            if (!texfiles[nTexFiles])
+            {
+                // if we cant find it, Convert to lower case and try again
+                strlwr(szTmp);
+                texfiles[nTexFiles] = fopen(szTmp, "rb");
+            }
+            #endif
+        }
+
+        if (!texfiles[nTexFiles])
+        {
+            // still cant find it, error out
+			Log("  "); //SILENCER //Indentation and blank lines make it much easier to view
+            Fatal(assume_COULD_NOT_FIND_WAD, "Could not open wad file %s", pszWadFile);
+            continue;
+        }
+
+        // look and see if we're supposed to include the textures from this WAD in the bsp.
+        WadInclude_i it;
+        for (it = g_WadInclude.begin(); it != g_WadInclude.end(); it++)
+        {
+            if (stristr(pszWadFile, it->c_str()))
+            {
+				//SILENCER //Indentation and blank lines make it much easier to view
+				Log("  Including Wadfile: %s:\n", pszWadFile);
+                bExcludeThisWad = true;             // wadincluding this one
+                s_WadIncludeMap[nTexFiles] = true;
+                break;
+            }
+        }
+
+        if (!bExcludeThisWad)
+        {
+			//SILENCER //Indentation and blank lines make it much easier to view
+			Log("  Using Wadfile: %s:\n", pszWadFile);
+            safe_snprintf(szTmpWad, 1024, "%s%s;", szTmpWad, pszWadFile);
+        }
+
+        // temp assignment to make things cleaner:
+        texfile = texfiles[nTexFiles];
+
+        // read in this wadfiles information
+        SafeRead(texfile, &wadinfo, sizeof(wadinfo));
+
+        // make sure its a valid format
+        if (strncmp(wadinfo.identification, "WAD2", 4) && strncmp(wadinfo.identification, "WAD3", 4))
+        {
+            Log("    "); //SILENCER //Indentation and blank lines make it much easier to view
+            Error("%s isn't a Wadfile!", pszWadFile);
+        }
+
+        wadinfo.numlumps        = LittleLong(wadinfo.numlumps);
+        wadinfo.infotableofs    = LittleLong(wadinfo.infotableofs);
+
+        // read in lump
+		if (fseek(texfile, wadinfo.infotableofs, SEEK_SET)) {
+			Log("    "); //SILENCER //Indentation and blank lines make it much easier to view
+            Warning("fseek to %d in wadfile %s failed", wadinfo.infotableofs, pszWadFile);
+		}
+
+        // memalloc for this lump
+        lumpinfo = (lumpinfo_t*)realloc(lumpinfo, (nTexLumps + wadinfo.numlumps) * sizeof(lumpinfo_t));
+
+        // for each texlump
+        for (j = 0; j < wadinfo.numlumps; j++, nTexLumps++)
+        {
+            SafeRead(texfile, &lumpinfo[nTexLumps], (sizeof(lumpinfo_t) - sizeof(int)) );  // iTexFile is NOT read from file
+
+            if (!TerminatedString(lumpinfo[nTexLumps].name, MAXWADNAME))
+            {
+                lumpinfo[nTexLumps].name[MAXWADNAME - 1] = 0;
+                Log("    "); //SILENCER //Indentation and blank lines make it much easier to view
+                Warning("Unterminated texture name : wad[%s] texture[%d] name[%s]\n", pszWadFile, nTexLumps, lumpinfo[nTexLumps].name);
+            }
+
+            CleanupName(lumpinfo[nTexLumps].name, lumpinfo[nTexLumps].name);
+
+            lumpinfo[nTexLumps].filepos = LittleLong(lumpinfo[nTexLumps].filepos);
+            lumpinfo[nTexLumps].disksize = LittleLong(lumpinfo[nTexLumps].disksize);
+            lumpinfo[nTexLumps].iTexFile = nTexFiles;
+
+            if (lumpinfo[nTexLumps].disksize > MAX_TEXTURE_SIZE)
+            {
+                Log("    "); //SILENCER //Indentation and blank lines make it much easier to view
+                Warning("Larger than expected texture (%d bytes): '%s'",
+                    lumpinfo[nTexLumps].disksize, lumpinfo[nTexLumps].name);
+            }
+
+        }
+
+        // AJM: this feature is dependant on autowad. :(
+        // CONSIDER: making it standard?
+#ifdef HLCSG_AUTOWAD
+        {
+            double percused = ((float)(currentwad->usedtextures) / (float)(g_numUsedTextures)) * 100;
+			 //SILENCER //Indentation and blank lines make it much easier to view:
+            Log("    Contains %i used texture%s, %2.2f percent of map. (%d textures in wad)\n\n",
+                currentwad->usedtextures, currentwad->usedtextures == 1 ? "" : "s", percused, wadinfo.numlumps);
+        }
+#endif
+
+        nTexFiles++;
+        hlassume(nTexFiles < MAX_TEXFILES, assume_MAX_TEXFILES);
+    }
+
+    //Log("num of used textures: %i\n", g_numUsedTextures);
+
+    // AJM: Tommy suggested i add this warning message in, and  it certainly doesnt
+    // hurt to be cautious. Especially one of the possible side effects he mentioned was svc_bad
+    if (nTexFiles > 8)
+    {
+        Warning("More than 8 wadfiles are in use. (%i)\n"
+                "This may be harmless, and if no strange side effects are occurring, then\n"
+                "it can safely be ignored. However, if your map starts exhibiting strange\n"
+                "or obscure errors, consider this as suspect. One of the possible side\n"
+				"effects is getting an svc_bad error, by which a client drops from the game."
+                , nTexFiles); //SILENCER: Added the note about possible svc_bad to the warning message.
+    }
+
+    // sort texlumps in memory by name
+    qsort((void*)lumpinfo, (size_t) nTexLumps, sizeof(lumpinfo[0]), lump_sorter_by_name);
+
+    SetKeyValue(&g_entities[0], "wad", szTmpWad);
+
+    Log("\n");
+    CheckFatal();
+    return true;
+}
+
+// =====================================================================================
+//  FindTexture
+// =====================================================================================
+lumpinfo_t*     FindTexture(const lumpinfo_t* const source)
+{
+    //Log("** PnFNFUNC: FindTexture\n");
+
+    lumpinfo_t*     found = NULL;
+
+    found = (lumpinfo_t*)bsearch(source, (void*)lumpinfo, (size_t) nTexLumps, sizeof(lumpinfo[0]), lump_sorter_by_name);
+    if (!found)
+    {
+        Warning("::FindTexture() texture %s not found!", source->name);
+        if (!strcmp(source->name, "NULL"))
+        {
+            Log("Are you sure you included zhlt.wad in your wadpath list?\n");
+        }
+    }
+
+    return found;
+}
+
+// =====================================================================================
+//  TestIncludeTextureNamed
+//	check to see if this texture should never be included -- should fix problematic
+//	sky behavior.
+//
+//  TODO : fix any texture used by this code so that it is always contained in a
+//  non-included wad or throw warning and include anyway
+// =====================================================================================
+
+bool TestIncludeTextureNamed(const char* const name)
+{
+	bool shouldInclude = true;
+/*	switch(name[0])
+	{
+	case 'a': case 'A':
+		if(!stricmp(name,"AAATRIGGER"))
+		{ shouldInclude = false; }
+		break;
+	case 'c': case 'C':
+		if(!stricmp(name,"CLIP"))
+		{ shouldInclude = false; }
+		break;
+	case 'h': case 'H':
+		if(!stricmp(name,"HINT"))
+		{ shouldInclude = false; }
+		break;
+//	case 'n': case 'N':
+//		if(!stricmp(name,"NULL"))
+//		{ shouldInclude = false; }
+//		break;
+	case 'o': case 'O':
+		if(!stricmp(name,"ORIGIN"))
+		{ shouldInclude = false; }
+		break;
+	case 's': case 'S':
+		if(!stricmp(name,"SKY") || !stricmp(name,"SKIP"))
+		{ shouldInclude = false; }
+		break;
+	}
+*/
+	if(!shouldInclude)
+	{ Warning("Overriding inclusion of common texture: %s",name); }
+	return shouldInclude;
+}
+
+// =====================================================================================
+//  LoadLump
+// =====================================================================================
+int             LoadLump(const lumpinfo_t* const source, byte* dest, int* texsize)
+{
+    //Log("** PnFNFUNC: LoadLump\n");
+
+    *texsize = 0;
+    if (source->filepos)
+    {
+        if (fseek(texfiles[source->iTexFile], source->filepos, SEEK_SET)) {
+			Log("    "); //SILENCER //Indentation and blank lines make it much easier to view
+            Warning("fseek to %d failed\n", source->filepos);
+        }
+        *texsize = source->disksize;
+
+        bool wadinclude = false;
+        std::map< int, bool >::iterator it;
+        it = s_WadIncludeMap.find(source->iTexFile);
+        if (it != s_WadIncludeMap.end())
+        {
+            wadinclude = it->second;
+        }
+
+        // Should we just load the texture header w/o the palette & bitmap?
+        if ((g_wadtextures && !wadinclude) || !TestIncludeTextureNamed(source->name))
+        {
+            // Just read the miptex header and zero out the data offsets.
+            // We will load the entire texture from the WAD at engine runtime
+            int             i;
+            miptex_t*       miptex = (miptex_t*)dest;
+            SafeRead(texfiles[source->iTexFile], dest, sizeof(miptex_t));
+
+            for (i = 0; i < MIPLEVELS; i++)
+                miptex->offsets[i] = 0;
+            return sizeof(miptex_t);
+        }
+        else
+        {
+			Developer(DEVELOPER_LEVEL_MESSAGE,"Including texture %s\n",source->name);
+            // Load the entire texture here so the BSP contains the texture
+            SafeRead(texfiles[source->iTexFile], dest, source->disksize);
+            return source->disksize;
+        }
+    }
+	
+	Log("    "); //SILENCER //Indentation and blank lines make it much easier to view
+    Warning("::LoadLump() texture %s not found!", source->name);
+    return 0;
+}
+
+// =====================================================================================
+//  AddAnimatingTextures
+// =====================================================================================
+void            AddAnimatingTextures()
+{
+    int             base;
+    int             i, j, k;
+    char            name[MAXWADNAME];
+
+    base = nummiptex;
+
+    for (i = 0; i < base; i++)
+    {
+        if ((miptex[i].name[0] != '+') && (miptex[i].name[0] != '-'))
+        {
+            continue;
+        }
+
+        safe_strncpy(name, miptex[i].name, MAXWADNAME);
+
+        for (j = 0; j < 20; j++)
+        {
+            if (j < 10)
+            {
+                name[1] = '0' + j;
+            }
+            else
+            {
+                name[1] = 'A' + j - 10;  // alternate animation
+            }
+
+            // see if this name exists in the wadfile
+            for (k = 0; k < nTexLumps; k++)
+            {
+                if (!strcmp(name, lumpinfo[k].name))
+                {
+                    FindMiptex(name);                      // add to the miptex list
+                    break;
+                }
+            }
+        }
+    }
+
+    if (nummiptex - base)
+    {
+        Log("Added %i additional animating textures.\n\n", nummiptex - base);
+    }
+}
+
+// =====================================================================================
+//  GetWadPath
+// AJM: this sub is obsolete
+// =====================================================================================
+char*           GetWadPath()
+{
+    const char*     path = ValueForKey(&g_entities[0], "_wad");
+
+    if (!path || !path[0])
+    {
+        path = ValueForKey(&g_entities[0], "wad");
+        if (!path || !path[0])
+        {
+            Warning("no wadfile specified");
+            return strdup("");
+        }
+    }
+
+    return strdup(path);
+}
+
+// =====================================================================================
+//  WriteMiptex
+// =====================================================================================
+void            WriteMiptex()
+{
+    int             len, texsize, totaltexsize = 0;
+    byte*           data;
+    dmiptexlump_t*  l;
+    double          start, end;
+
+    g_texdatasize = 0;
+
+    start = I_FloatTime();
+    {
+        if (!TEX_InitFromWad())
+            return;
+
+        AddAnimatingTextures();
+    }
+    end = I_FloatTime();
+    Verbose("TEX_InitFromWad & AddAnimatingTextures elapsed time = %ldms\n", (long)(end - start));
+
+    start = I_FloatTime();
+    {
+        int             i;
+
+        for (i = 0; i < nummiptex; i++)
+        {
+            lumpinfo_t*     found;
+
+            found = FindTexture(miptex + i);
+            if (found)
+            {
+                miptex[i] = *found;
+            }
+            else
+            {
+                miptex[i].iTexFile = miptex[i].filepos = miptex[i].disksize = 0;
+            }
+        }
+    }
+    end = I_FloatTime();
+    Verbose("FindTextures elapsed time = %ldms\n", (long)(end - start));
+
+    start = I_FloatTime();
+    {
+        int             i;
+        texinfo_t*      tx = g_texinfo;
+
+        // Sort them FIRST by wadfile and THEN by name for most efficient loading in the engine.
+        qsort((void*)miptex, (size_t) nummiptex, sizeof(miptex[0]), lump_sorter_by_wad_and_name);
+
+        // Sleazy Hack 104 Pt 2 - After sorting the miptex array, reset the texinfos to point to the right miptexs
+        for (i = 0; i < g_numtexinfo; i++, tx++)
+        {
+            char*          miptex_name = texmap64_retrieve(tx->miptex);
+
+            tx->miptex = FindMiptex(miptex_name);
+
+            // Free up the originally strdup()'ed miptex_name
+            free(miptex_name);
+        }
+    }
+    end = I_FloatTime();
+    Verbose("qsort(miptex) elapsed time = %ldms\n", (long)(end - start));
+
+    start = I_FloatTime();
+    {
+        int             i;
+
+        // Now setup to get the miptex data (or just the headers if using -wadtextures) from the wadfile
+        l = (dmiptexlump_t*)g_dtexdata;
+        data = (byte*) & l->dataofs[nummiptex];
+        l->nummiptex = nummiptex;
+        for (i = 0; i < nummiptex; i++)
+        {
+            l->dataofs[i] = data - (byte*) l;
+            len = LoadLump(miptex + i, data, &texsize);
+
+            if (!len)
+            {
+                l->dataofs[i] = -1;                        // didn't find the texture
+            }
+            else
+            {
+                totaltexsize += texsize;
+
+                hlassume(totaltexsize < g_max_map_miptex, assume_MAX_MAP_MIPTEX);
+            }
+            data += len;
+        }
+        g_texdatasize = data - g_dtexdata;
+    }
+    end = I_FloatTime();
+    Log("Texture usage is at %1.2f MB (of %1.2f MB max)\n", (float)totaltexsize / (1024 * 1024),
+        (float)g_max_map_miptex / (1024 * 1024));
+    Verbose("LoadLump() elapsed time = %ldms\n", (long)(end - start));
+}
+
+//==========================================================================
+
+// =====================================================================================
+//  TexinfoForBrushTexture
+// =====================================================================================
+int             TexinfoForBrushTexture(const plane_t* const plane, brush_texture_t* bt, const vec3_t origin)
+{
+    vec3_t          vecs[2];
+    int             sv, tv;
+    vec_t           ang, sinv, cosv;
+    vec_t           ns, nt;
+    texinfo_t       tx;
+    texinfo_t*      tc;
+    int             i, j, k;
+
+    memset(&tx, 0, sizeof(tx));
+	if(!strncmp(bt->name,"BEVEL",5))
+	{
+		tx.flags |= TEX_BEVEL;
+		safe_strncpy(bt->name,"NULL",5);
+	}
+    tx.miptex = FindMiptex(bt->name);
+
+    // Note: FindMiptex() still needs to be called here to add it to the global miptex array
+
+    // Very Sleazy Hack 104 - since the tx.miptex index will be bogus after we sort the miptex array later
+    // Put the string name of the miptex in this "index" until after we are done sorting it in WriteMiptex().
+    tx.miptex = texmap64_store(strdup(bt->name));
+
+    // set the special flag
+    if (bt->name[0] == '*'
+        || !strncasecmp(bt->name, "sky", 3)
+
+// =====================================================================================
+//Cpt_Andrew - Env_Sky Check
+// =====================================================================================
+        || !strncasecmp(bt->name, "env_sky", 5)
+// =====================================================================================
+
+        || !strncasecmp(bt->name, "clip", 4)
+        || !strncasecmp(bt->name, "origin", 6)
+#ifdef ZHLT_NULLTEX // AJM
+        || !strncasecmp(bt->name, "null", 4)
+#endif
+        || !strncasecmp(bt->name, "aaatrigger", 10)
+       )
+    {
+        tx.flags |= TEX_SPECIAL;
+    }
+
+    if (bt->txcommand)
+    {
+        memcpy(tx.vecs, bt->vects.quark.vects, sizeof(tx.vecs));
+        if (origin[0] || origin[1] || origin[2])
+        {
+            tx.vecs[0][3] += DotProduct(origin, tx.vecs[0]);
+            tx.vecs[1][3] += DotProduct(origin, tx.vecs[1]);
+        }
+    }
+    else
+    {
+        if (g_nMapFileVersion < 220)
+        {
+            TextureAxisFromPlane(plane, vecs[0], vecs[1]);
+        }
+
+        if (!bt->vects.valve.scale[0])
+        {
+            bt->vects.valve.scale[0] = 1;
+        }
+        if (!bt->vects.valve.scale[1])
+        {
+            bt->vects.valve.scale[1] = 1;
+        }
+
+        if (g_nMapFileVersion < 220)
+        {
+            // rotate axis
+            if (bt->vects.valve.rotate == 0)
+            {
+                sinv = 0;
+                cosv = 1;
+            }
+            else if (bt->vects.valve.rotate == 90)
+            {
+                sinv = 1;
+                cosv = 0;
+            }
+            else if (bt->vects.valve.rotate == 180)
+            {
+                sinv = 0;
+                cosv = -1;
+            }
+            else if (bt->vects.valve.rotate == 270)
+            {
+                sinv = -1;
+                cosv = 0;
+            }
+            else
+            {
+                ang = bt->vects.valve.rotate / 180 * Q_PI;
+                sinv = sin(ang);
+                cosv = cos(ang);
+            }
+
+            if (vecs[0][0])
+            {
+                sv = 0;
+            }
+            else if (vecs[0][1])
+            {
+                sv = 1;
+            }
+            else
+            {
+                sv = 2;
+            }
+
+            if (vecs[1][0])
+            {
+                tv = 0;
+            }
+            else if (vecs[1][1])
+            {
+                tv = 1;
+            }
+            else
+            {
+                tv = 2;
+            }
+
+            for (i = 0; i < 2; i++)
+            {
+                ns = cosv * vecs[i][sv] - sinv * vecs[i][tv];
+                nt = sinv * vecs[i][sv] + cosv * vecs[i][tv];
+                vecs[i][sv] = ns;
+                vecs[i][tv] = nt;
+            }
+
+            for (i = 0; i < 2; i++)
+            {
+                for (j = 0; j < 3; j++)
+                {
+                    tx.vecs[i][j] = vecs[i][j] / bt->vects.valve.scale[i];
+                }
+            }
+        }
+        else
+        {
+            vec_t           scale;
+
+            scale = 1 / bt->vects.valve.scale[0];
+            VectorScale(bt->vects.valve.UAxis, scale, tx.vecs[0]);
+
+            scale = 1 / bt->vects.valve.scale[1];
+            VectorScale(bt->vects.valve.VAxis, scale, tx.vecs[1]);
+        }
+
+        tx.vecs[0][3] = bt->vects.valve.shift[0] + DotProduct(origin, tx.vecs[0]);
+        tx.vecs[1][3] = bt->vects.valve.shift[1] + DotProduct(origin, tx.vecs[1]);
+    }
+
+    //
+    // find the g_texinfo
+    //
+    ThreadLock();
+    tc = g_texinfo;
+    for (i = 0; i < g_numtexinfo; i++, tc++)
+    {
+        // Sleazy hack 104, Pt 3 - Use strcmp on names to avoid dups
+        if (strcmp(texmap64_retrieve((tc->miptex)), texmap64_retrieve((tx.miptex))) != 0)
+        {
+            continue;
+        }
+        if (tc->flags != tx.flags)
+        {
+            continue;
+        }
+        for (j = 0; j < 2; j++)
+        {
+            for (k = 0; k < 4; k++)
+            {
+                if (tc->vecs[j][k] != tx.vecs[j][k])
+                {
+                    goto skip;
+                }
+            }
+        }
+        ThreadUnlock();
+        return i;
+skip:;
+    }
+
+    hlassume(g_numtexinfo < MAX_MAP_TEXINFO, assume_MAX_MAP_TEXINFO);
+
+    *tc = tx;
+    g_numtexinfo++;
+    ThreadUnlock();
+    return i;
+}
+

+ 461 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/wadcfg.cpp

@@ -0,0 +1,461 @@
+// AJM: ADDED THIS ENTIRE FILE IN
+
+#include "csg.h"
+#ifdef HLCSG_WADCFG
+
+//#ifdef SYSTEM_WIN32
+#if defined(SYSTEM_WIN32) && !defined( __GNUC__ )
+#   include "atlbase.h" // win32 registry API
+#pragma warning(disable:4996)
+#else
+char *g_apppath = NULL; //JK: Stores application path
+#endif
+
+#define WAD_CONFIG_FILE "wad.cfg"
+
+typedef struct wadname_s 
+{
+    char                    wadname[_MAX_PATH];
+    bool                    wadinclude;
+    struct wadname_s*       next;
+} wadname_t; 
+
+typedef struct wadconfig_s
+{
+    char                    name[_MAX_PATH];
+    int                     entries;
+    wadname_t*              firstentry;
+    wadconfig_s*            next;
+} wadconfig_t;
+
+wadconfig_t* g_WadCfg;  // anchor for the wadconfigurations linked list
+
+bool        g_bWadConfigsLoaded = false;
+int         g_wadcfglinecount = 1;
+
+//JK: added in
+char *g_wadcfgfile = NULL;
+
+// little helper function
+void stripwadpath (char *str)
+{
+    char *p = str + strlen (str) - 1;
+    while ((*p == ' ' || *p == '\n' || *p == '\t') && p >= str) *p-- = '\0';
+}
+
+// =====================================================================================
+//  WadCfgParseError
+// =====================================================================================
+void        WadCfgParseError(const char* message, int linenum, char* got)
+{
+    stripwadpath(got); // strip newlines
+
+    Log("Error parsing " WAD_CONFIG_FILE ", line %i:\n"
+        "%s, got '%s'\n", linenum, message, got);
+
+    Log("If you need help on usage of the wad.cfg file, be sure to check http://www.zhlt.info/using-wad.cfg.html that came"
+        " in the zip file with these tools.\n"); 
+
+    g_bWadConfigsLoaded = false;
+}
+
+// ============================================================================
+//  IsWhitespace
+// ============================================================================
+bool        IsWhitespace(const char ThinkChar)
+{
+    if ((ThinkChar == ' ') || (ThinkChar == '\t') || (ThinkChar == '\n') || (ThinkChar == 13) /* strange whitespace char */)
+        return true;
+
+    return false;
+}
+
+// ============================================================================
+//  Safe_GetToken
+// ============================================================================
+void        Safe_GetToken(FILE* source, char* TokenBuffer, const unsigned int MaxBufferLength)
+{
+    char    ThinkChar[1];       // 2 char array = thinkchar and null terminator
+    bool    InToken = false;    // are we getting a token?
+    bool    InQuotes = false;   // are we in quotes?
+    bool    InComment = false;  // are we in a comment (//)?
+    //fpos_t* sourcepos;
+    long    sourcepos;
+
+    TokenBuffer[0] = '\0';
+    ThinkChar[1] = '\0';
+    
+    while(!feof(source))
+    {
+        if (strlen(TokenBuffer) >= MaxBufferLength)
+            return;     // we cant add any more chars onto the buffer, its maxed out
+
+        ThinkChar[0] = fgetc(source);   
+        
+        if (ThinkChar[0] == '\n')              // newline
+        {
+            g_wadcfglinecount++;
+            InComment = false;
+        }
+
+        if (ThinkChar[0] == 'ÿ')
+            return;  
+                
+        if (IsWhitespace(ThinkChar[0]) && !InToken)
+            continue;   // whitespace before token, ignore
+
+        if (ThinkChar[0] == '"')               // quotes
+        {
+            if(InQuotes)
+                InQuotes = false;
+            else
+                InQuotes = true;
+            continue;   // dont include quotes
+        }
+
+        if (ThinkChar[0] == '/')             
+        {   
+            sourcepos = ftell(source);
+            // might be a comment, see if the next char is a forward slash
+            if (fgetc(source) == '/')    // if it is, were in a comment
+            {
+                InComment = true;
+                continue;
+            }
+            else // if not, rewind pretend nothing happened...
+            {
+                fseek(source, sourcepos, 0);
+            }
+        }
+
+        if (
+             (IsWhitespace(ThinkChar[0]) && InToken && !InQuotes) // whitespace AFTER token and not in quotes
+          || (InToken && InComment) // we hit a comment, and we have our token
+           )
+        {
+            //printf("[gt: %s]\n", TokenBuffer);
+            return;   
+        }
+
+        if (!InComment)
+        {
+            strcat(TokenBuffer, ThinkChar);
+            InToken = true;
+        }
+    }
+}
+
+// =====================================================================================
+//  GetWadConfig
+//      return true if we didnt encounter any fatal errors
+#define MAX_TOKENBUFFER _MAX_PATH
+// =====================================================================================
+bool        GetWadConfig(FILE* wadcfg, wadconfig_t* wadconfig)
+{
+    char            TokenBuffer[MAX_TOKENBUFFER];
+    wadname_t*      current;
+    wadname_t*      previous;
+
+    while (!feof(wadcfg))
+    {
+        Safe_GetToken(wadcfg, TokenBuffer, MAX_TOKENBUFFER);
+
+        if (!strcmp(TokenBuffer, "}"))
+            return true; // no more work to do
+        
+        if (!strcmp(TokenBuffer, ";"))
+            continue; // old seperator, no longer used but here for backwards compadibility
+
+        if (!strcmp(TokenBuffer, "{"))  // wtf
+        {
+            WadCfgParseError("Expected wadpath (Nested blocks illegal)", g_wadcfglinecount, TokenBuffer);
+            return false;
+        }
+
+        // otherwise assume its a wadpath, make an entry in this configuration
+        current = (wadname_t*)malloc(sizeof(wadname_t));
+        wadconfig->entries++;
+        current->next = NULL;
+        current->wadinclude = false;
+
+        if (!strcmp(TokenBuffer, "include"))
+        {
+            current->wadinclude = true;
+            Safe_GetToken(wadcfg, TokenBuffer, MAX_TOKENBUFFER);
+        }
+        
+        strcpy_s(current->wadname, TokenBuffer);
+        
+        if (!wadconfig->firstentry)
+        {
+            wadconfig->firstentry = current;
+        }
+        else
+        {
+            previous->next = current;
+        }
+
+        previous = current;
+        previous->next = NULL;
+    }
+
+    safe_snprintf(TokenBuffer, MAX_TOKENBUFFER, "Unexptected end of file encountered while parsing configuration '%s'", wadconfig->name);
+    WadCfgParseError(TokenBuffer, g_wadcfglinecount, "(eof)");
+    return false; 
+}
+#undef MAX_TOKENBUFFER
+
+// =====================================================================================
+//  LoadWadConfigFile
+// =====================================================================================
+void        LoadWadConfigFile()
+{
+    FILE*           wadcfg;
+    wadconfig_t*    current;
+    wadconfig_t*    previous;
+
+    char            temp[_MAX_PATH];
+
+    //JK: If exists lets use user-defined file
+    if (g_wadcfgfile && q_exists(g_wadcfgfile))
+    {
+    	wadcfg = fopen(g_wadcfgfile, "r");
+    }
+    else // find the wad.cfg file
+    {
+        char    appdir[_MAX_PATH];
+        char    tmp[_MAX_PATH];
+                
+        memset(tmp, 0, sizeof(tmp));
+        memset(appdir, 0, sizeof(appdir));
+
+        // Get application directory (only an approximation on posix systems)
+        // try looking in the directory we were run from
+        #ifdef SYSTEM_WIN32
+        GetModuleFileName(NULL, tmp, _MAX_PATH);
+        #else
+        safe_strncpy(tmp, g_apppath, _MAX_PATH);
+        #endif
+    
+        ExtractFilePath(tmp, appdir);
+        safe_snprintf(tmp, _MAX_PATH, "%s%s", appdir, WAD_CONFIG_FILE);
+
+        #ifdef _DEBUG
+        Log("[dbg] Trying '%s'\n", tmp);
+        #endif
+
+        if (!q_exists(tmp))
+        {
+            // try the Half-Life directory
+            #ifdef SYSTEM_WIN32
+            {
+                HKEY        HLMachineKey;
+                DWORD       disposition;
+                DWORD       dwType, dwSize;
+
+                // REG: create machinekey
+                RegCreateKeyEx(HKEY_LOCAL_MACHINE, TEXT("Software\\Valve\\Half-Life"), 0, NULL,  
+                                                        0, 0, NULL, &HLMachineKey, &disposition);
+                // REG: get hl dir 
+                dwType = REG_SZ;
+                dwSize = _MAX_PATH;
+                RegQueryValueEx(HLMachineKey, TEXT("InstallPath"), NULL, &dwType, (PBYTE)&appdir, &dwSize);
+            }
+            
+            safe_strncpy(tmp, appdir, _MAX_PATH);
+            safe_strncat(tmp, SYSTEM_SLASH_STR, _MAX_PATH); // system slash pointless as this will only work on win32, but anyway...
+            safe_strncat(tmp, WAD_CONFIG_FILE, _MAX_PATH);
+
+            #ifdef _DEBUG
+            Log("[dbg] Trying '%s'\n", tmp);
+           #endif
+
+            if (!q_exists(tmp))
+            #endif  // SYSTEM_WIN32
+            {
+                // still cant find it, error out
+                Log("Warning: could not find wad configurations file\n"
+                    "Make sure that wad.cfg is in the Half-Life directory or the current working directory\n"
+                   );
+                return;
+            }
+        }
+
+        wadcfg = fopen(tmp, "r");
+    }
+
+    if (!wadcfg)
+    {
+        // cant open it, die
+        Log("Warning: could not open the wad configurations file\n"
+            "Make sure that wad.cfg is in the Half-Life directory or the current working directory\n"
+            );
+        return;
+    }
+
+    while(!feof(wadcfg))
+    {
+        Safe_GetToken(wadcfg, temp, MAX_WAD_CFG_NAME);
+
+        if (!strcmp(temp, "HalfLifePath="))  // backwards compadibitly
+        {
+            Safe_GetToken(wadcfg, temp, MAX_WAD_CFG_NAME); 
+            Warning("Redundant line in " WAD_CONFIG_FILE ": \"HalfLifePath= %s\" - Ignoring...\n",
+                temp);
+            continue;
+        }
+
+        if (feof(wadcfg))
+            break;
+
+        // assume its the name of a configuration
+        current = (wadconfig_t*)malloc(sizeof(wadconfig_t));
+        safe_strncpy(current->name, temp, _MAX_PATH);
+        current->entries = 0;
+        current->next = NULL;
+        current->firstentry = NULL;
+
+        // make sure the next char starts a wad configuration
+        Safe_GetToken(wadcfg, temp, _MAX_PATH);
+        if (strcmp(temp, "{"))
+        {
+            WadCfgParseError("Expected start of wadfile configuration, '{'", g_wadcfglinecount, temp);
+            //Log("[dbg] temp[0] is %i\n", temp[0]);
+            fclose(wadcfg);
+            return;
+        }
+
+        // otherwise were ok, get the definition
+        if (!GetWadConfig(wadcfg, current))
+        {
+            fclose(wadcfg);
+            return;
+        }
+
+        // add this config to the list
+        if (!g_WadCfg)
+        {
+            g_WadCfg = current;
+        }
+        else
+        {
+            previous->next = current;
+        }
+
+        previous = current;
+        previous->next = NULL;
+    }
+
+    g_bWadConfigsLoaded = true;
+}
+
+// =====================================================================================
+//  ProcessWadConfiguration
+// =====================================================================================
+void        ProcessWadConfiguration()
+{
+    int             usedwads = 0;
+    char            szTmp[1024]; // arbitrary, but needs to be large. probably bigger than this.
+    wadconfig_t*    config;
+    wadname_t*      path;
+
+    if(!g_bWadConfigsLoaded) // we did a graceful exit due to some warning/error, so dont complain about it
+    {
+        Log("Using mapfile wad configuration\n");
+        return;
+    }
+
+    szTmp[0] = 0;
+    config = g_WadCfg;
+
+    if (!wadconfigname)
+        return; // this should never happen
+
+    if (!config)
+    {
+        Warning("No configurations detected in wad.cfg\n"
+                "using map wad configuration");
+        return;
+    }
+
+    while (1)
+    {
+        if (!strcmp(config->name, wadconfigname))
+        {
+            path = config->firstentry;
+            while (1)
+            {
+                if (!path)
+                    break;
+
+                Verbose("Wadpath from wad.cfg: '%s'\n", path->wadname);
+                PushWadPath(path->wadname, true);
+                safe_snprintf(szTmp, 1024, "%s%s;", szTmp, path->wadname);
+                usedwads++;
+
+                if (path->wadinclude)
+                    g_WadInclude.push_back(path->wadname);
+
+                // next path
+                path = path->next;
+            }
+            break;  // the user can only specify one wad configuration, were done here
+        }
+
+        // next config
+        config = config->next;
+        if (!config)
+            break;
+    }
+    
+    if (usedwads)
+    {
+        Log("Using custom wadfile configuration: '%s' (with %i wad%s)\n", wadconfigname, usedwads, usedwads > 1 ? "s" : "");
+        SetKeyValue(&g_entities[0], "wad", szTmp);
+        SetKeyValue(&g_entities[0], "_wad", szTmp);    
+    }
+    else
+    {
+        Warning("no wadfiles are specified in configuration '%s' --\n"
+                "Using map wadfile configuration", wadconfigname);
+        g_bWadConfigsLoaded = false;
+    }
+
+    return;
+}
+
+// =====================================================================================
+//  WadCfg_cleanup
+// =====================================================================================
+void        WadCfg_cleanup()
+{
+    wadconfig_t*    config;
+    wadconfig_t*    nextconfig;
+    wadname_t*      path;
+    wadname_t*      nextpath;
+
+    config = g_WadCfg;
+    while (config)
+    {
+        path = config->firstentry;
+        while (path)
+        {
+            nextpath = path->next;
+            free(path);
+            path = nextpath;
+        }
+
+        nextconfig = config->next;
+        free(config);
+        config = nextconfig;
+    }
+
+	g_WadCfg = NULL;
+	g_bWadConfigsLoaded = false;
+    return;
+}
+
+
+
+#endif // HLCSG_WADCFG
+

+ 203 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/wadinclude.cpp

@@ -0,0 +1,203 @@
+#pragma warning(disable:4267) // 'size_t' to 'unsigned int', possible loss of data
+
+#include "csg.h"
+
+#ifdef HAVE_UNISTD_E
+#include <unistd.h>
+#endif
+
+void            LoadWadincludeFile(const char* const filename)
+{
+    char*           fname;
+    int             i, x;
+    char*           pData = NULL;
+    char*           pszData;
+    unsigned        len = strlen(filename) + 5;
+
+    fname = (char*)Alloc(len);
+    safe_snprintf(fname, len, "%s.wic", filename);
+
+    if (q_exists(fname))
+    {
+        i = LoadFile(fname, &pData);
+
+        if (i == 0)
+        {
+            goto LoadWadincludeFileReturn;
+        }
+    }
+    else
+    {
+        Warning("WadInclude file %s does not exist", fname);
+        goto LoadWadincludeFileReturn;
+    }
+
+    for (pszData = pData, x = 0; x < i; x++)
+    {
+        if (pData[x] == ';')
+        {
+            pData[x] = 0;
+            g_WadInclude.push_back(pszData);
+            pszData = pData + x + 1;
+        }
+    }
+
+LoadWadincludeFileReturn:;
+    Free(fname);
+    if (pData)
+    {
+        Free(pData);
+    }
+}
+
+void            SaveWadincludeFile(const char* const filename)
+{
+    char*           fname;
+    FILE*           file;
+    int             x;
+    unsigned        len = strlen(filename) + 5;
+
+    fname = (char*)Alloc(len);
+    safe_snprintf(fname, len, "%s.wic", filename);
+
+    _unlink(fname);
+
+    file = SafeOpenWrite(fname);
+
+    WadInclude_i it;
+    for (it = g_WadInclude.begin(); it != g_WadInclude.end(); it++)
+    {
+        x = it->size();
+        if (x)
+        {
+            SafeWrite(file, it->c_str(), x);
+            SafeWrite(file, ";", 1);
+        }
+    }
+
+    Free(fname);
+    fclose(file);
+}
+
+// this function is called in place of tex_initfromwad for onlyents compiles
+void            HandleWadinclude()
+{
+    int             i;
+    char            szTmpWad[1024]; // arbitrary, but needs to be large.
+    char*           pszWadFile;
+    wadpath_t*      currentwad;
+
+    Log("\n\nChecking Wadfiles:\n\n"); //SILENCER //Indentation and blank lines make it much easier to view
+
+    szTmpWad[0] = 0;
+
+#ifdef HLCSG_AUTOWAD
+    if (g_bWadAutoDetect)
+    {
+        autowad_UpdateUsedWads();
+    }
+#endif
+
+    // for eachwadpath
+    for (i = 0; i < g_iNumWadPaths; i++)
+    {
+        bool            bExcludeThisWad = false;
+
+        currentwad = g_pWadPaths[i];
+        pszWadFile = currentwad->path;
+        
+#ifdef HLCSG_AUTOWAD/*
+    #ifdef _DEBUG
+        Log("[dbg] HandleWIC: attempting to parse wad '%s'\n", currentwad->path);
+    #endif*/
+        if (g_bWadAutoDetect && !currentwad->usedtextures)
+            continue;/*
+    #ifdef _DEBUG
+        Log("[dbg] HandleWIC: parsing wad\n");
+    #endif*/
+#endif // HLCSG_AUTOWAD
+
+        // look and see if we're supposed to include the textures from this WAD in the bsp.
+        WadInclude_i it;
+        for (it = g_WadInclude.begin(); it != g_WadInclude.end(); it++)
+        {
+            if (stristr(pszWadFile, it->c_str()))
+            {
+				Log("  Including Wadfile: %s:\n", pszWadFile); //SILENCER //Indentation and blank lines make it much easier to view
+                bExcludeThisWad = true;             // wadincluding this one
+            }
+        }
+
+        if (!bExcludeThisWad)
+        {
+			Log("  Using Wadfile: %s:\n", pszWadFile); //SILENCER //Indentation and blank lines make it much easier to view
+            safe_snprintf(szTmpWad, 1024, "%s%s;", szTmpWad, pszWadFile);
+        }
+    }
+
+    Log("\"wad\" is \"%s\"\n", szTmpWad);
+
+    SetKeyValue(&g_entities[0], "wad", szTmpWad);
+
+    Log("\n");
+    CheckFatal();
+}
+
+#if 0
+void            HandleWadinclude()
+{
+    // Code somewhat copied from TEX_InitFromWad()
+
+    char            szTmpPath[MAXTOKEN];
+    char            szNewWad[MAXTOKEN];
+    char*           pszWadFile;
+    bool            bExcludeThisWad;
+
+    const char*     path = ValueForKey(&g_entities[0], "wad");
+    
+    szNewWad[0] = 0;
+    safe_strncpy(szTmpPath, path, MAXTOKEN);
+
+    // temporary kludge so we don't have to deal with no occurances of a semicolon
+    //  in the path name ..
+    if (strchr(szTmpPath, ';') == NULL)
+    {
+        safe_strncat(szTmpPath, ";", MAXTOKEN);
+    }
+
+    pszWadFile = strtok(szTmpPath, ";");
+
+    while (pszWadFile)
+    {
+        bExcludeThisWad = false;
+
+        // look and see if we're supposed to include the textures from this WAD in the bsp.
+        WadInclude_i it;
+        for (it = g_WadInclude.begin(); it != g_WadInclude.end(); it++)
+        {
+            if (stristr(pszWadFile, it->c_str()))
+            {
+                Log("Embedding textures from WAD File [%s] into BSP\n", pszWadFile);
+                bExcludeThisWad = true;
+            }
+        }
+
+        if (!bExcludeThisWad)
+        {
+            safe_strncat(szNewWad, pszWadFile, MAXTOKEN);
+            safe_strncat(szNewWad, ";", MAXTOKEN);
+        }
+
+        if (!bExcludeThisWad)
+        {
+            Log("Using WAD File: %s\n", pszWadFile);
+        }
+
+        // next wad file
+        pszWadFile = strtok(NULL, ";");
+    }
+
+    SetKeyValue(&g_entities[0], "wad", szNewWad);
+}
+
+#endif

+ 132 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/wadpath.cpp

@@ -0,0 +1,132 @@
+// AJM: added this file in
+
+#include "csg.h"
+
+wadpath_t*  g_pWadPaths[MAX_WADPATHS];
+int         g_iNumWadPaths = 0;    
+
+
+// =====================================================================================
+//  PushWadPath
+//      adds a wadpath into the wadpaths list, without duplicates
+// =====================================================================================
+void        PushWadPath(const char* const path, bool inuse)
+{
+    int         i;
+    wadpath_t*  current;
+
+    if (!strlen(path))
+        return; // no path
+
+    // check for pre-existing path
+    for (i = 0; i < g_iNumWadPaths; i++)
+    {
+        current = g_pWadPaths[i];
+
+        if (!strcmp(current->path, path))
+            return; 
+    }
+
+    current = (wadpath_t*)malloc(sizeof(wadpath_t));
+
+    safe_strncpy(current->path, path, _MAX_PATH);
+    current->usedbymap = inuse;
+    current->usedtextures = 0;  // should be updated later in autowad procedures
+
+    g_pWadPaths[g_iNumWadPaths++] = current;
+
+#ifdef _DEBUG
+    Log("[dbg] PushWadPath: %i[%s]\n", g_iNumWadPaths, path);
+#endif
+}
+
+// =====================================================================================
+//  IsUsedWadPath
+// =====================================================================================
+bool        IsUsedWadPath(const char* const path)
+{
+    int         i;
+    wadpath_t*  current;
+
+    for (i = 0; i < g_iNumWadPaths; i++)
+    {
+        current = g_pWadPaths[i];
+        if (!strcmp(current->path, path))
+        {
+            if (current->usedbymap)
+                return true;
+
+            return false;
+        }
+    }   
+
+    return false;
+}
+
+// =====================================================================================
+//  IsListedWadPath
+// =====================================================================================
+bool        IsListedWadPath(const char* const path)
+{
+    int         i;
+    wadpath_t*  current;
+
+    for (i = 0; i < g_iNumWadPaths; i++)
+    {
+        current = g_pWadPaths[i];
+        if (!strcmp(current->path, path))
+            return true;
+    }
+
+    return false;
+}
+
+// =====================================================================================
+//  FreeWadPaths
+// =====================================================================================
+void        FreeWadPaths()
+{
+    int         i;
+    wadpath_t*  current;
+
+    for (i = 0; i < g_iNumWadPaths; i++)
+    {
+        current = g_pWadPaths[i];
+        free(current);
+    }
+}
+
+// =====================================================================================
+//  GetUsedWads
+//      parse the "wad" keyvalue into wadpath_t structs
+// =====================================================================================
+void        GetUsedWads()
+{
+    const char* pszWadPaths;
+    char        szTmp[_MAX_PATH];
+    int         i, j;
+
+    pszWadPaths = ValueForKey(&g_entities[0], "wad");
+
+    for(i = 0; i < MAX_WADPATHS; i++)
+    {
+        memset(szTmp, 0, sizeof(szTmp));    // are you happy zipster?
+        for (j = 0; j < _MAX_PATH; j++, pszWadPaths++)
+        {
+            if (pszWadPaths[0] == ';')
+            {
+                pszWadPaths++;
+                PushWadPath(szTmp, true);
+                break;
+            }
+
+            if (pszWadPaths[0] == 0)
+            {
+                PushWadPath(szTmp, true); // fix by AmericanRPG for last wadpath ignorance bug
+                return;
+            }
+
+            szTmp[j] = pszWadPaths[0];
+        }
+    }
+}

+ 24 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlcsg/wadpath.h

@@ -0,0 +1,24 @@
+// AJM: added file in
+#ifndef WADPATH_H__
+#define WADPATH_H__
+
+#define MAX_WADPATHS 128    // arbitrary
+
+typedef struct    
+{
+    char            path[_MAX_PATH];
+    bool            usedbymap;        // does this map requrie this wad to be included in the bsp?
+    int             usedtextures;         // number of textures in this wad the map actually uses
+} wadpath_t;//!!! the above two are VERY DIFFERENT. ie (usedtextures == 0) != (usedbymap == false)
+
+extern wadpath_t*  g_pWadPaths[MAX_WADPATHS];
+extern int         g_iNumWadPaths;    
+
+
+extern void        PushWadPath(const char* const path, bool inuse);
+extern bool        IsUsedWadPath(const char* const path);
+extern bool        IsListedWadPath(const char* const path);
+extern void        FreeWadPaths();
+extern void        GetUsedWads();
+
+#endif // WADPATH_H__

+ 709 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/hlrad.mak

@@ -0,0 +1,709 @@
+# Microsoft Developer Studio Generated NMAKE File, Based on hlrad.dsp
+!IF "$(CFG)" == ""
+CFG=hlrad - Win32 Super_Debug
+!MESSAGE No configuration specified. Defaulting to hlrad - Win32 Super_Debug.
+!ENDIF 
+
+!IF "$(CFG)" != "hlrad - Win32 Release" && "$(CFG)" != "hlrad - Win32 Debug" && "$(CFG)" != "hlrad - Win32 Release w Symbols" && "$(CFG)" != "hlrad - Win32 Super_Debug"
+!MESSAGE Invalid configuration "$(CFG)" specified.
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE 
+!MESSAGE NMAKE /f "hlrad.mak" CFG="hlrad - Win32 Super_Debug"
+!MESSAGE 
+!MESSAGE Possible choices for configuration are:
+!MESSAGE 
+!MESSAGE "hlrad - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "hlrad - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE "hlrad - Win32 Release w Symbols" (based on "Win32 (x86) Console Application")
+!MESSAGE "hlrad - Win32 Super_Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE 
+!ERROR An invalid configuration is specified.
+!ENDIF 
+
+!IF "$(OS)" == "Windows_NT"
+NULL=
+!ELSE 
+NULL=nul
+!ENDIF 
+
+CPP=cl.exe
+RSC=rc.exe
+
+!IF  "$(CFG)" == "hlrad - Win32 Release"
+
+OUTDIR=.\Release
+INTDIR=.\Release
+# Begin Custom Macros
+OutDir=.\Release
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlrad.exe" "$(OUTDIR)\hlrad.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\lerp.obj"
+	-@erase "$(INTDIR)\lerp.sbr"
+	-@erase "$(INTDIR)\lightmap.obj"
+	-@erase "$(INTDIR)\lightmap.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\mathutil.obj"
+	-@erase "$(INTDIR)\mathutil.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\nomatrix.obj"
+	-@erase "$(INTDIR)\nomatrix.sbr"
+	-@erase "$(INTDIR)\qrad.obj"
+	-@erase "$(INTDIR)\qrad.sbr"
+	-@erase "$(INTDIR)\qradutil.obj"
+	-@erase "$(INTDIR)\qradutil.sbr"
+	-@erase "$(INTDIR)\resourcelock.obj"
+	-@erase "$(INTDIR)\resourcelock.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\sparse.obj"
+	-@erase "$(INTDIR)\sparse.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\trace.obj"
+	-@erase "$(INTDIR)\trace.sbr"
+	-@erase "$(INTDIR)\transfers.obj"
+	-@erase "$(INTDIR)\transfers.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vismatrix.obj"
+	-@erase "$(INTDIR)\vismatrix.sbr"
+	-@erase "$(INTDIR)\vismatrixutil.obj"
+	-@erase "$(INTDIR)\vismatrixutil.sbr"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(OUTDIR)\hlrad.bsc"
+	-@erase "$(OUTDIR)\hlrad.exe"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /GX /O2 /I "..\common" /I "..\template" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /D "STDC_HEADERS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlrad.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlrad.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\resourcelock.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\winding.sbr" \
+	"$(INTDIR)\lerp.sbr" \
+	"$(INTDIR)\lightmap.sbr" \
+	"$(INTDIR)\mathutil.sbr" \
+	"$(INTDIR)\nomatrix.sbr" \
+	"$(INTDIR)\qrad.sbr" \
+	"$(INTDIR)\qradutil.sbr" \
+	"$(INTDIR)\sparse.sbr" \
+	"$(INTDIR)\trace.sbr" \
+	"$(INTDIR)\transfers.sbr" \
+	"$(INTDIR)\vismatrix.sbr" \
+	"$(INTDIR)\vismatrixutil.sbr"
+
+"$(OUTDIR)\hlrad.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x400000,0x100000 /subsystem:console /incremental:no /pdb:"$(OUTDIR)\hlrad.pdb" /machine:I386 /out:"$(OUTDIR)\hlrad.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\resourcelock.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\winding.obj" \
+	"$(INTDIR)\lerp.obj" \
+	"$(INTDIR)\lightmap.obj" \
+	"$(INTDIR)\mathutil.obj" \
+	"$(INTDIR)\nomatrix.obj" \
+	"$(INTDIR)\qrad.obj" \
+	"$(INTDIR)\qradutil.obj" \
+	"$(INTDIR)\sparse.obj" \
+	"$(INTDIR)\trace.obj" \
+	"$(INTDIR)\transfers.obj" \
+	"$(INTDIR)\vismatrix.obj" \
+	"$(INTDIR)\vismatrixutil.obj"
+
+"$(OUTDIR)\hlrad.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "hlrad - Win32 Debug"
+
+OUTDIR=.\Debug
+INTDIR=.\Debug
+# Begin Custom Macros
+OutDir=.\Debug
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlrad.exe" "$(OUTDIR)\hlrad.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\lerp.obj"
+	-@erase "$(INTDIR)\lerp.sbr"
+	-@erase "$(INTDIR)\lightmap.obj"
+	-@erase "$(INTDIR)\lightmap.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\mathutil.obj"
+	-@erase "$(INTDIR)\mathutil.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\nomatrix.obj"
+	-@erase "$(INTDIR)\nomatrix.sbr"
+	-@erase "$(INTDIR)\qrad.obj"
+	-@erase "$(INTDIR)\qrad.sbr"
+	-@erase "$(INTDIR)\qradutil.obj"
+	-@erase "$(INTDIR)\qradutil.sbr"
+	-@erase "$(INTDIR)\resourcelock.obj"
+	-@erase "$(INTDIR)\resourcelock.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\sparse.obj"
+	-@erase "$(INTDIR)\sparse.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\trace.obj"
+	-@erase "$(INTDIR)\trace.sbr"
+	-@erase "$(INTDIR)\transfers.obj"
+	-@erase "$(INTDIR)\transfers.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(INTDIR)\vismatrix.obj"
+	-@erase "$(INTDIR)\vismatrix.sbr"
+	-@erase "$(INTDIR)\vismatrixutil.obj"
+	-@erase "$(INTDIR)\vismatrixutil.sbr"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(OUTDIR)\hlrad.bsc"
+	-@erase "$(OUTDIR)\hlrad.exe"
+	-@erase "$(OUTDIR)\hlrad.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /Gm /GX /Zi /Od /I "..\common" /I "..\template" /D "_DEBUG" /D "STDC_HEADERS" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlrad.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlrad.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\resourcelock.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\winding.sbr" \
+	"$(INTDIR)\lerp.sbr" \
+	"$(INTDIR)\lightmap.sbr" \
+	"$(INTDIR)\mathutil.sbr" \
+	"$(INTDIR)\nomatrix.sbr" \
+	"$(INTDIR)\qrad.sbr" \
+	"$(INTDIR)\qradutil.sbr" \
+	"$(INTDIR)\sparse.sbr" \
+	"$(INTDIR)\trace.sbr" \
+	"$(INTDIR)\transfers.sbr" \
+	"$(INTDIR)\vismatrix.sbr" \
+	"$(INTDIR)\vismatrixutil.sbr"
+
+"$(OUTDIR)\hlrad.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x1000000,0x100000 /subsystem:console /profile /map:"$(INTDIR)\hlrad.map" /debug /machine:I386 /out:"$(OUTDIR)\hlrad.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\resourcelock.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\winding.obj" \
+	"$(INTDIR)\lerp.obj" \
+	"$(INTDIR)\lightmap.obj" \
+	"$(INTDIR)\mathutil.obj" \
+	"$(INTDIR)\nomatrix.obj" \
+	"$(INTDIR)\qrad.obj" \
+	"$(INTDIR)\qradutil.obj" \
+	"$(INTDIR)\sparse.obj" \
+	"$(INTDIR)\trace.obj" \
+	"$(INTDIR)\transfers.obj" \
+	"$(INTDIR)\vismatrix.obj" \
+	"$(INTDIR)\vismatrixutil.obj"
+
+"$(OUTDIR)\hlrad.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "hlrad - Win32 Release w Symbols"
+
+OUTDIR=.\Release_w_Symbols
+INTDIR=.\Release_w_Symbols
+# Begin Custom Macros
+OutDir=.\Release_w_Symbols
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlrad.exe" "$(OUTDIR)\hlrad.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\lerp.obj"
+	-@erase "$(INTDIR)\lerp.sbr"
+	-@erase "$(INTDIR)\lightmap.obj"
+	-@erase "$(INTDIR)\lightmap.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\mathutil.obj"
+	-@erase "$(INTDIR)\mathutil.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\nomatrix.obj"
+	-@erase "$(INTDIR)\nomatrix.sbr"
+	-@erase "$(INTDIR)\qrad.obj"
+	-@erase "$(INTDIR)\qrad.sbr"
+	-@erase "$(INTDIR)\qradutil.obj"
+	-@erase "$(INTDIR)\qradutil.sbr"
+	-@erase "$(INTDIR)\resourcelock.obj"
+	-@erase "$(INTDIR)\resourcelock.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\sparse.obj"
+	-@erase "$(INTDIR)\sparse.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\trace.obj"
+	-@erase "$(INTDIR)\trace.sbr"
+	-@erase "$(INTDIR)\transfers.obj"
+	-@erase "$(INTDIR)\transfers.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(INTDIR)\vismatrix.obj"
+	-@erase "$(INTDIR)\vismatrix.sbr"
+	-@erase "$(INTDIR)\vismatrixutil.obj"
+	-@erase "$(INTDIR)\vismatrixutil.sbr"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(OUTDIR)\hlrad.bsc"
+	-@erase "$(OUTDIR)\hlrad.exe"
+	-@erase "$(OUTDIR)\hlrad.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MD /W3 /GX /Zi /O2 /I "..\common" /I "..\template" /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /D "STDC_HEADERS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlrad.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlrad.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\resourcelock.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\winding.sbr" \
+	"$(INTDIR)\lerp.sbr" \
+	"$(INTDIR)\lightmap.sbr" \
+	"$(INTDIR)\mathutil.sbr" \
+	"$(INTDIR)\nomatrix.sbr" \
+	"$(INTDIR)\qrad.sbr" \
+	"$(INTDIR)\qradutil.sbr" \
+	"$(INTDIR)\sparse.sbr" \
+	"$(INTDIR)\trace.sbr" \
+	"$(INTDIR)\transfers.sbr" \
+	"$(INTDIR)\vismatrix.sbr" \
+	"$(INTDIR)\vismatrixutil.sbr"
+
+"$(OUTDIR)\hlrad.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x400000,0x100000 /subsystem:console /pdb:none /map:"$(INTDIR)\hlrad.map" /debug /machine:I386 /out:"$(OUTDIR)\hlrad.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\resourcelock.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\winding.obj" \
+	"$(INTDIR)\lerp.obj" \
+	"$(INTDIR)\lightmap.obj" \
+	"$(INTDIR)\mathutil.obj" \
+	"$(INTDIR)\nomatrix.obj" \
+	"$(INTDIR)\qrad.obj" \
+	"$(INTDIR)\qradutil.obj" \
+	"$(INTDIR)\sparse.obj" \
+	"$(INTDIR)\trace.obj" \
+	"$(INTDIR)\transfers.obj" \
+	"$(INTDIR)\vismatrix.obj" \
+	"$(INTDIR)\vismatrixutil.obj"
+
+"$(OUTDIR)\hlrad.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ELSEIF  "$(CFG)" == "hlrad - Win32 Super_Debug"
+
+OUTDIR=.\Super_Debug
+INTDIR=.\Super_Debug
+# Begin Custom Macros
+OutDir=.\Super_Debug
+# End Custom Macros
+
+ALL : "$(OUTDIR)\hlrad.exe" "$(OUTDIR)\hlrad.bsc"
+
+
+CLEAN :
+	-@erase "$(INTDIR)\blockmem.obj"
+	-@erase "$(INTDIR)\blockmem.sbr"
+	-@erase "$(INTDIR)\bspfile.obj"
+	-@erase "$(INTDIR)\bspfile.sbr"
+	-@erase "$(INTDIR)\cmdlib.obj"
+	-@erase "$(INTDIR)\cmdlib.sbr"
+	-@erase "$(INTDIR)\filelib.obj"
+	-@erase "$(INTDIR)\filelib.sbr"
+	-@erase "$(INTDIR)\lerp.obj"
+	-@erase "$(INTDIR)\lerp.sbr"
+	-@erase "$(INTDIR)\lightmap.obj"
+	-@erase "$(INTDIR)\lightmap.sbr"
+	-@erase "$(INTDIR)\log.obj"
+	-@erase "$(INTDIR)\log.sbr"
+	-@erase "$(INTDIR)\mathlib.obj"
+	-@erase "$(INTDIR)\mathlib.sbr"
+	-@erase "$(INTDIR)\mathutil.obj"
+	-@erase "$(INTDIR)\mathutil.sbr"
+	-@erase "$(INTDIR)\messages.obj"
+	-@erase "$(INTDIR)\messages.sbr"
+	-@erase "$(INTDIR)\nomatrix.obj"
+	-@erase "$(INTDIR)\nomatrix.sbr"
+	-@erase "$(INTDIR)\qrad.obj"
+	-@erase "$(INTDIR)\qrad.sbr"
+	-@erase "$(INTDIR)\qradutil.obj"
+	-@erase "$(INTDIR)\qradutil.sbr"
+	-@erase "$(INTDIR)\resourcelock.obj"
+	-@erase "$(INTDIR)\resourcelock.sbr"
+	-@erase "$(INTDIR)\scriplib.obj"
+	-@erase "$(INTDIR)\scriplib.sbr"
+	-@erase "$(INTDIR)\sparse.obj"
+	-@erase "$(INTDIR)\sparse.sbr"
+	-@erase "$(INTDIR)\threads.obj"
+	-@erase "$(INTDIR)\threads.sbr"
+	-@erase "$(INTDIR)\trace.obj"
+	-@erase "$(INTDIR)\trace.sbr"
+	-@erase "$(INTDIR)\transfers.obj"
+	-@erase "$(INTDIR)\transfers.sbr"
+	-@erase "$(INTDIR)\vc60.idb"
+	-@erase "$(INTDIR)\vc60.pdb"
+	-@erase "$(INTDIR)\vismatrix.obj"
+	-@erase "$(INTDIR)\vismatrix.sbr"
+	-@erase "$(INTDIR)\vismatrixutil.obj"
+	-@erase "$(INTDIR)\vismatrixutil.sbr"
+	-@erase "$(INTDIR)\winding.obj"
+	-@erase "$(INTDIR)\winding.sbr"
+	-@erase "$(OUTDIR)\hlrad.bsc"
+	-@erase "$(OUTDIR)\hlrad.exe"
+	-@erase "$(OUTDIR)\hlrad.map"
+
+"$(OUTDIR)" :
+    if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
+
+CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\common" /I "..\template" /D "_DEBUG" /D "STDC_HEADERS" /D "WIN32" /D "_CONSOLE" /D "SYSTEM_WIN32" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\hlrad.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c 
+BSC32=bscmake.exe
+BSC32_FLAGS=/nologo /o"$(OUTDIR)\hlrad.bsc" 
+BSC32_SBRS= \
+	"$(INTDIR)\blockmem.sbr" \
+	"$(INTDIR)\bspfile.sbr" \
+	"$(INTDIR)\cmdlib.sbr" \
+	"$(INTDIR)\filelib.sbr" \
+	"$(INTDIR)\log.sbr" \
+	"$(INTDIR)\mathlib.sbr" \
+	"$(INTDIR)\messages.sbr" \
+	"$(INTDIR)\resourcelock.sbr" \
+	"$(INTDIR)\scriplib.sbr" \
+	"$(INTDIR)\threads.sbr" \
+	"$(INTDIR)\winding.sbr" \
+	"$(INTDIR)\lerp.sbr" \
+	"$(INTDIR)\lightmap.sbr" \
+	"$(INTDIR)\mathutil.sbr" \
+	"$(INTDIR)\nomatrix.sbr" \
+	"$(INTDIR)\qrad.sbr" \
+	"$(INTDIR)\qradutil.sbr" \
+	"$(INTDIR)\sparse.sbr" \
+	"$(INTDIR)\trace.sbr" \
+	"$(INTDIR)\transfers.sbr" \
+	"$(INTDIR)\vismatrix.sbr" \
+	"$(INTDIR)\vismatrixutil.sbr"
+
+"$(OUTDIR)\hlrad.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
+    $(BSC32) @<<
+  $(BSC32_FLAGS) $(BSC32_SBRS)
+<<
+
+LINK32=link.exe
+LINK32_FLAGS=binmode.obj /nologo /stack:0x1000000,0x100000 /subsystem:console /profile /map:"$(INTDIR)\hlrad.map" /debug /machine:I386 /out:"$(OUTDIR)\hlrad.exe" 
+LINK32_OBJS= \
+	"$(INTDIR)\blockmem.obj" \
+	"$(INTDIR)\bspfile.obj" \
+	"$(INTDIR)\cmdlib.obj" \
+	"$(INTDIR)\filelib.obj" \
+	"$(INTDIR)\log.obj" \
+	"$(INTDIR)\mathlib.obj" \
+	"$(INTDIR)\messages.obj" \
+	"$(INTDIR)\resourcelock.obj" \
+	"$(INTDIR)\scriplib.obj" \
+	"$(INTDIR)\threads.obj" \
+	"$(INTDIR)\winding.obj" \
+	"$(INTDIR)\lerp.obj" \
+	"$(INTDIR)\lightmap.obj" \
+	"$(INTDIR)\mathutil.obj" \
+	"$(INTDIR)\nomatrix.obj" \
+	"$(INTDIR)\qrad.obj" \
+	"$(INTDIR)\qradutil.obj" \
+	"$(INTDIR)\sparse.obj" \
+	"$(INTDIR)\trace.obj" \
+	"$(INTDIR)\transfers.obj" \
+	"$(INTDIR)\vismatrix.obj" \
+	"$(INTDIR)\vismatrixutil.obj"
+
+"$(OUTDIR)\hlrad.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
+    $(LINK32) @<<
+  $(LINK32_FLAGS) $(LINK32_OBJS)
+<<
+
+!ENDIF 
+
+.c{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.obj::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.c{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cpp{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+.cxx{$(INTDIR)}.sbr::
+   $(CPP) @<<
+   $(CPP_PROJ) $< 
+<<
+
+
+!IF "$(NO_EXTERNAL_DEPS)" != "1"
+!IF EXISTS("hlrad.dep")
+!INCLUDE "hlrad.dep"
+!ELSE 
+!MESSAGE Warning: cannot find "hlrad.dep"
+!ENDIF 
+!ENDIF 
+
+
+!IF "$(CFG)" == "hlrad - Win32 Release" || "$(CFG)" == "hlrad - Win32 Debug" || "$(CFG)" == "hlrad - Win32 Release w Symbols" || "$(CFG)" == "hlrad - Win32 Super_Debug"
+SOURCE=..\common\blockmem.cpp
+
+"$(INTDIR)\blockmem.obj"	"$(INTDIR)\blockmem.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\bspfile.cpp
+
+"$(INTDIR)\bspfile.obj"	"$(INTDIR)\bspfile.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\cmdlib.cpp
+
+"$(INTDIR)\cmdlib.obj"	"$(INTDIR)\cmdlib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\filelib.cpp
+
+"$(INTDIR)\filelib.obj"	"$(INTDIR)\filelib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\log.cpp
+
+"$(INTDIR)\log.obj"	"$(INTDIR)\log.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\mathlib.cpp
+
+"$(INTDIR)\mathlib.obj"	"$(INTDIR)\mathlib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\messages.cpp
+
+"$(INTDIR)\messages.obj"	"$(INTDIR)\messages.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\resourcelock.cpp
+
+"$(INTDIR)\resourcelock.obj"	"$(INTDIR)\resourcelock.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\scriplib.cpp
+
+"$(INTDIR)\scriplib.obj"	"$(INTDIR)\scriplib.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\threads.cpp
+
+"$(INTDIR)\threads.obj"	"$(INTDIR)\threads.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=..\common\winding.cpp
+
+"$(INTDIR)\winding.obj"	"$(INTDIR)\winding.sbr" : $(SOURCE) "$(INTDIR)"
+	$(CPP) $(CPP_PROJ) $(SOURCE)
+
+
+SOURCE=.\lerp.cpp
+
+"$(INTDIR)\lerp.obj"	"$(INTDIR)\lerp.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\lightmap.cpp
+
+"$(INTDIR)\lightmap.obj"	"$(INTDIR)\lightmap.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\mathutil.cpp
+
+"$(INTDIR)\mathutil.obj"	"$(INTDIR)\mathutil.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\nomatrix.cpp
+
+"$(INTDIR)\nomatrix.obj"	"$(INTDIR)\nomatrix.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\qrad.cpp
+
+"$(INTDIR)\qrad.obj"	"$(INTDIR)\qrad.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\qradutil.cpp
+
+"$(INTDIR)\qradutil.obj"	"$(INTDIR)\qradutil.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\sparse.cpp
+
+"$(INTDIR)\sparse.obj"	"$(INTDIR)\sparse.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\trace.cpp
+
+"$(INTDIR)\trace.obj"	"$(INTDIR)\trace.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\transfers.cpp
+
+"$(INTDIR)\transfers.obj"	"$(INTDIR)\transfers.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\vismatrix.cpp
+
+"$(INTDIR)\vismatrix.obj"	"$(INTDIR)\vismatrix.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+SOURCE=.\vismatrixutil.cpp
+
+"$(INTDIR)\vismatrixutil.obj"	"$(INTDIR)\vismatrixutil.sbr" : $(SOURCE) "$(INTDIR)"
+
+
+
+!ENDIF 
+

+ 761 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/hlrad.vcproj

@@ -0,0 +1,761 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="hlrad"
+	ProjectGUID="{1916D8FC-71DD-4D45-8066-80AB489D764A}"
+	TargetFrameworkVersion="131072"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+		<Platform
+			Name="x64"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory=".\Release"
+			IntermediateDirectory=".\Release"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			UseOfATL="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="0"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\Release/hlrad.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				UseUnicodeResponseFiles="false"
+				Optimization="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="..\common,..\template"
+				PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE,SYSTEM_WIN32,STDC_HEADERS,HLRAD_XTRA_LIGHTDATA"
+				StringPooling="true"
+				ExceptionHandling="1"
+				BufferSecurityCheck="false"
+				EnableFunctionLevelLinking="false"
+				EnableEnhancedInstructionSet="2"
+				FloatingPointModel="0"
+				RuntimeTypeInfo="false"
+				OpenMP="false"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Release/hlrad.pch"
+				AssemblerListingLocation=".\Release/"
+				ObjectFile=".\Release/"
+				ProgramDataBaseFileName=".\Release/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Release/hlrad.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\Release/hlrad.pdb"
+				SubSystem="1"
+				StackReserveSize="4194304"
+				StackCommitSize="1048576"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="0"
+				LinkTimeCodeGeneration="1"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+				TargetMachine="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|x64"
+			OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			UseOfATL="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			CharacterSet="0"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+				TypeLibraryName=".\Release/hlrad.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				UseUnicodeResponseFiles="false"
+				Optimization="3"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="..\common,..\template"
+				PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE,SYSTEM_WIN32,STDC_HEADERS,HLRAD_XTRA_LIGHTDATA"
+				StringPooling="true"
+				RuntimeLibrary="0"
+				BufferSecurityCheck="false"
+				EnableFunctionLevelLinking="true"
+				EnableEnhancedInstructionSet="0"
+				FloatingPointModel="0"
+				RuntimeTypeInfo="false"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Release/hlrad.pch"
+				AssemblerListingLocation=".\Release/"
+				ObjectFile=".\Release/"
+				ProgramDataBaseFileName=".\Release/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				Detect64BitPortabilityProblems="false"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Release/hlrad.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\Release/hlrad.pdb"
+				SubSystem="1"
+				StackReserveSize="4194304"
+				StackCommitSize="1048576"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				LinkTimeCodeGeneration="1"
+				TargetMachine="17"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory=".\Debug"
+			IntermediateDirectory=".\Debug"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\Debug/hlrad.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\common,..\template"
+				PreprocessorDefinitions="_DEBUG,STDC_HEADERS,WIN32,_CONSOLE,SYSTEM_WIN32,HLRAD_XTRA_LIGHTDATA"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Debug/hlrad.pch"
+				AssemblerListingLocation=".\Debug/"
+				ObjectFile=".\Debug/"
+				ProgramDataBaseFileName=".\Debug/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Debug/hlrad.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\Debug/hlrad.pdb"
+				GenerateMapFile="true"
+				MapFileName=".\Debug/hlrad.map"
+				SubSystem="1"
+				StackReserveSize="16777216"
+				StackCommitSize="1048576"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|x64"
+			OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+			IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TargetEnvironment="3"
+				TypeLibraryName=".\Debug/hlrad.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="..\common,..\template"
+				PreprocessorDefinitions="_DEBUG,STDC_HEADERS,WIN32,_CONSOLE,SYSTEM_WIN32,HLRAD_XTRA_LIGHTDATA"
+				RuntimeLibrary="2"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Debug/hlrad.pch"
+				AssemblerListingLocation=".\Debug/"
+				ObjectFile=".\Debug/"
+				ProgramDataBaseFileName=".\Debug/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				DebugInformationFormat="3"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="_DEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalOptions="/MACHINE:I386"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Debug/hlrad.exe"
+				LinkIncremental="2"
+				SuppressStartupBanner="true"
+				GenerateDebugInformation="true"
+				ProgramDatabaseFile=".\Debug/hlrad.pdb"
+				GenerateMapFile="true"
+				MapFileName=".\Debug/hlrad.map"
+				SubSystem="1"
+				StackReserveSize="16777216"
+				StackCommitSize="1048576"
+				TargetMachine="17"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|Win32"
+			OutputDirectory="$(ConfigurationName)"
+			IntermediateDirectory="$(ConfigurationName)"
+			ConfigurationType="1"
+			InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
+			UseOfMFC="0"
+			ATLMinimizesCRunTimeLibraryUsage="false"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+				TypeLibraryName=".\Release/hlrad.tlb"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				InlineFunctionExpansion="2"
+				EnableIntrinsicFunctions="true"
+				FavorSizeOrSpeed="1"
+				AdditionalIncludeDirectories="D:\Programs\MSPlatformSDKServer2003\Include\atl;..\common;..\template"
+				PreprocessorDefinitions="NDEBUG,WIN32,_CONSOLE,SYSTEM_WIN32,STDC_HEADERS,HLRAD_XTRA_LIGHTDATA"
+				StringPooling="true"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				EnableEnhancedInstructionSet="2"
+				UsePrecompiledHeader="0"
+				PrecompiledHeaderFile=".\Release/hlrad.pch"
+				AssemblerListingLocation=".\Release/"
+				ObjectFile=".\Release/"
+				ProgramDataBaseFileName=".\Release/"
+				BrowseInformation="1"
+				WarningLevel="3"
+				SuppressStartupBanner="true"
+				Detect64BitPortabilityProblems="false"
+				CompileAs="0"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+				PreprocessorDefinitions="NDEBUG"
+				Culture="1033"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				AdditionalDependencies="binmode.obj"
+				OutputFile=".\Release/hlrad.exe"
+				LinkIncremental="1"
+				SuppressStartupBanner="true"
+				ProgramDatabaseFile=".\Release/hlrad.pdb"
+				SubSystem="1"
+				StackReserveSize="4194304"
+				StackCommitSize="1048576"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				OptimizeForWindows98="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|x64"
+			ConfigurationType="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
+			>
+			<File
+				RelativePath=".\lerp.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\lightmap.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\mathutil.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\nomatrix.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\qrad.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\qradutil.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\sparse.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\trace.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\transfers.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\transparency.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\vismatrix.cpp"
+				>
+			</File>
+			<File
+				RelativePath=".\vismatrixutil.cpp"
+				>
+			</File>
+			<Filter
+				Name="common"
+				>
+				<File
+					RelativePath="..\common\blockmem.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\bspfile.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\cmdlib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\filelib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\log.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\mathlib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\messages.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\resourcelock.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\scriplib.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\threads.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\common\winding.cpp"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;fi;fd"
+			>
+			<File
+				RelativePath="..\common\anorms.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\blockmem.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\boundingbox.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\bspfile.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\cmdlib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\compress.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\filelib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\hlassert.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\log.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\mathlib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\mathtypes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\messages.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\polylib.h"
+				>
+			</File>
+			<File
+				RelativePath=".\qrad.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\resourcelock.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\scriplib.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\threads.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\win32fix.h"
+				>
+			</File>
+			<File
+				RelativePath="..\common\winding.h"
+				>
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
+			>
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 177 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/hlrad.vcproj.SILENCERSPC.Administrator.user

@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioUserFile
+	ProjectType="Visual C++"
+	Version="9.00"
+	ShowAllFiles="false"
+	>
+	<Configurations>
+		<Configuration
+			Name="Release|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|x64"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Debug|x64"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|Win32"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release x64|x64"
+			>
+			<DebugSettings
+				Command="$(TargetPath)"
+				WorkingDirectory=""
+				CommandArguments=""
+				Attach="false"
+				DebuggerType="3"
+				Remote="1"
+				RemoteMachine="SILENCERSPC"
+				RemoteCommand=""
+				HttpUrl=""
+				PDBPath=""
+				SQLDebugging=""
+				Environment=""
+				EnvironmentMerge="true"
+				DebuggerFlavor=""
+				MPIRunCommand=""
+				MPIRunArguments=""
+				MPIRunWorkingDirectory=""
+				ApplicationCommand=""
+				ApplicationArguments=""
+				ShimCommand=""
+				MPIAcceptMode=""
+				MPIAcceptFilter=""
+			/>
+		</Configuration>
+	</Configurations>
+</VisualStudioUserFile>

+ 640 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/lerp.cpp

@@ -0,0 +1,640 @@
+#pragma warning(disable:4018) //amckern - 64bit - '<' Singed/Unsigned Mismatch
+
+#include "qrad.h"
+
+int             g_lerp_enabled = DEFAULT_LERP_ENABLED;
+
+// =====================================================================================
+//  TestWallIntersectTri
+//      Returns true if wall polygon intersects patch polygon
+// =====================================================================================
+static bool     TestWallIntersectTri(const lerpTriangulation_t* const trian, const vec3_t p1, const vec3_t p2, const vec3_t p3)
+{
+    int             x;
+    const lerpWall_t* wall = trian->walls;
+    dplane_t        plane;
+
+#ifdef HLRAD_FASTMATH
+	PlaneFromPoints(p1,p2,p3,&plane);
+#else
+    plane_from_points(p1, p2, p3, &plane);
+#endif
+
+    // Try first 'vertical' side
+    // Since we test each of the 3 segments from patch against wall, only one side of wall needs testing inside 
+    // patch (since they either dont intersect at all at this point, or both line segments intersect inside)
+    for (x = 0; x < trian->numwalls; x++, wall++)
+    {
+        vec3_t          point;
+
+        // Try side A
+#ifdef HLRAD_FASTMATH
+		if(LineSegmentIntersectsPlane(plane,wall->vertex[0],wall->vertex[3],point))
+		{
+			if(PointInTri(point,&plane,p1,p2,p3))
+			{
+#else
+        if (intersect_linesegment_plane(&plane, wall->vertex[0], wall->vertex[3], point))
+        {
+            if (point_in_tri(point, &plane, p1, p2, p3))
+            {
+#endif
+#if 0
+                Verbose
+                    ("Wall side A point @ (%4.3f %4.3f %4.3f) inside patch (%4.3f %4.3f %4.3f) (%4.3f %4.3f %4.3f) (%4.3f %4.3f %4.3f)\n",
+                     point[0], point[1], point[2], p1[0], p1[1], p1[2], p2[0], p2[1], p2[2], p3[0], p3[1], p3[2]);
+#endif
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+// =====================================================================================
+//  TestLineSegmentIntersectWall
+//      Returns true if line would hit the 'wall' (to fix light streaking)
+// =====================================================================================
+static bool     TestLineSegmentIntersectWall(const lerpTriangulation_t* const trian, const vec3_t p1, const vec3_t p2)
+{
+    int             x;
+    const lerpWall_t* wall = trian->walls;
+
+    for (x = 0; x < trian->numwalls; x++, wall++)
+    {
+        vec3_t          point;
+
+#ifdef HLRAD_FASTMATH
+		if(LineSegmentIntersectsPlane(wall->plane,p1,p2,point))
+		{
+			if(PointInWall(wall,point))
+			{
+#else
+        if (intersect_linesegment_plane(&wall->plane, p1, p2, point))
+        {
+            if (point_in_wall(wall, point))
+			{
+#endif
+#if 0
+                Verbose
+                    ("Tested point @ (%4.3f %4.3f %4.3f) blocks segment from (%4.3f %4.3f %4.3f) to (%4.3f %4.3f %4.3f) intersects wall\n",
+                     point[0], point[1], point[2], p1[0], p1[1], p1[2], p2[0], p2[1], p2[2]);
+#endif
+                return true;
+            }
+        }
+    }
+    return false;
+}
+
+// =====================================================================================
+//  TestTriIntersectWall
+//      Returns true if line would hit the 'wall' (to fix light streaking)
+// =====================================================================================
+static bool     TestTriIntersectWall(const lerpTriangulation_t* trian, const vec3_t p1, const vec3_t p2,
+                                     const vec3_t p3)
+{
+    if (TestLineSegmentIntersectWall(trian, p1, p2) || TestLineSegmentIntersectWall(trian, p1, p3)
+        || TestLineSegmentIntersectWall(trian, p2, p3))
+    {
+        return true;
+    }
+    return false;
+}
+
+// =====================================================================================
+//  LerpTriangle
+//      pt1 must be closest point
+// =====================================================================================
+#ifdef ZHLT_TEXLIGHT
+static void     LerpTriangle(const lerpTriangulation_t* const trian, const vec3_t point, vec3_t result, const unsigned pt1, const unsigned pt2, const unsigned pt3, int style) //LRC
+#else
+static void     LerpTriangle(const lerpTriangulation_t* const trian, const vec3_t point, vec3_t result, const unsigned pt1, const unsigned pt2, const unsigned pt3)
+#endif
+{
+    patch_t*        p1;
+    patch_t*        p2;
+    patch_t*        p3;
+    vec3_t          base;
+    vec3_t          d1;
+    vec3_t          d2;
+    vec_t           x;
+    vec_t           y;
+    vec_t           y1;
+    vec_t           x2;
+    vec3_t          v;
+    dplane_t        ep1;
+    dplane_t        ep2;
+
+    p1 = trian->points[pt1];
+    p2 = trian->points[pt2];
+    p3 = trian->points[pt3];
+
+#ifdef ZHLT_TEXLIGHT
+    VectorCopy(*GetTotalLight(p1, style), base); //LRC
+    VectorSubtract(*GetTotalLight(p2, style), base, d1); //LRC
+    VectorSubtract(*GetTotalLight(p3, style), base, d2); //LRC
+#else
+    VectorCopy(p1->totallight, base);
+    VectorSubtract(p2->totallight, base, d1);
+    VectorSubtract(p3->totallight, base, d2);
+#endif
+
+    // Get edge normals
+    VectorSubtract(p1->origin, p2->origin, v);
+    VectorNormalize(v);
+    CrossProduct(v, trian->plane->normal, ep1.normal);
+    ep1.dist = DotProduct(p1->origin, ep1.normal);
+
+    VectorSubtract(p1->origin, p3->origin, v);
+    VectorNormalize(v);
+    CrossProduct(v, trian->plane->normal, ep2.normal);
+    ep2.dist = DotProduct(p1->origin, ep2.normal);
+
+    x = DotProduct(point, ep1.normal) - ep1.dist;
+    y = DotProduct(point, ep2.normal) - ep2.dist;
+
+    y1 = DotProduct(p2->origin, ep2.normal) - ep2.dist;
+    x2 = DotProduct(p3->origin, ep1.normal) - ep1.dist;
+
+    VectorCopy(base, result);
+    if (fabs(x2) >= ON_EPSILON)
+    {
+        int             i;
+
+        for (i = 0; i < 3; i++)
+        {
+            result[i] += x * d2[i] / x2;
+        }
+    }
+    if (fabs(y1) >= ON_EPSILON)
+    {
+        int             i;
+
+        for (i = 0; i < 3; i++)
+        {
+            result[i] += y * d1[i] / y1;
+        }
+    }
+}
+
+// =====================================================================================
+//  LerpNearest
+// =====================================================================================
+#ifdef ZHLT_TEXLIGHT
+static void     LerpNearest(const lerpTriangulation_t* const trian, vec3_t result, int style) //LRC
+#else
+static void     LerpNearest(const lerpTriangulation_t* const trian, vec3_t result)
+#endif
+{
+    unsigned        x;
+    unsigned        numpoints = trian->numpoints;
+    patch_t*        patch;
+
+    // Find nearest in original face
+    for (x = 0; x < numpoints; x++)
+    {
+        patch = trian->points[trian->dists[x].patch];
+
+        if (patch->faceNumber == trian->facenum)
+        {
+#ifdef ZHLT_TEXLIGHT
+            VectorCopy(*GetTotalLight(patch, style), result); //LRC
+#else
+            VectorCopy(patch->totallight, result);
+#endif
+            return;
+        }
+    }
+
+    // If none in nearest face, settle for nearest
+    if (numpoints)
+    {
+#ifdef ZHLT_TEXLIGHT 
+        VectorCopy(*GetTotalLight(trian->points[trian->dists[0].patch], style), result); //LRC
+#else
+        VectorCopy(trian->points[trian->dists[0].patch]->totallight, result);
+#endif
+    }
+    else
+    {
+        VectorClear(result);
+    }
+}
+
+// =====================================================================================
+//  LerpEdge
+// =====================================================================================
+#ifdef ZHLT_TEXLIGHT
+static bool     LerpEdge(const lerpTriangulation_t* const trian, const vec3_t point, vec3_t result, int style) //LRC
+#else
+static bool     LerpEdge(const lerpTriangulation_t* const trian, const vec3_t point, vec3_t result)
+#endif
+{
+    patch_t*        p1;
+    patch_t*        p2;
+    patch_t*        p3;
+    vec3_t          v1;
+    vec3_t          v2;
+    vec_t           d;
+
+    p1 = trian->points[trian->dists[0].patch];
+    p2 = trian->points[trian->dists[1].patch];
+    p3 = trian->points[trian->dists[2].patch];
+
+    VectorSubtract(point, p1->origin, v2);
+    VectorNormalize(v2);
+
+    // Try nearest and 2
+    if (!TestLineSegmentIntersectWall(trian, p1->origin, p2->origin))
+    {
+        VectorSubtract(p2->origin, p1->origin, v1);
+        VectorNormalize(v1);
+        d = DotProduct(v2, v1);
+        if (d >= ON_EPSILON)
+        {
+            int             i;
+            vec_t           length1;
+            vec_t           length2;
+            vec3_t          segment;
+            vec_t           total_length;
+
+            VectorSubtract(point, p1->origin, segment);
+            length1 = VectorLength(segment);
+            VectorSubtract(point, p2->origin, segment);
+            length2 = VectorLength(segment);
+            total_length = length1 + length2;
+
+            for (i = 0; i < 3; i++)
+            {
+#ifdef ZHLT_TEXLIGHT
+                result[i] = (((*GetTotalLight(p1, style))[i] * length2) + ((*GetTotalLight(p1, style))[i] * length1)) / total_length; //LRC
+#else
+                result[i] = ((p1->totallight[i] * length2) + (p2->totallight[i] * length1)) / total_length;
+#endif
+            }
+            return true;
+        }
+    }
+
+    // Try nearest and 3
+    if (!TestLineSegmentIntersectWall(trian, p1->origin, p3->origin))
+    {
+        VectorSubtract(p3->origin, p1->origin, v1);
+        VectorNormalize(v1);
+        d = DotProduct(v2, v1);
+        if (d >= ON_EPSILON)
+        {
+            int             i;
+            vec_t           length1;
+            vec_t           length2;
+            vec3_t          segment;
+            vec_t           total_length;
+
+            VectorSubtract(point, p1->origin, segment);
+            length1 = VectorLength(segment);
+            VectorSubtract(point, p3->origin, segment);
+            length2 = VectorLength(segment);
+            total_length = length1 + length2;
+
+            for (i = 0; i < 3; i++)
+            {
+#ifdef ZHLT_TEXLIGHT
+                result[i] = (((*GetTotalLight(p1, style))[i] * length2) + ((*GetTotalLight(p3, style))[i] * length1)) / total_length; //LRC
+
+#else
+                result[i] = ((p1->totallight[i] * length2) + (p3->totallight[i] * length1)) / total_length;
+#endif
+            }
+            return true;
+        }
+    }
+    return false;
+}
+
+
+// =====================================================================================
+//
+//  SampleTriangulation
+//
+// =====================================================================================
+
+// =====================================================================================
+//  dist_sorter
+// =====================================================================================
+static int CDECL dist_sorter(const void* p1, const void* p2)
+{
+    lerpDist_t*     dist1 = (lerpDist_t*) p1;
+    lerpDist_t*     dist2 = (lerpDist_t*) p2;
+
+    if (dist1->dist < dist2->dist)
+    {
+        return -1;
+    }
+    else if (dist1->dist > dist2->dist)
+    {
+        return 1;
+    }
+    else
+    {
+        return 0;
+    }
+}
+
+// =====================================================================================
+//  FindDists
+// =====================================================================================
+static void     FindDists(const lerpTriangulation_t* const trian, const vec3_t point)
+{
+    unsigned        x;
+    unsigned        numpoints = trian->numpoints;
+    patch_t**       patch = trian->points;
+    lerpDist_t*     dists = trian->dists;
+    vec3_t          delta;
+
+    for (x = 0; x < numpoints; x++, patch++, dists++)
+    {
+        VectorSubtract((*patch)->origin, point, delta);
+        dists->dist = VectorLength(delta);
+        dists->patch = x;
+    }
+
+    qsort((void*)trian->dists, (size_t) numpoints, sizeof(lerpDist_t), dist_sorter);
+}
+
+// =====================================================================================
+//  SampleTriangulation
+// =====================================================================================
+#ifdef ZHLT_TEXLIGHT
+void            SampleTriangulation(const lerpTriangulation_t* const trian, vec3_t point, vec3_t result, int style) //LRC
+#else
+void            SampleTriangulation(const lerpTriangulation_t* const trian, vec3_t point, vec3_t result)
+#endif
+{
+    FindDists(trian, point);
+
+    if ((trian->numpoints > 3) && (g_lerp_enabled))
+    {
+        unsigned        pt1;
+        unsigned        pt2;
+        unsigned        pt3;
+        vec_t*          p1;
+        vec_t*          p2;
+        vec_t*          p3;
+        dplane_t        plane;
+
+        pt1 = trian->dists[0].patch;
+        pt2 = trian->dists[1].patch;
+        pt3 = trian->dists[2].patch;
+
+        p1 = trian->points[pt1]->origin;
+        p2 = trian->points[pt2]->origin;
+        p3 = trian->points[pt3]->origin;
+
+#ifdef HLRAD_FASTMATH // KGP
+		PlaneFromPoints(p1,p2,p3,&plane);
+		SnapToPlane(&plane,point,0.0);
+		if(PointInTri(point,&plane,p1,p2,p3))
+		{
+#else
+        plane_from_points(p1, p2, p3, &plane);
+        SnapToPlane(&plane, point, 0.0);
+        if (point_in_tri(point, &plane, p1, p2, p3))
+        {                                                  // TODO check edges/tri for blocking by wall
+#endif
+            if (!TestWallIntersectTri(trian, p1, p2, p3) && !TestTriIntersectWall(trian, p1, p2, p3))
+            {
+#ifdef ZHLT_TEXLIGHT
+                LerpTriangle(trian, point, result, pt1, pt2, pt3, style); //LRC
+#else
+                LerpTriangle(trian, point, result, pt1, pt2, pt3);
+#endif
+                return;
+            }
+        }
+        else
+        {
+#ifdef ZHLT_TEXLIGHT
+            if (LerpEdge(trian, point, result, style)) //LRC
+#else
+            if (LerpEdge(trian, point, result))
+#endif
+            {
+                return;
+            }
+        }
+    }
+
+#ifdef ZHLT_TEXLIGHT
+    LerpNearest(trian, result, style); //LRC
+#else
+    LerpNearest(trian, result);
+#endif
+}
+
+// =====================================================================================
+//  AddPatchToTriangulation
+// =====================================================================================
+static void     AddPatchToTriangulation(lerpTriangulation_t* trian, patch_t* patch)
+{
+    if (!(patch->flags & ePatchFlagOutside))
+    {
+        int             pnum = trian->numpoints;
+
+        if (pnum >= trian->maxpoints)
+        {
+            trian->points = (patch_t**)realloc(trian->points, sizeof(patch_t*) * (trian->maxpoints + DEFAULT_MAX_LERP_POINTS));
+
+            hlassume(trian->points != NULL, assume_NoMemory);
+            memset(trian->points + trian->maxpoints, 0, sizeof(patch_t*) * DEFAULT_MAX_LERP_POINTS);   // clear the new block
+
+            trian->maxpoints += DEFAULT_MAX_LERP_POINTS;
+        }
+
+        trian->points[pnum] = patch;
+        trian->numpoints++;
+    }
+}
+
+// =====================================================================================
+//  CreateWalls
+// =====================================================================================
+static void     CreateWalls(lerpTriangulation_t* trian, const dface_t* const face)
+{
+    const dplane_t* p = getPlaneFromFace(face);
+    int             facenum = face - g_dfaces;
+    int             x;
+
+    for (x = 0; x < face->numedges; x++)
+    {
+        edgeshare_t*    es;
+        dface_t*        f2;
+        int             edgenum = g_dsurfedges[face->firstedge + x];
+
+        if (edgenum > 0)
+        {
+            es = &g_edgeshare[edgenum];
+            f2 = es->faces[1];
+        }
+        else
+        {
+            es = &g_edgeshare[-edgenum];
+            f2 = es->faces[0];
+        }
+
+        // Build Wall for non-coplanar neighbhors
+        if (f2 && !es->coplanar && VectorCompare(vec3_origin, es->interface_normal))
+        {
+            const dplane_t* plane = getPlaneFromFace(f2);
+
+            // if plane isn't facing us, ignore it
+            if (DotProduct(plane->normal, g_face_centroids[facenum]) < plane->dist)
+            {
+                continue;
+            }
+
+            {
+                vec3_t          delta;
+                vec3_t          p0;
+                vec3_t          p1;
+                lerpWall_t*     wall;
+
+                if (trian->numwalls >= trian->maxwalls)
+                {
+                    trian->walls =
+                        (lerpWall_t*)realloc(trian->walls, sizeof(lerpWall_t) * (trian->maxwalls + DEFAULT_MAX_LERP_WALLS));
+                    hlassume(trian->walls != NULL, assume_NoMemory);
+                    memset(trian->walls + trian->maxwalls, 0, sizeof(lerpWall_t) * DEFAULT_MAX_LERP_WALLS);     // clear the new block
+                    trian->maxwalls += DEFAULT_MAX_LERP_WALLS;
+                }
+
+                wall = &trian->walls[trian->numwalls];
+                trian->numwalls++;
+
+                VectorScale(p->normal, 10000.0, delta);
+
+                VectorCopy(g_dvertexes[g_dedges[abs(edgenum)].v[0]].point, p0);
+                VectorCopy(g_dvertexes[g_dedges[abs(edgenum)].v[1]].point, p1);
+
+                // Adjust for origin-based models
+                // technically we should use the other faces g_face_offset entries
+                // If they are nonzero, it has to be from the same model with
+                // the same offset, so we are cool
+                VectorAdd(p0, g_face_offset[facenum], p0);
+                VectorAdd(p1, g_face_offset[facenum], p1);
+
+                VectorAdd(p0, delta, wall->vertex[0]);
+                VectorAdd(p1, delta, wall->vertex[1]);
+                VectorSubtract(p1, delta, wall->vertex[2]);
+                VectorSubtract(p0, delta, wall->vertex[3]);
+
+                {
+                    vec3_t          delta1;
+                    vec3_t          delta2;
+                    vec3_t          normal;
+                    vec_t           dist;
+
+                    VectorSubtract(wall->vertex[2], wall->vertex[1], delta1);
+                    VectorSubtract(wall->vertex[0], wall->vertex[1], delta2);
+                    CrossProduct(delta1, delta2, normal);
+                    VectorNormalize(normal);
+                    dist = DotProduct(normal, p0);
+
+                    VectorCopy(normal, wall->plane.normal);
+                    wall->plane.dist = dist;
+                }
+            }
+        }
+    }
+}
+
+// =====================================================================================
+//  AllocTriangulation
+// =====================================================================================
+static lerpTriangulation_t* AllocTriangulation()
+{
+    lerpTriangulation_t* trian = (lerpTriangulation_t*)calloc(1, sizeof(lerpTriangulation_t));
+
+    trian->maxpoints = DEFAULT_MAX_LERP_POINTS;
+    trian->maxwalls = DEFAULT_MAX_LERP_WALLS;
+
+    trian->points = (patch_t**)calloc(DEFAULT_MAX_LERP_POINTS, sizeof(patch_t*));
+
+    trian->walls = (lerpWall_t*)calloc(DEFAULT_MAX_LERP_WALLS, sizeof(lerpWall_t));
+
+    hlassume(trian->points != NULL, assume_NoMemory);
+    hlassume(trian->walls != NULL, assume_NoMemory);
+
+    return trian;
+}
+
+// =====================================================================================
+//  FreeTriangulation
+// =====================================================================================
+void            FreeTriangulation(lerpTriangulation_t* trian)
+{
+    free(trian->dists);
+    free(trian->points);
+    free(trian->walls);
+    free(trian);
+}
+
+// =====================================================================================
+//  CreateTriangulation
+// =====================================================================================
+lerpTriangulation_t* CreateTriangulation(const unsigned int facenum)
+{
+    const dface_t*  f = g_dfaces + facenum;
+    const dplane_t* p = getPlaneFromFace(f);
+    lerpTriangulation_t* trian = AllocTriangulation();
+    patch_t*        patch;
+    unsigned int    j;
+    dface_t*        f2;
+
+    trian->facenum = facenum;
+    trian->plane = p;
+    trian->face = f;
+
+    for (patch = g_face_patches[facenum]; patch; patch = patch->next)
+    {
+        AddPatchToTriangulation(trian, patch);
+    }
+
+    CreateWalls(trian, f);
+
+    for (j = 0; j < f->numedges; j++)
+    {
+        edgeshare_t*    es;
+        int             edgenum = g_dsurfedges[f->firstedge + j];
+
+        if (edgenum > 0)
+        {
+            es = &g_edgeshare[edgenum];
+            f2 = es->faces[1];
+        }
+        else
+        {
+            es = &g_edgeshare[-edgenum];
+            f2 = es->faces[0];
+        }
+
+        if (!es->coplanar && VectorCompare(vec3_origin, es->interface_normal))
+        {
+            continue;
+        }
+
+        for (patch = g_face_patches[f2 - g_dfaces]; patch; patch = patch->next)
+        {
+            AddPatchToTriangulation(trian, patch);
+        }
+    }
+
+    trian->dists = (lerpDist_t*)calloc(trian->numpoints, sizeof(lerpDist_t));
+#ifdef HLRAD_HULLU
+    //Get rid off error that seems to happen with some opaque faces (when opaque face have all edges 'out' of map)
+    if(trian->numpoints != 0)
+#endif
+    hlassume(trian->dists != NULL, assume_NoMemory);
+
+    return trian;
+}

File diff suppressed because it is too large
+ 2450 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/lightmap.cpp


+ 57 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/make.inc

@@ -0,0 +1,57 @@
+HLRAD_DEFINES+=
+HLRAD:=$(OUTDIR)/hlrad$(EXEEXT)
+HLRAD_SRCDIR:=hlrad
+HLRAD_OUTDIR:=$(HLRAD_SRCDIR)/$(OUTDIR)
+
+
+HLRAD_INPUT := \
+$(HLRAD_SRCDIR)/lightmap.cpp \
+$(HLRAD_SRCDIR)/qrad.cpp \
+$(HLRAD_SRCDIR)/qradutil.cpp \
+$(HLRAD_SRCDIR)/mathutil.cpp \
+$(HLRAD_SRCDIR)/trace.cpp \
+$(HLRAD_SRCDIR)/transfers.cpp \
+$(HLRAD_SRCDIR)/vismatrix.cpp \
+$(HLRAD_SRCDIR)/vismatrixutil.cpp \
+$(HLRAD_SRCDIR)/sparse.cpp \
+$(HLRAD_SRCDIR)/nomatrix.cpp \
+$(HLRAD_SRCDIR)/lerp.cpp \
+$(HLRAD_SRCDIR)/transparency.cpp \
+$(COMMON_SRCDIR)/blockmem.cpp \
+$(COMMON_SRCDIR)/bspfile.cpp \
+$(COMMON_SRCDIR)/cmdlib.cpp \
+$(COMMON_SRCDIR)/filelib.cpp \
+$(COMMON_SRCDIR)/log.cpp \
+$(COMMON_SRCDIR)/mathlib.cpp \
+$(COMMON_SRCDIR)/messages.cpp \
+$(COMMON_SRCDIR)/resourcelock.cpp \
+$(COMMON_SRCDIR)/scriplib.cpp \
+$(COMMON_SRCDIR)/threads.cpp \
+$(COMMON_SRCDIR)/winding.cpp \
+
+
+HLRAD_OUTPUT := \
+$(HLRAD_OUTDIR)/lightmap$(OBJEXT) \
+$(HLRAD_OUTDIR)/qrad$(OBJEXT) \
+$(HLRAD_OUTDIR)/qradutil$(OBJEXT) \
+$(HLRAD_OUTDIR)/mathutil$(OBJEXT) \
+$(HLRAD_OUTDIR)/trace$(OBJEXT) \
+$(HLRAD_OUTDIR)/transfers$(OBJEXT) \
+$(HLRAD_OUTDIR)/vismatrix$(OBJEXT) \
+$(HLRAD_OUTDIR)/vismatrixutil$(OBJEXT) \
+$(HLRAD_OUTDIR)/sparse$(OBJEXT) \
+$(HLRAD_OUTDIR)/nomatrix$(OBJEXT) \
+$(HLRAD_OUTDIR)/lerp$(OBJEXT) \
+$(HLRAD_OUTDIR)/transparency$(OBJEXT) \
+$(HLRAD_OUTDIR)/blockmem$(OBJEXT) \
+$(HLRAD_OUTDIR)/bspfile$(OBJEXT) \
+$(HLRAD_OUTDIR)/cmdlib$(OBJEXT) \
+$(HLRAD_OUTDIR)/filelib$(OBJEXT) \
+$(HLRAD_OUTDIR)/log$(OBJEXT) \
+$(HLRAD_OUTDIR)/mathlib$(OBJEXT) \
+$(HLRAD_OUTDIR)/messages$(OBJEXT) \
+$(HLRAD_OUTDIR)/resourcelock$(OBJEXT) \
+$(HLRAD_OUTDIR)/scriplib$(OBJEXT) \
+$(HLRAD_OUTDIR)/threads$(OBJEXT) \
+$(HLRAD_OUTDIR)/winding$(OBJEXT) \
+

+ 246 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/mathutil.cpp

@@ -0,0 +1,246 @@
+#include "qrad.h"
+
+#define NUM_LERP_POINTS 4 //used by PointInWall (defines magic number)
+
+//===============================================
+// PointInEdge - base for all boundary checks
+//===============================================
+
+inline bool PointInEdge(const vec_t* const point, const vec_t* const p1, const vec_t* const p2, const vec_t* const normal)
+{
+	vec3_t edge, temp, temp2; //don't make static because we need multithread support
+	VectorSubtract(p1,p2,edge);
+	VectorSubtract(p1,point,temp);
+	CrossProduct(edge,temp,temp2);
+	//old code normalizes here, which is useless when detecting sign change below
+	return (DotProduct(temp2,normal) >= 0);
+}
+
+//===============================================
+// PointInWall - check a lerpWall_t boundary
+//===============================================
+
+inline bool PointInWall(const lerpWall_t* const wall, const vec_t* const point)
+{
+	for(int counter = 0; counter < NUM_LERP_POINTS; counter++)
+	{
+		if(!PointInEdge(point,wall->vertex[counter],wall->vertex[(counter+1)%4],wall->plane.normal))
+		{ return false; }
+	}
+	return true;
+}
+
+//===============================================
+// PointInWall - check a Winding boundary
+//===============================================
+
+inline bool PointInWinding(const Winding* const W, const dplane_t* const plane, const vec_t* const point)
+{
+	//reverse direction of points because plane input is 180 degrees from desired normal
+	for(size_t counter = 0; counter < W->m_NumPoints-1; counter++)
+	{
+		if(!PointInEdge(point,W->m_Points[counter+1],W->m_Points[counter],plane->normal))
+		{ return false; }
+	}
+	return PointInEdge(point,W->m_Points[0],W->m_Points[W->m_NumPoints-1],plane->normal);
+}
+
+//==================================================
+// PointInTri - check a boundary defined by 3 points
+//==================================================
+
+inline bool PointInTri(const vec_t* const point, const dplane_t* const plane, const vec_t* const p1, const vec_t* const p2, const vec_t* const p3)
+{
+	return (PointInEdge(point,p1,p2,plane->normal) && PointInEdge(point,p2,p3,plane->normal) && PointInEdge(point,p3,p1,plane->normal));
+}
+
+//==================================================
+// LineSegmentIntersectsBounds - does the line pass through the box?
+//==================================================
+
+inline bool LineSegmentIntersectsBounds(const vec_t* const p1, const vec_t* const p2, const vec3_t& mins, const vec3_t& maxs)
+{
+	vec_t tNear = -999999999;
+	vec_t tFar  =  999999999;
+	vec_t t0,t1,tmp;
+
+	vec3_t d;
+	VectorSubtract(p2,p1,d);
+
+	for(int index = 0; index < 3; ++index)
+	{
+		if(fabs(d[index]) < EQUAL_EPSILON)
+		{
+			if(p1[index] < (mins[index] - EQUAL_EPSILON) || p1[index] > (maxs[index] + EQUAL_EPSILON))
+			{
+				return false;
+			}
+			continue;
+		}
+
+		t0 = (mins[index] - p1[index]) / d[index];
+		t1 = (maxs[index] - p1[index]) / d[index];
+
+		if(t0 > t1)
+		{
+			tmp = t1;
+			t1 = t0;
+			t0 = tmp;
+		}
+
+		if(t0 > tNear)
+		{
+			tNear = t0;
+		}
+
+		if(t1 < tFar)
+		{
+			tFar = t1;
+		}
+
+		if(tNear > tFar || tFar < 0)
+		{
+			return false;
+		}
+	}
+
+	return true;
+}
+
+//==================================================
+// LineSegmentIntersectsFace - does the face block the segment?
+//==================================================
+
+inline bool LineSegmentIntersectsFace(const vec_t* const p1, const vec_t* const p2, vec3_t& point_out, const int index)
+{
+	if(LineSegmentIntersectsBounds(p1,p2,g_opaque_face_list[index].mins,g_opaque_face_list[index].maxs))
+	{
+		if(LineSegmentIntersectsPlane(g_opaque_face_list[index].plane,p1,p2,point_out))
+		{
+			if(PointInWinding(g_opaque_face_list[index].winding,&g_opaque_face_list[index].plane,point_out))
+			{
+				return true;
+			}
+		}
+	}
+	return false;
+}
+
+//==================================================
+// LineSegmentIntersectsPlane - returns intersection
+// point in point parameter if it exists
+//==================================================
+
+inline bool LineSegmentIntersectsPlane(const dplane_t& plane, const vec_t* const p1, const vec_t* const p2, vec3_t& point)
+{
+	vec3_t line;
+	VectorSubtract(p2,p1,line);
+	vec_t dist1 = DotProduct(plane.normal,line); //p1 to p2
+
+	if(dist1 == 0.0) //parallel
+	{ return false; }
+
+	vec3_t origin;
+	VectorScale(plane.normal,plane.dist,origin);
+	VectorSubtract(origin,p1,origin);
+
+	vec_t loc = DotProduct(plane.normal,origin)/dist1; //p1 to plane
+	if(loc < 0 || loc > 1) //if we're over 100% or 
+	{ return false; } //under 0% of original length
+
+	VectorMA(p1,loc,line,point);
+	return true;
+}
+
+//==================================================
+// PlaneFromPoints
+//==================================================
+
+inline void PlaneFromPoints(const vec_t* const p1, const vec_t* const p2, const vec_t* const p3, dplane_t* plane)
+{
+	vec3_t	temp, temp2;
+	VectorSubtract(p3,p2,temp);
+	VectorSubtract(p1,p2,temp2);
+	CrossProduct(temp,temp2,plane->normal);
+	VectorNormalize(plane->normal);
+	plane->dist = DotProduct(plane->normal,p1);
+}
+
+//==================================================
+// SnapToPlane
+//==================================================
+
+inline void SnapToPlane(const dplane_t* const plane, vec_t* const point, const vec_t offset)
+{
+	vec_t scale = (plane->dist + offset);
+	scale -= DotProduct(plane->normal,point);
+	VectorMA(point,scale,plane->normal,point);
+}
+
+// =====================================================================================
+//  TestSegmentAgainstOpaqueList
+//      Returns facenum of the opaque face if the segment intersects an item in the opaque list
+// =====================================================================================
+#ifdef HLRAD_HULLU
+int TestSegmentAgainstOpaqueList(const vec_t* p1, const vec_t* p2, vec3_t &scaleout)
+#else
+int TestSegmentAgainstOpaqueList(const vec_t* p1, const vec_t* p2)
+#endif
+{
+    unsigned        x;
+    vec3_t          point;
+    const dplane_t* plane;
+    const Winding*  winding;
+	int             returnVal = -1;
+	int             facenum;
+	//vec_t*			endpoint;
+	bool blocked = false;
+
+	//*endpoint = *p2;
+
+#ifdef HLRAD_HULLU
+    VectorFill(scaleout,1.0);
+#endif
+
+    for (x = 0; x < g_opaque_face_count; x++)
+    {
+        plane = &g_opaque_face_list[x].plane;
+        winding = g_opaque_face_list[x].winding;
+		facenum = g_opaque_face_list[x].facenum;
+
+//		if(LineSegmentIntersectsFace(p1,endpoint,point,x))
+		if(LineSegmentIntersectsFace(p1,p2,point,x))
+		{
+#ifdef HLRAD_HULLU
+		    if(g_opaque_face_list[x].transparency)
+		    {
+			    VectorMultiply(scaleout, g_opaque_face_list[x].transparency_scale, scaleout);
+				//don't change endpoint here -- only if face completely blocks light
+		    }
+            else
+            {
+				//can't break here because we might be blocked more than one time,
+				//continue searching for earliest blocking face
+				//*endpoint = *point;
+				returnVal = facenum;
+                blocked = true;
+            }
+#else
+			*endpoint = *point;
+			returnVal = facenum;
+            blocked = true;
+#endif
+        }
+	}
+	if(blocked)
+	{
+		return returnVal; //return face that intersects the segment closest to p1
+	}
+#ifdef HLRAD_HULLU
+	if(VectorCompare(scaleout,vec3_origin))
+	{
+		VectorClear(scaleout);
+	}
+#endif
+    return -1; //not completely blocked
+}

+ 124 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/nomatrix.cpp

@@ -0,0 +1,124 @@
+#include "qrad.h"
+
+// =====================================================================================
+//  CheckVisBit
+// =====================================================================================
+#ifdef HLRAD_HULLU
+static bool     CheckVisBitNoVismatrix(unsigned patchnum1, unsigned patchnum2, vec3_t &transparency_out, unsigned int &)
+#else
+static bool     CheckVisBitNoVismatrix(unsigned patchnum1, unsigned patchnum2)
+#endif
+{
+#ifdef HLRAD_HULLU
+    // This fix was in vismatrix and sparse methods but not in nomatrix
+    // Without this nomatrix causes SwapTransfers output lots of errors
+    if (patchnum1 > patchnum2)
+    {
+        const unsigned a = patchnum1;
+        const unsigned b = patchnum2;
+        patchnum1 = b;
+        patchnum2 = a;
+    }
+    
+    if (patchnum1 > g_num_patches)
+    {
+        Warning("in CheckVisBit(), patchnum1 > num_patches");
+    }
+    if (patchnum2 > g_num_patches)
+    {
+        Warning("in CheckVisBit(), patchnum2 > num_patches");
+    }
+#endif
+	
+    patch_t*        patch = &g_patches[patchnum1];
+    patch_t*        patch2 = &g_patches[patchnum2];
+	vec3_t			transparency;
+
+#ifdef HLRAD_HULLU
+    VectorFill(transparency_out, 1.0);
+#endif
+
+    // if emitter is behind that face plane, skip all patches
+
+    if (patch2)
+    {
+        const dplane_t* plane2 = getPlaneFromFaceNumber(patch2->faceNumber);
+
+        if (DotProduct(patch->origin, plane2->normal) > (PatchPlaneDist(patch2) + MINIMUM_PATCH_DISTANCE))
+        {
+            // we need to do a real test
+
+            const dplane_t* plane = getPlaneFromFaceNumber(patch->faceNumber);
+
+            // check vis between patch and patch2
+            //  if v2 is not behind light plane
+            //  && v2 is visible from v1
+#ifdef HLRAD_HULLU
+			int facenum = TestSegmentAgainstOpaqueList(patch->origin, patch2->origin, transparency);
+#else
+			int facenum = TestSegmentAgainstOpaqueList(patch->origin, patch2->origin);
+#endif
+            if ((facenum < 0 || facenum == patch2->faceNumber)
+                && (DotProduct(patch2->origin, plane->normal) > (PatchPlaneDist(patch) + MINIMUM_PATCH_DISTANCE))
+                && (TestLine_r(0, patch->origin, patch2->origin) == CONTENTS_EMPTY))
+            {
+#ifdef HLRAD_HULLU            	
+            	if(g_customshadow_with_bouncelight)
+            	{
+            		VectorCopy(transparency, transparency_out);
+            	}
+#endif
+                return true;
+            }
+        }
+    }
+
+    return false;
+}
+
+//
+// end old vismat.c
+////////////////////////////
+
+void            MakeScalesNoVismatrix()
+{
+    char            transferfile[_MAX_PATH];
+
+    hlassume(g_num_patches < MAX_PATCHES, assume_MAX_PATCHES);
+
+    safe_strncpy(transferfile, g_source, _MAX_PATH);
+    StripExtension(transferfile);
+    DefaultExtension(transferfile, ".inc");
+
+    if (!g_incremental || !readtransfers(transferfile, g_num_patches))
+    {
+        g_CheckVisBit = CheckVisBitNoVismatrix;
+#ifndef HLRAD_HULLU
+        NamedRunThreadsOn(g_num_patches, g_estimate, MakeScales);
+#else
+	if(g_rgb_transfers)
+		{NamedRunThreadsOn(g_num_patches, g_estimate, MakeRGBScales);}
+	else
+		{NamedRunThreadsOn(g_num_patches, g_estimate, MakeScales);}
+#endif
+
+        // invert the transfers for gather vs scatter
+#ifndef HLRAD_HULLU
+        NamedRunThreadsOnIndividual(g_num_patches, g_estimate, SwapTransfers);
+#else
+	if(g_rgb_transfers)
+		{NamedRunThreadsOnIndividual(g_num_patches, g_estimate, SwapRGBTransfers);}
+	else
+		{NamedRunThreadsOnIndividual(g_num_patches, g_estimate, SwapTransfers);}
+#endif
+        if (g_incremental)
+        {
+            writetransfers(transferfile, g_num_patches);
+        }
+        else
+        {
+            _unlink(transferfile);
+        }
+        DumpTransfersMemoryUsage();
+    }
+}

File diff suppressed because it is too large
+ 3023 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/qrad.cpp


+ 523 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/qrad.h

@@ -0,0 +1,523 @@
+#ifndef HLRAD_H__
+#define HLRAD_H__
+
+#if _MSC_VER >= 1000
+#pragma once
+#endif
+
+#include "cmdlib.h"
+#include "messages.h"
+#include "win32fix.h"
+#include "log.h"
+#include "hlassert.h"
+#include "mathlib.h"
+#include "bspfile.h"
+#include "winding.h"
+#include "scriplib.h"
+#include "threads.h"
+#include "blockmem.h"
+#include "filelib.h"
+#include "winding.h"
+
+#ifdef SYSTEM_WIN32
+#pragma warning(disable:4142 4028)
+#include <io.h>
+#pragma warning(default: 4142 4028)
+#endif
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif
+
+#ifdef STDC_HEADERS
+#include <ctype.h>
+#endif
+
+#ifdef SYSTEM_WIN32
+#include <direct.h>
+#endif
+
+#define DEFAULT_LERP_ENABLED        true
+#define DEFAULT_FADE                1.0
+#define DEFAULT_FALLOFF             2
+#define DEFAULT_BOUNCE              1
+#define DEFAULT_BOUNCE_DYNAMIC		true
+#define DEFAULT_DUMPPATCHES         false
+#define DEFAULT_AMBIENT_RED         0.0
+#define DEFAULT_AMBIENT_GREEN       0.0
+#define DEFAULT_AMBIENT_BLUE        0.0
+#define DEFAULT_MAXLIGHT            256.0
+#define DEFAULT_TEXSCALE            true
+#define DEFAULT_CHOP                64.0
+#define DEFAULT_TEXCHOP             32.0
+#define DEFAULT_LIGHTSCALE          1.0
+#define DEFAULT_DLIGHT_THRESHOLD    25.0
+#define DEFAULT_DLIGHT_SCALE        2.0
+#define DEFAULT_SMOOTHING_VALUE     50.0
+#define DEFAULT_INCREMENTAL         false
+
+#ifdef ZHLT_PROGRESSFILE // AJM
+#define DEFAULT_PROGRESSFILE NULL // progress file is only used if g_progressfile is non-null
+#endif
+
+// ------------------------------------------------------------------------
+// Changes by Adam Foster - [email protected]
+
+// superseded by DEFAULT_COLOUR_LIGHTSCALE_*
+#ifndef HLRAD_WHOME
+   #define DEFAULT_LIGHTSCALE          1.0
+#endif
+
+// superseded by DEFAULT_COLOUR_GAMMA_*
+#ifndef HLRAD_WHOME
+   #define DEFAULT_GAMMA               0.5
+#endif
+// ------------------------------------------------------------------------
+
+#define DEFAULT_INDIRECT_SUN        1.0
+#define DEFAULT_EXTRA               false
+#define DEFAULT_SKY_LIGHTING_FIX    true
+#define DEFAULT_OBS_LIGHT_REMOVAL   true
+#define DEFAULT_CIRCUS              false
+#define DEFAULT_CORING              1.0
+#define DEFAULT_SUBDIVIDE           true
+#define DEFAULT_CHART               false
+#define DEFAULT_SKYCLIP             true
+#define DEFAULT_INFO                true
+#define DEFAULT_ALLOW_OPAQUES       true
+
+// ------------------------------------------------------------------------
+// Changes by Adam Foster - [email protected]
+#ifdef HLRAD_WHOME
+
+#define DEFAULT_COLOUR_GAMMA_RED		0.5
+#define DEFAULT_COLOUR_GAMMA_GREEN		0.5
+#define DEFAULT_COLOUR_GAMMA_BLUE		0.5
+
+#define DEFAULT_COLOUR_LIGHTSCALE_RED		1.0
+#define DEFAULT_COLOUR_LIGHTSCALE_GREEN		1.0
+#define DEFAULT_COLOUR_LIGHTSCALE_BLUE		1.0
+
+#define DEFAULT_COLOUR_JITTER_HACK_RED		0.0
+#define DEFAULT_COLOUR_JITTER_HACK_GREEN	0.0
+#define DEFAULT_COLOUR_JITTER_HACK_BLUE		0.0
+
+#define DEFAULT_JITTER_HACK_RED			0.0
+#define DEFAULT_JITTER_HACK_GREEN		0.0
+#define DEFAULT_JITTER_HACK_BLUE		0.0
+
+#define DEFAULT_DIFFUSE_HACK			true
+#define DEFAULT_SPOTLIGHT_HACK			true
+
+#define DEFAULT_SOFTLIGHT_HACK_RED		0.0
+#define DEFAULT_SOFTLIGHT_HACK_GREEN		0.0
+#define DEFAULT_SOFTLIGHT_HACK_BLUE		0.0
+#define DEFAULT_SOFTLIGHT_HACK_DISTANCE 	0.0
+
+#endif
+// ------------------------------------------------------------------------
+
+// O_o ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+// Changes by Jussi Kivilinna <[email protected]> [http://hullu.xtragaming.com/]
+#ifdef HLRAD_HULLU
+	// Transparency light support for bounced light(transfers) is extreamly slow 
+	// for 'vismatrix' and 'sparse' atm. 
+	// Only recommended to be used with 'nomatrix' mode
+	#define DEFAULT_CUSTOMSHADOW_WITH_BOUNCELIGHT false
+
+	// RGB Transfers support for HLRAD .. to be used with -customshadowwithbounce
+	#define DEFAULT_RGB_TRANSFERS false
+#endif
+// o_O ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+
+
+#ifdef SYSTEM_WIN32
+#define DEFAULT_ESTIMATE    false
+#endif
+#ifdef SYSTEM_POSIX
+#define DEFAULT_ESTIMATE    true
+#endif
+
+// Ideally matches what is in the FGD :)
+#define SPAWNFLAG_NOBLEEDADJUST    (1 << 0)
+
+// DEFAULT_HUNT_OFFSET is how many units in front of the plane to place the samples
+// Unit of '1' causes the 1 unit crate trick to cause extra shadows
+#define DEFAULT_HUNT_OFFSET 0.5
+// DEFAULT_HUNT_SIZE number of iterations (one based) of radial search in HuntForWorld
+#define DEFAULT_HUNT_SIZE   11
+// DEFAULT_HUNT_SCALE amount to grow from origin point per iteration of DEFAULT_HUNT_SIZE in HuntForWorld
+#define DEFAULT_HUNT_SCALE 0.1
+
+// If patches are allowed to be closer, the light gets amplified (which looks really damn weird)
+#define MINIMUM_PATCH_DISTANCE 1.01
+
+//
+// LIGHTMAP.C STUFF
+//
+
+typedef enum
+{
+    emit_surface,
+    emit_point,
+    emit_spotlight,
+    emit_skylight
+}
+emittype_t;
+
+typedef struct directlight_s
+{
+    struct directlight_s* next;
+    emittype_t      type;
+    int             style;
+    vec3_t          origin;
+    vec3_t          intensity;
+    vec3_t          normal;                                // for surfaces and spotlights
+    float           stopdot;                               // for spotlights
+    float           stopdot2;                              // for spotlights
+
+    // 'Arghrad'-like features
+    vec_t           fade;                                  // falloff scaling for linear and inverse square falloff 1.0 = normal, 0.5 = farther, 2.0 = shorter etc
+    unsigned char   falloff;                               // falloff style 0 = default (inverse square), 1 = inverse falloff, 2 = inverse square (arghrad compat)
+
+	// -----------------------------------------------------------------------------------
+	// Changes by Adam Foster - [email protected]
+	// Diffuse light_environment light colour
+	// Really horrible hack which probably won't work!
+#ifdef HLRAD_WHOME
+	vec3_t			diffuse_intensity;
+#endif
+	// -----------------------------------------------------------------------------------
+
+} directlight_t;
+
+#define TRANSFER_SCALE_VAL    (USHRT_MAX/4)
+
+#define	TRANSFER_SCALE          (1.0 / TRANSFER_SCALE_VAL)
+#define	INVERSE_TRANSFER_SCALE	(TRANSFER_SCALE_VAL)
+#define TRANSFER_SCALE_MAX	(TRANSFER_SCALE_VAL * 4)
+
+typedef struct
+{
+    unsigned size  : 12;
+    unsigned index : 20;
+} transfer_index_t;
+
+typedef unsigned transfer_raw_index_t;
+typedef float transfer_data_t;
+
+//Special RGB mode for transfers
+#ifdef HLRAD_HULLU
+	#if defined(HLRAD_HULLU_48BIT_RGB_TRANSFERS) && defined(HLRAD_HULLU_96BIT_RGB_TRANSFERS)
+		#error Conflict: Both HLRAD_HULLU_48BIT_RGB_TRANSFERS and HLRAD_HULLU_96BIT_RGB_TRANSFERS defined!
+	#elif defined(HLRAD_HULLU_96BIT_RGB_TRANSFERS)
+		//96bit (no noticeable difference to 48bit)
+		typedef float rgb_transfer_t[3];
+	#else
+		//default.. 48bit
+		typedef unsigned short rgb_transfer_t[3];
+	#endif
+	
+	typedef rgb_transfer_t rgb_transfer_data_t;
+#endif
+
+#define MAX_COMPRESSED_TRANSFER_INDEX_SIZE ((1 << 12) - 1)
+
+#define	MAX_PATCHES	(65535*4) // hard limit
+#define MAX_VISMATRIX_PATCHES 65535 // hard limit
+#define MAX_SPARSE_VISMATRIX_PATCHES MAX_PATCHES
+
+typedef enum
+{
+    ePatchFlagNull = 0,
+    ePatchFlagOutside = 1
+} ePatchFlags;
+
+typedef struct patch_s
+{
+    struct patch_s* next;                                  // next in face
+    vec3_t          origin;                                // Center centroid of winding (cached info calculated from winding)
+    vec_t           area;                                  // Surface area of this patch (cached info calculated from winding)
+    Winding*        winding;                               // Winding (patches are triangles, so its easy)
+    vec_t           scale;                                 // Texture scale for this face (blend of S and T scale)
+    vec_t           chop;                                  // Texture chop for this face factoring in S and T scale
+
+    unsigned        iIndex;
+    unsigned        iData;
+
+    transfer_index_t* tIndex;
+    transfer_data_t*  tData;
+#ifdef HLRAD_HULLU
+    rgb_transfer_data_t*	tRGBData;
+#endif
+
+    int             faceNumber;
+    ePatchFlags     flags;
+
+#ifdef ZHLT_TEXLIGHT
+	int				totalstyle[MAXLIGHTMAPS];				//LRC - gives the styles for use by the new switchable totallight values
+	vec3_t          totallight[MAXLIGHTMAPS];				// accumulated by radiosity does NOT include light accounted for by direct lighting
+	vec3_t			directlight[MAXLIGHTMAPS];				// direct light only
+	int				emitstyle;							   //LRC - for switchable texlights
+    vec3_t          baselight;                             // emissivity only, uses emitstyle
+    vec3_t          samplelight[MAXLIGHTMAPS];
+    int             samples[MAXLIGHTMAPS];                 // for averaging direct light
+#else
+    vec3_t          totallight;                            // accumulated by radiosity does NOT include light accounted for by direct lighting
+    vec3_t          baselight;                             // emissivity only
+    vec3_t          directlight;                           // direct light value
+
+    vec3_t          samplelight;
+    int             samples;                               // for averaging direct light
+#endif
+} patch_t;
+
+#ifdef ZHLT_TEXLIGHT
+//LRC
+vec3_t* GetTotalLight(patch_t* patch, int style);
+#endif
+
+typedef struct
+{
+    dface_t*        faces[2];
+    vec3_t          interface_normal;
+    vec_t           cos_normals_angle;
+    bool            coplanar;
+} edgeshare_t;
+
+extern edgeshare_t g_edgeshare[MAX_MAP_EDGES];
+
+//
+// lerp.c stuff
+//
+
+typedef struct lerprect_s
+{
+    dplane_t        plane; // all walls will be perpindicular to face normal in some direction
+    vec3_t          vertex[4];
+}
+lerpWall_t;
+
+typedef struct lerpdist_s
+{
+    vec_t           dist;
+    unsigned        patch;
+} lerpDist_t;
+
+// Valve's default was 2048 originally.
+// MAX_LERP_POINTS causes lerpTriangulation_t to consume :
+// 2048 : roughly 17.5Mb
+// 3072 : roughly 35Mb
+// 4096 : roughly 70Mb
+#define	DEFAULT_MAX_LERP_POINTS		     512
+#define DEFAULT_MAX_LERP_WALLS           128
+
+typedef struct
+{
+    unsigned        maxpoints;
+    unsigned        numpoints;
+
+    unsigned        maxwalls;
+    unsigned        numwalls;
+    patch_t**       points;    // maxpoints
+    lerpDist_t*     dists;     // numpoints after points is populated
+    lerpWall_t*     walls;     // maxwalls
+
+    unsigned        facenum;
+    const dface_t*  face;
+    const dplane_t* plane;
+}
+lerpTriangulation_t;
+
+// These are bitflags for lighting adjustments for special cases
+typedef enum
+{
+    eModelLightmodeNull     = 0,
+    eModelLightmodeEmbedded = 0x01,
+    eModelLightmodeOpaque   = 0x02,
+    eModelLightmodeConcave  = 0x04
+}
+eModelLightmodes;
+
+typedef struct
+{
+    Winding* winding;
+	vec3_t   mins;
+	vec3_t   maxs;
+    dplane_t plane;
+    unsigned facenum;
+
+#ifdef HLRAD_HULLU
+    vec3_t transparency_scale;
+    bool transparency;
+#endif
+
+} opaqueList_t;
+
+#define OPAQUE_ARRAY_GROWTH_SIZE 1024
+
+//
+// qrad globals
+//
+
+extern patch_t* g_face_patches[MAX_MAP_FACES];
+extern entity_t* g_face_entity[MAX_MAP_FACES];
+extern vec3_t   g_face_offset[MAX_MAP_FACES];              // for models with origins
+extern eModelLightmodes g_face_lightmode[MAX_MAP_FACES];
+extern vec3_t   g_face_centroids[MAX_MAP_EDGES];
+extern patch_t  g_patches[MAX_PATCHES];
+extern unsigned g_num_patches;
+
+extern float    g_lightscale;
+extern float    g_dlight_threshold;
+extern float    g_coring;
+extern int      g_lerp_enabled;
+
+extern void     MakeShadowSplits();
+
+//==============================================
+
+extern bool     g_extra;
+extern vec3_t   g_ambient;
+extern vec_t    g_direct_scale;
+extern float    g_maxlight;
+extern unsigned g_numbounce;
+extern float    g_qgamma;
+extern float    g_indirect_sun;
+extern float    g_smoothing_threshold;
+extern float    g_smoothing_value;
+extern bool     g_estimate;
+extern char     g_source[_MAX_PATH];
+extern vec_t    g_fade;
+extern int      g_falloff;
+extern bool     g_incremental;
+extern bool     g_circus;
+extern bool     g_sky_lighting_fix;
+extern bool     g_light_remove;
+extern vec_t    g_chop;    // Chop value for normal textures
+extern vec_t    g_texchop; // Chop value for texture lights
+extern opaqueList_t* g_opaque_face_list;
+extern unsigned      g_opaque_face_count;
+extern unsigned      g_max_opaque_face_count;    // Current array maximum (used for reallocs)
+
+#ifdef ZHLT_PROGRESSFILE // AJM
+extern char*           g_progressfile ;
+#endif
+
+// ------------------------------------------------------------------------
+// Changes by Adam Foster - [email protected]
+#ifdef HLRAD_WHOME
+
+extern vec3_t	g_colour_qgamma;
+extern vec3_t	g_colour_lightscale;
+
+extern vec3_t	g_colour_jitter_hack;
+extern vec3_t	g_jitter_hack;
+extern bool	g_diffuse_hack;
+extern bool	g_spotlight_hack;
+extern vec3_t	g_softlight_hack;
+extern float	g_softlight_hack_distance;
+
+#endif
+// ------------------------------------------------------------------------
+
+
+#ifdef HLRAD_HULLU
+	extern bool	g_customshadow_with_bouncelight;
+	extern bool	g_rgb_transfers;
+	extern const vec3_t vec3_one;
+#endif
+
+extern void     MakeTnodes(dmodel_t* bm);
+extern void     PairEdges();
+extern void     BuildFacelights(int facenum);
+extern void     PrecompLightmapOffsets();
+extern void     FinalLightFace(int facenum);
+extern int      TestLine(const vec3_t start, const vec3_t stop);
+extern int      TestLine_r(int node, const vec3_t start, const vec3_t stop);
+extern void     CreateDirectLights();
+extern void     DeleteDirectLights(int * lNumAddress, int * lListAddress);
+extern void     GetPhongNormal(int facenum, vec3_t spot, vec3_t phongnormal);
+
+#ifdef HLRAD_HULLU
+typedef bool (*funcCheckVisBit) (unsigned, unsigned, vec3_t&, unsigned int&);
+#else
+typedef bool (*funcCheckVisBit) (unsigned, unsigned);
+#endif
+extern funcCheckVisBit g_CheckVisBit;
+
+// qradutil.c
+extern vec_t    PatchPlaneDist(const patch_t* const patch);
+extern dleaf_t* PointInLeaf(const vec3_t point);
+extern void     MakeBackplanes();
+extern const dplane_t* getPlaneFromFace(const dface_t* const face);
+extern const dplane_t* getPlaneFromFaceNumber(unsigned int facenum);
+extern void     getAdjustedPlaneFromFaceNumber(unsigned int facenum, dplane_t* plane);
+extern dleaf_t* HuntForWorld(vec_t* point, const vec_t* plane_offset, const dplane_t* plane, int hunt_size, vec_t hunt_scale, vec_t hunt_offset);
+
+// makescales.c
+extern void     MakeScalesVismatrix();
+extern void     MakeScalesSparseVismatrix();
+extern void     MakeScalesNoVismatrix();
+
+// transfers.c
+extern unsigned g_total_transfer;
+extern bool     readtransfers(const char* const transferfile, long numpatches);
+extern void     writetransfers(const char* const transferfile, long total_patches);
+
+// vismatrixutil.c (shared between vismatrix.c and sparse.c)
+extern void     SwapTransfers(int patchnum);
+extern void     MakeScales(int threadnum);
+extern void     DumpTransfersMemoryUsage();
+#ifdef HLRAD_HULLU
+extern void     SwapRGBTransfers(int patchnum);
+extern void     MakeRGBScales(int threadnum);
+
+// transparency.c (transparency array functions - shared between vismatrix.c and sparse.c)
+extern void	GetTransparency(const unsigned p1, const unsigned p2, vec3_t &trans, unsigned int &next_index);
+extern void	AddTransparencyToRawArray(const unsigned p1, const unsigned p2, const vec3_t trans);
+extern void	CreateFinalTransparencyArrays(const char *print_name);
+extern void	FreeTransparencyArrays();
+#endif
+
+// lerp.c
+#ifdef ZHLT_TEXLIGHT
+extern void     SampleTriangulation(const lerpTriangulation_t* const trian, vec3_t point, vec3_t result, int style); //LRC
+#else
+extern void     SampleTriangulation(const lerpTriangulation_t* const trian, vec3_t point, vec3_t result);
+#endif
+extern void     DestroyTriangulation(lerpTriangulation_t* trian);
+extern lerpTriangulation_t* CreateTriangulation(unsigned int facenum);
+extern void     FreeTriangulation(lerpTriangulation_t* trian);
+
+// mathutil.c
+#ifdef HLRAD_HULLU
+extern int     TestSegmentAgainstOpaqueList(const vec_t* p1, const vec_t* p2, vec3_t &scaleout);
+#else
+extern int     TestSegmentAgainstOpaqueList(const vec_t* p1, const vec_t* p2);
+#endif
+
+#ifdef HLRAD_FASTMATH
+extern void PlaneFromPoints(const vec_t* const p1, const vec_t* const p2, const vec_t* const p3, dplane_t* plane);
+extern bool LineSegmentIntersectsPlane(const dplane_t& plane, const vec_t* const p1, const vec_t* const p2, vec3_t& point);
+extern bool PointInWinding(const Winding* const W, const dplane_t* const plane, const vec_t* const point);
+extern bool PointInWall(const lerpWall_t* const wall, const vec_t* const point);
+extern bool PointInTri(const vec_t* const point, const dplane_t* const plane, const vec_t* const p1, const vec_t* const p2, const vec_t* const p3);
+extern void SnapToPlane(const dplane_t* const plane, vec_t* const point, const vec_t offset);
+#else
+extern bool     intersect_line_plane(const dplane_t* const plane, const vec_t* const p1, const vec_t* const p2, vec3_t point);
+extern bool     intersect_linesegment_plane(const dplane_t* const plane, const vec_t* const p1, const vec_t* const p2,vec3_t point);
+extern void     plane_from_points(const vec3_t p1, const vec3_t p2, const vec3_t p3, dplane_t* plane);
+extern bool     point_in_winding(const Winding& w, const dplane_t& plane, const vec_t* point);
+extern bool     point_in_wall(const lerpWall_t* wall, vec3_t point);
+extern bool     point_in_tri(const vec3_t point, const dplane_t* const plane, const vec3_t p1, const vec3_t p2, const vec3_t p3);
+extern void     ProjectionPoint(const vec_t* const v, const vec_t* const p, vec_t* rval);
+extern void     SnapToPlane(const dplane_t* const plane, vec_t* const point, vec_t offset);
+#endif
+
+
+#endif //HLRAD_H__

+ 0 - 0
build/SHLT-3.9/SHLT 3.9 Sourcecode/SHLT/hlrad/qradutil.cpp


Some files were not shown because too many files changed in this diff