]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge commit 'b681f28130ff2e9789253eff1c1d41163e427eaa' into master-merge
authorThomas Debesse <dev@illwieckz.net>
Mon, 20 Jun 2022 02:39:42 +0000 (04:39 +0200)
committerThomas Debesse <dev@illwieckz.net>
Mon, 20 Jun 2022 02:39:42 +0000 (04:39 +0200)
radiant/environment.cpp
radiant/mainframe.cpp
radiant/map.cpp
radiant/texwindow.cpp
tools/quake3/q3map2/bspfile_abstract.c
tools/quake3/q3map2/light_bounce.c
tools/quake3/q3map2/lightmaps_ydnar.c
tools/quake3/q3map2/q3map2.h
tools/quake3/q3map2/shaders.c
tools/quake3/q3map2/surface_meta.c

index f2315b85a743960d7acb2c5354c982f97916f5ff..e7b48a6bf188d763cebc1fc26f00ece80e3e105f 100644 (file)
@@ -110,7 +110,8 @@ bool gamedetect_check_game( char const *gamefile, const char *checkfile1, const
 void gamedetect(){
        // if we're inside a Nexuiz install
        // default to nexuiz.game (unless the user used an option to inhibit this)
-       bool nogamedetect = false;
+       //bool nogamedetect = false;
+       bool nogamedetect = true;
        int i;
        for ( i = 1; i < g_argc - 1; ++i )
        {
index 1bea47d16daa80c47f0b4ca559b64d8e9871ba7b..84ab042c1bcf94e39487b28e1ba4f2ba2ba3db08 100644 (file)
@@ -630,8 +630,10 @@ ui::Window BuildDialog(){
 
 PathsDialog g_PathsDialog;
 
+bool g_strEnginePath_was_empty_1st_start = false;
+
 void EnginePath_verify(){
-       if ( !file_exists( g_strEnginePath.c_str() ) ) {
+       if ( !file_exists( g_strEnginePath.c_str() ) || g_strEnginePath_was_empty_1st_start ) {
                g_PathsDialog.Create();
                g_PathsDialog.DoModal();
                g_PathsDialog.Destroy();
@@ -3088,9 +3090,9 @@ void MainFrame::Create(){
                        vbox.pack_start( hsplit, TRUE, TRUE, 0 );
                        hsplit.show();
                        {
-                       ui::Widget vsplit = ui::VPaned(ui::New);
+                               ui::Widget vsplit = ui::VPaned(ui::New);
                                vsplit.show();
-                       m_vSplit = vsplit;
+                               m_vSplit = vsplit;
                                ui::Widget vsplit2 = ui::VPaned(ui::New);
                                vsplit2.show();
                                m_vSplit = vsplit2;
@@ -3103,10 +3105,10 @@ void MainFrame::Create(){
                                        gtk_paned_add1( GTK_PANED( hsplit ), vsplit2 );
                                }
 
-                       // console
-                       ui::Widget console_window = Console_constructWindow( window );
-                       gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, TRUE );
-
+                               // console
+                               ui::Widget console_window = Console_constructWindow( window );
+                               gtk_paned_pack2( GTK_PANED( vsplit ), console_window, FALSE, TRUE );
+                               
                                // xy
                                m_pXYWnd = new XYWnd();
                                m_pXYWnd->SetViewType( XY );
@@ -3668,7 +3670,10 @@ void MainFrame_Construct(){
        GlobalPreferenceSystem().registerPreference( "YZWnd", make_property<WindowPositionTracker_String>(g_posYZWnd) );
        GlobalPreferenceSystem().registerPreference( "XZWnd", make_property<WindowPositionTracker_String>(g_posXZWnd) );
 
+       GlobalPreferenceSystem().registerPreference( "EnginePath", make_property_string( g_strEnginePath ) );
+       if ( g_strEnginePath.empty() )
        {
+               g_strEnginePath_was_empty_1st_start = true;
                const char* ENGINEPATH_ATTRIBUTE =
 #if GDEF_OS_WINDOWS
                        "enginepath_win32"
@@ -3685,10 +3690,9 @@ void MainFrame_Construct(){
                path << DirectoryCleaned( g_pGameDescription->getRequiredKeyValue( ENGINEPATH_ATTRIBUTE ) );
 
                g_strEnginePath = transformPath( path.c_str() ).c_str();
+               GlobalPreferenceSystem().registerPreference( "EnginePath", make_property_string( g_strEnginePath ) );
        }
 
-       GlobalPreferenceSystem().registerPreference( "EnginePath", make_property_string( g_strEnginePath ) );
-
        GlobalPreferenceSystem().registerPreference( "DisableEnginePath", make_property_string( g_disableEnginePath ) );
        GlobalPreferenceSystem().registerPreference( "DisableHomePath", make_property_string( g_disableHomePath ) );
 
index a5ac53f899e63e2a27e863482a12091851efd4ce..b8c727ba3d8e87bf6f6b833013fca1b10f099a2b 100644 (file)
@@ -1681,21 +1681,19 @@ bool Map_SaveSelected( const char* filename ){
        return MapResource_saveFile( MapFormat_forFile( filename ), GlobalSceneGraph().root(), Map_Traverse_Selected, filename );
 }
 
-
 class ParentSelectedBrushesToEntityWalker : public scene::Graph::Walker
 {
-scene::Node& m_parent;
+       scene::Node& m_parent;
+       mutable bool m_emptyOldParent;
+
 public:
-ParentSelectedBrushesToEntityWalker( scene::Node& parent ) : m_parent( parent ){
+ParentSelectedBrushesToEntityWalker( scene::Node& parent ) : m_parent( parent ), m_emptyOldParent( false ){
 }
 
 bool pre( const scene::Path& path, scene::Instance& instance ) const {
-       if ( path.top().get_pointer() != &m_parent
-                && Node_isPrimitive( path.top() ) ) {
+       if ( path.top().get_pointer() != &m_parent && ( Node_isPrimitive( path.top() ) || m_emptyOldParent ) ) {
                Selectable* selectable = Instance_getSelectable( instance );
-               if ( selectable != 0
-                        && selectable->isSelected()
-                        && path.size() > 1 ) {
+               if ( selectable && selectable->isSelected() && path.size() > 1 ) {
                        return false;
                }
        }
@@ -1703,20 +1701,33 @@ bool pre( const scene::Path& path, scene::Instance& instance ) const {
 }
 
 void post( const scene::Path& path, scene::Instance& instance ) const {
-       if ( path.top().get_pointer() != &m_parent
-                && Node_isPrimitive( path.top() ) ) {
+       if ( path.top().get_pointer() == &m_parent )
+               return;
+
+       if ( Node_isPrimitive( path.top() ) ){
+               m_emptyOldParent = false;
                Selectable* selectable = Instance_getSelectable( instance );
-               if ( selectable != 0
-                        && selectable->isSelected()
-                        && path.size() > 1 ) {
+
+               if ( selectable && selectable->isSelected() && path.size() > 1 ){
                        scene::Node& parent = path.parent();
-                       if ( &parent != &m_parent ) {
+                       if ( &parent != &m_parent ){
                                NodeSmartReference node( path.top().get() );
-                               Node_getTraversable( parent )->erase( node );
+                               scene::Traversable* traversable_parent = Node_getTraversable( parent );
+                               traversable_parent->erase( node );
                                Node_getTraversable( m_parent )->insert( node );
+                               if ( traversable_parent->empty() )
+                                       m_emptyOldParent = true;
                        }
                }
        }
+       else if ( m_emptyOldParent ){
+               m_emptyOldParent = false;
+               // delete empty entities
+               Entity* entity = Node_getEntity( path.top() );
+               if ( entity != 0 && path.top().get_pointer() != Map_FindWorldspawn( g_map )     && Node_getTraversable( path.top() )->empty() ) {
+                       Path_deleteTop( path );
+               }
+       }
 }
 };
 
index 6640b97e7b04b873fb8d9ece04b4df78f5e9aca8..edfe4bc7562ee7e96501b38a3321f629bd0c99ff 100644 (file)
@@ -347,11 +347,11 @@ int m_uniformTextureMinSize;
                else if ( tex->width <= m_uniformTextureMinSize ){
                        *width = m_uniformTextureMinSize;
                        *height = (int)( m_uniformTextureMinSize * ( (float)tex->height / tex->width ) );
-       }
-       else {
+               }
+               else {
                        *width = tex->width;
                        *height = tex->height;
-       }
+               }
        }
        else {
                // Texture taller than it is wide
@@ -371,34 +371,32 @@ int m_uniformTextureMinSize;
 }
 
 */
-void getTextureWH( qtexture_t* tex, int *width, int *height ){
+void getTextureWH( qtexture_t* tex, int &W, int &H ){
                // Don't use uniform size
-               *width = (int)( tex->width * ( (float)m_textureScale / 100 ) );
-               *height = (int)( tex->height * ( (float)m_textureScale / 100 ) );
+               W = (int)( tex->width * ( (float)m_textureScale / 100 ) );
+               H = (int)( tex->height * ( (float)m_textureScale / 100 ) );
 
        if ( g_TextureBrowser_fixedSize ){
-               int W = *width;
-               int H = *height;
                if      ( W >= H ) {
                        // Texture is square, or wider than it is tall
                        if ( W >= m_uniformTextureSize ){
-                               *width = m_uniformTextureSize;
-                               *height = m_uniformTextureSize * H / W;
-       }
+                               H = m_uniformTextureSize * H / W;
+                               W = m_uniformTextureSize;
+                       }
                        else if ( W <= m_uniformTextureMinSize ){
-                               *width = m_uniformTextureMinSize;
-                               *height = m_uniformTextureMinSize * H / W;
+                               H = m_uniformTextureMinSize * H / W;
+                               W = m_uniformTextureMinSize;
                        }
-       }
-       else {
+               }
+               else {
                        // Texture taller than it is wide
                        if ( H >= m_uniformTextureSize ){
-                               *height = m_uniformTextureSize;
-                               *width = m_uniformTextureSize * W / H;
-       }
+                               W = m_uniformTextureSize * W / H;
+                               H = m_uniformTextureSize;
+                       }
                        else if ( H <= m_uniformTextureMinSize ){
-                               *height = m_uniformTextureMinSize;
-                               *width = m_uniformTextureMinSize * W / H;
+                               W = m_uniformTextureMinSize * W / H;
+                               H = m_uniformTextureMinSize;
                        }
                }
        }
@@ -529,7 +527,7 @@ void Texture_NextPos( TextureBrowser& textureBrowser, TextureLayout& layout, qte
        qtexture_t* q = current_texture;
 
        int nWidth, nHeight;
-       textureBrowser.getTextureWH( q, &nWidth, &nHeight );
+       textureBrowser.getTextureWH( q, nWidth, nHeight );
        if ( layout.current_x + nWidth > textureBrowser.width - 8 && layout.current_row ) { // go to the next row unless the texture is the first on the row
                layout.current_x = 8;
                layout.current_y -= layout.current_row + TextureBrowser_fontHeight( textureBrowser ) + 4;
@@ -659,7 +657,7 @@ void TextureBrowser_evaluateHeight( TextureBrowser& textureBrowser ){
                        int x, y;
                        Texture_NextPos( textureBrowser, layout, shader->getTexture(), &x, &y );
                        int nWidth, nHeight;
-                       textureBrowser.getTextureWH( shader->getTexture(), &nWidth, &nHeight );
+                       textureBrowser.getTextureWH( shader->getTexture(), nWidth, nHeight );
                        textureBrowser.m_nTotalHeight = std::max( textureBrowser.m_nTotalHeight, abs( layout.current_y ) + TextureBrowser_fontHeight( textureBrowser ) + nHeight + 4 );
                }
        }
@@ -1126,7 +1124,7 @@ IShader* Texture_At( TextureBrowser& textureBrowser, int mx, int my ){
                }
 
                int nWidth, nHeight;
-               textureBrowser.getTextureWH( q, &nWidth, &nHeight );
+               textureBrowser.getTextureWH( q, nWidth, nHeight );
                if ( mx > x && mx - x < nWidth
                         && my < y && y - my < nHeight + TextureBrowser_fontHeight( textureBrowser ) ) {
                        return shader;
@@ -1264,7 +1262,7 @@ void Texture_Draw( TextureBrowser& textureBrowser ){
                }
 
                int nWidth, nHeight;
-               textureBrowser.getTextureWH( q, &nWidth, &nHeight );
+               textureBrowser.getTextureWH( q, nWidth, nHeight );
 
                if ( y != last_y ) {
                        last_y = y;
index db3a46bb6f0e6ca5a30f26a758408dc5c2cf6547..55d358f0e69b65c9d5aa859bcb5036f12beb3d98 100644 (file)
@@ -68,14 +68,19 @@ void IncDrawVerts(){
 
        }
        else if ( numBSPDrawVerts > numBSPDrawVertsBuffer ) {
+               bspDrawVert_t *newBspDrawVerts;
+
                numBSPDrawVertsBuffer *= 3; // multiply by 1.5
                numBSPDrawVertsBuffer /= 2;
 
-               bspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer );
+               newBspDrawVerts = realloc( bspDrawVerts, sizeof( bspDrawVert_t ) * numBSPDrawVertsBuffer );
 
-               if ( !bspDrawVerts ) {
+               if ( !newBspDrawVerts ) {
+                       free (bspDrawVerts);
                        Error( "realloc() failed (IncDrawVerts)" );
                }
+
+               bspDrawVerts = newBspDrawVerts;
        }
 
        memset( bspDrawVerts + ( numBSPDrawVerts - 1 ), 0, sizeof( bspDrawVert_t ) );
index 18d1f0a4c236650d2de4e718fe58ca581efdde24..7858116d84a41a71ed58a26f100a2101f0f97b8e 100644 (file)
@@ -185,10 +185,10 @@ static void RadClipWindingEpsilon( radWinding_t *in, vec3_t normal, vec_t dist,
        }
 
        /* error check */
-       if ( front->numVerts > maxPoints || front->numVerts > maxPoints ) {
+       if ( front->numVerts > maxPoints ) {
                Error( "RadClipWindingEpsilon: points exceeded estimate" );
        }
-       if ( front->numVerts > MAX_POINTS_ON_WINDING || front->numVerts > MAX_POINTS_ON_WINDING ) {
+       if ( front->numVerts > MAX_POINTS_ON_WINDING ) {
                Error( "RadClipWindingEpsilon: MAX_POINTS_ON_WINDING" );
        }
 }
@@ -295,7 +295,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm,
                        /* multiply by texture color */
                        if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, rw->verts[ samples ].st, textureColor ) ) {
                                VectorCopy( si->averageColor, textureColor );
-                               textureColor[ 4 ] = 255.0f;
+                               textureColor[ 3 ] = 255.0f;
                        }
                        avgcolor = ( textureColor[ 0 ] + textureColor[ 1 ] + textureColor[ 2 ] ) / 3;
                        for ( i = 0; i < 3; i++ )
@@ -381,7 +381,7 @@ static void RadSample( int lightmapNum, bspDrawSurface_t *ds, rawLightmap_t *lm,
                                                /* multiply by texture color */
                                                if ( !RadSampleImage( si->lightImage->pixels, si->lightImage->width, si->lightImage->height, st, textureColor ) ) {
                                                        VectorCopy( si->averageColor, textureColor );
-                                                       textureColor[ 4 ] = 255;
+                                                       textureColor[ 3 ] = 255;
                                                }
                                                avgcolor = ( textureColor[ 0 ] + textureColor[ 1 ] + textureColor[ 2 ] ) / 3;
                                                for ( l = 0; l < 3; l++ ){
index 7afb86a46633852d911973fa5fed0a48f3ce854d..3c08c8b60d13c1223ba795bdf08a556121300bf1 100644 (file)
@@ -2173,6 +2173,10 @@ static void FindOutLightmaps( rawLightmap_t *lm, qboolean fastAllocate ){
                        /* allocate LIGHTMAP_RESERVE_COUNT new output lightmaps */
                        numOutLightmaps += LIGHTMAP_RESERVE_COUNT;
                        olm = safe_malloc( numOutLightmaps * sizeof( outLightmap_t ) );
+                       if ( !olm ){
+                               Error( "FindOutLightmaps: Failed to allocate memory.\n" );
+                       }
+
                        if ( outLightmaps != NULL && numOutLightmaps > LIGHTMAP_RESERVE_COUNT ) {
                                memcpy( olm, outLightmaps, ( numOutLightmaps - LIGHTMAP_RESERVE_COUNT ) * sizeof( outLightmap_t ) );
                                free( outLightmaps );
index 7f0582e249820c4513110f4a6574273dd1423515..e48d6a7be774da211fa9ac086e72c3ebc7cb89b9 100644 (file)
@@ -810,7 +810,7 @@ typedef struct shaderInfo_s
        sun_t               *sun;                           /* ydnar */
 
        vec3_t color;                                       /* normalized color */
-       vec3_t averageColor;
+       vec4_t averageColor;
        byte lightStyle;
 
        /* vortex: per-surface floodlight */
index 22c7b9b22beea97f82c1bbef746ce5a8d1c8392e..cfa0db86047362e2777b73bf949bf9e1c1c60e2f 100644 (file)
@@ -811,10 +811,12 @@ static void LoadShaderImages( shaderInfo_t *si ){
        if ( VectorLength( si->color ) <= 0.0f ) {
                ColorNormalize( color, si->color );
                VectorScale( color, ( 1.0f / count ), si->averageColor );
+               si->averageColor[ 3 ] = color[ 3 ] / count;
        }
        else
        {
                VectorCopy( si->color, si->averageColor );
+               si->averageColor[ 3 ] = 1.0f;
        }
 }
 
index 2cd6f0374e8b2aea6189facca07a1dcaf7ae7e7b..d7af5374fa7859bd9516d52521d8de86a06c99f9 100644 (file)
@@ -962,7 +962,8 @@ void MakeEntityMetaTriangles( entity_t *e ){
 
 typedef struct edge_s
 {
-       vec3_t origin, edge;
+       vec3_t origin;
+       vec4_t edge;
        vec_t length, kingpinLength;
        int kingpin;
        vec4_t plane;