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:
Andrei Alexeyev 2024-05-10 01:28:22 +02:00
parent 07a0bdf558
commit 4072d31ffa
No known key found for this signature in database
GPG key ID: 72D26128040B9690
2 changed files with 10 additions and 3 deletions

View file

@ -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;
}

View file

@ -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) ({ \