dpvsnprintf(msg,sizeof(msg),fmt,argptr);
va_end(argptr);
- Con_Printf(CON_WARN "%s", msg);
+ Con_Printf(CON_WARN "%s VM warning: %s", prog->name, 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 != host.realtime) // NOTE: this compares to the time, just in case if PRVM_PrintState causes a Host_Error and keeps recursive set
if (!strcasecmp("DP_QC_DIGEST_SHA256", name))
return Crypto_Available();
+ // special shreck for libcurl
+ if (!strcasecmp("DP_QC_URI_GET", name) || !strcasecmp("DP_QC_URI_POST", name))
+ return Curl_Available();
+
return true;
}
}
=================
VM_random
-Returns a number from 0<= num < 1
+Returns a random number > 0 and < 1
float random()
=================
else
chainfield = prog->fieldoffsets.chain;
if (chainfield < 0)
- prog->error_cmd("VM_findchain: %s doesnt have the specified chain field !", prog->name);
+ prog->error_cmd("VM_findchainfloat: %s doesnt have the specified chain field !", prog->name);
chain = (prvm_edict_t *)prog->edicts;
else
chainfield = prog->fieldoffsets.chain;
if (chainfield < 0)
- prog->error_cmd("VM_findchain: %s doesnt have the specified chain field !", prog->name);
+ prog->error_cmd("VM_findchainflags: %s doesnt have the specified chain field !", prog->name);
chain = (prvm_edict_t *)prog->edicts;
=========
VM_strcat
-string strcat(string,string,...[string])
+string strcat(string s, string...)
=========
*/
-//string(string s1, string s2) strcat = #115;
-// concatenates two strings (for example "abc", "def" would return "abcdef")
+//string(string s, string...) strcat = #115;
+// concatenates strings (for example "abc", "def" would return "abcdef")
// and returns as a tempstring
void VM_strcat(prvm_prog_t *prog)
{
*/
void VM_modulo(prvm_prog_t *prog)
{
- prvm_int_t val, m;
+ vec_t val, m;
+
VM_SAFEPARMCOUNT(2, VM_modulo);
- val = (prvm_int_t) PRVM_G_FLOAT(OFS_PARM0);
- m = (prvm_int_t) PRVM_G_FLOAT(OFS_PARM1);
+ val = PRVM_G_FLOAT(OFS_PARM0);
+ m = PRVM_G_FLOAT(OFS_PARM1);
- PRVM_G_FLOAT(OFS_RETURN) = (prvm_vec_t) (val % m);
+ // matches how gmqcc implements % when mod() builtin isn't defined, and FTEQW mod()
+ if (m)
+ PRVM_G_FLOAT(OFS_RETURN) = val - m * (prvm_int_t)(val / m);
+ else
+ {
+ VM_Warning(prog, "Attempted modulo of %f by zero\n", val);
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ }
}
static void VM_Search_Init(prvm_prog_t *prog)
}
}
+// DP_QC_NUDGEOUTOFSOLID
+// float(entity ent) nudgeoutofsolid = #567;
+void VM_nudgeoutofsolid(prvm_prog_t *prog)
+{
+ prvm_edict_t *ent;
+
+ VM_SAFEPARMCOUNTRANGE(1, 1, VM_nudgeoutofsolid);
+
+ ent = PRVM_G_EDICT(OFS_PARM0);
+ if (ent == prog->edicts)
+ {
+ VM_Warning(prog, "nudgeoutofsolid: can not modify world entity\n");
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ return;
+ }
+ if (ent->free)
+ {
+ VM_Warning(prog, "nudgeoutofsolid: can not modify free entity\n");
+ PRVM_G_FLOAT(OFS_RETURN) = 0;
+ return;
+ }
+
+ PRVM_G_FLOAT(OFS_RETURN) = PHYS_NudgeOutOfSolid(prog, ent);
+
+ if (PRVM_G_FLOAT(OFS_RETURN) > 0)
+ {
+ if (prog == SVVM_prog)
+ SV_LinkEdict(ent);
+ else if (prog == CLVM_prog)
+ CL_LinkEdict(ent);
+ else
+ Sys_Error("PHYS_NudgeOutOfSolid: cannot be called from %s VM\n", prog->name);
+ }
+}
+
/*
=========
Common functions between menu.dat and clsprogs