]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_cmds.c
r_font_postprocess_* cvars to render fonts similar to mplayer subtitles with a blurre...
[xonotic/darkplaces.git] / prvm_cmds.c
index 3b49fe1c31984866dbbcf0aef74ef21af3d91dc7..5d3650421bc7a819df64cf07788f2ada940aef61 100644 (file)
@@ -204,19 +204,19 @@ void VM_UpdateEdictSkeleton(prvm_edict_t *ed, const dp_model_t *edmodel, const f
                        int blendindex;
                        int bonenum;
                        int numbones = ed->priv.server->skeleton.model->num_bones;
-                       const float *poses = ed->priv.server->skeleton.model->data_poses;
-                       const float *framebones;
+                       const short *framebones6s;
                        float lerp;
+                       float scale = ed->priv.server->skeleton.model->num_posescale;
                        matrix4x4_t *relativetransforms = ed->priv.server->skeleton.relativetransforms;
                        matrix4x4_t matrix;
                        memset(relativetransforms, 0, numbones * sizeof(matrix4x4_t));
                        for (blendindex = 0;blendindex < MAX_FRAMEBLENDS && frameblend[blendindex].lerp > 0;blendindex++)
                        {
                                lerp = frameblend[blendindex].lerp;
-                               framebones = poses + 12 * frameblend[blendindex].subframe * numbones;
+                               framebones6s = ed->priv.server->skeleton.model->data_poses6s + 6 * frameblend[blendindex].subframe * numbones;
                                for (bonenum = 0;bonenum < numbones;bonenum++)
                                {
-                                       Matrix4x4_FromArray12FloatD3D(&matrix, framebones + 12 * bonenum);
+                                       Matrix4x4_FromBonePose6s(&matrix, scale, framebones6s + 6 * bonenum);
                                        Matrix4x4_Accumulate(&ed->priv.server->skeleton.relativetransforms[bonenum], &matrix, lerp);
                                }
                        }
@@ -3285,7 +3285,7 @@ void VM_drawcharacter(void)
        }
 
        getdrawfontscale(&sx, &sy);
-       DrawQ_String_Font_Scale(pos[0], pos[1], &character, 1, scale[0], scale[1], sx, sy, rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag, NULL, true, getdrawfont());
+       DrawQ_String_Scale(pos[0], pos[1], &character, 1, scale[0], scale[1], sx, sy, rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag, NULL, true, getdrawfont());
        PRVM_G_FLOAT(OFS_RETURN) = 1;
 }
 
@@ -3328,7 +3328,7 @@ void VM_drawstring(void)
                Con_Printf("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(&sx, &sy);
-       DrawQ_String_Font_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());
+       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());
        //Font_DrawString(pos[0], pos[1], string, 0, scale[0], scale[1], rgb[0], rgb[1], rgb[2], PRVM_G_FLOAT(OFS_PARM4), flag, NULL, true);
        PRVM_G_FLOAT(OFS_RETURN) = 1;
 }
@@ -3372,7 +3372,7 @@ void VM_drawcolorcodedstring(void)
 
        color = -1;
        getdrawfontscale(&sx, &sy);
-       DrawQ_String_Font_Scale(pos[0], pos[1], string, 0, scale[0], scale[1], sx, sy, 1, 1, 1, PRVM_G_FLOAT(OFS_PARM3), flag, NULL, false, getdrawfont());
+       DrawQ_String_Scale(pos[0], pos[1], string, 0, scale[0], scale[1], sx, sy, 1, 1, 1, PRVM_G_FLOAT(OFS_PARM3), flag, NULL, false, getdrawfont());
        PRVM_G_FLOAT(OFS_RETURN) = 1;
 }
 /*
@@ -3416,7 +3416,7 @@ void VM_stringwidth(void)
        string = PRVM_G_STRING(OFS_PARM0);
        colors = (int)PRVM_G_FLOAT(OFS_PARM1);
 
-       PRVM_G_FLOAT(OFS_RETURN) = DrawQ_TextWidth_Font_UntilWidth_TrackColors_Size_Scale(string, &maxlen, szv[0], szv[1], sx, sy, NULL, !colors, getdrawfont(), 1000000000) * mult;
+       PRVM_G_FLOAT(OFS_RETURN) = DrawQ_TextWidth_UntilWidth_TrackColors_Scale(string, &maxlen, szv[0], szv[1], sx, sy, NULL, !colors, getdrawfont(), 1000000000) * mult;
 /*
        if(prog->argc == 3)
        {
@@ -3431,7 +3431,7 @@ void VM_stringwidth(void)
        string = PRVM_G_STRING(OFS_PARM0);
        colors = (int)PRVM_G_FLOAT(OFS_PARM1);
 
-       PRVM_G_FLOAT(OFS_RETURN) = DrawQ_TextWidth_Font(string, 0, !colors, getdrawfont()) * mult; // 1x1 characters, don't actually draw
+       PRVM_G_FLOAT(OFS_RETURN) = DrawQ_TextWidth(string, 0, !colors, getdrawfont()) * mult; // 1x1 characters, don't actually draw
 */
 
 }
@@ -5057,7 +5057,10 @@ void VM_str2chr (void)
 
        if((unsigned)index < strlen(s))
        {
-               ch = u8_getchar_noendptr(s + index);
+               if (utf8_enable.integer)
+                       ch = u8_getchar_noendptr(s + index);
+               else
+                       ch = (unsigned char)s[index];
                PRVM_G_FLOAT(OFS_RETURN) = ch;
        }
        else
@@ -5600,7 +5603,7 @@ void VM_CL_getextresponse (void)
                int first;
                --cl_net_extresponse_count;
                first = (cl_net_extresponse_last + NET_EXTRESPONSE_MAX - cl_net_extresponse_count) % NET_EXTRESPONSE_MAX;
-               PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(cl_net_extresponse[first]);
+               PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(cl_net_extresponse[first]);
        }
 }
 
@@ -5615,7 +5618,7 @@ void VM_SV_getextresponse (void)
                int first;
                --sv_net_extresponse_count;
                first = (sv_net_extresponse_last + NET_EXTRESPONSE_MAX - sv_net_extresponse_count) % NET_EXTRESPONSE_MAX;
-               PRVM_G_INT(OFS_RETURN) = PRVM_SetEngineString(sv_net_extresponse[first]);
+               PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(sv_net_extresponse[first]);
        }
 }
 
@@ -5802,6 +5805,11 @@ noflags:
                                                else
                                                        width = argpos++;
                                                width = GETARG_FLOAT(width);
+                                               if(width < 0)
+                                               {
+                                                       flags |= PRINTF_LEFT;
+                                                       width = -width;
+                                               }
                                        }
                                        else if(*s >= '0' && *s <= '9')
                                        {
@@ -5812,12 +5820,13 @@ noflags:
                                                        goto finished;
                                                }
                                                s = err;
+                                               if(width < 0)
+                                               {
+                                                       flags |= PRINTF_LEFT;
+                                                       width = -width;
+                                               }
                                        }
-                                       if(width < 0)
-                                       {
-                                               flags |= PRINTF_LEFT;
-                                               width = -width;
-                                       }
+                                       // otherwise width stays -1
                                }
 
                                if(*s == '.')
@@ -5893,24 +5902,28 @@ nolength:
                                        *f++ = *s;
                                        *f++ = 0;
 
-                                       if(width < 0)
+                                       if(width < 0) // not set
                                                width = 0;
 
                                        switch(*s)
                                        {
                                                case 'd': case 'i':
+                                                       if(precision < 0) // not set
+                                                               precision = 1;
                                                        o += dpsnprintf(o, end - o, formatbuf, width, precision, (isfloat ? (int) GETARG_FLOAT(thisarg) : (int) GETARG_INT(thisarg)));
                                                        break;
                                                case 'o': case 'u': case 'x': case 'X':
+                                                       if(precision < 0) // not set
+                                                               precision = 1;
                                                        o += dpsnprintf(o, end - o, formatbuf, width, precision, (isfloat ? (unsigned int) GETARG_FLOAT(thisarg) : (unsigned int) GETARG_INT(thisarg)));
                                                        break;
                                                case 'e': case 'E': case 'f': case 'F': case 'g': case 'G':
-                                                       if(precision < 0)
+                                                       if(precision < 0) // not set
                                                                precision = 6;
                                                        o += dpsnprintf(o, end - o, formatbuf, width, precision, (isfloat ? (double) GETARG_FLOAT(thisarg) : (double) GETARG_INT(thisarg)));
                                                        break;
                                                case 'c':
-                                                       if(precision < 0)
+                                                       if(precision < 0) // not set
                                                                precision = end - o - 1;
                                                        if(flags & PRINTF_ALTERNATE)
                                                                o += dpsnprintf(o, end - o, formatbuf, width, precision, (isfloat ? (unsigned int) GETARG_FLOAT(thisarg) : (unsigned int) GETARG_INT(thisarg)));
@@ -5924,7 +5937,7 @@ nolength:
                                                        }
                                                        break;
                                                case 's':
-                                                       if(precision < 0)
+                                                       if(precision < 0) // not set
                                                                precision = end - o - 1;
                                                        if(flags & PRINTF_ALTERNATE)
                                                                o += dpsnprintf(o, end - o, formatbuf, width, precision, GETARG_STRING(thisarg));