]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
Fix a few warnings.
[xonotic/darkplaces.git] / clvm_cmds.c
index 5ee778f9a7c2e52219474f2a857b47d195332fc4..6e4b3fcf597e9487c8e46dc38bf2af5a45780d5e 100644 (file)
@@ -21,7 +21,6 @@
 //4 feature darkplaces csqc: add builtins to clientside qc for gl calls
 
 extern cvar_t v_flipped;
-extern cvar_t r_equalize_entities_fullbright;
 
 r_refdef_view_t csqc_original_r_refdef_view;
 r_refdef_view_t csqc_main_r_refdef_view;
@@ -129,7 +128,7 @@ static void VM_CL_setmodel (prvm_prog_t *prog)
 
        if( mod ) {
                // TODO: check if this breaks needed consistency and maybe add a cvar for it too?? [1/10/2008 Black]
-               // LordHavoc: erm you broke it by commenting this out - setmodel must do setsize or else the qc can't find out the model size, and ssqc does this by necessity, consistency.
+               // LadyHavoc: erm you broke it by commenting this out - setmodel must do setsize or else the qc can't find out the model size, and ssqc does this by necessity, consistency.
                SetMinMaxSize (prog, e, mod->normalmins, mod->normalmaxs);
        }
        else
@@ -207,7 +206,7 @@ static void VM_CL_sound (prvm_prog_t *prog)
                flags = 0;
        else
        {
-               // LordHavoc: we only let the qc set certain flags, others are off-limits
+               // LadyHavoc: we only let the qc set certain flags, others are off-limits
                flags = (int)PRVM_G_FLOAT(OFS_PARM6) & (CHANNELFLAG_RELIABLE | CHANNELFLAG_FORCELOOP | CHANNELFLAG_PAUSED | CHANNELFLAG_FULLVOLUME);
        }
 
@@ -319,7 +318,7 @@ if the tryents flag is set.
 tracebox (vector1, vector mins, vector maxs, vector2, tryents)
 =================
 */
-// LordHavoc: added this for my own use, VERY useful, similar to traceline
+// LadyHavoc: added this for my own use, VERY useful, similar to traceline
 static void VM_CL_tracebox (prvm_prog_t *prog)
 {
        vec3_t  v1, v2, m1, m2;
@@ -369,7 +368,7 @@ static trace_t CL_Trace_Toss (prvm_prog_t *prog, prvm_edict_t *tossent, prvm_edi
                gravity = 1.0f;
        gravity *= cl.movevars_gravity * 0.05;
 
-       for (i = 0;i < 200;i++) // LordHavoc: sanity check; never trace more than 10 seconds
+       for (i = 0;i < 200;i++) // LadyHavoc: sanity check; never trace more than 10 seconds
        {
                PRVM_clientedictvector(tossent, velocity)[2] -= gravity;
                VectorMA (PRVM_clientedictvector(tossent, angles), 0.05, PRVM_clientedictvector(tossent, avelocity), PRVM_clientedictvector(tossent, angles));
@@ -500,7 +499,7 @@ static void VM_CL_findradius (prvm_prog_t *prog)
                // (note: this is the reason you can't blow up fallen zombies)
                if (PRVM_clientedictfloat(ent, solid) == SOLID_NOT && !sv_gameplayfix_blowupfallenzombies.integer)
                        continue;
-               // LordHavoc: compare against bounding box rather than center so it
+               // LadyHavoc: compare against bounding box rather than center so it
                // doesn't miss large objects, and use DotProduct instead of Length
                // for a major speedup
                VectorSubtract(org, PRVM_clientedictvector(ent, origin), eorg);
@@ -736,6 +735,8 @@ static void VM_CL_R_ClearScene (prvm_prog_t *prog)
        r_refdef.scene.numlights = 0;
        // restore the view settings to the values that VM_CL_UpdateView received from the client code
        r_refdef.view = csqc_original_r_refdef_view;
+       // polygonbegin without draw2d arg has to guess
+       prog->polygonbegin_guess2d = false;
        VectorCopy(cl.csqc_vieworiginfromengine, cl.csqc_vieworigin);
        VectorCopy(cl.csqc_viewanglesfromengine, cl.csqc_viewangles);
        cl.csqc_vidvars.drawworld = r_drawworld.integer != 0;
@@ -1809,8 +1810,6 @@ static void VM_CL_makestatic (prvm_prog_t *prog)
                {
                        if (!(staticent->render.effects & EF_FULLBRIGHT))
                                staticent->render.flags |= RENDER_LIGHT;
-                       else if(r_equalize_entities_fullbright.integer)
-                               staticent->render.flags |= RENDER_LIGHT | RENDER_EQUALIZE;
                }
                // turn off shadows from transparent objects
                if (!(staticent->render.effects & (EF_NOSHADOW | EF_ADDITIVE | EF_NODEPTHTEST)) && (staticent->render.alpha >= 1))
@@ -2503,9 +2502,9 @@ int CL_GetTagMatrix (prvm_prog_t *prog, matrix4x4_t *out, prvm_edict_t *ent, int
                if (PRVM_clientedictfloat(ent, health) > 0 && cl_bob.value && cl_bobcycle.value)
                {
                        double bob, cycle;
-                       // LordHavoc: this code is *weird*, but not replacable (I think it
+                       // LadyHavoc: this code is *weird*, but not replacable (I think it
                        // should be done in QC on the server, but oh well, quake is quake)
-                       // LordHavoc: figured out bobup: the time at which the sin is at 180
+                       // LadyHavoc: figured out bobup: the time at which the sin is at 180
                        // degrees (which allows lengthening or squishing the peak or valley)
                        cycle = cl.time/cl_bobcycle.value;
                        cycle -= (int)cycle;
@@ -3278,6 +3277,9 @@ static void VM_CL_R_RenderScene (prvm_prog_t *prog)
        t = Sys_DirtyTime() - t;if (t < 0 || t >= 1800) t = 0;
        prog->functions[PRVM_clientfunction(CSQC_UpdateView)].totaltime -= t;
 
+       // polygonbegin without draw2d arg has to guess
+       prog->polygonbegin_guess2d = false;
+
        // update the views
        if (ismain)
        {
@@ -3299,13 +3301,22 @@ static void VM_CL_R_PolygonBegin (prvm_prog_t *prog)
 
        texname = PRVM_G_STRING(OFS_PARM0);
        drawflags = (int)PRVM_G_FLOAT(OFS_PARM1);
-       // weird hacky way to figure out if this is a 2D HUD polygon or a scene polygon
-       draw2d = (prog->argc >= 3 ? (int)PRVM_G_FLOAT(OFS_PARM2) : r_refdef.draw2dstage);
+       if (prog->argc >= 3)
+               draw2d = PRVM_G_FLOAT(OFS_PARM2) != 0;
+       else
+       {
+               // weird hacky way to figure out if this is a 2D HUD polygon or a scene
+               // polygon, for compatibility with mods aimed at old darkplaces versions
+               // - polygonbegin_guess2d is 0 if the most recent major call was
+               // clearscene, 1 if the most recent major call was drawpic (and similar)
+               // or renderscene
+               draw2d = prog->polygonbegin_guess2d;
+       }
 
        // we need to remember whether this is a 2D or 3D mesh we're adding to
        mod = draw2d ? CL_Mesh_UI() : CL_Mesh_CSQC();
        prog->polygonbegin_model = mod;
-       Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, texname, drawflags, TEXF_ALPHA, MATERIALFLAG_VERTEXCOLOR), draw2d);
+       Mod_Mesh_AddSurface(mod, Mod_Mesh_GetTexture(mod, texname, drawflags, TEXF_ALPHA, MATERIALFLAG_WALL | MATERIALFLAG_VERTEXCOLOR | MATERIALFLAG_ALPHAGEN_VERTEX), draw2d);
 }
 
 //void(vector org, vector texcoords, vector rgb, float alpha) R_PolygonVertex
@@ -4503,7 +4514,7 @@ NULL,                                                     // #396
 NULL,                                                  // #397
 NULL,                                                  // #398
 NULL,                                                  // #399
-// LordHavoc's range #400-#499
+// LadyHavoc's range #400-#499
 VM_CL_copyentity,                              // #400 void(entity from, entity to) copyentity (DP_QC_COPYENTITY)
 NULL,                                                  // #401 void(entity ent, float colors) setcolor (DP_QC_SETCOLOR)
 VM_findchain,                                  // #402 entity(.string fld, string match) findchain (DP_QC_FINDCHAIN)
@@ -4756,6 +4767,7 @@ void CLVM_init_cmd(prvm_prog_t *prog)
 {
        VM_Cmd_Init(prog);
        prog->polygonbegin_model = NULL;
+       prog->polygonbegin_guess2d = 0;
 }
 
 void CLVM_reset_cmd(prvm_prog_t *prog)
@@ -4763,4 +4775,5 @@ void CLVM_reset_cmd(prvm_prog_t *prog)
        World_End(&cl.world);
        VM_Cmd_Reset(prog);
        prog->polygonbegin_model = NULL;
+       prog->polygonbegin_guess2d = 0;
 }