mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-10 15:22:04 +00:00
[gamecode] Clean up state imlementations
This makes the code easier to read. Also, yay for automated tests: caught a mistyped time :)
This commit is contained in:
parent
f7efcde7ab
commit
6b38a17cf1
2 changed files with 16 additions and 22 deletions
|
@ -1488,31 +1488,25 @@ op_call:
|
|||
case OP_STATE:
|
||||
{
|
||||
int self = *pr->globals.self;
|
||||
int nextthink = pr->fields.nextthink;
|
||||
int frame = pr->fields.frame;
|
||||
int think = pr->fields.think;
|
||||
fldofs = self + nextthink;
|
||||
pr->pr_edict_area[fldofs].float_var = *pr->globals.time +
|
||||
0.1;
|
||||
fldofs = self + frame;
|
||||
pr->pr_edict_area[fldofs].float_var = OPA.float_var;
|
||||
fldofs = self + think;
|
||||
pr->pr_edict_area[fldofs].func_var = OPB.func_var;
|
||||
int nextthink = pr->fields.nextthink + self;
|
||||
int frame = pr->fields.frame + self;
|
||||
int think = pr->fields.think + self;
|
||||
float time = *pr->globals.time + 0.1;
|
||||
pr->pr_edict_area[nextthink].float_var = time;
|
||||
pr->pr_edict_area[frame].float_var = OPA.float_var;
|
||||
pr->pr_edict_area[think].func_var = OPB.func_var;
|
||||
}
|
||||
break;
|
||||
case OP_STATE_F:
|
||||
{
|
||||
int self = *pr->globals.self;
|
||||
int nextthink = pr->fields.nextthink;
|
||||
int frame = pr->fields.frame;
|
||||
int think = pr->fields.think;
|
||||
fldofs = self + nextthink;
|
||||
pr->pr_edict_area[fldofs].float_var = *pr->globals.time +
|
||||
OPC.float_var;
|
||||
fldofs = self + frame;
|
||||
pr->pr_edict_area[fldofs].float_var = OPA.float_var;
|
||||
fldofs = self + think;
|
||||
pr->pr_edict_area[fldofs].func_var = OPB.func_var;
|
||||
int nextthink = pr->fields.nextthink + self;
|
||||
int frame = pr->fields.frame + self;
|
||||
int think = pr->fields.think + self;
|
||||
float time = *pr->globals.time + OPC.float_var;
|
||||
pr->pr_edict_area[nextthink].float_var = time;
|
||||
pr->pr_edict_area[frame].float_var = OPA.float_var;
|
||||
pr->pr_edict_area[think].func_var = OPB.func_var;
|
||||
}
|
||||
break;
|
||||
case OP_ADD_I:
|
||||
|
|
|
@ -25,7 +25,7 @@ state1 (void)
|
|||
{
|
||||
if (self.frame != $frame2 || self.think != state2
|
||||
|| self.nextthink != 0.2f) {
|
||||
printf ("state0: %g %x %g\n", self.frame, self.think, self.nextthink);
|
||||
printf ("state1: %g %x %g\n", self.frame, self.think, self.nextthink);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,7 @@ state2 (void)
|
|||
{
|
||||
if (self.frame != $frame0 || self.think != state0
|
||||
|| self.nextthink != 0.5f) {
|
||||
printf ("state0: %g %x %g\n", self.frame, self.think, self.nextthink);
|
||||
printf ("state2: %g %x %g\n", self.frame, self.think, self.nextthink);
|
||||
exit (1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue