mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-12-02 00:52:19 +00:00
a6cdc8735a
This is a nice feature found in fteqcc (also a bit of a challenge from Spike). Getting bison to accept the new expression required rewriting the state expression grammar, so this is mostly for the state expression. A test to ensure the state expression doesn't break is included.
53 lines
887 B
R
53 lines
887 B
R
#include "test-harness.h"
|
|
|
|
.void() think;
|
|
.float nextthink;
|
|
.float frame;
|
|
entity self;
|
|
float time;
|
|
|
|
$frame frame0 frame1 frame2 frame3
|
|
|
|
void
|
|
state0 (void)
|
|
[$frame1, state1]
|
|
{
|
|
if (self.frame != $frame1 || self.think != state1
|
|
|| self.nextthink != 0.1) {
|
|
printf ("state0: %g %x %g\n", self.frame, self.think, self.nextthink);
|
|
exit (1);
|
|
}
|
|
}
|
|
|
|
void
|
|
state1 (void)
|
|
[$frame2, state2, 0.2]
|
|
{
|
|
if (self.frame != $frame2 || self.think != state2
|
|
|| self.nextthink != 0.2) {
|
|
printf ("state0: %g %x %g\n", self.frame, self.think, self.nextthink);
|
|
exit (1);
|
|
}
|
|
}
|
|
|
|
void
|
|
state2 (void)
|
|
[$frame0, state0, 0.5]
|
|
{
|
|
if (self.frame != $frame0 || self.think != state0
|
|
|| self.nextthink != 0.5) {
|
|
printf ("state0: %g %x %g\n", self.frame, self.think, self.nextthink);
|
|
exit (1);
|
|
}
|
|
}
|
|
|
|
int
|
|
main ()
|
|
{
|
|
self = spawn ();
|
|
state0();
|
|
while (self.frame != $frame0) {
|
|
self.think();
|
|
}
|
|
return 0;
|
|
}
|