]> de.git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Merge branch 'Mario/winfix' into 'master'
authorTimePath <andrew.hardaker1995@gmail.com>
Thu, 3 May 2018 09:52:10 +0000 (09:52 +0000)
committerTimePath <andrew.hardaker1995@gmail.com>
Thu, 3 May 2018 09:52:10 +0000 (09:52 +0000)
Merge branch Mario/winfix (S merge request)

See merge request xonotic/netradiant!91

12 files changed:
contrib/bobtoolz/DEntity.cpp
libs/container/hashfunc.h
radiant/brushmanip.cpp
radiant/csg.cpp
radiant/csg.h
radiant/mainframe.cpp
radiant/renderstate.cpp
setup/data/tools/bitmaps/selection_makeroom.png [new file with mode: 0644]
tools/quake3/common/threads.c
tools/quake3/q3map2/help.c
tools/quake3/q3map2/path_init.c
tools/quake3/q3map2/surface.c

index f4d9f0b16dac5927dc77844115e83f0ef9ba4a81..d764c312d58cfc69665311aca2ba25f24fcf2317 100644 (file)
@@ -164,7 +164,7 @@ bool DEntity::LoadFromPrt(char *filename)
 
         for (unsigned int j = 0; j < portals.node[i].portal_count; j++) {
             for (unsigned int k = 0; k < portals.node[i].portal[j].point_count - 2; k++) {
-                vec3_t v1, v2, normal, n;
+                vec3_t v1{}, v2{}, normal{}, n{};
                 VectorSubtract(portals.node[i].portal[j].point[k + 2].p, portals.node[i].portal[j].point[k + 1].p, v1);
                 VectorSubtract(portals.node[i].portal[j].point[k].p, portals.node[i].portal[j].point[k + 1].p, v2);
                 CrossProduct(v1, v2, n);
index 6d2166971488b65e7601395d47a533c8aefe9d4e..305202d0c9f00435bdcdab0c0798363abf5a8ef2 100644 (file)
@@ -203,17 +203,17 @@ inline ub4 hash(
        c += length;
        switch ( len )          /* all the case statements fall through */
        {
-       case 11: c += ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 24 );
-       case 10: c += ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 16 );
-       case 9: c += ( ( ub4 ) UB1Traits::as_ub1( k[8] ) << 8 );
+       case 11: c += ( ( ub4 ) UB1Traits::as_ub1( k[10] ) << 24 ); __attribute((fallthrough));
+       case 10: c += ( ( ub4 ) UB1Traits::as_ub1( k[9] ) << 16 ); __attribute((fallthrough));
+       case 9: c += ( ( ub4 ) UB1Traits::as_ub1( k[8] ) << 8 ); __attribute((fallthrough));
        /* the first byte of c is reserved for the length */
-       case 8: b += ( ( ub4 ) UB1Traits::as_ub1( k[7] ) << 24 );
-       case 7: b += ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 );
-       case 6: b += ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 );
-       case 5: b += UB1Traits::as_ub1( k[4] );
-       case 4: a += ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 );
-       case 3: a += ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 );
-       case 2: a += ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 );
+       case 8: b += ( ( ub4 ) UB1Traits::as_ub1( k[7] ) << 24 ); __attribute((fallthrough));
+       case 7: b += ( ( ub4 ) UB1Traits::as_ub1( k[6] ) << 16 ); __attribute((fallthrough));
+       case 6: b += ( ( ub4 ) UB1Traits::as_ub1( k[5] ) << 8 ); __attribute((fallthrough));
+       case 5: b += UB1Traits::as_ub1( k[4] );  __attribute((fallthrough));
+       case 4: a += ( ( ub4 ) UB1Traits::as_ub1( k[3] ) << 24 ); __attribute((fallthrough));
+       case 3: a += ( ( ub4 ) UB1Traits::as_ub1( k[2] ) << 16 ); __attribute((fallthrough));
+       case 2: a += ( ( ub4 ) UB1Traits::as_ub1( k[1] ) << 8 ); __attribute((fallthrough));
        case 1: a += UB1Traits::as_ub1( k[0] );
                /* case 0: nothing left to add */
        }
index 68c8a5ba08e9d810ddf1064a9a10a61443e58fcc..19e91e03871ec7380685add4265aea203eae6858 100644 (file)
@@ -1336,7 +1336,8 @@ void Brush_constructMenu(ui::Menu menu)
         if (g_Layout_enableDetachableMenus.m_value) {
             menu_tearoff(menu_in_menu);
         }
-        create_menu_item_with_mnemonic(menu_in_menu, "Make _Hollow", "CSGHollow");
+        create_menu_item_with_mnemonic(menu_in_menu, "Make _Hollow", "CSGMakeHollow");
+        create_menu_item_with_mnemonic(menu_in_menu, "Make _Room", "CSGMakeRoom");
         create_menu_item_with_mnemonic(menu_in_menu, "CSG _Subtract", "CSGSubtract");
         create_menu_item_with_mnemonic(menu_in_menu, "CSG _Merge", "CSGMerge");
     }
index c294642c4053a6133885e79aaa2438b645be9a77..fab905aaa4b62854e2ab62c1f94138d1c2bb57d8 100644 (file)
@@ -43,6 +43,20 @@ void Face_makeBrush(Face &face, const Brush &brush, brush_vector_t &out, float o
     }
 }
 
+void Face_makeRoom(Face &face, const Brush &brush, brush_vector_t &out, float offset)
+{
+    if (face.contributes()) {
+        face.getPlane().offset(offset);
+        out.push_back(new Brush(brush));
+        face.getPlane().offset(-offset);
+        Face *newFace = out.back()->addFace(face);
+        if (newFace != 0) {
+            newFace->flipWinding();
+            newFace->planeChanged();
+        }
+    }
+}
+
 void Brush_makeHollow(const Brush &brush, brush_vector_t &out, float offset)
 {
     Brush_forEachFace(brush, [&](Face &face) {
@@ -50,11 +64,19 @@ void Brush_makeHollow(const Brush &brush, brush_vector_t &out, float offset)
     });
 }
 
+void Brush_makeRoom(const Brush &brush, brush_vector_t &out, float offset)
+{
+    Brush_forEachFace(brush, [&](Face &face) {
+        Face_makeRoom(face, brush, out, offset);
+    });
+}
+
 class BrushHollowSelectedWalker : public scene::Graph::Walker {
     float m_offset;
+    bool m_makeRoom;
 public:
-    BrushHollowSelectedWalker(float offset)
-            : m_offset(offset)
+    BrushHollowSelectedWalker(float offset, bool makeRoom)
+            : m_offset(offset), m_makeRoom(makeRoom)
     {
     }
 
@@ -66,7 +88,14 @@ public:
                 && Instance_getSelectable(instance)->isSelected()
                 && path.size() > 1) {
                 brush_vector_t out;
-                Brush_makeHollow(*brush, out, m_offset);
+
+                if (m_makeRoom) {
+                    Brush_makeRoom(*brush, out, m_offset);
+                }
+                else {
+                    Brush_makeHollow(*brush, out, m_offset);
+                }
+
                 for (brush_vector_t::const_iterator i = out.begin(); i != out.end(); ++i) {
                     (*i)->removeEmptyFaces();
                     NodeSmartReference node((new BrushNode())->node());
@@ -123,9 +152,9 @@ public:
     }
 };
 
-void Scene_BrushMakeHollow_Selected(scene::Graph &graph)
+void Scene_BrushMakeHollow_Selected(scene::Graph &graph, bool makeRoom)
 {
-    GlobalSceneGraph().traverse(BrushHollowSelectedWalker(GetGridSize()));
+    GlobalSceneGraph().traverse(BrushHollowSelectedWalker(GetGridSize(), makeRoom));
     GlobalSceneGraph().traverse(BrushDeleteSelected());
 }
 
@@ -139,7 +168,16 @@ void CSG_MakeHollow(void)
 {
     UndoableCommand undo("brushHollow");
 
-    Scene_BrushMakeHollow_Selected(GlobalSceneGraph());
+    Scene_BrushMakeHollow_Selected(GlobalSceneGraph(), false);
+
+    SceneChangeNotify();
+}
+
+void CSG_MakeRoom(void)
+{
+    UndoableCommand undo("brushRoom");
+
+    Scene_BrushMakeHollow_Selected(GlobalSceneGraph(), true);
 
     SceneChangeNotify();
 }
index c2765341170dd21c5e4a6defd77355f7d1ecb06e..886680e1dcf86fd4a42bff73f670afa5a6677abf 100644 (file)
@@ -24,6 +24,8 @@
 
 void CSG_MakeHollow(void);
 
+void CSG_MakeRoom(void);
+
 void CSG_Subtract(void);
 
 void CSG_Merge(void);
index 36794f83af2ffcc06da90e65ffba3cc97a7f567f..05464649dc6e3984192bb743cad2d0de198f0949 100644 (file)
@@ -2606,7 +2606,8 @@ void CSG_constructToolbar(ui::Toolbar toolbar)
 {
     toolbar_append_button(toolbar, "CSG Subtract (SHIFT + U)", "selection_csgsubtract.png", "CSGSubtract");
     toolbar_append_button(toolbar, "CSG Merge (CTRL + U)", "selection_csgmerge.png", "CSGMerge");
-    toolbar_append_button(toolbar, "Hollow", "selection_makehollow.png", "CSGHollow");
+    toolbar_append_button(toolbar, "Make Hollow", "selection_makehollow.png", "CSGMakeHollow");
+    toolbar_append_button(toolbar, "Make Room", "selection_makeroom.png", "CSGMakeRoom");
 }
 
 void ComponentModes_constructToolbar(ui::Toolbar toolbar)
@@ -3623,7 +3624,8 @@ void MainFrame_Construct()
     GlobalCommands_insert("CSGSubtract", makeCallbackF(CSG_Subtract),
                           Accelerator('U', (GdkModifierType) GDK_SHIFT_MASK));
     GlobalCommands_insert("CSGMerge", makeCallbackF(CSG_Merge), Accelerator('U', (GdkModifierType) GDK_CONTROL_MASK));
-    GlobalCommands_insert("CSGHollow", makeCallbackF(CSG_MakeHollow));
+    GlobalCommands_insert("CSGMakeHollow", makeCallbackF(CSG_MakeHollow));
+    GlobalCommands_insert("CSGMakeRoom", makeCallbackF(CSG_MakeRoom));
 
     Grid_registerCommands();
 
index faa04502e1ff524033d19c5c0d1bd0053d9bb936..1da08b71dad6c1061891abb7d73fb9269171ebd3 100644 (file)
@@ -2463,16 +2463,22 @@ void OpenGLShader::construct(const char *name)
                     switch (alphafunc) {
                         case IShader::eAlways:
                             state.m_alphafunc = GL_ALWAYS;
+                            break;
                         case IShader::eEqual:
                             state.m_alphafunc = GL_EQUAL;
+                            break;
                         case IShader::eLess:
                             state.m_alphafunc = GL_LESS;
+                            break;
                         case IShader::eGreater:
                             state.m_alphafunc = GL_GREATER;
+                            break;
                         case IShader::eLEqual:
                             state.m_alphafunc = GL_LEQUAL;
+                            break;
                         case IShader::eGEqual:
                             state.m_alphafunc = GL_GEQUAL;
+                            break;
                     }
                 }
                 reinterpret_cast<Vector3 &>( state.m_colour ) = m_shader->getTexture()->color;
diff --git a/setup/data/tools/bitmaps/selection_makeroom.png b/setup/data/tools/bitmaps/selection_makeroom.png
new file mode 100644 (file)
index 0000000..c17ee28
Binary files /dev/null and b/setup/data/tools/bitmaps/selection_makeroom.png differ
index 054dc746625ef214d0b73ecc65793160db865cc6..fd38ef9f9c70cfb13098aa7119daf99e372a3f3c 100644 (file)
@@ -20,6 +20,7 @@
  */
 
 #include "globaldefs.h"
+#include <stdint.h>
 #if !GDEF_OS_WINDOWS
 // The below define is necessary to use
 // pthreads extensions like pthread_mutexattr_settype
index 17b21173bb4e4f7fe5f7bf15a62eb972344c21f2..e253720c82b56d3cdbbbdb5b8d5508e86ca216c7 100644 (file)
@@ -356,7 +356,8 @@ void HelpCommon()
                {"-fs_game <gamename>", "Sets a different game directory name (default for Q3A: baseq3, can be used more than once)"},
                {"-fs_homebase <dir>", "Specifies where the user home directory name is on Linux (default for Q3A: .q3a)"},
                {"-fs_homepath <path>", "Sets the given path as home directory name"},
-               {"-fs_nobasepath", "Do not load base paths in VFS"},
+               {"-fs_nobasepath", "Do not load base paths in VFS, imply -fs_nomagicpath"},
+               {"-fs_nomagicpath", "Do not try to guess base path magically"},
                {"-fs_nohomepath", "Do not load home path in VFS"},
                {"-fs_pakpath <path>", "Specify a package directory (can be used more than once to look in multiple paths)"},
                {"-game <gamename>", "Load settings for the given game (default: quake3)"},
index ef346f70bd596f88011b612c8a8e347dc943a3f2..80cdbcae5d4e1fb50d571b72532c6c4919000df7 100644 (file)
@@ -409,6 +409,7 @@ void InitPaths( int *argc, char **argv ){
 
        int noBasePath = 0;
        int noHomePath = 0;
+       int noMagicPath = 0;
 
        /* note it */
        Sys_FPrintf( SYS_VRB, "--- InitPaths ---\n" );
@@ -459,9 +460,17 @@ void InitPaths( int *argc, char **argv ){
                /* -fs_nobasepath */
                else if ( strcmp( argv[ i ], "-fs_nobasepath" ) == 0 ) {
                        noBasePath = 1;
+                       // we don't want any basepath, neither guessed ones
+                       noMagicPath = 1;
                        argv[ i ] = NULL;
                }               
 
+               /* -fs_nomagicpath */
+               else if ( strcmp( argv[ i ], "-fs_nomagicpath") == 0) {
+                       noMagicPath = 1;
+                       argv[ i ] = NULL;
+               }
+
                /* -fs_basepath */
                else if ( strcmp( argv[ i ], "-fs_basepath" ) == 0 ) {
                        if ( ++i >= *argc ) {
@@ -528,7 +537,6 @@ void InitPaths( int *argc, char **argv ){
                        AddPakPath( argv[ i ] );
                        argv[ i ] = NULL;
                }
-
        }
 
        /* remove processed arguments */
@@ -545,8 +553,8 @@ void InitPaths( int *argc, char **argv ){
        /* add standard game path */
        AddGamePath( game->gamePath );
 
-       /* if there is no base path set, figure it out */
-       if ( numBasePaths == 0 && noBasePath == 0 ) {
+       /* if there is no base path set, figure it out unless fs_nomagicpath is set */
+       if ( numBasePaths == 0 && noBasePath == 0 && noMagicPath == 0 ) {
                /* this is another crappy replacement for SetQdirFromPath() */
                len2 = strlen( game->magic );
                for ( i = 0; i < *argc && numBasePaths == 0; i++ )
index e47f256735e3ac081e976fd2c1577ecc986469b6..a51db8c176c7e91f59c67e183da6db59bcc3f137 100644 (file)
@@ -781,6 +781,10 @@ byte GetShaderIndexForPoint( indexMap_t *im, vec3_t eMins, vec3_t eMaxs, vec3_t
 }
 
 
+#define snprintf_ignore(s, n, format, ...) do { \
+    size_t __n = snprintf(s, n, format, __VA_ARGS__); \
+    if (n >= n) {} /* truncated, ignore */ \
+} while (0)
 
 /*
    GetIndexedShader() - ydnar
@@ -827,10 +831,10 @@ shaderInfo_t *GetIndexedShader( shaderInfo_t *parent, indexMap_t *im, int numPoi
 
        /* make a shader name */
        if ( minShaderIndex == maxShaderIndex ) {
-               sprintf( shader, "textures/%s_%d", im->shader, maxShaderIndex );
+               snprintf_ignore( shader, sizeof shader, "textures/%s_%d", im->shader, maxShaderIndex );
        }
        else{
-               sprintf( shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
+               snprintf_ignore( shader, sizeof shader, "textures/%s_%dto%d", im->shader, minShaderIndex, maxShaderIndex );
        }
 
        /* get the shader */
@@ -926,17 +930,17 @@ mapDrawSurface_t *DrawSurfaceForSide( entity_t *e, brush_t *b, side_t *s, windin
        /* ydnar: sky hack/fix for GL_CLAMP borders on ati cards */
        if ( skyFixHack && si->skyParmsImageBase[ 0 ] != '\0' ) {
                //%     Sys_FPrintf( SYS_VRB, "Enabling sky hack for shader %s using env %s\n", si->shader, si->skyParmsImageBase );
-               sprintf( tempShader, "%s_lf", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_lf", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_rt", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_rt", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_ft", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_ft", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_bk", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_bk", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_up", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_up", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
-               sprintf( tempShader, "%s_dn", si->skyParmsImageBase );
+               snprintf_ignore( tempShader, sizeof tempShader, "%s_dn", si->skyParmsImageBase );
                DrawSurfaceForShader( tempShader );
        }