mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-17 22:50:51 +00:00
Added the sqrt and abs math functions and the continue GIB builtin. I
changed where a loop program gets copied back into its buffer so that the continue builtin would work.
This commit is contained in:
parent
0a8ff6a8cf
commit
91266619f3
5 changed files with 33 additions and 7 deletions
|
@ -44,4 +44,6 @@ double Func_Tan (double *oplist, unsigned int numops);
|
|||
double Func_Asin (double *oplist, unsigned int numops);
|
||||
double Func_Acos (double *oplist, unsigned int numops);
|
||||
double Func_Atan (double *oplist, unsigned int numops);
|
||||
double Func_Sqrt (double *oplist, unsigned int numops);
|
||||
double Func_Abs (double *oplist, unsigned int numops);
|
||||
#endif // __ops_h
|
||||
|
|
|
@ -57,6 +57,8 @@ optable_t optable[] =
|
|||
|
||||
functable_t functable[] =
|
||||
{
|
||||
{"sqrt", Func_Sqrt, 1},
|
||||
{"abs", Func_Abs, 1},
|
||||
{"sin", Func_Sin, 1},
|
||||
{"cos", Func_Cos, 1},
|
||||
{"tan", Func_Tan, 1},
|
||||
|
|
|
@ -415,11 +415,22 @@ GIB_Break_f (void)
|
|||
"break attempted outside of a loop"
|
||||
);
|
||||
else {
|
||||
GIB_DATA(cbuf_active)->type = GIB_BUFFER_PROXY; // If we set it to normal locals will get freed
|
||||
GIB_DATA(cbuf_active)->type = GIB_BUFFER_PROXY; // If we set it to normal, locals will get double freed
|
||||
dstring_clearstr (cbuf_active->buf);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GIB_Continue_f (void)
|
||||
{
|
||||
if (GIB_DATA(cbuf_active)->type != GIB_BUFFER_LOOP)
|
||||
Cbuf_Error ("syntax",
|
||||
"break attempted outside of a loop"
|
||||
);
|
||||
else
|
||||
dstring_clearstr (cbuf_active->buf);
|
||||
}
|
||||
|
||||
// Note: this is a standard console command, not a GIB builtin
|
||||
void
|
||||
GIB_Runexported_f (void)
|
||||
|
@ -890,6 +901,7 @@ GIB_Builtin_Init (qboolean sandbox)
|
|||
GIB_Builtin_Add ("for", GIB_For_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("__for", GIB___For_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("break", GIB_Break_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("continue", GIB_Continue_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("string::length", GIB_String_Length_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("string::equal", GIB_String_Equal_f, GIB_BUILTIN_NORMAL);
|
||||
GIB_Builtin_Add ("string::findsub", GIB_String_Findsub_f, GIB_BUILTIN_NORMAL);
|
||||
|
|
|
@ -279,12 +279,6 @@ GIB_Parse_Extract_Line (struct cbuf_s *cbuf)
|
|||
// Clip out what we used or any leftover newlines or ;s
|
||||
dstring_snip (dstr, 0, i + (dstr->str[i] == '\n' || dstr->str[i] == ';'));
|
||||
}
|
||||
|
||||
// If this is a looping buffer and it is now empty,
|
||||
// copy the loop program back in
|
||||
if (GIB_DATA(cbuf)->type == GIB_BUFFER_LOOP && !cbuf->buf->str[0])
|
||||
Cbuf_AddText (cbuf, GIB_DATA(cbuf)->loop_program->str);
|
||||
|
||||
return;
|
||||
|
||||
PARSE_ERROR: // Extract out the line where the parse error occurred
|
||||
|
@ -540,5 +534,9 @@ GIB_Parse_Execute_Line (cbuf_t *cbuf)
|
|||
} else
|
||||
Cmd_Command (cbuf->args);
|
||||
dstring_clearstr (cbuf->line);
|
||||
// If this is a looping buffer and it is now empty,
|
||||
// copy the loop program back in
|
||||
if (GIB_DATA(cbuf)->type == GIB_BUFFER_LOOP && !cbuf->buf->str[0])
|
||||
Cbuf_AddText (cbuf, GIB_DATA(cbuf)->loop_program->str);
|
||||
}
|
||||
|
||||
|
|
|
@ -147,3 +147,15 @@ Func_Atan (double *oplist, unsigned int numops)
|
|||
{
|
||||
return atan (oplist[0]);
|
||||
}
|
||||
|
||||
double
|
||||
Func_Sqrt (double *oplist, unsigned int numops)
|
||||
{
|
||||
return sqrt (oplist[0]);
|
||||
}
|
||||
|
||||
double
|
||||
Func_Abs (double *oplist, unsigned int numops)
|
||||
{
|
||||
return fabs (oplist[0]);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue