]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_cmds.c
remove PRECACHE_PIC_NOCLAMP because it currently has no chance to work
[xonotic/darkplaces.git] / prvm_cmds.c
index 763942e7724168d2baafdcd6a50e4af031d40338..fab17c9b26bb5bab877ee0359f9696fa4abdbdec 100644 (file)
@@ -29,7 +29,7 @@ void VM_Warning(prvm_prog_t *prog, const char *fmt, ...)
        dpvsnprintf(msg,sizeof(msg),fmt,argptr);
        va_end(argptr);
 
-       Con_DPrint(msg);
+       Con_Print(msg);
 
        // TODO: either add a cvar/cmd to control the state dumping or replace some of the calls with Con_Printf [9/13/2006 Black]
        if(prvm_backtraceforwarnings.integer && recursive != realtime) // NOTE: this compares to the time, just in case if PRVM_PrintState causes a Host_Error and keeps recursive set
@@ -96,7 +96,7 @@ void VM_FrameBlendFromFrameGroupBlend(frameblend_t *frameblend, const framegroup
 
        memset(blend, 0, MAX_FRAMEBLENDS * sizeof(*blend));
 
-       if (!model || !model->surfmesh.isanimated || model->numframes <= 1)
+       if (!model || !model->surfmesh.isanimated)
        {
                blend[0].lerp = 1;
                return;
@@ -3241,18 +3241,34 @@ VM_precache_pic
 string precache_pic(string pic)
 =========
 */
+#define PRECACHE_PIC_FROMWAD 1 /* FTEQW, not supported here */
+#define PRECACHE_PIC_NOTPERSISTENT 2
+//#define PRECACHE_PIC_NOCLAMP 4
+#define PRECACHE_PIC_MIPMAP 8
 void VM_precache_pic(prvm_prog_t *prog)
 {
        const char      *s;
+       int flags = 0;
 
-       VM_SAFEPARMCOUNT(1, VM_precache_pic);
+       VM_SAFEPARMCOUNTRANGE(1, 2, VM_precache_pic);
 
        s = PRVM_G_STRING(OFS_PARM0);
        PRVM_G_INT(OFS_RETURN) = PRVM_G_INT(OFS_PARM0);
        VM_CheckEmptyString(prog, s);
 
+       if(prog->argc >= 2)
+       {
+               int f = PRVM_G_FLOAT(OFS_PARM1);
+               if(f & PRECACHE_PIC_NOTPERSISTENT)
+                       flags |= CACHEPICFLAG_NOTPERSISTENT;
+               //if(f & PRECACHE_PIC_NOCLAMP)
+               //      flags |= CACHEPICFLAG_NOCLAMP;
+               if(f & PRECACHE_PIC_MIPMAP)
+                       flags |= CACHEPICFLAG_MIPMAP;
+       }
+
        // AK Draw_CachePic is supposed to always return a valid pointer
-       if( Draw_CachePic_Flags(s, 0)->tex == r_texture_notexture )
+       if( Draw_CachePic_Flags(s, flags)->tex == r_texture_notexture )
                PRVM_G_INT(OFS_RETURN) = OFS_NULL;
 }
 
@@ -3331,7 +3347,7 @@ void VM_drawcharacter(prvm_prog_t *prog)
        }
 
        if(pos[2] || scale[2])
-               VM_Warning("VM_drawcharacter: z value%c from %s discarded\n",(pos[2] && scale[2]) ? 's' : 0,((pos[2] && scale[2]) ? "pos and scale" : (pos[2] ? "pos" : "scale")));
+               VM_Warning(prog, "VM_drawcharacter: z value%c from %s discarded\n",(pos[2] && scale[2]) ? 's' : 0,((pos[2] && scale[2]) ? "pos and scale" : (pos[2] ? "pos" : "scale")));
 
        if(!scale[0] || !scale[1])
        {
@@ -3382,7 +3398,7 @@ void VM_drawstring(prvm_prog_t *prog)
        }
 
        if(pos[2] || scale[2])
-               VM_Warning("VM_drawstring: z value%s from %s discarded\n",(pos[2] && scale[2]) ? "s" : " ",((pos[2] && scale[2]) ? "pos and scale" : (pos[2] ? "pos" : "scale")));
+               VM_Warning(prog, "VM_drawstring: z value%s from %s discarded\n",(pos[2] && scale[2]) ? "s" : " ",((pos[2] && scale[2]) ? "pos and scale" : (pos[2] ? "pos" : "scale")));
 
        getdrawfontscale(prog, &sx, &sy);
        DrawQ_String_Scale(pos[0], pos[1], string, 0, scale[0], scale[1], sx, sy, rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag, NULL, true, getdrawfont(prog));
@@ -3445,7 +3461,7 @@ void VM_drawcolorcodedstring(prvm_prog_t *prog)
        }
 
        if(pos[2] || scale[2])
-               VM_Warning("VM_drawcolorcodedstring: z value%s from %s discarded\n",(pos[2] && scale[2]) ? "s" : " ",((pos[2] && scale[2]) ? "pos and scale" : (pos[2] ? "pos" : "scale")));
+               VM_Warning(prog, "VM_drawcolorcodedstring: z value%s from %s discarded\n",(pos[2] && scale[2]) ? "s" : " ",((pos[2] && scale[2]) ? "pos and scale" : (pos[2] ? "pos" : "scale")));
 
        getdrawfontscale(prog, &sx, &sy);
        DrawQ_String_Scale(pos[0], pos[1], string, 0, scale[0], scale[1], sx, sy, rgb[0], rgb[1], rgb[2], alpha, flag, NULL, false, getdrawfont(prog));
@@ -3720,7 +3736,7 @@ void VM_drawpic(prvm_prog_t *prog)
        }
 
        if(pos[2] || size[2])
-               VM_Warning("VM_drawpic: z value%s from %s discarded\n",(pos[2] && size[2]) ? "s" : " ",((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
+               VM_Warning(prog, "VM_drawpic: z value%s from %s discarded\n",(pos[2] && size[2]) ? "s" : " ",((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
 
        DrawQ_Pic(pos[0], pos[1], Draw_CachePic_Flags (picname, CACHEPICFLAG_NOTPERSISTENT), size[0], size[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag);
        PRVM_G_FLOAT(OFS_RETURN) = 1;
@@ -3765,7 +3781,7 @@ void VM_drawrotpic(prvm_prog_t *prog)
        }
 
        if(pos[2] || size[2] || org[2])
-               VM_Warning("VM_drawrotpic: z value from pos/size/org discarded\n");
+               VM_Warning(prog, "VM_drawrotpic: z value from pos/size/org discarded\n");
 
        DrawQ_RotPic(pos[0], pos[1], Draw_CachePic_Flags(picname, CACHEPICFLAG_NOTPERSISTENT), size[0], size[1], org[0], org[1], PRVM_G_FLOAT(OFS_PARM4), rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM6), flag);
        PRVM_G_FLOAT(OFS_RETURN) = 1;
@@ -3813,7 +3829,7 @@ void VM_drawsubpic(prvm_prog_t *prog)
        }
 
        if(pos[2] || size[2])
-               VM_Warning("VM_drawsubpic: z value%s from %s discarded\n",(pos[2] && size[2]) ? "s" : " ",((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
+               VM_Warning(prog, "VM_drawsubpic: z value%s from %s discarded\n",(pos[2] && size[2]) ? "s" : " ",((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
 
        DrawQ_SuperPic(pos[0], pos[1], Draw_CachePic_Flags (picname, CACHEPICFLAG_NOTPERSISTENT),
                size[0], size[1],
@@ -3853,7 +3869,7 @@ void VM_drawfill(prvm_prog_t *prog)
        }
 
        if(pos[2] || size[2])
-               VM_Warning("VM_drawfill: z value%s from %s discarded\n",(pos[2] && size[2]) ? "s" : " ",((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
+               VM_Warning(prog, "VM_drawfill: z value%s from %s discarded\n",(pos[2] && size[2]) ? "s" : " ",((pos[2] && size[2]) ? "pos and size" : (pos[2] ? "pos" : "size")));
 
        DrawQ_Fill(pos[0], pos[1], size[0], size[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM3), flag);
        PRVM_G_FLOAT(OFS_RETURN) = 1;
@@ -3911,9 +3927,16 @@ void VM_getimagesize(prvm_prog_t *prog)
        VM_CheckEmptyString(prog, p);
 
        pic = Draw_CachePic_Flags (p, CACHEPICFLAG_NOTPERSISTENT);
-
-       PRVM_G_VECTOR(OFS_RETURN)[0] = pic->width;
-       PRVM_G_VECTOR(OFS_RETURN)[1] = pic->height;
+       if( pic->tex == r_texture_notexture )
+       {
+               PRVM_G_VECTOR(OFS_RETURN)[0] = 0;
+               PRVM_G_VECTOR(OFS_RETURN)[1] = 0;
+       }
+       else
+       {
+               PRVM_G_VECTOR(OFS_RETURN)[0] = pic->width;
+               PRVM_G_VECTOR(OFS_RETURN)[1] = pic->height;
+       }
        PRVM_G_VECTOR(OFS_RETURN)[2] = 0;
 }
 
@@ -6326,7 +6349,10 @@ nolength:
                                                        {
                                                                if(precision < 0) // not set
                                                                        precision = end - o - 1;
-                                                               o += u8_strpad(o, end - o, GETARG_STRING(thisarg), (flags & PRINTF_LEFT) != 0, width, precision);
+                                                               if(flags & PRINTF_SIGNPOSITIVE)
+                                                                       o += u8_strpad(o, end - o, GETARG_STRING(thisarg), (flags & PRINTF_LEFT) != 0, width, precision);
+                                                               else
+                                                                       o += u8_strpad_colorcodes(o, end - o, GETARG_STRING(thisarg), (flags & PRINTF_LEFT) != 0, width, precision);
                                                        }
                                                        break;
                                                default:
@@ -6826,9 +6852,9 @@ void VM_physics_addforce(prvm_prog_t *prog)
                VM_Warning(prog, "VM_physics_addforce: entity is not MOVETYPE_PHYSICS!\n");
                return;
        }
-       f.type = ODEFUNC_RELFORCEATPOS;
+       f.type = ODEFUNC_FORCE;
        VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f.v1);
-       VectorSubtract(PRVM_serveredictvector(ed, origin), PRVM_G_VECTOR(OFS_PARM2), f.v2);
+       VectorCopy(PRVM_G_VECTOR(OFS_PARM2), f.v2);
        VM_physics_ApplyCmd(ed, &f);
 }
 
@@ -6852,7 +6878,7 @@ void VM_physics_addtorque(prvm_prog_t *prog)
                VM_Warning(prog, "VM_physics_addtorque: entity is not MOVETYPE_PHYSICS!\n");
                return;
        }
-       f.type = ODEFUNC_RELTORQUE;
+       f.type = ODEFUNC_TORQUE;
        VectorCopy(PRVM_G_VECTOR(OFS_PARM1), f.v1);
        VM_physics_ApplyCmd(ed, &f);
 }