mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-01-18 15:01:41 +00:00
various tests
This commit is contained in:
parent
d44f60f17c
commit
c553917c53
3 changed files with 58 additions and 0 deletions
|
@ -112,6 +112,42 @@ bi_traceoff (progs_t *pr)
|
|||
pr->pr_trace = false;
|
||||
}
|
||||
|
||||
static void
|
||||
bi_printf (progs_t *pr)
|
||||
{
|
||||
const char *fmt = G_STRING (pr, OFS_PARM0);
|
||||
char c;
|
||||
int count = 0;
|
||||
float *v;
|
||||
|
||||
while ((c = *fmt++)) {
|
||||
if (c == '%' && count < 7) {
|
||||
switch (c = *fmt++) {
|
||||
case 'i':
|
||||
fprintf (stdout, "%i", G_INT (pr, OFS_PARM1 + count++ * 3));
|
||||
break;
|
||||
case 'f':
|
||||
fprintf (stdout, "%f", G_FLOAT (pr, OFS_PARM1 + count++ * 3));
|
||||
break;
|
||||
case 's':
|
||||
fputs (G_STRING (pr, OFS_PARM1 + count++ * 3), stdout);
|
||||
break;
|
||||
case 'v':
|
||||
v = G_VECTOR (pr, OFS_PARM1 + count++ * 3);
|
||||
fprintf (stdout, "'%f %f %f'", v[0], v[1], v[2]);
|
||||
break;
|
||||
default:
|
||||
fputc ('%', stdout);
|
||||
fputc (c, stdout);
|
||||
count = 7;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
fputc (c, stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
builtin_t builtins[] = {
|
||||
bi_fixme,
|
||||
bi_print,
|
||||
|
@ -125,6 +161,7 @@ builtin_t builtins[] = {
|
|||
bi_seek,
|
||||
bi_traceon,
|
||||
bi_traceoff,
|
||||
bi_printf,
|
||||
};
|
||||
|
||||
void
|
||||
|
|
|
@ -11,6 +11,8 @@ integer (integer handle, integer pos, integer whence) seek = #9;
|
|||
void() traceon = #10; // turns statment trace on
|
||||
void() traceoff = #11;
|
||||
|
||||
void (...) printf = #12;
|
||||
|
||||
|
||||
float time;
|
||||
entity self;
|
||||
|
|
|
@ -58,6 +58,11 @@ void () blarg =
|
|||
{
|
||||
local float foo = -1;
|
||||
local float bar;
|
||||
local entity te;
|
||||
while (te) {
|
||||
if (bar)
|
||||
bar = 0;
|
||||
}
|
||||
do {
|
||||
foo = 1;
|
||||
} while (foo);
|
||||
|
@ -78,6 +83,8 @@ entity sent;
|
|||
void () eek =
|
||||
{
|
||||
local string bop = "";
|
||||
local vector v = '1 2 3';
|
||||
|
||||
traceon();
|
||||
if (sent && sent.owner != self )
|
||||
self.origin = '0 0 0';
|
||||
|
@ -85,6 +92,13 @@ void () eek =
|
|||
test_int (1);
|
||||
if (bop)
|
||||
traceoff();
|
||||
printf ("%v\n", v);
|
||||
v = 2 * v;
|
||||
printf ("%v\n", v);
|
||||
v = v * 2;
|
||||
printf ("%v\n", v);
|
||||
v = -v;
|
||||
printf ("%v\n", v);
|
||||
};
|
||||
|
||||
void () assign =
|
||||
|
@ -97,4 +111,9 @@ void () assign =
|
|||
foo = bar = bar + 1;
|
||||
foo = self.nextthink = self.nextthink + 1.0;
|
||||
self.frame = self.nextthink = self.nextthink + 1.0;
|
||||
foo = self.nextthink = foo + 1.0;
|
||||
self.nextthink = foo = foo + 1.0;
|
||||
self.frame = self.nextthink = foo + 1.0;
|
||||
foo = self.nextthink = foo;
|
||||
self.frame = self.nextthink = foo;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue