lasers/rules: make create_dynamic_laser return MoveParams* in an out-parameter
No need to mess with LaserRuleDynamicData and LaserRuleDynamicTaskData
This commit is contained in:
parent
07a0bdf558
commit
4072d31ffa
2 changed files with 10 additions and 3 deletions
|
@ -146,6 +146,7 @@ TASK(laser_dynamic, {
|
|||
float timespan;
|
||||
float deathtime;
|
||||
const Color *color;
|
||||
MoveParams **out_move;
|
||||
}) {
|
||||
int histsize = ceilf(ARGS.timespan) + 2;
|
||||
assume(histsize > 2);
|
||||
|
@ -160,6 +161,10 @@ TASK(laser_dynamic, {
|
|||
laser_rule_dynamic(THIS_TASK, &td)
|
||||
));
|
||||
|
||||
if(LIKELY(ARGS.out_move)) {
|
||||
*ARGS.out_move = &td.move;
|
||||
}
|
||||
|
||||
*ARGS.out_laser = l;
|
||||
ringbuf_push(&td.history, l->pos); // HACK: this works around some edge cases but we can probably
|
||||
ringbuf_push(&td.history, l->pos); // make the sampling function more robust instead?
|
||||
|
@ -174,9 +179,11 @@ TASK(laser_dynamic, {
|
|||
STALL;
|
||||
}
|
||||
|
||||
Laser *create_dynamic_laser(cmplx pos, float time, float deathtime, const Color *color) {
|
||||
Laser *create_dynamic_laser(
|
||||
cmplx pos, float time, float deathtime, const Color *color, MoveParams **out_move
|
||||
) {
|
||||
Laser *l;
|
||||
INVOKE_TASK(laser_dynamic, &l, pos, time, deathtime, color);
|
||||
INVOKE_TASK(laser_dynamic, &l, pos, time, deathtime, color, out_move);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ typedef struct LaserRuleDynamicData {
|
|||
LaserRuleDynamicTaskData *const task_data;
|
||||
} LaserRuleDynamicData;
|
||||
|
||||
Laser *create_dynamic_laser(cmplx pos, float time, float deathtime, const Color *color);
|
||||
Laser *create_dynamic_laser(cmplx pos, float time, float deathtime, const Color *color, MoveParams **out_move);
|
||||
LaserRuleDynamicData *laser_get_ruledata_dynamic(Laser *l);
|
||||
|
||||
#define MAKE_LASER_RULE(func, data) ({ \
|
||||
|
|
Loading…
Reference in a new issue