X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=prvm_cmds.c;h=6833080ec04a9f33c1508e4bae5be7a16328d079;hb=efa1b13f3b4e1b512309d16f51d1e2e28d32c013;hp=e1b248dd0169b05f10aa33ea16a110a746969751;hpb=641d75aeb3b3934d9bbe1e2603bdd05d14a15ff1;p=xonotic%2Fdarkplaces.git diff --git a/prvm_cmds.c b/prvm_cmds.c index e1b248dd..6833080e 100644 --- a/prvm_cmds.c +++ b/prvm_cmds.c @@ -21,7 +21,7 @@ extern cvar_t prvm_backtraceforwarnings; extern dllhandle_t ode_dll; #endif -// LordHavoc: changed this to NOT use a return statement, so that it can be used in functions that must return a value +// LadyHavoc: changed this to NOT use a return statement, so that it can be used in functions that must return a value void VM_Warning(prvm_prog_t *prog, const char *fmt, ...) { va_list argptr; @@ -32,12 +32,12 @@ void VM_Warning(prvm_prog_t *prog, const char *fmt, ...) dpvsnprintf(msg,sizeof(msg),fmt,argptr); va_end(argptr); - Con_Print(msg); + Con_Printf(CON_WARN "%s", 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 + if(prvm_backtraceforwarnings.integer && recursive != host.realtime) // NOTE: this compares to the time, just in case if PRVM_PrintState causes a Host_Error and keeps recursive set { - recursive = realtime; + recursive = host.realtime; PRVM_PrintState(prog, 0); recursive = -1; } @@ -49,8 +49,8 @@ void VM_Warning(prvm_prog_t *prog, const char *fmt, ...) // TODO DONE: move vm_files and vm_fssearchlist to prvm_prog_t struct // TODO: move vm_files and vm_fssearchlist back [9/13/2006 Black] -// TODO: (move vm_files and vm_fssearchlist to prvm_prog_t struct again) [2007-01-23 LordHavoc] -// TODO: will this war ever end? [2007-01-23 LordHavoc] +// TODO: (move vm_files and vm_fssearchlist to prvm_prog_t struct again) [2007-01-23 LadyHavoc] +// TODO: will this war ever end? [2007-01-23 LadyHavoc] void VM_CheckEmptyString(prvm_prog_t *prog, const char *s) { @@ -84,7 +84,7 @@ void VM_GenerateFrameGroupBlend(prvm_prog_t *prog, framegroupblend_t *framegroup framegroupblend[0].lerp = 1 - framegroupblend[1].lerp - framegroupblend[2].lerp - framegroupblend[3].lerp; } -// LordHavoc: quite tempting to break apart this function to reuse the +// LadyHavoc: quite tempting to break apart this function to reuse the // duplicated code, but I suspect it is better for performance // this way void VM_FrameBlendFromFrameGroupBlend(frameblend_t *frameblend, const framegroupblend_t *framegroupblend, const dp_model_t *model, double curtime) @@ -99,13 +99,16 @@ 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; } - nolerp = (model->type == mod_sprite) ? !r_lerpsprites.integer : !r_lerpmodels.integer; + nolerp = ((model->type == mod_sprite) ? !r_lerpsprites.integer : !r_lerpmodels.integer) || (model->nolerp == true); numframes = model->numframes; for (k = 0, g = framegroupblend;k < MAX_FRAMEGROUPBLENDS;k++, g++) { @@ -262,20 +265,11 @@ checkextension(extensionname) // kind of helper function static qboolean checkextension(prvm_prog_t *prog, const char *name) { - int len; - const char *e, *start; - len = (int)strlen(name); + const char **e; for (e = prog->extensionstring;*e;e++) { - while (*e == ' ') - e++; - if (!*e) - break; - start = e; - while (*e && *e != ' ') - e++; - if ((e - start) == len && !strncasecmp(start, name, len)) + if(!strcasecmp(*e, name)) { #ifdef USEODE // special sheck for ODE @@ -328,7 +322,7 @@ void VM_error(prvm_prog_t *prog) char string[VM_STRINGTEMP_LENGTH]; VM_VarString(prog, 0, string, sizeof(string)); - Con_Printf("======%s ERROR in %s:\n%s\n", prog->name, PRVM_GetString(prog, prog->xfunction->s_name), string); + Con_Printf(CON_ERROR "======%s ERROR in %s:\n%s\n", prog->name, PRVM_GetString(prog, prog->xfunction->s_name), string); ed = PRVM_PROG_TO_EDICT(PRVM_allglobaledict(self)); PRVM_ED_Print(prog, ed, NULL); @@ -351,11 +345,11 @@ void VM_objerror(prvm_prog_t *prog) char string[VM_STRINGTEMP_LENGTH]; VM_VarString(prog, 0, string, sizeof(string)); - Con_Printf("======OBJECT ERROR======\n"); // , prog->name, PRVM_GetString(prog->xfunction->s_name), string); // or include them? FIXME + Con_Printf(CON_ERROR "======OBJECT ERROR======\n"); // , prog->name, PRVM_GetString(prog->xfunction->s_name), string); // or include them? FIXME ed = PRVM_PROG_TO_EDICT(PRVM_allglobaledict(self)); PRVM_ED_Print(prog, ed, NULL); PRVM_ED_Free (prog, ed); - Con_Printf("%s OBJECT ERROR in %s:\n%s\nTip: read above for entity information\n", prog->name, PRVM_GetString(prog, prog->xfunction->s_name), string); + Con_Printf(CON_ERROR "%s OBJECT ERROR in %s:\n%s\nTip: read above for entity information\n", prog->name, PRVM_GetString(prog, prog->xfunction->s_name), string); } /* @@ -601,7 +595,7 @@ void VM_break(prvm_prog_t *prog) /* ================= -VM_localcmd +VM_localcmd_client Sends text over to the client's execution buffer @@ -609,18 +603,36 @@ Sends text over to the client's execution buffer cmd (string, ...) ================= */ -void VM_localcmd(prvm_prog_t *prog) +void VM_localcmd_client(prvm_prog_t *prog) +{ + char string[VM_STRINGTEMP_LENGTH]; + VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd_client); + VM_VarString(prog, 0, string, sizeof(string)); + Cbuf_AddText(&cmd_client, string); +} + +/* +================= +VM_localcmd_server + +Sends text over to the server's execution buffer + +[localcmd (string, ...) or] +cmd (string, ...) +================= +*/ +void VM_localcmd_server(prvm_prog_t *prog) { char string[VM_STRINGTEMP_LENGTH]; - VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd); + VM_SAFEPARMCOUNTRANGE(1, 8, VM_localcmd_server); VM_VarString(prog, 0, string, sizeof(string)); - Cbuf_AddText(string); + Cbuf_AddText(&cmd_server, string); } -static qboolean PRVM_Cvar_ReadOk(const char *string) +static qboolean PRVM_Cvar_ReadOk(prvm_prog_t *prog, const char *string) { cvar_t *cvar; - cvar = Cvar_FindVar(string); + cvar = Cvar_FindVar(prog->console_cmd->cvars, string, prog->console_cmd->cvars_flagsmask); return ((cvar) && ((cvar->flags & CVAR_PRIVATE) == 0)); } @@ -637,7 +649,7 @@ void VM_cvar(prvm_prog_t *prog) VM_SAFEPARMCOUNTRANGE(1,8,VM_cvar); VM_VarString(prog, 0, string, sizeof(string)); VM_CheckEmptyString(prog, string); - PRVM_G_FLOAT(OFS_RETURN) = PRVM_Cvar_ReadOk(string) ? Cvar_VariableValue(string) : 0; + PRVM_G_FLOAT(OFS_RETURN) = PRVM_Cvar_ReadOk(prog, string) ? Cvar_VariableValue(prog->console_cmd->cvars, string, prog->console_cmd->cvars_flagsmask) : 0; } /* @@ -659,10 +671,10 @@ void VM_cvar_type(prvm_prog_t *prog) cvar_t *cvar; int ret; - VM_SAFEPARMCOUNTRANGE(1,8,VM_cvar); + VM_SAFEPARMCOUNTRANGE(1, 8, VM_cvar_type); VM_VarString(prog, 0, string, sizeof(string)); VM_CheckEmptyString(prog, string); - cvar = Cvar_FindVar(string); + cvar = Cvar_FindVar(prog->console_cmd->cvars, string, prog->console_cmd->cvars_flagsmask); if(!cvar) @@ -699,7 +711,7 @@ void VM_cvar_string(prvm_prog_t *prog) VM_SAFEPARMCOUNTRANGE(1,8,VM_cvar_string); VM_VarString(prog, 0, string, sizeof(string)); VM_CheckEmptyString(prog, string); - PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, PRVM_Cvar_ReadOk(string) ? Cvar_VariableString(string) : ""); + PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, PRVM_Cvar_ReadOk(prog, string) ? Cvar_VariableString(prog->console_cmd->cvars, string, prog->console_cmd->cvars_flagsmask) : ""); } @@ -716,7 +728,7 @@ void VM_cvar_defstring(prvm_prog_t *prog) VM_SAFEPARMCOUNTRANGE(1,8,VM_cvar_defstring); VM_VarString(prog, 0, string, sizeof(string)); VM_CheckEmptyString(prog, string); - PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, Cvar_VariableDefString(string)); + PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, Cvar_VariableDefString(prog->console_cmd->cvars, string, prog->console_cmd->cvars_flagsmask)); } /* @@ -732,7 +744,7 @@ void VM_cvar_description(prvm_prog_t *prog) VM_SAFEPARMCOUNTRANGE(1,8,VM_cvar_description); VM_VarString(prog, 0, string, sizeof(string)); VM_CheckEmptyString(prog, string); - PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, Cvar_VariableDescription(string)); + PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, Cvar_VariableDescription(prog->console_cmd->cvars, string, prog->console_cmd->cvars_flagsmask)); } /* ================= @@ -749,7 +761,7 @@ void VM_cvar_set(prvm_prog_t *prog) VM_VarString(prog, 1, string, sizeof(string)); name = PRVM_G_STRING(OFS_PARM0); VM_CheckEmptyString(prog, name); - Cvar_Set(name, string); + Cvar_Set(prog->console_cmd->cvars, name, string); } /* @@ -1023,7 +1035,7 @@ void VM_find(prvm_prog_t *prog) f = PRVM_G_INT(OFS_PARM1); s = PRVM_G_STRING(OFS_PARM2); - // LordHavoc: apparently BloodMage does a find(world, weaponmodel, "") and + // LadyHavoc: apparently BloodMage does a find(world, weaponmodel, "") and // expects it to find all the monsters, so we must be careful to support // searching for "" @@ -1054,12 +1066,12 @@ VM_findfloat entity findentity(entity start, .entity field, entity match) ========= */ -// LordHavoc: added this for searching float, int, and entity reference fields +// LadyHavoc: added this for searching float, int, and entity reference fields void VM_findfloat(prvm_prog_t *prog) { int e; int f; - float s; + prvm_vec_t s; prvm_edict_t *ed; VM_SAFEPARMCOUNT(3,VM_findfloat); @@ -1115,7 +1127,7 @@ void VM_findchain(prvm_prog_t *prog) f = PRVM_G_INT(OFS_PARM0); s = PRVM_G_STRING(OFS_PARM1); - // LordHavoc: apparently BloodMage does a find(world, weaponmodel, "") and + // LadyHavoc: apparently BloodMage does a find(world, weaponmodel, "") and // expects it to find all the monsters, so we must be careful to support // searching for "" @@ -1146,13 +1158,13 @@ entity findchainfloat(.string field, float match) entity findchainentity(.string field, entity match) ========= */ -// LordHavoc: chained search for float, int, and entity reference fields +// LadyHavoc: chained search for float, int, and entity reference fields // entity(.string field, float match) findchainfloat = #403; void VM_findchainfloat(prvm_prog_t *prog) { int i; int f; - float s; + prvm_vec_t s; prvm_edict_t *ent, *chain; int chainfield; @@ -1193,7 +1205,7 @@ VM_findflags entity findflags(entity start, .float field, float match) ======================== */ -// LordHavoc: search for flags in float fields +// LadyHavoc: search for flags in float fields void VM_findflags(prvm_prog_t *prog) { prvm_int_t e; @@ -1233,7 +1245,7 @@ VM_findchainflags entity findchainflags(.float field, float match) ======================== */ -// LordHavoc: chained search for flags in float fields +// LadyHavoc: chained search for flags in float fields void VM_findchainflags(prvm_prog_t *prog) { prvm_int_t i; @@ -1323,11 +1335,12 @@ coredump() */ void VM_coredump(prvm_prog_t *prog) { + cmd_state_t *cmd = cls.state == ca_dedicated ? &cmd_server : &cmd_client; VM_SAFEPARMCOUNT(0,VM_coredump); - Cbuf_AddText("prvm_edicts "); - Cbuf_AddText(prog->name); - Cbuf_AddText("\n"); + Cbuf_AddText(cmd, "prvm_edicts "); + Cbuf_AddText(cmd, prog->name); + Cbuf_AddText(cmd, "\n"); } /* @@ -1508,7 +1521,7 @@ void VM_changelevel(prvm_prog_t *prog) return; svs.changelevel_issued = true; - Cbuf_AddText(va(vabuf, sizeof(vabuf), "changelevel %s\n",PRVM_G_STRING(OFS_PARM0))); + Cbuf_AddText(&cmd_server, va(vabuf, sizeof(vabuf), "changelevel %s\n", PRVM_G_STRING(OFS_PARM0))); } /* @@ -1652,17 +1665,17 @@ void VM_registercvar(prvm_prog_t *prog) return; // first check to see if it has already been defined - if (Cvar_FindVar (name)) + if (Cvar_FindVar (prog->console_cmd->cvars, name, prog->console_cmd->cvars_flagsmask)) return; // check for overlap with a command - if (Cmd_Exists (name)) + if (Cmd_Exists(&cmd_client, name) || Cmd_Exists(&cmd_server, name)) { VM_Warning(prog, "VM_registercvar: %s is a command\n", name); return; } - Cvar_Get(name, value, flags, NULL); + Cvar_Get(prog->console_cmd->cvars, name, value, prog->console_cmd->cvars_flagsmask | flags, NULL); PRVM_G_FLOAT(OFS_RETURN) = 1; // success } @@ -1680,7 +1693,7 @@ float min(float a, float b, ...[float]) void VM_min(prvm_prog_t *prog) { VM_SAFEPARMCOUNTRANGE(2, 8, VM_min); - // LordHavoc: 3+ argument enhancement suggested by FrikaC + // LadyHavoc: 3+ argument enhancement suggested by FrikaC if (prog->argc >= 3) { int i; @@ -1706,7 +1719,7 @@ float max(float a, float b, ...[float]) void VM_max(prvm_prog_t *prog) { VM_SAFEPARMCOUNTRANGE(2, 8, VM_max); - // LordHavoc: 3+ argument enhancement suggested by FrikaC + // LadyHavoc: 3+ argument enhancement suggested by FrikaC if (prog->argc >= 3) { int i; @@ -2189,7 +2202,7 @@ void VM_strdecolorize(prvm_prog_t *prog) // Prepare Strings VM_SAFEPARMCOUNT(1,VM_strdecolorize); szString = PRVM_G_STRING(OFS_PARM0); - COM_StringDecolorize(szString, 0, szNewString, sizeof(szNewString), TRUE); + COM_StringDecolorize(szString, 0, szNewString, sizeof(szNewString), true); PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, szNewString); } @@ -2437,7 +2450,7 @@ void VM_strireplace(prvm_prog_t *prog) char string[VM_STRINGTEMP_LENGTH]; int search_len, replace_len, subject_len; - VM_SAFEPARMCOUNT(3,VM_strreplace); + VM_SAFEPARMCOUNT(3, VM_strireplace); search = PRVM_G_STRING(OFS_PARM0); replace = PRVM_G_STRING(OFS_PARM1); @@ -2551,7 +2564,7 @@ clientcommand(float client, string s) (for client and menu) ========= */ //void(entity e, string s) clientcommand = #440; // executes a command string as if it came from the specified client -//this function originally written by KrimZon, made shorter by LordHavoc +//this function originally written by KrimZon, made shorter by LadyHavoc void VM_clcommand (prvm_prog_t *prog) { client_t *temp_client; @@ -2568,7 +2581,7 @@ void VM_clcommand (prvm_prog_t *prog) temp_client = host_client; host_client = svs.clients + i; - Cmd_ExecuteString (PRVM_G_STRING(OFS_PARM1), src_client, true); + Cmd_ExecuteString (&cmd_serverfromclient, PRVM_G_STRING(OFS_PARM1), src_client, true); host_client = temp_client; } @@ -2581,8 +2594,8 @@ float tokenize(string s) ========= */ //float(string s) tokenize = #441; // takes apart a string into individal words (access them with argv), returns how many -//this function originally written by KrimZon, made shorter by LordHavoc -//20040203: rewritten by LordHavoc (no longer uses allocations) +//this function originally written by KrimZon, made shorter by LadyHavoc +//20040203: rewritten by LadyHavoc (no longer uses allocations) static int num_tokens = 0; static int tokens[VM_STRINGTEMP_LENGTH / 2]; static int tokens_startpos[VM_STRINGTEMP_LENGTH / 2]; @@ -2623,7 +2636,7 @@ void VM_tokenize_console (prvm_prog_t *prog) { const char *p; - VM_SAFEPARMCOUNT(1,VM_tokenize); + VM_SAFEPARMCOUNT(1, VM_tokenize_console); strlcpy(tokenize_string, PRVM_G_STRING(OFS_PARM0), sizeof(tokenize_string)); p = tokenize_string; @@ -2728,7 +2741,7 @@ void VM_tokenizebyseparator (prvm_prog_t *prog) } //string(float n) argv = #442; // returns a word from the tokenized string (returns nothing for an invalid index) -//this function originally written by KrimZon, made shorter by LordHavoc +//this function originally written by KrimZon, made shorter by LadyHavoc void VM_argv (prvm_prog_t *prog) { int token_num; @@ -2791,7 +2804,7 @@ float isserver() */ void VM_isserver(prvm_prog_t *prog) { - VM_SAFEPARMCOUNT(0,VM_serverstate); + VM_SAFEPARMCOUNT(0, VM_isserver); PRVM_G_FLOAT(OFS_RETURN) = sv.active; } @@ -2872,9 +2885,7 @@ VM_gettime float gettime(prvm_prog_t *prog) ========= */ -#ifdef CONFIG_CD float CDAudio_GetPosition(void); -#endif void VM_gettime(prvm_prog_t *prog) { int timer_index; @@ -2883,7 +2894,7 @@ void VM_gettime(prvm_prog_t *prog) if(prog->argc == 0) { - PRVM_G_FLOAT(OFS_RETURN) = (prvm_vec_t) realtime; + PRVM_G_FLOAT(OFS_RETURN) = (prvm_vec_t) host.realtime; } else { @@ -2891,25 +2902,23 @@ void VM_gettime(prvm_prog_t *prog) switch(timer_index) { case 0: // GETTIME_FRAMESTART - PRVM_G_FLOAT(OFS_RETURN) = realtime; + PRVM_G_FLOAT(OFS_RETURN) = host.realtime; break; case 1: // GETTIME_REALTIME PRVM_G_FLOAT(OFS_RETURN) = Sys_DirtyTime(); break; case 2: // GETTIME_HIRES - PRVM_G_FLOAT(OFS_RETURN) = (Sys_DirtyTime() - host_dirtytime); + PRVM_G_FLOAT(OFS_RETURN) = (Sys_DirtyTime() - host.dirtytime); break; case 3: // GETTIME_UPTIME - PRVM_G_FLOAT(OFS_RETURN) = realtime; + PRVM_G_FLOAT(OFS_RETURN) = host.realtime; break; -#ifdef CONFIG_CD case 4: // GETTIME_CDTRACK PRVM_G_FLOAT(OFS_RETURN) = CDAudio_GetPosition(); break; -#endif default: VM_Warning(prog, "VM_gettime: %s: unsupported timer specified, returning realtime\n", prog->name); - PRVM_G_FLOAT(OFS_RETURN) = realtime; + PRVM_G_FLOAT(OFS_RETURN) = host.realtime; break; } } @@ -2971,7 +2980,7 @@ loadfromdata(string data) */ void VM_loadfromdata(prvm_prog_t *prog) { - VM_SAFEPARMCOUNT(1,VM_loadentsfromfile); + VM_SAFEPARMCOUNT(1, VM_loadfromdata); PRVM_ED_LoadFromFile(prog, PRVM_G_STRING(OFS_PARM0)); } @@ -3048,7 +3057,7 @@ float mod(float val, float m) void VM_modulo(prvm_prog_t *prog) { prvm_int_t val, m; - VM_SAFEPARMCOUNT(2,VM_module); + VM_SAFEPARMCOUNT(2, VM_modulo); val = (prvm_int_t) PRVM_G_FLOAT(OFS_PARM0); m = (prvm_int_t) PRVM_G_FLOAT(OFS_PARM1); @@ -3158,7 +3167,7 @@ float search_getsize(float handle) void VM_search_getsize(prvm_prog_t *prog) { int handle; - VM_SAFEPARMCOUNT(1, VM_M_search_getsize); + VM_SAFEPARMCOUNT(1, VM_search_getsize); handle = (int)PRVM_G_FLOAT(OFS_PARM0); @@ -3270,7 +3279,7 @@ string precache_pic(string pic) void VM_precache_pic(prvm_prog_t *prog) { const char *s; - int flags = 0; + int flags = CACHEPICFLAG_FAILONMISSING; VM_SAFEPARMCOUNTRANGE(1, 2, VM_precache_pic); @@ -3289,8 +3298,7 @@ void VM_precache_pic(prvm_prog_t *prog) flags |= CACHEPICFLAG_MIPMAP; } - // AK Draw_CachePic is supposed to always return a valid pointer - if( Draw_CachePic_Flags(s, flags)->tex == r_texture_notexture ) + if( !Draw_IsPicLoaded(Draw_CachePic_Flags(s, flags | CACHEPICFLAG_QUIET)) ) PRVM_G_INT(OFS_RETURN) = OFS_NULL; } @@ -3348,6 +3356,9 @@ void VM_drawcharacter(prvm_prog_t *prog) float sx, sy; VM_SAFEPARMCOUNT(6,VM_drawcharacter); + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; + character = (char) PRVM_G_FLOAT(OFS_PARM1); if(character == 0) { @@ -3398,6 +3409,9 @@ void VM_drawstring(prvm_prog_t *prog) float sx, sy; VM_SAFEPARMCOUNTRANGE(5,6,VM_drawstring); + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; + string = PRVM_G_STRING(OFS_PARM1); pos = PRVM_G_VECTOR(OFS_PARM0); scale = PRVM_G_VECTOR(OFS_PARM2); @@ -3447,6 +3461,9 @@ void VM_drawcolorcodedstring(prvm_prog_t *prog) VM_SAFEPARMCOUNTRANGE(5,6,VM_drawcolorcodedstring); + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; + if (prog->argc == 6) // full 6 parms, like normal drawstring { pos = PRVM_G_VECTOR(OFS_PARM0); @@ -3507,7 +3524,7 @@ void VM_stringwidth(prvm_prog_t *prog) int colors; float sx, sy; size_t maxlen = 0; - VM_SAFEPARMCOUNTRANGE(2,3,VM_drawstring); + VM_SAFEPARMCOUNTRANGE(2, 3, VM_stringwidth); getdrawfontscale(prog, &sx, &sy); if(prog->argc == 3) @@ -3732,6 +3749,9 @@ void VM_drawpic(prvm_prog_t *prog) VM_SAFEPARMCOUNTRANGE(5,6,VM_drawpic); + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; + picname = PRVM_G_STRING(OFS_PARM1); VM_CheckEmptyString(prog, picname); @@ -3777,6 +3797,9 @@ void VM_drawrotpic(prvm_prog_t *prog) VM_SAFEPARMCOUNT(8,VM_drawrotpic); + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; + picname = PRVM_G_STRING(OFS_PARM1); VM_CheckEmptyString(prog, picname); @@ -3823,6 +3846,9 @@ void VM_drawsubpic(prvm_prog_t *prog) VM_SAFEPARMCOUNT(8,VM_drawsubpic); + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; + picname = PRVM_G_STRING(OFS_PARM2); VM_CheckEmptyString(prog, picname); @@ -3876,6 +3902,8 @@ void VM_drawfill(prvm_prog_t *prog) VM_SAFEPARMCOUNT(5,VM_drawfill); + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; pos = PRVM_G_VECTOR(OFS_PARM0); size = PRVM_G_VECTOR(OFS_PARM1); @@ -3908,6 +3936,9 @@ void VM_drawsetcliparea(prvm_prog_t *prog) float x,y,w,h; VM_SAFEPARMCOUNT(4,VM_drawsetcliparea); + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; + x = bound(0, PRVM_G_FLOAT(OFS_PARM0), vid_conwidth.integer); y = bound(0, PRVM_G_FLOAT(OFS_PARM1), vid_conheight.integer); w = bound(0, PRVM_G_FLOAT(OFS_PARM2) + PRVM_G_FLOAT(OFS_PARM0) - x, (vid_conwidth.integer - x)); @@ -3927,6 +3958,9 @@ void VM_drawresetcliparea(prvm_prog_t *prog) { VM_SAFEPARMCOUNT(0,VM_drawresetcliparea); + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; + DrawQ_ResetClipArea(); } @@ -3947,16 +3981,16 @@ void VM_getimagesize(prvm_prog_t *prog) p = PRVM_G_STRING(OFS_PARM0); VM_CheckEmptyString(prog, p); - pic = Draw_CachePic_Flags (p, CACHEPICFLAG_NOTPERSISTENT); - if( pic->tex == r_texture_notexture ) + pic = Draw_CachePic_Flags (p, CACHEPICFLAG_QUIET | CACHEPICFLAG_NOTPERSISTENT); + if (!Draw_IsPicLoaded(pic)) { 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)[0] = Draw_GetPicWidth(pic); + PRVM_G_VECTOR(OFS_RETURN)[1] = Draw_GetPicHeight(pic); } PRVM_G_VECTOR(OFS_RETURN)[2] = 0; } @@ -4024,7 +4058,7 @@ float stringtokeynum(string key) */ void VM_stringtokeynum (prvm_prog_t *prog) { - VM_SAFEPARMCOUNT( 1, VM_keynumtostring ); + VM_SAFEPARMCOUNT( 1, VM_stringtokeynum ); PRVM_G_FLOAT(OFS_RETURN) = Key_StringToKeynum(PRVM_G_STRING(OFS_PARM0)); } @@ -4039,7 +4073,7 @@ string getkeybind(float key, float bindmap) void VM_getkeybind (prvm_prog_t *prog) { int bindmap; - VM_SAFEPARMCOUNTRANGE(1, 2, VM_CL_getkeybind); + VM_SAFEPARMCOUNTRANGE(1, 2, VM_getkeybind); if(prog->argc == 2) bindmap = bound(-1, PRVM_G_FLOAT(OFS_PARM1), MAX_BINDMAPS-1); else @@ -4058,7 +4092,7 @@ float setkeybind(float key, string cmd, float bindmap) void VM_setkeybind (prvm_prog_t *prog) { int bindmap; - VM_SAFEPARMCOUNTRANGE(2, 3, VM_CL_setkeybind); + VM_SAFEPARMCOUNTRANGE(2, 3, VM_setkeybind); if(prog->argc == 3) bindmap = bound(-1, PRVM_G_FLOAT(OFS_PARM2), MAX_BINDMAPS-1); else @@ -4079,7 +4113,7 @@ vector getbindmaps() void VM_getbindmaps (prvm_prog_t *prog) { int fg, bg; - VM_SAFEPARMCOUNT(0, VM_CL_getbindmap); + VM_SAFEPARMCOUNT(0, VM_getbindmaps); Key_GetBindMap(&fg, &bg); PRVM_G_VECTOR(OFS_RETURN)[0] = fg; PRVM_G_VECTOR(OFS_RETURN)[1] = bg; @@ -4095,7 +4129,7 @@ float setbindmaps(vector bindmap) */ void VM_setbindmaps (prvm_prog_t *prog) { - VM_SAFEPARMCOUNT(1, VM_CL_setbindmap); + VM_SAFEPARMCOUNT(1, VM_setbindmaps); PRVM_G_FLOAT(OFS_RETURN) = 0; if(PRVM_G_VECTOR(OFS_PARM0)[2] == 0) if(Key_SetBindMap((int)PRVM_G_VECTOR(OFS_PARM0)[0], (int)PRVM_G_VECTOR(OFS_PARM0)[1])) @@ -4161,7 +4195,7 @@ void VM_cin_setstate(prvm_prog_t *prog) clvideostate_t state; clvideo_t *video; - VM_SAFEPARMCOUNT( 2, VM_cin_netstate ); + VM_SAFEPARMCOUNT( 2, VM_cin_setstate ); name = PRVM_G_STRING( OFS_PARM0 ); VM_CheckEmptyString(prog, name ); @@ -4356,6 +4390,10 @@ void VM_drawline (prvm_prog_t *prog) unsigned char flags; VM_SAFEPARMCOUNT(6, VM_drawline); + + // polygonbegin without draw2d arg has to guess + prog->polygonbegin_guess2d = true; + width = PRVM_G_FLOAT(OFS_PARM0); c1 = PRVM_G_VECTOR(OFS_PARM1); c2 = PRVM_G_VECTOR(OFS_PARM2); @@ -4740,9 +4778,9 @@ void VM_buf_create (prvm_prog_t *prog) { prvm_stringbuffer_t *stringbuffer; int i; - + VM_SAFEPARMCOUNTRANGE(0, 2, VM_buf_create); - + // VorteX: optional parm1 (buffer format) is unfinished, to keep intact with future databuffers extension must be set to "string" if(prog->argc >= 1 && strcmp(PRVM_G_STRING(OFS_PARM0), "string")) { @@ -4861,7 +4899,7 @@ void VM_buf_copy (prvm_prog_t *prog) ======================== VM_buf_sort sort buffer by beginnings of strings (cmplength defaults it's length) -"backward == TRUE" means that sorting goes upside-down +"backward == true" means that sorting goes upside-down void buf_sort(float bufhandle, float cmplength, float backward) = #464; ======================== */ @@ -5000,7 +5038,7 @@ void VM_bufstr_set (prvm_prog_t *prog) ======================== VM_bufstr_add adds string to buffer in first free slot and returns its index -"order == TRUE" means that string will be added after last "full" slot +"order == true" means that string will be added after last "full" slot float bufstr_add(float bufhandle, string str, float order) = #467; ======================== */ @@ -5339,7 +5377,7 @@ void VM_bufstr_find(prvm_prog_t *prog) char string[VM_STRINGTEMP_LENGTH]; int matchrule, matchlen, i, step; const char *match; - + VM_SAFEPARMCOUNTRANGE(3, 5, VM_bufstr_find); PRVM_G_FLOAT(OFS_RETURN) = -1; @@ -5354,7 +5392,7 @@ void VM_bufstr_find(prvm_prog_t *prog) // get pattern/rule matchrule = (int)PRVM_G_FLOAT(OFS_PARM2); - if (matchrule < 0 && matchrule > 5) + if (matchrule < 0 || matchrule > 5) { VM_Warning(prog, "VM_bufstr_find: invalid match rule %i in %s\n", matchrule, prog->name); return; @@ -5400,9 +5438,9 @@ void VM_matchpattern(prvm_prog_t *prog) // get pattern/rule matchrule = (int)PRVM_G_FLOAT(OFS_PARM2); - if (matchrule < 0 && matchrule > 5) + if (matchrule < 0 || matchrule > 5) { - VM_Warning(prog, "VM_bufstr_find: invalid match rule %i in %s\n", matchrule, prog->name); + VM_Warning(prog, "VM_matchpattern: invalid match rule %i in %s\n", matchrule, prog->name); return; } if (matchrule) @@ -5472,7 +5510,7 @@ void VM_buf_cvarlist(prvm_prog_t *prog) antiispattern = antipartial && (strchr(antipartial, '*') || strchr(antipartial, '?')); n = 0; - for(cvar = cvar_vars; cvar; cvar = cvar->next) + for(cvar = prog->console_cmd->cvars->vars; cvar; cvar = cvar->next) { if(len && (ispattern ? !matchpattern_with_separator(cvar->name, partial, false, "", false) : strncmp(partial, cvar->name, len))) continue; @@ -5488,7 +5526,7 @@ void VM_buf_cvarlist(prvm_prog_t *prog) stringbuffer->strings = (char **)Mem_Alloc(prog->progs_mempool, sizeof(stringbuffer->strings[0]) * stringbuffer->max_strings); n = 0; - for(cvar = cvar_vars; cvar; cvar = cvar->next) + for(cvar = prog->console_cmd->cvars->vars; cvar; cvar = cvar->next) { if(len && (ispattern ? !matchpattern_with_separator(cvar->name, partial, false, "", false) : strncmp(partial, cvar->name, len))) continue; @@ -5634,7 +5672,7 @@ void VM_uncolorstring (prvm_prog_t *prog) // Prepare Strings VM_SAFEPARMCOUNT(1, VM_uncolorstring); szString = PRVM_G_STRING(OFS_PARM0); - COM_StringDecolorize(szString, 0, szNewString, sizeof(szNewString), TRUE); + COM_StringDecolorize(szString, 0, szNewString, sizeof(szNewString), true); PRVM_G_INT(OFS_RETURN) = PRVM_SetTempString(prog, szNewString); } @@ -6036,11 +6074,14 @@ void VM_Cmd_Init(prvm_prog_t *prog) VM_Search_Init(prog); } +static void animatemodel_reset(prvm_prog_t *prog); + void VM_Cmd_Reset(prvm_prog_t *prog) { CL_PurgeOwner( MENUOWNER ); VM_Search_Reset(prog); VM_Files_CloseAll(prog); + animatemodel_reset(prog); } // #510 string(string input, ...) uri_escape (DP_QC_URI_ESCAPE) @@ -6444,7 +6485,7 @@ void VM_callfunction(prvm_prog_t *prog) func = PRVM_ED_FindFunction(prog, s); if(!func) - prog->error_cmd("VM_callfunciton: function %s not found !", s); + prog->error_cmd("VM_callfunction: function %s not found !", s); else if (func->first_statement < 0) { // negative statements are built in functions @@ -6833,9 +6874,8 @@ static dp_model_t *getmodel(prvm_prog_t *prog, prvm_edict_t *ed) return NULL; } -typedef struct +struct animatemodel_cache { - unsigned int progid; dp_model_t *model; frameblend_t frameblend[MAX_FRAMEBLENDS]; skeleton_t *skeleton_p; @@ -6849,61 +6889,74 @@ typedef struct float *buf_svector3f; float *buf_tvector3f; float *buf_normal3f; +}; + +static void animatemodel_reset(prvm_prog_t *prog) +{ + if (!prog->animatemodel_cache) + return; + if(prog->animatemodel_cache->buf_vertex3f) Mem_Free(prog->animatemodel_cache->buf_vertex3f); + if(prog->animatemodel_cache->buf_svector3f) Mem_Free(prog->animatemodel_cache->buf_svector3f); + if(prog->animatemodel_cache->buf_tvector3f) Mem_Free(prog->animatemodel_cache->buf_tvector3f); + if(prog->animatemodel_cache->buf_normal3f) Mem_Free(prog->animatemodel_cache->buf_normal3f); + Mem_Free(prog->animatemodel_cache); } -animatemodel_cache_t; -static animatemodel_cache_t animatemodel_cache; static void animatemodel(prvm_prog_t *prog, dp_model_t *model, prvm_edict_t *ed) { skeleton_t *skeleton; int skeletonindex = -1; qboolean need = false; + struct animatemodel_cache *animatemodel_cache; + if (!prog->animatemodel_cache) + { + prog->animatemodel_cache = (struct animatemodel_cache *)Mem_Alloc(prog->progs_mempool, sizeof(struct animatemodel_cache)); + memset(prog->animatemodel_cache, 0, sizeof(struct animatemodel_cache)); + } + animatemodel_cache = prog->animatemodel_cache; if(!(model->surfmesh.isanimated && model->AnimateVertices)) { - animatemodel_cache.data_vertex3f = model->surfmesh.data_vertex3f; - animatemodel_cache.data_svector3f = model->surfmesh.data_svector3f; - animatemodel_cache.data_tvector3f = model->surfmesh.data_tvector3f; - animatemodel_cache.data_normal3f = model->surfmesh.data_normal3f; + animatemodel_cache->data_vertex3f = model->surfmesh.data_vertex3f; + animatemodel_cache->data_svector3f = model->surfmesh.data_svector3f; + animatemodel_cache->data_tvector3f = model->surfmesh.data_tvector3f; + animatemodel_cache->data_normal3f = model->surfmesh.data_normal3f; return; } - if(animatemodel_cache.progid != prog->id) - memset(&animatemodel_cache, 0, sizeof(animatemodel_cache)); - need |= (animatemodel_cache.model != model); + need |= (animatemodel_cache->model != model); VM_GenerateFrameGroupBlend(prog, ed->priv.server->framegroupblend, ed); VM_FrameBlendFromFrameGroupBlend(ed->priv.server->frameblend, ed->priv.server->framegroupblend, model, PRVM_serverglobalfloat(time)); - need |= (memcmp(&animatemodel_cache.frameblend, &ed->priv.server->frameblend, sizeof(ed->priv.server->frameblend))) != 0; + need |= (memcmp(&animatemodel_cache->frameblend, &ed->priv.server->frameblend, sizeof(ed->priv.server->frameblend))) != 0; skeletonindex = (int)PRVM_gameedictfloat(ed, skeletonindex) - 1; if (!(skeletonindex >= 0 && skeletonindex < MAX_EDICTS && (skeleton = prog->skeletons[skeletonindex]) && skeleton->model->num_bones == ed->priv.server->skeleton.model->num_bones)) skeleton = NULL; - need |= (animatemodel_cache.skeleton_p != skeleton); + need |= (animatemodel_cache->skeleton_p != skeleton); if(skeleton) - need |= (memcmp(&animatemodel_cache.skeleton, skeleton, sizeof(ed->priv.server->skeleton))) != 0; + need |= (memcmp(&animatemodel_cache->skeleton, skeleton, sizeof(ed->priv.server->skeleton))) != 0; if(!need) return; - if(model->surfmesh.num_vertices > animatemodel_cache.max_vertices) - { - animatemodel_cache.max_vertices = model->surfmesh.num_vertices * 2; - if(animatemodel_cache.buf_vertex3f) Mem_Free(animatemodel_cache.buf_vertex3f); - if(animatemodel_cache.buf_svector3f) Mem_Free(animatemodel_cache.buf_svector3f); - if(animatemodel_cache.buf_tvector3f) Mem_Free(animatemodel_cache.buf_tvector3f); - if(animatemodel_cache.buf_normal3f) Mem_Free(animatemodel_cache.buf_normal3f); - animatemodel_cache.buf_vertex3f = (float *)Mem_Alloc(prog->progs_mempool, sizeof(float[3]) * animatemodel_cache.max_vertices); - animatemodel_cache.buf_svector3f = (float *)Mem_Alloc(prog->progs_mempool, sizeof(float[3]) * animatemodel_cache.max_vertices); - animatemodel_cache.buf_tvector3f = (float *)Mem_Alloc(prog->progs_mempool, sizeof(float[3]) * animatemodel_cache.max_vertices); - animatemodel_cache.buf_normal3f = (float *)Mem_Alloc(prog->progs_mempool, sizeof(float[3]) * animatemodel_cache.max_vertices); - } - animatemodel_cache.data_vertex3f = animatemodel_cache.buf_vertex3f; - animatemodel_cache.data_svector3f = animatemodel_cache.buf_svector3f; - animatemodel_cache.data_tvector3f = animatemodel_cache.buf_tvector3f; - animatemodel_cache.data_normal3f = animatemodel_cache.buf_normal3f; + if(model->surfmesh.num_vertices > animatemodel_cache->max_vertices) + { + animatemodel_cache->max_vertices = model->surfmesh.num_vertices * 2; + if(animatemodel_cache->buf_vertex3f) Mem_Free(animatemodel_cache->buf_vertex3f); + if(animatemodel_cache->buf_svector3f) Mem_Free(animatemodel_cache->buf_svector3f); + if(animatemodel_cache->buf_tvector3f) Mem_Free(animatemodel_cache->buf_tvector3f); + if(animatemodel_cache->buf_normal3f) Mem_Free(animatemodel_cache->buf_normal3f); + animatemodel_cache->buf_vertex3f = (float *)Mem_Alloc(prog->progs_mempool, sizeof(float[3]) * animatemodel_cache->max_vertices); + animatemodel_cache->buf_svector3f = (float *)Mem_Alloc(prog->progs_mempool, sizeof(float[3]) * animatemodel_cache->max_vertices); + animatemodel_cache->buf_tvector3f = (float *)Mem_Alloc(prog->progs_mempool, sizeof(float[3]) * animatemodel_cache->max_vertices); + animatemodel_cache->buf_normal3f = (float *)Mem_Alloc(prog->progs_mempool, sizeof(float[3]) * animatemodel_cache->max_vertices); + } + animatemodel_cache->data_vertex3f = animatemodel_cache->buf_vertex3f; + animatemodel_cache->data_svector3f = animatemodel_cache->buf_svector3f; + animatemodel_cache->data_tvector3f = animatemodel_cache->buf_tvector3f; + animatemodel_cache->data_normal3f = animatemodel_cache->buf_normal3f; VM_UpdateEdictSkeleton(prog, ed, model, ed->priv.server->frameblend); - model->AnimateVertices(model, ed->priv.server->frameblend, &ed->priv.server->skeleton, animatemodel_cache.data_vertex3f, animatemodel_cache.data_normal3f, animatemodel_cache.data_svector3f, animatemodel_cache.data_tvector3f); - animatemodel_cache.progid = prog->id; - animatemodel_cache.model = model; - memcpy(&animatemodel_cache.frameblend, &ed->priv.server->frameblend, sizeof(ed->priv.server->frameblend)); - animatemodel_cache.skeleton_p = skeleton; + model->AnimateVertices(model, ed->priv.server->frameblend, &ed->priv.server->skeleton, animatemodel_cache->data_vertex3f, animatemodel_cache->data_normal3f, animatemodel_cache->data_svector3f, animatemodel_cache->data_tvector3f); + animatemodel_cache->model = model; + memcpy(&animatemodel_cache->frameblend, &ed->priv.server->frameblend, sizeof(ed->priv.server->frameblend)); + animatemodel_cache->skeleton_p = skeleton; if(skeleton) - memcpy(&animatemodel_cache.skeleton, skeleton, sizeof(ed->priv.server->skeleton)); + memcpy(&animatemodel_cache->skeleton, skeleton, sizeof(ed->priv.server->skeleton)); } static void getmatrix(prvm_prog_t *prog, prvm_edict_t *ed, matrix4x4_t *out) @@ -6959,9 +7012,9 @@ static void clippointtosurface(prvm_prog_t *prog, prvm_edict_t *ed, dp_model_t * { // clip original point to each triangle of the surface and find the // triangle that is closest - v[0] = animatemodel_cache.data_vertex3f + e[0] * 3; - v[1] = animatemodel_cache.data_vertex3f + e[1] * 3; - v[2] = animatemodel_cache.data_vertex3f + e[2] * 3; + v[0] = prog->animatemodel_cache->data_vertex3f + e[0] * 3; + v[1] = prog->animatemodel_cache->data_vertex3f + e[1] * 3; + v[2] = prog->animatemodel_cache->data_vertex3f + e[2] * 3; TriangleNormal(v[0], v[1], v[2], facenormal); VectorNormalize(facenormal); offsetdist = DotProduct(v[0], facenormal) - DotProduct(p, facenormal); @@ -7026,7 +7079,7 @@ void VM_getsurfacepoint(prvm_prog_t *prog) if (pointnum < 0 || pointnum >= surface->num_vertices) return; animatemodel(prog, model, ed); - applytransform_forward(prog, &(animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); + applytransform_forward(prog, &(prog->animatemodel_cache->data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN)); } //PF_getsurfacepointattribute, // #486 vector(entity e, float s, float n, float a) getsurfacepointattribute = #486; @@ -7046,7 +7099,7 @@ void VM_getsurfacepointattribute(prvm_prog_t *prog) int attributetype; vec3_t result; - VM_SAFEPARMCOUNT(4, VM_getsurfacepoint); + VM_SAFEPARMCOUNT(4, VM_getsurfacepointattribute); VectorClear(PRVM_G_VECTOR(OFS_RETURN)); ed = PRVM_G_EDICT(OFS_PARM0); if (!(model = getmodel(prog, ed)) || !(surface = getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1)))) @@ -7061,22 +7114,22 @@ void VM_getsurfacepointattribute(prvm_prog_t *prog) switch( attributetype ) { // float SPA_POSITION = 0; case 0: - applytransform_forward(prog, &(animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); + applytransform_forward(prog, &(prog->animatemodel_cache->data_vertex3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN)); break; // float SPA_S_AXIS = 1; case 1: - applytransform_forward_direction(prog, &(animatemodel_cache.data_svector3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); + applytransform_forward_direction(prog, &(prog->animatemodel_cache->data_svector3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN)); break; // float SPA_T_AXIS = 2; case 2: - applytransform_forward_direction(prog, &(animatemodel_cache.data_tvector3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); + applytransform_forward_direction(prog, &(prog->animatemodel_cache->data_tvector3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN)); break; // float SPA_R_AXIS = 3; // same as SPA_NORMAL case 3: - applytransform_forward_direction(prog, &(animatemodel_cache.data_normal3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); + applytransform_forward_direction(prog, &(prog->animatemodel_cache->data_normal3f + 3 * surface->num_firstvertex)[pointnum * 3], ed, result); VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN)); break; // float SPA_TEXCOORDS0 = 4; @@ -7121,7 +7174,7 @@ void VM_getsurfacenormal(prvm_prog_t *prog) // note: this only returns the first triangle, so it doesn't work very // well for curved surfaces or arbitrary meshes animatemodel(prog, model, PRVM_G_EDICT(OFS_PARM0)); - TriangleNormal((animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex), (animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex) + 3, (animatemodel_cache.data_vertex3f + 3 * surface->num_firstvertex) + 6, normal); + TriangleNormal((prog->animatemodel_cache->data_vertex3f + 3 * surface->num_firstvertex), (prog->animatemodel_cache->data_vertex3f + 3 * surface->num_firstvertex) + 3, (prog->animatemodel_cache->data_vertex3f + 3 * surface->num_firstvertex) + 6, normal); applytransform_forward_normal(prog, normal, PRVM_G_EDICT(OFS_PARM0), result); VectorNormalize(result); VectorCopy(result, PRVM_G_VECTOR(OFS_RETURN)); @@ -7194,7 +7247,7 @@ void VM_getsurfaceclippedpoint(prvm_prog_t *prog) dp_model_t *model; msurface_t *surface; vec3_t p, out, inp; - VM_SAFEPARMCOUNT(3, VM_te_getsurfaceclippedpoint); + VM_SAFEPARMCOUNT(3, VM_getsurfaceclippedpoint); VectorClear(PRVM_G_VECTOR(OFS_RETURN)); ed = PRVM_G_EDICT(OFS_PARM0); if (!(model = getmodel(prog, ed)) || !(surface = getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1)))) @@ -7211,7 +7264,7 @@ void VM_getsurfacenumtriangles(prvm_prog_t *prog) { dp_model_t *model; msurface_t *surface; - VM_SAFEPARMCOUNT(2, VM_SV_getsurfacenumtriangles); + VM_SAFEPARMCOUNT(2, VM_getsurfacenumtriangles); // return 0 if no such surface if (!(model = getmodel(prog, PRVM_G_EDICT(OFS_PARM0))) || !(surface = getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1)))) { @@ -7229,7 +7282,7 @@ void VM_getsurfacetriangle(prvm_prog_t *prog) dp_model_t *model; msurface_t *surface; int trinum; - VM_SAFEPARMCOUNT(3, VM_SV_getsurfacetriangle); + VM_SAFEPARMCOUNT(3, VM_getsurfacetriangle); VectorClear(PRVM_G_VECTOR(OFS_RETURN)); ed = PRVM_G_EDICT(OFS_PARM0); if (!(model = getmodel(prog, ed)) || !(surface = getsurface(model, (int)PRVM_G_FLOAT(OFS_PARM1))))