+# TODO: when deleting this Makefile, don't forget to also delete conftest.cpp
+# which is only required by this Makefile
+
+ifeq ($(I_KNOW_MAKEFILE_IS_DEPRECATED),)
+ $(shell printf 'ERROR: Makefile build is deprecated, use CMake instead, see README.md\n\n' >&2)
+ $(error I_KNOW_MAKEFILE_IS_DEPRECATED is not set)
+else
+ $(shell printf 'WARNING: deprecated Makefile build enforced\n\n' >&2)
+endif
+
MAKEFILE_CONF ?= Makefile.conf
-include $(MAKEFILE_CONF)
CPPFLAGS ?=
LIBS ?=
RADIANT_ABOUTMSG ?= Custom build
+RADIANT_NAME ?= NetRadiant
+RADIANT_BASENAME ?= netradiant
# warning: this directory may NOT contain any files other than the ones written by this Makefile!
# NEVER SET THIS TO A SYSTEM WIDE "bin" DIRECTORY!
else
ifeq ($(OS),Win32)
- CPPFLAGS_COMMON += -DWIN32 -D_WIN32 -D_inline=inline
+ CPPFLAGS_COMMON += -DWIN32 -D_WIN32 -D_inline=inline -DWORKAROUND_WINDOWS_FLOATING_WINDOW=1 -DWORKAROUND_WINDOWS_GTK2_GLWIDGET=1
CFLAGS_COMMON += -mms-bitfields
LDFLAGS_DLL = -Wl,--add-stdcall-alias
LIBS_COMMON = -lws2_32 -luser32 -lgdi32 -lole32
RADIANT_VERSION = $(RADIANT_VERSION_NUMBER)n
Q3MAP_VERSION = 2.5.17n
-# Executable extension
-RADIANT_EXECUTABLE := $(EXE)
-
GIT_VERSION := $(shell $(GIT) rev-parse --short HEAD $(STDERR_TO_DEVNULL))
ifneq ($(GIT_VERSION),)
RADIANT_VERSION := $(RADIANT_VERSION)-git-$(GIT_VERSION)
Q3MAP_VERSION := $(Q3MAP_VERSION)-git-$(GIT_VERSION)
endif
-CPPFLAGS += -DRADIANT_VERSION="\"$(RADIANT_VERSION)\"" -DRADIANT_MAJOR_VERSION="\"$(RADIANT_MAJOR_VERSION)\"" -DRADIANT_MINOR_VERSION="\"$(RADIANT_MINOR_VERSION)\"" -DRADIANT_PATCH_VERSION="\"$(RADIANT_PATCH_VERSION)\"" -DRADIANT_ABOUTMSG="\"$(RADIANT_ABOUTMSG)\"" -DQ3MAP_VERSION="\"$(Q3MAP_VERSION)\"" -DRADIANT_EXECUTABLE="\"$(RADIANT_EXECUTABLE)\""
+CPPFLAGS += -DRADIANT_VERSION="\"$(RADIANT_VERSION)\"" -DRADIANT_VERSION_STRING="\"$(RADIANT_VERSION_STRING)\"" -DRADIANT_ABOUTMSG="\"$(RADIANT_ABOUTMSG)\"" -DRADIANT_NAME="\"${RADIANT_NAME}\"" -DRADIANT_BASENAME="\"${RADIANT_BASENAME}\"" -DQ3MAP_VERSION="\"$(Q3MAP_VERSION)\""
CPPFLAGS += -DGTK_TARGET=2
.PHONY: all
.PHONY: binaries-h2data
binaries-h2data: \
- $(INSTALLDIR)/heretic2/h2data.$(EXE) \
- $(INSTALLDIR)/heretic2/h2data \
+ $(INSTALLDIR)/h2data.$(EXE) \
+ $(INSTALLDIR)/h2data \
.PHONY: binaries-tools-quake3
binaries-tools-quake3: \
%.o: %.c $(if $(findstring $(DEPEND_ON_MAKEFILE),yes),$(wildcard Makefile*),) | dependencies-check
$(CC) $< $(CFLAGS) $(CFLAGS_COMMON) $(CPPFLAGS_EXTRA) $(CPPFLAGS_COMMON) $(CPPFLAGS) $(TARGET_ARCH) -c -o $@
-
+ $(INSTALLDIR)/q3map2.$(EXE): LDFLAGS_EXTRA := -Wl,--large-address-aware
$(INSTALLDIR)/q3map2.$(EXE): LIBS_EXTRA := $(LIBS_XML) $(LIBS_GLIB) $(LIBS_PNG) $(LIBS_JPEG) $(LIBS_WEBP) $(LIBS_ZLIB)
$(INSTALLDIR)/q3map2.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) $(CPPFLAGS_GLIB) $(CPPFLAGS_PNG) $(CPPFLAGS_JPEG) $(CPPFLAGS_WEBP) -Itools/quake3/common -Ilibs -Iinclude
$(INSTALLDIR)/q3map2.$(EXE): \
contrib/bkgrnd2d/dialog.o \
contrib/bkgrnd2d/plugin.o \
-$(INSTALLDIR)/heretic2/h2data.$(EXE): LIBS_EXTRA := $(LIBS_XML)
-$(INSTALLDIR)/heretic2/h2data.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) -Itools/quake2/qdata_heretic2/common -Itools/quake2/qdata_heretic2/qcommon -Itools/quake2/qdata_heretic2 -Itools/quake2/common -Ilibs -Iinclude
-$(INSTALLDIR)/heretic2/h2data.$(EXE): \
- tools/quake2/qdata_heretic2/common/bspfile.o \
- tools/quake2/qdata_heretic2/common/cmdlib.o \
- tools/quake2/qdata_heretic2/common/inout.o \
- tools/quake2/qdata_heretic2/common/l3dslib.o \
- tools/quake2/qdata_heretic2/common/lbmlib.o \
- tools/quake2/qdata_heretic2/common/mathlib.o \
- tools/quake2/qdata_heretic2/common/md4.o \
- tools/quake2/qdata_heretic2/common/path_init.o \
- tools/quake2/qdata_heretic2/common/qfiles.o \
- tools/quake2/qdata_heretic2/common/scriplib.o \
- tools/quake2/qdata_heretic2/common/threads.o \
- tools/quake2/qdata_heretic2/common/token.o \
- tools/quake2/qdata_heretic2/common/trilib.o \
- tools/quake2/qdata_heretic2/qcommon/reference.o \
- tools/quake2/qdata_heretic2/qcommon/resourcemanager.o \
- tools/quake2/qdata_heretic2/qcommon/skeletons.o \
- tools/quake2/qdata_heretic2/animcomp.o \
- tools/quake2/qdata_heretic2/book.o \
- tools/quake2/qdata_heretic2/fmodels.o \
- tools/quake2/qdata_heretic2/images.o \
- tools/quake2/qdata_heretic2/jointed.o \
- tools/quake2/qdata_heretic2/models.o \
- tools/quake2/qdata_heretic2/pics.o \
- tools/quake2/qdata_heretic2/qdata.o \
- tools/quake2/qdata_heretic2/qd_skeletons.o \
- tools/quake2/qdata_heretic2/sprites.o \
- tools/quake2/qdata_heretic2/svdcmp.o \
- tools/quake2/qdata_heretic2/tables.o \
- tools/quake2/qdata_heretic2/tmix.o \
- tools/quake2/qdata_heretic2/video.o \
+$(INSTALLDIR)/h2data.$(EXE): LIBS_EXTRA := $(LIBS_XML)
+$(INSTALLDIR)/h2data.$(EXE): CPPFLAGS_EXTRA := $(CPPFLAGS_XML) -Itools/heretic2/common -Itools/heretic2/qcommon -Itools/heretic2/h2data -Itools/quake2/common -Ilibs -Iinclude
+$(INSTALLDIR)/h2data.$(EXE): \
+ tools/heretic2/common/bspfile.o \
+ tools/heretic2/common/cmdlib.o \
+ tools/heretic2/common/inout.o \
+ tools/heretic2/common/l3dslib.o \
+ tools/heretic2/common/lbmlib.o \
+ tools/heretic2/common/mathlib.o \
+ tools/heretic2/common/md4.o \
+ tools/heretic2/common/path_init.o \
+ tools/heretic2/common/qfiles.o \
+ tools/heretic2/common/scriplib.o \
+ tools/heretic2/common/threads.o \
+ tools/heretic2/common/token.o \
+ tools/heretic2/common/trilib.o \
+ tools/heretic2/qcommon/reference.o \
+ tools/heretic2/qcommon/resourcemanager.o \
+ tools/heretic2/qcommon/skeletons.o \
+ tools/heretic2/h2data/animcomp.o \
+ tools/heretic2/h2data/book.o \
+ tools/heretic2/h2data/fmodels.o \
+ tools/heretic2/h2data/images.o \
+ tools/heretic2/h2data/jointed.o \
+ tools/heretic2/h2data/models.o \
+ tools/heretic2/h2data/pics.o \
+ tools/heretic2/h2data/qdata.o \
+ tools/heretic2/h2data/qd_skeletons.o \
+ tools/heretic2/h2data/sprites.o \
+ tools/heretic2/h2data/svdcmp.o \
+ tools/heretic2/h2data/tables.o \
+ tools/heretic2/h2data/tmix.o \
+ tools/heretic2/h2data/video.o \
libl_net.$(A) \
$(if $(findstring $(OS),Win32),icons/h2data.o,) \
.PHONY: install-data
install-data: binaries
- $(MKDIR) $(INSTALLDIR)/games
- DOWNLOAD_GAMEPACKS="$(DOWNLOAD_GAMEPACKS)" DOWNLOADDIR="$(DOWNLOADDIR)" INSTALLDIR="$(INSTALLDIR)" GIT="$(GIT)" SVN="$(SVN)" WGET="$(WGET)" RM_R="$(RM_R)" MV="$(MV)" UNZIPPER="$(UNZIPPER)" ECHO="$(ECHO)" SH="$(SH)" CP="$(CP)" CP_R="$(CP_R)" $(SH) gamepack-manager
+ DOWNLOAD_GAMEPACKS="$(DOWNLOAD_GAMEPACKS)" DOWNLOADDIR="$(DOWNLOADDIR)" INSTALLDIR="$(INSTALLDIR)/gamepacks" GIT="$(GIT)" SVN="$(SVN)" WGET="$(WGET)" RM_R="$(RM_R)" MV="$(MV)" UNZIPPER="$(UNZIPPER)" ECHO="$(ECHO)" CP="$(CP)" CP_R="$(CP_R)" ./gamepack-manager
$(ECHO) $(RADIANT_MAJOR_VERSION) > $(INSTALLDIR)/RADIANT_MAJOR
$(ECHO) $(RADIANT_MINOR_VERSION) > $(INSTALLDIR)/RADIANT_MINOR
$(ECHO) $(RADIANT_PATCH_VERSION) > $(INSTALLDIR)/RADIANT_PATCH
filter_face_shader g_filter_face_hint( "textures/common/hint" );
filter_brush_any_face g_filter_brush_hint( &g_filter_face_hint );
+ filter_face_shader g_filter_face_hintlocal( "textures/common/hintlocal" );
+ filter_brush_any_face g_filter_brush_hintlocal( &g_filter_face_hintlocal );
+
filter_face_shader g_filter_face_hint_q2( "textures/hint" );
filter_brush_any_face g_filter_brush_hint_q2( &g_filter_face_hint_q2 );
filter_face_shader g_filter_face_hint_ja( "textures/system/hint" );
filter_brush_any_face g_filter_brush_hint_ja( &g_filter_face_hint_ja );
+filter_face_shader g_filter_face_subtlehint( "textures/common/subtlehint" );
+filter_brush_any_face g_filter_brush_subtlehint( &g_filter_face_subtlehint );
+
filter_face_shader g_filter_face_areaportal( "textures/common/areaportal" );
filter_brush_all_faces g_filter_brush_areaportal( &g_filter_face_areaportal );
add_face_filter( g_filter_face_caulk_ja, EXCLUDE_CAULK );
add_brush_filter( g_filter_brush_liquids, EXCLUDE_LIQUIDS );
add_brush_filter( g_filter_brush_hint, EXCLUDE_HINTSSKIPS );
+ add_brush_filter( g_filter_brush_hintlocal, EXCLUDE_HINTSSKIPS );
add_brush_filter( g_filter_brush_hint_q2, EXCLUDE_HINTSSKIPS );
add_brush_filter( g_filter_brush_hint_ja, EXCLUDE_HINTSSKIPS );
+ add_brush_filter( g_filter_brush_subtlehint, EXCLUDE_HINTSSKIPS );
add_brush_filter( g_filter_brush_clusterportal, EXCLUDE_CLUSTERPORTALS );
add_brush_filter( g_filter_brush_visportal, EXCLUDE_VISPORTALS );
add_brush_filter( g_filter_brush_areaportal, EXCLUDE_AREAPORTALS );
/* check for patches with adjacent edges that need to lod together */
PatchMapDrawSurfs( e );
+ if ( debugClip ) {
+ AddTriangleModels( e );
+ }
+
/* build an initial bsp tree using all of the sides of all of the structural brushes */
faces = MakeStructuralBSPFaceList( entities[ 0 ].brushes );
tree = FaceBSP( faces );
Sys_FPrintf( SYS_NOXML, "**********************\n" );
polyline = LeakFile( tree, lineFilePath );
leaknode = xmlNewNode( NULL, (xmlChar*)"message" );
- xmlNodeSetContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
+ xmlNodeAddContent( leaknode, (xmlChar*)"MAP LEAKED\n" );
xmlAddChild( leaknode, polyline );
level[0] = (int) '0' + SYS_ERR;
level[1] = 0;
FloodAreas( tree );
/* create drawsurfs for triangle models */
- AddTriangleModels( e );
+ if ( !debugClip ) {
+ AddTriangleModels( e );
+ }
/* create drawsurfs for surface models */
AddEntitySurfaceModels( e );
portalFilePath[0] = 0;
surfaceFilePath[0] = 0;
+ if ( argc >= 2 && !strcmp( argv[ 1 ], "-bsp" ) ) {
+ argv++;
+ argc--;
+ }
/* note it */
Sys_Printf( "--- BSP ---\n" );
doingBSP = qtrue;
SetDrawSurfacesBuffer();
- mapDrawSurfs = safe_malloc( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
- memset( mapDrawSurfs, 0, sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
+ mapDrawSurfs = safe_malloc0( sizeof( mapDrawSurface_t ) * MAX_MAP_DRAW_SURFS );
numMapDrawSurfs = 0;
tempSource[ 0 ] = '\0';
i++;
Sys_Printf( "Distance epsilon set to %f\n", distanceEpsilon );
}
- else if ( !strcmp( argv[ i ], "-mv" ) ) {
+ else if ( !strcmp( argv[ i ], "-fastmeta" ) ) {
+ maxLMSurfaceVerts = 64;
+ maxSurfaceVerts = 999;
+ maxSurfaceIndexes = 6000;
+ Sys_Printf( "Maximum per-surface vertex count set to %d\n", maxSurfaceVerts );
+ Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes );
+ Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts );
+ }
+ else if ( !strcmp( argv[ i ], "-maxsurfacevertices" ) ) {
+ maxSurfaceVerts = atoi( argv[ i + 1 ] );
+ if ( maxSurfaceVerts < 3 ) {
+ maxSurfaceVerts = 3;
+ }
+ i++;
+ Sys_Printf( "Maximum per-surface vertex count set to %d\n", maxSurfaceVerts );
+ }
+ else if ( !strcmp( argv[ i ], "-maxsurfaceindexes" ) || !strcmp( argv[ i ], "-mi" ) ) {
+ maxSurfaceIndexes = atoi( argv[ i + 1 ] );
+ if ( maxSurfaceIndexes < 3 ) {
+ maxSurfaceIndexes = 3;
+ }
+ i++;
+
+ if ( !strcmp( argv[ i ], "-mi" ) ) {
+ Sys_Printf( "The -mi argument is deprecated, use \"-maxsurfaceindexes\" instead\n" );
+ }
+ else {
+ Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes );
+ }
+ }
+ else if ( !strcmp( argv[ i ], "-maxlightmapvertices" ) || !strcmp( argv[ i ], "-mv" ) ) {
maxLMSurfaceVerts = atoi( argv[ i + 1 ] );
if ( maxLMSurfaceVerts < 3 ) {
maxLMSurfaceVerts = 3;
maxSurfaceVerts = maxLMSurfaceVerts;
}
i++;
+
+ if ( !strcmp( argv[ i ], "-mv" ) ) {
+ Sys_Printf( "The -mv argument is deprecated, use \"-maxlightmapvertices\" instead\n" );
+ }
+ else {
Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts );
}
- else if ( !strcmp( argv[ i ], "-mi" ) ) {
- maxSurfaceIndexes = atoi( argv[ i + 1 ] );
- if ( maxSurfaceIndexes < 3 ) {
- maxSurfaceIndexes = 3;
- }
- i++;
- Sys_Printf( "Maximum per-surface index count set to %d\n", maxSurfaceIndexes );
}
else if ( !strcmp( argv[ i ], "-np" ) ) {
npDegrees = atof( argv[ i + 1 ] );
Sys_Printf( "Debug portal surfaces enabled\n" );
debugPortals = qtrue;
}
+ else if ( !strcmp( argv[ i ], "-debugclip" ) ) {
+ Sys_Printf( "Debug model clip enabled\n" );
+ debugClip = qtrue;
+ }
+ else if ( !strcmp( argv[ i ], "-snapmodelclip" ) ) {
+ Sys_Printf( "Snapping model clip enabled\n" );
+ snapModelClip = qtrue;
+ }
else if ( !strcmp( argv[ i ], "-sRGBtex" ) ) {
texturesRGB = qtrue;
Sys_Printf( "Textures are in sRGB\n" );
else if ( !strcmp( argv[ i ], "-bspfile" ) )
{
strcpy( BSPFilePath, argv[i + 1] );
+ argv[ i ] = NULL;
i++;
+ argv[ i ] = NULL;
Sys_Printf( "Use %s as bsp file\n", BSPFilePath );
}
else if ( !strcmp( argv[ i ], "-linfile" ) )
{
strcpy( lineFilePath, argv[i + 1] );
+ argv[ i ] = NULL;
i++;
+ argv[ i ] = NULL;
Sys_Printf( "Use %s as line file\n", lineFilePath );
}
else if ( !strcmp( argv[ i ], "-prtfile" ) )
{
strcpy( portalFilePath, argv[i + 1] );
+ argv[ i ] = NULL;
i++;
+ argv[ i ] = NULL;
Sys_Printf( "Use %s as portal file\n", portalFilePath );
}
else if ( !strcmp( argv[ i ], "-srffile" ) )
{
strcpy( surfaceFilePath, argv[i + 1] );
+ argv[ i ] = NULL;
i++;
+ argv[ i ] = NULL;
Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
}
- else if ( !strcmp( argv[ i ], "-bsp" ) ) {
- Sys_Printf( "-bsp argument unnecessary\n" );
- }
else if ( !strcmp( argv[ i ], "-noob" ) ) {
Sys_Printf( "No oBs!\n" );
noob = qtrue;
/* create a light */
numSunLights++;
- light = safe_malloc( sizeof( *light ) );
- memset( light, 0, sizeof( *light ) );
+ light = safe_malloc0( sizeof( *light ) );
light->next = lights;
lights = light;
/* create a light */
numPointLights++;
- light = safe_malloc( sizeof( *light ) );
- memset( light, 0, sizeof( *light ) );
+ light = safe_malloc0( sizeof( *light ) );
light->next = lights;
lights = light;
VectorScale( origin, 0.5f, origin );
/* create a light */
- light = safe_malloc( sizeof( *light ) );
- memset( light, 0, sizeof( *light ) );
+ light = safe_malloc0( sizeof( *light ) );
light->next = lights;
lights = light;
for ( i = 0; i < w->numpoints; i++ )
{
VectorSubtract( w->p[ i ], point, dirs[ i ] );
- VectorNormalize( dirs[ i ], dirs[ i ] );
+ VectorFastNormalize( dirs[ i ], dirs[ i ] );
}
/* duplicate first vertex to avoid mod operation */
angle = acos( dot );
CrossProduct( dirs[ i ], dirs[ j ], triVector );
- if ( VectorNormalize( triVector, triNormal ) < 0.0001f ) {
+ if ( VectorFastNormalize( triVector, triNormal ) < 0.0001f ) {
continue;
}
}
/* vortex: apply gridscale and gridambientscale here */
- ColorToBytes( color, bgp->ambient[ i ], gridScale * gridAmbientScale );
+ if (gp->directed[i][0] || gp->directed[i][1] || gp->directed[i][2]) {
+ /*
+ * HACK: if there's a non-zero directed component, this
+ * lightgrid cell is useful. However, ioq3 skips grid
+ * cells with zero ambient. So let's force ambient to be
+ * nonzero unless directed is zero too.
+ */
+ ColorToBytesNonZero(color, bgp->ambient[i], gridScale * gridAmbientScale);
+ } else {
+ ColorToBytes(color, bgp->ambient[i], gridScale * gridAmbientScale);
+ }
ColorToBytes( gp->directed[ i ], bgp->directed[ i ], gridScale );
}
numBSPGridPoints = numRawGridPoints;
/* allocate lightgrid */
- rawGridPoints = safe_malloc( numRawGridPoints * sizeof( *rawGridPoints ) );
- memset( rawGridPoints, 0, numRawGridPoints * sizeof( *rawGridPoints ) );
+ rawGridPoints = safe_malloc0( numRawGridPoints * sizeof( *rawGridPoints ) );
if ( bspGridPoints != NULL ) {
free( bspGridPoints );
}
- bspGridPoints = safe_malloc( numBSPGridPoints * sizeof( *bspGridPoints ) );
- memset( bspGridPoints, 0, numBSPGridPoints * sizeof( *bspGridPoints ) );
+ bspGridPoints = safe_malloc0( numBSPGridPoints * sizeof( *bspGridPoints ) );
/* clear lightgrid */
for ( i = 0; i < numRawGridPoints; i++ )
does what it says...
*/
-void LightWorld( const char *BSPFilePath, qboolean fastAllocate ){
+void LightWorld( const char *BSPFilePath, qboolean fastAllocate, qboolean noBounceStore ){
vec3_t color;
float f;
int b, bt;
qboolean minVertex, minGrid;
const char *value;
-
/* ydnar: smooth normals */
if ( shade ) {
Sys_Printf( "--- SmoothNormals ---\n" );
/* radiosity */
b = 1;
bt = bounce;
+
while ( bounce > 0 )
{
+ qboolean storeForReal = !noBounceStore;
+
/* store off the bsp between bounces */
- StoreSurfaceLightmaps( fastAllocate );
+ StoreSurfaceLightmaps( fastAllocate, storeForReal );
UnparseEntities();
- Sys_Printf( "Writing %s\n", BSPFilePath );
- WriteBSPFile( BSPFilePath );
+
+ if ( storeForReal ) {
+ Sys_Printf( "Writing %s\n", BSPFilePath );
+ WriteBSPFile( BSPFilePath );
+ }
/* note it */
Sys_Printf( "\n--- Radiosity (bounce %d of %d) ---\n", b, bt );
SetupEnvelopes( qfalse, fastbounce );
if ( numLights == 0 ) {
Sys_Printf( "No diffuse light to calculate, ending radiosity.\n" );
+ if ( noBounceStore ) {
+ break;
+ }
return;
}
bounce--;
b++;
}
+
/* ydnar: store off lightmaps */
- StoreSurfaceLightmaps( fastAllocate );
+ StoreSurfaceLightmaps( fastAllocate, qtrue );
+}
+
+
+
+/*
+ LoadSurfaceFlags()
+ added by spoon to get back the changed surfaceflags
+ from tex file
+*/
+
+void LoadSurfaceFlags( char *filename ) {
+ int i;
+
+ for( i = 0; i < numBSPShaders; i++ ) {
+ shaderInfo_t *si;
+
+ si = ShaderInfoForShader( bspShaders[i].shader );
+
+ bspShaders[ i ].surfaceFlags = si->surfaceFlags;
+ }
}
int lightmapMergeSize = 0;
qboolean lightSamplesInsist = qfalse;
qboolean fastAllocate = qfalse;
+ qboolean noBounceStore = qfalse;
/* note it */
Sys_Printf( "--- Light ---\n" );
Sys_Printf( "No lightmaps yo\n" );
}
+ else if ( !strcmp( argv[ i ], "-bouncecolorratio" ) ) {
+ f = atof( argv[ i + 1 ] );
+ bounceColorRatio *= f;
+ if ( bounceColorRatio > 1 ) {
+ bounceColorRatio = 1;
+ }
+ if ( bounceColorRatio < 0 ) {
+ bounceColorRatio = 0;
+ }
+ Sys_Printf( "Bounce color ratio set to %f\n", bounceColorRatio );
+ i++;
+ }
+
else if ( !strcmp( argv[ i ], "-bouncescale" ) ) {
f = atof( argv[ i + 1 ] );
bounceScale *= f;
else if ( !strcmp( argv[ i ], "-lightmapdir" ) ) {
lmCustomDir = argv[i + 1];
+ argv[ i ] = NULL;
i++;
+ argv[ i ] = NULL;
Sys_Printf( "Lightmap directory set to %s\n", lmCustomDir );
externalLightmaps = qtrue;
Sys_Printf( "Storing all lightmaps externally\n" );
Sys_Printf( "Storing bounced light (radiosity) only\n" );
}
+ else if ( !strcmp( argv[ i ], "-nobouncestore" ) ) {
+ noBounceStore = qtrue;
+ Sys_Printf( "Do not store BSP, lightmap and shader files between bounces\n" );
+ }
+
else if ( !strcmp( argv[ i ], "-nocollapse" ) ) {
noCollapse = qtrue;
Sys_Printf( "Identical lightmap collapsing disabled\n" );
Sys_Printf( "Faster mode enabled\n" );
}
- else if ( !strcmp( argv[ i ], "-fastallocate" ) ) {
+ else if ( !strcmp( argv[ i ], "-fastallocate" ) || !strcmp( argv[ i ], "-fastlightmapsearch" ) ) {
fastAllocate = qtrue;
- Sys_Printf( "Fast allocation mode enabled\n" );
+
+ if ( !strcmp( argv[ i ], "-fastlightmapsearch" ) ) {
+ Sys_Printf( "The -fastlightmapsearch argument is deprecated, use \"-fastallocate\" instead\n" );
+ }
+ else {
+ Sys_Printf( "Fast lightmap allocation mode enabled\n" );
+ }
+ }
+
+ else if ( !strcmp( argv[ i ], "-slowallocate" ) ) {
+ fastAllocate = qfalse;
+ Sys_Printf( "Slow lightmap allocation mode enabled (default)\n" );
}
else if ( !strcmp( argv[ i ], "-fastgrid" ) ) {
if ( ( atof( argv[ i + 1 ] ) != 0 ) && ( atof( argv[ i + 1 ] )) < 1 ) {
noVertexLighting = ( atof( argv[ i + 1 ] ) );
i++;
- Sys_Printf( "Setting vertex lighting globally to %d\n", noVertexLighting );
+ Sys_Printf( "Setting vertex lighting globally to %f\n", noVertexLighting );
}
else{
Sys_Printf( "Disabling vertex lighting\n" );
else if ( !strcmp( argv[ i ], "-bspfile" ) )
{
strcpy( BSPFilePath, argv[i + 1] );
+ argv[ i ] = NULL;
i++;
+ argv[ i ] = NULL;
Sys_Printf( "Use %s as bsp file\n", BSPFilePath );
}
else if ( !strcmp( argv[ i ], "-srffile" ) )
{
strcpy( surfaceFilePath, argv[i + 1] );
+ argv[ i ] = NULL;
i++;
+ argv[ i ] = NULL;
Sys_Printf( "Use %s as surface file\n", surfaceFilePath );
}
/* unhandled args */
Sys_Printf( "Restricted lightmap searching enabled - block size adjusted to %d\n", lightmapSearchBlockSize );
}
+ /* arg checking */
+ if ( i != ( argc - 1 ) ) {
+ Error( "usage: q3map -light [options] <bspfile>" );
+ }
+
strcpy( source, ExpandArg( argv[ i ] ) );
StripExtension( source );
DefaultExtension( source, ".map" );
SetupTraceNodes();
/* light the world */
- LightWorld( BSPFilePath, fastAllocate );
+ LightWorld( BSPFilePath, fastAllocate, noBounceStore );
/* write out the bsp */
UnparseEntities();
+/*
+ Modulo1IfNegative()
+ Previously the bias computation was doing:
+
+ while ( f < 0.0f ) {
+ f += 1.0f;
+ }
+
+ That may end in infinite loop in some case.
+ It may also be slower because of useless loops.
+ I don't know what that computation is for.
+ -- illwieckz
+*/
+float Modulo1IfNegative( float f ){
+ return f < 0.0f ? f - floor( f ) : f;
+}
+
/*
*/
qboolean RadSampleImage( byte *pixels, int width, int height, float st[ 2 ], float color[ 4 ] ){
- float sto[ 2 ];
int x, y;
-
/* clear color first */
color[ 0 ] = color[ 1 ] = color[ 2 ] = color[ 3 ] = 255;
return qfalse;
}
- /* bias st */
- sto[ 0 ] = st[ 0 ];
- while ( sto[ 0 ] < 0.0f )
- sto[ 0 ] += 1.0f;
- sto[ 1 ] = st[ 1 ];
- while ( sto[ 1 ] < 0.0f )
- sto[ 1 ] += 1.0f;
-
/* get offsets */
- x = ( (float) width * sto[ 0 ] ) + 0.5f;
+ x = ( (float) width * Modulo1IfNegative( st[ 0 ] ) ) + 0.5f;
x %= width;
- y = ( (float) height * sto[ 1 ] ) + 0.5f;
+ y = ( (float) height * Modulo1IfNegative( st[ 1 ] ) ) + 0.5f;
y %= height;
/* get pixel */
#define SAMPLE_GRANULARITY 6
static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm, shaderInfo_t *si, radWinding_t *rw, vec3_t average, vec3_t gradient, int *style ){
- int i, j, k, l, v, x, y, samples;
+ int i, j, k, l, v, x, y, samples, avgcolor;
vec3_t color, mins, maxs;
vec4_t textureColor;
float alpha, alphaI, bf;
VectorCopy( si->averageColor, textureColor );
textureColor[ 4 ] = 255.0f;
}
+ avgcolor = ( textureColor[ 0 ] + textureColor[ 1 ] + textureColor[ 2 ] ) / 3;
for ( i = 0; i < 3; i++ )
- color[ i ] = ( textureColor[ i ] / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f );
+ color[ i ] = ( ( textureColor[ i ] * bounceColorRatio + ( avgcolor * ( 1 - bounceColorRatio ) ) ) / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f );
+ // color[ i ] = ( textureColor[ i ] / 255 ) * ( rw->verts[ samples ].color[ lightmapNum ][ i ] / 255.0f );
AddPointToBounds( color, mins, maxs );
VectorAdd( average, color, average );
VectorCopy( si->averageColor, textureColor );
textureColor[ 4 ] = 255;
}
- for ( i = 0; i < 3; i++ )
- color[ i ] = ( textureColor[ i ] / 255 ) * ( radLuxel[ i ] / 255 );
-
+ avgcolor = ( textureColor[ 0 ] + textureColor[ 1 ] + textureColor[ 2 ] ) / 3;
+ for ( l = 0; l < 3; l++ ){
+ color[ l ] = ( ( textureColor[ l ] * bounceColorRatio + ( avgcolor * ( 1 - bounceColorRatio ) ) ) / 255 ) * ( radLuxel[ l ] / 255 );
+ //Sys_Printf( "%i %i %i %i %i \n", (int) textureColor[ 0 ], (int) textureColor[ 1 ], (int) textureColor[ 2 ], (int) avgcolor, (int) color[ i ] );
+ }
AddPointToBounds( color, mins, maxs );
VectorAdd( average, color, average );
}
/* create a light */
- light = safe_malloc( sizeof( *light ) );
- memset( light, 0, sizeof( *light ) );
+ light = safe_malloc0( sizeof( *light ) );
/* attach it */
ThreadLock();
/* optionally create a point splashsplash light for first pass */
if ( original && si->backsplashFraction > 0 ) {
/* allocate a new point light */
- splash = safe_malloc( sizeof( *splash ) );
- memset( splash, 0, sizeof( *splash ) );
+ splash = safe_malloc0( sizeof( *splash ) );
splash->next = lights;
lights = splash;
snaps a plane to normal/distance epsilons
*/
- void SnapPlane( vec3_t normal, vec_t *dist, vec3_t center ){
+ void SnapPlane( vec3_t normal, vec_t *dist ){
// SnapPlane disabled by LordHavoc because it often messes up collision
// brushes made from triangles of embedded models, and it has little effect
// on anything else (axial planes are usually derived from snapped points)
VectorCopy( innormal, normal );
#if Q3MAP2_EXPERIMENTAL_SNAP_PLANE_FIX
- SnapPlaneImproved( normal, &dist, numPoints, (const vec3_t *) points );
+ if ( !doingModelClip ) {
+ SnapPlaneImproved( normal, &dist, numPoints, (const vec3_t *) points );
+ }
+ if ( doingModelClip && snapModelClip ) {
+ SnapPlane( normal, &dist );
+ }
#else
SnapPlane( normal, &dist );
#endif
}
/* create a new index map */
- im = safe_malloc( sizeof( *im ) );
- memset( im, 0, sizeof( *im ) );
+ im = safe_malloc0( sizeof( *im ) );
/* set it up */
im->w = w;
/* set particulars */
ds->numVerts = PicoGetSurfaceNumVertexes( surface );
- ds->verts = safe_malloc( ds->numVerts * sizeof( ds->verts[ 0 ] ) );
- memset( ds->verts, 0, ds->numVerts * sizeof( ds->verts[ 0 ] ) );
+ ds->verts = safe_malloc0( ds->numVerts * sizeof( ds->verts[ 0 ] ) );
ds->numIndexes = PicoGetSurfaceNumIndexes( surface );
- ds->indexes = safe_malloc( ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
- memset( ds->indexes, 0, ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
+ ds->indexes = safe_malloc0( ds->numIndexes * sizeof( ds->indexes[ 0 ] ) );
/* copy vertexes */
for ( i = 0; i < ds->numVerts; i++ )
/* set up brush sides */
buildBrush->numsides = 5;
buildBrush->sides[ 0 ].shaderInfo = si;
- for ( j = 1; j < buildBrush->numsides; j++ )
- buildBrush->sides[ j ].shaderInfo = NULL; // don't emit these faces as draw surfaces, should make smaller BSPs; hope this works
+ for ( j = 1; j < buildBrush->numsides; j++ ) {
+ if ( debugClip ) {
+ buildBrush->sides[ 0 ].shaderInfo = ShaderInfoForShader( "debugclip2" );
+ buildBrush->sides[ j ].shaderInfo = ShaderInfoForShader( "debugclip" );
+ }
+ else {
+ buildBrush->sides[ j ].shaderInfo = NULL; // don't emit these faces as draw surfaces, should make smaller BSPs; hope this works
+ }
+ }
buildBrush->sides[ 0 ].planenum = FindFloatPlane( plane, plane[ 3 ], 3, points );
buildBrush->sides[ 1 ].planenum = FindFloatPlane( pa, pa[ 3 ], 2, &points[ 1 ] ); // pa contains points[1] and points[2]
/* note it */
Sys_FPrintf( SYS_VRB, "--- AddTriangleModels ---\n" );
+ doingModelClip = qtrue;
+
/* get current brush entity targetname */
if ( e == entities ) {
targetName = "";
remap = remap2;
}
}
+
+ doingModelClip = qfalse;
}
------------------------------------------------------------------------------- */
/* platform-specific */
-#if GDEF_OS_LINUX || GDEF_OS_MACOS
- #define Q_UNIX
-#endif
-
-#ifdef Q_UNIX
+#if GDEF_OS_POSIX
#include <unistd.h>
#include <pwd.h>
#include <limits.h>
/* general */
-#include "version.h" /* ttimo: might want to guard that if built outside of the GtkRadiant tree */
-
#include "cmdlib.h"
#include "mathlib.h"
#include "md5lib.h"
------------------------------------------------------------------------------- */
-#define MAC_STATIC_HACK 0
-#if GDEF_OS_MACOS && MAC_STATIC_HACK
- #define MAC_STATIC static
-#else
- #define MAC_STATIC
-#endif
-
-#if 1
#if GDEF_OS_WINDOWS
#define Q_stricmp stricmp
#define Q_strncasecmp strnicmp
#define Q_stricmp strcasecmp
#define Q_strncasecmp strncasecmp
#endif
+
+// hack to declare and define in the same file
+#ifdef MAIN_C
+ #define Q_EXTERN
+ #define Q_ASSIGN( a ) = a
+#else
+ #define Q_EXTERN extern
+ #define Q_ASSIGN( a )
#endif
/* macro version */
/* general */
#define MAX_QPATH 64
-#define MAX_IMAGES 512
+#define MAX_IMAGES 2048
#define DEFAULT_IMAGE "*default"
-#define MAX_MODELS 512
+#define MAX_MODELS 2048
#define DEF_BACKSPLASH_FRACTION 0.05f /* 5% backsplash by default */
#define DEF_BACKSPLASH_DISTANCE 23
#define C_DETAIL 0x08000000 /* THIS MUST BE THE SAME AS IN RADIANT! */
+/* new tex surface flags, like Smokin'Guns */
+#define TEX_SURF_METAL 0x00001000
+#define TEX_SURF_WOOD 0x00080000
+#define TEX_SURF_CLOTH 0x00100000
+#define TEX_SURF_DIRT 0x00200000
+#define TEX_SURF_GLASS 0x00400000
+#define TEX_SURF_PLANT 0x00800000
+#define TEX_SURF_SAND 0x01000000
+#define TEX_SURF_SNOW 0x02000000
+#define TEX_SURF_STONE 0x04000000
+#define TEX_SURF_WATER 0x08000000
+#define TEX_SURF_GRASS 0x10000000
+#define TEX_SURF_BREAKABLE 0x20000000
+
+
/* shadow flags */
#define WORLDSPAWN_CAST_SHADOWS 1
#define WORLDSPAWN_RECV_SHADOWS 1
#define HINT_PRIORITY 1000 /* ydnar: force hint splits first and antiportal/areaportal splits last */
#define ANTIPORTAL_PRIORITY -1000
#define AREAPORTAL_PRIORITY -1000
-#define DETAIL_PRIORITY -3000
+#define DETAIL_PRIORITY -3000
#define PSIDE_FRONT 1
#define PSIDE_BACK 2
#define RAD_LUXEL_SIZE 3
#define SUPER_LUXEL_SIZE 4
#define SUPER_FLAG_SIZE 4
-#define FLAG_FORCE_SUBSAMPLING 1
+#define FLAG_FORCE_SUBSAMPLING 1
#define FLAG_ALREADY_SUBSAMPLED 2
#define SUPER_ORIGIN_SIZE 3
#define SUPER_NORMAL_SIZE 4
}
miniMapMode_t;
+typedef enum
+{
+ MINIMAP_SIDECAR_NONE,
+ MINIMAP_SIDECAR_UNVANQUISHED
+}
+miniMapSidecarFormat_t;
+
typedef struct game_s
{
char *arg; /* -game matches this */
int maxLMSurfaceVerts; /* default maximum meta surface verts */
int maxSurfaceVerts; /* default maximum surface verts */
int maxSurfaceIndexes; /* default maximum surface indexes (tris * 3) */
+ qboolean texFile; /* enable per shader prefix surface flags and .tex file */
qboolean emitFlares; /* when true, emit flare surfaces */
char *flareShader; /* default flare shader (MUST BE SET) */
qboolean wolfLight; /* when true, lights work like wolf q3map */
qboolean miniMapKeepAspect; /* minimap keep aspect ratio by letterboxing */
miniMapMode_t miniMapMode; /* minimap mode */
char *miniMapNameFormat; /* minimap name format */
+ miniMapSidecarFormat_t miniMapSidecarFormat; /* minimap sidecar format */
char *bspIdent; /* 4-letter bsp file prefix */
int bspVersion; /* bsp version to use */
qboolean lumpSwap; /* cod-style len/ofs order */
struct face_s *next;
int planenum;
int priority;
- //qboolean checked;
+ //qboolean checked;
int compileFlags;
winding_t *w;
}
}
surfaceType_t;
-char *surfaceTypes[ NUM_SURFACE_TYPES ]
+Q_EXTERN char *surfaceTypes[ NUM_SURFACE_TYPES ]
#ifndef MAIN_C
;
#else
float *bspLuxels[ MAX_LIGHTMAPS ];
float *radLuxels[ MAX_LIGHTMAPS ];
float *superLuxels[ MAX_LIGHTMAPS ];
- unsigned char *superFlags;
+ unsigned char *superFlags;
float *superOrigins;
float *superNormals;
int *superClusters;
/* light_ydnar.c */
void ColorToBytes( const float *color, byte *colorBytes, float scale );
+void ColorToBytesNonZero( const float *color, byte *colorBytes, float scale );
void SmoothNormals( void );
void MapRawLightmap( int num );
void SetupSurfaceLightmaps( void );
void StitchSurfaceLightmaps( void );
-void StoreSurfaceLightmaps( qboolean fastAllocate );
+void StoreSurfaceLightmaps( qboolean fastAllocate, qboolean storeForReal );
/* exportents.c */
void WriteBSPFile( const char *filename );
void PrintBSPFileSizes( void );
+void WriteTexFile( char *name );
+void LoadSurfaceFlags( char *filename );
+int GetSurfaceParm( const char *tex );
+void RestoreSurfaceFlags( char *filename );
+
epair_t *ParseEPair( void );
void ParseEntities( void );
void UnparseEntities( void );
------------------------------------------------------------------------------- */
-#ifdef MAIN_C
- #define Q_EXTERN
- #define Q_ASSIGN( a ) = a
-#else
- #define Q_EXTERN extern
- #define Q_ASSIGN( a )
-#endif
-
/* game support */
Q_EXTERN game_t games[]
#ifndef MAIN_C
=
{
#include "game_quake3.h"
+ ,
+ #include "game_nexuiz.h" /* must be after game_quake3.h as they share defines! */
+ ,
+ #include "game_oa.h" /* must be after game_quake3.h as they share defines! */
+ ,
+ #include "game_q3rally.h" /* must be after game_quake3.h as they share defines! */
,
#include "game_quakelive.h" /* must be after game_quake3.h as they share defines! */
,
- #include "game_nexuiz.h" /* must be after game_quake3.h as they share defines! */
+ #include "game_reaction.h" /* must be after game_quake3.h */
,
- #include "game_xonotic.h" /* must be after game_quake3.h as they share defines! */
+ #include "game_smokinguns.h" /* must be after game_quake3.h */
,
#include "game_tremulous.h" /*LinuxManMikeC: must be after game_quake3.h, depends on #define's set in it */
,
#include "game_unvanquished.h" /* must be after game_tremulous.h as they share defines! */
+ ,
+ #include "game_wop.h" /* must be after game_quake3.h as they share defines! */
+ ,
+ #include "game_xonotic.h" /* must be after game_quake3.h as they share defines! */
,
#include "game_tenebrae.h"
,
,
#include "game_qfusion.h" /* qfusion game */
,
- #include "game_reaction.h" /* must be after game_quake3.h */
+ #include "game_warsow.h" /* must be after game_qfusion.h as they share defines! */
+ ,
+ #include "game_warfork.h" /* must be after game_qfusion.h as they share defines! */
,
- #include "game_darkplaces.h" /* vortex: darkplaces q1 engine */
+ #include "game_darkplaces.h" /* darkplaces q1 engine */
,
- #include "game_dq.h" /* vortex: deluxe quake game ( darkplaces q1 engine) */
+ #include "game_dq.h" /* deluxe quake game ( darkplaces q1 engine) */
,
#include "game_prophecy.h" /* vortex: prophecy game ( darkplaces q1 engine) */
,
/*can't code*/
Q_EXTERN qboolean doingBSP Q_ASSIGN( qfalse );
-
+ Q_EXTERN qboolean doingModelClip Q_ASSIGN( qfalse );
+ Q_EXTERN qboolean snapModelClip Q_ASSIGN( qfalse );
/* commandline arguments */
Q_EXTERN qboolean nocmdline Q_ASSIGN( qfalse );
-Q_EXTERN qboolean verbose;
Q_EXTERN qboolean verboseEntities Q_ASSIGN( qfalse );
Q_EXTERN qboolean force Q_ASSIGN( qfalse );
Q_EXTERN qboolean infoMode Q_ASSIGN( qfalse );
Q_EXTERN qboolean noHint Q_ASSIGN( qfalse ); /* ydnar */
Q_EXTERN qboolean renameModelShaders Q_ASSIGN( qfalse ); /* ydnar */
Q_EXTERN qboolean skyFixHack Q_ASSIGN( qfalse ); /* ydnar */
-Q_EXTERN qboolean bspAlternateSplitWeights Q_ASSIGN( qfalse ); /* 27 */
-Q_EXTERN qboolean deepBSP Q_ASSIGN( qfalse ); /* div0 */
+Q_EXTERN qboolean bspAlternateSplitWeights Q_ASSIGN( qfalse ); /* 27 */
+Q_EXTERN qboolean deepBSP Q_ASSIGN( qfalse ); /* div0 */
Q_EXTERN qboolean maxAreaFaceSurface Q_ASSIGN( qfalse ); /* divVerent */
Q_EXTERN int patchSubdivisions Q_ASSIGN( 8 ); /* ydnar: -patchmeta subdivisions */
Q_EXTERN qboolean debugSurfaces Q_ASSIGN( qfalse );
Q_EXTERN qboolean debugInset Q_ASSIGN( qfalse );
Q_EXTERN qboolean debugPortals Q_ASSIGN( qfalse );
+ Q_EXTERN qboolean debugClip Q_ASSIGN( qfalse ); /* debug model autoclipping */
Q_EXTERN qboolean lightmapTriangleCheck Q_ASSIGN( qfalse );
Q_EXTERN qboolean lightmapExtraVisClusterNudge Q_ASSIGN( qfalse );
Q_EXTERN qboolean lightmapFill Q_ASSIGN( qfalse );
Q_EXTERN float areaScale Q_ASSIGN( 0.25f );
Q_EXTERN float skyScale Q_ASSIGN( 1.0f );
Q_EXTERN float bounceScale Q_ASSIGN( 0.25f );
+ Q_EXTERN float bounceColorRatio Q_ASSIGN( 1.0f );
Q_EXTERN float vertexglobalscale Q_ASSIGN( 1.0f );
/* jal: alternative angle attenuation curve */
Q_EXTERN bspBrushSide_t* bspBrushSides Q_ASSIGN( NULL );
Q_EXTERN int numBSPLightBytes Q_ASSIGN( 0 );
-Q_EXTERN byte *bspLightBytes Q_ASSIGN( NULL );
+Q_EXTERN byte *bspLightBytes Q_ASSIGN( NULL );
//% Q_EXTERN int numBSPGridPoints Q_ASSIGN( 0 );
//% Q_EXTERN byte *bspGridPoints Q_ASSIGN( NULL );
Q_EXTERN byte bspVisBytes[ MAX_MAP_VISIBILITY ];
Q_EXTERN int numBSPDrawVerts Q_ASSIGN( 0 );
-Q_EXTERN bspDrawVert_t *bspDrawVerts Q_ASSIGN( NULL );
+Q_EXTERN bspDrawVert_t *bspDrawVerts Q_ASSIGN( NULL );
Q_EXTERN int numBSPDrawIndexes Q_ASSIGN( 0 );
Q_EXTERN int allocatedBSPDrawIndexes Q_ASSIGN( 0 );
-Q_EXTERN int *bspDrawIndexes Q_ASSIGN( NULL );
+Q_EXTERN int *bspDrawIndexes Q_ASSIGN( NULL );
Q_EXTERN int numBSPDrawSurfaces Q_ASSIGN( 0 );
Q_EXTERN bspDrawSurface_t *bspDrawSurfaces Q_ASSIGN( NULL );
Q_EXTERN int numBSPAds Q_ASSIGN( 0 );
Q_EXTERN bspAdvertisement_t bspAds[ MAX_MAP_ADVERTISEMENTS ];
-#define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) \
+// Used for tex file support, Smokin'Guns globals
+Q_EXTERN qboolean compile_map;
+
+#define _AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def, fillWithZeros ) \
do \
{ \
+ int prevAllocated = allocated; \
if ( reqitem >= allocated ) \
{ \
if ( allocated == 0 ) { \
- allocated = def; } \
+ allocated = def; \
+ } \
while ( reqitem >= allocated && allocated ) \
+ { \
allocated *= 2; \
+ } \
if ( !allocated || allocated > 2147483647 / (int)sizeof( *ptr ) ) \
{ \
- Error( # ptr " over 2 GB" ); \
+ Error( #ptr " over 2 GB" ); \
} \
ptr = realloc( ptr, sizeof( *ptr ) * allocated ); \
if ( !ptr ) { \
- Error( # ptr " out of memory" ); } \
+ Error( #ptr " out of memory" ); \
+ } \
+ if ( fillWithZeros ) \
+ { \
+ memset( ptr + ( sizeof( *ptr ) * prevAllocated ), 0 , sizeof( *ptr ) * ( allocated - prevAllocated ) ); \
+ } \
} \
} \
while ( 0 )
-#define AUTOEXPAND_BY_REALLOC_BSP( suffix, def ) AUTOEXPAND_BY_REALLOC( bsp ## suffix, numBSP ## suffix, allocatedBSP ## suffix, def )
+#define AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def ) _AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def, qfalse )
+
+#define AUTOEXPAND_BY_REALLOC0( ptr, reqitem, allocated, def ) _AUTOEXPAND_BY_REALLOC( ptr, reqitem, allocated, def, qtrue )
+
+#define AUTOEXPAND_BY_REALLOC_BSP( suffix, def ) AUTOEXPAND_BY_REALLOC( bsp##suffix, numBSP##suffix, allocatedBSP##suffix, def )
+
+#define AUTOEXPAND_BY_REALLOC0_BSP( suffix, def ) AUTOEXPAND_BY_REALLOC0( bsp##suffix, numBSP##suffix, allocatedBSP##suffix, def )
#define Image_LinearFloatFromsRGBFloat( c ) ( ( ( c ) <= 0.04045f ) ? ( c ) * ( 1.0f / 12.92f ) : (float)pow( ( ( c ) + 0.055f ) * ( 1.0f / 1.055f ), 2.4f ) )
#define Image_sRGBFloatFromLinearFloat( c ) ( ( ( c ) < 0.0031308f ) ? ( c ) * 12.92f : 1.055f * (float)pow( ( c ), 1.0f / 2.4f ) - 0.055f )