Convert all projects to C++, remove obsolete source files from light project

#138
This commit is contained in:
Sam V 2022-03-15 22:09:08 +01:00
parent 193ff499c5
commit b6b184d429
83 changed files with 305 additions and 1337 deletions

View file

@ -85,10 +85,10 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\bspinfo\bspinfo.c" />
<ClCompile Include="..\..\utils\common\bspfile.c" />
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\scriplib.c" />
<ClCompile Include="..\..\utils\bspinfo\bspinfo.cpp" />
<ClCompile Include="..\..\utils\common\bspfile.cpp" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\scriplib.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\common\bspfile.h" />

View file

@ -30,16 +30,16 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\bspinfo\bspinfo.c">
<ClCompile Include="..\..\utils\bspinfo\bspinfo.cpp">
<Filter>Source Files\utils\bspinfo</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\scriplib.c">
<ClCompile Include="..\..\utils\common\scriplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\bspfile.c">
<ClCompile Include="..\..\utils\common\bspfile.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
</ItemGroup>

View file

@ -11,14 +11,14 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\bspfile.c" />
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\mathlib.c" />
<ClCompile Include="..\..\utils\common\scriplib.c" />
<ClCompile Include="..\..\utils\common\threads.c" />
<ClCompile Include="..\..\utils\light\light.c" />
<ClCompile Include="..\..\utils\light\ltface.c" />
<ClCompile Include="..\..\utils\light\trace.c" />
<ClCompile Include="..\..\utils\light\ltface.cpp" />
<ClCompile Include="..\..\utils\common\bspfile.cpp" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\mathlib.cpp" />
<ClCompile Include="..\..\utils\common\scriplib.cpp" />
<ClCompile Include="..\..\utils\common\threads.cpp" />
<ClCompile Include="..\..\utils\light\light.cpp" />
<ClCompile Include="..\..\utils\light\trace.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\light\light.h" />

View file

@ -30,30 +30,30 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\threads.c">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\bspfile.c">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\mathlib.c">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\scriplib.c">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\light\trace.c">
<ClCompile Include="..\..\utils\light\ltface.cpp">
<Filter>Source Files\utils\light</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\light\light.c">
<ClCompile Include="..\..\utils\light\trace.cpp">
<Filter>Source Files\utils\light</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\light\ltface.c">
<ClCompile Include="..\..\utils\light\light.cpp">
<Filter>Source Files\utils\light</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\bspfile.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\mathlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\scriplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\threads.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\light\light.h">

View file

@ -11,8 +11,8 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\wadlib.c" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\wadlib.cpp" />
<ClCompile Include="..\..\utils\makefont\makefont.cpp" />
</ItemGroup>
<ItemGroup>

View file

@ -30,10 +30,10 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\wadlib.c">
<ClCompile Include="..\..\utils\common\wadlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\makefont\makefont.cpp">

View file

@ -11,7 +11,7 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\mathlib.c" />
<ClCompile Include="..\..\utils\common\mathlib.cpp" />
<ClCompile Include="..\..\utils\mdlviewer\mdlviewer.cpp" />
<ClCompile Include="..\..\utils\mdlviewer\studio_render.cpp" />
<ClCompile Include="..\..\utils\mdlviewer\studio_utils.cpp" />

View file

@ -33,7 +33,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\mathlib.c">
<ClCompile Include="..\..\utils\common\mathlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\mdlviewer\studio_utils.cpp">

View file

@ -11,7 +11,7 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\mkmovie\mkmovie.c" />
<ClCompile Include="..\..\utils\mkmovie\mkmovie.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\common\cmdlib.h" />

View file

@ -27,7 +27,7 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\mkmovie\mkmovie.c">
<ClCompile Include="..\..\utils\mkmovie\mkmovie.cpp">
<Filter>Source Files\utils\mkmovie</Filter>
</ClCompile>
</ItemGroup>

View file

@ -19,20 +19,20 @@
<ClInclude Include="..\..\utils\qbsp2\bsp5.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\bsplib.c" />
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\mathlib.c" />
<ClCompile Include="..\..\utils\common\scriplib.c" />
<ClCompile Include="..\..\utils\common\threads.c" />
<ClCompile Include="..\..\utils\qbsp2\gldraw.c" />
<ClCompile Include="..\..\utils\qbsp2\merge.c" />
<ClCompile Include="..\..\utils\qbsp2\outside.c" />
<ClCompile Include="..\..\utils\qbsp2\portals.c" />
<ClCompile Include="..\..\utils\qbsp2\qbsp.c" />
<ClCompile Include="..\..\utils\qbsp2\solidbsp.c" />
<ClCompile Include="..\..\utils\qbsp2\surfaces.c" />
<ClCompile Include="..\..\utils\qbsp2\tjunc.c" />
<ClCompile Include="..\..\utils\qbsp2\writebsp.c" />
<ClCompile Include="..\..\utils\common\bsplib.cpp" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\mathlib.cpp" />
<ClCompile Include="..\..\utils\common\scriplib.cpp" />
<ClCompile Include="..\..\utils\common\threads.cpp" />
<ClCompile Include="..\..\utils\qbsp2\gldraw.cpp" />
<ClCompile Include="..\..\utils\qbsp2\merge.cpp" />
<ClCompile Include="..\..\utils\qbsp2\outside.cpp" />
<ClCompile Include="..\..\utils\qbsp2\portals.cpp" />
<ClCompile Include="..\..\utils\qbsp2\qbsp.cpp" />
<ClCompile Include="..\..\utils\qbsp2\solidbsp.cpp" />
<ClCompile Include="..\..\utils\qbsp2\surfaces.cpp" />
<ClCompile Include="..\..\utils\qbsp2\tjunc.cpp" />
<ClCompile Include="..\..\utils\qbsp2\writebsp.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{415A5B85-BEA0-4F96-BBB6-5447E4CF726F}</ProjectGuid>

View file

@ -53,46 +53,46 @@
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\bsplib.c">
<ClCompile Include="..\..\utils\common\bsplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\mathlib.c">
<ClCompile Include="..\..\utils\common\mathlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qbsp2\gldraw.c">
<ClCompile Include="..\..\utils\qbsp2\gldraw.cpp">
<Filter>Source Files\utils\qbsp2</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qbsp2\portals.c">
<ClCompile Include="..\..\utils\qbsp2\portals.cpp">
<Filter>Source Files\utils\qbsp2</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qbsp2\merge.c">
<ClCompile Include="..\..\utils\qbsp2\merge.cpp">
<Filter>Source Files\utils\qbsp2</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qbsp2\outside.c">
<ClCompile Include="..\..\utils\qbsp2\outside.cpp">
<Filter>Source Files\utils\qbsp2</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qbsp2\qbsp.c">
<ClCompile Include="..\..\utils\qbsp2\qbsp.cpp">
<Filter>Source Files\utils\qbsp2</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qbsp2\surfaces.c">
<ClCompile Include="..\..\utils\qbsp2\surfaces.cpp">
<Filter>Source Files\utils\qbsp2</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qbsp2\solidbsp.c">
<ClCompile Include="..\..\utils\qbsp2\solidbsp.cpp">
<Filter>Source Files\utils\qbsp2</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\threads.c">
<ClCompile Include="..\..\utils\common\threads.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\scriplib.c">
<ClCompile Include="..\..\utils\common\scriplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qbsp2\writebsp.c">
<ClCompile Include="..\..\utils\qbsp2\writebsp.cpp">
<Filter>Source Files\utils\qbsp2</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qbsp2\tjunc.c">
<ClCompile Include="..\..\utils\qbsp2\tjunc.cpp">
<Filter>Source Files\utils\qbsp2</Filter>
</ClCompile>
</ItemGroup>

View file

@ -11,18 +11,18 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\bspfile.c" />
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\mathlib.c" />
<ClCompile Include="..\..\utils\common\polylib.c" />
<ClCompile Include="..\..\utils\common\scriplib.c" />
<ClCompile Include="..\..\utils\common\threads.c" />
<ClCompile Include="..\..\utils\qcsg\brush.c" />
<ClCompile Include="..\..\utils\qcsg\gldraw.c" />
<ClCompile Include="..\..\utils\qcsg\hullfile.c" />
<ClCompile Include="..\..\utils\qcsg\map.c" />
<ClCompile Include="..\..\utils\qcsg\qcsg.c" />
<ClCompile Include="..\..\utils\qcsg\textures.c" />
<ClCompile Include="..\..\utils\common\bspfile.cpp" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\mathlib.cpp" />
<ClCompile Include="..\..\utils\common\polylib.cpp" />
<ClCompile Include="..\..\utils\common\scriplib.cpp" />
<ClCompile Include="..\..\utils\common\threads.cpp" />
<ClCompile Include="..\..\utils\qcsg\brush.cpp" />
<ClCompile Include="..\..\utils\qcsg\gldraw.cpp" />
<ClCompile Include="..\..\utils\qcsg\hullfile.cpp" />
<ClCompile Include="..\..\utils\qcsg\map.cpp" />
<ClCompile Include="..\..\utils\qcsg\qcsg.cpp" />
<ClCompile Include="..\..\utils\qcsg\textures.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\common\bspfile.h" />

View file

@ -33,40 +33,40 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\qcsg\brush.c">
<ClCompile Include="..\..\utils\qcsg\brush.cpp">
<Filter>Source Files\utils\qcsg</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\bspfile.c">
<ClCompile Include="..\..\utils\common\bspfile.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\polylib.c">
<ClCompile Include="..\..\utils\common\polylib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\mathlib.c">
<ClCompile Include="..\..\utils\common\mathlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qcsg\qcsg.c">
<ClCompile Include="..\..\utils\qcsg\qcsg.cpp">
<Filter>Source Files\utils\qcsg</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qcsg\gldraw.c">
<ClCompile Include="..\..\utils\qcsg\gldraw.cpp">
<Filter>Source Files\utils\qcsg</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qcsg\hullfile.c">
<ClCompile Include="..\..\utils\qcsg\hullfile.cpp">
<Filter>Source Files\utils\qcsg</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qcsg\map.c">
<ClCompile Include="..\..\utils\qcsg\map.cpp">
<Filter>Source Files\utils\qcsg</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qcsg\textures.c">
<ClCompile Include="..\..\utils\qcsg\textures.cpp">
<Filter>Source Files\utils\qcsg</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\scriplib.c">
<ClCompile Include="..\..\utils\common\scriplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\threads.c">
<ClCompile Include="..\..\utils\common\threads.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
</ItemGroup>

View file

@ -11,12 +11,12 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\lbmlib.c" />
<ClCompile Include="..\..\utils\common\scriplib.c" />
<ClCompile Include="..\..\utils\common\wadlib.c" />
<ClCompile Include="..\..\utils\qlumpy\qlumpy.c" />
<ClCompile Include="..\..\utils\qlumpy\quakegrb.c" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\lbmlib.cpp" />
<ClCompile Include="..\..\utils\common\scriplib.cpp" />
<ClCompile Include="..\..\utils\common\wadlib.cpp" />
<ClCompile Include="..\..\utils\qlumpy\qlumpy.cpp" />
<ClCompile Include="..\..\utils\qlumpy\quakegrb.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\common\cmdlib.h" />

View file

@ -33,22 +33,22 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\wadlib.c">
<ClCompile Include="..\..\utils\common\wadlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\lbmlib.c">
<ClCompile Include="..\..\utils\common\lbmlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\scriplib.c">
<ClCompile Include="..\..\utils\common\scriplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qlumpy\quakegrb.c">
<ClCompile Include="..\..\utils\qlumpy\quakegrb.cpp">
<Filter>Source Files\utils\qlumpy</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qlumpy\qlumpy.c">
<ClCompile Include="..\..\utils\qlumpy\qlumpy.cpp">
<Filter>Source Files\utils\qlumpy</Filter>
</ClCompile>
</ItemGroup>

View file

@ -11,16 +11,16 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\bspfile.c" />
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\mathlib.c" />
<ClCompile Include="..\..\utils\common\polylib.c" />
<ClCompile Include="..\..\utils\common\scriplib.c" />
<ClCompile Include="..\..\utils\common\threads.c" />
<ClCompile Include="..\..\utils\qrad\lightmap.c" />
<ClCompile Include="..\..\utils\qrad\qrad.c" />
<ClCompile Include="..\..\utils\qrad\trace.c" />
<ClCompile Include="..\..\utils\qrad\vismat.c" />
<ClCompile Include="..\..\utils\common\bspfile.cpp" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\mathlib.cpp" />
<ClCompile Include="..\..\utils\common\polylib.cpp" />
<ClCompile Include="..\..\utils\common\scriplib.cpp" />
<ClCompile Include="..\..\utils\common\threads.cpp" />
<ClCompile Include="..\..\utils\qrad\lightmap.cpp" />
<ClCompile Include="..\..\utils\qrad\qrad.cpp" />
<ClCompile Include="..\..\utils\qrad\trace.cpp" />
<ClCompile Include="..\..\utils\qrad\vismat.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\common\bspfile.h" />

View file

@ -33,34 +33,34 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\bspfile.c">
<ClCompile Include="..\..\utils\common\bspfile.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\mathlib.c">
<ClCompile Include="..\..\utils\common\mathlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\polylib.c">
<ClCompile Include="..\..\utils\common\polylib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\scriplib.c">
<ClCompile Include="..\..\utils\common\scriplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\threads.c">
<ClCompile Include="..\..\utils\common\threads.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qrad\vismat.c">
<ClCompile Include="..\..\utils\qrad\vismat.cpp">
<Filter>Source Files\utils\qrad</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qrad\lightmap.c">
<ClCompile Include="..\..\utils\qrad\lightmap.cpp">
<Filter>Source Files\utils\qrad</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qrad\qrad.c">
<ClCompile Include="..\..\utils\qrad\qrad.cpp">
<Filter>Source Files\utils\qrad</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\qrad\trace.c">
<ClCompile Include="..\..\utils\qrad\trace.cpp">
<Filter>Source Files\utils\qrad</Filter>
</ClCompile>
</ItemGroup>

View file

@ -11,10 +11,10 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\lbmlib.c" />
<ClCompile Include="..\..\utils\common\scriplib.c" />
<ClCompile Include="..\..\utils\sprgen\sprgen.c" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\lbmlib.cpp" />
<ClCompile Include="..\..\utils\common\scriplib.cpp" />
<ClCompile Include="..\..\utils\sprgen\sprgen.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\common\cmdlib.h" />

View file

@ -33,16 +33,16 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\scriplib.c">
<ClCompile Include="..\..\utils\common\scriplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\lbmlib.c">
<ClCompile Include="..\..\utils\common\lbmlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\sprgen\sprgen.c">
<ClCompile Include="..\..\utils\sprgen\sprgen.cpp">
<Filter>Source Files\utils\sprgen</Filter>
</ClCompile>
</ItemGroup>

View file

@ -11,15 +11,15 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\lbmlib.c" />
<ClCompile Include="..\..\utils\common\mathlib.c" />
<ClCompile Include="..\..\utils\common\scriplib.c" />
<ClCompile Include="..\..\utils\common\trilib.c" />
<ClCompile Include="..\..\utils\studiomdl\bmpread.c" />
<ClCompile Include="..\..\utils\studiomdl\studiomdl.c" />
<ClCompile Include="..\..\utils\studiomdl\tristrip.c" />
<ClCompile Include="..\..\utils\studiomdl\write.c" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\lbmlib.cpp" />
<ClCompile Include="..\..\utils\common\mathlib.cpp" />
<ClCompile Include="..\..\utils\common\scriplib.cpp" />
<ClCompile Include="..\..\utils\common\trilib.cpp" />
<ClCompile Include="..\..\utils\studiomdl\bmpread.cpp" />
<ClCompile Include="..\..\utils\studiomdl\studiomdl.cpp" />
<ClCompile Include="..\..\utils\studiomdl\tristrip.cpp" />
<ClCompile Include="..\..\utils\studiomdl\write.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\common\cmdlib.h" />

View file

@ -33,31 +33,31 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\trilib.c">
<ClCompile Include="..\..\utils\common\trilib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\lbmlib.c">
<ClCompile Include="..\..\utils\common\lbmlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\mathlib.c">
<ClCompile Include="..\..\utils\common\mathlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\scriplib.c">
<ClCompile Include="..\..\utils\common\scriplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\studiomdl\write.c">
<ClCompile Include="..\..\utils\studiomdl\write.cpp">
<Filter>Source Files\utils\studiomdl</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\studiomdl\bmpread.c">
<ClCompile Include="..\..\utils\studiomdl\bmpread.cpp">
<Filter>Source Files\utils\studiomdl</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\studiomdl\studiomdl.c">
<ClCompile Include="..\..\utils\studiomdl\studiomdl.cpp">
<Filter>Source Files\utils\studiomdl</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\studiomdl\tristrip.c">
<ClCompile Include="..\..\utils\studiomdl\tristrip.cpp">
<Filter>Source Files\utils\studiomdl</Filter>
</ClCompile>
</ItemGroup>

View file

@ -11,14 +11,14 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\bspfile.c" />
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\mathlib.c" />
<ClCompile Include="..\..\utils\common\scriplib.c" />
<ClCompile Include="..\..\utils\common\threads.c" />
<ClCompile Include="..\..\utils\visx2\flow.c" />
<ClCompile Include="..\..\utils\visx2\soundpvs.c" />
<ClCompile Include="..\..\utils\visx2\vis.c" />
<ClCompile Include="..\..\utils\common\bspfile.cpp" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\mathlib.cpp" />
<ClCompile Include="..\..\utils\common\scriplib.cpp" />
<ClCompile Include="..\..\utils\common\threads.cpp" />
<ClCompile Include="..\..\utils\visx2\flow.cpp" />
<ClCompile Include="..\..\utils\visx2\soundpvs.cpp" />
<ClCompile Include="..\..\utils\visx2\vis.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\utils\common\bspfile.h" />

View file

@ -36,28 +36,28 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\threads.c">
<ClCompile Include="..\..\utils\common\threads.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\bspfile.c">
<ClCompile Include="..\..\utils\common\bspfile.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\mathlib.c">
<ClCompile Include="..\..\utils\common\mathlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\scriplib.c">
<ClCompile Include="..\..\utils\common\scriplib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\visx2\vis.c">
<ClCompile Include="..\..\utils\visx2\vis.cpp">
<Filter>Source Files\utils\vis</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\visx2\flow.c">
<ClCompile Include="..\..\utils\visx2\flow.cpp">
<Filter>Source Files\utils\vis</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\visx2\soundpvs.c">
<ClCompile Include="..\..\utils\visx2\soundpvs.cpp">
<Filter>Source Files\utils\vis</Filter>
</ClCompile>
</ItemGroup>

View file

@ -11,10 +11,10 @@
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\cmdlib.c" />
<ClCompile Include="..\..\utils\common\lbmlib.c" />
<ClCompile Include="..\..\utils\common\wadlib.c" />
<ClCompile Include="..\..\utils\xwad\xwad.c" />
<ClCompile Include="..\..\utils\common\cmdlib.cpp" />
<ClCompile Include="..\..\utils\common\lbmlib.cpp" />
<ClCompile Include="..\..\utils\common\wadlib.cpp" />
<ClCompile Include="..\..\utils\xwad\xwad.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8A13BDB4-772F-4D03-B343-B56A6D412149}</ProjectGuid>

View file

@ -33,16 +33,16 @@
</Filter>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\utils\common\wadlib.c">
<ClCompile Include="..\..\utils\common\wadlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\cmdlib.c">
<ClCompile Include="..\..\utils\common\cmdlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\common\lbmlib.c">
<ClCompile Include="..\..\utils\common\lbmlib.cpp">
<Filter>Source Files\utils\common</Filter>
</ClCompile>
<ClCompile Include="..\..\utils\xwad\xwad.c">
<ClCompile Include="..\..\utils\xwad\xwad.cpp">
<Filter>Source Files\utils\xwad</Filter>
</ClCompile>
</ItemGroup>

View file

@ -86,10 +86,12 @@ FastChecksum
int FastChecksum(void *buffer, int bytes)
{
char* byteBuffer = reinterpret_cast<char*>(buffer);
int checksum = 0;
while( bytes-- )
checksum = _rotl(checksum, 4) ^ *((char *)buffer)++;
checksum = _rotl(checksum, 4) ^ *byteBuffer++;
return checksum;
}
@ -465,7 +467,7 @@ void WriteBSPFile (char *filename)
#define ENTRIES(a) (sizeof(a)/sizeof(*(a)))
#define ENTRYSIZE(a) (sizeof(*(a)))
ArrayUsage( char *szItem, int items, int maxitems, int itemsize )
int ArrayUsage( char *szItem, int items, int maxitems, int itemsize )
{
float percentage = maxitems ? items * 100.0 / maxitems : 0.0;
@ -482,7 +484,7 @@ ArrayUsage( char *szItem, int items, int maxitems, int itemsize )
return items * itemsize;
}
GlobUsage( char *szItem, int itemstorage, int maxstorage )
int GlobUsage( char *szItem, int itemstorage, int maxstorage )
{
float percentage = maxstorage ? itemstorage * 100.0 / maxstorage : 0.0;
printf("%-12s [variable] %7i/%-7i (%4.1f%%)",
@ -544,7 +546,7 @@ epair_t *ParseEpair (void)
{
epair_t *e;
e = malloc (sizeof(epair_t));
e = reinterpret_cast<epair_t*>(malloc(sizeof(epair_t)));
memset (e, 0, sizeof(epair_t));
if (strlen(token) >= MAX_KEY-1)
@ -668,7 +670,7 @@ void SetKeyValue (entity_t *ent, char *key, char *value)
ep->value = copystring(value);
return;
}
ep = malloc (sizeof(*ep));
ep = reinterpret_cast<epair_t*>(malloc (sizeof(*ep)));
ep->next = ent->epairs;
ent->epairs = ep;
ep->key = copystring(key);

View file

@ -86,10 +86,12 @@ FastChecksum
int FastChecksum(void *buffer, int bytes)
{
int checksum = 0;
char* byteBuffer = reinterpret_cast<char*>(buffer);
while( bytes-- )
checksum = _rotl(checksum, 4) ^ *((char *)buffer)++;
int checksum = 0;
while (bytes--)
checksum = _rotl(checksum, 4) ^ *byteBuffer++;
return checksum;
}
@ -465,7 +467,7 @@ void WriteBSPFile (char *filename)
#define ENTRIES(a) (sizeof(a)/sizeof(*(a)))
#define ENTRYSIZE(a) (sizeof(*(a)))
ArrayUsage( char *szItem, int items, int maxitems, int itemsize )
int ArrayUsage( char *szItem, int items, int maxitems, int itemsize )
{
float percentage = maxitems ? items * 100.0 / maxitems : 0.0;
@ -482,7 +484,7 @@ ArrayUsage( char *szItem, int items, int maxitems, int itemsize )
return items * itemsize;
}
GlobUsage( char *szItem, int itemstorage, int maxstorage )
int GlobUsage( char *szItem, int itemstorage, int maxstorage )
{
float percentage = maxstorage ? itemstorage * 100.0 / maxstorage : 0.0;
printf("%-12s [variable] %7i/%-7i (%4.1f%%)",
@ -544,7 +546,7 @@ epair_t *ParseEpair (void)
{
epair_t *e;
e = malloc (sizeof(epair_t));
e = reinterpret_cast<epair_t*>(malloc (sizeof(epair_t)));
memset (e, 0, sizeof(epair_t));
if (strlen(token) >= MAX_KEY-1)
@ -668,7 +670,7 @@ void SetKeyValue (entity_t *ent, char *key, char *value)
ep->value = copystring(value);
return;
}
ep = malloc (sizeof(*ep));
ep = reinterpret_cast<epair_t*>(malloc (sizeof(*ep)));
ep->next = ent->epairs;
ent->epairs = ep;
ep->key = copystring(key);

View file

@ -245,7 +245,7 @@ char *ExpandPathAndArchive (char *path)
char *copystring(char *s)
{
char *b;
b = malloc(strlen(s)+1);
b = reinterpret_cast<char*>(malloc(strlen(s)+1));
strcpy (b, s);
return b;
}
@ -1003,7 +1003,7 @@ void ListPak(char* pakname)
long totlen=0;
SafeRead(f,&head,sizeof(packheader_t));
pdir=malloc(head.dirlen);
pdir=reinterpret_cast<packfile_t*>(malloc(head.dirlen));
fseek(f,head.dirofs,SEEK_SET);
SafeRead(f,pdir,head.dirlen);

View file

@ -28,15 +28,11 @@ extern "C"
#ifndef __CMDUTIL__
#define __CMDUTIL__
#ifndef _NOENUMQBOOL
typedef enum {false, true} qboolean;
#else
typedef int qboolean;
#undef true
#undef false
#define true 1
#define false 0
#endif
typedef unsigned char byte;
#endif

View file

@ -264,7 +264,7 @@ void Load3DSTriangleList (char *filename, triangle_t **pptri, int *numtriangles)
// back to top of file so we can parse the first chunk descriptor
fseek(input, 0, SEEK_SET);
ptri = malloc (MAXTRIANGLES * sizeof(triangle_t));
triangle_t* ptri = reinterpret_cast<triangle_t*>(malloc (MAXTRIANGLES * sizeof(triangle_t)));
*pptri = ptri;

View file

@ -300,7 +300,7 @@ int LoadBMP (const char* szFile, BYTE** ppbBits, BYTE** ppbPalette)
{ rc = -6; goto GetOut; }
// convert to a packed 768 byte palette
pbPal = malloc(768);
pbPal = reinterpret_cast<byte*>(malloc(768));
if (pbPal == NULL)
{ rc = -7; goto GetOut; }
@ -324,11 +324,11 @@ int LoadBMP (const char* szFile, BYTE** ppbBits, BYTE** ppbPalette)
// Read bitmap bits (remainder of file)
cbBmpBits = bmfh.bfSize - ftell(pfile);
pb = malloc(cbBmpBits);
pb = reinterpret_cast<byte*>(malloc(cbBmpBits));
if (fread(pb, cbBmpBits, 1/*count*/, pfile) != 1)
{ rc = -7; goto GetOut; }
pbBmpBits = malloc(cbBmpBits);
pbBmpBits = reinterpret_cast<BYTE*>(malloc(cbBmpBits));
// data is actually stored with the width being rounded up to a multiple of 4
biTrueWidth = (bmih.biWidth + 3) & ~3;
@ -439,7 +439,7 @@ int WriteBMPfile (char *szFile, byte *pbBits, int width, int height, byte *pbPal
{ rc = -6; goto GetOut; }
pbBmpBits = malloc(cbBmpBits);
pbBmpBits = reinterpret_cast<BYTE*>(malloc(cbBmpBits));
pb = pbBits;
// reverse the order of the data.
@ -538,7 +538,7 @@ void LoadLBM (char *filename, byte **picture, byte **palette)
break;
case CMAPID:
cmapbuffer = malloc (768);
cmapbuffer = reinterpret_cast<byte*>(malloc (768));
memset (cmapbuffer, 0, 768);
memcpy (cmapbuffer, LBM_P, chunklength);
break;
@ -546,7 +546,7 @@ void LoadLBM (char *filename, byte **picture, byte **palette)
case BODYID:
body_p = LBM_P;
pic_p = picbuffer = malloc (bmhd.w*bmhd.h);
pic_p = picbuffer = reinterpret_cast<byte*>(malloc (bmhd.w*bmhd.h));
if (formtype == PBMID)
{
//
@ -643,7 +643,7 @@ void WriteLBMfile (char *filename, byte *data, int width, int height, byte *pale
int length;
bmhd_t basebmhd;
lbm = lbmptr = malloc (width*height+1000);
lbm = lbmptr = reinterpret_cast<byte*>(malloc (width*height+1000));
//
// start FORM

View file

@ -46,7 +46,7 @@ winding_t *AllocWinding (int points)
s = sizeof(vec_t)*3*points + sizeof(int);
s += sizeof(vec_t) - sizeof(w->numpoints); // padding
w = malloc (s);
w = reinterpret_cast<winding_t*>(malloc (s));
memset (w, 0, s);
return w;
@ -257,7 +257,7 @@ winding_t *CopyWinding (winding_t *w)
winding_t *c;
size = (int)((winding_t *)0)->p[w->numpoints];
c = malloc (size);
c = reinterpret_cast<winding_t*>(malloc (size));
memcpy (c, w, size);
return c;
}

View file

@ -138,7 +138,7 @@ RunThreadsOn
*/
void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int))
{
int threadid[MAX_THREADS];
DWORD threadid[MAX_THREADS];
HANDLE threadhandle[MAX_THREADS];
int i;
int start, end;

View file

@ -86,7 +86,7 @@ void LoadTriangleList (char *filename, triangle_t **pptri, int *numtriangles)
exit(0);
}
ptri = malloc (MAXTRIANGLES * sizeof(triangle_t));
ptri = reinterpret_cast<triangle_t*>(malloc (MAXTRIANGLES * sizeof(triangle_t)));
*pptri = ptri;

View file

@ -69,7 +69,7 @@ void W_OpenWad (char *filename)
numlumps = header.numlumps;
length = numlumps*sizeof(lumpinfo_t);
lumpinfo = malloc (length);
lumpinfo = reinterpret_cast<lumpinfo_t*>(malloc (length));
lump_p = lumpinfo;
fseek (wadhandle, header.infotableofs, SEEK_SET);

View file

@ -5,6 +5,8 @@
// $NoKeywords: $
//=============================================================================
#include <algorithm>
#include "light.h"
extern qboolean hicolor;
@ -646,9 +648,9 @@ void LightFace (int surfnum)
#endif
if ( divisor > 1.0 )
VectorScale( total, 1/divisor, total );
total[0] = max(total[0],0.0);
total[1] = max(total[1],0.0);
total[2] = max(total[2],0.0);
total[0] = std::max(total[0],vec_t(0.0));
total[1] = std::max(total[1],vec_t(0.0));
total[2] = std::max(total[2],vec_t(0.0));
}
else
VectorCopy( light[ c ], total );

View file

@ -1,193 +0,0 @@
// lighting.c
#include "light.h"
/*
NOTES
-----
*/
float scaledist = 1.0;
float scalecos = 0.5;
float rangescale = 0.5;
byte *filebase, *file_p, *file_end;
dmodel_t *bspmodel;
vec3_t bsp_origin;
qboolean extrasamples;
float minlights[MAX_MAP_FACES];
lightentity_t lightentities[MAX_MAP_ENTITIES];
int numlightentities;
/*
==================
LoadEntities
==================
*/
void LoadEntities (void)
{
char *s, *s2;
entity_t *e;
lightentity_t *le;
int i, j;
ParseEntities ();
// go through all the entities
for (i=1 ; i<num_entities ; i++)
{
e = &entities[i];
s = ValueForKey (e, "classname");
if (strncmp (s, "light", 5))
continue;
le = &lightentities[numlightentities];
numlightentities++;
strcpy (le->classname, s);
le->light = FloatForKey (e, "light");
if (!le->light)
le->light = DEFAULTLIGHTLEVEL;
le->style = FloatForKey (e, "style");
le->angle = FloatForKey (e, "angle");
GetVectorForKey (e, "origin", le->origin);
s = ValueForKey (e, "target");
if (!s[0])
continue;
// find matching targetname
for (j=1 ; j<num_entities ; j++)
{
s2 = ValueForKey (&entities[j], "targetname");
if (!strcmp (s, s2))
{
le->targetent = true;
GetVectorForKey (&entities[j], "origin", le->targetorigin);
break;
}
}
if (j == num_entities)
printf ("WARNING: entity %i has unmatched target %s\n", i, s);
}
qprintf ("%d lightentities\n", numlightentities);
}
byte *GetFileSpace (int size)
{
byte *buf;
ThreadLock();
file_p = (byte *)(((long)file_p + 3)&~3);
buf = file_p;
file_p += size;
ThreadUnlock();
if (file_p > file_end)
Error ("GetFileSpace: overrun");
return buf;
}
/*
=============
LightWorld
=============
*/
void LightWorld (void)
{
filebase = file_p = dlightdata;
file_end = filebase + MAX_MAP_LIGHTING;
RunThreadsOnIndividual (numfaces, true, LightFace);
lightdatasize = file_p - filebase;
printf ("lightdatasize: %i\n", lightdatasize);
}
/*
========
main
light modelfile
========
*/
int main (int argc, char **argv)
{
int i;
double start, end;
char source[1024];
printf ("----- LightFaces ----\n");
for (i=1 ; i<argc ; i++)
{
if (!strcmp(argv[i],"-threads"))
{
numthreads = atoi (argv[i+1]);
i++;
}
else if (!strcmp(argv[i],"-extra"))
{
extrasamples = true;
printf ("extra sampling enabled\n");
}
else if (!strcmp(argv[i],"-dist"))
{
scaledist = atof (argv[i+1]);
i++;
}
else if (!strcmp(argv[i],"-range"))
{
rangescale = atof (argv[i+1]);
i++;
}
else if (argv[i][0] == '-')
Error ("Unknown option \"%s\"", argv[i]);
else
break;
}
if (i != argc - 1)
Error ("usage: light [-threads num] [-extra] bspfile");
ThreadSetDefault ();
start = I_FloatTime ();
strcpy (source, argv[i]);
StripExtension (source);
DefaultExtension (source, ".bsp");
LoadBSPFile (source);
LoadEntities ();
MakeTnodes (&dmodels[0]);
LightWorld ();
WriteBSPFile (source);
end = I_FloatTime ();
printf ("%5.1f seconds elapsed\n", end-start);
return 0;
}

View file

@ -1,54 +0,0 @@
#include "cmdlib.h"
#include "mathlib.h"
#include "bspfile.h"
#include "threads.h"
#define DEFAULTLIGHTLEVEL 300
typedef struct entity_s
{
char classname[64];
vec3_t origin;
float angle;
int light;
int style;
qboolean targetent;
vec3_t targetorigin;
} lightentity_t;
extern lightentity_t lightentities[MAX_MAP_ENTITIES];
extern int numlightentities;
#define ON_EPSILON 0.1
#define MAXLIGHTS 1024
void LoadNodes (char *file);
qboolean TestLine (vec3_t start, vec3_t stop);
void LightFace (int surfnum);
void LightLeaf (dleaf_t *leaf);
void MakeTnodes (dmodel_t *bm);
extern float scaledist;
extern float scalecos;
extern float rangescale;
extern int c_culldistplane, c_proper;
byte *GetFileSpace (int size);
extern byte *filebase;
extern vec3_t bsp_origin;
extern vec3_t bsp_xvector;
extern vec3_t bsp_yvector;
void TransformSample (vec3_t in, vec3_t out);
void RotateSample (vec3_t in, vec3_t out);
extern qboolean extrasamples;
extern float minlights[MAX_MAP_FACES];

View file

@ -1,585 +0,0 @@
#include "light.h"
/*
============
CastRay
Returns the distance between the points, or -1 if blocked
=============
*/
vec_t CastRay (vec3_t p1, vec3_t p2)
{
int i;
vec_t t;
qboolean trace;
trace = TestLine (p1, p2);
if (!trace)
return -1; // ray was blocked
t = 0;
for (i=0 ; i< 3 ; i++)
t += (p2[i]-p1[i]) * (p2[i]-p1[i]);
if (t == 0)
t = 1; // don't blow up...
return sqrt(t);
}
/*
===============================================================================
SAMPLE POINT DETERMINATION
void SetupBlock (dface_t *f) Returns with surfpt[] set
This is a little tricky because the lightmap covers more area than the face.
If done in the straightforward fashion, some of the
sample points will be inside walls or on the other side of walls, causing
false shadows and light bleeds.
To solve this, I only consider a sample point valid if a line can be drawn
between it and the exact midpoint of the face. If invalid, it is adjusted
towards the center until it is valid.
(this doesn't completely work)
===============================================================================
*/
#define SINGLEMAP (18*18*4)
typedef struct
{
vec_t lightmaps[MAXLIGHTMAPS][SINGLEMAP];
int numlightstyles;
vec_t *light;
vec_t facedist;
vec3_t facenormal;
int numsurfpt;
vec3_t surfpt[SINGLEMAP];
vec3_t texorg;
vec3_t worldtotex[2]; // s = (world - texorg) . worldtotex[0]
vec3_t textoworld[2]; // world = texorg + s * textoworld[0]
vec_t exactmins[2], exactmaxs[2];
int texmins[2], texsize[2];
int lightstyles[256];
int surfnum;
dface_t *face;
} lightinfo_t;
/*
================
CalcFaceVectors
Fills in texorg, worldtotex. and textoworld
================
*/
void CalcFaceVectors (lightinfo_t *l)
{
texinfo_t *tex;
int i, j;
vec3_t texnormal;
float distscale;
vec_t dist, len;
tex = &texinfo[l->face->texinfo];
// convert from float to vec_t
for (i=0 ; i<2 ; i++)
for (j=0 ; j<3 ; j++)
l->worldtotex[i][j] = tex->vecs[i][j];
// calculate a normal to the texture axis. points can be moved along this
// without changing their S/T
texnormal[0] = tex->vecs[1][1]*tex->vecs[0][2]
- tex->vecs[1][2]*tex->vecs[0][1];
texnormal[1] = tex->vecs[1][2]*tex->vecs[0][0]
- tex->vecs[1][0]*tex->vecs[0][2];
texnormal[2] = tex->vecs[1][0]*tex->vecs[0][1]
- tex->vecs[1][1]*tex->vecs[0][0];
VectorNormalize (texnormal);
// flip it towards plane normal
distscale = DotProduct (texnormal, l->facenormal);
if (!distscale)
Error ("Texture axis perpendicular to face");
if (distscale < 0)
{
distscale = -distscale;
VectorSubtract (vec3_origin, texnormal, texnormal);
}
// distscale is the ratio of the distance along the texture normal to
// the distance along the plane normal
distscale = 1/distscale;
for (i=0 ; i<2 ; i++)
{
len = VectorLength (l->worldtotex[i]);
dist = DotProduct (l->worldtotex[i], l->facenormal);
dist *= distscale;
VectorMA (l->worldtotex[i], -dist, texnormal, l->textoworld[i]);
VectorScale (l->textoworld[i], (1/len)*(1/len), l->textoworld[i]);
}
// calculate texorg on the texture plane
for (i=0 ; i<3 ; i++)
l->texorg[i] = -tex->vecs[0][3]* l->textoworld[0][i] - tex->vecs[1][3] * l->textoworld[1][i];
// project back to the face plane
dist = DotProduct (l->texorg, l->facenormal) - l->facedist - 1;
dist *= distscale;
VectorMA (l->texorg, -dist, texnormal, l->texorg);
}
/*
================
CalcFaceExtents
Fills in s->texmins[] and s->texsize[]
also sets exactmins[] and exactmaxs[]
================
*/
void CalcFaceExtents (lightinfo_t *l)
{
dface_t *s;
vec_t mins[2], maxs[2], val;
int i,j, e;
dvertex_t *v;
texinfo_t *tex;
s = l->face;
mins[0] = mins[1] = 999999;
maxs[0] = maxs[1] = -99999;
tex = &texinfo[s->texinfo];
for (i=0 ; i<s->numedges ; i++)
{
e = dsurfedges[s->firstedge+i];
if (e >= 0)
v = dvertexes + dedges[e].v[0];
else
v = dvertexes + dedges[-e].v[1];
for (j=0 ; j<2 ; j++)
{
val = v->point[0] * tex->vecs[j][0] +
v->point[1] * tex->vecs[j][1] +
v->point[2] * tex->vecs[j][2] +
tex->vecs[j][3];
if (val < mins[j])
mins[j] = val;
if (val > maxs[j])
maxs[j] = val;
}
}
for (i=0 ; i<2 ; i++)
{
l->exactmins[i] = mins[i];
l->exactmaxs[i] = maxs[i];
mins[i] = floor(mins[i]/16);
maxs[i] = ceil(maxs[i]/16);
l->texmins[i] = mins[i];
l->texsize[i] = maxs[i] - mins[i];
if (l->texsize[i] > 17)
Error ("Bad surface extents");
}
}
/*
=================
CalcPoints
For each texture aligned grid point, back project onto the plane
to get the world xyz value of the sample point
=================
*/
int c_bad;
void CalcPoints (lightinfo_t *l)
{
int i;
int s, t, j;
int w, h, step;
vec_t starts, startt, us, ut;
vec_t *surf;
vec_t mids, midt;
vec3_t facemid, move;
//
// fill in surforg
// the points are biased towards the center of the surface
// to help avoid edge cases just inside walls
//
surf = l->surfpt[0];
mids = (l->exactmaxs[0] + l->exactmins[0])/2;
midt = (l->exactmaxs[1] + l->exactmins[1])/2;
for (j=0 ; j<3 ; j++)
facemid[j] = l->texorg[j] + l->textoworld[0][j]*mids + l->textoworld[1][j]*midt;
if (extrasamples)
{ // extra filtering
h = (l->texsize[1]+1)*2;
w = (l->texsize[0]+1)*2;
starts = (l->texmins[0]-0.5)*16;
startt = (l->texmins[1]-0.5)*16;
step = 8;
}
else
{
h = l->texsize[1]+1;
w = l->texsize[0]+1;
starts = l->texmins[0]*16;
startt = l->texmins[1]*16;
step = 16;
}
l->numsurfpt = w * h;
for (t=0 ; t<h ; t++)
{
for (s=0 ; s<w ; s++, surf+=3)
{
us = starts + s*step;
ut = startt + t*step;
// if a line can be traced from surf to facemid, the point is good
for (i=0 ; i<6 ; i++)
{
// calculate texture point
for (j=0 ; j<3 ; j++)
surf[j] = l->texorg[j] + l->textoworld[0][j]*us
+ l->textoworld[1][j]*ut;
if (CastRay (facemid, surf) != -1)
break; // got it
if (i & 1)
{
if (us > mids)
{
us -= 8;
if (us < mids)
us = mids;
}
else
{
us += 8;
if (us > mids)
us = mids;
}
}
else
{
if (ut > midt)
{
ut -= 8;
if (ut < midt)
ut = midt;
}
else
{
ut += 8;
if (ut > midt)
ut = midt;
}
}
// move surf 8 pixels towards the center
VectorSubtract (facemid, surf, move);
VectorNormalize (move);
VectorMA (surf, 8, move, surf);
}
if (i == 2)
c_bad++;
}
}
}
/*
===============================================================================
FACE LIGHTING
===============================================================================
*/
int c_culldistplane, c_proper;
/*
================
SingleLightFace
================
*/
void SingleLightFace (lightentity_t *light, lightinfo_t *l)
{
vec_t dist;
vec3_t incoming;
vec_t angle;
vec_t add;
vec_t *surf;
qboolean hit;
int mapnum;
int size;
int c, i;
vec3_t rel;
vec3_t spotvec;
vec_t falloff;
vec_t *lightsamp;
VectorSubtract (light->origin, bsp_origin, rel);
dist = scaledist * (DotProduct (rel, l->facenormal) - l->facedist);
// don't bother with lights behind the surface
if (dist <= 0)
return;
// don't bother with light too far away
if (dist > light->light)
{
c_culldistplane++;
return;
}
if (light->targetent)
{
VectorSubtract (light->targetorigin, light->origin, spotvec);
VectorNormalize (spotvec);
if (!light->angle)
falloff = -cos(20*Q_PI/180);
else
falloff = -cos(light->angle/2*Q_PI/180);
}
else
falloff = 0; // shut up compiler warnings
mapnum = 0;
for (mapnum=0 ; mapnum<l->numlightstyles ; mapnum++)
if (l->lightstyles[mapnum] == light->style)
break;
lightsamp = l->lightmaps[mapnum];
if (mapnum == l->numlightstyles)
{ // init a new light map
if (mapnum == MAXLIGHTMAPS)
{
printf ("WARNING: Too many light styles on a face\n");
return;
}
size = (l->texsize[1]+1)*(l->texsize[0]+1);
for (i=0 ; i<size ; i++)
lightsamp[i] = 0;
}
//
// check it for real
//
hit = false;
c_proper++;
surf = l->surfpt[0];
for (c=0 ; c<l->numsurfpt ; c++, surf+=3)
{
dist = CastRay(light->origin, surf)*scaledist;
if (dist < 0)
continue; // light doesn't reach
VectorSubtract (light->origin, surf, incoming);
VectorNormalize (incoming);
angle = DotProduct (incoming, l->facenormal);
if (light->targetent)
{ // spotlight cutoff
if (DotProduct (spotvec, incoming) > falloff)
continue;
}
angle = (1.0-scalecos) + scalecos*angle;
add = light->light - dist;
add *= angle;
if (add < 0)
continue;
lightsamp[c] += add;
if (lightsamp[c] > 1) // ignore real tiny lights
hit = true;
}
if (mapnum == l->numlightstyles && hit)
{
l->lightstyles[mapnum] = light->style;
l->numlightstyles++; // the style has some real data now
}
}
/*
============
FixMinlight
============
*/
void FixMinlight (lightinfo_t *l)
{
int i, j;
float minlight;
minlight = minlights[l->surfnum];
// if minlight is set, there must be a style 0 light map
if (!minlight)
return;
for (i=0 ; i< l->numlightstyles ; i++)
{
if (l->lightstyles[i] == 0)
break;
}
if (i == l->numlightstyles)
{
if (l->numlightstyles == MAXLIGHTMAPS)
return; // oh well..
for (j=0 ; j<l->numsurfpt ; j++)
l->lightmaps[i][j] = minlight;
l->lightstyles[i] = 0;
l->numlightstyles++;
}
else
{
for (j=0 ; j<l->numsurfpt ; j++)
if ( l->lightmaps[i][j] < minlight)
l->lightmaps[i][j] = minlight;
}
}
/*
============
LightFace
============
*/
void LightFace (int surfnum)
{
dface_t *f;
lightinfo_t l;
int s, t;
int i,j,c;
vec_t total;
int size;
int lightmapwidth, lightmapsize;
byte *out;
vec_t *light;
int w, h;
f = dfaces + surfnum;
//
// some surfaces don't need lightmaps
//
f->lightofs = -1;
for (j=0 ; j<MAXLIGHTMAPS ; j++)
f->styles[j] = 255;
if ( texinfo[f->texinfo].flags & TEX_SPECIAL)
{ // non-lit texture
return;
}
memset (&l, 0, sizeof(l));
l.surfnum = surfnum;
l.face = f;
//
// rotate plane
//
VectorCopy (dplanes[f->planenum].normal, l.facenormal);
l.facedist = dplanes[f->planenum].dist;
if (f->side)
{
VectorSubtract (vec3_origin, l.facenormal, l.facenormal);
l.facedist = -l.facedist;
}
CalcFaceVectors (&l);
CalcFaceExtents (&l);
CalcPoints (&l);
lightmapwidth = l.texsize[0]+1;
size = lightmapwidth*(l.texsize[1]+1);
if (size > SINGLEMAP)
Error ("Bad lightmap size");
for (i=0 ; i<MAXLIGHTMAPS ; i++)
l.lightstyles[i] = 255;
//
// cast all lights
//
l.numlightstyles = 0;
for (i=0 ; i<numlightentities ; i++)
SingleLightFace (&lightentities[i], &l);
FixMinlight (&l);
if (!l.numlightstyles)
{ // no light hitting it
return;
}
//
// save out the values
//
for (i=0 ; i <MAXLIGHTMAPS ; i++)
f->styles[i] = l.lightstyles[i];
lightmapsize = size*l.numlightstyles;
out = GetFileSpace (lightmapsize);
f->lightofs = out - filebase;
// extra filtering
h = (l.texsize[1]+1)*2;
w = (l.texsize[0]+1)*2;
for (i=0 ; i< l.numlightstyles ; i++)
{
if (l.lightstyles[i] == 0xff)
Error ("Wrote empty lightmap");
light = l.lightmaps[i];
c = 0;
for (t=0 ; t<=l.texsize[1] ; t++)
for (s=0 ; s<=l.texsize[0] ; s++, c++)
{
if (extrasamples)
{ // filtered sample
total = light[t*2*w+s*2] + light[t*2*w+s*2+1]
+ light[(t*2+1)*w+s*2] + light[(t*2+1)*w+s*2+1];
total *= 0.25;
}
else
total = light[c];
total *= rangescale; // scale before clamping
if (total > 255)
total = 255;
if (total < 0)
Error ("light < 0");
*out++ = total;
}
}
}

View file

@ -1,199 +0,0 @@
// trace.c
#include "light.h"
typedef struct tnode_s
{
int type;
vec3_t normal;
float dist;
int children[2];
int pad;
} tnode_t;
tnode_t *tnodes, *tnode_p;
/*
==============
MakeTnode
Converts the disk node structure into the efficient tracing structure
==============
*/
void MakeTnode (int nodenum)
{
tnode_t *t;
dplane_t *plane;
int i;
dnode_t *node;
t = tnode_p++;
node = dnodes + nodenum;
plane = dplanes + node->planenum;
t->type = plane->type;
VectorCopy (plane->normal, t->normal);
t->dist = plane->dist;
for (i=0 ; i<2 ; i++)
{
if (node->children[i] < 0)
t->children[i] = dleafs[-node->children[i] - 1].contents;
else
{
t->children[i] = tnode_p - tnodes;
MakeTnode (node->children[i]);
}
}
}
/*
=============
MakeTnodes
Loads the node structure out of a .bsp file to be used for light occlusion
=============
*/
void MakeTnodes (dmodel_t *bm)
{
if (!numnodes)
Error ("Map has no nodes\n");
tnode_p = tnodes = malloc(numnodes * sizeof(tnode_t));
MakeTnode (0);
}
/*
==============================================================================
LINE TRACING
The major lighting operation is a point to point visibility test, performed
by recursive subdivision of the line by the BSP tree.
==============================================================================
*/
typedef struct
{
vec3_t backpt;
int side;
int node;
} tracestack_t;
/*
==============
TestLine
==============
*/
qboolean TestLine (vec3_t start, vec3_t stop)
{
int node;
float front, back;
tracestack_t *tstack_p;
int side;
float frontx,fronty, frontz, backx, backy, backz;
tracestack_t tracestack[64];
tnode_t *tnode;
frontx = start[0];
fronty = start[1];
frontz = start[2];
backx = stop[0];
backy = stop[1];
backz = stop[2];
tstack_p = tracestack;
node = 0;
while (1)
{
while (node < 0 && node != CONTENTS_SOLID)
{
// pop up the stack for a back side
tstack_p--;
if (tstack_p < tracestack)
return true;
node = tstack_p->node;
// set the hit point for this plane
frontx = backx;
fronty = backy;
frontz = backz;
// go down the back side
backx = tstack_p->backpt[0];
backy = tstack_p->backpt[1];
backz = tstack_p->backpt[2];
node = tnodes[tstack_p->node].children[!tstack_p->side];
}
if (node == CONTENTS_SOLID)
return false; // DONE!
tnode = &tnodes[node];
switch (tnode->type)
{
case PLANE_X:
front = frontx - tnode->dist;
back = backx - tnode->dist;
break;
case PLANE_Y:
front = fronty - tnode->dist;
back = backy - tnode->dist;
break;
case PLANE_Z:
front = frontz - tnode->dist;
back = backz - tnode->dist;
break;
default:
front = (frontx*tnode->normal[0] + fronty*tnode->normal[1] + frontz*tnode->normal[2]) - tnode->dist;
back = (backx*tnode->normal[0] + backy*tnode->normal[1] + backz*tnode->normal[2]) - tnode->dist;
break;
}
if (front > -ON_EPSILON && back > -ON_EPSILON)
// if (front > 0 && back > 0)
{
node = tnode->children[0];
continue;
}
if (front < ON_EPSILON && back < ON_EPSILON)
// if (front <= 0 && back <= 0)
{
node = tnode->children[1];
continue;
}
side = front < 0;
front = front / (front-back);
tstack_p->node = node;
tstack_p->side = side;
tstack_p->backpt[0] = backx;
tstack_p->backpt[1] = backy;
tstack_p->backpt[2] = backz;
tstack_p++;
backx = frontx + front*(backx-frontx);
backy = fronty + front*(backy-fronty);
backz = frontz + front*(backz-frontz);
node = tnode->children[side];
}
}

View file

@ -68,7 +68,7 @@ void MakeTnodes (dmodel_t *bm)
{
if (!numnodes)
Error ("Map has no nodes\n");
tnode_p = tnodes = malloc(numnodes * sizeof(tnode_t));
tnode_p = tnodes = reinterpret_cast<tnode_t*>(malloc(numnodes * sizeof(tnode_t)));
MakeTnode (0);
}

View file

@ -17,11 +17,8 @@
#include <windows.h>
extern "C"
{
#include "cmdlib.h"
#include "wadlib.h"
}
#include "cmdlib.h"
#include "wadlib.h"
#include "qfont.h"
#define DEFAULT_FONT "Arial"

View file

@ -158,7 +158,7 @@ winding_t *CopyWinding (winding_t *w)
winding_t *c;
size = (int)((winding_t *)0)->points[w->numpoints];
c = malloc (size);
c = reinterpret_cast<winding_t*>(malloc (size));
memcpy (c, w, size);
return c;
}
@ -573,7 +573,7 @@ winding_t *NewWinding (int points)
c_peakwindings = c_activewindings;
size = (int)((winding_t *)0)->points[points];
w = malloc (size);
w = reinterpret_cast<winding_t*>(malloc (size));
memset (w, 0, size);
return w;
@ -601,7 +601,7 @@ face_t *AllocFace (void)
if (c_activefaces > c_peakfaces)
c_peakfaces = c_activefaces;
f = malloc (sizeof(face_t));
f = reinterpret_cast<face_t*>(malloc (sizeof(face_t)));
memset (f, 0, sizeof(face_t));
f->planenum = -1;
@ -625,7 +625,7 @@ surface_t *AllocSurface (void)
{
surface_t *s;
s = malloc (sizeof(surface_t));
s = reinterpret_cast<surface_t*>(malloc (sizeof(surface_t)));
memset (s, 0, sizeof(surface_t));
c_activesurfaces++;
@ -654,7 +654,7 @@ portal_t *AllocPortal (void)
if (c_activeportals > c_peakportals)
c_peakportals = c_activeportals;
p = malloc (sizeof(portal_t));
p = reinterpret_cast<portal_t*>(malloc (sizeof(portal_t)));
memset (p, 0, sizeof(portal_t));
return p;
@ -676,7 +676,7 @@ node_t *AllocNode (void)
{
node_t *n;
n = malloc (sizeof(node_t));
n = reinterpret_cast<node_t*>(malloc (sizeof(node_t)));
memset (n, 0, sizeof(node_t));
return n;
@ -710,7 +710,7 @@ surfchain_t *SurflistFromValidFaces (void)
face_t *f, *next;
surfchain_t *sc;
sc = malloc(sizeof(*sc));
sc = reinterpret_cast<surfchain_t*>(malloc(sizeof(*sc)));
ClearBounds (sc->mins, sc->maxs);
sc->surfaces = NULL;

View file

@ -613,7 +613,7 @@ void LinkLeafFaces (surface_t *planelist, node_t *leafnode)
markfaces[nummarkfaces] = NULL; // end marker
nummarkfaces++;
leafnode->markfaces = malloc(nummarkfaces * sizeof(*leafnode->markfaces));
leafnode->markfaces = reinterpret_cast<face_t**>(malloc(nummarkfaces * sizeof(*leafnode->markfaces)));
memcpy (leafnode->markfaces, markfaces, nummarkfaces * sizeof(*leafnode->markfaces));
}

View file

@ -278,7 +278,7 @@ face_t *newlist;
void SplitFaceForTjunc (face_t *f, face_t *original)
{
int i;
face_t *new, *chain;
face_t *newFace, *chain;
vec3_t dir, test;
vec_t v;
int firstcorner, lastcorner;
@ -343,33 +343,33 @@ restart:
// cut off as big a piece as possible, less than MAXPOINTS, and not
// past lastcorner
new = NewFaceFromFace (f);
newFace = NewFaceFromFace(f);
if (f->original)
Error ("SplitFaceForTjunc: f->original");
new->original = chain;
chain = new;
new->next = newlist;
newlist = new;
newFace->original = chain;
chain = newFace;
newFace->next = newlist;
newlist = newFace;
if (f->numpoints - firstcorner <= MAXPOINTS)
new->numpoints = firstcorner+2;
newFace->numpoints = firstcorner + 2;
else if (lastcorner+2 < MAXPOINTS &&
f->numpoints - lastcorner <= MAXPOINTS)
new->numpoints = lastcorner+2;
newFace->numpoints = lastcorner + 2;
else
new->numpoints = MAXPOINTS;
newFace->numpoints = MAXPOINTS;
for (i=0 ; i<new->numpoints ; i++)
for (i = 0; i < newFace->numpoints; i++)
{
VectorCopy (f->pts[i], new->pts[i]);
VectorCopy(f->pts[i], newFace->pts[i]);
}
for (i=new->numpoints-1 ; i<f->numpoints ; i++)
for (i = newFace->numpoints - 1; i < f->numpoints; i++)
{
VectorCopy (f->pts[i], f->pts[i-(new->numpoints-2)]);
VectorCopy(f->pts[i], f->pts[i - (newFace->numpoints - 2)]);
}
f->numpoints -= (new->numpoints-2);
f->numpoints -= (newFace->numpoints - 2);
} while (1);
}

View file

@ -401,7 +401,7 @@ void AddBrushPlane (expand_t *ex, plane_t *plane)
return;
}
nf = malloc(sizeof(*nf));
nf = reinterpret_cast<bface_t*>(malloc(sizeof(*nf)));
memset (nf, 0, sizeof(*nf));
nf->planenum = FindIntPlane (plane->inormal, plane->iorigin);
nf->plane = &mapplanes[nf->planenum];
@ -477,7 +477,7 @@ void TestAddPlane (expand_t *ex, plane_t *plane)
}
nf = malloc(sizeof(*nf));
nf = reinterpret_cast<bface_t*>(malloc(sizeof(*nf)));
memset (nf, 0, sizeof(*nf));
nf->planenum = FindIntPlane (plane->inormal, plane->iorigin);
nf->plane = &mapplanes[nf->planenum];
@ -650,7 +650,7 @@ void ExpandBrush (brush_t *b, int hullnum)
corner = 0;
iorigin[x] += p->normal[x]*corner;
}
nf = malloc(sizeof(*nf));
nf = reinterpret_cast<bface_t*>(malloc(sizeof(*nf)));
memset (nf, 0, sizeof(*nf));
nf->planenum = FindIntPlane (inormal, iorigin);
@ -845,7 +845,7 @@ qboolean MakeBrushPlanes (brush_t *b)
}
}
f = malloc(sizeof(*f));
f = reinterpret_cast<bface_t*>(malloc(sizeof(*f)));
memset (f, 0, sizeof(*f));
f->planenum = planenum;

View file

@ -101,8 +101,8 @@ extern side_t brushsides[MAX_MAP_SIDES];
extern qboolean noclip;
extern qboolean wadtextures;
int nWadInclude;
char *pszWadInclude[];
extern int nWadInclude;
extern char *pszWadInclude[];
void LoadMapFile (char *filename);

View file

@ -296,7 +296,7 @@ qboolean ParseMapEntity (void)
newbrushes = mapent->numbrushes;
worldbrushes = entities[0].numbrushes;
temp = malloc(newbrushes*sizeof(brush_t));
temp = reinterpret_cast<brush_t*>(malloc(newbrushes*sizeof(brush_t)));
memcpy (temp, mapbrushes + mapent->firstbrush, newbrushes*sizeof(brush_t));
for (i=0 ; i<newbrushes ; i++)

View file

@ -50,7 +50,7 @@ bface_t *NewFaceFromFace (bface_t *in)
{
bface_t *newf;
newf = malloc (sizeof(bface_t));
newf = reinterpret_cast<bface_t*>(malloc (sizeof(bface_t)));
memset (newf, 0, sizeof(newf));
newf->contents = in->contents;
newf->texinfo = in->texinfo;

View file

@ -153,8 +153,8 @@ qboolean TEX_InitFromWad (char *path)
wadinfo.numlumps = LittleLong(wadinfo.numlumps);
wadinfo.infotableofs = LittleLong(wadinfo.infotableofs);
fseek (texfile, wadinfo.infotableofs, SEEK_SET);
lumpinfo = realloc(lumpinfo, (nTexLumps + wadinfo.numlumps)
* sizeof(lumpinfo_t));
lumpinfo = reinterpret_cast<lumpinfo_t*>(realloc(lumpinfo, (nTexLumps + wadinfo.numlumps)
* sizeof(lumpinfo_t)));
for(i = 0; i < wadinfo.numlumps; i++)
{
@ -187,7 +187,7 @@ lumpinfo_t *
FindTexture (lumpinfo_t *source )
{
lumpinfo_t *found = NULL;
if ( !( found = bsearch( source, (void *)lumpinfo, (size_t)nTexLumps, sizeof(lumpinfo[0]), lump_sorter_by_name ) ) )
if ( !( found = reinterpret_cast<lumpinfo_t*>(bsearch( source, (void *)lumpinfo, (size_t)nTexLumps, sizeof(lumpinfo[0]), lump_sorter_by_name ) )) )
printf ("WARNING: texture %s not found in BSP's wad file list!\n", source->name);
return found;

View file

@ -377,13 +377,13 @@ int main (int argc, char **argv)
{
int i;
printf ("\nqlumpy "VERSION" by John Carmack, copyright (c) 1994 Id Software.\n");
printf ("\nqlumpy " VERSION " by John Carmack, copyright (c) 1994 Id Software.\n");
printf ("Portions copyright (c) 1998 Valve LLC (%s)\n", __DATE__ );
if (argc == 1)
Error ("qlumpy [-archive directory] [-8bit] [-proj <project>] scriptfile [scriptfile ...]");
lumpbuffer = malloc (MAXLUMP);
lumpbuffer = reinterpret_cast<byte*>(malloc (MAXLUMP));
do16bit = true;
for( i=1; i<argc; i++ )

View file

@ -152,7 +152,7 @@ triangulation_t *AllocTriangulation (dplane_t *plane)
HANDLE h;
if ( h = GlobalAlloc( GMEM_FIXED | GMEM_ZEROINIT, sizeof(triangulation_t) ) )
{
t = GlobalLock( h );
t = reinterpret_cast<triangulation_t*>(GlobalLock( h ));
t->numpoints = 0;
t->numedges = 0;
@ -850,7 +850,7 @@ void CreateDirectLights (void)
if( VectorAvg( p->totallight ) >= dlight_threshold )
{
numdlights++;
dl = calloc(1, sizeof(directlight_t));
dl = reinterpret_cast<directlight_t*>(calloc(1, sizeof(directlight_t)));
VectorCopy (p->origin, dl->origin);
@ -886,7 +886,7 @@ void CreateDirectLights (void)
continue;
numdlights++;
dl = calloc(1, sizeof(directlight_t));
dl = reinterpret_cast<directlight_t*>(calloc(1, sizeof(directlight_t)));
GetVectorForKey (e, "origin", dl->origin);
@ -1412,7 +1412,7 @@ void BuildFacelights (int facenum)
facelight[facenum].numsamples = l.numsurfpt;
for (k=0 ; k<MAXLIGHTMAPS; k++)
facelight[facenum].samples[k] = calloc(l.numsurfpt, sizeof(sample_t));
facelight[facenum].samples[k] = reinterpret_cast<sample_t*>(calloc(l.numsurfpt, sizeof(sample_t)));
spot = l.surfpt[0];
for (i=0 ; i<l.numsurfpt ; i++, spot += 3)

View file

@ -774,7 +774,7 @@ void MakeScales (int threadnum)
{
transfer_t *t, *t2;
patch->transfers = calloc (patch->numtransfers, sizeof(transfer_t));
patch->transfers = reinterpret_cast<transfer_t*>(calloc (patch->numtransfers, sizeof(transfer_t)));
if (!patch->transfers)
Error ("Memory allocation failure");
@ -1086,7 +1086,7 @@ readtransfers(char *transferfile, long numpatches)
{
int handle;
long readpatches = 0, readtransfers = 0, totalbytes = 0;
long start, end;
time_t start, end;
time(&start);
if ( (handle = _open( transferfile, _O_RDONLY | _O_BINARY )) != -1 )
{
@ -1109,7 +1109,7 @@ readtransfers(char *transferfile, long numpatches)
if ( (bytesread = _read(handle, &patch->numtransfers, sizeof(patch->numtransfers)))
== sizeof(patch->numtransfers) )
{
if ( patch->transfers = calloc(patch->numtransfers, sizeof(patch->transfers[0])) )
if ( patch->transfers = reinterpret_cast<transfer_t*>(calloc(patch->numtransfers, sizeof(patch->transfers[0]))) )
{
totalbytes += bytesread;
@ -1148,7 +1148,7 @@ readtransfers(char *transferfile, long numpatches)
}
_close( handle );
time(&end);
printf("%10.3fMB] (%d)\n",totalbytes/(1024.0*1024.0), end-start);
printf("%10.3fMB] (%d)\n",totalbytes/(1024.0*1024.0), static_cast<int>(end-start));
}
if (readpatches != numpatches )

View file

@ -75,7 +75,7 @@ Loads the node structure out of a .bsp file to be used for light occlusion
void MakeTnodes (dmodel_t *bm)
{
// 32 byte align the structs
tnodes = calloc( (numnodes+1), sizeof(tnode_t));
tnodes = reinterpret_cast<tnode_t*>(calloc( (numnodes+1), sizeof(tnode_t)));
tnodes = (tnode_t *)(((int)tnodes + 31)&~31);
tnode_p = tnodes;

View file

@ -290,7 +290,7 @@ getfiledata(char *filename, char *buffer, int buffersize)
{
long size = 0;
int handle;
long start,end;
time_t start,end;
time(&start);
if ( (handle = _open( filename, _O_RDONLY | _O_BINARY )) != -1 )
@ -304,7 +304,7 @@ getfiledata(char *filename, char *buffer, int buffersize)
}
_close( handle );
time(&end);
printf("%10.3fMB] (%d)\n",size/(1024.0*1024.0), end-start);
printf("%10.3fMB] (%d)\n",size/(1024.0*1024.0), static_cast<int>(end-start));
}
if (buffersize != size)
@ -485,7 +485,7 @@ void BuildVisMatrix (void)
qprintf ("visibility matrix: %5.1f megs\n", c/(1024*1024.0));
if ( h = GlobalAlloc( GMEM_FIXED | GMEM_ZEROINIT, c ) )
vismatrix = GlobalLock( h );
vismatrix = reinterpret_cast<byte*>(GlobalLock( h ));
else
Error ("vismatrix too big");
@ -496,7 +496,7 @@ void BuildVisMatrix (void)
if ( !incremental
|| !IsIncremental(incrementfile)
|| getfilesize(vismatfile) != c
|| getfiledata(vismatfile,vismatrix, c) != c )
|| getfiledata(vismatfile,reinterpret_cast<char*>(vismatrix), c) != c )
{
// memset (vismatrix, 0, c);
RunThreadsOn (numleafs-1, true, BuildVisLeafs);

View file

@ -97,7 +97,7 @@ void WriteSprite (FILE *spriteouthandle)
spritetemp.height = LittleLong (framesmaxs[1]);
spritetemp.numframes = LittleLong (sprite.numframes);
spritetemp.beamlength = LittleFloat (sprite.beamlength);
spritetemp.synctype = LittleFloat (sprite.synctype);
spritetemp.synctype = static_cast<synctype_t>(LittleFloat (sprite.synctype));
spritetemp.version = LittleLong (SPRITE_VERSION);
spritetemp.ident = LittleLong (IDSPRITEHEADER);
@ -510,7 +510,7 @@ void Cmd_Spritename (void)
framesmaxs[1] = -9999999;
if ( !lumpbuffer )
lumpbuffer = malloc (MAX_BUFFER_SIZE * 2); // *2 for padding
lumpbuffer = reinterpret_cast<byte*>(malloc (MAX_BUFFER_SIZE * 2)); // *2 for padding
if (!lumpbuffer)
Error ("Couldn't get buffer memory");

View file

@ -78,12 +78,12 @@ ReadBmpFile(
// Read bitmap bits (remainder of file)
cbBmpBits = bmfh.bfSize - ftell(pfile);
pbBmpBits = malloc(cbBmpBits);
pbBmpBits = reinterpret_cast<BYTE*>(malloc(cbBmpBits));
if (fread(pbBmpBits, cbBmpBits, 1/*count*/, pfile) != 1)
{ rc = -7; goto GetOut; }
// Set output parameters
*ppbPalette = malloc(sizeof rgrgbPalette);
*ppbPalette = reinterpret_cast<unsigned char*>(malloc(sizeof rgrgbPalette));
memcpy(*ppbPalette, rgrgbPalette, cbPalBytes);
*ppbBits = pbBmpBits;

View file

@ -18,6 +18,7 @@
#pragma warning( disable : 4237 )
#pragma warning( disable : 4305 )
#include <algorithm>
#include <stdio.h>
#include <stdlib.h>
@ -459,8 +460,8 @@ void SimplifyModel (void)
bonetable[k].bonecontroller = 0;
bonetable[k].flags = 0;
// set defaults
defaultpos[k] = kalloc( MAXSTUDIOANIMATIONS, sizeof( vec3_t ) );
defaultrot[k] = kalloc( MAXSTUDIOANIMATIONS, sizeof( vec3_t ) );
defaultpos[k] = reinterpret_cast<vec3_t*>(kalloc( MAXSTUDIOANIMATIONS, sizeof( vec3_t ) ));
defaultrot[k] = reinterpret_cast<vec3_t*>(kalloc( MAXSTUDIOANIMATIONS, sizeof( vec3_t ) ));
for (n = 0; n < MAXSTUDIOANIMATIONS; n++)
{
VectorCopy( model[i]->skeleton[j].pos, defaultpos[k][n] );
@ -1018,7 +1019,7 @@ void SimplifyModel (void)
}
else
{
sequence[i].panim[q]->anim[j][k] = kalloc( pvalue - data, sizeof( mstudioanimvalue_t ) );
sequence[i].panim[q]->anim[j][k] = reinterpret_cast<mstudioanimvalue_t*>(kalloc( pvalue - data, sizeof( mstudioanimvalue_t ) ));
memmove( sequence[i].panim[q]->anim[j][k], data, (pvalue - data) * sizeof( mstudioanimvalue_t ) );
}
// printf("%d(%d) ", sequence[i].panim[q]->numanim[j][k], n );
@ -1176,7 +1177,7 @@ s_mesh_t *lookup_mesh( s_model_t *pmodel, char *texturename )
}
pmodel->nummesh = i + 1;
pmodel->pmesh[i] = kalloc( 1, sizeof( s_mesh_t ) );
pmodel->pmesh[i] = reinterpret_cast<s_mesh_t*>(kalloc( 1, sizeof( s_mesh_t ) ));
pmodel->pmesh[i]->skinref = j;
@ -1192,11 +1193,11 @@ s_trianglevert_t *lookup_triangle( s_mesh_t *pmesh, int index )
int start = pmesh->alloctris;
pmesh->alloctris = index + 256;
if (pmesh->triangle) {
pmesh->triangle = realloc( pmesh->triangle, pmesh->alloctris * sizeof( *pmesh->triangle ) );
pmesh->triangle = reinterpret_cast<s_trianglevert_t(*)[3]>(realloc( pmesh->triangle, pmesh->alloctris * sizeof( *pmesh->triangle ) ));
kmemset( &pmesh->triangle[start], 0, (pmesh->alloctris - start) * sizeof( *pmesh->triangle ) );
}
else {
pmesh->triangle = kalloc( pmesh->alloctris, sizeof( *pmesh->triangle ) );
pmesh->triangle = reinterpret_cast<s_trianglevert_t(*)[3]>(kalloc( pmesh->alloctris, sizeof( *pmesh->triangle ) ));
}
}
@ -1331,8 +1332,8 @@ void TextureCoordRanges( s_mesh_t *pmesh, s_texture_t *ptexture )
for (i=0 ; i<pmesh->numtris ; i++)
{
float local_min, local_max;
local_min = min( pmesh->triangle[i][0].u, min( pmesh->triangle[i][1].u, pmesh->triangle[i][2].u ));
local_max = max( pmesh->triangle[i][0].u, max( pmesh->triangle[i][1].u, pmesh->triangle[i][2].u ));
local_min = std::min( pmesh->triangle[i][0].u, std::min( pmesh->triangle[i][1].u, pmesh->triangle[i][2].u ));
local_max = std::max( pmesh->triangle[i][0].u, std::max( pmesh->triangle[i][1].u, pmesh->triangle[i][2].u ));
if (local_min < min_u) { min_u = local_min; k = i; k_max_u = local_max; }
if (local_max > max_u) { max_u = local_max; n = i; n_min_u = local_min; }
}
@ -1364,8 +1365,8 @@ void TextureCoordRanges( s_mesh_t *pmesh, s_texture_t *ptexture )
for (i=0 ; i<pmesh->numtris ; i++)
{
float local_min, local_max;
local_min = min( pmesh->triangle[i][0].v, min( pmesh->triangle[i][1].v, pmesh->triangle[i][2].v ));
local_max = max( pmesh->triangle[i][0].v, max( pmesh->triangle[i][1].v, pmesh->triangle[i][2].v ));
local_min = std::min( pmesh->triangle[i][0].v, std::min( pmesh->triangle[i][1].v, pmesh->triangle[i][2].v ));
local_max = std::max( pmesh->triangle[i][0].v, std::max( pmesh->triangle[i][1].v, pmesh->triangle[i][2].v ));
if (local_min < min_v) { min_v = local_min; k = i; k_max_v = local_max; }
if (local_max > max_v) { max_v = local_max; n = i; n_min_v = local_min; }
}
@ -1415,10 +1416,10 @@ void TextureCoordRanges( s_mesh_t *pmesh, s_texture_t *ptexture )
{
for (i=0 ; i<pmesh->numtris ; i++) {
for (j = 0; j < 3; j++) {
ptexture->max_s = max( pmesh->triangle[i][j].s, ptexture->max_s );
ptexture->min_s = min( pmesh->triangle[i][j].s, ptexture->min_s );
ptexture->max_t = max( pmesh->triangle[i][j].t, ptexture->max_t );
ptexture->min_t = min( pmesh->triangle[i][j].t, ptexture->min_t );
ptexture->max_s = std::max( static_cast<float>(pmesh->triangle[i][j].s), ptexture->max_s );
ptexture->min_s = std::min( static_cast<float>(pmesh->triangle[i][j].s), ptexture->min_s );
ptexture->max_t = std::max( static_cast<float>(pmesh->triangle[i][j].t), ptexture->max_t );
ptexture->min_t = std::min( static_cast<float>(pmesh->triangle[i][j].t), ptexture->min_t );
}
}
}
@ -1540,7 +1541,7 @@ void ResizeTexture( s_texture_t *ptexture )
printf("%.0f %.0f %.0f %.0f\n", ptexture->min_s, ptexture->max_s, ptexture->min_t, ptexture->max_t );
Error("texture too large\n");
}
pdest = malloc( ptexture->size );
pdest = reinterpret_cast<byte*>(malloc( ptexture->size ));
ptexture->pdata = pdest;
// data is saved as a multiple of 4
@ -2181,7 +2182,7 @@ void Option_Studio( )
{
if (!GetToken (false)) return;
model[nummodels] = kalloc( 1, sizeof( s_model_t ) );
model[nummodels] = reinterpret_cast<s_model_t*>(kalloc( 1, sizeof( s_model_t ) ));
bodypart[numbodyparts].pmodel[bodypart[numbodyparts].nummodels] = model[nummodels];
strcpyn( model[nummodels]->name, token );
@ -2215,7 +2216,7 @@ void Option_Studio( )
int Option_Blank( )
{
model[nummodels] = kalloc( 1, sizeof( s_model_t ) );
model[nummodels] = reinterpret_cast<s_model_t*>(kalloc( 1, sizeof( s_model_t ) ));
bodypart[numbodyparts].pmodel[bodypart[numbodyparts].nummodels] = model[nummodels];
strcpyn( model[nummodels]->name, "blank" );
@ -2299,8 +2300,8 @@ void Grab_Animation( s_animation_t *panim)
for (index = 0; index < panim->numbones; index++)
{
panim->pos[index] = kalloc( MAXSTUDIOANIMATIONS, sizeof( vec3_t ) );
panim->rot[index] = kalloc( MAXSTUDIOANIMATIONS, sizeof( vec3_t ) );
panim->pos[index] = reinterpret_cast<vec3_t*>(kalloc( MAXSTUDIOANIMATIONS, sizeof( vec3_t ) ));
panim->rot[index] = reinterpret_cast<vec3_t*>(kalloc( MAXSTUDIOANIMATIONS, sizeof( vec3_t ) ));
}
cz = cos( zrotation );
@ -2382,8 +2383,8 @@ void Shift_Animation( s_animation_t *panim)
k_memtotal -= MAXSTUDIOANIMATIONS * sizeof( vec3_t ) * 2;
k_memtotal += size * 2;
ppos = kalloc( 1, size );
prot = kalloc( 1, size );
ppos = reinterpret_cast<vec3_t*>(kalloc( 1, size ));
prot = reinterpret_cast<vec3_t*>(kalloc( 1, size ));
memmove( ppos, &panim->pos[j][panim->startframe], size );
memmove( prot, &panim->rot[j][panim->startframe], size );
@ -2802,7 +2803,7 @@ int Cmd_Sequence( )
}
for (i = 0; i < numblends; i++)
{
panimation[numani] = kalloc( 1, sizeof( s_animation_t ) );
panimation[numani] = reinterpret_cast<s_animation_t*>(kalloc( 1, sizeof( s_animation_t ) ));
sequence[numseq].panim[i] = panimation[numani];
sequence[numseq].panim[i]->startframe = start;
sequence[numseq].panim[i]->endframe = end;

View file

@ -106,7 +106,7 @@ typedef struct
} s_bonefixup_t;
EXTERN s_bonefixup_t bonefixup[MAXSTUDIOSRCBONES];
int numbones;
EXTERN int numbones;
typedef struct
{
char name[32]; // bone name for symbolic links
@ -123,7 +123,7 @@ typedef struct
} s_bonetable_t;
EXTERN s_bonetable_t bonetable[MAXSTUDIOSRCBONES];
int numrenamedbones;
EXTERN int numrenamedbones;
typedef struct
{
char from[32];
@ -131,7 +131,7 @@ typedef struct
} s_renamebone_t;
EXTERN s_renamebone_t renamedbone[MAXSTUDIOSRCBONES];
int numhitboxes;
EXTERN int numhitboxes;
typedef struct
{
char name[32]; // bone name
@ -142,7 +142,7 @@ typedef struct
} s_bbox_t;
EXTERN s_bbox_t hitbox[MAXSTUDIOSRCBONES];
int numhitgroups;
EXTERN int numhitgroups;
typedef struct
{
int models;
@ -162,8 +162,8 @@ typedef struct
float end;
} s_bonecontroller_t;
s_bonecontroller_t bonecontroller[MAXSTUDIOSRCBONES];
int numbonecontrollers;
EXTERN s_bonecontroller_t bonecontroller[MAXSTUDIOSRCBONES];
EXTERN int numbonecontrollers;
typedef struct
{
@ -175,8 +175,8 @@ typedef struct
vec3_t org;
} s_attachment_t;
s_attachment_t attachment[MAXSTUDIOSRCBONES];
int numattachments;
EXTERN s_attachment_t attachment[MAXSTUDIOSRCBONES];
EXTERN int numattachments;
typedef struct
{

View file

@ -531,7 +531,7 @@ void WriteFile (void)
int total = 0;
int i;
pStart = kalloc( 1, FILEBUFFER );
pStart = reinterpret_cast<byte*>(kalloc( 1, FILEBUFFER ));
StripExtension (outname);

View file

@ -557,7 +557,7 @@ void PortalFlow (portal_t *p)
Error ("PortalFlow: reflowed");
p->status = stat_working;
p->visbits = malloc (bitbytes);
p->visbits = reinterpret_cast<byte*>(malloc (bitbytes));
memset (p->visbits, 0, bitbytes);
memset (&data, 0, sizeof(data));
@ -629,7 +629,7 @@ void BasePortalVis (int threadnum)
break;
p = portals+i;
p->mightsee = malloc (bitbytes);
p->mightsee = reinterpret_cast<byte*>(malloc (bitbytes));
memset (p->mightsee, 0, bitbytes);
memset (portalsee, 0, numportals*2);

View file

@ -37,7 +37,6 @@ int bitbytes; // (portalleafs+63)>>3
int bitlongs;
qboolean fastvis;
qboolean verbose;
//=============================================================================
@ -68,7 +67,7 @@ winding_t *NewWinding (int points)
Error ("NewWinding: %i points", points);
size = (int)((winding_t *)0)->points[points];
w = malloc (size);
w = reinterpret_cast<winding_t*>(malloc (size));
memset (w, 0, size);
return w;
@ -361,10 +360,10 @@ void LoadPortals (char *name)
bitlongs = bitbytes/sizeof(long);
// each file portal is split into two memory portals
portals = malloc(2*numportals*sizeof(portal_t));
portals = reinterpret_cast<portal_t*>(malloc(2*numportals*sizeof(portal_t)));
memset (portals, 0, 2*numportals*sizeof(portal_t));
leafs = malloc(portalleafs*sizeof(leaf_t));
leafs = reinterpret_cast<leaf_t*>(malloc(portalleafs*sizeof(leaf_t)));
memset (leafs, 0, portalleafs*sizeof(leaf_t));
originalvismapsize = portalleafs*((portalleafs+7)/8);
@ -501,7 +500,7 @@ int main (int argc, char **argv)
LoadPortals (portalfile);
uncompressed = malloc(bitbytes*portalleafs);
uncompressed = reinterpret_cast<byte*>(malloc(bitbytes*portalleafs));
memset (uncompressed, 0, bitbytes*portalleafs);
CalcVis ();