Add anglesub builtin, requested by Shpuld. Returns angle difference within rotations +/- 180.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@6004 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2021-08-04 21:17:52 +00:00
parent 057d8fcff2
commit 8156eda700
4 changed files with 14 additions and 0 deletions

View File

@ -6945,6 +6945,7 @@ static struct {
{"checkextension", PF_checkextension, 99}, // #99 float(string extname) checkextension (EXT_CSQC)
{"checkbuiltin", PF_checkbuiltin, 0},
{"anglemod", PF_anglemod, 102},
{"anglesub", PF_anglesub, 0},
//110
{"fopen", PF_fopen, 110}, // #110 float(string strname, float accessmode) fopen (FRIK_FILE)

View File

@ -6112,6 +6112,17 @@ void QCBUILTIN PF_anglemod (pubprogfuncs_t *prinst, struct globalvars_s *pr_glob
G_FLOAT(OFS_RETURN) = v;
}
void QCBUILTIN PF_anglesub (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
float v = G_FLOAT(OFS_PARM0) - G_FLOAT(OFS_PARM1);
while (v > 180)
v = v - 360;
while (v < -180)
v = v + 360;
G_FLOAT(OFS_RETURN) = v;
}
//void(vector dir) vectorvectors
//Writes new values for v_forward, v_up, and v_right based on the given forward vector

View File

@ -121,6 +121,7 @@ void QCBUILTIN PF_rint (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
void QCBUILTIN PF_floor (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_ceil (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_anglemod (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_anglesub (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_vectorvectors (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_crossproduct (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_Tokenize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);

View File

@ -11085,6 +11085,7 @@ static BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
{"checkbuiltin", PF_checkbuiltin, 0, 0, 0, 0, D("float(__variant funcref)", "Checks to see if the specified builtin is supported/mapped. This is intended as a way to check for #0 functions, allowing for simple single-builtin functions. Warning, if two different engines map different builtins to the same number, then this function will not tell you which will be called, only that it won't crash (the exception being #0, which are remapped as available).")},
{"builtin_find", PF_builtinsupported,100, 100, 0, 100, D("float(string builtinname)", "Looks to see if the named builtin is valid, and returns the builtin number it exists at.")}, // #100 //per builtin system.
{"anglemod", PF_anglemod, 0, 0, 0, 102, "float(float value)"},
{"anglesub", PF_anglesub, 0, 0, 0, 0, D("float(float newangle, float oldangle)","Returns newangle-oldangle, except returning the shortest route around a circle so yields a result between -180 and +180.")},
{"qsg_cvar_string", PF_cvar_string, 0, 0, 0, 103, D("DEP string(string cvarname)","An old/legacy equivelent of more recent/common builtins in order to read a cvar's string value."), true},
//TEI_SHOWLMP2