X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=prvm_cmds.c;h=98f819c8bd9ae01296834dee20389ee164f0f1c4;hb=6ad90d1388ee03427548282e23fcd5bdba03b83a;hp=746d480e76e77530715affa874eb5353cf5f2843;hpb=fd726ac9658cd7d684d68a63f255ea6df7baf166;p=xonotic%2Fdarkplaces.git diff --git a/prvm_cmds.c b/prvm_cmds.c index 746d480e..98f819c8 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -99,7 +99,10 @@ void VM_FrameBlendFromFrameGroupBlend(frameblend_t *frameblend, const framegroup memset(blend, 0, MAX_FRAMEBLENDS * sizeof(*blend)); - if (!model || !model->surfmesh.isanimated) + // rpolzer: Not testing isanimated here - a model might have + // "animations" that move no vertices (but only bones), thus rendering + // may assume it's not animated while processing can't. + if (!model) { blend[0].lerp = 1; return; @@ -2212,8 +2215,8 @@ void VM_strlennocol(prvm_prog_t *prog) szString = PRVM_G_STRING(OFS_PARM0); - //nCnt = COM_StringLengthNoColors(szString, 0, NULL); - nCnt = u8_COM_StringLengthNoColors(szString, 0, NULL); + //nCnt = (int)COM_StringLengthNoColors(szString, 0, NULL); + nCnt = (int)u8_COM_StringLengthNoColors(szString, 0, NULL); PRVM_G_FLOAT(OFS_RETURN) = nCnt; } @@ -2327,7 +2330,7 @@ void VM_substring(prvm_prog_t *prog) if (start < 0) // FTE_STRINGS feature { - u_slength = u8_strlen(s); + u_slength = (int)u8_strlen(s); start += u_slength; start = bound(0, start, u_slength); } @@ -2335,7 +2338,7 @@ void VM_substring(prvm_prog_t *prog) if (length < 0) // FTE_STRINGS feature { if (!u_slength) // it's not calculated when it's not needed above - u_slength = u8_strlen(s); + u_slength = (int)u8_strlen(s); length += u_slength - start + 1; } @@ -2686,7 +2689,7 @@ void VM_tokenizebyseparator (prvm_prog_t *prog) if (!s[0]) continue; separators[numseparators] = s; - separatorlen[numseparators] = strlen(s); + separatorlen[numseparators] = (int)strlen(s); numseparators++; } @@ -4425,23 +4428,25 @@ string altstr_prepare(string) */ void VM_altstr_prepare(prvm_prog_t *prog) { - char *out; const char *instr, *in; - int size; char outstr[VM_STRINGTEMP_LENGTH]; + size_t outpos; VM_SAFEPARMCOUNT( 1, VM_altstr_prepare ); instr = PRVM_G_STRING( OFS_PARM0 ); - for( out = outstr, in = instr, size = sizeof(outstr) - 1 ; size && *in ; size--, in++, out++ ) - if( *in == '\'' ) { - *out++ = '\\'; - *out = '\''; - size--; - } else - *out = *in; - *out = 0; + for (in = instr, outpos = 0; *in && outpos < sizeof(outstr) - 1; ++in) + { + if (*in == '\'' && outpos < sizeof(outstr) - 2) + { + outstr[outpos++] = '\\'; + outstr[outpos++] = '\''; + } + else + outstr[outpos++] = *in; + } + outstr[outpos] = 0; PRVM_G_INT( OFS_RETURN ) = PRVM_SetTempString(prog, outstr ); } @@ -4637,7 +4642,7 @@ static int BufStr_SortStringsDOWN (const void *in1, const void *in2) return strncmp(b, a, stringbuffers_sortlength); } -prvm_stringbuffer_t *BufStr_FindCreateReplace (prvm_prog_t *prog, int bufindex, int flags, char *format) +prvm_stringbuffer_t *BufStr_FindCreateReplace (prvm_prog_t *prog, int bufindex, int flags, const char *format) { prvm_stringbuffer_t *stringbuffer; int i; @@ -4718,7 +4723,7 @@ void BufStr_Flush(prvm_prog_t *prog) prvm_stringbuffer_t *stringbuffer; int i, numbuffers; - numbuffers = Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray); + numbuffers = (int)Mem_ExpandableArray_IndexRange(&prog->stringbuffersarray); for (i = 0; i < numbuffers; i++) if ( (stringbuffer = (prvm_stringbuffer_t *)Mem_ExpandableArray_RecordAtIndex(&prog->stringbuffersarray, i)) ) BufStr_Del(prog, stringbuffer); @@ -5090,21 +5095,19 @@ void VM_buf_loadfile(prvm_prog_t *prog) size_t alloclen; prvm_stringbuffer_t *stringbuffer; char string[VM_STRINGTEMP_LENGTH]; - int filenum, strindex, c, end; + int strindex, c, end; const char *filename; char vabuf[1024]; + qfile_t *file; VM_SAFEPARMCOUNT(2, VM_buf_loadfile); // get file filename = PRVM_G_STRING(OFS_PARM0); - for (filenum = 0;filenum < PRVM_MAX_OPENFILES;filenum++) - if (prog->openfiles[filenum] == NULL) - break; - prog->openfiles[filenum] = FS_OpenVirtualFile(va(vabuf, sizeof(vabuf), "data/%s", filename), false); - if (prog->openfiles[filenum] == NULL) - prog->openfiles[filenum] = FS_OpenVirtualFile(va(vabuf, sizeof(vabuf), "%s", filename), false); - if (prog->openfiles[filenum] == NULL) + file = FS_OpenVirtualFile(va(vabuf, sizeof(vabuf), "data/%s", filename), false); + if (file == NULL) + file = FS_OpenVirtualFile(va(vabuf, sizeof(vabuf), "%s", filename), false); + if (file == NULL) { if (developer_extra.integer) VM_Warning(prog, "VM_buf_loadfile: failed to open file %s in %s\n", filename, prog->name); @@ -5129,7 +5132,7 @@ void VM_buf_loadfile(prvm_prog_t *prog) end = 0; for (;;) { - c = FS_Getc(prog->openfiles[filenum]); + c = FS_Getc(file); if (c == '\r' || c == '\n' || c < 0) break; if (end < VM_STRINGTEMP_LENGTH - 1) @@ -5139,9 +5142,9 @@ void VM_buf_loadfile(prvm_prog_t *prog) // remove \n following \r if (c == '\r') { - c = FS_Getc(prog->openfiles[filenum]); + c = FS_Getc(file); if (c != '\n') - FS_UnGetc(prog->openfiles[filenum], (unsigned char)c); + FS_UnGetc(file, (unsigned char)c); } // add and continue if (c >= 0 || end) @@ -5158,10 +5161,7 @@ void VM_buf_loadfile(prvm_prog_t *prog) } // close file - FS_Close(prog->openfiles[filenum]); - prog->openfiles[filenum] = NULL; - if (prog->openfiles_origin[filenum]) - PRVM_Free((char *)prog->openfiles_origin[filenum]); + FS_Close(file); PRVM_G_FLOAT(OFS_RETURN) = 1; } @@ -5236,7 +5236,7 @@ void VM_buf_writefile(prvm_prog_t *prog) { if (stringbuffer->strings[strindex]) { - if ((strlength = strlen(stringbuffer->strings[strindex]))) + if ((strlength = (int)strlen(stringbuffer->strings[strindex]))) FS_Write(prog->openfiles[filenum], stringbuffer->strings[strindex], strlength); FS_Write(prog->openfiles[filenum], "\n", 1); } @@ -5259,7 +5259,7 @@ static const char *detect_match_rule(char *pattern, int *matchrule) char *ppos, *qpos; int patternlength; - patternlength = strlen(pattern); + patternlength = (int)strlen(pattern); ppos = strchr(pattern, '*'); qpos = strchr(pattern, '?'); // has ? - pattern @@ -5369,7 +5369,7 @@ void VM_bufstr_find(prvm_prog_t *prog) strlcpy(string, PRVM_G_STRING(OFS_PARM1), sizeof(string)); match = detect_match_rule(string, &matchrule); } - matchlen = strlen(match); + matchlen = (int)strlen(match); // find i = (prog->argc > 3) ? (int)PRVM_G_FLOAT(OFS_PARM3) : 0; @@ -5417,7 +5417,7 @@ void VM_matchpattern(prvm_prog_t *prog) } // offset - l = strlen(match); + l = (int)strlen(match); if (prog->argc > 3) s += max(0, min((unsigned int)PRVM_G_FLOAT(OFS_PARM3), strlen(s)-1)); @@ -5652,7 +5652,7 @@ void VM_strstrofs (prvm_prog_t *prog) instr = PRVM_G_STRING(OFS_PARM0); match = PRVM_G_STRING(OFS_PARM1); firstofs = (prog->argc > 2)?(int)PRVM_G_FLOAT(OFS_PARM2):0; - firstofs = u8_bytelen(instr, firstofs); + firstofs = (int)u8_bytelen(instr, firstofs); if (firstofs && (firstofs < 0 || firstofs > (int)strlen(instr))) { @@ -5675,7 +5675,7 @@ void VM_str2chr (prvm_prog_t *prog) int index; VM_SAFEPARMCOUNT(2, VM_str2chr); s = PRVM_G_STRING(OFS_PARM0); - index = u8_bytelen(s, (int)PRVM_G_FLOAT(OFS_PARM1)); + index = (int)u8_bytelen(s, (int)PRVM_G_FLOAT(OFS_PARM1)); if((unsigned)index < strlen(s)) { @@ -5805,7 +5805,7 @@ void VM_strconv (prvm_prog_t *prog) redalpha = (int) PRVM_G_FLOAT(OFS_PARM1); //0 same, 1 white, 2 red, 5 alternate, 6 alternate-alternate rednum = (int) PRVM_G_FLOAT(OFS_PARM2); //0 same, 1 white, 2 red, 3 redspecial, 4 whitespecial, 5 alternate, 6 alternate-alternate VM_VarString(prog, 3, (char *) resbuf, sizeof(resbuf)); - len = strlen((char *) resbuf); + len = (int)strlen((char *) resbuf); for (i = 0; i < len; i++, result++) //should this be done backwards? { @@ -5957,7 +5957,7 @@ void VM_digest_hex(prvm_prog_t *prog) if(!digest) digest = ""; VM_VarString(prog, 1, s, sizeof(s)); - len = strlen(s); + len = (int)strlen(s); outlen = 0; @@ -6813,7 +6813,8 @@ nolength: default: verbatim: if(o < end - 1) - *o++ = *s++; + *o++ = *s; + ++s; break; } }