]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - clvm_cmds.c
Fix a typo in DrawQ_RotPic which broke it badly.
[xonotic/darkplaces.git] / clvm_cmds.c
index 4734484513b85ee6ca4c8be317051458830ae75a..e218878e200f86578cb4309304aeac5c6390291e 100644 (file)
@@ -736,6 +736,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;
@@ -3252,18 +3254,15 @@ static void VM_CL_GetEntity (prvm_prog_t *prog)
 // --blub
 static void VM_CL_R_RenderScene (prvm_prog_t *prog)
 {
+       qboolean ismain = r_refdef.view.ismain;
        double t = Sys_DirtyTime();
        VM_SAFEPARMCOUNT(0, VM_CL_R_RenderScene);
 
        // update the views
-       if(r_refdef.view.ismain)
+       if(ismain)
        {
                // set the main view
                csqc_main_r_refdef_view = r_refdef.view;
-
-               // clear the flags so no other view becomes "main" unless CSQC sets VF_MAINVIEW
-               r_refdef.view.ismain = false;
-               csqc_original_r_refdef_view.ismain = false;
        }
 
        // we need to update any RENDER_VIEWMODEL entities at this point because
@@ -3280,6 +3279,17 @@ static void VM_CL_R_RenderScene (prvm_prog_t *prog)
        // callprofile fixing hack: do not include this time in what is counted for CSQC_UpdateView
        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)
+       {
+               // clear the flags so no other view becomes "main" unless CSQC sets VF_MAINVIEW
+               r_refdef.view.ismain = false;
+               csqc_original_r_refdef_view.ismain = false;
+       }
 }
 
 //void(string texturename, float flag[, float is2d]) R_BeginPolygon
@@ -3294,8 +3304,17 @@ 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();
@@ -4751,6 +4770,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)
@@ -4758,4 +4778,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;
 }