]> de.git.xonotic.org Git - voretournament/voretournament.git/blobdiff - misc/source/darkplaces-src/model_brush.c
Update the prebuilt engines to latest version of darkplaces. Also put Linux rebrand...
[voretournament/voretournament.git] / misc / source / darkplaces-src / model_brush.c
index 23fa6d48504e31372ab7e6d607d59acf91380ca6..f6453414e4726dfd4024028b76f4f8c11dbd5b8f 100644 (file)
@@ -56,6 +56,8 @@ cvar_t mod_q3shader_default_offsetmapping_bias = {CVAR_SAVE, "mod_q3shader_defau
 cvar_t mod_q3shader_default_polygonfactor = {0, "mod_q3shader_default_polygonfactor", "0", "biases depth values of 'polygonoffset' shaders to prevent z-fighting artifacts"};
 cvar_t mod_q3shader_default_polygonoffset = {0, "mod_q3shader_default_polygonoffset", "-2", "biases depth values of 'polygonoffset' shaders to prevent z-fighting artifacts"};
 cvar_t mod_q3shader_force_addalpha = {0, "mod_q3shader_force_addalpha", "0", "treat GL_ONE GL_ONE (or add) blendfunc as GL_SRC_ALPHA GL_ONE for compatibility with older DarkPlaces releases"};
+cvar_t mod_q3shader_force_terrain_alphaflag = {0, "mod_q3shader_force_terrain_alphaflag", "0", "for multilayered terrain shaders force TEXF_ALPHA flag on both layers"};
+
 cvar_t mod_q1bsp_polygoncollisions = {0, "mod_q1bsp_polygoncollisions", "0", "disables use of precomputed cliphulls and instead collides with polygons (uses Bounding Interval Hierarchy optimizations)"};
 cvar_t mod_collision_bih = {0, "mod_collision_bih", "1", "enables use of generated Bounding Interval Hierarchy tree instead of compiled bsp tree in collision code"};
 cvar_t mod_recalculatenodeboxes = {0, "mod_recalculatenodeboxes", "1", "enables use of generated node bounding boxes based on BSP tree portal reconstruction, rather than the node boxes supplied by the map compiler"};
@@ -98,6 +100,7 @@ void Mod_BrushInit(void)
        Cvar_RegisterVariable(&mod_q3shader_default_polygonfactor);
        Cvar_RegisterVariable(&mod_q3shader_default_polygonoffset);
        Cvar_RegisterVariable(&mod_q3shader_force_addalpha);
+       Cvar_RegisterVariable(&mod_q3shader_force_terrain_alphaflag);
        Cvar_RegisterVariable(&mod_q1bsp_polygoncollisions);
        Cvar_RegisterVariable(&mod_collision_bih);
        Cvar_RegisterVariable(&mod_recalculatenodeboxes);
@@ -1228,7 +1231,8 @@ loc0:
                // check for impact on this node
                if (node->numsurfaces)
                {
-                       int i, dsi, dti, lmwidth, lmheight;
+                       unsigned int i;
+                       int dsi, dti, lmwidth, lmheight;
                        float ds, dt;
                        msurface_t *surface;
                        unsigned char *lightmap;
@@ -1313,7 +1317,7 @@ static void Mod_Q1BSP_LightPoint(dp_model_t *model, const vec3_t p, vec3_t ambie
 
 static const texture_t *Mod_Q1BSP_TraceLineAgainstSurfacesFindTextureOnNode(RecursiveHullCheckTraceInfo_t *t, const dp_model_t *model, const mnode_t *node, double mid[3])
 {
-       int i;
+       unsigned int i;
        int j;
        int k;
        const msurface_t *surface;
@@ -1676,6 +1680,9 @@ static void Mod_Q1BSP_LoadTextures(sizebuf_t *sb)
                tx->offsetbias = 0;
                tx->specularscalemod = 1;
                tx->specularpowermod = 1;
+               tx->transparentsort = TRANSPARENTSORT_DISTANCE;
+               // WHEN ADDING DEFAULTS HERE, REMEMBER TO PUT DEFAULTS IN ALL LOADERS
+               // JUST GREP FOR "specularscalemod = 1".
        }
 
        if (!sb->cursize)
@@ -2225,7 +2232,7 @@ static void Mod_Q1BSP_LoadEdges(sizebuf_t *sb)
                        out->v[0] = (unsigned short)MSG_ReadLittleShort(sb);
                        out->v[1] = (unsigned short)MSG_ReadLittleShort(sb);
                }
-               if (out->v[0] >= loadmodel->brushq1.numvertexes || out->v[1] >= loadmodel->brushq1.numvertexes)
+               if ((int)out->v[0] >= loadmodel->brushq1.numvertexes || (int)out->v[1] >= loadmodel->brushq1.numvertexes)
                {
                        Con_Printf("Mod_Q1BSP_LoadEdges: %s has invalid vertex indices in edge %i (vertices %i %i >= numvertices %i)\n", loadmodel->name, i, out->v[0], out->v[1], loadmodel->brushq1.numvertexes);
                        if(!loadmodel->brushq1.numvertexes)
@@ -3467,7 +3474,7 @@ static void Mod_Q1BSP_RecursiveNodePortals(mnode_t *node)
        // TODO: calculate node bounding boxes during recursion and calculate a maximum plane size accordingly to improve precision (as most maps do not need 1 billion unit plane polygons)
        PolygonD_QuadForPlane(nodeportal->points, nodeportal->plane.normal[0], nodeportal->plane.normal[1], nodeportal->plane.normal[2], nodeportal->plane.dist, 1024.0*1024.0*1024.0);
        nodeportal->numpoints = 4;
-       side = 0;       // shut up compiler warning
+       // side = 0;    // shut up compiler warning -> should be no longer needed, Host_Error is declared noreturn now
        for (portal = (portal_t *)node->portals;portal;portal = portal->next[side])
        {
                clipplane = portal->plane;
@@ -3482,7 +3489,10 @@ static void Mod_Q1BSP_RecursiveNodePortals(mnode_t *node)
                        side = 1;
                }
                else
+               {
                        Host_Error("Mod_Q1BSP_RecursiveNodePortals: mislinked portal");
+                       side = 0; // hush warning
+               }
 
                for (i = 0;i < nodeportal->numpoints*3;i++)
                        frontpoints[i] = nodeportal->points[i];
@@ -3515,7 +3525,10 @@ static void Mod_Q1BSP_RecursiveNodePortals(mnode_t *node)
                else if (portal->nodes[1] == node)
                        side = 1;
                else
+               {
                        Host_Error("Mod_Q1BSP_RecursiveNodePortals: mislinked portal");
+                       side = 0; // hush warning
+               }
                nextportal = portal->next[side];
                if (!portal->numpoints)
                        continue;