From 428a588b4c93c25465374cdd7b8a6ef689aad049 Mon Sep 17 00:00:00 2001 From: lordhavoc Date: Fri, 25 Jul 2008 07:31:37 +0000 Subject: [PATCH] ported over the 1.5 branch version of q3map2 which is newer made Visual Studio files work in VS2005 Express fixed a ton of warnings in VS2005 Express fixed some compile problems on OpenSUSE 11.0 git-svn-id: https://zerowing.idsoftware.com/svn/radiant/GtkRadiant/trunk@302 8a3a26a2-13c4-0310-b231-cf6edde360e5 --- SConscript.q3map2 | 2 +- contrib/bkgrnd2d/dialog.cpp | 2 +- contrib/camera/camera.vcproj | 337 +- contrib/camera/dialogs.cpp | 3 + contrib/camera/dialogs_common.cpp | 2 +- contrib/camera/funchandlers.cpp | 4 +- contrib/gtkgensurf/gendlgs.cpp | 2 +- contrib/gtkgensurf/gensurf.cpp | 4 +- include/qerplugin.h | 2 +- libs/ddslib/ddslib.c | 6 +- libs/picomodel/lwo/lwob.c | 2 +- libs/picomodel/lwo/pntspols.c | 4 +- plugins/entity/light.cpp | 2 +- plugins/surface/surfacedialog.cpp | 2 +- radiant/bp_dlg.cpp | 2 +- radiant/brush.cpp | 4 +- radiant/gtkdlgs.cpp | 2 +- radiant/gtkmisc.cpp | 4 +- radiant/gtkmisc.h | 2 +- radiant/missing.cpp | 4 +- radiant/radiant.rc | 3 +- radiant/radiant.vcproj | 4920 ++++++++--------- radiant/selectedface.cpp | 4 +- radiant/winding.cpp | 2 +- tools/quake2/common/cmdlib.c | 14 +- tools/quake2/common/cmdlib.h | 4 +- tools/quake2/common/inout.c | 4 +- tools/quake2/common/path_init.c | 6 +- tools/quake2/common/qfiles.h | 2 +- tools/quake2/common/threads.c | 2 +- tools/quake2/q2map/q2map.h | 2 +- tools/quake2/q2map/qbsp.h | 2 +- tools/quake2/q2map/qrad.h | 4 +- tools/quake2/q2map/qvis.h | 2 +- tools/quake2/q2map/writebsp.c | 28 +- tools/quake2/qdata/images.c | 21 + tools/quake2/qdata/models.c | 20 + tools/quake2/qdata/qdata.c | 27 + tools/quake2/qdata/qdata.h | 22 +- tools/quake2/qdata/sprites.c | 20 + tools/quake2/qdata/tables.c | 21 + tools/quake2/qdata/video.c | 21 + tools/quake2/qdata_heretic2/anorms.h | 3 +- tools/quake2/qdata_heretic2/common/cmdlib.c | 8 +- tools/quake2/qdata_heretic2/common/inout.c | 4 +- tools/quake2/qdata_heretic2/common/md4.c | 298 + .../quake2/qdata_heretic2/common/path_init.c | 3 +- tools/quake2/qdata_heretic2/common/threads.c | 2 +- tools/quake2/qdata_heretic2/qdata.c | 6 + tools/quake3/common/cmdlib.c | 6 +- tools/quake3/common/imagelib.c | 402 +- tools/quake3/common/imagelib.h | 9 +- tools/quake3/common/inout.c | 14 +- tools/quake3/common/inout.h | 1 + tools/quake3/common/mutex.c | 2 +- tools/quake3/common/polylib.c | 9 +- tools/quake3/common/surfaceflags.h | 2 + tools/quake3/common/threads.c | 3 +- tools/quake3/common/vfs.c | 2 +- tools/quake3/q3data/3dslib.c | 21 + tools/quake3/q3data/3dslib.h | 21 + tools/quake3/q3data/compress.c | 21 + tools/quake3/q3data/images.c | 21 + tools/quake3/q3data/md3lib.c | 23 +- tools/quake3/q3data/md3lib.h | 21 + tools/quake3/q3data/models.c | 21 + tools/quake3/q3data/oldstuff.c | 21 + tools/quake3/q3data/p3dlib.c | 23 +- tools/quake3/q3data/p3dlib.h | 21 + tools/quake3/q3data/polyset.c | 21 + tools/quake3/q3data/q3data.c | 25 +- tools/quake3/q3data/q3data.h | 21 + tools/quake3/q3data/stripper.c | 21 + tools/quake3/q3data/video.c | 21 + tools/quake3/q3map2/brush.c | 38 +- tools/quake3/q3map2/brush_primit.c | 3 +- tools/quake3/q3map2/bsp.c | 17 +- tools/quake3/q3map2/bspfile_abstract.c | 5 +- tools/quake3/q3map2/bspfile_ibsp.c | 3 +- tools/quake3/q3map2/bspfile_rbsp.c | 3 +- tools/quake3/q3map2/changelog.q3map1 | 742 +-- tools/quake3/q3map2/changelog.q3map2.txt | 102 + tools/quake3/q3map2/convert_ase.c | 3 +- tools/quake3/q3map2/convert_map.c | 3 +- tools/quake3/q3map2/decals.c | 9 +- tools/quake3/q3map2/facebsp.c | 5 +- tools/quake3/q3map2/fog.c | 5 +- tools/quake3/q3map2/game_ef.h | 12 +- tools/quake3/q3map2/game_etut.h | 264 + tools/quake3/q3map2/game_ja.h | 12 +- tools/quake3/q3map2/game_jk2.h | 12 +- tools/quake3/q3map2/game_qfusion.h | 195 + tools/quake3/q3map2/game_quake3.h | 12 +- tools/quake3/q3map2/game_sof2.h | 12 +- tools/quake3/q3map2/game_tenebrae.h | 12 +- tools/quake3/q3map2/game_tremulous.h | 160 + tools/quake3/q3map2/game_wolf.h | 12 +- tools/quake3/q3map2/game_wolfet.h | 12 +- tools/quake3/q3map2/image.c | 5 +- tools/quake3/q3map2/leakfile.c | 3 +- tools/quake3/q3map2/light.c | 299 +- tools/quake3/q3map2/light_bounce.c | 20 +- tools/quake3/q3map2/light_trace.c | 50 +- tools/quake3/q3map2/light_ydnar.c | 536 +- tools/quake3/q3map2/lightmaps_ydnar.c | 251 +- tools/quake3/q3map2/main.c | 297 +- tools/quake3/q3map2/map.c | 37 +- tools/quake3/q3map2/mesh.c | 17 +- tools/quake3/q3map2/model.c | 12 +- tools/quake3/q3map2/patch.c | 3 +- tools/quake3/q3map2/path_init.c | 24 +- tools/quake3/q3map2/portals.c | 3 +- tools/quake3/q3map2/prtfile.c | 3 +- tools/quake3/q3map2/q3map2.h | 225 +- tools/quake3/q3map2/q3map2.vcproj | 12 +- tools/quake3/q3map2/shaders.c | 305 +- tools/quake3/q3map2/surface.c | 129 +- tools/quake3/q3map2/surface_extra.c | 3 +- tools/quake3/q3map2/surface_foliage.c | 3 +- tools/quake3/q3map2/surface_fur.c | 3 +- tools/quake3/q3map2/surface_meta.c | 98 +- tools/quake3/q3map2/tjunction.c | 3 +- tools/quake3/q3map2/tree.c | 3 +- tools/quake3/q3map2/vis.c | 14 +- tools/quake3/q3map2/visflow.c | 5 +- tools/quake3/q3map2/writebsp.c | 12 +- 126 files changed, 6892 insertions(+), 3776 deletions(-) create mode 100644 tools/quake3/q3map2/game_etut.h create mode 100644 tools/quake3/q3map2/game_qfusion.h create mode 100644 tools/quake3/q3map2/game_tremulous.h diff --git a/SConscript.q3map2 b/SConscript.q3map2 index 30ba5cbe..963f51af 100644 --- a/SConscript.q3map2 +++ b/SConscript.q3map2 @@ -10,7 +10,7 @@ Import( [ 'utils', 'config', 'settings', 'lib_objects' ] ) env = Environment() settings.SetupEnvironment( env, config['name'] ) env.Prepend( CPPPATH = [ '#tools/quake3/common' ] ) -env.Append( LIBS = [ 'pthread', 'png', 'jpeg' ] ) +env.Append( LIBS = [ 'pthread', 'png', 'jpeg', 'mhash' ] ) proj = utils.vcproj( os.path.join( GetLaunchDir(), 'tools/quake3/q3map2/q3map2.vcproj' ) ) objects = lib_objects objects += [ os.path.join( 'tools/quake3/q3map2', i ) for i in proj.getSourceFiles() ] diff --git a/contrib/bkgrnd2d/dialog.cpp b/contrib/bkgrnd2d/dialog.cpp index 3e7c862a..2529bab6 100644 --- a/contrib/bkgrnd2d/dialog.cpp +++ b/contrib/bkgrnd2d/dialog.cpp @@ -147,7 +147,7 @@ void CBackgroundDialogPage::Browse() //TODO bug/patch for comments //TODO patern gets fucked up sometimes if empty newfile = g_FuncTable.m_pfnFileDialog(pDialogWnd,TRUE, - _("Load Background Image"),browsedir,FILETYPE_KEY); + _("Load Background Image"),browsedir,FILETYPE_KEY, NULL); if(!newfile) { Syn_Printf(MSG_PREFIX "newfile = NULL\n"); return; diff --git a/contrib/camera/camera.vcproj b/contrib/camera/camera.vcproj index a63cbb7b..b32d3384 100644 --- a/contrib/camera/camera.vcproj +++ b/contrib/camera/camera.vcproj @@ -1,89 +1,248 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/contrib/camera/dialogs.cpp b/contrib/camera/dialogs.cpp index 146fd7ca..40985b38 100644 --- a/contrib/camera/dialogs.cpp +++ b/contrib/camera/dialogs.cpp @@ -26,6 +26,9 @@ Copyright (C) 2002 Splash Damage Ltd. #include "camera.h" +#include +#include + static GSList *g_pEditTypeRadio = NULL; static GtkWidget *g_pEditModeEditRadioButton = NULL; GtkWidget *g_pEditModeAddRadioButton = NULL; diff --git a/contrib/camera/dialogs_common.cpp b/contrib/camera/dialogs_common.cpp index ed21f5b4..d55e5f0a 100644 --- a/contrib/camera/dialogs_common.cpp +++ b/contrib/camera/dialogs_common.cpp @@ -36,7 +36,7 @@ void dialog_button_callback (GtkWidget *widget, gpointer data) ret = (int*)g_object_get_data (G_OBJECT (parent), "ret"); *loop = 0; - *ret = (int)data; + *ret = GPOINTER_TO_INT (data); } gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data) diff --git a/contrib/camera/funchandlers.cpp b/contrib/camera/funchandlers.cpp index fafae2a6..6423d399 100644 --- a/contrib/camera/funchandlers.cpp +++ b/contrib/camera/funchandlers.cpp @@ -106,7 +106,7 @@ void DoLoadCamera() else strcpy( basepath, g_FuncTable.m_pfnGetGamePath() ); - const gchar *filename = g_FuncTable.m_pfnFileDialog( (GtkWidget *)g_pRadiantWnd, TRUE, "Open Camera File", basepath, "camera"); + const gchar *filename = g_FuncTable.m_pfnFileDialog( (GtkWidget *)g_pRadiantWnd, TRUE, "Open Camera File", basepath, "camera", NULL); if( filename ) { @@ -161,7 +161,7 @@ void DoSaveCamera() { else strcpy( basepath, g_FuncTable.m_pfnGetGamePath() ); - const gchar *filename = g_FuncTable.m_pfnFileDialog( (void *)g_pRadiantWnd, FALSE, "Save Camera File", basepath, "camera"); + const gchar *filename = g_FuncTable.m_pfnFileDialog( (void *)g_pRadiantWnd, FALSE, "Save Camera File", basepath, "camera", NULL); if( filename ) { char fullpathtofile[PATH_MAX + 8]; diff --git a/contrib/gtkgensurf/gendlgs.cpp b/contrib/gtkgensurf/gendlgs.cpp index 372b833f..207f6b07 100644 --- a/contrib/gtkgensurf/gendlgs.cpp +++ b/contrib/gtkgensurf/gendlgs.cpp @@ -912,7 +912,7 @@ static void bitmap_browse (GtkWidget *widget, gpointer data) const char *filename; char *ptr; - filename = g_FuncTable.m_pfnFileDialog (g_pWnd, TRUE, "Bitmap File", gbmp.defpath, "gtkgensurf"); + filename = g_FuncTable.m_pfnFileDialog (g_pWnd, TRUE, "Bitmap File", gbmp.defpath, "gtkgensurf", NULL); if (filename != NULL) { diff --git a/contrib/gtkgensurf/gensurf.cpp b/contrib/gtkgensurf/gensurf.cpp index df40e911..65f90088 100644 --- a/contrib/gtkgensurf/gensurf.cpp +++ b/contrib/gtkgensurf/gensurf.cpp @@ -397,7 +397,7 @@ void UpdatePreview (bool DataChange) void SaveSetup (GtkWidget *parent) { const char *name = g_FuncTable.m_pfnFileDialog (parent, false, "Save GenSurf Settings", - g_FuncTable.m_pfnProfileGetDirectory (), "gtkgensurf"); + g_FuncTable.m_pfnProfileGetDirectory (), "gtkgensurf", NULL); if (name != NULL) { @@ -436,7 +436,7 @@ void OpenSetup (GtkWidget *parent, int UseDefaults) name = g_strdup ("plugins/defaults.srf"); // dummy string else name = g_FuncTable.m_pfnFileDialog (parent, true, "Open GenSurf Settings", - g_FuncTable.m_pfnProfileGetDirectory (), "gtkgensurf"); + g_FuncTable.m_pfnProfileGetDirectory (), "gtkgensurf", NULL); if(name != NULL) { diff --git a/include/qerplugin.h b/include/qerplugin.h index 71cddb23..a4389408 100644 --- a/include/qerplugin.h +++ b/include/qerplugin.h @@ -230,7 +230,7 @@ typedef gint (WINAPI* PFN_QERAPP_MESSAGEBOX) (void *parent, const char* text, // - 'pattern': the first pattern is for the win32 mode, then comes the Gtk pattern list, see Radiant source for samples // TTimo 04/01/2001 toolkit-independant, cast parent to a GtkWidget* typedef const gchar* (* PFN_QERAPP_FILEDIALOG) (void *parent, gboolean open, const char* title, - const char* path, const char* pattern); + const char* path, const char* pattern, const char *baseSubDir); typedef gchar* (WINAPI* PFN_QERAPP_DIRDIALOG) (void *parent, const char* title, const char* path); diff --git a/libs/ddslib/ddslib.c b/libs/ddslib/ddslib.c index bf1a9f15..bea6fb36 100644 --- a/libs/ddslib/ddslib.c +++ b/libs/ddslib/ddslib.c @@ -523,7 +523,7 @@ static int DDSDecompressDXT1( ddsBuffer_t *dds, int width, int height, unsigned for( y = 0; y < yBlocks; y++ ) { /* 8 bytes per block */ - block = (ddsColorBlock_t*) ((unsigned int) dds->data + y * xBlocks * 8); + block = (ddsColorBlock_t*) ((size_t) dds->data + y * xBlocks * 8); /* walk x */ for( x = 0; x < xBlocks; x++, block++ ) @@ -569,7 +569,7 @@ static int DDSDecompressDXT3( ddsBuffer_t *dds, int width, int height, unsigned for( y = 0; y < yBlocks; y++ ) { /* 8 bytes per block, 1 block for alpha, 1 block for color */ - block = (ddsColorBlock_t*) ((unsigned int) dds->data + y * xBlocks * 16); + block = (ddsColorBlock_t*) ((size_t) dds->data + y * xBlocks * 16); /* walk x */ for( x = 0; x < xBlocks; x++, block++ ) @@ -625,7 +625,7 @@ static int DDSDecompressDXT5( ddsBuffer_t *dds, int width, int height, unsigned for( y = 0; y < yBlocks; y++ ) { /* 8 bytes per block, 1 block for alpha, 1 block for color */ - block = (ddsColorBlock_t*) ((unsigned int) dds->data + y * xBlocks * 16); + block = (ddsColorBlock_t*) ((size_t) dds->data + y * xBlocks * 16); /* walk x */ for( x = 0; x < xBlocks; x++, block++ ) diff --git a/libs/picomodel/lwo/lwob.c b/libs/picomodel/lwo/lwob.c index 2d381c59..ba34c085 100644 --- a/libs/picomodel/lwo/lwob.c +++ b/libs/picomodel/lwo/lwob.c @@ -546,7 +546,7 @@ int lwGetPolygons5( picoMemStream_t *fp, int cksize, lwPolygonList *plist, int p bp += 2; } j -= 1; - pp->surf = ( lwSurface * ) j; + pp->surf = ( lwSurface * ) ((size_t)j); pp++; pv += nv; diff --git a/libs/picomodel/lwo/pntspols.c b/libs/picomodel/lwo/pntspols.c index 5cef01e6..141975e5 100644 --- a/libs/picomodel/lwo/pntspols.c +++ b/libs/picomodel/lwo/pntspols.c @@ -353,7 +353,7 @@ int lwResolvePolySurfaces( lwPolygonList *polygon, lwTagList *tlist, } for ( i = 0; i < polygon->count; i++ ) { - index = ( int ) polygon->pol[ i ].surf; + index = ( int ) ((size_t)polygon->pol[ i ].surf); if ( index < 0 || index > tlist->count ) return 0; if ( !s[ index ] ) { s[ index ] = lwDefaultSurface(); @@ -527,7 +527,7 @@ int lwGetPolygonTags( picoMemStream_t *fp, int cksize, lwTagList *tlist, if ( rlen < 0 || rlen > cksize ) return 0; switch ( type ) { - case ID_SURF: plist->pol[ i ].surf = ( lwSurface * ) j; break; + case ID_SURF: plist->pol[ i ].surf = ( lwSurface * ) ((size_t)j); break; case ID_PART: plist->pol[ i ].part = j; break; case ID_SMGP: plist->pol[ i ].smoothgrp = j; break; } diff --git a/plugins/entity/light.cpp b/plugins/entity/light.cpp index 9e08c181..d1a30e14 100644 --- a/plugins/entity/light.cpp +++ b/plugins/entity/light.cpp @@ -182,7 +182,7 @@ float CalculateLightRadius(entity_t * e, bool outer) if (!outer) { if (iSpawnFlags & 2) - fIntensity *= .9; + fIntensity *= .9f; else fIntensity *= .25f; } diff --git a/plugins/surface/surfacedialog.cpp b/plugins/surface/surfacedialog.cpp index 59311bed..57b48b92 100644 --- a/plugins/surface/surfacedialog.cpp +++ b/plugins/surface/surfacedialog.cpp @@ -1610,7 +1610,7 @@ static void on_lock_valuechange_togglebutton_toggled (GtkToggleButton *togglebut { bool is_Locked; - is_Locked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lock_valuechange_togglebutton)); + is_Locked = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lock_valuechange_togglebutton)) != false; gtk_widget_set_sensitive( GTK_WIDGET( hscale_value_spinbutton ), is_Locked ); gtk_widget_set_sensitive( GTK_WIDGET( vscale_value_spinbutton ), is_Locked ); diff --git a/radiant/bp_dlg.cpp b/radiant/bp_dlg.cpp index 3a5328e2..d43e5916 100644 --- a/radiant/bp_dlg.cpp +++ b/radiant/bp_dlg.cpp @@ -38,7 +38,7 @@ void BP_dialog_button_callback (GtkWidget *widget, gpointer data) ret = (int*)g_object_get_data (G_OBJECT (parent), "ret"); *loop = 0; - *ret = (int)data; + *ret = GPOINTER_TO_INT (data); } gint BP_dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data) diff --git a/radiant/brush.cpp b/radiant/brush.cpp index 25a7917a..59daecb6 100644 --- a/radiant/brush.cpp +++ b/radiant/brush.cpp @@ -3141,10 +3141,10 @@ void Brush_Draw(brush_t *b) if (!bTrans) { if (face->texdef.flags & Q2_SURF_TRANS33) { bTrans = true; - transVal = 0.33; + transVal = 0.33f; } else if (face->texdef.flags & Q2_SURF_TRANS66) { bTrans = true; - transVal = 0.66; + transVal = 0.66f; } } diff --git a/radiant/gtkdlgs.cpp b/radiant/gtkdlgs.cpp index ff1a8e8a..da91fc25 100644 --- a/radiant/gtkdlgs.cpp +++ b/radiant/gtkdlgs.cpp @@ -3158,7 +3158,7 @@ int DoCapDlg (int *type, bool *b_GroupResult) *type = IENDCAP; // *type = CapDialog::IENDCAP; // Gef: Added toggle for optional cap func_grouping - *b_GroupResult = (bool *)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(group_toggle)); + *b_GroupResult = (bool)gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(group_toggle)); } gtk_grab_remove (dlg); diff --git a/radiant/gtkmisc.cpp b/radiant/gtkmisc.cpp index 63d5bf75..fe97ef96 100644 --- a/radiant/gtkmisc.cpp +++ b/radiant/gtkmisc.cpp @@ -859,7 +859,7 @@ void dialog_button_callback( GtkWidget *widget, gpointer data ) { ret = (int*)g_object_get_data( G_OBJECT( parent ), "ret" ); *loop = 0; - *ret = (int)data; + *ret = GPOINTER_TO_INT (data); } gint dialog_delete_callback (GtkWidget *widget, GdkEvent* event, gpointer data) @@ -1037,7 +1037,7 @@ static void file_sel_callback (GtkWidget *widget, gpointer data) loop = (int*)g_object_get_data (G_OBJECT (parent), "loop"); success = (bool*)g_object_get_data (G_OBJECT (parent), "success"); - if ((int)data == IDOK) + if (GPOINTER_TO_INT (data) == IDOK) *success = true; #ifdef FILEDLG_DBG diff --git a/radiant/gtkmisc.h b/radiant/gtkmisc.h index 2ff2a960..52cec01c 100644 --- a/radiant/gtkmisc.h +++ b/radiant/gtkmisc.h @@ -81,7 +81,7 @@ URL adds an optional 'go to URL' button int WINAPI gtk_MessageBox (void *parent, const char* lpText, const char* lpCaption = "Radiant", guint32 uType = MB_OK, const char* URL = NULL); // NOTE: the returned filename is allocated with g_malloc and MUST be freed with g_free (both for win32 and Gtk dialogs) // GtkWidget *parent -const char* file_dialog (void *parent, gboolean open, const char* title, const char* path = (char*)NULL, const char* pattern = NULL, const char *baseSubDir = NULL); +const gchar* file_dialog (void *parent, gboolean open, const char* title, const char* path = (char*)NULL, const char* pattern = NULL, const char *baseSubDir = NULL); /*! \fn dir_dialog, prompts for a directory diff --git a/radiant/missing.cpp b/radiant/missing.cpp index f83bed3c..deafb638 100644 --- a/radiant/missing.cpp +++ b/radiant/missing.cpp @@ -208,11 +208,11 @@ EPathCheck CheckFile( const char *path ) { } bool radCreateDirectory( const char *directory ) { - return CreateDirectory( directory, NULL ); + return CreateDirectory( directory, NULL ) != false; } bool radCopyFile( const char *lpExistingFileName, const char *lpNewFileName ) { - return CopyFile( lpExistingFileName, lpNewFileName, FALSE ); + return CopyFile( lpExistingFileName, lpNewFileName, FALSE ) != false; } #endif diff --git a/radiant/radiant.rc b/radiant/radiant.rc index b38337f7..e678e451 100644 --- a/radiant/radiant.rc +++ b/radiant/radiant.rc @@ -7,7 +7,8 @@ // // Generated from the TEXTINCLUDE 2 resource. // -#include "afxres.h" +//#include "afxres.h" +#include "windows.h" ///////////////////////////////////////////////////////////////////////////// #undef APSTUDIO_READONLY_SYMBOLS diff --git a/radiant/radiant.vcproj b/radiant/radiant.vcproj index 2dbf2999..298f8740 100644 --- a/radiant/radiant.vcproj +++ b/radiant/radiant.vcproj @@ -1,2460 +1,2460 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/radiant/selectedface.cpp b/radiant/selectedface.cpp index b325df59..69025b5d 100644 --- a/radiant/selectedface.cpp +++ b/radiant/selectedface.cpp @@ -55,7 +55,7 @@ brush_t* WINAPI QERApp_GetSelectedFaceBrush(int iface) // NOTE: we expect pWinding to have MAX_POINTS_ON_WINDING points ready for writing int WINAPI QERApp_GetFaceInfo(int iface, _QERFaceData *pFaceData, winding_t *pWinding) { - int size; + size_t size; if (iface>=g_ptrSelectedFaces.GetSize()) { @@ -74,7 +74,7 @@ int WINAPI QERApp_GetFaceInfo(int iface, _QERFaceData *pFaceData, winding_t *pWi VectorCopy( selFace->planepts[2], pFaceData->m_v3 ); pFaceData->m_bBPrimit = true; memcpy( &pFaceData->brushprimit_texdef, &selFace->brushprimit_texdef, sizeof(brushprimit_texdef_t) ); - size = (int)((winding_t *)0)->points[selFace->face_winding->numpoints]; + size = (size_t)((winding_t *)0)->points[selFace->face_winding->numpoints]; memcpy( pWinding, selFace->face_winding, size ); return 1; } diff --git a/radiant/winding.cpp b/radiant/winding.cpp index 6fc608ca..88e02c34 100644 --- a/radiant/winding.cpp +++ b/radiant/winding.cpp @@ -250,7 +250,7 @@ void Winding_RemovePoint(winding_t *w, int point) if (point < w->numpoints-1) { - memmove(&w->points[point], &w->points[point+1], (int)((winding_t *)0)->points[w->numpoints - point - 1]); + memmove(&w->points[point], &w->points[point+1], (size_t)((winding_t *)0)->points[w->numpoints - point - 1]); } w->numpoints--; } diff --git a/tools/quake2/common/cmdlib.c b/tools/quake2/common/cmdlib.c index 68a16d82..f1ade4aa 100644 --- a/tools/quake2/common/cmdlib.c +++ b/tools/quake2/common/cmdlib.c @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#ifdef _WIN32 +#ifdef WIN32 #include #include #endif @@ -93,7 +93,7 @@ Mimic unix command line expansion #define MAX_EX_ARGC 1024 int ex_argc; char *ex_argv[MAX_EX_ARGC]; -#ifdef _WIN32 +#ifdef WIN32 #include "io.h" void ExpandWildcards( int *argc, char ***argv ) { @@ -337,7 +337,7 @@ void Q_getwd (char *out) { int i = 0; -#ifdef _WIN32 +#ifdef WIN32 _getcwd (out, 256); strcat (out, "\\"); #else @@ -356,7 +356,7 @@ void Q_getwd (char *out) void Q_mkdir (const char *path) { -#ifdef _WIN32 +#ifdef WIN32 if (_mkdir (path) != -1) return; #else @@ -1159,7 +1159,7 @@ void CreatePath (const char *path) char c; char dir[1024]; -#ifdef _WIN32 +#ifdef WIN32 int olddrive = -1; if ( path[1] == ':' ) @@ -1183,7 +1183,7 @@ void CreatePath (const char *path) } } -#ifdef _WIN32 +#ifdef WIN32 if ( olddrive != -1 ) { _chdrive( olddrive ); @@ -1212,7 +1212,7 @@ void QCopyFile (const char *from, const char *to) void Sys_Sleep(int n) { -#ifdef _WIN32 +#ifdef WIN32 Sleep (n); #endif #if defined (__linux__) || defined (__APPLE__) diff --git a/tools/quake2/common/cmdlib.h b/tools/quake2/common/cmdlib.h index 02ced5be..8dbf9e61 100644 --- a/tools/quake2/common/cmdlib.h +++ b/tools/quake2/common/cmdlib.h @@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#ifdef _WIN32 +#ifdef WIN32 #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float @@ -40,7 +40,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #endif #endif -#ifdef _WIN32 +#ifdef WIN32 #pragma intrinsic( memset, memcpy ) #endif diff --git a/tools/quake2/common/inout.c b/tools/quake2/common/inout.c index 33eac651..9153077c 100644 --- a/tools/quake2/common/inout.c +++ b/tools/quake2/common/inout.c @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#ifdef _WIN32 +#ifdef WIN32 #include #include #endif @@ -42,7 +42,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_net/l_net.h" #include "libxml/tree.h" -#ifdef _WIN32 +#ifdef WIN32 HWND hwndOut = NULL; qboolean lookedForServer = false; UINT wm_BroadcastCommand = -1; diff --git a/tools/quake2/common/path_init.c b/tools/quake2/common/path_init.c index bf731c99..9a6596fa 100644 --- a/tools/quake2/common/path_init.c +++ b/tools/quake2/common/path_init.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -17,6 +18,9 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GtkRadiant; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Nurail: Swiped from Q3Map2 + */ diff --git a/tools/quake2/common/qfiles.h b/tools/quake2/common/qfiles.h index 1dd9d0ae..13542402 100644 --- a/tools/quake2/common/qfiles.h +++ b/tools/quake2/common/qfiles.h @@ -32,7 +32,7 @@ The .pak files are just a linear collapse of a directory tree ======================================================================== */ -#ifdef _WIN32 +#ifdef WIN32 #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/common/threads.c b/tools/quake2/common/threads.c index a2e8a810..0f5d3668 100644 --- a/tools/quake2/common/threads.c +++ b/tools/quake2/common/threads.c @@ -110,7 +110,7 @@ WIN32 =================================================================== */ -#ifdef _WIN32 +#ifdef WIN32 #define USED diff --git a/tools/quake2/q2map/q2map.h b/tools/quake2/q2map/q2map.h index 7303263c..75938f60 100644 --- a/tools/quake2/q2map/q2map.h +++ b/tools/quake2/q2map/q2map.h @@ -31,7 +31,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #endif -#ifdef _WIN32 +#ifdef WIN32 #include #endif diff --git a/tools/quake2/q2map/qbsp.h b/tools/quake2/q2map/qbsp.h index 47d8d4b5..1ba1b75d 100644 --- a/tools/quake2/q2map/qbsp.h +++ b/tools/quake2/q2map/qbsp.h @@ -46,7 +46,7 @@ writebsp.c #include "bspfile.h" #include "inout.h" -#ifdef _WIN32 +#ifdef WIN32 #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/q2map/qrad.h b/tools/quake2/q2map/qrad.h index 2eef8bc4..62ee38c3 100644 --- a/tools/quake2/q2map/qrad.h +++ b/tools/quake2/q2map/qrad.h @@ -36,11 +36,11 @@ trace.c #include "lbmlib.h" #include "inout.h" -#ifdef _WIN32 +#ifdef WIN32 #include #endif -#ifdef _WIN32 +#ifdef WIN32 #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/q2map/qvis.h b/tools/quake2/q2map/qvis.h index 44c84516..b9517704 100644 --- a/tools/quake2/q2map/qvis.h +++ b/tools/quake2/q2map/qvis.h @@ -30,7 +30,7 @@ qvis3.c #include "bspfile.h" #include "inout.h" -#ifdef _WIN32 +#ifdef WIN32 #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/q2map/writebsp.c b/tools/quake2/q2map/writebsp.c index 7ab613fd..8c45d530 100644 --- a/tools/quake2/q2map/writebsp.c +++ b/tools/quake2/q2map/writebsp.c @@ -495,17 +495,31 @@ void BeginBSPFile (void) EndBSPFile ============ */ -void EndBSPFile( void ) { +void EndBSPFile (void) +{ char path[1024]; - EmitBrushes(); - EmitPlanes(); - UnparseEntities(); +#if 0 + int len; + byte *buf; +#endif + + EmitBrushes (); + EmitPlanes (); + UnparseEntities (); + + // load the pop +#if 0 + sprintf (path, "%s/pics/pop.lmp", gamedir); + len = LoadFile (path, &buf); + memcpy (dpop, buf, sizeof(dpop)); + free (buf); +#endif // write the map - sprintf( path, "%s.bsp", source ); - Sys_Printf( "Writing %s\n", path ); - WriteBSPFile( path ); + sprintf (path, "%s.bsp", source); + Sys_Printf ("Writing %s\n", path); + WriteBSPFile (path); } diff --git a/tools/quake2/qdata/images.c b/tools/quake2/qdata/images.c index 37a2fc19..2d18588b 100644 --- a/tools/quake2/qdata/images.c +++ b/tools/quake2/qdata/images.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "qdata.h" #include "inout.h" diff --git a/tools/quake2/qdata/models.c b/tools/quake2/qdata/models.c index 76713a5b..508d1378 100644 --- a/tools/quake2/qdata/models.c +++ b/tools/quake2/qdata/models.c @@ -1,3 +1,23 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include "qdata.h" #include "inout.h" diff --git a/tools/quake2/qdata/qdata.c b/tools/quake2/qdata/qdata.c index 0502ec89..6c001a75 100644 --- a/tools/quake2/qdata/qdata.c +++ b/tools/quake2/qdata/qdata.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "qdata.h" #include "inout.h" @@ -26,6 +47,8 @@ void InitPaths( int *argc, char **argv ); ======================================================= */ +unsigned Com_BlockChecksum (void *buffer, int length); + typedef struct { char name[56]; @@ -143,6 +166,7 @@ void FinishPak (void) int dirlen; int d; int i; + unsigned checksum; if (!g_pak) return; @@ -155,6 +179,8 @@ void FinishPak (void) pakheader.dirofs = LittleLong(ftell(pakfile)); pakheader.dirlen = LittleLong(dirlen); + checksum = Com_BlockChecksum ( (void *)pfiles, dirlen ); + SafeWrite (pakfile, pfiles, dirlen); i = ftell (pakfile); @@ -165,6 +191,7 @@ void FinishPak (void) d = pf - pfiles; printf ("%i files packed in %i bytes\n",d, i); + printf ("checksum: 0x%x\n", checksum); } diff --git a/tools/quake2/qdata/qdata.h b/tools/quake2/qdata/qdata.h index 2a1da9cb..81418175 100644 --- a/tools/quake2/qdata/qdata.h +++ b/tools/quake2/qdata/qdata.h @@ -1,5 +1,23 @@ -// qdata.h +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include #include @@ -16,7 +34,7 @@ #include "l3dslib.h" #include "bspfile.h" -#ifdef _WIN32 +#ifdef WIN32 #ifdef NDEBUG // Don't show in a Release build #pragma warning(disable : 4305) // truncate from double to float #pragma warning(disable : 4244) // conversion from double to float diff --git a/tools/quake2/qdata/sprites.c b/tools/quake2/qdata/sprites.c index db812751..dc85da43 100644 --- a/tools/quake2/qdata/sprites.c +++ b/tools/quake2/qdata/sprites.c @@ -1,3 +1,23 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ #include "qdata.h" #include "inout.h" diff --git a/tools/quake2/qdata/tables.c b/tools/quake2/qdata/tables.c index 6aee6126..837c7b42 100644 --- a/tools/quake2/qdata/tables.c +++ b/tools/quake2/qdata/tables.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "qdata.h" /* diff --git a/tools/quake2/qdata/video.c b/tools/quake2/qdata/video.c index 370f5e95..4ad90c9b 100644 --- a/tools/quake2/qdata/video.c +++ b/tools/quake2/qdata/video.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "qdata.h" #include "inout.h" diff --git a/tools/quake2/qdata_heretic2/anorms.h b/tools/quake2/qdata_heretic2/anorms.h index f240902b..82e4df36 100644 --- a/tools/quake2/qdata_heretic2/anorms.h +++ b/tools/quake2/qdata_heretic2/anorms.h @@ -180,4 +180,5 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA {-0.425325f, 0.688191f, -0.587785f}, {-0.425325f, -0.688191f, -0.587785f}, {-0.587785f, -0.425325f, -0.688191f}, - {-0.688191f, -0.587785f, -0.425325f}, \ No newline at end of file + {-0.688191f, -0.587785f, -0.425325f}, + diff --git a/tools/quake2/qdata_heretic2/common/cmdlib.c b/tools/quake2/qdata_heretic2/common/cmdlib.c index c5f5c3a6..104a61b8 100644 --- a/tools/quake2/qdata_heretic2/common/cmdlib.c +++ b/tools/quake2/qdata_heretic2/common/cmdlib.c @@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#ifdef _WIN32 +#ifdef WIN32 #include #include #endif @@ -356,7 +356,7 @@ void Q_getwd (char *out) { int i = 0; -#ifdef _WIN32 +#ifdef WIN32 _getcwd (out, 256); strcat (out, "\\"); #else @@ -375,7 +375,7 @@ void Q_getwd (char *out) void Q_mkdir (const char *path) { -#ifdef _WIN32 +#ifdef WIN32 if (_mkdir (path) != -1) return; #else @@ -1229,7 +1229,7 @@ void QCopyFile (const char *from, const char *to) void Sys_Sleep(int n) { -#ifdef _WIN32 +#ifdef WIN32 Sleep (n); #endif #if defined (__linux__) || defined (__APPLE__) diff --git a/tools/quake2/qdata_heretic2/common/inout.c b/tools/quake2/qdata_heretic2/common/inout.c index 33eac651..9153077c 100644 --- a/tools/quake2/qdata_heretic2/common/inout.c +++ b/tools/quake2/qdata_heretic2/common/inout.c @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#ifdef _WIN32 +#ifdef WIN32 #include #include #endif @@ -42,7 +42,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_net/l_net.h" #include "libxml/tree.h" -#ifdef _WIN32 +#ifdef WIN32 HWND hwndOut = NULL; qboolean lookedForServer = false; UINT wm_BroadcastCommand = -1; diff --git a/tools/quake2/qdata_heretic2/common/md4.c b/tools/quake2/qdata_heretic2/common/md4.c index e69de29b..7398d4e4 100644 --- a/tools/quake2/qdata_heretic2/common/md4.c +++ b/tools/quake2/qdata_heretic2/common/md4.c @@ -0,0 +1,298 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +/* GLOBAL.H - RSAREF types and constants */ + +#include + +/* POINTER defines a generic pointer type */ +typedef unsigned char *POINTER; + +/* UINT2 defines a two byte word */ +typedef unsigned short int UINT2; + +/* UINT4 defines a four byte word */ +typedef unsigned long int UINT4; + + +/* MD4.H - header file for MD4C.C */ + +/* Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. + +All rights reserved. + +License to copy and use this software is granted provided that it is identified as the “RSA Data Security, Inc. MD4 Message-Digest Algorithm” in all material mentioning or referencing this software or this function. +License is also granted to make and use derivative works provided that such works are identified as “derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm” in all material mentioning or referencing the derived work. +RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided “as is” without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this documentation and/or software. */ + +/* MD4 context. */ +typedef struct { + UINT4 state[4]; /* state (ABCD) */ + UINT4 count[2]; /* number of bits, modulo 2^64 (lsb first) */ + unsigned char buffer[64]; /* input buffer */ +} MD4_CTX; + +void MD4Init (MD4_CTX *); +void MD4Update (MD4_CTX *, unsigned char *, unsigned int); +void MD4Final (unsigned char [16], MD4_CTX *); + + + +/* MD4C.C - RSA Data Security, Inc., MD4 message-digest algorithm */ +/* Copyright (C) 1990-2, RSA Data Security, Inc. All rights reserved. + +License to copy and use this software is granted provided that it is identified as the +RSA Data Security, Inc. MD4 Message-Digest Algorithm + in all material mentioning or referencing this software or this function. +License is also granted to make and use derivative works provided that such works are identified as +derived from the RSA Data Security, Inc. MD4 Message-Digest Algorithm +in all material mentioning or referencing the derived work. +RSA Data Security, Inc. makes no representations concerning either the merchantability of this software or the suitability of this software for any particular purpose. It is provided +as is without express or implied warranty of any kind. + +These notices must be retained in any copies of any part of this documentation and/or software. */ + +/* Constants for MD4Transform routine. */ +#define S11 3 +#define S12 7 +#define S13 11 +#define S14 19 +#define S21 3 +#define S22 5 +#define S23 9 +#define S24 13 +#define S31 3 +#define S32 9 +#define S33 11 +#define S34 15 + +static void MD4Transform (UINT4 [4], unsigned char [64]); +static void Encode (unsigned char *, UINT4 *, unsigned int); +static void Decode (UINT4 *, unsigned char *, unsigned int); +static void MD4_memcpy (POINTER, POINTER, unsigned int); +static void MD4_memset (POINTER, int, unsigned int); + +static unsigned char PADDING[64] = { +0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 +}; + +/* F, G and H are basic MD4 functions. */ +#define F(x, y, z) (((x) & (y)) | ((~x) & (z))) +#define G(x, y, z) (((x) & (y)) | ((x) & (z)) | ((y) & (z))) +#define H(x, y, z) ((x) ^ (y) ^ (z)) + +/* ROTATE_LEFT rotates x left n bits. */ +#define ROTATE_LEFT(x, n) (((x) << (n)) | ((x) >> (32-(n)))) + +/* FF, GG and HH are transformations for rounds 1, 2 and 3 */ +/* Rotation is separate from addition to prevent recomputation */ +#define FF(a, b, c, d, x, s) {(a) += F ((b), (c), (d)) + (x); (a) = ROTATE_LEFT ((a), (s));} + +#define GG(a, b, c, d, x, s) {(a) += G ((b), (c), (d)) + (x) + (UINT4)0x5a827999; (a) = ROTATE_LEFT ((a), (s));} + +#define HH(a, b, c, d, x, s) {(a) += H ((b), (c), (d)) + (x) + (UINT4)0x6ed9eba1; (a) = \ +ROTATE_LEFT ((a), (s)); } + + +/* MD4 initialization. Begins an MD4 operation, writing a new context. */ +void MD4Init (MD4_CTX *context) +{ + context->count[0] = context->count[1] = 0; + +/* Load magic initialization constants.*/ +context->state[0] = 0x67452301; +context->state[1] = 0xefcdab89; +context->state[2] = 0x98badcfe; +context->state[3] = 0x10325476; +} + +/* MD4 block update operation. Continues an MD4 message-digest operation, processing another message block, and updating the context. */ +void MD4Update (MD4_CTX *context, unsigned char *input, unsigned int inputLen) +{ + unsigned int i, index, partLen; + + /* Compute number of bytes mod 64 */ + index = (unsigned int)((context->count[0] >> 3) & 0x3F); + + /* Update number of bits */ + if ((context->count[0] += ((UINT4)inputLen << 3))< ((UINT4)inputLen << 3)) + context->count[1]++; + + context->count[1] += ((UINT4)inputLen >> 29); + + partLen = 64 - index; + + /* Transform as many times as possible.*/ + if (inputLen >= partLen) + { + memcpy((POINTER)&context->buffer[index], (POINTER)input, partLen); + MD4Transform (context->state, context->buffer); + + for (i = partLen; i + 63 < inputLen; i += 64) + MD4Transform (context->state, &input[i]); + + index = 0; + } + else + i = 0; + + /* Buffer remaining input */ + memcpy ((POINTER)&context->buffer[index], (POINTER)&input[i], inputLen-i); +} + + +/* MD4 finalization. Ends an MD4 message-digest operation, writing the the message digest and zeroizing the context. */ +void MD4Final (unsigned char digest[16], MD4_CTX *context) +{ + unsigned char bits[8]; + unsigned int index, padLen; + + /* Save number of bits */ + Encode (bits, context->count, 8); + + /* Pad out to 56 mod 64.*/ + index = (unsigned int)((context->count[0] >> 3) & 0x3f); + padLen = (index < 56) ? (56 - index) : (120 - index); + MD4Update (context, PADDING, padLen); + + /* Append length (before padding) */ + MD4Update (context, bits, 8); + + /* Store state in digest */ + Encode (digest, context->state, 16); + + /* Zeroize sensitive information.*/ + memset ((POINTER)context, 0, sizeof (*context)); +} + + +/* MD4 basic transformation. Transforms state based on block. */ +static void MD4Transform (UINT4 state[4], unsigned char block[64]) +{ + UINT4 a = state[0], b = state[1], c = state[2], d = state[3], x[16]; + + Decode (x, block, 64); + +/* Round 1 */ +FF (a, b, c, d, x[ 0], S11); /* 1 */ +FF (d, a, b, c, x[ 1], S12); /* 2 */ +FF (c, d, a, b, x[ 2], S13); /* 3 */ +FF (b, c, d, a, x[ 3], S14); /* 4 */ +FF (a, b, c, d, x[ 4], S11); /* 5 */ +FF (d, a, b, c, x[ 5], S12); /* 6 */ +FF (c, d, a, b, x[ 6], S13); /* 7 */ +FF (b, c, d, a, x[ 7], S14); /* 8 */ +FF (a, b, c, d, x[ 8], S11); /* 9 */ +FF (d, a, b, c, x[ 9], S12); /* 10 */ +FF (c, d, a, b, x[10], S13); /* 11 */ +FF (b, c, d, a, x[11], S14); /* 12 */ +FF (a, b, c, d, x[12], S11); /* 13 */ +FF (d, a, b, c, x[13], S12); /* 14 */ +FF (c, d, a, b, x[14], S13); /* 15 */ +FF (b, c, d, a, x[15], S14); /* 16 */ + +/* Round 2 */ +GG (a, b, c, d, x[ 0], S21); /* 17 */ +GG (d, a, b, c, x[ 4], S22); /* 18 */ +GG (c, d, a, b, x[ 8], S23); /* 19 */ +GG (b, c, d, a, x[12], S24); /* 20 */ +GG (a, b, c, d, x[ 1], S21); /* 21 */ +GG (d, a, b, c, x[ 5], S22); /* 22 */ +GG (c, d, a, b, x[ 9], S23); /* 23 */ +GG (b, c, d, a, x[13], S24); /* 24 */ +GG (a, b, c, d, x[ 2], S21); /* 25 */ +GG (d, a, b, c, x[ 6], S22); /* 26 */ +GG (c, d, a, b, x[10], S23); /* 27 */ +GG (b, c, d, a, x[14], S24); /* 28 */ +GG (a, b, c, d, x[ 3], S21); /* 29 */ +GG (d, a, b, c, x[ 7], S22); /* 30 */ +GG (c, d, a, b, x[11], S23); /* 31 */ +GG (b, c, d, a, x[15], S24); /* 32 */ + +/* Round 3 */ +HH (a, b, c, d, x[ 0], S31); /* 33 */ +HH (d, a, b, c, x[ 8], S32); /* 34 */ +HH (c, d, a, b, x[ 4], S33); /* 35 */ +HH (b, c, d, a, x[12], S34); /* 36 */ +HH (a, b, c, d, x[ 2], S31); /* 37 */ +HH (d, a, b, c, x[10], S32); /* 38 */ +HH (c, d, a, b, x[ 6], S33); /* 39 */ +HH (b, c, d, a, x[14], S34); /* 40 */ +HH (a, b, c, d, x[ 1], S31); /* 41 */ +HH (d, a, b, c, x[ 9], S32); /* 42 */ +HH (c, d, a, b, x[ 5], S33); /* 43 */ +HH (b, c, d, a, x[13], S34); /* 44 */ +HH (a, b, c, d, x[ 3], S31); /* 45 */ +HH (d, a, b, c, x[11], S32); /* 46 */ +HH (c, d, a, b, x[ 7], S33); /* 47 */ +HH (b, c, d, a, x[15], S34); /* 48 */ + +state[0] += a; +state[1] += b; +state[2] += c; +state[3] += d; + + /* Zeroize sensitive information.*/ + memset ((POINTER)x, 0, sizeof (x)); +} + + +/* Encodes input (UINT4) into output (unsigned char). Assumes len is a multiple of 4. */ +static void Encode (unsigned char *output, UINT4 *input, unsigned int len) +{ + unsigned int i, j; + + for (i = 0, j = 0; j < len; i++, j += 4) { + output[j] = (unsigned char)(input[i] & 0xff); + output[j+1] = (unsigned char)((input[i] >> 8) & 0xff); + output[j+2] = (unsigned char)((input[i] >> 16) & 0xff); + output[j+3] = (unsigned char)((input[i] >> 24) & 0xff); + } +} + + +/* Decodes input (unsigned char) into output (UINT4). Assumes len is a multiple of 4. */ +static void Decode (UINT4 *output, unsigned char *input, unsigned int len) +{ +unsigned int i, j; + +for (i = 0, j = 0; j < len; i++, j += 4) + output[i] = ((UINT4)input[j]) | (((UINT4)input[j+1]) << 8) | (((UINT4)input[j+2]) << 16) | (((UINT4)input[j+3]) << 24); +} + +//=================================================================== + +unsigned Com_BlockChecksum (void *buffer, int length) +{ + int digest[4]; + unsigned val; + MD4_CTX ctx; + + MD4Init (&ctx); + MD4Update (&ctx, (unsigned char *)buffer, length); + MD4Final ( (unsigned char *)digest, &ctx); + + val = digest[0] ^ digest[1] ^ digest[2] ^ digest[3]; + + return val; +} diff --git a/tools/quake2/qdata_heretic2/common/path_init.c b/tools/quake2/qdata_heretic2/common/path_init.c index 644908ea..5554d02a 100644 --- a/tools/quake2/qdata_heretic2/common/path_init.c +++ b/tools/quake2/qdata_heretic2/common/path_init.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake2/qdata_heretic2/common/threads.c b/tools/quake2/qdata_heretic2/common/threads.c index ce51fb32..58462e16 100644 --- a/tools/quake2/qdata_heretic2/common/threads.c +++ b/tools/quake2/qdata_heretic2/common/threads.c @@ -110,7 +110,7 @@ WIN32 =================================================================== */ -#ifdef _WIN32 +#ifdef WIN32 #define USED diff --git a/tools/quake2/qdata_heretic2/qdata.c b/tools/quake2/qdata_heretic2/qdata.c index 64edf0a3..ee84c3b8 100644 --- a/tools/quake2/qdata_heretic2/qdata.c +++ b/tools/quake2/qdata_heretic2/qdata.c @@ -55,6 +55,8 @@ extern qboolean g_nomkdir; ======================================================= */ +unsigned Com_BlockChecksum (void *buffer, int length); + typedef struct { char name[56]; @@ -153,6 +155,7 @@ void FinishPak (void) int dirlen; int d; int i; + unsigned checksum; if (!g_pak) return; @@ -165,6 +168,8 @@ void FinishPak (void) pakheader.dirofs = LittleLong(ftell(pakfile)); pakheader.dirlen = LittleLong(dirlen); + checksum = Com_BlockChecksum ( (void *)pfiles, dirlen ); + SafeWrite (pakfile, pfiles, dirlen); i = ftell (pakfile); @@ -175,6 +180,7 @@ void FinishPak (void) d = pf - pfiles; printf ("%i files packed in %i bytes\n",d, i); + printf ("checksum: 0x%x\n", checksum); } diff --git a/tools/quake3/common/cmdlib.c b/tools/quake3/common/cmdlib.c index e2ea8f0a..24c9811f 100644 --- a/tools/quake3/common/cmdlib.c +++ b/tools/quake3/common/cmdlib.c @@ -333,7 +333,7 @@ void Q_getwd (char *out) { int i = 0; -#ifdef _WIN32 +#ifdef WIN32 _getcwd (out, 256); strcat (out, "\\"); #else @@ -352,7 +352,7 @@ void Q_getwd (char *out) void Q_mkdir (const char *path) { -#ifdef _WIN32 +#ifdef WIN32 if (_mkdir (path) != -1) return; #else @@ -1144,7 +1144,7 @@ void QCopyFile (const char *from, const char *to) void Sys_Sleep(int n) { -#ifdef _WIN32 +#ifdef WIN32 Sleep (n); #endif #if defined (__linux__) || defined (__APPLE__) diff --git a/tools/quake3/common/imagelib.c b/tools/quake3/common/imagelib.c index 7a0d22cf..f5752023 100644 --- a/tools/quake3/common/imagelib.c +++ b/tools/quake3/common/imagelib.c @@ -21,6 +21,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // imagelib.c +#include "inout.h" #include "cmdlib.h" #include "imagelib.h" #include "vfs.h" @@ -884,233 +885,242 @@ typedef struct _TargaHeader { unsigned char pixel_size, attributes; } TargaHeader; +void TargaError(TargaHeader *t, const char *message) +{ + Sys_Printf("%s\n:TargaHeader:\nuint8 id_length = %i;\nuint8 colormap_type = %i;\nuint8 image_type = %i;\nuint16 colormap_index = %i;\nuint16 colormap_length = %i;\nuint8 colormap_size = %i;\nuint16 x_origin = %i;\nuint16 y_origin = %i;\nuint16 width = %i;\nuint16 height = %i;\nuint8 pixel_size = %i;\nuint8 attributes = %i;\n", message, t->id_length, t->colormap_type, t->image_type, t->colormap_index, t->colormap_length, t->colormap_size, t->x_origin, t->y_origin, t->width, t->height, t->pixel_size, t->attributes); +} + /* ============= LoadTGABuffer ============= */ -void LoadTGABuffer ( byte *buffer, byte **pic, int *width, int *height) +void LoadTGABuffer (const byte *f, const byte *enddata, byte **pic, int *width, int *height) { - int columns, rows, numPixels; - byte *pixbuf; - int row, column; - byte *buf_p; - TargaHeader targa_header; - byte *targa_rgba; + int x, y, row_inc, compressed, readpixelcount, red, green, blue, alpha, runlen, pindex, alphabits, image_width, image_height; + byte *pixbuf, *image_rgba; + const byte *fin; + unsigned char *p; + TargaHeader targa_header; + unsigned char palette[256*4]; *pic = NULL; - buf_p = buffer; + // abort if it is too small to parse + if (enddata - f < 19) + return; - targa_header.id_length = *buf_p++; - targa_header.colormap_type = *buf_p++; - targa_header.image_type = *buf_p++; - - targa_header.colormap_index = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.colormap_length = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.colormap_size = *buf_p++; - targa_header.x_origin = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.y_origin = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.width = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.height = LittleShort ( *(short *)buf_p ); - buf_p += 2; - targa_header.pixel_size = *buf_p++; - targa_header.attributes = *buf_p++; - - if (targa_header.image_type!=2 - && targa_header.image_type!=10 - && targa_header.image_type != 3 ) + targa_header.id_length = f[0]; + targa_header.colormap_type = f[1]; + targa_header.image_type = f[2]; + + targa_header.colormap_index = f[3] + f[4] * 256; + targa_header.colormap_length = f[5] + f[6] * 256; + targa_header.colormap_size = f[7]; + targa_header.x_origin = f[8] + f[9] * 256; + targa_header.y_origin = f[10] + f[11] * 256; + targa_header.width = image_width = f[12] + f[13] * 256; + targa_header.height = image_height = f[14] + f[15] * 256; + + targa_header.pixel_size = f[16]; + targa_header.attributes = f[17]; + + // advance to end of header + fin = f + 18; + + // skip TARGA image comment (usually 0 bytes) + fin += targa_header.id_length; + + // read/skip the colormap if present (note: according to the TARGA spec it + // can be present even on truecolor or greyscale images, just not used by + // the image data) + if (targa_header.colormap_type) { - Error("LoadTGA: Only type 2 (RGB), 3 (gray), and 10 (RGB) TGA images supported\n"); + if (targa_header.colormap_length > 256) + { + TargaError(&targa_header, "LoadTGA: only up to 256 colormap_length supported\n"); + return; + } + if (targa_header.colormap_index) + { + TargaError(&targa_header, "LoadTGA: colormap_index not supported\n"); + return; + } + if (targa_header.colormap_size == 24) + { + for (x = 0;x < targa_header.colormap_length;x++) + { + palette[x*4+2] = *fin++; + palette[x*4+1] = *fin++; + palette[x*4+0] = *fin++; + palette[x*4+3] = 255; + } + } + else if (targa_header.colormap_size == 32) + { + for (x = 0;x < targa_header.colormap_length;x++) + { + palette[x*4+2] = *fin++; + palette[x*4+1] = *fin++; + palette[x*4+0] = *fin++; + palette[x*4+3] = *fin++; + } + } + else + { + TargaError(&targa_header, "LoadTGA: Only 32 and 24 bit colormap_size supported\n"); + return; + } } - if ( targa_header.colormap_type != 0 ) + // check our pixel_size restrictions according to image_type + if (targa_header.image_type == 2 || targa_header.image_type == 10) { - Error("LoadTGA: colormaps not supported\n" ); + if (targa_header.pixel_size != 24 && targa_header.pixel_size != 32) + { + TargaError(&targa_header, "LoadTGA: only 24bit and 32bit pixel sizes supported for type 2 and type 10 images\n"); + return; + } + } + else if (targa_header.image_type == 1 || targa_header.image_type == 9) + { + if (targa_header.pixel_size != 8) + { + TargaError(&targa_header, "LoadTGA: only 8bit pixel size for type 1, 3, 9, and 11 images supported\n"); + return; + } + } + else if (targa_header.image_type == 3 || targa_header.image_type == 11) + { + if (targa_header.pixel_size != 8) + { + TargaError(&targa_header, "LoadTGA: only 8bit pixel size for type 1, 3, 9, and 11 images supported\n"); + return; + } + } + else + { + TargaError(&targa_header, "LoadTGA: Only type 1, 2, 3, 9, 10, and 11 targa RGB images supported"); + return; } - if ( ( targa_header.pixel_size != 32 && targa_header.pixel_size != 24 ) && targa_header.image_type != 3 ) + if (targa_header.attributes & 0x10) { - Error("LoadTGA: Only 32 or 24 bit images supported (no colormaps)\n"); + TargaError(&targa_header, "LoadTGA: origin must be in top left or bottom left, top right and bottom right are not supported\n"); + return; } - columns = targa_header.width; - rows = targa_header.height; - numPixels = columns * rows; + // number of attribute bits per pixel, we only support 0 or 8 + alphabits = targa_header.attributes & 0x0F; + if (alphabits != 8 && alphabits != 0) + { + TargaError(&targa_header, "LoadTGA: only 0 or 8 attribute (alpha) bits supported\n"); + return; + } - if (width) - *width = columns; - if (height) - *height = rows; + image_rgba = safe_malloc(image_width * image_height * 4); + if (!image_rgba) + { + Sys_Printf("LoadTGA: not enough memory for %i by %i image\n", image_width, image_height); + return; + } - targa_rgba = safe_malloc (numPixels*4); - *pic = targa_rgba; + // If bit 5 of attributes isn't set, the image has been stored from bottom to top + if ((targa_header.attributes & 0x20) == 0) + { + pixbuf = image_rgba + (image_height - 1)*image_width*4; + row_inc = -image_width*4*2; + } + else + { + pixbuf = image_rgba; + row_inc = 0; + } - if (targa_header.id_length != 0) - buf_p += targa_header.id_length; // skip TARGA image comment - - if ( targa_header.image_type==2 || targa_header.image_type == 3 ) - { - // Uncompressed RGB or gray scale image - for(row=rows-1; row>=0; row--) + compressed = targa_header.image_type == 9 || targa_header.image_type == 10 || targa_header.image_type == 11; + x = 0; + y = 0; + red = green = blue = alpha = 255; + while (y < image_height) + { + // decoder is mostly the same whether it's compressed or not + readpixelcount = 1000000; + runlen = 1000000; + if (compressed && fin < enddata) + { + runlen = *fin++; + // high bit indicates this is an RLE compressed run + if (runlen & 0x80) + readpixelcount = 1; + runlen = 1 + (runlen & 0x7f); + } + + while((runlen--) && y < image_height) { - pixbuf = targa_rgba + row*columns*4; - for(column=0; column 0) { - unsigned char red,green,blue,alphabyte; - switch (targa_header.pixel_size) + readpixelcount--; + red = green = blue = alpha = 255; + if (fin < enddata) { - - case 8: - blue = *buf_p++; - green = blue; - red = blue; - *pixbuf++ = red; - *pixbuf++ = green; - *pixbuf++ = blue; - *pixbuf++ = 255; - break; - - case 24: - blue = *buf_p++; - green = *buf_p++; - red = *buf_p++; - *pixbuf++ = red; - *pixbuf++ = green; - *pixbuf++ = blue; - *pixbuf++ = 255; - break; - case 32: - blue = *buf_p++; - green = *buf_p++; - red = *buf_p++; - alphabyte = *buf_p++; - *pixbuf++ = red; - *pixbuf++ = green; - *pixbuf++ = blue; - *pixbuf++ = alphabyte; - break; - default: - //Error("LoadTGA: illegal pixel_size '%d' in file '%s'\n", targa_header.pixel_size, name ); - break; - } - } - } - } - else if (targa_header.image_type==10) { // Runlength encoded RGB images - unsigned char red,green,blue,alphabyte,packetHeader,packetSize,j; - - red = 0; - green = 0; - blue = 0; - alphabyte = 0xff; - - for(row=rows-1; row>=0; row--) { - pixbuf = targa_rgba + row*columns*4; - for(column=0; column0) - row--; - else - goto breakOut; - pixbuf = targa_rgba + row*columns*4; - } - } - } - else { // non run-length packet - for(j=0;j0) - row--; - else - goto breakOut; - pixbuf = targa_rgba + row*columns*4; - } + switch(targa_header.image_type) + { + case 1: + case 9: + // colormapped + pindex = *fin++; + if (pindex >= targa_header.colormap_length) + pindex = 0; // error + p = palette + pindex * 4; + red = p[0]; + green = p[1]; + blue = p[2]; + alpha = p[3]; + break; + case 2: + case 10: + // BGR or BGRA + blue = *fin++; + if (fin < enddata) + green = *fin++; + if (fin < enddata) + red = *fin++; + if (targa_header.pixel_size == 32 && fin < enddata) + alpha = *fin++; + break; + case 3: + case 11: + // greyscale + red = green = blue = *fin++; + break; } + if (!alphabits) + alpha = 255; } } - breakOut:; - } - } - - // vertically flipped - if ( (targa_header.attributes & (1<<5)) ) { - int flip; - for (row = 0; row < .5f * rows; row++) - { - for (column = 0; column < columns; column++) + *pixbuf++ = red; + *pixbuf++ = green; + *pixbuf++ = blue; + *pixbuf++ = alpha; + x++; + if (x == image_width) { - flip = *( (int*)targa_rgba + row * columns + column); - *( (int*)targa_rgba + row * columns + column) = *( (int*)targa_rgba + ( ( rows - 1 ) - row ) * columns + column ); - *( (int*)targa_rgba + ( ( rows - 1 ) - row ) * columns + column ) = flip; + // end of line, advance to next + x = 0; + y++; + pixbuf += row_inc; } } } - //free(buffer); + *pic = image_rgba; + if (width) + *width = image_width; + if (height) + *height = image_height; } - /* ============= LoadTGA @@ -1119,17 +1129,17 @@ LoadTGA void LoadTGA (const char *name, byte **pixels, int *width, int *height) { byte *buffer; - int nLen; + int nLen; // // load the file // nLen = vfsLoadFile ( ( char * ) name, (void **)&buffer, 0); - if (nLen == -1) - { + if (nLen == -1) + { Error ("Couldn't read %s", name); - } + } - LoadTGABuffer(buffer, pixels, width, height); + LoadTGABuffer(buffer, buffer + nLen, pixels, width, height); } diff --git a/tools/quake3/common/imagelib.h b/tools/quake3/common/imagelib.h index 9a99d6af..1379427d 100644 --- a/tools/quake3/common/imagelib.h +++ b/tools/quake3/common/imagelib.h @@ -36,9 +36,10 @@ void Save256Image (const char *name, byte *pixels, byte *palette, int width, int height); -void LoadTGA( const char *filename, byte **pixels, int *width, int *height ); -void LoadTGABuffer( byte *buffer, byte **pic, int *width, int *height ); -void WriteTGA( const char *filename, byte *data, int width, int height ); +void LoadTGA (const char *filename, byte **pixels, int *width, int *height); +void LoadTGABuffer ( const byte *buffer, const byte* enddata, byte **pic, int *width, int *height); +void WriteTGA (const char *filename, byte *data, int width, int height); int LoadJPGBuff( void *src_buffer, int src_size, unsigned char **pic, int *width, int *height ); -void Load32BitImage( const char *name, unsigned **pixels, int *width, int *height ); +void Load32BitImage (const char *name, unsigned **pixels, int *width, int *height); + diff --git a/tools/quake3/common/inout.c b/tools/quake3/common/inout.c index dcdd0893..6f127e3e 100644 --- a/tools/quake3/common/inout.c +++ b/tools/quake3/common/inout.c @@ -33,7 +33,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#ifdef _WIN32 +#ifdef WIN32 #include #include #endif @@ -42,7 +42,11 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA #include "l_net/l_net.h" #include "libxml/tree.h" -#ifdef _WIN32 +// utf8 conversion +#include +#include + +#ifdef WIN32 HWND hwndOut = NULL; qboolean lookedForServer = qfalse; UINT wm_BroadcastCommand = -1; @@ -289,7 +293,11 @@ void FPrintf (int flag, char *buf) bGotXML = qtrue; } node = xmlNewNode (NULL, "message"); - xmlNodeSetContent (node, buf); + { + gchar* utf8 = g_locale_to_utf8(buf, -1, NULL, NULL, NULL); + xmlNodeSetContent(node, utf8); + g_free(utf8); + } level[0] = (int)'0' + flag; level[1] = 0; xmlSetProp (node, "level", (char *)&level ); diff --git a/tools/quake3/common/inout.h b/tools/quake3/common/inout.h index d417a583..aa40ebdc 100644 --- a/tools/quake3/common/inout.h +++ b/tools/quake3/common/inout.h @@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA // inout is the only stuff relying on xml, include the headers there #include "libxml/tree.h" +#include "mathlib.h" // some useful xml routines xmlNodePtr xml_NodeForVec( vec3_t v ); diff --git a/tools/quake3/common/mutex.c b/tools/quake3/common/mutex.c index f7be7f5f..acca4a5d 100644 --- a/tools/quake3/common/mutex.c +++ b/tools/quake3/common/mutex.c @@ -31,7 +31,7 @@ WIN32 =================================================================== */ -#ifdef _WIN32 +#ifdef WIN32 #define USED diff --git a/tools/quake3/common/polylib.c b/tools/quake3/common/polylib.c index 187b1e70..75caec6b 100644 --- a/tools/quake3/common/polylib.c +++ b/tools/quake3/common/polylib.c @@ -249,8 +249,11 @@ winding_t *BaseWindingForPlane (vec3_t normal, vec_t dist) CrossProduct (vup, normal, vright); - VectorScale (vup, MAX_WORLD_COORD, vup); - VectorScale (vright, MAX_WORLD_COORD, vright); + // LordHavoc: this has to use *2 because otherwise some created points may + // be inside the world (think of a diagonal case), and any brush with such + // points should be removed, failure to detect such cases is disasterous + VectorScale (vup, MAX_WORLD_COORD*2, vup); + VectorScale (vright, MAX_WORLD_COORD*2, vright); // project a really big axis aligned box onto the plane w = AllocWinding (4); @@ -283,7 +286,7 @@ winding_t *CopyWinding (winding_t *w) winding_t *c; c = AllocWinding (w->numpoints); - size = (int)((winding_t *)0)->p[w->numpoints]; + size = (int)((size_t)((winding_t *)0)->p[w->numpoints]); memcpy (c, w, size); return c; } diff --git a/tools/quake3/common/surfaceflags.h b/tools/quake3/common/surfaceflags.h index 425e4f28..0267a18a 100644 --- a/tools/quake3/common/surfaceflags.h +++ b/tools/quake3/common/surfaceflags.h @@ -19,6 +19,8 @@ along with GtkRadiant; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +// Copyright (C) 1999-2000 Id Software, Inc. +// // This file must be identical in the quake and utils directories // contents flags are seperate bits diff --git a/tools/quake3/common/threads.c b/tools/quake3/common/threads.c index 463d32bd..abdf2055 100644 --- a/tools/quake3/common/threads.c +++ b/tools/quake3/common/threads.c @@ -110,7 +110,7 @@ WIN32 =================================================================== */ -#ifdef _WIN32 +#ifdef WIN32 #define USED @@ -602,7 +602,6 @@ RunThreadsOn */ void RunThreadsOn (int workcnt, qboolean showpacifier, void(*func)(int)) { - int i; int start, end; dispatch = 0; diff --git a/tools/quake3/common/vfs.c b/tools/quake3/common/vfs.c index 3afb00c6..25865661 100644 --- a/tools/quake3/common/vfs.c +++ b/tools/quake3/common/vfs.c @@ -60,7 +60,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. #include "cmdlib.h" #include "mathlib.h" -#include "glib.h" +#include #include "inout.h" #include "vfs.h" #include "unzip.h" diff --git a/tools/quake3/q3data/3dslib.c b/tools/quake3/q3data/3dslib.c index 719a487f..cecfb621 100644 --- a/tools/quake3/q3data/3dslib.c +++ b/tools/quake3/q3data/3dslib.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include #include "q3data.h" diff --git a/tools/quake3/q3data/3dslib.h b/tools/quake3/q3data/3dslib.h index cd73cb43..a24523c6 100644 --- a/tools/quake3/q3data/3dslib.h +++ b/tools/quake3/q3data/3dslib.h @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + typedef struct { float x, y, z; diff --git a/tools/quake3/q3data/compress.c b/tools/quake3/q3data/compress.c index af9669ab..b4b4892b 100644 --- a/tools/quake3/q3data/compress.c +++ b/tools/quake3/q3data/compress.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "q3data.h" #if 0 diff --git a/tools/quake3/q3data/images.c b/tools/quake3/q3data/images.c index de872d2b..6f8819ad 100644 --- a/tools/quake3/q3data/images.c +++ b/tools/quake3/q3data/images.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "q3data.h" byte *byteimage, *lbmpalette; diff --git a/tools/quake3/q3data/md3lib.c b/tools/quake3/q3data/md3lib.c index e959a411..4778017c 100644 --- a/tools/quake3/q3data/md3lib.c +++ b/tools/quake3/q3data/md3lib.c @@ -1,5 +1,26 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include -#ifdef _WIN32 +#ifdef WIN32 #include #endif #include "md3lib.h" diff --git a/tools/quake3/q3data/md3lib.h b/tools/quake3/q3data/md3lib.h index bdee0bd9..b6fdd16a 100644 --- a/tools/quake3/q3data/md3lib.h +++ b/tools/quake3/q3data/md3lib.h @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include #include "../common/cmdlib.h" #include "mathlib.h" diff --git a/tools/quake3/q3data/models.c b/tools/quake3/q3data/models.c index 1d2d6904..3c31f7bc 100644 --- a/tools/quake3/q3data/models.c +++ b/tools/quake3/q3data/models.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include #include "q3data.h" diff --git a/tools/quake3/q3data/oldstuff.c b/tools/quake3/q3data/oldstuff.c index c6083cf5..5f36f8bf 100644 --- a/tools/quake3/q3data/oldstuff.c +++ b/tools/quake3/q3data/oldstuff.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #if 0 /* diff --git a/tools/quake3/q3data/p3dlib.c b/tools/quake3/q3data/p3dlib.c index 0c3b6026..d115f22d 100644 --- a/tools/quake3/q3data/p3dlib.c +++ b/tools/quake3/q3data/p3dlib.c @@ -1,6 +1,27 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include "p3dlib.h" -#ifdef _WIN32 +#ifdef WIN32 #include #endif #include diff --git a/tools/quake3/q3data/p3dlib.h b/tools/quake3/q3data/p3dlib.h index 24e446d1..9d0bd6e4 100644 --- a/tools/quake3/q3data/p3dlib.h +++ b/tools/quake3/q3data/p3dlib.h @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #define P3D_GET_CROSSLINE 1 #define P3D_GET_RESTOFLINE 2 diff --git a/tools/quake3/q3data/polyset.c b/tools/quake3/q3data/polyset.c index f89a8cc0..388f8984 100644 --- a/tools/quake3/q3data/polyset.c +++ b/tools/quake3/q3data/polyset.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include #include "q3data.h" diff --git a/tools/quake3/q3data/q3data.c b/tools/quake3/q3data/q3data.c index 202f21dd..746fdc00 100644 --- a/tools/quake3/q3data/q3data.c +++ b/tools/quake3/q3data/q3data.c @@ -1,4 +1,25 @@ -#ifdef _WIN32 +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifdef WIN32 #include #endif #include "q3data.h" @@ -31,6 +52,8 @@ char writedir[1024]; ======================================================= */ +unsigned Com_BlockChecksum (void *buffer, int length); + typedef struct { char name[56]; diff --git a/tools/quake3/q3data/q3data.h b/tools/quake3/q3data/q3data.h index 458d4ed6..727afcde 100644 --- a/tools/quake3/q3data/q3data.h +++ b/tools/quake3/q3data/q3data.h @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + // q3data.h diff --git a/tools/quake3/q3data/stripper.c b/tools/quake3/q3data/stripper.c index c42d4420..4c8b9b1c 100644 --- a/tools/quake3/q3data/stripper.c +++ b/tools/quake3/q3data/stripper.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include #include #include diff --git a/tools/quake3/q3data/video.c b/tools/quake3/q3data/video.c index 9054d5e9..aae09f07 100644 --- a/tools/quake3/q3data/video.c +++ b/tools/quake3/q3data/video.c @@ -1,3 +1,24 @@ +/* +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA +*/ + #include #include "q3data.h" diff --git a/tools/quake3/q3map2/brush.c b/tools/quake3/q3map2/brush.c index 28ade081..2517ca63 100644 --- a/tools/quake3/q3map2/brush.c +++ b/tools/quake3/q3map2/brush.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -77,7 +78,7 @@ int CountBrushList( brush_t *brushes ) /* count brushes */ - for( brushes; brushes != NULL; brushes = brushes->next ) + for( ; brushes != NULL; brushes = brushes->next ) c++; return c; } @@ -92,13 +93,13 @@ allocates a new brush brush_t *AllocBrush( int numSides ) { brush_t *bb; - int c; + size_t c; /* allocate and clear */ if( numSides <= 0 ) Error( "AllocBrush called with numsides = %d", numSides ); - c = (int) &(((brush_t*) 0)->sides[ numSides ]); + c = (size_t)&(((brush_t*) 0)->sides[ numSides ]); bb = safe_malloc( c ); memset( bb, 0, c ); if( numthreads == 1 ) @@ -121,7 +122,7 @@ void FreeBrush( brush_t *b ) /* error check */ - if( *((int*) b) == 0xFEFEFEFE ) + if( *((unsigned int*) b) == 0xFEFEFEFE ) { Sys_FPrintf( SYS_VRB, "WARNING: Attempt to free an already freed brush!\n" ); return; @@ -133,8 +134,8 @@ void FreeBrush( brush_t *b ) FreeWinding( b->sides[ i ].winding ); /* ydnar: overwrite it */ - memset( b, 0xFE, (int) &(((brush_t*) 0)->sides[ b->numsides ]) ); - *((int*) b) = 0xFEFEFEFE; + memset( b, 0xFE, (size_t)&(((brush_t*) 0)->sides[ b->numsides ]) ); + *((unsigned int*) b) = 0xFEFEFEFE; /* free it */ free( b ); @@ -155,7 +156,7 @@ void FreeBrushList( brush_t *brushes ) /* walk brush list */ - for( brushes; brushes != NULL; brushes = next ) + for( ; brushes != NULL; brushes = next ) { next = brushes->next; FreeBrush( brushes ); @@ -172,12 +173,12 @@ duplicates the brush, sides, and windings brush_t *CopyBrush( brush_t *brush ) { brush_t *newBrush; - int size; + size_t size; int i; /* copy brush */ - size = (int) &(((brush_t*) 0)->sides[ brush->numsides ]); + size = (size_t)&(((brush_t*) 0)->sides[ brush->numsides ]); newBrush = AllocBrush( brush->numsides ); memcpy( newBrush, brush, size ); @@ -376,8 +377,6 @@ qboolean CreateBrushWindings( brush_t *brush ) continue; /* back side clipaway */ if( brush->sides[ j ].bevel ) continue; - if( brush->sides[ j ].backSide ) - continue; plane = &mapplanes[ brush->sides[ j ].planenum ^ 1 ]; ChopWindingInPlace( &w, plane->normal, plane->dist, 0 ); // CLIP_EPSILON ); @@ -850,9 +849,6 @@ void SplitBrush( brush_t *brush, int planenum, brush_t **front, brush_t **back ) w = BaseWindingForPlane (plane->normal, plane->dist); for (i=0 ; inumsides && w ; i++) { - if ( brush->sides[i].backSide ) { - continue; // fake back-sided polygons never split - } plane2 = &mapplanes[brush->sides[i].planenum ^ 1]; ChopWindingInPlace (&w, plane2->normal, plane2->dist, 0); // PLANESIDE_EPSILON); } @@ -910,18 +906,10 @@ void SplitBrush( brush_t *brush, int planenum, brush_t **front, brush_t **back ) // see if we have valid polygons on both sides for (i=0 ; i<2 ; i++) { - BoundBrush (b[i]); - for (j=0 ; j<3 ; j++) + if (b[i]->numsides < 3 || !BoundBrush (b[i])) { - if (b[i]->mins[j] < MIN_WORLD_COORD || b[i]->maxs[j] > MAX_WORLD_COORD) - { + if (b[i]->numsides >= 3) Sys_FPrintf (SYS_VRB,"bogus brush after clip\n"); - break; - } - } - - if (b[i]->numsides < 3 || j < 3) - { FreeBrush (b[i]); b[i] = NULL; } diff --git a/tools/quake3/q3map2/brush_primit.c b/tools/quake3/q3map2/brush_primit.c index 9bc2ab62..4a0d2520 100644 --- a/tools/quake3/q3map2/brush_primit.c +++ b/tools/quake3/q3map2/brush_primit.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake3/q3map2/bsp.c b/tools/quake3/q3map2/bsp.c index ed3d2430..b05901fa 100644 --- a/tools/quake3/q3map2/bsp.c +++ b/tools/quake3/q3map2/bsp.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -586,7 +587,9 @@ int BSPMain( int argc, char **argv ) tempSource[ 0 ] = '\0'; - /* set flares flag */ + /* set standard game flags */ + maxSurfaceVerts = game->maxSurfaceVerts; + maxSurfaceIndexes = game->maxSurfaceIndexes; emitFlares = game->emitFlares; /* process arguments */ @@ -687,11 +690,13 @@ int BSPMain( int argc, char **argv ) } else if( !strcmp( argv[ i ], "-mv" ) ) { - maxSurfaceVerts = atoi( argv[ i + 1 ] ); - if( maxSurfaceVerts < 3 ) - maxSurfaceVerts = 3; + maxLMSurfaceVerts = atoi( argv[ i + 1 ] ); + if( maxLMSurfaceVerts < 3 ) + maxLMSurfaceVerts = 3; + if( maxLMSurfaceVerts > maxSurfaceVerts ) + maxSurfaceVerts = maxLMSurfaceVerts; i++; - Sys_Printf( "Maximum per-surface vertex count set to %d\n", maxSurfaceVerts ); + Sys_Printf( "Maximum lightmapped surface vertex count set to %d\n", maxLMSurfaceVerts ); } else if( !strcmp( argv[ i ], "-mi" ) ) { diff --git a/tools/quake3/q3map2/bspfile_abstract.c b/tools/quake3/q3map2/bspfile_abstract.c index ae2fec30..a79d65b2 100644 --- a/tools/quake3/q3map2/bspfile_abstract.c +++ b/tools/quake3/q3map2/bspfile_abstract.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -435,7 +436,7 @@ void PrintBSPFileSizes( void ) Sys_Printf( "\n"); Sys_Printf( "%9d lightmaps %9d\n", - numBSPLightBytes / (LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT * 3), numBSPLightBytes ); + numBSPLightBytes / (game->lightmapSize * game->lightmapSize * 3), numBSPLightBytes ); Sys_Printf( "%9d lightgrid %9d *\n", numBSPGridPoints, (int) (numBSPGridPoints * sizeof( *bspGridPoints )) ); Sys_Printf( " visibility %9d\n", diff --git a/tools/quake3/q3map2/bspfile_ibsp.c b/tools/quake3/q3map2/bspfile_ibsp.c index 71b982da..abcfab99 100644 --- a/tools/quake3/q3map2/bspfile_ibsp.c +++ b/tools/quake3/q3map2/bspfile_ibsp.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake3/q3map2/bspfile_rbsp.c b/tools/quake3/q3map2/bspfile_rbsp.c index 1f4f1f77..74d77ae9 100644 --- a/tools/quake3/q3map2/bspfile_rbsp.c +++ b/tools/quake3/q3map2/bspfile_rbsp.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake3/q3map2/changelog.q3map1 b/tools/quake3/q3map2/changelog.q3map1 index e9be59b6..21b0cb99 100644 --- a/tools/quake3/q3map2/changelog.q3map1 +++ b/tools/quake3/q3map2/changelog.q3map1 @@ -1,371 +1,371 @@ -Old Q3Map 1.x and Early Q3Map2 Changelog (Chronological Order) - -- FILE IS STATIC. IF YOU MAKE CHANGES, UPDATE CHANGELOG.Q3MAP2 - - - -Date Version Notes ----------------------------------------------------------------- -2001-12-03 1.2 (ydnar) Alpha Initial version (win32) - -2001-12-03 1.2 (ydnar 2) Alpha Tolerance expanded - (more brush faces caught) - -2001-12-04 1.2 (ydnar 3) Alpha Detail faces inside other - detail brushes now culled, - Small against large detail - faces also culled. - -2001-12-04 1.2 (ydnar 4) Alpha djbob found a bug where - coincident caulk faces - were causing textured - faces to be caulked. Fixed. - -2001-12-04 1.2 (ydnar 7) Alpha 5 and 6 were internal test - versions. This version - takes into account extra - surface info, so coplanar - clip brushes no longer - cull away textured sides. - -2001-12-22 1.2 (ydnar 8) Alpha Optimized light. Lighting - for most maps should now - be measurable in minutes - as opposed to hours. - -2001-12-24 1.2 (ydnar 9) Alpha Fixed light. It is still - faster, but to enable - "blinding fast" mode, - you must supply the -fast - switch on the commandline - after -light. Fast mode - should be approximately - 2x as fast as build 8. - -2001-12-24 1.2 (ydnar 10) Alpha Grid lighting is now - optimized. Not as much - as I would like, but - a distance^2 cull before - traces on EVERY SINGLE - SURFACE LIGHT IN THE MAP - certainly speeds things - the fuck up. -fast not - necessary to see this - optimization. Also added - the -cheap switch to - limit light contributions - to a point when it exceeds - 255 in R, G, and B. This - *may* cause artifacts. - Test away... - -2001-12-24 1.2 (ydnar 11) Alpha Now using PVS data (vis). - Well constructed and - hinted maps should now - see a bit of a speedup. - Lights in the void are - also now removed as a - byproduct. - -2001-12-24 1.2 (ydnar 12) Alpha Fixed bug that caused - vlight to crash. - -2001-12-27 1.2 (ydnar 13) Alpha - Fixed broken PVS check. - - Cheap now supresses sun - Sun trace skipped if - sample is "cheapened." - - Experimental -smooth - option for subsampling - shadow edges. - - Experimental radiosity - code. Will probably crash. - - Other minor optimizations. - -2001-12-27 1.2 (ydnar 14) Alpha Build 13 always subsampled, - making it slower. Fixed. - -2001-12-28 1.2 (ydnar 15) Alpha Bad windings from edge- or - vertex- manipulated brushes - no longer created. Vertex - lighting on func_* with - an origin now works. - Radiosity should be more - stable (but not fully - correct yet). Light - envelopes now properly - calculated for entities - with origins. - -2001-12-28 1.2 (ydnar 16) Alpha Un-vised maps will now light. - -2001-12-30 1.2 (ydnar 17) Alpha Radiosity. Use q3map_bounce - in shaders to specify - amount of light to reflect. - Use -bounce N after -light - to enable radiosity. Use - -dump to emit radiosity - lights as a prefab. - -2001-12-31 1.2 (ydnar 18) Alpha Normalization release. New - features include -fastgrid, - -cheapgrid, and -fastbounce. - Running with -fastgrid and - -cheapgrid will produce - results identical to normal - q3map (with the lightgrid - being a little darker). - Also added q3map_nofast to - shaders to override -fast - switch for a surface light. - -2002-01-01 1.2 (ydnar 19) Alpha Fixed an odd vertex lighting - bug (thanks Quakin) that was - causing sun to leak to brush - faces when using r_vertexlight - ingame. Changed a little bit - of the default behavior, so - test with vertex lighting - and with terrain. Minor - shader changes might be - necessary to get some maps to - look as before. - -2002-01-01 1.2 (ydnar 20) Alpha Colored alpha shadows. Some - minor optimizations in - shadow tracing. Should be - slightly faster than 19. - -2002-01-02 1.2 (ydnar 21) Alpha Set up colored shadows - properly to use - surfaceparm lightfilter. - Shaders must use this parm - to have colored shadows. - Can be used with alphashadow - as well. - -2002-01-04 1.2.1-y1 (nightly) This version is all new, - based off the official - GtkRadiant tree, which has - all the previous enhancements. - New features include colored - lightgrid tracing through - lightfilter shaders, and - surfaceparm lightgrid, for - large/space maps with large - volumes. Also fixed are - potential broken brush - winding radiosity crashes. - Maybe. - -2002-01-05 1.2.1-y2 (nightly) Merged latest CVS. Removed - bug where ambient was getting - calculated into the radiosity - solution for every pass, - leading to overbright maps - in a hurry. Also removed - the bad PTPFF reporting, - as it only caused problems - with radiosity in a big way. - Sue me. - -2002-01-05 1.2.1-y3 (nightly) I really suck. Sample color - now properly cleared to 0 - when bouncing. - -2002-01-07 1.2.1-y4 (nightly) Particle Studio generated - brush faces should no longer - be culled. I no longer cull - faces that are autosprite. - Added -bouncegrid to have - radiosity add to lightgrid. - -2002-01-08 1.2.1-y5 (nightly) Same as y4, but compiled with - full optimizations. Should - be 10-25% faster in all, - including BSP and vis - stages. - -2002-01-09 1.2.1-y6 (nightly) Brushfaces with polygonoffset - in their shader will no longer - be faceculled. - -2002-01-11 1.2.1-y7 (nightly) Increased stack size for threads - to 4MB on Win32 to (hopefully) - elminate stack overflow - crash with radiosity. Also - made subdivision use the heap - to lessen the stack load. Fixed - bug where q3map_bounce was not - being used in shader parsing. - Redid some of the divide math - to work in 0-255 instead of - 0-256. - -2002-01-11 1.2.1-y8 (nightly) More Win32 threading - crutches. Eat me, Bill. - -2002-01-15 1.2.1-y9 RR2DO2 noticed a stupid bug - in my PVS code. Fixed it, - so the PVS light opts work as - they should. Lighting is - faster. Also got rid of some - redundant square roots from - the raytracing, speeding up - lighting another ~25%. - -2002-01-20 1.2.1-y10 Fixed a potential crash bug - with maps with 0 lights. Also - changed how lightmaps are - projected onto patches that - lie in a single plane (bevel - endcaps, floors, etc). Shadows - now work properly on them. - -2002-01-22 1.2.1-y11 Fixed a divide-by-zero crash - with maps with no lights or - no tracing. Also added - code to make brush/patch - vertex lighting more closely - resemble lightmap, even on - less-than-perfect maps. And - -light is faster, too...about - 25% on q3dm17. 34->25 seconds. - -2002-01-24 1.2.1-y12 Completely rewrote the path - argument handling. Should find - the Quake 3 dir and other - dirs properly now. Needs to - be tested on Linux though. - Also made lights linear by - default when run with -game - wolf. This is to match the - Gray Matter q3map and - entity definition. - -2002-01-28 1.2.4-y1 Merged from 1.2.4-nightly CVS - sources. Fog sparklies gone. - -nopatchfix so vlight works - properly again. Cleaned up - paths processing some more, - including Linux stuff. Added - _lightmapscale entity key. - Brought -game wolf lighting - to parity with GM tools. - RR2DO2's PCX loading fix. A - bunch of other useful fun shit. - -2002-01-29 1.2.4-y2 Fixed a bug in RR2DO2's PCX fix. - Fixed a stupid bug in lightmap - dimension bounds checking (thanks - Laerth). - -2002-01-29 1.2.4-y3 Now will detect (and report to - GtkRadiant) all degenerate patches - like those created by capping a - cone. - -2002-02-23 2.0.0-a1 thru a3 Rewrote about 30% of the code. - Lots of cool new shit. - -2002-02-24 2.0.0-a4 thru a8 Terrain fix (thx Pointy), patches - are no longer circus colored, more - terrain texturing fixes. - -2002-02-26 2.0.0-a10 thru a11 Adjacent coplanar surfaces now - will share lightmaps. This prevents - most wierd edge cases with filter - and speeds things up a bit. Patches - too. - -2002-02-27 2.0.0-a12 More lightmap fixes for non-planar - surfaces. Bugfixes in allocation/ - compression of lightmaps as well. - -2002-03-02 2.0.0-a13 Fixed some surface light bugs, - adjusted the occluded-luxel finding - code, and amped the radiosity. Other - fixes to RTCW lighting code (better - angle attenuation on linear lights). - -2002-03-04 2.0.0-a14 Vertex light should now be near- - perfect on clean (and mostly on not- - so-clean) maps. Unlit maps will no - longer have tri-fanned brush faces - with random vertex colors. VLight is - now totally gone (reverts to -light). - -2002-03-06 2.0.0-a15 Relaxed the planar check, should now - classify all slightly-off plane brush - face metasurfaces as planar. Triangle - checking much more stringent as well. - -2002-03-11 2.0.0-a16 Vis crash gone. Lightmap allocation - now sorted by shader to minimize - shader count (and lessen chance for - RTCW shader substitution bug). Hit - big quarter-century also. - -2002-03-12 2.0.0-a17 Dammit. - -2002-03-12 2.0.0-a18 Hunting phantom lights... - -2002-03-16 2.0.0-a19 Fogclip and _celshader. Check the - extras folder... - -2002-03-18 2.0.0-b1-rc1 Beta release candidate. Fixed the - stupid phantom light bug finally. - Tricked out the sun tracing a wee - bit as well, should be a little - faster + more accurate. Other little - bits fixed up as well. Thanks to K, - {wf}ShadowSpawn and RR2DO2 for their - help tracking these last bugs down. - -2002-03-19 2.0.0-b1-rc2 Increased some maximums, and got - rid of some cruft. - -2002-03-22 2.0.0-b1-rc3 Some minor optimizations. - -2002-03-30 2.0.0-b1-rc5 Now with fur (see extras/fur.shader). - -2002-04-01 2.0.0-b1-rc6 Enhanced with baby seal technology. - -2002-05-01 2.0.1 OK, better late than never. Fixed the - alphashadow = 255 = transparent bug. - -2002-06-24 2.1.0-b1 Added _foghull functionality. Works - like terrain "_shader" where - you don't need "textures/" prefix. - Also added q3map_normalmap. See - NVIDIA's website for Photoshop filter - to generate normalmaps from grayscale - heightmaps. This makes lightmaps - look bumpmapped. Currently 50% broken. - -2002-07-06 2.2.0-b1 Empty epairs now stripped from map, - fixing Wolfenstein crash bug. Func_* - entities are now fogged properly. - Sort of. This will be enhanced later. - Added the .srf file to store all the - extra crap I was hiding in the BSP. - It's an editable text file that - -light uses, so you can change the - samplesize w/o recompiling the map - (just -light'ing it). Changed color - normalization to clamping, because - it looks better. Other stuff got - fixed as well. - -2002-07-08 2.2.0-b2 thru b11 Test versions. Thanks jer and jet! - -2002-07-09 2.2.0-b12 Larger-than-life lightmaps are now - supported, up to 1024x1024. Add - q3map_lightmapSize H W to a shader - to use. Lightmaps are stored in - maps/{mapname}/_lm_NNN.tga and a - shader script q3map_{mapname}.shader - is generated. Also added - q3map_lightmapGamma N.N. Use a - value of 2.0 to simulate - r_overBrightBits 1 and - r_mapOverBrightBits 2 on external - lightmap images. +Old Q3Map 1.x and Early Q3Map2 Changelog (Chronological Order) + +- FILE IS STATIC. IF YOU MAKE CHANGES, UPDATE CHANGELOG.Q3MAP2 - + + +Date Version Notes +---------------------------------------------------------------- +2001-12-03 1.2 (ydnar) Alpha Initial version (win32) + +2001-12-03 1.2 (ydnar 2) Alpha Tolerance expanded + (more brush faces caught) + +2001-12-04 1.2 (ydnar 3) Alpha Detail faces inside other + detail brushes now culled, + Small against large detail + faces also culled. + +2001-12-04 1.2 (ydnar 4) Alpha djbob found a bug where + coincident caulk faces + were causing textured + faces to be caulked. Fixed. + +2001-12-04 1.2 (ydnar 7) Alpha 5 and 6 were internal test + versions. This version + takes into account extra + surface info, so coplanar + clip brushes no longer + cull away textured sides. + +2001-12-22 1.2 (ydnar 8) Alpha Optimized light. Lighting + for most maps should now + be measurable in minutes + as opposed to hours. + +2001-12-24 1.2 (ydnar 9) Alpha Fixed light. It is still + faster, but to enable + "blinding fast" mode, + you must supply the -fast + switch on the commandline + after -light. Fast mode + should be approximately + 2x as fast as build 8. + +2001-12-24 1.2 (ydnar 10) Alpha Grid lighting is now + optimized. Not as much + as I would like, but + a distance^2 cull before + traces on EVERY SINGLE + SURFACE LIGHT IN THE MAP + certainly speeds things + the fuck up. -fast not + necessary to see this + optimization. Also added + the -cheap switch to + limit light contributions + to a point when it exceeds + 255 in R, G, and B. This + *may* cause artifacts. + Test away... + +2001-12-24 1.2 (ydnar 11) Alpha Now using PVS data (vis). + Well constructed and + hinted maps should now + see a bit of a speedup. + Lights in the void are + also now removed as a + byproduct. + +2001-12-24 1.2 (ydnar 12) Alpha Fixed bug that caused + vlight to crash. + +2001-12-27 1.2 (ydnar 13) Alpha - Fixed broken PVS check. + - Cheap now supresses sun + Sun trace skipped if + sample is "cheapened." + - Experimental -smooth + option for subsampling + shadow edges. + - Experimental radiosity + code. Will probably crash. + - Other minor optimizations. + +2001-12-27 1.2 (ydnar 14) Alpha Build 13 always subsampled, + making it slower. Fixed. + +2001-12-28 1.2 (ydnar 15) Alpha Bad windings from edge- or + vertex- manipulated brushes + no longer created. Vertex + lighting on func_* with + an origin now works. + Radiosity should be more + stable (but not fully + correct yet). Light + envelopes now properly + calculated for entities + with origins. + +2001-12-28 1.2 (ydnar 16) Alpha Un-vised maps will now light. + +2001-12-30 1.2 (ydnar 17) Alpha Radiosity. Use q3map_bounce + in shaders to specify + amount of light to reflect. + Use -bounce N after -light + to enable radiosity. Use + -dump to emit radiosity + lights as a prefab. + +2001-12-31 1.2 (ydnar 18) Alpha Normalization release. New + features include -fastgrid, + -cheapgrid, and -fastbounce. + Running with -fastgrid and + -cheapgrid will produce + results identical to normal + q3map (with the lightgrid + being a little darker). + Also added q3map_nofast to + shaders to override -fast + switch for a surface light. + +2002-01-01 1.2 (ydnar 19) Alpha Fixed an odd vertex lighting + bug (thanks Quakin) that was + causing sun to leak to brush + faces when using r_vertexlight + ingame. Changed a little bit + of the default behavior, so + test with vertex lighting + and with terrain. Minor + shader changes might be + necessary to get some maps to + look as before. + +2002-01-01 1.2 (ydnar 20) Alpha Colored alpha shadows. Some + minor optimizations in + shadow tracing. Should be + slightly faster than 19. + +2002-01-02 1.2 (ydnar 21) Alpha Set up colored shadows + properly to use + surfaceparm lightfilter. + Shaders must use this parm + to have colored shadows. + Can be used with alphashadow + as well. + +2002-01-04 1.2.1-y1 (nightly) This version is all new, + based off the official + GtkRadiant tree, which has + all the previous enhancements. + New features include colored + lightgrid tracing through + lightfilter shaders, and + surfaceparm lightgrid, for + large/space maps with large + volumes. Also fixed are + potential broken brush + winding radiosity crashes. + Maybe. + +2002-01-05 1.2.1-y2 (nightly) Merged latest CVS. Removed + bug where ambient was getting + calculated into the radiosity + solution for every pass, + leading to overbright maps + in a hurry. Also removed + the bad PTPFF reporting, + as it only caused problems + with radiosity in a big way. + Sue me. + +2002-01-05 1.2.1-y3 (nightly) I really suck. Sample color + now properly cleared to 0 + when bouncing. + +2002-01-07 1.2.1-y4 (nightly) Particle Studio generated + brush faces should no longer + be culled. I no longer cull + faces that are autosprite. + Added -bouncegrid to have + radiosity add to lightgrid. + +2002-01-08 1.2.1-y5 (nightly) Same as y4, but compiled with + full optimizations. Should + be 10-25% faster in all, + including BSP and vis + stages. + +2002-01-09 1.2.1-y6 (nightly) Brushfaces with polygonoffset + in their shader will no longer + be faceculled. + +2002-01-11 1.2.1-y7 (nightly) Increased stack size for threads + to 4MB on Win32 to (hopefully) + elminate stack overflow + crash with radiosity. Also + made subdivision use the heap + to lessen the stack load. Fixed + bug where q3map_bounce was not + being used in shader parsing. + Redid some of the divide math + to work in 0-255 instead of + 0-256. + +2002-01-11 1.2.1-y8 (nightly) More Win32 threading + crutches. Eat me, Bill. + +2002-01-15 1.2.1-y9 RR2DO2 noticed a stupid bug + in my PVS code. Fixed it, + so the PVS light opts work as + they should. Lighting is + faster. Also got rid of some + redundant square roots from + the raytracing, speeding up + lighting another ~25%. + +2002-01-20 1.2.1-y10 Fixed a potential crash bug + with maps with 0 lights. Also + changed how lightmaps are + projected onto patches that + lie in a single plane (bevel + endcaps, floors, etc). Shadows + now work properly on them. + +2002-01-22 1.2.1-y11 Fixed a divide-by-zero crash + with maps with no lights or + no tracing. Also added + code to make brush/patch + vertex lighting more closely + resemble lightmap, even on + less-than-perfect maps. And + -light is faster, too...about + 25% on q3dm17. 34->25 seconds. + +2002-01-24 1.2.1-y12 Completely rewrote the path + argument handling. Should find + the Quake 3 dir and other + dirs properly now. Needs to + be tested on Linux though. + Also made lights linear by + default when run with -game + wolf. This is to match the + Gray Matter q3map and + entity definition. + +2002-01-28 1.2.4-y1 Merged from 1.2.4-nightly CVS + sources. Fog sparklies gone. + -nopatchfix so vlight works + properly again. Cleaned up + paths processing some more, + including Linux stuff. Added + _lightmapscale entity key. + Brought -game wolf lighting + to parity with GM tools. + RR2DO2's PCX loading fix. A + bunch of other useful fun shit. + +2002-01-29 1.2.4-y2 Fixed a bug in RR2DO2's PCX fix. + Fixed a stupid bug in lightmap + dimension bounds checking (thanks + Laerth). + +2002-01-29 1.2.4-y3 Now will detect (and report to + GtkRadiant) all degenerate patches + like those created by capping a + cone. + +2002-02-23 2.0.0-a1 thru a3 Rewrote about 30% of the code. + Lots of cool new shit. + +2002-02-24 2.0.0-a4 thru a8 Terrain fix (thx Pointy), patches + are no longer circus colored, more + terrain texturing fixes. + +2002-02-26 2.0.0-a10 thru a11 Adjacent coplanar surfaces now + will share lightmaps. This prevents + most wierd edge cases with filter + and speeds things up a bit. Patches + too. + +2002-02-27 2.0.0-a12 More lightmap fixes for non-planar + surfaces. Bugfixes in allocation/ + compression of lightmaps as well. + +2002-03-02 2.0.0-a13 Fixed some surface light bugs, + adjusted the occluded-luxel finding + code, and amped the radiosity. Other + fixes to RTCW lighting code (better + angle attenuation on linear lights). + +2002-03-04 2.0.0-a14 Vertex light should now be near- + perfect on clean (and mostly on not- + so-clean) maps. Unlit maps will no + longer have tri-fanned brush faces + with random vertex colors. VLight is + now totally gone (reverts to -light). + +2002-03-06 2.0.0-a15 Relaxed the planar check, should now + classify all slightly-off plane brush + face metasurfaces as planar. Triangle + checking much more stringent as well. + +2002-03-11 2.0.0-a16 Vis crash gone. Lightmap allocation + now sorted by shader to minimize + shader count (and lessen chance for + RTCW shader substitution bug). Hit + big quarter-century also. + +2002-03-12 2.0.0-a17 Dammit. + +2002-03-12 2.0.0-a18 Hunting phantom lights... + +2002-03-16 2.0.0-a19 Fogclip and _celshader. Check the + extras folder... + +2002-03-18 2.0.0-b1-rc1 Beta release candidate. Fixed the + stupid phantom light bug finally. + Tricked out the sun tracing a wee + bit as well, should be a little + faster + more accurate. Other little + bits fixed up as well. Thanks to K, + {wf}ShadowSpawn and RR2DO2 for their + help tracking these last bugs down. + +2002-03-19 2.0.0-b1-rc2 Increased some maximums, and got + rid of some cruft. + +2002-03-22 2.0.0-b1-rc3 Some minor optimizations. + +2002-03-30 2.0.0-b1-rc5 Now with fur (see extras/fur.shader). + +2002-04-01 2.0.0-b1-rc6 Enhanced with baby seal technology. + +2002-05-01 2.0.1 OK, better late than never. Fixed the + alphashadow = 255 = transparent bug. + +2002-06-24 2.1.0-b1 Added _foghull functionality. Works + like terrain "_shader" where + you don't need "textures/" prefix. + Also added q3map_normalmap. See + NVIDIA's website for Photoshop filter + to generate normalmaps from grayscale + heightmaps. This makes lightmaps + look bumpmapped. Currently 50% broken. + +2002-07-06 2.2.0-b1 Empty epairs now stripped from map, + fixing Wolfenstein crash bug. Func_* + entities are now fogged properly. + Sort of. This will be enhanced later. + Added the .srf file to store all the + extra crap I was hiding in the BSP. + It's an editable text file that + -light uses, so you can change the + samplesize w/o recompiling the map + (just -light'ing it). Changed color + normalization to clamping, because + it looks better. Other stuff got + fixed as well. + +2002-07-08 2.2.0-b2 thru b11 Test versions. Thanks jer and jet! + +2002-07-09 2.2.0-b12 Larger-than-life lightmaps are now + supported, up to 1024x1024. Add + q3map_lightmapSize H W to a shader + to use. Lightmaps are stored in + maps/{mapname}/_lm_NNN.tga and a + shader script q3map_{mapname}.shader + is generated. Also added + q3map_lightmapGamma N.N. Use a + value of 2.0 to simulate + r_overBrightBits 1 and + r_mapOverBrightBits 2 on external + lightmap images. diff --git a/tools/quake3/q3map2/changelog.q3map2.txt b/tools/quake3/q3map2/changelog.q3map2.txt index 47bceb51..d58c0242 100644 --- a/tools/quake3/q3map2/changelog.q3map2.txt +++ b/tools/quake3/q3map2/changelog.q3map2.txt @@ -1,5 +1,107 @@ Q3Map2 Version History + Changelog (Reverse Chronological Order) +2.5.16 (2004-10-18) + +- New: -fixaas mode to reassociate an AAS file with a changed BSP +- New: -nostyles switch on light phase disabling lightstyles +- Using libmhash cryptographic hashing library instead of md5lib + + +2.5.15 (2004-07-08) + +- New: q3map_rgbGen, q3map_rgbMod or q3map_colorGen, q3map_colorMod +- New: q3map_alphaGen const (like q3map_alphaMod set) +- New: q3map_noVertexLight to suppress overwriting of vertex rgb +- q3map_backShader now works again, can be used instead of + q3map_cloneShader + q3map_invert on the target shader +- q3map_alphaMod volume brushes in func_group entities will now only + affect that entity's surfaces +- q3map_clipModel now works on trans/nonsolid shaders, allowing + simplified clipping surfaces in models +- Fixed bug in alphaMod code where only the first vertex was being + modded (thanks Ratty) +- Vis exits instead of crashing with divide-by-zero when there are + no portals on simple box maps +- All of a surface's lightmaps must be solid or not solid, fixing + ST coord problem with non-Raven games using lightstyles +- Reverted a change in the meta code which was causing lightmap coord + overflows and ugly self-shadowing errors on surface boundaries +- Any use of lightstyles automatically sets -nocollapse to reduce + total shader counts +- Tenebrae lightmap size changed to 512x512 + + +2.5.14 (2004-04-09) + +- New: -dirty mode courtesy of RaP7oR (dirtmapping/ambient occlusion) +- New: q3map_skyLight code using more uniform angular distribution about + the sky hemisphere +- New: q3map_alphaMod set N.N +- New: q3map_alphaMod scale N.N +- New: q3map_alphaMod volume - applies all other q3map_alphaMod directives + to each vertex inside a brush textured with this shader, allowing large + faded scrolling fire shaders, waterfalls, marquees, explicit dotProduct + terrain blending control, etc. +- Fixed a bug in alphaMod code where the type of the first alphaMod was + being used for all subsequent alphaMods +- Lowered vertex-lit surface limits to 999 verts, 1000 was breaking Quake 3 +- Tightened up solid lightmap tolerances +- Fixed bug in solid lightmap code where lightmap SD coords were being + incorrectly set + + +2.5.13 (2004-03-03) + +- New: -convert -format to convert between different BSP formats. + Example, to convert a Jedi Academy map to Enemy Territory: + -game ja -convert -format et +- New: -game etut support for Urban Terror on Enemy Territory +- New: -analyze mode for reverse engineering a BSP format +- New: -compensate N.N (default 1.0) for descaling lightmap/vertex/grid + data to compensate for ingame overbrighting. 4.0 is a good value for + Quake 3 if used in combination with -gamma 2.2 +- New: compensate/gamma per-game setting +- New: -light -cpma argument for "classic" (sic) vertex lighting +- Replaced malloc() with stack allocation in IlluminateRawLightmap for + most small/medium lightmap calculations +- Misc cleanups in q3map2.h +- Support for non-128x128 lightmaps +- The -meta process will now generate surfaces with more than 64 + verts that have non-lightmapped shaders +- Extended lightmap size tolerance to 2x for merging meta triangles in + maps with aggressive lightmapscale. Sorry kids! +- Moved surface finish pass (celshading, cloning) to final surface pass. + This should fix a bug involving fog/tesselation/celshading/cloning +- Solid-color lightmaps (within 1/255 in RGB) are detected and replaced + with a single pixel lightmap, saving space + + +2.5.12 (2004-01-18) + +- New: -dark option for dark lightmap/brush seams in -light (Unreal 1-ish) +- New: spawnflags 4 on misc_model entities makes them forcemeta/lightmapped + unless explicitly set as vertex lit in their shader(s). This can be + combined with spawnflags 2 (solid) as spawnflags 6 +- New: -gamma N.N switch sets lightmap/vertex gamma value for more + realistic lighting, instead of using high ambient/minlight. Default + is 1.0 (linear ramp), good values are between 1.5 and 2.2 +- Changed q3map_lightmapGamma N.N to q3map_lightmapBrightness N.N, to + better match its intended function +- Ported to VS.NET 2003 and GtkRadiant 1.5 (spog_branch) +- Fixed bug in _skybox maps where sunlight was leaking through brushes. + Thanks pjw! +- Fixed bug in ASE loader where models without submodels/submaterials + would not load properly. +- Fixed bug where q3map_tcGen was not being applied to models +- Optimized MergeMetaTriangles a bit +- Added KOR's fix to raytracer +- -bouncegrid no longer affects the lightgrid dir +- Added feature to PicoModel where spaces in material names in 3DS, ASE + and LWO models will mark the end of the shader name, so you can have + "textures/foo/bar 1" and "textures/foo/bar 2" in Lightwave, and both + surfaces will map to "textures/foo/bar" + + 2.5.11 (2003-12-01) - New: added support for _skybox entities to generate "portal sky" diff --git a/tools/quake3/q3map2/convert_ase.c b/tools/quake3/q3map2/convert_ase.c index f0ac6df5..2be25a43 100644 --- a/tools/quake3/q3map2/convert_ase.c +++ b/tools/quake3/q3map2/convert_ase.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake3/q3map2/convert_map.c b/tools/quake3/q3map2/convert_map.c index ca0ba7fb..1fabbc63 100644 --- a/tools/quake3/q3map2/convert_map.c +++ b/tools/quake3/q3map2/convert_map.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake3/q3map2/decals.c b/tools/quake3/q3map2/decals.c index 5260437d..f4de7cea 100644 --- a/tools/quake3/q3map2/decals.c +++ b/tools/quake3/q3map2/decals.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -659,9 +660,6 @@ static void ProjectDecalOntoWinding( decalProjector_t *dp, mapDrawSurface_t *ds, dv->color[ j ][ 3 ] = alpha; } } - - /* ydnar: finish the surface */ - FinishSurface( ds2 ); } @@ -788,8 +786,7 @@ static void ProjectDecalOntoTriangles( decalProjector_t *dp, mapDrawSurface_t *d /* triangle surfaces without shaders don't get marks by default */ - if( (ds->type == SURFACE_TRIANGLES || ds->type == SURFACE_FORCED_META) && - ds->shaderInfo->shaderText == NULL ) + if( ds->type == SURFACE_TRIANGLES && ds->shaderInfo->shaderText == NULL ) return; /* backface check */ diff --git a/tools/quake3/q3map2/facebsp.c b/tools/quake3/q3map2/facebsp.c index 484a7489..270eefe2 100644 --- a/tools/quake3/q3map2/facebsp.c +++ b/tools/quake3/q3map2/facebsp.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -179,7 +180,7 @@ int CountFaceList( face_t *list ) c = 0; - for( list; list != NULL; list = list->next ) + for( ; list != NULL; list = list->next ) c++; return c; } diff --git a/tools/quake3/q3map2/fog.c b/tools/quake3/q3map2/fog.c index 0cfdc924..c9ee6e25 100644 --- a/tools/quake3/q3map2/fog.c +++ b/tools/quake3/q3map2/fog.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -396,8 +397,6 @@ qboolean ChopFaceSurfaceByBrush( entity_t *e, mapDrawSurface_t *ds, brush_t *b ) { /* get brush side and plane */ s = &b->sides[ i ]; - if( s->backSide ) - continue; plane = &mapplanes[ s->planenum ]; /* handle coplanar outfacing (don't fog) */ diff --git a/tools/quake3/q3map2/game_ef.h b/tools/quake3/q3map2/game_ef.h index 8d15c732..f8d21d1a 100644 --- a/tools/quake3/q3map2/game_ef.h +++ b/tools/quake3/q3map2/game_ef.h @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -104,11 +105,18 @@ game_t struct ".ef", /* unix home sub-dir */ "elite", /* magic path word */ "scripts", /* shader directory */ - qfalse, /* wolf lighting model? */ + 64, /* max lightmapped surface verts */ + 999, /* max surface verts */ + 6000, /* max surface indexes */ qfalse, /* flares */ "flareshader", /* default flare shader */ + qfalse, /* wolf lighting model? */ + 128, /* lightmap width/height */ + 1.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ LoadIBSPFile, /* bsp load function */ WriteIBSPFile, /* bsp write function */ diff --git a/tools/quake3/q3map2/game_etut.h b/tools/quake3/q3map2/game_etut.h new file mode 100644 index 00000000..9823ff96 --- /dev/null +++ b/tools/quake3/q3map2/game_etut.h @@ -0,0 +1,264 @@ +/* ------------------------------------------------------------------------------- + +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +---------------------------------------------------------------------------------- + +This code has been altered significantly from its original form, to support +several games based on the Quake III Arena engine, in the form of "Q3Map2." + +------------------------------------------------------------------------------- */ + + + +/* marker */ +#ifndef GAME_ETUT_H +#define GAME_ETUT_H + + + +/* ------------------------------------------------------------------------------- + +content and surface flags + +------------------------------------------------------------------------------- */ + +/* game flags */ +#define U_CONT_SOLID 1 /* an eye is never valid in a solid */ +#define U_CONT_LAVA 8 +#define U_CONT_SLIME 16 +#define U_CONT_WATER 32 +#define U_CONT_FOG 64 + +#define U_CONT_AREAPORTAL 0x8000 + +#define U_CONT_PLAYERCLIP 0x10000 +#define U_CONT_MONSTERCLIP 0x20000 +#define U_CONT_TELEPORTER 0x40000 +#define U_CONT_JUMPPAD 0x80000 +#define U_CONT_CLUSTERPORTAL 0x100000 +#define U_CONT_DONOTENTER 0x200000 +#define U_CONT_BOTCLIP 0x400000 + +#define U_CONT_ORIGIN 0x1000000 /* removed before bsping an entity */ + +#define U_CONT_BODY 0x2000000 /* should never be on a brush, only in game */ +#define U_CONT_CORPSE 0x4000000 +#define U_CONT_DETAIL 0x8000000 /* brushes not used for the bsp */ +#define U_CONT_STRUCTURAL 0x10000000 /* brushes used for the bsp */ +#define U_CONT_TRANSLUCENT 0x20000000 /* don't consume surface fragments inside */ +#define U_CONT_TRIGGER 0x40000000 +#define U_CONT_NODROP 0x80000000 /* don't leave bodies or items (death fog, lava) */ + +#define U_SURF_NODAMAGE 0x1 /* never give falling damage */ +#define U_SURF_SLICK 0x2 /* effects game physics */ +#define U_SURF_SKY 0x4 /* lighting from environment map */ +#define U_SURF_LADDER 0x8 +#define U_SURF_NOIMPACT 0x10 /* don't make missile explosions */ +#define U_SURF_NOMARKS 0x20 /* don't leave missile marks */ +#define U_SURF_FLESH 0x40 /* make flesh sounds and effects */ +#define U_SURF_NODRAW 0x80 /* don't generate a drawsurface at all */ +#define U_SURF_HINT 0x100 /* make a primary bsp splitter */ +#define U_SURF_SKIP 0x200 /* completely ignore, allowing non-closed brushes */ +#define U_SURF_NOLIGHTMAP 0x400 /* surface doesn't need a lightmap */ +#define U_SURF_POINTLIGHT 0x800 /* generate lighting info at vertexes */ +#define U_SURF_METALSTEPS 0x1000 /* clanking footsteps */ +#define U_SURF_NOSTEPS 0x2000 /* no footstep sounds */ +#define U_SURF_NONSOLID 0x4000 /* don't collide against curves with this set */ +#define U_SURF_LIGHTFILTER 0x8000 /* act as a light filter during q3map -light */ +#define U_SURF_ALPHASHADOW 0x10000 /* do per-pixel light shadow casting in q3map */ +#define U_SURF_NODLIGHT 0x20000 /* don't dlight even if solid (solid lava, skies) */ +#define U_SURF_DUST 0x40000 /* leave a dust trail when walking on this surface */ + +/* ydnar flags */ +#define U_SURF_VERTEXLIT (U_SURF_POINTLIGHT | U_SURF_NOLIGHTMAP) + +/* materials */ +#define U_MAT_MASK 0xFFF00000 /* mask to get the material type */ + +#define U_MAT_NONE 0x00000000 +#define U_MAT_TIN 0x00100000 +#define U_MAT_ALUMINUM 0x00200000 +#define U_MAT_IRON 0x00300000 +#define U_MAT_TITANIUM 0x00400000 +#define U_MAT_STEEL 0x00500000 +#define U_MAT_BRASS 0x00600000 +#define U_MAT_COPPER 0x00700000 +#define U_MAT_CEMENT 0x00800000 +#define U_MAT_ROCK 0x00900000 +#define U_MAT_GRAVEL 0x00A00000 +#define U_MAT_PAVEMENT 0x00B00000 +#define U_MAT_BRICK 0x00C00000 +#define U_MAT_CLAY 0x00D00000 +#define U_MAT_GRASS 0x00E00000 +#define U_MAT_DIRT 0x00F00000 +#define U_MAT_MUD 0x01000000 +#define U_MAT_SNOW 0x01100000 +#define U_MAT_ICE 0x01200000 +#define U_MAT_SAND 0x01300000 +#define U_MAT_CERAMICTILE 0x01400000 +#define U_MAT_LINOLEUM 0x01500000 +#define U_MAT_RUG 0x01600000 +#define U_MAT_PLASTER 0x01700000 +#define U_MAT_PLASTIC 0x01800000 +#define U_MAT_CARDBOARD 0x01900000 +#define U_MAT_HARDWOOD 0x01A00000 +#define U_MAT_SOFTWOOD 0x01B00000 +#define U_MAT_PLANK 0x01C00000 +#define U_MAT_GLASS 0x01D00000 +#define U_MAT_WATER 0x01E00000 +#define U_MAT_STUCCO 0x01F00000 + + + +/* ------------------------------------------------------------------------------- + +game_t struct + +------------------------------------------------------------------------------- */ + +{ + "etut", /* -game x */ + "etut", /* default base game data dir */ + ".etwolf", /* unix home sub-dir */ + "et", /* magic path word */ + "scripts", /* shader directory */ + 1024, /* max lightmapped surface verts */ + 1024, /* max surface verts */ + 6144, /* max surface indexes */ + qfalse, /* flares */ + "flareshader", /* default flare shader */ + qfalse, /* wolf lighting model? */ + 128, /* lightmap width/height */ + 2.2f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ + "IBSP", /* bsp file prefix */ + 47, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ + LoadIBSPFile, /* bsp load function */ + WriteIBSPFile, /* bsp write function */ + + { + /* name contentFlags contentFlagsClear surfaceFlags surfaceFlagsClear compileFlags compileFlagsClear */ + + /* default */ + { "default", U_CONT_SOLID, -1, 0, -1, C_SOLID, -1 }, + + + /* ydnar */ + { "lightgrid", 0, 0, 0, 0, C_LIGHTGRID, 0 }, + { "antiportal", 0, 0, 0, 0, C_ANTIPORTAL, 0 }, + { "skip", 0, 0, 0, 0, C_SKIP, 0 }, + + + /* compiler */ + { "origin", U_CONT_ORIGIN, U_CONT_SOLID, 0, 0, C_ORIGIN | C_TRANSLUCENT, C_SOLID }, + { "areaportal", U_CONT_AREAPORTAL, U_CONT_SOLID, 0, 0, C_AREAPORTAL | C_TRANSLUCENT, C_SOLID }, + { "trans", U_CONT_TRANSLUCENT, 0, 0, 0, C_TRANSLUCENT, 0 }, + { "detail", U_CONT_DETAIL, 0, 0, 0, C_DETAIL, 0 }, + { "structural", U_CONT_STRUCTURAL, 0, 0, 0, C_STRUCTURAL, 0 }, + { "hint", 0, 0, U_SURF_HINT, 0, C_HINT, 0 }, + { "nodraw", 0, 0, U_SURF_NODRAW, 0, C_NODRAW, 0 }, + + { "alphashadow", 0, 0, U_SURF_ALPHASHADOW, 0, C_ALPHASHADOW | C_TRANSLUCENT, 0 }, + { "lightfilter", 0, 0, U_SURF_LIGHTFILTER, 0, C_LIGHTFILTER | C_TRANSLUCENT, 0 }, + { "nolightmap", 0, 0, U_SURF_VERTEXLIT, 0, C_VERTEXLIT, 0 }, + { "pointlight", 0, 0, U_SURF_VERTEXLIT, 0, C_VERTEXLIT, 0 }, + + + /* game */ + { "nonsolid", 0, U_CONT_SOLID, U_SURF_NONSOLID, 0, 0, C_SOLID }, + + { "trigger", U_CONT_TRIGGER, U_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + + { "water", U_CONT_WATER, U_CONT_SOLID, 0, 0, C_LIQUID | C_TRANSLUCENT, C_SOLID }, + { "slime", U_CONT_SLIME, U_CONT_SOLID, 0, 0, C_LIQUID | C_TRANSLUCENT, C_SOLID }, + { "lava", U_CONT_LAVA, U_CONT_SOLID, 0, 0, C_LIQUID | C_TRANSLUCENT, C_SOLID }, + + { "playerclip", U_CONT_PLAYERCLIP, U_CONT_SOLID, 0, 0, C_DETAIL | C_TRANSLUCENT, C_SOLID }, + { "monsterclip", U_CONT_MONSTERCLIP, U_CONT_SOLID, 0, 0, C_DETAIL | C_TRANSLUCENT, C_SOLID }, + { "nodrop", U_CONT_NODROP, U_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + + { "clusterportal", U_CONT_CLUSTERPORTAL, U_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + { "donotenter", U_CONT_DONOTENTER, U_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + { "botclip", U_CONT_BOTCLIP, U_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + + { "fog", U_CONT_FOG, U_CONT_SOLID, 0, 0, C_FOG, C_SOLID }, + { "sky", 0, 0, U_SURF_SKY, 0, C_SKY, 0 }, + + { "slick", 0, 0, U_SURF_SLICK, 0, 0, 0 }, + + { "noimpact", 0, 0, U_SURF_NOIMPACT, 0, 0, 0 }, + { "nomarks", 0, 0, U_SURF_NOMARKS, 0, C_NOMARKS, 0 }, + { "ladder", 0, 0, U_SURF_LADDER, 0, 0, 0 }, + { "nodamage", 0, 0, U_SURF_NODAMAGE, 0, 0, 0 }, + { "metalsteps", 0, 0, U_SURF_METALSTEPS, 0, 0, 0 }, + { "flesh", 0, 0, U_SURF_FLESH, 0, 0, 0 }, + { "nosteps", 0, 0, U_SURF_NOSTEPS, 0, 0, 0 }, + { "nodlight", 0, 0, U_SURF_NODLIGHT, 0, 0, 0 }, + { "dust", 0, 0, U_SURF_DUST, 0, 0, 0 }, + + + /* materials */ + { "*mat_none", 0, 0, U_MAT_NONE, U_MAT_MASK, 0, 0 }, + { "*mat_tin", 0, 0, U_MAT_TIN, U_MAT_MASK, 0, 0 }, + { "*mat_aluminum", 0, 0, U_MAT_ALUMINUM, U_MAT_MASK, 0, 0 }, + { "*mat_iron", 0, 0, U_MAT_IRON, U_MAT_MASK, 0, 0 }, + { "*mat_titanium", 0, 0, U_MAT_TITANIUM, U_MAT_MASK, 0, 0 }, + { "*mat_steel", 0, 0, U_MAT_STEEL, U_MAT_MASK, 0, 0 }, + { "*mat_brass", 0, 0, U_MAT_BRASS, U_MAT_MASK, 0, 0 }, + { "*mat_copper", 0, 0, U_MAT_COPPER, U_MAT_MASK, 0, 0 }, + { "*mat_cement", 0, 0, U_MAT_CEMENT, U_MAT_MASK, 0, 0 }, + { "*mat_rock", 0, 0, U_MAT_ROCK, U_MAT_MASK, 0, 0 }, + { "*mat_gravel", 0, 0, U_MAT_GRAVEL, U_MAT_MASK, 0, 0 }, + { "*mat_pavement", 0, 0, U_MAT_PAVEMENT, U_MAT_MASK, 0, 0 }, + { "*mat_brick", 0, 0, U_MAT_BRICK, U_MAT_MASK, 0, 0 }, + { "*mat_clay", 0, 0, U_MAT_CLAY, U_MAT_MASK, 0, 0 }, + { "*mat_grass", 0, 0, U_MAT_GRASS, U_MAT_MASK, 0, 0 }, + { "*mat_dirt", 0, 0, U_MAT_DIRT, U_MAT_MASK, 0, 0 }, + { "*mat_mud", 0, 0, U_MAT_MUD, U_MAT_MASK, 0, 0 }, + { "*mat_snow", 0, 0, U_MAT_SNOW, U_MAT_MASK, 0, 0 }, + { "*mat_ice", 0, 0, U_MAT_ICE, U_MAT_MASK, 0, 0 }, + { "*mat_sand", 0, 0, U_MAT_SAND, U_MAT_MASK, 0, 0 }, + { "*mat_ceramic", 0, 0, U_MAT_CERAMICTILE, U_MAT_MASK, 0, 0 }, + { "*mat_ceramictile", 0, 0, U_MAT_CERAMICTILE, U_MAT_MASK, 0, 0 }, + { "*mat_linoleum", 0, 0, U_MAT_LINOLEUM, U_MAT_MASK, 0, 0 }, + { "*mat_rug", 0, 0, U_MAT_RUG, U_MAT_MASK, 0, 0 }, + { "*mat_plaster", 0, 0, U_MAT_PLASTER, U_MAT_MASK, 0, 0 }, + { "*mat_plastic", 0, 0, U_MAT_PLASTIC, U_MAT_MASK, 0, 0 }, + { "*mat_cardboard", 0, 0, U_MAT_CARDBOARD, U_MAT_MASK, 0, 0 }, + { "*mat_hardwood", 0, 0, U_MAT_HARDWOOD, U_MAT_MASK, 0, 0 }, + { "*mat_softwood", 0, 0, U_MAT_SOFTWOOD, U_MAT_MASK, 0, 0 }, + { "*mat_plank", 0, 0, U_MAT_PLANK, U_MAT_MASK, 0, 0 }, + { "*mat_glass", 0, 0, U_MAT_GLASS, U_MAT_MASK, 0, 0 }, + { "*mat_water", 0, 0, U_MAT_WATER, U_MAT_MASK, 0, 0 }, + { "*mat_stucco", 0, 0, U_MAT_STUCCO, U_MAT_MASK, 0, 0 }, + + + /* null */ + { NULL, 0, 0, 0, 0, 0, 0 } + } +} + + + +/* end marker */ +#endif + diff --git a/tools/quake3/q3map2/game_ja.h b/tools/quake3/q3map2/game_ja.h index d7b39762..79007ed6 100644 --- a/tools/quake3/q3map2/game_ja.h +++ b/tools/quake3/q3map2/game_ja.h @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -58,11 +59,18 @@ game_t struct ".ja", /* unix home sub-dir */ "GameData", /* magic path word */ "shaders", /* shader directory */ - qfalse, /* wolf lighting model? */ + 64, /* max lightmapped surface verts */ + 999, /* max surface verts */ + 6000, /* max surface indexes */ qtrue, /* flares */ "gfx/misc/flare", /* default flare shader */ + qfalse, /* wolf lighting model? */ + 128, /* lightmap width/height */ + 1.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ "RBSP", /* bsp file prefix */ 1, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ LoadRBSPFile, /* bsp load function */ WriteRBSPFile, /* bsp write function */ diff --git a/tools/quake3/q3map2/game_jk2.h b/tools/quake3/q3map2/game_jk2.h index 086eaced..a8dc01a0 100644 --- a/tools/quake3/q3map2/game_jk2.h +++ b/tools/quake3/q3map2/game_jk2.h @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -55,11 +56,18 @@ game_t struct ".jk2", /* unix home sub-dir */ "GameData", /* magic path word */ "shaders", /* shader directory */ - qfalse, /* wolf lighting model? */ + 64, /* max lightmapped surface verts */ + 999, /* max surface verts */ + 6000, /* max surface indexes */ qtrue, /* flares */ "gfx/misc/flare", /* default flare shader */ + qfalse, /* wolf lighting model? */ + 128, /* lightmap width/height */ + 1.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ "RBSP", /* bsp file prefix */ 1, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ LoadRBSPFile, /* bsp load function */ WriteRBSPFile, /* bsp write function */ diff --git a/tools/quake3/q3map2/game_qfusion.h b/tools/quake3/q3map2/game_qfusion.h new file mode 100644 index 00000000..43c27fc5 --- /dev/null +++ b/tools/quake3/q3map2/game_qfusion.h @@ -0,0 +1,195 @@ +/* ------------------------------------------------------------------------------- + +This code is based on source provided under the terms of the Id Software +LIMITED USE SOFTWARE LICENSE AGREEMENT, a copy of which is included with the +GtkRadiant sources (see LICENSE_ID). If you did not receive a copy of +LICENSE_ID, please contact Id Software immediately at info@idsoftware.com. + +All changes and additions to the original source which have been developed by +other contributors (see CONTRIBUTORS) are provided under the terms of the +license the contributors choose (see LICENSE), to the extent permitted by the +LICENSE_ID. If you did not receive a copy of the contributor license, +please contact the GtkRadiant maintainers at info@gtkradiant.com immediately. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +---------------------------------------------------------------------------------- + +This code has been altered significantly from its original form, to support +several games based on the Quake III Arena engine, in the form of "Q3Map2." + +------------------------------------------------------------------------------- */ + + + +/* marker */ +#ifndef GAME_QFUSION_H +#define GAME_QFUSION_H + + + +/* ------------------------------------------------------------------------------- + +content and surface flags + +------------------------------------------------------------------------------- */ + +/* game flags */ +#define F_CONT_SOLID 1 /* an eye is never valid in a solid */ +#define F_CONT_LAVA 8 +#define F_CONT_SLIME 16 +#define F_CONT_WATER 32 +#define F_CONT_FOG 64 + +#define F_CONT_AREAPORTAL 0x8000 + +#define F_CONT_PLAYERCLIP 0x10000 +#define F_CONT_MONSTERCLIP 0x20000 +#define F_CONT_TELEPORTER 0x40000 +#define F_CONT_JUMPPAD 0x80000 +#define F_CONT_CLUSTERPORTAL 0x100000 +#define F_CONT_DONOTENTER 0x200000 +#define F_CONT_BOTCLIP 0x400000 + +#define F_CONT_ORIGIN 0x1000000 /* removed before bsping an entity */ + +#define F_CONT_BODY 0x2000000 /* should never be on a brush, only in game */ +#define F_CONT_CORPSE 0x4000000 +#define F_CONT_DETAIL 0x8000000 /* brushes not used for the bsp */ +#define F_CONT_STRUCTURAL 0x10000000 /* brushes used for the bsp */ +#define F_CONT_TRANSLUCENT 0x20000000 /* don't consume surface fragments inside */ +#define F_CONT_TRIGGER 0x40000000 +#define F_CONT_NODROP 0x80000000 /* don't leave bodies or items (death fog, lava) */ + +#define F_SURF_NODAMAGE 0x1 /* never give falling damage */ +#define F_SURF_SLICK 0x2 /* effects game physics */ +#define F_SURF_SKY 0x4 /* lighting from environment map */ +#define F_SURF_LADDER 0x8 +#define F_SURF_NOIMPACT 0x10 /* don't make missile explosions */ +#define F_SURF_NOMARKS 0x20 /* don't leave missile marks */ +#define F_SURF_FLESH 0x40 /* make flesh sounds and effects */ +#define F_SURF_NODRAW 0x80 /* don't generate a drawsurface at all */ +#define F_SURF_HINT 0x100 /* make a primary bsp splitter */ +#define F_SURF_SKIP 0x200 /* completely ignore, allowing non-closed brushes */ +#define F_SURF_NOLIGHTMAP 0x400 /* surface doesn't need a lightmap */ +#define F_SURF_POINTLIGHT 0x800 /* generate lighting info at vertexes */ +#define F_SURF_METALSTEPS 0x1000 /* clanking footsteps */ +#define F_SURF_NOSTEPS 0x2000 /* no footstep sounds */ +#define F_SURF_NONSOLID 0x4000 /* don't collide against curves with this set */ +#define F_SURF_LIGHTFILTER 0x8000 /* act as a light filter during q3map -light */ +#define F_SURF_ALPHASHADOW 0x10000 /* do per-pixel light shadow casting in q3map */ +#define F_SURF_NODLIGHT 0x20000 /* don't dlight even if solid (solid lava, skies) */ +#define F_SURF_DUST 0x40000 /* leave a dust trail when walking on this surface */ + +/* ydnar flags */ +#define F_SURF_VERTEXLIT (F_SURF_POINTLIGHT | F_SURF_NOLIGHTMAP) + + + +/* ------------------------------------------------------------------------------- + +game_t struct + +------------------------------------------------------------------------------- */ + +{ + "qfusion", /* -game x */ + "baseq3", /* default base game data dir */ + ".q3a", /* unix home sub-dir */ + "quake", /* magic path word */ + "scripts", /* shader directory */ + 2048, /* max lightmapped surface verts */ + 2048, /* max surface verts */ + 12288, /* max surface indexes */ + qtrue, /* flares */ + "flareshader", /* default flare shader */ + qfalse, /* wolf lighting model? */ + 512, /* lightmap width/height */ + 1.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ + "FBSP", /* bsp file prefix */ + 1, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ + LoadRBSPFile, /* bsp load function */ + WriteRBSPFile, /* bsp write function */ + + { + /* name contentFlags contentFlagsClear surfaceFlags surfaceFlagsClear compileFlags compileFlagsClear */ + + /* default */ + { "default", F_CONT_SOLID, -1, 0, -1, C_SOLID, -1 }, + + + /* ydnar */ + { "lightgrid", 0, 0, 0, 0, C_LIGHTGRID, 0 }, + { "antiportal", 0, 0, 0, 0, C_ANTIPORTAL, 0 }, + { "skip", 0, 0, 0, 0, C_SKIP, 0 }, + + + /* compiler */ + { "origin", F_CONT_ORIGIN, F_CONT_SOLID, 0, 0, C_ORIGIN | C_TRANSLUCENT, C_SOLID }, + { "areaportal", F_CONT_AREAPORTAL, F_CONT_SOLID, 0, 0, C_AREAPORTAL | C_TRANSLUCENT, C_SOLID }, + { "trans", F_CONT_TRANSLUCENT, 0, 0, 0, C_TRANSLUCENT, 0 }, + { "detail", F_CONT_DETAIL, 0, 0, 0, C_DETAIL, 0 }, + { "structural", F_CONT_STRUCTURAL, 0, 0, 0, C_STRUCTURAL, 0 }, + { "hint", 0, 0, F_SURF_HINT, 0, C_HINT, 0 }, + { "nodraw", 0, 0, F_SURF_NODRAW, 0, C_NODRAW, 0 }, + + { "alphashadow", 0, 0, F_SURF_ALPHASHADOW, 0, C_ALPHASHADOW | C_TRANSLUCENT, 0 }, + { "lightfilter", 0, 0, F_SURF_LIGHTFILTER, 0, C_LIGHTFILTER | C_TRANSLUCENT, 0 }, + { "nolightmap", 0, 0, F_SURF_VERTEXLIT, 0, C_VERTEXLIT, 0 }, + { "pointlight", 0, 0, F_SURF_VERTEXLIT, 0, C_VERTEXLIT, 0 }, + + + /* game */ + { "nonsolid", 0, F_CONT_SOLID, F_SURF_NONSOLID, 0, 0, C_SOLID }, + + { "trigger", F_CONT_TRIGGER, F_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + + { "water", F_CONT_WATER, F_CONT_SOLID, 0, 0, C_LIQUID | C_TRANSLUCENT, C_SOLID }, + { "slime", F_CONT_SLIME, F_CONT_SOLID, 0, 0, C_LIQUID | C_TRANSLUCENT, C_SOLID }, + { "lava", F_CONT_LAVA, F_CONT_SOLID, 0, 0, C_LIQUID | C_TRANSLUCENT, C_SOLID }, + + { "playerclip", F_CONT_PLAYERCLIP, F_CONT_SOLID, 0, 0, C_DETAIL | C_TRANSLUCENT, C_SOLID }, + { "monsterclip", F_CONT_MONSTERCLIP, F_CONT_SOLID, 0, 0, C_DETAIL | C_TRANSLUCENT, C_SOLID }, + { "nodrop", F_CONT_NODROP, F_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + + { "clusterportal", F_CONT_CLUSTERPORTAL, F_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + { "donotenter", F_CONT_DONOTENTER, F_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + { "botclip", F_CONT_BOTCLIP, F_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + + { "fog", F_CONT_FOG, F_CONT_SOLID, 0, 0, C_FOG, C_SOLID }, + { "sky", 0, 0, F_SURF_SKY, 0, C_SKY, 0 }, + + { "slick", 0, 0, F_SURF_SLICK, 0, 0, 0 }, + + { "noimpact", 0, 0, F_SURF_NOIMPACT, 0, 0, 0 }, + { "nomarks", 0, 0, F_SURF_NOMARKS, 0, C_NOMARKS, 0 }, + { "ladder", 0, 0, F_SURF_LADDER, 0, 0, 0 }, + { "nodamage", 0, 0, F_SURF_NODAMAGE, 0, 0, 0 }, + { "metalsteps", 0, 0, F_SURF_METALSTEPS, 0, 0, 0 }, + { "flesh", 0, 0, F_SURF_FLESH, 0, 0, 0 }, + { "nosteps", 0, 0, F_SURF_NOSTEPS, 0, 0, 0 }, + { "nodlight", 0, 0, F_SURF_NODLIGHT, 0, 0, 0 }, + { "dust", 0, 0, F_SURF_DUST, 0, 0, 0 }, + + + /* null */ + { NULL, 0, 0, 0, 0, 0, 0 } + } +} + + + +/* end marker */ +#endif + diff --git a/tools/quake3/q3map2/game_quake3.h b/tools/quake3/q3map2/game_quake3.h index 9b55787d..1aad043d 100644 --- a/tools/quake3/q3map2/game_quake3.h +++ b/tools/quake3/q3map2/game_quake3.h @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -103,11 +104,18 @@ game_t struct ".q3a", /* unix home sub-dir */ "quake", /* magic path word */ "scripts", /* shader directory */ - qfalse, /* wolf lighting model? */ + 64, /* max lightmapped surface verts */ + 999, /* max surface verts */ + 6000, /* max surface indexes */ qfalse, /* flares */ "flareshader", /* default flare shader */ + qfalse, /* wolf lighting model? */ + 128, /* lightmap width/height */ + 1.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ LoadIBSPFile, /* bsp load function */ WriteIBSPFile, /* bsp write function */ diff --git a/tools/quake3/q3map2/game_sof2.h b/tools/quake3/q3map2/game_sof2.h index 5d12d07d..c9760392 100644 --- a/tools/quake3/q3map2/game_sof2.h +++ b/tools/quake3/q3map2/game_sof2.h @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -130,11 +131,18 @@ game_t struct ".sof2", /* unix home sub-dir */ "soldier", /* magic path word */ "shaders", /* shader directory */ - qfalse, /* wolf lighting model? */ + 64, /* max lightmapped surface verts */ + 999, /* max surface verts */ + 6000, /* max surface indexes */ qtrue, /* flares */ "gfx/misc/lens_flare", /* default flare shader */ + qfalse, /* wolf lighting model? */ + 128, /* lightmap width/height */ + 1.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ "RBSP", /* bsp file prefix */ 1, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ LoadRBSPFile, /* bsp load function */ WriteRBSPFile, /* bsp write function */ diff --git a/tools/quake3/q3map2/game_tenebrae.h b/tools/quake3/q3map2/game_tenebrae.h index a639288f..355c9263 100644 --- a/tools/quake3/q3map2/game_tenebrae.h +++ b/tools/quake3/q3map2/game_tenebrae.h @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -103,11 +104,18 @@ game_t struct ".tenebrae", /* unix home sub-dir */ "tenebrae", /* magic path word */ "scripts", /* shader directory */ - qfalse, /* wolf lighting model? */ + 1024, /* max lightmapped surface verts */ + 1024, /* max surface verts */ + 6144, /* max surface indexes */ qfalse, /* flares */ "flareshader", /* default flare shader */ + qfalse, /* wolf lighting model? */ + 512, /* lightmap width/height */ + 2.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ "IBSP", /* bsp file prefix */ 46, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ LoadIBSPFile, /* bsp load function */ WriteIBSPFile, /* bsp write function */ diff --git a/tools/quake3/q3map2/game_tremulous.h b/tools/quake3/q3map2/game_tremulous.h new file mode 100644 index 00000000..9864cb9c --- /dev/null +++ b/tools/quake3/q3map2/game_tremulous.h @@ -0,0 +1,160 @@ +/* ------------------------------------------------------------------------------- + +Copyright (C) 1999-2007 id Software, Inc. and contributors. +For a list of contributors, see the accompanying CONTRIBUTORS file. + +This file is part of GtkRadiant. + +GtkRadiant is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +GtkRadiant is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with GtkRadiant; if not, write to the Free Software +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +---------------------------------------------------------------------------------- + +This code has been altered significantly from its original form, to support +several games based on the Quake III Arena engine, in the form of "Q3Map2." + +------------------------------------------------------------------------------- */ + +/* Tremulous support, by LinuxManMikeC */ + + +/* marker */ +#ifndef GAME_TREMULOUS_H +#define GAME_TREMULOUS_H + + + +/* ------------------------------------------------------------------------------- + +content and surface flags - also uses defines from game_quake3.h + +------------------------------------------------------------------------------- */ +#define TREM_CONT_NOALIENBUILD 0x1000 +#define TREM_CONT_NOHUMANBUILD 0x2000 +#define TREM_CONT_NOBUILD 0x4000 + +#define TREM_SURF_NOALIENBUILDSURFACE 0x80000 +#define TREM_SURF_NOHUMANBUILDSURFACE 0x100000 +#define TREM_SURF_NOBUILDSURFACE 0x200000 + + + +/* ------------------------------------------------------------------------------- + +game_t struct + +------------------------------------------------------------------------------- */ + +{ + "tremulous", /* -game x */ + "base", /* default base game data dir */ + ".tremulous", /* unix home sub-dir */ + "tremulous", /* magic path word - think this is right for trem*/ + "scripts", /* shader directory */ + 64, /* max lightmapped surface verts */ + 999, /* max surface verts */ + 6000, /* max surface indexes */ + qfalse, /* flares */ + "flareshader", /* default flare shader */ + qfalse, /* wolf lighting model? */ + 128, /* lightmap width/height */ + 1.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ + "IBSP", /* bsp file prefix */ + 46, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ + LoadIBSPFile, /* bsp load function */ + WriteIBSPFile, /* bsp write function */ + + { + /* name contentFlags contentFlagsClear surfaceFlags surfaceFlagsClear compileFlags compileFlagsClear */ + + /* default */ + { "default", Q_CONT_SOLID, -1, 0, -1, C_SOLID, -1 }, + + + /* ydnar */ + { "lightgrid", 0, 0, 0, 0, C_LIGHTGRID, 0 }, + { "antiportal", 0, 0, 0, 0, C_ANTIPORTAL, 0 }, + { "skip", 0, 0, 0, 0, C_SKIP, 0 }, + + + /* compiler */ + { "origin", Q_CONT_ORIGIN, Q_CONT_SOLID, 0, 0, C_ORIGIN | C_TRANSLUCENT, C_SOLID }, + { "areaportal", Q_CONT_AREAPORTAL, Q_CONT_SOLID, 0, 0, C_AREAPORTAL | C_TRANSLUCENT, C_SOLID }, + { "trans", Q_CONT_TRANSLUCENT, 0, 0, 0, C_TRANSLUCENT, 0 }, + { "detail", Q_CONT_DETAIL, 0, 0, 0, C_DETAIL, 0 }, + { "structural", Q_CONT_STRUCTURAL, 0, 0, 0, C_STRUCTURAL, 0 }, + { "hint", 0, 0, Q_SURF_HINT, 0, C_HINT, 0 }, + { "nodraw", 0, 0, Q_SURF_NODRAW, 0, C_NODRAW, 0 }, + + { "alphashadow", 0, 0, Q_SURF_ALPHASHADOW, 0, C_ALPHASHADOW | C_TRANSLUCENT, 0 }, + { "lightfilter", 0, 0, Q_SURF_LIGHTFILTER, 0, C_LIGHTFILTER | C_TRANSLUCENT, 0 }, + { "nolightmap", 0, 0, Q_SURF_VERTEXLIT, 0, C_VERTEXLIT, 0 }, + { "pointlight", 0, 0, Q_SURF_VERTEXLIT, 0, C_VERTEXLIT, 0 }, + + + /* game */ + { "nonsolid", 0, Q_CONT_SOLID, Q_SURF_NONSOLID, 0, 0, C_SOLID }, + + { "trigger", Q_CONT_TRIGGER, Q_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + + { "water", Q_CONT_WATER, Q_CONT_SOLID, 0, 0, C_LIQUID | C_TRANSLUCENT, C_SOLID }, + { "slime", Q_CONT_SLIME, Q_CONT_SOLID, 0, 0, C_LIQUID | C_TRANSLUCENT, C_SOLID }, + { "lava", Q_CONT_LAVA, Q_CONT_SOLID, 0, 0, C_LIQUID | C_TRANSLUCENT, C_SOLID }, + + { "playerclip", Q_CONT_PLAYERCLIP, Q_CONT_SOLID, 0, 0, C_DETAIL | C_TRANSLUCENT, C_SOLID }, + { "monsterclip", Q_CONT_MONSTERCLIP, Q_CONT_SOLID, 0, 0, C_DETAIL | C_TRANSLUCENT, C_SOLID }, + { "nodrop", Q_CONT_NODROP, Q_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + + { "clusterportal", Q_CONT_CLUSTERPORTAL, Q_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + { "donotenter", Q_CONT_DONOTENTER, Q_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + { "botclip", Q_CONT_BOTCLIP, Q_CONT_SOLID, 0, 0, C_TRANSLUCENT, C_SOLID }, + + { "fog", Q_CONT_FOG, Q_CONT_SOLID, 0, 0, C_FOG, C_SOLID }, + { "sky", 0, 0, Q_SURF_SKY, 0, C_SKY, 0 }, + + { "slick", 0, 0, Q_SURF_SLICK, 0, 0, 0 }, + + { "noimpact", 0, 0, Q_SURF_NOIMPACT, 0, 0, 0 }, + { "nomarks", 0, 0, Q_SURF_NOMARKS, 0, C_NOMARKS, 0 }, + { "ladder", 0, 0, Q_SURF_LADDER, 0, 0, 0 }, + { "nodamage", 0, 0, Q_SURF_NODAMAGE, 0, 0, 0 }, + { "metalsteps", 0, 0, Q_SURF_METALSTEPS, 0, 0, 0 }, + { "flesh", 0, 0, Q_SURF_FLESH, 0, 0, 0 }, + { "nosteps", 0, 0, Q_SURF_NOSTEPS, 0, 0, 0 }, + { "nodlight", 0, 0, Q_SURF_NODLIGHT, 0, 0, 0 }, + { "dust", 0, 0, Q_SURF_DUST, 0, 0, 0 }, + + + /* tremulous */ + {"noalienbuild", TREM_CONT_NOALIENBUILD,0,0,0,0,0}, + {"nohumanbuild", TREM_CONT_NOHUMANBUILD,0,0,0,0,0}, + {"nobuild", TREM_CONT_NOBUILD,0,0,0,0,0}, + + {"noalienbuildsurface", 0,0,TREM_SURF_NOALIENBUILDSURFACE,0,0,0}, + {"nohumanbuildsurface", 0,0,TREM_SURF_NOHUMANBUILDSURFACE,0,0,0}, + {"nobuildsurface", 0,0,TREM_SURF_NOBUILDSURFACE,0,0,0}, + + + /* null */ + { NULL, 0, 0, 0, 0, 0, 0 } + } +} + + + +/* end marker */ +#endif + diff --git a/tools/quake3/q3map2/game_wolf.h b/tools/quake3/q3map2/game_wolf.h index 0e882868..3200d162 100644 --- a/tools/quake3/q3map2/game_wolf.h +++ b/tools/quake3/q3map2/game_wolf.h @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -120,11 +121,18 @@ game_t struct ".wolf", /* unix home sub-dir */ "wolf", /* magic path word */ "scripts", /* shader directory */ - qtrue, /* wolf lighting model? */ + 64, /* max lightmapped surface verts */ + 999, /* max surface verts */ + 6000, /* max surface indexes */ qfalse, /* flares */ "flareshader", /* default flare shader */ + qtrue, /* wolf lighting model? */ + 128, /* lightmap width/height */ + 1.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ "IBSP", /* bsp file prefix */ 47, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ LoadIBSPFile, /* bsp load function */ WriteIBSPFile, /* bsp write function */ diff --git a/tools/quake3/q3map2/game_wolfet.h b/tools/quake3/q3map2/game_wolfet.h index fdc5b7e8..a6ca181f 100644 --- a/tools/quake3/q3map2/game_wolfet.h +++ b/tools/quake3/q3map2/game_wolfet.h @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -57,11 +58,18 @@ game_t struct ".etwolf", /* unix home sub-dir */ "et", /* magic path word */ "scripts", /* shader directory */ - qtrue, /* wolf lighting model? */ + 1024, /* max lightmapped surface verts */ + 1024, /* max surface verts */ + 6144, /* max surface indexes */ qfalse, /* flares */ "flareshader", /* default flare shader */ + qtrue, /* wolf lighting model? */ + 128, /* lightmap width/height */ + 1.0f, /* lightmap gamma */ + 1.0f, /* lightmap compensate */ "IBSP", /* bsp file prefix */ 47, /* bsp file version */ + qfalse, /* cod-style lump len/ofs order */ LoadIBSPFile, /* bsp load function */ WriteIBSPFile, /* bsp write function */ diff --git a/tools/quake3/q3map2/image.c b/tools/quake3/q3map2/image.c index fec9f6f5..0ddcaf86 100644 --- a/tools/quake3/q3map2/image.c +++ b/tools/quake3/q3map2/image.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -390,7 +391,7 @@ image_t *ImageLoad( const char *filename ) strcat( name, ".tga" ); size = vfsLoadFile( (const char*) name, (void**) &buffer, 0 ); if( size > 0 ) - LoadTGABuffer( buffer, &image->pixels, &image->width, &image->height ); + LoadTGABuffer( buffer, buffer + size, &image->pixels, &image->width, &image->height ); else { /* attempt to load png */ diff --git a/tools/quake3/q3map2/leakfile.c b/tools/quake3/q3map2/leakfile.c index 1d72604b..51fda300 100644 --- a/tools/quake3/q3map2/leakfile.c +++ b/tools/quake3/q3map2/leakfile.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake3/q3map2/light.c b/tools/quake3/q3map2/light.c index 670c9a0e..25d40a9a 100644 --- a/tools/quake3/q3map2/light.c +++ b/tools/quake3/q3map2/light.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -115,6 +116,7 @@ static void CreateSunLight( sun_t *sun ) light->fade = 1.0f; light->falloffTolerance = falloffTolerance; light->filterRadius = sun->filterRadius / sun->numSamples; + light->style = noStyles ? LS_NORMAL : sun->style; /* set the light's position out to infinity */ VectorMA( vec3_origin, (MAX_WORLD_COORD * 8.0f), direction, light->origin ); /* MAX_WORLD_COORD * 2.0f */ @@ -140,11 +142,13 @@ CreateSkyLights() - ydnar simulates sky light with multiple suns */ -static void CreateSkyLights( vec3_t color, float value, int iterations, float filterRadius ) +static void CreateSkyLights( vec3_t color, float value, int iterations, float filterRadius, int style ) { - int c, i, j, k, numSuns; + int i, j, numSuns; + int angleSteps, elevationSteps; + float angle, elevation; + float angleStep, elevationStep; float step, start; - vec3_t in; sun_t sun; @@ -161,36 +165,49 @@ static void CreateSkyLights( vec3_t color, float value, int iterations, float fi sun.deviance = 0.0f; sun.filterRadius = filterRadius; sun.numSamples = 1; + sun.style = noStyles ? LS_NORMAL : style; sun.next = NULL; - /* iterate */ - numSuns = 0; - for( c = 0; c < 2; c++ ) + /* setup */ + elevationSteps = iterations - 1; + angleSteps = elevationSteps * 4; + angle = 0.0f; + elevationStep = DEG2RAD( 90.0f / iterations ); /* skip elevation 0 */ + angleStep = DEG2RAD( 360.0f / angleSteps ); + + /* calc individual sun brightness */ + numSuns = angleSteps * elevationSteps + 1; + sun.photons = value / numSuns; + + /* iterate elevation */ + elevation = elevationStep * 0.5f; + angle = 0.0f; + for( i = 0, elevation = elevationStep * 0.5f; i < elevationSteps; i++ ) { - for( k = 0, in[ 2 ] = start; k < iterations; k++, in[ 2 ] += step ) - { - /* don't create sky light below the horizon */ - if( in[ 2 ] <= 0.0f ) - continue; + /* iterate angle */ + for( j = 0; j < angleSteps; j++ ) + { + /* create sun */ + sun.direction[ 0 ] = cos( angle ) * cos( elevation ); + sun.direction[ 1 ] = sin( angle ) * cos( elevation ); + sun.direction[ 2 ] = sin( elevation ); + CreateSunLight( &sun ); - for( j = 0, in[ 1 ] = start; j < iterations; j++, in[ 1 ] += step ) - { - for( i = 0, in[ 0 ] = start; i < iterations; i++, in[ 0 ] += step ) - { - if( VectorNormalize( in, sun.direction ) ) - { - if( c > 0 && numSuns > 0 ) - { - sun.photons = value / numSuns; - CreateSunLight( &sun ); - } - else - numSuns++; - } - } - } + /* move */ + angle += angleStep; } + + /* move */ + elevation += elevationStep; + angle += angleStep / elevationSteps; } + + /* create vertical sun */ + VectorSet( sun.direction, 0.0f, 0.0f, 1.0f ); + CreateSunLight( &sun ); + + /* short circuit */ + return; } @@ -245,7 +262,7 @@ void CreateEntityLights( void ) spawnflags = IntForKey( e, "spawnflags" ); /* ydnar: quake 3+ light behavior */ - if( game->wolfLight == qfalse ) + if( wolfLight == qfalse ) { /* set default flags */ flags = LIGHT_Q3A_DEFAULT; @@ -317,11 +334,15 @@ void CreateEntityLights( void ) /* set origin */ GetVectorForKey( e, "origin", light->origin); light->style = IntForKey( e, "_style" ); - if( light->style == 0 ) + if( light->style == LS_NORMAL ) light->style = IntForKey( e, "style" ); if( light->style < LS_NORMAL || light->style >= LS_NONE ) Error( "Invalid lightstyle (%d) on entity %d", light->style, i ); + /* override */ + if( noStyles ) + light->style = LS_NORMAL; + /* set light intensity */ intensity = FloatForKey( e, "_light" ); if( intensity == 0.0f ) @@ -433,6 +454,7 @@ void CreateEntityLights( void ) sun.photons = (intensity / pointScale); sun.deviance = deviance / 180.0f * Q_PI; sun.numSamples = numSamples; + sun.style = noStyles ? LS_NORMAL : light->style; sun.next = NULL; /* make a sun light */ @@ -516,7 +538,7 @@ void CreateSurfaceLights( void ) if( si->skyLightValue > 0.0f ) { Sys_FPrintf( SYS_VRB, "Sky: %s\n", si->shader ); - CreateSkyLights( si->color, si->skyLightValue, si->skyLightIterations, si->lightFilterRadius ); + CreateSkyLights( si->color, si->skyLightValue, si->skyLightIterations, si->lightFilterRadius, si->lightStyle ); si->skyLightValue = 0.0f; /* FIXME: hack! */ } @@ -546,7 +568,7 @@ void CreateSurfaceLights( void ) VectorCopy( origin, light->origin ); VectorCopy( si->color, light->color ); light->falloffTolerance = falloffTolerance; - light->style = light->style; + light->style = si->lightStyle; /* add to point light count and continue */ numPointLights++; @@ -737,35 +759,8 @@ int LightContributionToSample( trace_t *trace ) return 0; } - /* ptpff approximation */ - if( light->type == EMIT_AREA && faster ) - { - /* get direction and distance */ - VectorCopy( light->origin, trace->end ); - dist = SetupTrace( trace ); - if( dist >= light->envelope ) - return 0; - - /* clamp the distance to prevent super hot spots */ - if( dist < 16.0f ) - dist = 16.0f; - - /* angle attenuation */ - angle = DotProduct( trace->normal, trace->direction ); - - /* twosided lighting */ - if( trace->twoSided ) - angle = fabs( angle ); - - /* attenuate */ - angle *= -DotProduct( light->normal, trace->direction ); - if( angle <= 0.0f ) - return 0; - add = light->photons / (dist * dist) * angle; - } - /* exact point to polygon form factor */ - else if( light->type == EMIT_AREA ) + if( light->type == EMIT_AREA ) { float factor; float d; @@ -774,8 +769,6 @@ int LightContributionToSample( trace_t *trace ) /* project sample point into light plane */ d = DotProduct( trace->origin, light->normal ) - light->dist; - //% if( !(light->flags & LIGHT_TWOSIDED) && d < -1.0f ) - //% return 0; if( d < 3.0f ) { /* sample point behind plane? */ @@ -800,29 +793,51 @@ int LightContributionToSample( trace_t *trace ) if( dist >= light->envelope ) return 0; - /* calculate the contribution */ - factor = PointToPolygonFormFactor( pushedOrigin, trace->normal, light->w ); - if( factor == 0.0f ) - return 0; - else if( factor < 0.0f ) + /* ptpff approximation */ + if( faster ) { + /* angle attenuation */ + angle = DotProduct( trace->normal, trace->direction ); + /* twosided lighting */ - if( trace->twoSided || (light->flags & LIGHT_TWOSIDED) ) + if( trace->twoSided ) + angle = fabs( angle ); + + /* attenuate */ + angle *= -DotProduct( light->normal, trace->direction ); + if( angle == 0.0f ) + return 0; + else if( angle < 0.0f && + (trace->twoSided || (light->flags & LIGHT_TWOSIDED)) ) + angle = -angle; + add = light->photons / (dist * dist) * angle; + } + else + { + /* calculate the contribution */ + factor = PointToPolygonFormFactor( pushedOrigin, trace->normal, light->w ); + if( factor == 0.0f ) + return 0; + else if( factor < 0.0f ) { - factor = -factor; + /* twosided lighting */ + if( trace->twoSided || (light->flags & LIGHT_TWOSIDED) ) + { + factor = -factor; - /* push light origin to other side of the plane */ - VectorMA( light->origin, -2.0f, light->normal, trace->end ); - dist = SetupTrace( trace ); - if( dist >= light->envelope ) + /* push light origin to other side of the plane */ + VectorMA( light->origin, -2.0f, light->normal, trace->end ); + dist = SetupTrace( trace ); + if( dist >= light->envelope ) + return 0; + } + else return 0; } - else - return 0; + + /* ydnar: moved to here */ + add = factor * light->add; } - - /* ydnar: moved to here */ - add = factor * light->add; } /* point/spot lights */ @@ -1436,7 +1451,8 @@ void TraceGrid( int num ) #endif /* store direction */ - NormalToLatLong( gp->dir, bgp->latLong ); + if( !bouncing ) + NormalToLatLong( gp->dir, bgp->latLong ); } @@ -1633,6 +1649,18 @@ void LightWorld( void ) Sys_Printf( "%9d luxels\n", numLuxels ); Sys_Printf( "%9d luxels mapped\n", numLuxelsMapped ); Sys_Printf( "%9d luxels occluded\n", numLuxelsOccluded ); + + /* dirty them up */ + if( dirty ) + { + Sys_Printf( "--- DirtyRawLightmap ---\n" ); + + + + + RunThreadsOnIndividual( numRawLightmaps, qtrue, DirtyRawLightmap ); + } + /* ydnar: set up light envelopes */ SetupEnvelopes( qfalse, fast ); @@ -1747,6 +1775,12 @@ int LightMain( int argc, char **argv ) /* note it */ Sys_Printf( "--- Light ---\n" ); + /* set standard game flags */ + wolfLight = game->wolfLight; + lmCustomSize = game->lightmapSize; + lightmapGamma = game->lightmapGamma; + lightmapCompensate = game->lightmapCompensate; + /* process commandline arguments */ for( i = 1; i < (argc - 1); i++ ) { @@ -1794,6 +1828,24 @@ int LightMain( int argc, char **argv ) i++; } + else if( !strcmp( argv[ i ], "-gamma" ) ) + { + f = atof( argv[ i + 1 ] ); + lightmapGamma = f; + Sys_Printf( "Lighting gamma set to %f\n", lightmapGamma ); + i++; + } + + else if( !strcmp( argv[ i ], "-compensate" ) ) + { + f = atof( argv[ i + 1 ] ); + if( f <= 0.0f ) + f = 1.0f; + lightmapCompensate = f; + Sys_Printf( "Lighting compensation set to 1/%f\n", lightmapCompensate ); + i++; + } + /* ydnar switches */ else if( !strcmp( argv[ i ], "-bounce" ) ) { @@ -1831,6 +1883,18 @@ int LightMain( int argc, char **argv ) Sys_Printf( "Lightmap filtering enabled\n" ); } + else if( !strcmp( argv[ i ], "-dark" ) ) + { + dark = qtrue; + Sys_Printf( "Dark lightmap seams enabled\n" ); + } + + + + + + + else if( !strcmp( argv[ i ], "-shadeangle" ) ) { shadeAngleDegrees = atof( argv[ i + 1 ] ); @@ -1884,13 +1948,13 @@ int LightMain( int argc, char **argv ) if( ((lmCustomSize - 1) & lmCustomSize) || lmCustomSize < 2 ) { Sys_Printf( "WARNING: Lightmap size must be a power of 2, greater or equal to 2 pixels.\n" ); - lmCustomSize = LIGHTMAP_WIDTH; + lmCustomSize = game->lightmapSize; } i++; Sys_Printf( "Default lightmap size set to %d x %d pixels\n", lmCustomSize, lmCustomSize ); /* enable external lightmaps */ - if( lmCustomSize != LIGHTMAP_WIDTH ) + if( lmCustomSize != game->lightmapSize ) { externalLightmaps = qtrue; Sys_Printf( "Storing all lightmaps externally\n" ); @@ -1907,8 +1971,15 @@ int LightMain( int argc, char **argv ) else if( !strcmp( argv[ i ], "-wolf" ) ) { /* -game should already be set */ - game->wolfLight = qtrue; - Sys_Printf( "Enabling Wolf lighting model\n" ); + wolfLight = qtrue; + Sys_Printf( "Enabling Wolf lighting model (linear default)\n" ); + } + + else if( !strcmp( argv[ i ], "-q3" ) ) + { + /* -game should already be set */ + wolfLight = qfalse; + Sys_Printf( "Enabling Quake 3 lighting model (nonlinear default)\n" ); } else if( !strcmp( argv[ i ], "-sunonly" ) ) @@ -1944,7 +2015,6 @@ int LightMain( int argc, char **argv ) else if( !strcmp( argv[ i ], "-smooth" ) ) { - smooth = qtrue; lightSamples = EXTRA_SCALE; Sys_Printf( "The -smooth argument is deprecated, use \"-samples 2\" instead\n" ); } @@ -2064,14 +2134,11 @@ int LightMain( int argc, char **argv ) } else if( !strcmp( argv[ i ], "-extra" ) ) { - extra = qtrue; superSample = EXTRA_SCALE; /* ydnar */ Sys_Printf( "The -extra argument is deprecated, use \"-super 2\" instead\n" ); } else if( !strcmp( argv[ i ], "-extrawide" ) ) { - extra = qtrue; - extraWide = qtrue; superSample = EXTRAWIDE_SCALE; /* ydnar */ filter = qtrue; /* ydnar */ Sys_Printf( "The -extrawide argument is deprecated, use \"-filter [-super 2]\" instead\n"); @@ -2114,9 +2181,64 @@ int LightMain( int argc, char **argv ) loMem = qtrue; Sys_Printf( "Enabling low-memory (potentially slower) lighting mode\n" ); } + else if( !strcmp( argv[ i ], "-nostyle" ) || !strcmp( argv[ i ], "-nostyles" ) ) + { + noStyles = qtrue; + Sys_Printf( "Disabling lightstyles\n" ); + } + else if( !strcmp( argv[ i ], "-cpma" ) ) + { + cpmaHack = qtrue; + Sys_Printf( "Enabling Challenge Pro Mode Asstacular Vertex Lighting Mode (tm)\n" ); + } + /* r7: dirtmapping */ + else if( !strcmp( argv[ i ], "-dirty" ) ) + { + dirty = qtrue; + Sys_Printf( "Dirtmapping enabled\n" ); + } + else if( !strcmp( argv[ i ], "-dirtdebug" ) || !strcmp( argv[ i ], "-debugdirt" ) ) + { + dirtDebug = qtrue; + Sys_Printf( "Dirtmap debugging enabled\n" ); + } + else if( !strcmp( argv[ i ], "-dirtmode" ) ) + { + dirtMode = atoi( argv[ i + 1 ] ); + if( dirtMode != 0 && dirtMode != 1 ) + dirtMode = 0; + if( dirtMode == 1 ) + Sys_Printf( "Enabling randomized dirtmapping\n" ); + else + Sys_Printf( "Enabling ordered dir mapping\n" ); + } + else if( !strcmp( argv[ i ], "-dirtdepth" ) ) + { + dirtDepth = atof( argv[ i + 1 ] ); + if( dirtDepth <= 0.0f ) + dirtDepth = 128.0f; + Sys_Printf( "Dirtmapping depth set to %.1f\n", dirtDepth ); + } + else if( !strcmp( argv[ i ], "-dirtscale" ) ) + { + dirtScale = atof( argv[ i + 1 ] ); + if( dirtScale <= 0.0f ) + dirtScale = 1.0f; + Sys_Printf( "Dirtmapping scale set to %.1f\n", dirtScale ); + } + else if( !strcmp( argv[ i ], "-dirtgain" ) ) + { + dirtGain = atof( argv[ i + 1 ] ); + if( dirtGain <= 0.0f ) + dirtGain = 1.0f; + Sys_Printf( "Dirtmapping gain set to %.1f\n", dirtGain ); + } + + /* unhandled args */ else - Sys_Printf( "WARNING: Unknown option \"%s\"\n", argv[ i ] ); + Sys_Printf( "WARNING: Unknown argument \"%s\"\n", argv[ i ] ); + } /* clean up map name */ @@ -2156,6 +2278,7 @@ int LightMain( int argc, char **argv ) /* ydnar: set up optimization */ SetupBrushes(); + SetupDirt(); SetupSurfaceLightmaps(); /* initialize the surface facet tracing */ diff --git a/tools/quake3/q3map2/light_bounce.c b/tools/quake3/q3map2/light_bounce.c index 4181ce53..dba5b131 100644 --- a/tools/quake3/q3map2/light_bounce.c +++ b/tools/quake3/q3map2/light_bounce.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -509,7 +510,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw break; case MST_TRIANGLE_SOUP: - numTriangleDiffuseLights; + numTriangleDiffuseLights++; break; case MST_PATCH: @@ -546,9 +547,9 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw light->add = value * formFactorValueScale * areaScale; VectorCopy( si->color, light->color ); VectorScale( light->color, light->add, light->emitColor ); - light->style = si->lightStyle; - if( light->style < 0 || light->style >= LS_NONE ) - light->style = 0; + light->style = noStyles ? LS_NORMAL : si->lightStyle; + if( light->style < LS_NORMAL || light->style >= LS_NONE ) + light->style = LS_NORMAL; /* set origin */ VectorAdd( mins, maxs, light->origin ); @@ -577,7 +578,7 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw VectorMA( light->origin, si->backsplashDistance, normal, splash->origin ); VectorCopy( si->color, splash->color ); splash->falloffTolerance = falloffTolerance; - splash->style = light->style; + splash->style = noStyles ? LS_NORMAL : light->style; /* add to counts */ numPointLights++; @@ -591,9 +592,9 @@ static void RadSubdivideDiffuseLight( int lightmapNum, bspDrawSurface_t *ds, raw light->add = value * formFactorValueScale * bounceScale; VectorCopy( color, light->color ); VectorScale( light->color, light->add, light->emitColor ); - light->style = style; - if( light->style < 0 || light->style >= LS_NONE ) - light->style = 0; + light->style = noStyles ? LS_NORMAL : style; + if( light->style < LS_NORMAL || light->style >= LS_NONE ) + light->style = LS_NORMAL; /* set origin */ WindingCenter( w, light->origin ); @@ -952,3 +953,4 @@ void RadCreateDiffuseLights( void ) + diff --git a/tools/quake3/q3map2/light_trace.c b/tools/quake3/q3map2/light_trace.c index 287b22dd..2a4e7e46 100644 --- a/tools/quake3/q3map2/light_trace.c +++ b/tools/quake3/q3map2/light_trace.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -72,7 +73,7 @@ traceVert_t; typedef struct traceInfo_s { shaderInfo_t *si; - int surfaceNum, castShadows, padding; + int surfaceNum, castShadows; } traceInfo_t; @@ -87,7 +88,7 @@ traceWinding_t; typedef struct traceTriangle_s { vec3_t edge1, edge2; - int infoNum, padding; + int infoNum; traceVert_t v[ 3 ]; } traceTriangle_t; @@ -326,6 +327,8 @@ static int AddItemToTraceNode( traceNode_t *node, int num ) node->maxItems *= 2; else node->maxItems += GROW_NODE_ITEMS; + if( node->maxItems <= 0 ) + node->maxItems = GROW_NODE_ITEMS; temp = safe_malloc( node->maxItems * sizeof( *node->items ) ); if( node->items != NULL ) { @@ -384,16 +387,6 @@ static int SetupTraceNodes_r( int bspNodeNum ) { bspLeafNum = -bspNode->children[ i ] - 1; - #if 0 - /* solid leaf */ - if( bspLeafs[ bspLeafNum ].cluster == -1 ) - traceNodes[ nodeNum ].children[ i ] = -1; - - /* passable leaf */ - else - traceNodes[ nodeNum ].children[ i ] = AllocTraceNode(); - #endif - /* new code */ traceNodes[ nodeNum ].children[ i ] = AllocTraceNode(); if( bspLeafs[ bspLeafNum ].cluster == -1 ) @@ -968,17 +961,23 @@ static void PopulateWithBSPModel( bspModel_t *model, m4x4_t transform ) ti.castShadows = info->castShadows; ti.surfaceNum = model->firstBSPBrush + i; - /* setup trace winding */ - memset( &tw, 0, sizeof( tw ) ); - tw.infoNum = AddTraceInfo( &ti ); - tw.numVerts = 3; - /* choose which node (normal or skybox) */ if( info->parentSurfaceNum >= 0 ) + { nodeNum = skyboxNodeNum; + + /* sky surfaces in portal skies are ignored */ + if( info->si->compileFlags & C_SKY ) + continue; + } else nodeNum = headNodeNum; + /* setup trace winding */ + memset( &tw, 0, sizeof( tw ) ); + tw.infoNum = AddTraceInfo( &ti ); + tw.numVerts = 3; + /* switch on type */ switch( ds->surfaceType ) { @@ -1436,7 +1435,7 @@ qboolean TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace ) det = DotProduct( tt->edge1, pvec ); /* the non-culling branch */ - if( det > -COPLANAR_EPSILON && det < COPLANAR_EPSILON ) + if( fabs( det ) < COPLANAR_EPSILON ) return qfalse; invDet = 1.0f / det; @@ -1458,8 +1457,6 @@ qboolean TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace ) /* calculate t (depth) */ depth = DotProduct( tt->edge2, qvec ) * invDet; - //% if( depth <= SELF_SHADOW_EPSILON || depth >= (trace->dist - SELF_SHADOW_EPSILON) ) - //% return qfalse; if( depth <= trace->inhibitRadius || depth >= trace->distance ) return qfalse; @@ -1485,6 +1482,7 @@ qboolean TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace ) if( !(si->compileFlags & (C_ALPHASHADOW | C_LIGHTFILTER)) || si->lightImage == NULL || si->lightImage->pixels == NULL ) { + VectorMA( trace->origin, depth, trace->direction, trace->hit ); VectorClear( trace->color ); trace->opaque = qtrue; return qtrue; @@ -1531,6 +1529,7 @@ qboolean TraceTriangle( traceInfo_t *ti, traceTriangle_t *tt, trace_t *trace ) /* check filter for opaque */ if( trace->color[ 0 ] <= 0.001f && trace->color[ 1 ] <= 0.001f && trace->color[ 2 ] <= 0.001f ) { + VectorMA( trace->origin, depth, trace->direction, trace->hit ); trace->opaque = qtrue; return qtrue; } @@ -1596,6 +1595,7 @@ static qboolean TraceLine_r( int nodeNum, vec3_t origin, vec3_t end, trace_t *tr /* bogus node number means solid, end tracing unless testing all */ if( nodeNum < 0 ) { + VectorCopy( origin, trace->hit ); trace->passSolid = qtrue; return qtrue; } @@ -1606,6 +1606,7 @@ static qboolean TraceLine_r( int nodeNum, vec3_t origin, vec3_t end, trace_t *tr /* solid? */ if( node->type == TRACE_LEAF_SOLID ) { + VectorCopy( origin, trace->hit ); trace->passSolid = qtrue; return qtrue; } @@ -1666,6 +1667,9 @@ static qboolean TraceLine_r( int nodeNum, vec3_t origin, vec3_t end, trace_t *tr /* fixme: check inhibit radius, then solid nodes and ignore */ + /* set trace hit here */ + //% VectorCopy( mid, trace->hit ); + /* trace first side */ r = TraceLine_r( node->children[ side ], origin, mid, trace ); if( r ) @@ -1702,7 +1706,7 @@ void TraceLine( trace_t *trace ) /* trace through nodes */ TraceLine_r( headNodeNum, trace->origin, trace->end, trace ); - if( (trace->passSolid && !trace->testAll) ) + if( trace->passSolid && !trace->testAll ) { trace->opaque = qtrue; return; @@ -1714,6 +1718,7 @@ void TraceLine( trace_t *trace ) /* testall means trace through sky */ if( trace->testAll && trace->numTestNodes < MAX_TRACE_TEST_NODES && + trace->compileFlags & C_SKY && (trace->numSurfaces == 0 || surfaceInfos[ trace->surfaces[ 0 ] ].childSurfaceNum < 0) ) { //% trace->testNodes[ trace->numTestNodes++ ] = skyboxNodeNum; @@ -1750,5 +1755,6 @@ float SetupTrace( trace_t *trace ) { VectorSubtract( trace->end, trace->origin, trace->displacement ); trace->distance = VectorNormalize( trace->displacement, trace->direction ); + VectorCopy( trace->origin, trace->hit ); return trace->distance; } diff --git a/tools/quake3/q3map2/light_ydnar.c b/tools/quake3/q3map2/light_ydnar.c index 6a292156..44d60d8a 100644 --- a/tools/quake3/q3map2/light_ydnar.c +++ b/tools/quake3/q3map2/light_ydnar.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -45,7 +46,8 @@ ydnar: moved to here 2001-02-04 void ColorToBytes( const float *color, byte *colorBytes, float scale ) { - float max; + int i; + float max, gamma; vec3_t sample; @@ -56,13 +58,20 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ) /* make a local copy */ VectorScale( color, scale, sample ); - /* handle negative light */ - if( sample[ 0 ] < 0.0f ) - sample[ 0 ] = 0.0f; - if( sample[ 1 ] < 0.0f ) - sample[ 1 ] = 0.0f; - if( sample[ 2 ] < 0.0f ) - sample[ 2 ] = 0.0f; + /* muck with it */ + gamma = 1.0f / lightmapGamma; + for( i = 0; i < 3; i++ ) + { + /* handle negative light */ + if( sample[ i ] < 0.0f ) + { + sample[ i ] = 0.0f; + continue; + } + + /* gamma */ + sample[ i ] = pow( sample[ i ] / 255.0f, gamma ) * 255.0f; + } /* clamp with color normalization */ max = sample[ 0 ]; @@ -73,6 +82,9 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ) if( max > 255.0f ) VectorScale( sample, (255.0f / max), sample ); + /* compensate for ingame overbrighting/bitshifting */ + VectorScale( sample, (1.0f / lightmapCompensate), sample ); + /* store it off */ colorBytes[ 0 ] = sample[ 0 ]; colorBytes[ 1 ] = sample[ 1 ]; @@ -510,8 +522,8 @@ static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t /* another retarded hack, storing nudge count in luxel[ 1 ] */ luxel[ 1 ] = 0.0f; - /* point in solid? */ - if( pointCluster < 0 ) + /* point in solid? (except in dark mode) */ + if( pointCluster < 0 && dark == qfalse ) { /* nudge the the location around */ nudge = nudges[ 0 ]; @@ -533,8 +545,8 @@ static int MapSingleLuxel( rawLightmap_t *lm, surfaceInfo_t *info, bspDrawVert_t } } - /* as a last resort, if still in solid, try drawvert origin offset by normal */ - if( pointCluster < 0 && si != NULL ) + /* as a last resort, if still in solid, try drawvert origin offset by normal (except in dark mode) */ + if( pointCluster < 0 && si != NULL && dark == qfalse ) { VectorMA( dv->xyz, lightmapSampleOffset, dv->normal, nudged ); pointCluster = ClusterForPointExtFilter( nudged, LUXEL_EPSILON, numClusters, clusters ); @@ -1244,6 +1256,310 @@ void MapRawLightmap( int rawLightmapNum ) +/* +SetupDirt() +sets up dirtmap (ambient occlusion) +*/ + +#define DIRT_CONE_ANGLE 88 /* degrees */ +#define DIRT_NUM_ANGLE_STEPS 16 +#define DIRT_NUM_ELEVATION_STEPS 3 +#define DIRT_NUM_VECTORS (DIRT_NUM_ANGLE_STEPS * DIRT_NUM_ELEVATION_STEPS) + +static vec3_t dirtVectors[ DIRT_NUM_VECTORS ]; +static int numDirtVectors = 0; + +void SetupDirt( void ) +{ + int i, j; + float angle, elevation, angleStep, elevationStep; + + + /* note it */ + Sys_FPrintf( SYS_VRB, "--- SetupDirt ---\n" ); + + /* calculate angular steps */ + angleStep = DEG2RAD( 360.0f / DIRT_NUM_ANGLE_STEPS ); + elevationStep = DEG2RAD( DIRT_CONE_ANGLE / DIRT_NUM_ELEVATION_STEPS ); + + /* iterate angle */ + angle = 0.0f; + for( i = 0, angle = 0.0f; i < DIRT_NUM_ANGLE_STEPS; i++, angle += angleStep ) + { + /* iterate elevation */ + for( j = 0, elevation = elevationStep * 0.5f; j < DIRT_NUM_ELEVATION_STEPS; j++, elevation += elevationStep ) + { + dirtVectors[ numDirtVectors ][ 0 ] = sin( elevation ) * cos( angle ); + dirtVectors[ numDirtVectors ][ 1 ] = sin( elevation ) * sin( angle ); + dirtVectors[ numDirtVectors ][ 2 ] = cos( elevation ); + numDirtVectors++; + } + } + + /* emit some statistics */ + Sys_FPrintf( SYS_VRB, "%9d dirtmap vectors\n", numDirtVectors ); +} + + +/* +DirtForSample() +calculates dirt value for a given sample +*/ + +float DirtForSample( trace_t *trace ) +{ + int i; + float gatherDirt, outDirt, angle, elevation, ooDepth; + vec3_t normal, worldUp, myUp, myRt, temp, direction, displacement; + + + /* dummy check */ + if( !dirty ) + return 1.0f; + if( trace == NULL || trace->cluster < 0 ) + return 0.0f; + + /* setup */ + gatherDirt = 0.0f; + ooDepth = 1.0f / dirtDepth; + VectorCopy( trace->normal, normal ); + + /* check if the normal is aligned to the world-up */ + if( normal[ 0 ] == 0.0f && normal[ 1 ] == 0.0f ) + { + if( normal[ 2 ] == 1.0f ) + { + VectorSet( myRt, 1.0f, 0.0f, 0.0f ); + VectorSet( myUp, 0.0f, 1.0f, 0.0f ); + } + else if( normal[ 2 ] == -1.0f ) + { + VectorSet( myRt, -1.0f, 0.0f, 0.0f ); + VectorSet( myUp, 0.0f, 1.0f, 0.0f ); + } + } + else + { + VectorSet( worldUp, 0.0f, 0.0f, 1.0f ); + CrossProduct( normal, worldUp, myRt ); + VectorNormalize( myRt, myRt ); + CrossProduct( myRt, normal, myUp ); + VectorNormalize( myUp, myUp ); + } + + /* 1 = random mode, 0 (well everything else) = non-random mode */ + if( dirtMode == 1 ) + { + /* iterate */ + for( i = 0; i < numDirtVectors; i++ ) + { + /* get random vector */ + angle = Random() * DEG2RAD( 360.0f ); + elevation = Random() * DEG2RAD( DIRT_CONE_ANGLE ); + temp[ 0 ] = cos( angle ) * sin( elevation ); + temp[ 1 ] = sin( angle ) * sin( elevation ); + temp[ 2 ] = cos( elevation ); + + /* transform into tangent space */ + direction[ 0 ] = myRt[ 0 ] * temp[ 0 ] + myUp[ 0 ] * temp[ 1 ] + normal[ 0 ] * temp[ 2 ]; + direction[ 1 ] = myRt[ 1 ] * temp[ 0 ] + myUp[ 1 ] * temp[ 1 ] + normal[ 1 ] * temp[ 2 ]; + direction[ 2 ] = myRt[ 2 ] * temp[ 0 ] + myUp[ 2 ] * temp[ 1 ] + normal[ 2 ] * temp[ 2 ]; + + /* set endpoint */ + VectorMA( trace->origin, dirtDepth, direction, trace->end ); + SetupTrace( trace ); + + /* trace */ + TraceLine( trace ); + if( trace->opaque ) + { + VectorSubtract( trace->hit, trace->origin, displacement ); + gatherDirt += 1.0f - ooDepth * VectorLength( displacement ); + } + } + } + else + { + /* iterate through ordered vectors */ + for( i = 0; i < numDirtVectors; i++ ) + { + /* transform vector into tangent space */ + direction[ 0 ] = myRt[ 0 ] * dirtVectors[ i ][ 0 ] + myUp[ 0 ] * dirtVectors[ i ][ 1 ] + normal[ 0 ] * dirtVectors[ i ][ 2 ]; + direction[ 1 ] = myRt[ 1 ] * dirtVectors[ i ][ 0 ] + myUp[ 1 ] * dirtVectors[ i ][ 1 ] + normal[ 1 ] * dirtVectors[ i ][ 2 ]; + direction[ 2 ] = myRt[ 2 ] * dirtVectors[ i ][ 0 ] + myUp[ 2 ] * dirtVectors[ i ][ 1 ] + normal[ 2 ] * dirtVectors[ i ][ 2 ]; + + /* set endpoint */ + VectorMA( trace->origin, dirtDepth, direction, trace->end ); + SetupTrace( trace ); + + /* trace */ + TraceLine( trace ); + if( trace->opaque ) + { + VectorSubtract( trace->hit, trace->origin, displacement ); + gatherDirt += 1.0f - ooDepth * VectorLength( displacement ); + } + } + } + + /* direct ray */ + VectorMA( trace->origin, dirtDepth, normal, trace->end ); + SetupTrace( trace ); + + /* trace */ + TraceLine( trace ); + if( trace->opaque ) + { + VectorSubtract( trace->hit, trace->origin, displacement ); + gatherDirt += 1.0f - ooDepth * VectorLength( displacement ); + } + + /* early out */ + if( gatherDirt <= 0.0f ) + return 1.0f; + + /* apply gain (does this even do much? heh) */ + outDirt = pow( gatherDirt / (numDirtVectors + 1), dirtGain ); + if( outDirt > 1.0f ) + outDirt = 1.0f; + + /* apply scale */ + outDirt *= dirtScale; + if( outDirt > 1.0f ) + outDirt = 1.0f; + + /* return to sender */ + return 1.0f - outDirt; +} + + + +/* +DirtyRawLightmap() +calculates dirty fraction for each luxel +*/ + +void DirtyRawLightmap( int rawLightmapNum ) +{ + int i, x, y, sx, sy, *cluster; + float *origin, *normal, *dirt, *dirt2, average, samples; + rawLightmap_t *lm; + surfaceInfo_t *info; + trace_t trace; + + + /* bail if this number exceeds the number of raw lightmaps */ + if( rawLightmapNum >= numRawLightmaps ) + return; + + /* get lightmap */ + lm = &rawLightmaps[ rawLightmapNum ]; + + /* setup trace */ + trace.testOcclusion = qtrue; + trace.forceSunlight = qfalse; + trace.recvShadows = lm->recvShadows; + trace.numSurfaces = lm->numLightSurfaces; + trace.surfaces = &lightSurfaces[ lm->firstLightSurface ]; + trace.inhibitRadius = DEFAULT_INHIBIT_RADIUS; + trace.testAll = qfalse; + + /* twosided lighting (may or may not be a good idea for lightmapped stuff) */ + trace.twoSided = qfalse; + for( i = 0; i < trace.numSurfaces; i++ ) + { + /* get surface */ + info = &surfaceInfos[ trace.surfaces[ i ] ]; + + /* check twosidedness */ + if( info->si->twoSided ) + { + trace.twoSided = qtrue; + break; + } + } + + /* gather dirt */ + for( y = 0; y < lm->sh; y++ ) + { + for( x = 0; x < lm->sw; x++ ) + { + /* get luxel */ + cluster = SUPER_CLUSTER( x, y ); + origin = SUPER_ORIGIN( x, y ); + normal = SUPER_NORMAL( x, y ); + dirt = SUPER_DIRT( x, y ); + + /* set default dirt */ + *dirt = 0.0f; + + /* only look at mapped luxels */ + if( *cluster < 0 ) + continue; + + /* copy to trace */ + trace.cluster = *cluster; + VectorCopy( origin, trace.origin ); + VectorCopy( normal, trace.normal ); + + /* get dirt */ + *dirt = DirtForSample( &trace ); + } + } + + /* testing no filtering */ + //% return; + + /* filter dirt */ + for( y = 0; y < lm->sh; y++ ) + { + for( x = 0; x < lm->sw; x++ ) + { + /* get luxel */ + cluster = SUPER_CLUSTER( x, y ); + dirt = SUPER_DIRT( x, y ); + + /* filter dirt by adjacency to unmapped luxels */ + average = *dirt; + samples = 1.0f; + for( sy = (y - 1); sy <= (y + 1); sy++ ) + { + if( sy < 0 || sy >= lm->sh ) + continue; + + for( sx = (x - 1); sx <= (x + 1); sx++ ) + { + if( sx < 0 || sx >= lm->sw || (sx == x && sy == y) ) + continue; + + /* get neighboring luxel */ + cluster = SUPER_CLUSTER( sx, sy ); + dirt2 = SUPER_DIRT( sx, sy ); + if( *cluster < 0 || *dirt2 <= 0.0f ) + continue; + + /* add it */ + average += *dirt2; + samples += 1.0f; + } + + /* bail */ + if( samples <= 0.0f ) + break; + } + + /* bail */ + if( samples <= 0.0f ) + continue; + + /* scale dirt */ + *dirt = average / samples; + } + } +} + + + /* SubmapRawLuxel() calculates the pvs cluster, origin, normal of a sub-luxel @@ -1335,7 +1651,7 @@ SubsampleRawLuxel_r() recursively subsamples a luxel until its color gradient is low enough or subsampling limit is reached */ -void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampleOrigin, int x, int y, float bias, float *lightLuxel ) +static void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampleOrigin, int x, int y, float bias, float *lightLuxel ) { int b, samples, mapped, lighted; int cluster[ 4 ]; @@ -1377,7 +1693,7 @@ void SubsampleRawLuxel_r( rawLightmap_t *lm, trace_t *trace, vec3_t sampleOrigin VectorCopy( normal[ b ], trace->normal ); /* sample light */ - //% LightContributionToSample( light, cluster[ b ], origin[ b ], normal[ b ], luxel[ b ], qtrue, qfalse, lm->numLightSurfaces, &lightSurfaces[ lm->firstLightSurface ] ); + LightContributionToSample( trace ); /* add to totals (fixme: make contrast function) */ @@ -1434,6 +1750,7 @@ IlluminateRawLightmap() illuminates the luxels */ +#define STACK_LL_SIZE (SUPER_LUXEL_SIZE * 64 * 64) #define LIGHT_LUXEL( x, y ) (lightLuxels + ((((y) * lm->sw) + (x)) * SUPER_LUXEL_SIZE)) void IlluminateRawLightmap( int rawLightmapNum ) @@ -1444,11 +1761,12 @@ void IlluminateRawLightmap( int rawLightmapNum ) surfaceInfo_t *info; qboolean filterColor, filterDir; float brightness; - float *origin, *normal, *luxel, *luxel2, *deluxel, *deluxel2; + float *origin, *normal, *dirt, *luxel, *luxel2, *deluxel, *deluxel2; float *lightLuxels, *lightLuxel, samples, filterRadius, weight; vec3_t color, averageColor, averageDir, total, temp, temp2; float tests[ 4 ][ 2 ] = { { 0.0f, 0 }, { 1, 0 }, { 0, 1 }, { 1, 1 } }; trace_t trace; + float stackLightLuxels[ STACK_LL_SIZE ]; /* bail if this number exceeds the number of raw lightmaps */ @@ -1488,8 +1806,11 @@ void IlluminateRawLightmap( int rawLightmapNum ) fill pass ----------------------------------------------------------------- */ + /* set counts */ + numLuxelsIlluminated += (lm->sw * lm->sh); + /* test debugging state */ - if( debugSurfaces || debugAxis || debugCluster || debugOrigin || normalmap ) + if( debugSurfaces || debugAxis || debugCluster || debugOrigin || dirtDebug || normalmap ) { /* debug fill the luxels */ for( y = 0; y < lm->sh; y++ ) @@ -1543,8 +1864,11 @@ void IlluminateRawLightmap( int rawLightmapNum ) luxel[ 2 ] = (normal[ 2 ] + 1.0f) * 127.5f; } + /* otherwise clear it */ + else + VectorClear( luxel ); + /* add to counts */ - numLuxelsIlluminated++; luxel[ 3 ] = 1.0f; } } @@ -1553,7 +1877,10 @@ void IlluminateRawLightmap( int rawLightmapNum ) { /* allocate temporary per-light luxel storage */ llSize = lm->sw * lm->sh * SUPER_LUXEL_SIZE * sizeof( float ); - lightLuxels = safe_malloc( llSize ); + if( llSize <= (STACK_LL_SIZE * sizeof( float )) ) + lightLuxels = stackLightLuxels; + else + lightLuxels = safe_malloc( llSize ); /* clear luxels */ //% memset( lm->superLuxels[ 0 ], 0, llSize ); @@ -1751,6 +2078,29 @@ void IlluminateRawLightmap( int rawLightmapNum ) } } + /* tertiary pass, apply dirt map (ambient occlusion) */ + if( 0 && dirty ) + { + /* walk luxels */ + for( y = 0; y < lm->sh; y++ ) + { + for( x = 0; x < lm->sw; x++ ) + { + /* get cluster */ + cluster = SUPER_CLUSTER( x, y ); + if( *cluster < 0 ) + continue; + + /* get particulars */ + lightLuxel = LIGHT_LUXEL( x, y ); + dirt = SUPER_DIRT( x, y ); + + /* scale light value */ + VectorScale( lightLuxel, *dirt, lightLuxel ); + } + } + } + /* allocate sampling lightmap storage */ if( lm->superLuxels[ lightmapNum ] == NULL ) { @@ -1865,12 +2215,51 @@ void IlluminateRawLightmap( int rawLightmapNum ) } /* free temporary luxels */ - free( lightLuxels ); + if( lightLuxels != stackLightLuxels ) + free( lightLuxels ); } /* free light list */ FreeTraceLights( &trace ); + /* ----------------------------------------------------------------- + dirt pass + ----------------------------------------------------------------- */ + + if( dirty ) + { + /* walk lightmaps */ + for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) + { + /* early out */ + if( lm->superLuxels[ lightmapNum ] == NULL ) + continue; + + /* apply dirt to each luxel */ + for( y = 0; y < lm->sh; y++ ) + { + for( x = 0; x < lm->sw; x++ ) + { + /* get cluster */ + cluster = SUPER_CLUSTER( x, y ); + //% if( *cluster < 0 ) + //% continue; + + /* get particulars */ + luxel = SUPER_LUXEL( lightmapNum, x, y ); + dirt = SUPER_DIRT( x, y ); + + /* apply dirt */ + VectorScale( luxel, *dirt, luxel ); + + /* debugging */ + if( dirtDebug ) + VectorSet( luxel, *dirt * 255.0f, *dirt * 255.0f, *dirt * 255.0f ); + } + } + } + } + /* ----------------------------------------------------------------- filter pass ----------------------------------------------------------------- */ @@ -1908,7 +2297,7 @@ void IlluminateRawLightmap( int rawLightmapNum ) /* choose seed amount */ VectorClear( averageColor ); VectorClear( averageDir ); - samples = 0; + samples = 0.0f; /* walk 3x3 matrix */ for( sy = (y - 1); sy <= (y + 1); sy++ ) @@ -1940,9 +2329,17 @@ void IlluminateRawLightmap( int rawLightmapNum ) } /* fall through */ - if( samples == 0.0f ) + if( samples <= 0.0f ) continue; + /* dark lightmap seams */ + if( dark ) + { + if( lightmapNum == 0 ) + VectorMA( averageColor, 2.0f, ambientColor, averageColor ); + samples += 2.0f; + } + /* average it */ if( filterColor ) { @@ -1967,14 +2364,14 @@ IlluminateVertexes() light the surface vertexes */ -#define VERTEX_NUDGE 2.0f +#define VERTEX_NUDGE 4.0f void IlluminateVertexes( int num ) { int i, x, y, z, x1, y1, z1, sx, sy, radius, maxRadius, *cluster; - int lightmapNum; - float samples, *vertLuxel, *radVertLuxel, *luxel; - vec3_t origin, temp, temp2, colors[ MAX_LIGHTMAPS ]; + int lightmapNum, numAvg; + float samples, *vertLuxel, *radVertLuxel, *luxel, dirt; + vec3_t origin, temp, temp2, colors[ MAX_LIGHTMAPS ], avgColors[ MAX_LIGHTMAPS ]; bspDrawSurface_t *ds; surfaceInfo_t *info; rawLightmap_t *lm; @@ -1982,10 +2379,6 @@ void IlluminateVertexes( int num ) trace_t trace; - /* der... */ - if( noVertexLighting ) - return; - /* get surface, info, and raw lightmap */ ds = &bspDrawSurfaces[ num ]; info = &surfaceInfos[ num ]; @@ -1996,10 +2389,10 @@ void IlluminateVertexes( int num ) ----------------------------------------------------------------- */ /* calculate vertex lighting for surfaces without lightmaps */ - if( lm == NULL ) + if( lm == NULL || cpmaHack ) { /* setup trace */ - trace.testOcclusion = !noTrace; + trace.testOcclusion = (cpmaHack && lm != NULL) ? qfalse : !noTrace; trace.forceSunlight = info->si->forceSunlight; trace.recvShadows = info->recvShadows; trace.numSurfaces = 1; @@ -2012,8 +2405,12 @@ void IlluminateVertexes( int num ) /* make light list for this surface */ CreateTraceLightsForSurface( num, &trace ); - /* walk the surface verts */ + /* setup */ verts = yDrawVerts + ds->firstVert; + numAvg = 0; + memset( avgColors, 0, sizeof( avgColors ) ); + + /* walk the surface verts */ for( i = 0; i < ds->numVerts; i++ ) { /* get vertex luxel */ @@ -2046,7 +2443,7 @@ void IlluminateVertexes( int num ) else { /* clear vertex luxel */ - VectorCopy( ambientColor, radVertLuxel ); + VectorSet( radVertLuxel, -1.0f, -1.0f, -1.0f ); /* try at initial origin */ trace.cluster = ClusterForPointExtFilter( verts[ i ].xyz, VERTEX_EPSILON, info->numSurfaceClusters, &surfaceClusters[ info->firstSurfaceCluster ] ); @@ -2056,18 +2453,30 @@ void IlluminateVertexes( int num ) VectorCopy( verts[ i ].xyz, trace.origin ); VectorCopy( verts[ i ].normal, trace.normal ); + /* r7 dirt */ + if( dirty ) + dirt = DirtForSample( &trace ); + else + dirt = 1.0f; + /* trace */ LightingAtSample( &trace, ds->vertexStyles, colors ); /* store */ for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) { + /* r7 dirt */ + VectorScale( colors[ lightmapNum ], dirt, colors[ lightmapNum ] ); + + /* store */ radVertLuxel = RAD_VERTEX_LUXEL( lightmapNum, ds->firstVert + i ); VectorCopy( colors[ lightmapNum ], radVertLuxel ); + VectorAdd( avgColors[ lightmapNum ], colors[ lightmapNum ], colors[ lightmapNum ] ); } } /* is this sample bright enough? */ + radVertLuxel = RAD_VERTEX_LUXEL( 0, ds->firstVert + i ); if( radVertLuxel[ 0 ] <= ambientColor[ 0 ] && radVertLuxel[ 1 ] <= ambientColor[ 1 ] && radVertLuxel[ 2 ] <= ambientColor[ 2 ] ) @@ -2102,6 +2511,10 @@ void IlluminateVertexes( int num ) /* store */ for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) { + /* r7 dirt */ + VectorScale( colors[ lightmapNum ], dirt, colors[ lightmapNum ] ); + + /* store */ radVertLuxel = RAD_VERTEX_LUXEL( lightmapNum, ds->firstVert + i ); VectorCopy( colors[ lightmapNum ], radVertLuxel ); } @@ -2116,10 +2529,55 @@ void IlluminateVertexes( int num ) } } } + + /* add to average? */ + radVertLuxel = RAD_VERTEX_LUXEL( 0, ds->firstVert + i ); + if( radVertLuxel[ 0 ] > ambientColor[ 0 ] || + radVertLuxel[ 1 ] > ambientColor[ 1 ] || + radVertLuxel[ 2 ] > ambientColor[ 2 ] ) + { + numAvg++; + for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) + { + radVertLuxel = RAD_VERTEX_LUXEL( lightmapNum, ds->firstVert + i ); + VectorAdd( avgColors[ lightmapNum ], radVertLuxel, avgColors[ lightmapNum ] ); + } + } } /* another happy customer */ numVertsIlluminated++; + } + + /* set average color */ + if( numAvg > 0 ) + { + for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) + VectorScale( avgColors[ lightmapNum ], (1.0f / numAvg), avgColors[ lightmapNum ] ); + } + else + { + VectorCopy( ambientColor, avgColors[ 0 ] ); + } + + /* clean up and store vertex color */ + for( i = 0; i < ds->numVerts; i++ ) + { + /* get vertex luxel */ + radVertLuxel = RAD_VERTEX_LUXEL( 0, ds->firstVert + i ); + + /* store average in occluded vertexes */ + if( radVertLuxel[ 0 ] < 0.0f ) + { + for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) + { + radVertLuxel = RAD_VERTEX_LUXEL( lightmapNum, ds->firstVert + i ); + VectorCopy( avgColors[ lightmapNum ], radVertLuxel ); + + /* debug code */ + //% VectorSet( radVertLuxel, 255.0f, 0.0f, 0.0f ); + } + } /* store it */ for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) @@ -2131,7 +2589,8 @@ void IlluminateVertexes( int num ) /* store */ if( bouncing || bounce == 0 || !bounceOnly ) VectorAdd( vertLuxel, radVertLuxel, vertLuxel ); - ColorToBytes( vertLuxel, verts[ i ].color[ lightmapNum ], info->si->vertexScale ); + if( !info->si->noVertexLight ) + ColorToBytes( vertLuxel, verts[ i ].color[ lightmapNum ], info->si->vertexScale ); } } @@ -2241,7 +2700,8 @@ void IlluminateVertexes( int num ) numVertsIlluminated++; /* store into bytes (for vertex approximation) */ - ColorToBytes( vertLuxel, verts[ i ].color[ lightmapNum ], 1.0f ); + if( !info->si->noVertexLight ) + ColorToBytes( vertLuxel, verts[ i ].color[ lightmapNum ], 1.0f ); } } } @@ -2923,6 +3383,10 @@ void SetupEnvelopes( qboolean forGrid, qboolean fastFlag ) /* filter into correct bucket */ light->next = buckets[ light->style ]; buckets[ light->style ] = light; + + /* if any styled light is present, automatically set nocollapse */ + if( light->style != LS_NORMAL ) + noCollapse = qtrue; } /* filter back into light list */ diff --git a/tools/quake3/q3map2/lightmaps_ydnar.c b/tools/quake3/q3map2/lightmaps_ydnar.c index df169351..8ae0d75a 100644 --- a/tools/quake3/q3map2/lightmaps_ydnar.c +++ b/tools/quake3/q3map2/lightmaps_ydnar.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -136,12 +137,12 @@ void ExportLightmaps( void ) Q_mkdir( dirname ); /* iterate through the lightmaps */ - for( i = 0, lightmap = bspLightBytes; lightmap < (bspLightBytes + numBSPLightBytes); i++, lightmap += (LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT * 3) ) + for( i = 0, lightmap = bspLightBytes; lightmap < (bspLightBytes + numBSPLightBytes); i++, lightmap += (game->lightmapSize * game->lightmapSize * 3) ) { /* write a tga image out */ sprintf( filename, "%s/lightmap_%04d.tga", dirname, i ); Sys_Printf( "Writing %s\n", filename ); - WriteTGA24( filename, lightmap, LIGHTMAP_WIDTH, LIGHTMAP_HEIGHT, qfalse ); + WriteTGA24( filename, lightmap, game->lightmapSize, game->lightmapSize, qfalse ); } } @@ -222,7 +223,7 @@ int ImportLightmapsMain( int argc, char **argv ) Q_mkdir( dirname ); /* iterate through the lightmaps */ - for( i = 0, lightmap = bspLightBytes; lightmap < (bspLightBytes + numBSPLightBytes); i++, lightmap += (LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT * 3) ) + for( i = 0, lightmap = bspLightBytes; lightmap < (bspLightBytes + numBSPLightBytes); i++, lightmap += (game->lightmapSize * game->lightmapSize * 3) ) { /* read a tga image */ sprintf( filename, "%s/lightmap_%04d.tga", dirname, i ); @@ -237,7 +238,7 @@ int ImportLightmapsMain( int argc, char **argv ) /* parse file into an image */ pixels = NULL; - LoadTGABuffer( buffer, &pixels, &width, &height ); + LoadTGABuffer( buffer, buffer + len, &pixels, &width, &height ); free( buffer ); /* sanity check it */ @@ -246,16 +247,16 @@ int ImportLightmapsMain( int argc, char **argv ) Sys_Printf( "WARNING: Unable to load image %s\n", filename ); continue; } - if( width != LIGHTMAP_WIDTH || height != LIGHTMAP_HEIGHT ) + if( width != game->lightmapSize || height != game->lightmapSize ) Sys_Printf( "WARNING: Image %s is not the right size (%d, %d) != (%d, %d)\n", - filename, width, height, LIGHTMAP_WIDTH, LIGHTMAP_HEIGHT ); + filename, width, height, game->lightmapSize, game->lightmapSize ); /* copy the pixels */ in = pixels; - for( y = 1; y <= LIGHTMAP_HEIGHT; y++ ) + for( y = 1; y <= game->lightmapSize; y++ ) { - out = lightmap + ((LIGHTMAP_HEIGHT - y) * LIGHTMAP_WIDTH * 3); - for( x = 0; x < LIGHTMAP_WIDTH; x++, in += 4, out += 3 ) + out = lightmap + ((game->lightmapSize - y) * game->lightmapSize * 3); + for( x = 0; x < game->lightmapSize; x++, in += 4, out += 3 ) VectorCopy( in, out ); } @@ -615,7 +616,7 @@ qboolean AddSurfaceToRawLightmap( int num, rawLightmap_t *lm ) info->recvShadows != lm->recvShadows || info->si->lmCustomWidth != lm->customWidth || info->si->lmCustomHeight != lm->customHeight || - info->si->lmGamma != lm->gamma || + info->si->lmBrightness != lm->brightness || info->si->lmFilterRadius != lm->filterRadius || info->si->splotchFix != lm->splotchFix ) return qfalse; @@ -1095,7 +1096,7 @@ void SetupSurfaceLightmaps( void ) lm->actualSampleSize = info->sampleSize; lm->entityNum = info->entityNum; lm->recvShadows = info->recvShadows; - lm->gamma = info->si->lmGamma; + lm->brightness = info->si->lmBrightness; lm->filterRadius = info->si->lmFilterRadius; VectorCopy( info->axis, lm->axis ); lm->plane = info->plane; @@ -1327,6 +1328,7 @@ CompareBSPLuxels() compares two surface lightmaps' bsp luxels, ignoring occluded luxels */ +#define SOLID_EPSILON 0.0625 #define LUXEL_TOLERANCE 0.0025 #define LUXEL_COLOR_FRAC 0.001302083 /* 1 / 3 / 256 */ @@ -1343,13 +1345,33 @@ static qboolean CompareBSPLuxels( rawLightmap_t *a, int aNum, rawLightmap_t *b, ((aNum == 0 && bNum != 0) || (aNum != 0 && bNum == 0)) ) return qfalse; - /* compare */ - if( a->w != b->w || a->h != b->h || - a->customWidth != b->customWidth || a->customHeight != b->customHeight || - a->gamma != b->gamma || + /* basic tests */ + if( a->customWidth != b->customWidth || a->customHeight != b->customHeight || + a->brightness != b->brightness || + a->solid[ aNum ] != b->solid[ bNum ] || a->bspLuxels[ aNum ] == NULL || b->bspLuxels[ bNum ] == NULL ) return qfalse; + /* compare solid color lightmaps */ + if( a->solid[ aNum ] && b->solid[ bNum ] ) + { + /* get deltas */ + rd = fabs( a->solidColor[ aNum ][ 0 ] - b->solidColor[ bNum ][ 0 ] ); + gd = fabs( a->solidColor[ aNum ][ 1 ] - b->solidColor[ bNum ][ 1 ] ); + bd = fabs( a->solidColor[ aNum ][ 2 ] - b->solidColor[ bNum ][ 2 ] ); + + /* compare color */ + if( rd > SOLID_EPSILON || gd > SOLID_EPSILON|| bd > SOLID_EPSILON ) + return qfalse; + + /* okay */ + return qtrue; + } + + /* compare nonsolid lightmaps */ + if( a->w != b->w || a->h != b->h ) + return qfalse; + /* compare luxels */ delta = 0.0; total = 0.0; @@ -1399,19 +1421,38 @@ MergeBSPLuxels() merges two surface lightmaps' bsp luxels, overwriting occluded luxels */ -static void MergeBSPLuxels( rawLightmap_t *a, int aNum, rawLightmap_t *b, int bNum ) +static qboolean MergeBSPLuxels( rawLightmap_t *a, int aNum, rawLightmap_t *b, int bNum ) { rawLightmap_t *lm; int x, y; float luxel[ 3 ], *aLuxel, *bLuxel; - /* compare */ - if( a->w != b->w || a->h != b->h || - a->customWidth != b->customWidth || a->customHeight != b->customHeight || - a->gamma != b->gamma || + /* basic tests */ + if( a->customWidth != b->customWidth || a->customHeight != b->customHeight || + a->brightness != b->brightness || + a->solid[ aNum ] != b->solid[ bNum ] || a->bspLuxels[ aNum ] == NULL || b->bspLuxels[ bNum ] == NULL ) - return; + return qfalse; + + /* compare solid lightmaps */ + if( a->solid[ aNum ] && b->solid[ bNum ] ) + { + /* average */ + VectorAdd( a->solidColor[ aNum ], b->solidColor[ bNum ], luxel ); + VectorScale( luxel, 0.5f, luxel ); + + /* copy to both */ + VectorCopy( luxel, a->solidColor[ aNum ] ); + VectorCopy( luxel, b->solidColor[ bNum ] ); + + /* return to sender */ + return qtrue; + } + + /* compare nonsolid lightmaps */ + if( a->w != b->w || a->h != b->h ) + return qfalse; /* merge luxels */ for( y = 0; y < a->h; y++ ) @@ -1442,6 +1483,9 @@ static void MergeBSPLuxels( rawLightmap_t *a, int aNum, rawLightmap_t *b, int bN } } } + + /* done */ + return qtrue; } @@ -1631,18 +1675,23 @@ static qboolean ApproximateLightmap( rawLightmap_t *lm ) ds = &bspDrawSurfaces[ num ]; info = &surfaceInfos[ num ]; + /* assume not-reduced initially */ + info->approximated = qfalse; + /* bail if lightmap doesn't match up */ if( info->lm != lm ) continue; - /* assume reduced initially */ - info->approximated = qtrue; + /* bail if not vertex lit */ + if( info->si->noVertexLight ) + continue; /* assume that surfaces whose bounding boxes is smaller than 2x samplesize will be forced to vertex */ if( (info->maxs[ 0 ] - info->mins[ 0 ]) <= (2.0f * info->sampleSize) && (info->maxs[ 1 ] - info->mins[ 1 ]) <= (2.0f * info->sampleSize) && (info->maxs[ 2 ] - info->mins[ 2 ]) <= (2.0f * info->sampleSize) ) { + info->approximated = qtrue; numSurfsVertexForced++; continue; } @@ -1655,6 +1704,7 @@ static qboolean ApproximateLightmap( rawLightmap_t *lm ) verts = yDrawVerts + ds->firstVert; /* map the triangles */ + info->approximated = qtrue; for( i = 0; i < ds->numIndexes && info->approximated; i += 3 ) { dv[ 0 ] = &verts[ bspDrawIndexes[ ds->firstIndex + i ] ]; @@ -1681,6 +1731,7 @@ static qboolean ApproximateLightmap( rawLightmap_t *lm ) verts = mesh->verts; /* map the mesh quads */ + info->approximated = qtrue; for( y = 0; y < (mesh->height - 1) && info->approximated; y++ ) { for( x = 0; x < (mesh->width - 1) && info->approximated; x++ ) @@ -1746,6 +1797,15 @@ static qboolean TestOutLightmapStamp( rawLightmap_t *lm, int lightmapNum, outLig if( x < 0 || y < 0 || (x + lm->w) > olm->customWidth || (y + lm->h) > olm->customHeight ) return qfalse; + /* solid lightmaps test a 1x1 stamp */ + if( lm->solid[ lightmapNum ] ) + { + offset = (y * olm->customWidth) + x; + if( olm->lightBits[ offset >> 3 ] & (1 << (offset & 7)) ) + return qfalse; + return qtrue; + } + /* test the stamp */ for( sy = 0; sy < lm->h; sy++ ) { @@ -1783,7 +1843,7 @@ static void SetupOutLightmap( rawLightmap_t *lm, outLightmap_t *olm ) return; /* is this a "normal" bsp-stored lightmap? */ - if( (lm->customWidth == LIGHTMAP_WIDTH && lm->customHeight == LIGHTMAP_HEIGHT) || externalLightmaps ) + if( (lm->customWidth == game->lightmapSize && lm->customHeight == game->lightmapSize) || externalLightmaps ) { olm->lightmapNum = numBSPLightmaps; numBSPLightmaps++; @@ -1838,7 +1898,7 @@ static void FindOutLightmaps( rawLightmap_t *lm ) /* set default lightmap number (-3 = LIGHTMAP_BY_VERTEX) */ for( lightmapNum = 0; lightmapNum < MAX_LIGHTMAPS; lightmapNum++ ) lm->outLightmapNums[ lightmapNum ] = -3; - + /* can this lightmap be approximated with vertex color? */ if( ApproximateLightmap( lm ) ) return; @@ -1936,8 +1996,16 @@ static void FindOutLightmaps( rawLightmap_t *lm ) continue; /* set maxs */ - xMax = (olm->customWidth - lm->w) + 1; - yMax = (olm->customHeight - lm->h) + 1; + if( lm->solid[ lightmapNum ] ) + { + xMax = olm->customWidth; + yMax = olm->customHeight; + } + else + { + xMax = (olm->customWidth - lm->w) + 1; + yMax = (olm->customHeight - lm->h) + 1; + } /* walk the origin around the lightmap */ for( y = 0; y < yMax; y++ ) @@ -1994,7 +2062,7 @@ static void FindOutLightmaps( rawLightmap_t *lm ) } /* if this is a style-using lightmap, it must be exported */ - if( lightmapNum > 0 ) + if( lightmapNum > 0 && game->load != LoadRBSPFile ) olm->extLightmapNum = 0; /* add the surface lightmap to the bsp lightmap */ @@ -2025,20 +2093,40 @@ static void FindOutLightmaps( rawLightmap_t *lm ) } } + /* set maxs */ + if( lm->solid[ lightmapNum ] ) + { + xMax = 1; + yMax = 1; + } + else + { + xMax = lm->w; + yMax = lm->h; + } + /* mark the bits used */ - for( y = 0; y < lm->h; y++ ) + for( y = 0; y < yMax; y++ ) { - for( x = 0; x < lm->w; x++ ) + for( x = 0; x < xMax; x++ ) { /* get luxel */ luxel = BSP_LUXEL( lightmapNum, x, y ); deluxel = BSP_DELUXEL( x, y ); - if( luxel[ 0 ] < 0.0f ) + if( luxel[ 0 ] < 0.0f && !lm->solid[ lightmapNum ]) continue; /* set minimum light */ - VectorCopy( luxel, color ); - + if( lm->solid[ lightmapNum ] ) + { + if( debug ) + VectorSet( color, 255.0f, 0.0f, 0.0f ); + else + VectorCopy( lm->solidColor[ lightmapNum ], color ); + } + else + VectorCopy( luxel, color ); + /* styles are not affected by minlight */ if( lightmapNum == 0 ) { @@ -2060,7 +2148,7 @@ static void FindOutLightmaps( rawLightmap_t *lm ) /* store color */ pixel = olm->bspLightBytes + (((oy * olm->customWidth) + ox) * 3); - ColorToBytes( color, pixel, lm->gamma ); + ColorToBytes( color, pixel, lm->brightness ); /* store direction */ if( deluxemap ) @@ -2149,7 +2237,7 @@ void StoreSurfaceLightmaps( void ) int i, j, k, x, y, lx, ly, sx, sy, *cluster, mappedSamples; int style, size, lightmapNum, lightmapNum2; float *normal, *luxel, *bspLuxel, *bspLuxel2, *radLuxel, samples, occludedSamples; - vec3_t sample, occludedSample, dirSample; + vec3_t sample, occludedSample, dirSample, colorMins, colorMaxs; float *deluxel, *bspDeluxel, *bspDeluxel2; byte *lb; int numUsed, numTwins, numTwinLuxels, numStored; @@ -2187,6 +2275,7 @@ void StoreSurfaceLightmaps( void ) numUsed = 0; numTwins = 0; numTwinLuxels = 0; + numSolidLightmaps = 0; for( i = 0; i < numRawLightmaps; i++ ) { /* get lightmap */ @@ -2336,8 +2425,11 @@ void StoreSurfaceLightmaps( void ) } } - /* clean up and store into bsp luxels */ + /* setup */ lm->used = 0; + ClearBounds( colorMins, colorMaxs ); + + /* clean up and store into bsp luxels */ for( y = 0; y < lm->h; y++ ) { for( x = 0; x < lm->w; x++ ) @@ -2433,6 +2525,41 @@ void StoreSurfaceLightmaps( void ) VectorAdd( bspLuxel, sample, bspLuxel ); if( deluxemap && lightmapNum == 0 ) VectorAdd( bspDeluxel, dirSample, bspDeluxel ); + + /* add color to bounds for solid checking */ + if( samples > 0.0f ) + AddPointToBounds( bspLuxel, colorMins, colorMaxs ); + } + } + + /* set solid color */ + lm->solid[ lightmapNum ] = qfalse; + VectorAdd( colorMins, colorMaxs, lm->solidColor[ lightmapNum ] ); + VectorScale( lm->solidColor[ lightmapNum ], 0.5f, lm->solidColor[ lightmapNum ] ); + + /* nocollapse prevents solid lightmaps */ + if( noCollapse == qfalse ) + { + /* check solid color */ + VectorSubtract( colorMaxs, colorMins, sample ); + if( (sample[ 0 ] <= SOLID_EPSILON && sample[ 1 ] <= SOLID_EPSILON && sample[ 2 ] <= SOLID_EPSILON) || + (lm->w <= 2 && lm->h <= 2) ) /* small lightmaps get forced to solid color */ + { + /* set to solid */ + VectorCopy( colorMins, lm->solidColor[ lightmapNum ] ); + lm->solid[ lightmapNum ] = qtrue; + numSolidLightmaps++; + } + + /* if all lightmaps aren't solid, then none of them are solid */ + if( lm->solid[ lightmapNum ] != lm->solid[ 0 ] ) + { + for( y = 0; y < MAX_LIGHTMAPS; y++ ) + { + if( lm->solid[ y ] ) + numSolidLightmaps--; + lm->solid[ y ] = qfalse; + } } } @@ -2530,15 +2657,17 @@ void StoreSurfaceLightmaps( void ) if( CompareBSPLuxels( lm, lightmapNum, lm2, lightmapNum2 ) ) { /* merge and set twin */ - MergeBSPLuxels( lm, lightmapNum, lm2, lightmapNum2 ); - lm2->twins[ lightmapNum2 ] = lm; - lm2->twinNums[ lightmapNum2 ] = lightmapNum; - numTwins++; - numTwinLuxels += (lm->w * lm->h); - - /* count styled twins */ - if( lightmapNum > 0 ) - lm->numStyledTwins++; + if( MergeBSPLuxels( lm, lightmapNum, lm2, lightmapNum2 ) ) + { + lm2->twins[ lightmapNum2 ] = lm; + lm2->twinNums[ lightmapNum2 ] = lightmapNum; + numTwins++; + numTwinLuxels += (lm->w * lm->h); + + /* count styled twins */ + if( lightmapNum > 0 ) + lm->numStyledTwins++; + } } } } @@ -2632,7 +2761,7 @@ void StoreSurfaceLightmaps( void ) } else { - numBSPLightBytes = (numBSPLightmaps * LIGHTMAP_WIDTH * LIGHTMAP_HEIGHT * 3); + numBSPLightBytes = (numBSPLightmaps * game->lightmapSize * game->lightmapSize * 3); bspLightBytes = safe_malloc( numBSPLightBytes ); memset( bspLightBytes, 0, numBSPLightBytes ); } @@ -2647,14 +2776,14 @@ void StoreSurfaceLightmaps( void ) if( olm->lightmapNum >= 0 && !externalLightmaps ) { /* copy lighting data */ - lb = bspLightBytes + (olm->lightmapNum * LIGHTMAP_HEIGHT * LIGHTMAP_WIDTH * 3); - memcpy( lb, olm->bspLightBytes, LIGHTMAP_HEIGHT * LIGHTMAP_WIDTH * 3 ); + lb = bspLightBytes + (olm->lightmapNum * game->lightmapSize * game->lightmapSize * 3); + memcpy( lb, olm->bspLightBytes, game->lightmapSize * game->lightmapSize * 3 ); /* copy direction data */ if( deluxemap ) { - lb = bspLightBytes + ((olm->lightmapNum + 1) * LIGHTMAP_HEIGHT * LIGHTMAP_WIDTH * 3); - memcpy( lb, olm->bspDirBytes, LIGHTMAP_HEIGHT * LIGHTMAP_WIDTH * 3 ); + lb = bspLightBytes + ((olm->lightmapNum + 1) * game->lightmapSize * game->lightmapSize * 3); + memcpy( lb, olm->bspDirBytes, game->lightmapSize * game->lightmapSize * 3 ); } } @@ -2787,13 +2916,21 @@ void StoreSurfaceLightmaps( void ) lmx = (float) lm->lightmapX[ lightmapNum ] / (float) olm->customWidth; lmy = (float) lm->lightmapY[ lightmapNum ] / (float) olm->customHeight; - /* calc lightmap st coords and store lighting values */ + /* calc lightmap st coords */ dv = &bspDrawVerts[ ds->firstVert ]; ydv = &yDrawVerts[ ds->firstVert ]; for( j = 0; j < ds->numVerts; j++ ) { - dv[ j ].lightmap[ lightmapNum ][ 0 ] = lmx + (ydv[ j ].lightmap[ 0 ][ 0 ] / (superSample * olm->customWidth)); - dv[ j ].lightmap[ lightmapNum ][ 1 ] = lmy + (ydv[ j ].lightmap[ 0 ][ 1 ] / (superSample * olm->customHeight)); + if( lm->solid[ lightmapNum ] ) + { + dv[ j ].lightmap[ lightmapNum ][ 0 ] = lmx + (0.5f / (float) olm->customWidth); + dv[ j ].lightmap[ lightmapNum ][ 1 ] = lmy + (0.5f / (float) olm->customWidth); + } + else + { + dv[ j ].lightmap[ lightmapNum ][ 0 ] = lmx + (ydv[ j ].lightmap[ 0 ][ 0 ] / (superSample * olm->customWidth)); + dv[ j ].lightmap[ lightmapNum ][ 1 ] = lmy + (ydv[ j ].lightmap[ 0 ][ 1 ] / (superSample * olm->customHeight)); + } } } } @@ -2824,7 +2961,8 @@ void StoreSurfaceLightmaps( void ) } /* store to bytes */ - ColorToBytes( color, dv[ j ].color[ lightmapNum ], info->si->vertexScale ); + if( !info->si->noVertexLight ) + ColorToBytes( color, dv[ j ].color[ lightmapNum ], info->si->vertexScale ); } } @@ -2947,7 +3085,7 @@ void StoreSurfaceLightmaps( void ) /* devise a custom shader for this surface (fixme: make this work with light styles) */ else if( olm != NULL && lm != NULL && !externalLightmaps && - (olm->customWidth != LIGHTMAP_WIDTH || olm->customHeight != LIGHTMAP_HEIGHT) ) + (olm->customWidth != game->lightmapSize || olm->customHeight != game->lightmapSize) ) { /* get output lightmap */ olm = &outLightmaps[ lm->outLightmapNums[ 0 ] ]; @@ -2981,6 +3119,7 @@ void StoreSurfaceLightmaps( void ) /* print stats */ Sys_Printf( "%9d luxels used\n", numUsed ); Sys_Printf( "%9d luxels stored (%3.2f percent efficiency)\n", numStored, efficiency * 100.0f ); + Sys_Printf( "%9d solid surface lightmaps\n", numSolidLightmaps ); Sys_Printf( "%9d identical surface lightmaps, using %d luxels\n", numTwins, numTwinLuxels ); Sys_Printf( "%9d vertex forced surfaces\n", numSurfsVertexForced ); Sys_Printf( "%9d vertex approximated surfaces\n", numSurfsVertexApproximated ); diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index 4da3bcf8..25eff791 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -63,6 +64,264 @@ static void ExitQ3Map( void ) +/* +MD4BlockChecksum() +calculates an md4 checksum for a block of data +*/ + +static int MD4BlockChecksum( void *buffer, int length ) +{ + MHASH mh; + int digest[ 4 ], checksum; + + + /* make md4 hash */ + mh = mhash_init( MHASH_MD4 ); + if( !mh ) + Error( "Unable to initialize MD4 hash context" ); + mhash( mh, buffer, length ); + mhash_deinit( mh, digest ); + + /* xor the bits and return */ + checksum = digest[ 0 ] ^ digest[ 1 ] ^ digest[ 2 ] ^ digest[ 3 ]; + return checksum; +} + + + +/* +FixAAS() +resets an aas checksum to match the given BSP +*/ + +int FixAAS( int argc, char **argv ) +{ + int length, checksum; + void *buffer; + FILE *file; + char aas[ 1024 ], **ext; + char *exts[] = + { + ".aas", + "_b0.aas", + "_b1.aas", + NULL + }; + + + /* arg checking */ + if( argc < 2 ) + { + Sys_Printf( "Usage: q3map -fixaas [-v] \n" ); + return 0; + } + + /* do some path mangling */ + strcpy( source, ExpandArg( argv[ argc - 1 ] ) ); + StripExtension( source ); + DefaultExtension( source, ".bsp" ); + + /* note it */ + Sys_Printf( "--- FixAAS ---\n" ); + + /* load the bsp */ + Sys_Printf( "Loading %s\n", source ); + length = LoadFile( source, &buffer ); + + /* create bsp checksum */ + Sys_Printf( "Creating checksum...\n" ); + checksum = LittleLong( MD4BlockChecksum( buffer, length ) ); + + /* write checksum to aas */ + ext = exts; + while( *ext ) + { + /* mangle name */ + strcpy( aas, source ); + StripExtension( aas ); + strcat( aas, *ext ); + Sys_Printf( "Trying %s\n", aas ); + ext++; + + /* fix it */ + file = fopen( aas, "r+b" ); + if( !file ) + continue; + if( fwrite( &checksum, 4, 1, file ) != 1 ) + Error( "Error writing checksum to %s", aas ); + fclose( file ); + } + + /* return to sender */ + return 0; +} + + + +/* +AnalyzeBSP() - ydnar +analyzes a Quake engine BSP file +*/ + +typedef struct abspHeader_s +{ + char ident[ 4 ]; + int version; + + bspLump_t lumps[ 1 ]; /* unknown size */ +} +abspHeader_t; + +typedef struct abspLumpTest_s +{ + int radix, minCount; + char *name; +} +abspLumpTest_t; + +int AnalyzeBSP( int argc, char **argv ) +{ + abspHeader_t *header; + int size, i, version, offset, length, lumpInt, count; + char ident[ 5 ]; + void *lump; + float lumpFloat; + char lumpString[ 1024 ], source[ 1024 ]; + qboolean lumpSwap = qfalse; + abspLumpTest_t *lumpTest; + static abspLumpTest_t lumpTests[] = + { + { sizeof( bspPlane_t ), 6, "IBSP LUMP_PLANES" }, + { sizeof( bspBrush_t ), 1, "IBSP LUMP_BRUSHES" }, + { 8, 6, "IBSP LUMP_BRUSHSIDES" }, + { sizeof( bspBrushSide_t ), 6, "RBSP LUMP_BRUSHSIDES" }, + { sizeof( bspModel_t ), 1, "IBSP LUMP_MODELS" }, + { sizeof( bspNode_t ), 2, "IBSP LUMP_NODES" }, + { sizeof( bspLeaf_t ), 1, "IBSP LUMP_LEAFS" }, + { 104, 3, "IBSP LUMP_DRAWSURFS" }, + { 44, 3, "IBSP LUMP_DRAWVERTS" }, + { 4, 6, "IBSP LUMP_DRAWINDEXES" }, + { 128 * 128 * 3, 1, "IBSP LUMP_LIGHTMAPS" }, + { 256 * 256 * 3, 1, "IBSP LUMP_LIGHTMAPS (256 x 256)" }, + { 512 * 512 * 3, 1, "IBSP LUMP_LIGHTMAPS (512 x 512)" }, + { 0, 0, NULL } + }; + + + /* arg checking */ + if( argc < 1 ) + { + Sys_Printf( "Usage: q3map -analyze [-lumpswap] [-v] \n" ); + return 0; + } + + /* process arguments */ + for( i = 1; i < (argc - 1); i++ ) + { + /* -format map|ase|... */ + if( !strcmp( argv[ i ], "-lumpswap" ) ) + { + Sys_Printf( "Swapped lump structs enabled\n" ); + lumpSwap = qtrue; + } + } + + /* clean up map name */ + strcpy( source, ExpandArg( argv[ i ] ) ); + Sys_Printf( "Loading %s\n", source ); + + /* load the file */ + size = LoadFile( source, (void**) &header ); + if( size == 0 || header == NULL ) + { + Sys_Printf( "Unable to load %s.\n", source ); + return -1; + } + + /* analyze ident/version */ + memcpy( ident, header->ident, 4 ); + ident[ 4 ] = '\0'; + version = LittleLong( header->version ); + + Sys_Printf( "Identity: %s\n", ident ); + Sys_Printf( "Version: %d\n", version ); + Sys_Printf( "---------------------------------------\n" ); + + /* analyze each lump */ + for( i = 0; i < 100; i++ ) + { + /* call of duty swapped lump pairs */ + if( lumpSwap ) + { + offset = LittleLong( header->lumps[ i ].length ); + length = LittleLong( header->lumps[ i ].offset ); + } + + /* standard lump pairs */ + else + { + offset = LittleLong( header->lumps[ i ].offset ); + length = LittleLong( header->lumps[ i ].length ); + } + + /* extract data */ + lump = (byte*) header + offset; + lumpInt = LittleLong( (int) *((int*) lump) ); + lumpFloat = LittleFloat( (float) *((float*) lump) ); + memcpy( lumpString, (char*) lump, (length < 1024 ? length : 1024) ); + lumpString[ 1024 ] = '\0'; + + /* print basic lump info */ + Sys_Printf( "Lump: %d\n", i ); + Sys_Printf( "Offset: %d bytes\n", offset ); + Sys_Printf( "Length: %d bytes\n", length ); + + /* only operate on valid lumps */ + if( length > 0 ) + { + /* print data in 4 formats */ + Sys_Printf( "As hex: %08X\n", lumpInt ); + Sys_Printf( "As int: %d\n", lumpInt ); + Sys_Printf( "As float: %f\n", lumpFloat ); + Sys_Printf( "As string: %s\n", lumpString ); + + /* guess lump type */ + if( lumpString[ 0 ] == '{' && lumpString[ 2 ] == '"' ) + Sys_Printf( "Type guess: IBSP LUMP_ENTITIES\n" ); + else if( strstr( lumpString, "textures/" ) ) + Sys_Printf( "Type guess: IBSP LUMP_SHADERS\n" ); + else + { + /* guess based on size/count */ + for( lumpTest = lumpTests; lumpTest->radix > 0; lumpTest++ ) + { + if( (length % lumpTest->radix) != 0 ) + continue; + count = length / lumpTest->radix; + if( count < lumpTest->minCount ) + continue; + Sys_Printf( "Type guess: %s (%d x %d)\n", lumpTest->name, count, lumpTest->radix ); + } + } + } + + Sys_Printf( "---------------------------------------\n" ); + + /* end of file */ + if( offset + length >= size ) + break; + } + + /* last stats */ + Sys_Printf( "Lump count: %d\n", i + 1 ); + Sys_Printf( "File size: %d bytes\n", size ); + + /* return to caller */ + return 0; +} + + + /* BSPInfo() emits statistics about the bsp file @@ -250,10 +509,12 @@ int ConvertBSPMain( int argc, char **argv ) { int i; int (*convertFunc)( char * ); + game_t *convertGame; /* set default */ convertFunc = ConvertBSPToASE; + convertGame = NULL; /* arg checking */ if( argc < 1 ) @@ -274,7 +535,11 @@ int ConvertBSPMain( int argc, char **argv ) else if( !Q_stricmp( argv[ i ], "map" ) ) convertFunc = ConvertBSPToMap; else - Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] ); + { + convertGame = GetGame( argv[ i ] ); + if( convertGame == NULL ) + Sys_Printf( "Unknown conversion format \"%s\". Defaulting to ASE.\n", argv[ i ] ); + } } } @@ -295,7 +560,23 @@ int ConvertBSPMain( int argc, char **argv ) /* parse bsp entities */ ParseEntities(); - /* convert */ + /* bsp format convert? */ + if( convertGame != NULL ) + { + /* set global game */ + game = convertGame; + + /* write bsp */ + StripExtension( source ); + DefaultExtension( source, "_c.bsp" ); + Sys_Printf( "Writing %s\n", source ); + WriteBSPFile( source ); + + /* return to sender */ + return 0; + } + + /* normal convert */ return convertFunc( source ); } @@ -404,8 +685,16 @@ int main( int argc, char **argv ) if( argc < 2 ) Error( "Usage: %s [general options] [options] mapfile", argv[ 0 ] ); + /* fixaas */ + if( !strcmp( argv[ 1 ], "-fixaas" ) ) + r = FixAAS( argc - 1, argv + 1 ); + + /* analyze */ + else if( !strcmp( argv[ 1 ], "-analyze" ) ) + r = AnalyzeBSP( argc - 1, argv + 1 ); + /* info */ - if( !strcmp( argv[ 1 ], "-info" ) ) + else if( !strcmp( argv[ 1 ], "-info" ) ) r = BSPInfo( argc - 2, argv + 2 ); /* vis */ diff --git a/tools/quake3/q3map2/map.c b/tools/quake3/q3map2/map.c index 633d327a..1e2f3267 100644 --- a/tools/quake3/q3map2/map.c +++ b/tools/quake3/q3map2/map.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -185,6 +186,13 @@ snaps a plane to normal/distance epsilons 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) +/* + SnapPlane reenabled by namespace because of multiple reports of + q3map2-crashes which were triggered by this patch. +*/ SnapNormal( normal ); if( fabs( *dist - Q_rint( *dist ) ) < distanceEpsilon ) @@ -573,7 +581,7 @@ and links it to the current entity brush_t *FinishBrush( void ) { - brush_t *b; + brush_t *b; /* create windings for sides and bounds for brush */ @@ -644,6 +652,15 @@ brush_t *FinishBrush( void ) mapEnt->lastBrush = b; } + /* link colorMod volume brushes to the entity directly */ + if( b->contentShader != NULL && + b->contentShader->colorMod != NULL && + b->contentShader->colorMod->type == CM_VOLUME ) + { + b->nextColorModBrush = mapEnt->colorModBrushes; + mapEnt->colorModBrushes = b; + } + /* return to sender */ return b; } @@ -1062,16 +1079,24 @@ void MoveBrushesToWorld( entity_t *ent ) entities[ 0 ].lastBrush->next = b; entities[ 0 ].lastBrush = b; } - - //% b->next = entities[ 0 ].brushes; - //% entities[ 0 ].brushes = b; } ent->brushes = NULL; + /* ydnar: move colormod brushes */ + if( ent->colorModBrushes != NULL ) + { + for( b = ent->colorModBrushes; b->nextColorModBrush != NULL; b = b->nextColorModBrush ); + + b->nextColorModBrush = entities[ 0 ].colorModBrushes; + entities[ 0 ].colorModBrushes = ent->colorModBrushes; + + ent->colorModBrushes = NULL; + } + /* move patches */ if( ent->patches != NULL ) { - for( pm = ent->patches; pm->next; pm = pm->next ); + for( pm = ent->patches; pm->next != NULL; pm = pm->next ); pm->next = entities[ 0 ].patches; entities[ 0 ].patches = ent->patches; diff --git a/tools/quake3/q3map2/mesh.c b/tools/quake3/q3map2/mesh.c index 9e205da7..288525cf 100644 --- a/tools/quake3/q3map2/mesh.c +++ b/tools/quake3/q3map2/mesh.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -381,7 +382,8 @@ mesh_t *SubdivideMesh( mesh_t in, float maxError, float minLength ) float len; mesh_t out; - static bspDrawVert_t expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS]; + /* ydnar: static for os x */ + MAC_STATIC bspDrawVert_t expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS]; out.width = in.width; @@ -547,7 +549,8 @@ mesh_t *SubdivideMesh2( mesh_t in, int iterations ) bspDrawVert_t prev, next, mid; mesh_t out; - static bspDrawVert_t expand[ MAX_EXPANDED_AXIS ][ MAX_EXPANDED_AXIS ]; + /* ydnar: static for os x */ + MAC_STATIC bspDrawVert_t expand[ MAX_EXPANDED_AXIS ][ MAX_EXPANDED_AXIS ]; /* initial setup */ @@ -560,7 +563,7 @@ mesh_t *SubdivideMesh2( mesh_t in, int iterations ) } /* keep chopping */ - for( iterations; iterations > 0; iterations-- ) + for( ; iterations > 0; iterations-- ) { /* horizontal subdivisions */ for( j = 0; j + 2 < out.width; j += 4 ) @@ -652,7 +655,8 @@ mesh_t *RemoveLinearMeshColumnsRows( mesh_t *in ) { vec3_t proj, dir; mesh_t out; - static bspDrawVert_t expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS]; + /* ydnar: static for os x */ + MAC_STATIC bspDrawVert_t expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS]; out.width = in->width; @@ -728,8 +732,7 @@ mesh_t *SubdivideMeshQuads( mesh_t *in, float minLength, int maxsize, int *width vec3_t dir; float length, maxLength, amount; mesh_t out; - - static bspDrawVert_t expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS]; + bspDrawVert_t expand[MAX_EXPANDED_AXIS][MAX_EXPANDED_AXIS]; out.width = in->width; out.height = in->height; diff --git a/tools/quake3/q3map2/model.c b/tools/quake3/q3map2/model.c index f303df75..4200368b 100644 --- a/tools/quake3/q3map2/model.c +++ b/tools/quake3/q3map2/model.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -322,7 +323,7 @@ void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shade ds->lightmapScale = lightmapScale; /* force to meta? */ - if( si != NULL && si->forceMeta ) + if( (si != NULL && si->forceMeta) || (spawnFlags & 4) ) /* 3rd bit */ ds->type = SURFACE_FORCED_META; /* set particulars */ @@ -366,6 +367,7 @@ void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shade } /* normal texture coordinates */ + else { st = PicoGetSurfaceST( surface, 0, i ); dv->st[ 0 ] = st[ 0 ]; @@ -393,9 +395,6 @@ void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shade /* set cel shader */ ds->celShader = celShader; - /* finish surface */ - FinishSurface( ds ); - /* ydnar: giant hack land: generate clipping brushes for model triangles */ if( si->clipModel || (spawnFlags & 2) ) /* 2nd bit */ { @@ -405,7 +404,8 @@ void InsertModel( char *name, int frame, m4x4_t transform, remap_t *remap, shade /* temp hack */ - if( (si->compileFlags & C_TRANSLUCENT) || !(si->compileFlags & C_SOLID) ) + if( !si->clipModel && + ((si->compileFlags & C_TRANSLUCENT) || !(si->compileFlags & C_SOLID)) ) continue; /* overflow check */ diff --git a/tools/quake3/q3map2/patch.c b/tools/quake3/q3map2/patch.c index a1134db3..58b8ea20 100644 --- a/tools/quake3/q3map2/patch.c +++ b/tools/quake3/q3map2/patch.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake3/q3map2/path_init.c b/tools/quake3/q3map2/path_init.c index 80e3c6d3..186102b0 100644 --- a/tools/quake3/q3map2/path_init.c +++ b/tools/quake3/q3map2/path_init.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -200,19 +201,19 @@ void CleanPath( char *path ) /* -SetGame() - ydnar -sets the game based on a -game argument -doesn't set it if the game doesn't match any known games +GetGame() - ydnar +gets the game_t based on a -game argument +returns NULL if no match found */ -void SetGame( char *arg ) +game_t *GetGame( char *arg ) { int i; /* dummy check */ if( arg == NULL || arg[ 0 ] == '\0' ) - return; + return NULL; /* joke */ if( !Q_stricmp( arg, "quake1" ) || @@ -232,9 +233,12 @@ void SetGame( char *arg ) while( games[ i ].arg != NULL ) { if( Q_stricmp( arg, games[ i ].arg ) == 0 ) - game = &games[ i ]; + return &games[ i ]; i++; } + + /* no matching game */ + return NULL; } @@ -349,7 +353,9 @@ void InitPaths( int *argc, char **argv ) if( ++i >= *argc ) Error( "Out of arguments: No game specified after %s", argv[ i - 1 ] ); argv[ i - 1 ] = NULL; - SetGame( argv[ i ] ); + game = GetGame( argv[ i ] ); + if( game == NULL ) + game = &games[ 0 ]; argv[ i ] = NULL; } @@ -377,7 +383,7 @@ void InitPaths( int *argc, char **argv ) /* remove processed arguments */ for( i = 0, j = 0, k = 0; i < *argc && j < *argc; i++, j++ ) { - for( j; j < *argc && argv[ j ] == NULL; j++ ); + for( ; j < *argc && argv[ j ] == NULL; j++ ); argv[ i ] = argv[ j ]; if( argv[ i ] != NULL ) k++; diff --git a/tools/quake3/q3map2/portals.c b/tools/quake3/q3map2/portals.c index 59ed6daf..02209d54 100644 --- a/tools/quake3/q3map2/portals.c +++ b/tools/quake3/q3map2/portals.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake3/q3map2/prtfile.c b/tools/quake3/q3map2/prtfile.c index 43fcbb03..6f36f758 100644 --- a/tools/quake3/q3map2/prtfile.c +++ b/tools/quake3/q3map2/prtfile.c @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. diff --git a/tools/quake3/q3map2/q3map2.h b/tools/quake3/q3map2/q3map2.h index a1e27a0c..e79736f5 100644 --- a/tools/quake3/q3map2/q3map2.h +++ b/tools/quake3/q3map2/q3map2.h @@ -1,4 +1,5 @@ -/* +/* ------------------------------------------------------------------------------- + Copyright (C) 1999-2007 id Software, Inc. and contributors. For a list of contributors, see the accompanying CONTRIBUTORS file. @@ -34,8 +35,8 @@ several games based on the Quake III Arena engine, in the form of "Q3Map2." /* version */ -#define Q3MAP_VERSION "2.5.11" -#define Q3MAP_MOTD "A well-oiled toaster oven" +#define Q3MAP_VERSION "2.5.17" +#define Q3MAP_MOTD "Last one turns the lights off" @@ -56,7 +57,7 @@ dependencies #include #endif -#ifdef _WIN32 +#ifdef WIN32 #include #endif @@ -78,6 +79,7 @@ dependencies #include "inout.h" #include "vfs.h" #include "png.h" +#include "mhash.h" #include @@ -97,7 +99,7 @@ port-related hacks #endif #if 1 - #ifdef _WIN32 + #ifdef WIN32 #define Q_stricmp stricmp #define Q_strncasecmp strnicmp #else @@ -262,7 +264,7 @@ constants #define RAD_LUXEL_SIZE 3 #define SUPER_LUXEL_SIZE 4 #define SUPER_ORIGIN_SIZE 3 -#define SUPER_NORMAL_SIZE 3 +#define SUPER_NORMAL_SIZE 4 #define SUPER_DELUXEL_SIZE 3 #define BSP_DELUXEL_SIZE 3 @@ -271,11 +273,12 @@ constants #define BSP_LUXEL( s, x, y ) (lm->bspLuxels[ s ] + ((((y) * lm->w) + (x)) * BSP_LUXEL_SIZE)) #define RAD_LUXEL( s, x, y ) (lm->radLuxels[ s ] + ((((y) * lm->w) + (x)) * RAD_LUXEL_SIZE)) #define SUPER_LUXEL( s, x, y ) (lm->superLuxels[ s ] + ((((y) * lm->sw) + (x)) * SUPER_LUXEL_SIZE)) -#define SUPER_ORIGIN( x, y ) (lm->superOrigins + ((((y) * lm->sw) + (x)) * SUPER_ORIGIN_SIZE)) -#define SUPER_NORMAL( x, y ) (lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE)) -#define SUPER_CLUSTER( x, y ) (lm->superClusters + (((y) * lm->sw) + (x))) #define SUPER_DELUXEL( x, y ) (lm->superDeluxels + ((((y) * lm->sw) + (x)) * SUPER_DELUXEL_SIZE)) #define BSP_DELUXEL( x, y ) (lm->bspDeluxels + ((((y) * lm->w) + (x)) * BSP_DELUXEL_SIZE)) +#define SUPER_CLUSTER( x, y ) (lm->superClusters + (((y) * lm->sw) + (x))) +#define SUPER_ORIGIN( x, y ) (lm->superOrigins + ((((y) * lm->sw) + (x)) * SUPER_ORIGIN_SIZE)) +#define SUPER_NORMAL( x, y ) (lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE)) +#define SUPER_DIRT( x, y ) (lm->superNormals + ((((y) * lm->sw) + (x)) * SUPER_NORMAL_SIZE) + 3) /* stash dirtyness in normal[ 3 ] */ @@ -301,7 +304,7 @@ abstracted bsp file #define MAX_MAP_BRUSHES 0x8000 #define MAX_MAP_ENTITIES 0x1000 //% 0x800 /* ydnar */ #define MAX_MAP_ENTSTRING 0x80000 //% 0x40000 /* ydnar */ -#define MAX_MAP_SHADERS 0x400 +#define MAX_MAP_SHADERS 0x800 //% 0x400 /* ydnar */ #define MAX_MAP_AREAS 0x100 /* MAX_MAP_AREA_BYTES in q_shared must match! */ #define MAX_MAP_FOGS 30 //& 0x100 /* RBSP (32 - world fog - goggles) */ @@ -309,7 +312,7 @@ abstracted bsp file #define MAX_MAP_NODES 0x20000 #define MAX_MAP_BRUSHSIDES 0x100000 //% 0x20000 /* ydnar */ #define MAX_MAP_LEAFS 0x20000 -#define MAX_MAP_LEAFFACES 0x20000 +#define MAX_MAP_LEAFFACES 0x100000 //% 0x20000 /* ydnar */ #define MAX_MAP_LEAFBRUSHES 0x40000 #define MAX_MAP_PORTALS 0x20000 #define MAX_MAP_LIGHTING 0x800000 @@ -342,7 +345,7 @@ typedef void (*bspFunc)( const char * ); typedef struct { - int offset, length; + int offset, length; } bspLump_t; @@ -532,11 +535,18 @@ typedef struct game_s char *homeBasePath; /* home sub-dir on unix */ char *magic; /* magic word for figuring out base path */ char *shaderPath; /* shader directory */ - qboolean wolfLight; /* when true, lights work like wolf q3map */ + int maxLMSurfaceVerts; /* default maximum meta surface verts */ + int maxSurfaceVerts; /* default maximum surface verts */ + int maxSurfaceIndexes; /* default maximum surface indexes (tris * 3) */ qboolean emitFlares; /* when true, emit flare surfaces */ char *flareShader; /* default flare shader (MUST BE SET) */ + qboolean wolfLight; /* when true, lights work like wolf q3map */ + int lightmapSize; /* bsp lightmap width/height */ + float lightmapGamma; /* default lightmap gamma */ + float lightmapCompensate; /* default lightmap compensate value */ char *bspIdent; /* 4-letter bsp file prefix */ - int bspVersion; /* BSP version to use */ + int bspVersion; /* bsp version to use */ + qboolean lumpSwap; /* cod-style len/ofs order */ bspFunc load, write; /* load/write function pointers */ surfaceParm_t surfaceParms[ 128 ]; /* surfaceparm array */ } @@ -558,7 +568,7 @@ typedef struct sun_s struct sun_s *next; vec3_t direction, color; float photons, deviance, filterRadius; - int numSamples; + int numSamples, style; } sun_t; @@ -601,21 +611,32 @@ typedef struct remap_s remap_t; +/* wingdi.h hack, it's the same: 0 */ +#undef CM_NONE + typedef enum { - AM_NONE, - AM_DOT_PRODUCT + CM_NONE, + CM_VOLUME, + CM_COLOR_SET, + CM_ALPHA_SET, + CM_COLOR_SCALE, + CM_ALPHA_SCALE, + CM_COLOR_DOT_PRODUCT, + CM_ALPHA_DOT_PRODUCT, + CM_COLOR_DOT_PRODUCT_2, + CM_ALPHA_DOT_PRODUCT_2 } -alphaModType_t; +colorModType_t; -typedef struct alphaMod_s +typedef struct colorMod_s { - struct alphaMod_s *next; - alphaModType_t type; + struct colorMod_s *next; + colorModType_t type; vec_t data[ 16 ]; } -alphaMod_t; +colorMod_t; typedef enum @@ -636,10 +657,11 @@ typedef struct shaderInfo_s int compileFlags; float value; /* light value */ - char backShader[ MAX_QPATH ]; /* for surfaces that generate different front and back passes */ - char flareShader[ MAX_QPATH ]; /* for light flares */ - char cloneShader[ MAX_QPATH ]; /* ydnar: for cloning of a surface */ - char damageShader[ MAX_QPATH ]; /* ydnar: sof2 damage shader name */ + char *flareShader; /* for light flares */ + char *damageShader; /* ydnar: sof2 damage shader name */ + char *backShader; /* for surfaces that generate different front and back passes */ + char *cloneShader; /* ydnar: for cloning of a surface */ + char *remapShader; /* ydnar: remap a shader in final stage */ surfaceModel_t *surfaceModel; /* ydnar: for distribution of models */ foliage_t *foliage; /* ydnar/splash damage: wolf et foliage */ @@ -670,7 +692,7 @@ typedef struct shaderInfo_s vec3_t vecs[ 2 ]; /* ydnar: explicit texture vectors for [0,1] texture space */ tcMod_t mod; /* ydnar: q3map_tcMod matrix for djbob :) */ vec3_t lightmapAxis; /* ydnar: explicit lightmap axis projection */ - alphaMod_t *alphaMod; /* ydnar: q3map_alphaMod support */ + colorMod_t *colorMod; /* ydnar: q3map_rgb/color/alpha/Set/Mod support */ int furNumLayers; /* ydnar: number of fur layers */ float furOffset; /* ydnar: offset of each layer */ @@ -689,8 +711,8 @@ typedef struct shaderInfo_s qb_t notjunc; /* don't use this surface for tjunction fixing */ qb_t fogParms; /* ydnar: has fogparms */ qb_t noFog; /* ydnar: supress fogging */ - qb_t clipModel; /* ydnar: solid model hack */ + qb_t noVertexLight; /* ydnar: leave vertex color alone */ byte styleMarker; /* ydnar: light styles hack */ @@ -719,7 +741,7 @@ typedef struct shaderInfo_s qb_t lmMergable; /* ydnar */ int lmCustomWidth, lmCustomHeight; /* ydnar */ - float lmGamma; /* ydnar */ + float lmBrightness; /* ydnar */ float lmFilterRadius; /* ydnar: lightmap filtering/blurring radius for this shader (default: 0) */ int shaderWidth, shaderHeight; /* ydnar */ @@ -784,8 +806,6 @@ typedef struct side_s qboolean visible; /* choose visble planes first */ qboolean bevel; /* don't ever use for bsp splitting, and don't bother making windings for it */ - qboolean backSide; /* generated side for a q3map_backShader */ - qboolean culled; /* ydnar: face culling */ } side_t; @@ -813,6 +833,7 @@ indexMap_t; typedef struct brush_s { struct brush_s *next; + struct brush_s *nextColorModBrush; /* ydnar: colorMod volume brushes go here */ struct brush_s *original; /* chopped up brushes will reference the originals */ int entityNum, brushNum;/* editor numbering */ @@ -948,8 +969,11 @@ typedef struct mapDrawSurface_s qboolean fur; /* ydnar: this is kind of a hack, but hey... */ qboolean skybox; /* ydnar: yet another fun hack */ + qboolean backSide; /* ydnar: q3map_backShader support */ struct mapDrawSurface_s *parent; /* ydnar: for cloned (skybox) surfaces to share lighting data */ + struct mapDrawSurface_s *clone; /* ydnar: for cloned surfaces */ + struct mapDrawSurface_s *cel; /* ydnar: for cloned cel surfaces */ shaderInfo_t *shaderInfo; shaderInfo_t *celShader; @@ -1032,7 +1056,7 @@ epair_t; typedef struct { vec3_t origin; - brush_t *brushes, *lastBrush; + brush_t *brushes, *lastBrush, *colorModBrushes; parseMesh_t *patches; int mapEntityNum, firstDrawSurf; int firstBrush, numBrushes; /* only valid during BSP compile */ @@ -1274,6 +1298,7 @@ typedef struct vec3_t color; /* starts out at full color, may be reduced if transparent surfaces are crossed */ /* output */ + vec3_t hit; int compileFlags; /* for determining surface compile flags traced through */ qboolean passSolid; qboolean opaque; @@ -1335,7 +1360,7 @@ typedef struct rawLightmap_s { qboolean finished, splotchFix, wrap[ 2 ]; int customWidth, customHeight; - float gamma; + float brightness; float filterRadius; int firstLightSurface, numLightSurfaces; /* index into lightSurfaces */ @@ -1348,6 +1373,9 @@ typedef struct rawLightmap_s float *plane; int w, h, sw, sh, used; + qboolean solid[ MAX_LIGHTMAPS ]; + vec3_t solidColor[ MAX_LIGHTMAPS ]; + int numStyledTwins; struct rawLightmap_s *twins[ MAX_LIGHTMAPS ]; @@ -1409,6 +1437,7 @@ int ConvertMain( int argc, char **argv ); /* path_init.c */ +game_t *GetGame( char *arg ); void InitPaths( int *argc, char **argv ); @@ -1670,6 +1699,11 @@ void ColorToBytes( const float *color, byte *colorBytes, float scale ); void SmoothNormals( void ); void MapRawLightmap( int num ); + +void SetupDirt(); +float DirtForSample( trace_t *trace ); +void DirtyRawLightmap( int num ); + void IlluminateRawLightmap( int num ); void IlluminateVertexes( int num ); @@ -1705,14 +1739,14 @@ image_t *ImageLoad( const char *filename ); /* shaders.c */ -void AlphaMod( alphaMod_t *am, int numVerts, bspDrawVert_t *drawVerts ); +void ColorMod( colorMod_t *am, int numVerts, bspDrawVert_t *drawVerts ); -void TcMod( tcMod_t mod, float st[ 2 ] ); -void TcModIdentity( tcMod_t mod ); -void TcModMultiply( tcMod_t a, tcMod_t b, tcMod_t out ); -void TcModTranslate( tcMod_t mod, float s, float t ); -void TcModScale( tcMod_t mod, float s, float t ); -void TcModRotate( tcMod_t mod, float euler ); +void TCMod( tcMod_t mod, float st[ 2 ] ); +void TCModIdentity( tcMod_t mod ); +void TCModMultiply( tcMod_t a, tcMod_t b, tcMod_t out ); +void TCModTranslate( tcMod_t mod, float s, float t ); +void TCModScale( tcMod_t mod, float s, float t ); +void TCModRotate( tcMod_t mod, float euler ); qboolean ApplySurfaceParm( char *name, int *contentFlags, int *surfaceFlags, int *compileFlags ); @@ -1791,12 +1825,16 @@ Q_EXTERN game_t games[] { #include "game_quake3.h" , + #include "game_tremulous.h" /*LinuxManMikeC: must be after game_quake3.h, depends on #define's set in it */ + , #include "game_tenebrae.h" , #include "game_wolf.h" , #include "game_wolfet.h"/* most be after game_wolf.h as they share defines! */ , + #include "game_etut.h" + , #include "game_ef.h" , #include "game_sof2.h" @@ -1805,7 +1843,9 @@ Q_EXTERN game_t games[] , #include "game_ja.h" /* most be after game_jk2.h as they share defines! */ , - { NULL, NULL, NULL, NULL, NULL, qfalse, 0, 0, NULL } /* null game */ + #include "game_qfusion.h" /* qfusion game */ + , + { NULL } /* null game */ }; #endif Q_EXTERN game_t *game Q_ASSIGN( &games[ 0 ] ); @@ -1856,8 +1896,9 @@ Q_EXTERN qboolean skyFixHack Q_ASSIGN( qfalse ); /* ydnar */ Q_EXTERN int patchSubdivisions Q_ASSIGN( 8 ); /* ydnar: -patchmeta subdivisions */ -Q_EXTERN int maxSurfaceVerts Q_ASSIGN( 64 ); /* ydnar */ -Q_EXTERN int maxSurfaceIndexes Q_ASSIGN( 1000 ); /* ydnar */ +Q_EXTERN int maxLMSurfaceVerts Q_ASSIGN( 64 ); /* ydnar */ +Q_EXTERN int maxSurfaceVerts Q_ASSIGN( 999 ); /* ydnar */ +Q_EXTERN int maxSurfaceIndexes Q_ASSIGN( 6000 ); /* ydnar */ Q_EXTERN float npDegrees Q_ASSIGN( 0.0f ); /* ydnar: nonplanar degrees */ Q_EXTERN int bevelSnap Q_ASSIGN( 0 ); /* ydnar: bevel plane snap */ Q_EXTERN int texRange Q_ASSIGN( 0 ); @@ -2009,57 +2050,61 @@ light global variables ------------------------------------------------------------------------------- */ /* commandline arguments */ -Q_EXTERN qboolean noSurfaces; - -Q_EXTERN qboolean deluxemap; -Q_EXTERN qboolean debugDeluxemap; - +Q_EXTERN qboolean wolfLight Q_ASSIGN( qfalse ); Q_EXTERN qboolean loMem Q_ASSIGN( qfalse ); +Q_EXTERN qboolean noStyles Q_ASSIGN( qfalse ); -Q_EXTERN qboolean fast; -Q_EXTERN qboolean faster; -Q_EXTERN qboolean fastgrid; -Q_EXTERN qboolean fastbounce; -Q_EXTERN qboolean cheap; -Q_EXTERN qboolean cheapgrid; -Q_EXTERN qboolean smooth; -Q_EXTERN int bounce; -Q_EXTERN qboolean bounceOnly; -Q_EXTERN qboolean bouncing; -Q_EXTERN qboolean bouncegrid; -Q_EXTERN qboolean normalmap; -Q_EXTERN qboolean trisoup; -Q_EXTERN qboolean shade; +Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE ); +Q_EXTERN qboolean noVertexLighting Q_ASSIGN( qfalse ); +Q_EXTERN qboolean noGridLighting Q_ASSIGN( qfalse ); + +Q_EXTERN qboolean noTrace Q_ASSIGN( qfalse ); +Q_EXTERN qboolean noSurfaces Q_ASSIGN( qfalse ); +Q_EXTERN qboolean patchShadows Q_ASSIGN( qfalse ); +Q_EXTERN qboolean cpmaHack Q_ASSIGN( qfalse ); + +Q_EXTERN qboolean deluxemap Q_ASSIGN( qfalse ); +Q_EXTERN qboolean debugDeluxemap Q_ASSIGN( qfalse ); + +Q_EXTERN qboolean fast Q_ASSIGN( qfalse ); +Q_EXTERN qboolean faster Q_ASSIGN( qfalse ); +Q_EXTERN qboolean fastgrid Q_ASSIGN( qfalse ); +Q_EXTERN qboolean fastbounce Q_ASSIGN( qfalse ); +Q_EXTERN qboolean cheap Q_ASSIGN( qfalse ); +Q_EXTERN qboolean cheapgrid Q_ASSIGN( qfalse ); +Q_EXTERN int bounce Q_ASSIGN( 0 ); +Q_EXTERN qboolean bounceOnly Q_ASSIGN( qfalse ); +Q_EXTERN qboolean bouncing Q_ASSIGN( qfalse ); +Q_EXTERN qboolean bouncegrid Q_ASSIGN( qfalse ); +Q_EXTERN qboolean normalmap Q_ASSIGN( qfalse ); +Q_EXTERN qboolean trisoup Q_ASSIGN( qfalse ); +Q_EXTERN qboolean shade Q_ASSIGN( qfalse ); Q_EXTERN float shadeAngleDegrees Q_ASSIGN( 0.0f ); Q_EXTERN int superSample Q_ASSIGN( 0 ); Q_EXTERN int lightSamples Q_ASSIGN( 1 ); -Q_EXTERN qboolean filter; -Q_EXTERN qboolean sunOnly; +Q_EXTERN qboolean filter Q_ASSIGN( qfalse ); +Q_EXTERN qboolean dark Q_ASSIGN( qfalse ); +Q_EXTERN qboolean sunOnly Q_ASSIGN( qfalse ); Q_EXTERN int approximateTolerance Q_ASSIGN( 0 ); -Q_EXTERN qboolean noCollapse; -Q_EXTERN qboolean debug; -Q_EXTERN qboolean debugSurfaces; -Q_EXTERN qboolean debugUnused; -Q_EXTERN qboolean debugAxis; -Q_EXTERN qboolean debugCluster; -Q_EXTERN qboolean debugOrigin; -Q_EXTERN qboolean exportLightmaps; -Q_EXTERN qboolean externalLightmaps; +Q_EXTERN qboolean noCollapse Q_ASSIGN( qfalse ); +Q_EXTERN qboolean exportLightmaps Q_ASSIGN( qfalse ); +Q_EXTERN qboolean externalLightmaps Q_ASSIGN( qfalse ); Q_EXTERN int lmCustomSize Q_ASSIGN( LIGHTMAP_WIDTH ); -/* standard flags */ -Q_EXTERN qboolean noTrace; -Q_EXTERN qboolean patchShadows; -Q_EXTERN qboolean dump; -Q_EXTERN qboolean extra; -Q_EXTERN qboolean extraWide; -Q_EXTERN qboolean lightmapBorder; - -Q_EXTERN qboolean noSurfaces; - -Q_EXTERN int sampleSize Q_ASSIGN( DEFAULT_LIGHTMAP_SAMPLE_SIZE ); -Q_EXTERN qboolean noVertexLighting Q_ASSIGN( qfalse ); -Q_EXTERN qboolean noGridLighting Q_ASSIGN( qfalse ); +Q_EXTERN qboolean dirty Q_ASSIGN( qfalse ); +Q_EXTERN qboolean dirtDebug Q_ASSIGN( qfalse ); +Q_EXTERN int dirtMode Q_ASSIGN( 0 ); +Q_EXTERN float dirtDepth Q_ASSIGN( 128.0f ); +Q_EXTERN float dirtScale Q_ASSIGN( 1.0f ); +Q_EXTERN float dirtGain Q_ASSIGN( 1.0f ); + +Q_EXTERN qboolean dump Q_ASSIGN( qfalse ); +Q_EXTERN qboolean debug Q_ASSIGN( qfalse ); +Q_EXTERN qboolean debugUnused Q_ASSIGN( qfalse ); +Q_EXTERN qboolean debugAxis Q_ASSIGN( qfalse ); +Q_EXTERN qboolean debugCluster Q_ASSIGN( qfalse ); +Q_EXTERN qboolean debugOrigin Q_ASSIGN( qfalse ); +Q_EXTERN qboolean lightmapBorder Q_ASSIGN( qfalse ); /* longest distance across the map */ Q_EXTERN float maxMapDistance Q_ASSIGN( 0 ); @@ -2070,13 +2115,14 @@ Q_EXTERN float areaScale Q_ASSIGN( 0.25f ); Q_EXTERN float skyScale Q_ASSIGN( 1.0f ); Q_EXTERN float bounceScale Q_ASSIGN( 0.25f ); +/* ydnar: lightmap gamma/compensation */ +Q_EXTERN float lightmapGamma Q_ASSIGN( 1.0f ); +Q_EXTERN float lightmapCompensate Q_ASSIGN( 1.0f ); + /* ydnar: for runtime tweaking of falloff tolerance */ Q_EXTERN float falloffTolerance Q_ASSIGN( 1.0f ); - Q_EXTERN qboolean exactPointToPolygon Q_ASSIGN( qtrue ); - Q_EXTERN float formFactorValueScale Q_ASSIGN( 3.0f ); - Q_EXTERN float linearScale Q_ASSIGN( 1.0f / 8000.0f ); Q_EXTERN light_t *lights; @@ -2169,6 +2215,7 @@ Q_EXTERN float *radVertexLuxels[ MAX_LIGHTMAPS ]; /* bsp lightmaps */ Q_EXTERN int numLightmapShaders Q_ASSIGN( 0 ); +Q_EXTERN int numSolidLightmaps Q_ASSIGN( 0 ); Q_EXTERN int numOutLightmaps Q_ASSIGN( 0 ); Q_EXTERN int numBSPLightmaps Q_ASSIGN( 0 ); Q_EXTERN int numExtLightmaps Q_ASSIGN( 0 ); diff --git a/tools/quake3/q3map2/q3map2.vcproj b/tools/quake3/q3map2/q3map2.vcproj index a3a45dae..31e947e6 100644 --- a/tools/quake3/q3map2/q3map2.vcproj +++ b/tools/quake3/q3map2/q3map2.vcproj @@ -40,7 +40,7 @@ next ) + /* walk colorMod list */ + for( cm2 = cm; cm2 != NULL; cm2 = cm2->next ) { + /* default */ + VectorSet( mult, 1.0f, 1.0f, 1.0f ); + mult[ 3 ] = 1.0f; + VectorSet( add, 0.0f, 0.0f, 0.0f ); + mult[ 3 ] = 0.0f; + /* switch on type */ - switch( am->type ) + switch( cm2->type ) { - case AM_DOT_PRODUCT: - mult = DotProduct( dv->normal, am2->data ); - add = 0.0f; + case CM_COLOR_SET: + VectorClear( mult ); + VectorScale( cm2->data, 255.0f, add ); + break; + + case CM_ALPHA_SET: + mult[ 3 ] = 0.0f; + add[ 3 ] = cm2->data[ 0 ] * 255.0f; + break; + + case CM_COLOR_SCALE: + VectorCopy( cm2->data, mult ); + break; + + case CM_ALPHA_SCALE: + mult[ 3 ] = cm2->data[ 0 ]; + break; + + case CM_COLOR_DOT_PRODUCT: + c = DotProduct( dv->normal, cm2->data ); + VectorSet( mult, c, c, c ); + break; + + case CM_ALPHA_DOT_PRODUCT: + mult[ 3 ] = DotProduct( dv->normal, cm2->data ); + break; + + case CM_COLOR_DOT_PRODUCT_2: + c = DotProduct( dv->normal, cm2->data ); + c *= c; + VectorSet( mult, c, c, c ); + break; + + case CM_ALPHA_DOT_PRODUCT_2: + mult[ 3 ] = DotProduct( dv->normal, cm2->data ); + mult[ 3 ] *= mult[ 3 ]; break; default: - mult = 1.0f; - add = 0.0f; break; } /* apply mod */ for( j = 0; j < MAX_LIGHTMAPS; j++ ) { - a = (mult * dv->color[ j ][ 3 ]) + add; - if( a < 0 ) - a = 0; - else if( a > 255 ) - a = 255; - dv->color[ j ][ 3 ] = a; + for( k = 0; k < 4; k++ ) + { + c = (mult[ k ] * dv->color[ j ][ k ]) + add[ k ]; + if( c < 0 ) + c = 0; + else if( c > 255 ) + c = 255; + dv->color[ j ][ k ] = c; + } } } } @@ -95,11 +137,11 @@ void AlphaMod( alphaMod_t *am, int numVerts, bspDrawVert_t *drawVerts ) /* -TcMod*() +TCMod*() routines for dealing with a 3x3 texture mod matrix */ -void TcMod( tcMod_t mod, float st[ 2 ] ) +void TCMod( tcMod_t mod, float st[ 2 ] ) { float old[ 2 ]; @@ -111,7 +153,7 @@ void TcMod( tcMod_t mod, float st[ 2 ] ) } -void TcModIdentity( tcMod_t mod ) +void TCModIdentity( tcMod_t mod ) { mod[ 0 ][ 0 ] = 1.0f; mod[ 0 ][ 1 ] = 0.0f; mod[ 0 ][ 2 ] = 0.0f; mod[ 1 ][ 0 ] = 0.0f; mod[ 1 ][ 1 ] = 1.0f; mod[ 1 ][ 2 ] = 0.0f; @@ -119,7 +161,7 @@ void TcModIdentity( tcMod_t mod ) } -void TcModMultiply( tcMod_t a, tcMod_t b, tcMod_t out ) +void TCModMultiply( tcMod_t a, tcMod_t b, tcMod_t out ) { int i; @@ -133,28 +175,28 @@ void TcModMultiply( tcMod_t a, tcMod_t b, tcMod_t out ) } -void TcModTranslate( tcMod_t mod, float s, float t ) +void TCModTranslate( tcMod_t mod, float s, float t ) { mod[ 0 ][ 2 ] += s; mod[ 1 ][ 2 ] += t; } -void TcModScale( tcMod_t mod, float s, float t ) +void TCModScale( tcMod_t mod, float s, float t ) { mod[ 0 ][ 0 ] *= s; mod[ 1 ][ 1 ] *= t; } -void TcModRotate( tcMod_t mod, float euler ) +void TCModRotate( tcMod_t mod, float euler ) { tcMod_t old, temp; float radians, sinv, cosv; memcpy( old, mod, sizeof( tcMod_t ) ); - TcModIdentity( temp ); + TCModIdentity( temp ); radians = euler / 180 * Q_PI; sinv = sin( radians ); @@ -163,7 +205,7 @@ void TcModRotate( tcMod_t mod, float euler ) temp[ 0 ][ 0 ] = cosv; temp[ 0 ][ 1 ] = -sinv; temp[ 1 ][ 0 ] = sinv; temp[ 1 ][ 1 ] = cosv; - TcModMultiply( old, temp, mod ); + TCModMultiply( old, temp, mod ); } @@ -365,7 +407,7 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ) char shader[ MAX_QPATH ]; char *s; int loc; - md5_state_t md5; + MHASH mh; byte digest[ 16 ]; char *srcShaderText, temp[ 8192 ], shaderText[ 8192 ]; /* ydnar: fixme (make this bigger?) */ @@ -487,9 +529,11 @@ shaderInfo_t *CustomShader( shaderInfo_t *si, char *find, char *replace ) } /* make md5 hash of the shader text */ - md5_init( &md5 ); - md5_append( &md5, shaderText, strlen( shaderText ) ); - md5_finish( &md5, digest ); + mh = mhash_init( MHASH_MD5 ); + if( !mh ) + Error( "Unable to initialize MD5 hash context" ); + mhash( mh, shaderText, strlen( shaderText ) ); + mhash_deinit( mh, digest ); /* mangle hash into a shader name */ sprintf( shader, "%s/%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X%02X", mapName, @@ -525,7 +569,7 @@ adds a vertexremapshader key/value pair to worldspawn void EmitVertexRemapShader( char *from, char *to ) { - md5_state_t md5; + MHASH mh; byte digest[ 16 ]; char key[ 64 ], value[ 256 ]; @@ -539,9 +583,11 @@ void EmitVertexRemapShader( char *from, char *to ) sprintf( value, "%s;%s", from, to ); /* make md5 hash */ - md5_init( &md5 ); - md5_append( &md5, value, strlen( value ) ); - md5_finish( &md5, digest ); + mh = mhash_init( MHASH_MD5 ); + if( !mh ) + Error( "Unable to initialize MD5 hash context" ); + mhash( mh, value, strlen( value ) ); + mhash_deinit( mh, digest ); /* make key (this is annoying, as vertexremapshader is precisely 17 characters, which is one too long, so we leave off the last byte of the md5 digest) */ @@ -603,11 +649,11 @@ static shaderInfo_t *AllocShaderInfo( void ) si->notjunc = qfalse; /* ydnar: set texture coordinate transform matrix to identity */ - TcModIdentity( si->mod ); + TCModIdentity( si->mod ); - /* ydnar: lightmaps can now be > 128x128 in an externally generated tga */ - si->lmCustomWidth = lmCustomSize; //% LIGHTMAP_WIDTH; - si->lmCustomHeight = lmCustomSize; //% LIGHTMAP_HEIGHT; + /* ydnar: lightmaps can now be > 128x128 in certain games or an externally generated tga */ + si->lmCustomWidth = lmCustomSize; + si->lmCustomHeight = lmCustomSize; /* return to sender */ return si; @@ -783,7 +829,7 @@ shaderInfo_t *ShaderInfoForShader( const char *shaderName ) if( !Q_stricmp( shader, si->shader ) ) { /* load image if necessary */ - if( si->shaderImage == NULL ) + if( si->finished == qfalse ) { LoadShaderImages( si ); FinishShader( si ); @@ -1078,17 +1124,21 @@ static void ParseShaderFile( const char *filename ) else if( !Q_stricmp( token, "light" ) ) { GetTokenAppend( shaderText, qfalse ); - strcpy( si->flareShader, "flareshader" ); + si->flareShader = game->flareShader; } /* ydnar: damageShader (sof2 mods) */ else if( !Q_stricmp( token, "damageShader" ) ) { GetTokenAppend( shaderText, qfalse ); - strcpy( si->damageShader, token ); + if( token[ 0 ] != '\0' ) + { + si->damageShader = safe_malloc( strlen( token ) + 1 ); + strcpy( si->damageShader, token ); + } GetTokenAppend( shaderText, qfalse ); /* don't do anything with health */ } - + /* ydnar: enemy territory implicit shaders */ else if( !Q_stricmp( token, "implicitMap" ) ) { @@ -1194,6 +1244,9 @@ static void ParseShaderFile( const char *filename ) sun = safe_malloc( sizeof( *sun ) ); memset( sun, 0, sizeof( *sun ) ); + /* set style */ + sun->style = si->lightStyle; + /* get color */ GetTokenAppend( shaderText, qfalse ); sun->color[ 0 ] = atof( token ); @@ -1276,6 +1329,8 @@ static void ParseShaderFile( const char *filename ) /* restore name and set to unfinished */ strcpy( si->shader, temp ); + si->shaderWidth = 0; + si->shaderHeight = 0; si->finished = qfalse; } } @@ -1348,8 +1403,8 @@ static void ParseShaderFile( const char *filename ) si->bounceScale = atof( token ); } - /* ydnar/splashdamage: q3map_skylight */ - else if( !Q_stricmp( token, "q3map_skylight" ) ) + /* ydnar/splashdamage: q3map_skyLight */ + else if( !Q_stricmp( token, "q3map_skyLight" ) ) { GetTokenAppend( shaderText, qfalse ); si->skyLightValue = atof( token ); @@ -1370,7 +1425,6 @@ static void ParseShaderFile( const char *filename ) si->value = atof( token ); } - /* q3map_lightStyle (sof2/jk2 lightstyle) */ else if( !Q_stricmp( token, "q3map_lightStyle" ) ) { @@ -1466,18 +1520,18 @@ static void ParseShaderFile( const char *filename ) { Sys_Printf( "WARNING: Non power-of-two lightmap size specified (%d, %d)\n", si->lmCustomWidth, si->lmCustomHeight ); - si->lmCustomWidth = LIGHTMAP_WIDTH; - si->lmCustomHeight = LIGHTMAP_HEIGHT; + si->lmCustomWidth = lmCustomSize; + si->lmCustomHeight = lmCustomSize; } } - /* ydnar: q3map_lightmapGamma N (for autogenerated shaders + external tga lightmaps) */ - else if( !Q_stricmp( token, "q3map_lightmapGamma" ) ) + /* ydnar: q3map_lightmapBrightness N (for autogenerated shaders + external tga lightmaps) */ + else if( !Q_stricmp( token, "q3map_lightmapBrightness" ) || !Q_stricmp( token, "q3map_lightmapGamma" ) ) { GetTokenAppend( shaderText, qfalse ); - si->lmGamma = atof( token ); - if( si->lmGamma < 0 ) - si->lmGamma = 1.0; + si->lmBrightness = atof( token ); + if( si->lmBrightness < 0 ) + si->lmBrightness = 1.0; } /* q3map_vertexScale (scale vertex lighting by this fraction) */ @@ -1487,32 +1541,61 @@ static void ParseShaderFile( const char *filename ) si->vertexScale = atof( token ); } - /* q3map_flare */ + /* q3map_noVertexLight */ + else if( !Q_stricmp( token, "q3map_noVertexLight" ) ) + { + si->noVertexLight = qtrue; + } + + /* q3map_flare[Shader] */ else if( !Q_stricmp( token, "q3map_flare" ) || !Q_stricmp( token, "q3map_flareShader" ) ) { GetTokenAppend( shaderText, qfalse ); - strcpy( si->flareShader, token ); + if( token[ 0 ] != '\0' ) + { + si->flareShader = safe_malloc( strlen( token ) + 1 ); + strcpy( si->flareShader, token ); + } } /* q3map_backShader */ else if( !Q_stricmp( token, "q3map_backShader" ) ) { GetTokenAppend( shaderText, qfalse ); - strcpy( si->backShader, token ); + if( token[ 0 ] != '\0' ) + { + si->backShader = safe_malloc( strlen( token ) + 1 ); + strcpy( si->backShader, token ); + } } - /* ydnar: q3map_offset */ - else if( !Q_stricmp( token, "q3map_offset" ) ) + /* ydnar: q3map_cloneShader */ + else if ( !Q_stricmp( token, "q3map_cloneShader" ) ) { GetTokenAppend( shaderText, qfalse ); - si->offset = atof( token ); + if( token[ 0 ] != '\0' ) + { + si->cloneShader = safe_malloc( strlen( token ) + 1 ); + strcpy( si->cloneShader, token ); + } } - /* ydnar: q3map_cloneShader */ - else if ( !Q_stricmp( token, "q3map_cloneShader" ) ) + /* q3map_remapShader */ + else if( !Q_stricmp( token, "q3map_remapShader" ) ) + { + GetTokenAppend( shaderText, qfalse ); + if( token[ 0 ] != '\0' ) + { + si->remapShader = safe_malloc( strlen( token ) + 1 ); + strcpy( si->remapShader, token ); + } + } + + /* ydnar: q3map_offset */ + else if( !Q_stricmp( token, "q3map_offset" ) ) { GetTokenAppend( shaderText, qfalse ); - strcpy( si->cloneShader, token ); + si->offset = atof( token ); } /* ydnar: q3map_textureSize (substitute for q3map_lightimage derivation for terrain) */ @@ -1595,26 +1678,32 @@ static void ParseShaderFile( const char *filename ) } } - /* ydnar: gs mods: q3map_alphaMod