fixup some post-rebase chaos

This commit is contained in:
Andrei Alexeyev 2019-12-18 16:19:13 +02:00
parent 75744681ed
commit 5c6b7671ef
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
13 changed files with 73 additions and 74 deletions

View file

@ -12,7 +12,7 @@
#include "random.h"
DEFINE_EXTERN_TASK(common_drop_items) {
complex p = *ARGS.pos;
cmplx p = *ARGS.pos;
for(int i = 0; i < ITEM_LAST - ITEM_FIRST; ++i) {
for(int j = ARGS.items.as_array[i]; j; --j) {
@ -22,7 +22,7 @@ DEFINE_EXTERN_TASK(common_drop_items) {
}
}
void common_move_loop(complex *restrict pos, MoveParams *restrict mp) {
void common_move_loop(cmplx *restrict pos, MoveParams *restrict mp) {
for(;;) {
move_update(pos, mp);
YIELD;
@ -53,8 +53,8 @@ DEFINE_EXTERN_TASK(common_call_func) {
cmplx common_wander(cmplx origin, double dist, Rect bounds) {
int attempts = 32;
double angle;
complex dest;
complex dir;
cmplx dest;
cmplx dir;
// assert(point_in_rect(origin, bounds));

View file

@ -19,17 +19,17 @@
DECLARE_EXTERN_TASK(
common_drop_items,
{ complex *pos; ItemCounts items; }
{ cmplx *pos; ItemCounts items; }
);
DECLARE_EXTERN_TASK(
common_move,
{ complex *pos; MoveParams move_params; BoxedEntity ent; }
{ cmplx *pos; MoveParams move_params; BoxedEntity ent; }
);
DECLARE_EXTERN_TASK(
common_move_ext,
{ complex *pos; MoveParams *move_params; BoxedEntity ent; }
{ cmplx *pos; MoveParams *move_params; BoxedEntity ent; }
);
DECLARE_EXTERN_TASK(
@ -46,6 +46,6 @@ INLINE Rect viewport_bounds(double margin) {
};
}
complex common_wander(complex origin, double dist, Rect bounds);
cmplx common_wander(cmplx origin, double dist, Rect bounds);
#endif // IGUARD_common_tasks_h

View file

@ -308,7 +308,7 @@ void *cotask_resume(CoTask *task, void *arg) {
}
void *cotask_yield(void *arg) {
CoTask *task = cotask_active();
attr_unused CoTask *task = cotask_active();
TASK_DEBUG_EVENT(ev);
TASK_DEBUG("[%zu] Yielding from task %s", ev, task->debug_label);
arg = koishi_yield(arg);
@ -387,7 +387,6 @@ CoWaitResult cotask_wait_event(CoEvent *evt, void *arg) {
*/
CoTask *task = cotask_active();
CoEventSnapshot snapshot = coevent_snapshot(evt);
coevent_add_subscriber(evt, task);
cotask_wait_init(task, COTASK_WAIT_EVENT);

View file

@ -11,14 +11,14 @@
#include "move.h"
#include "util/miscmath.h"
complex move_update(complex *restrict pos, MoveParams *restrict p) {
complex v = p->velocity;
cmplx move_update(cmplx *restrict pos, MoveParams *restrict p) {
cmplx v = p->velocity;
*pos += v;
p->velocity = p->acceleration + p->retention * v;
if(p->attraction) {
complex av = p->attraction_point - *pos;
cmplx av = p->attraction_point - *pos;
if(p->attraction_max_speed) {
av = cclampabs(av, p->attraction_max_speed);
@ -30,8 +30,8 @@ complex move_update(complex *restrict pos, MoveParams *restrict p) {
return v;
}
complex move_update_multiple(uint times, complex *restrict pos, MoveParams *restrict p) {
complex v = p->velocity;
cmplx move_update_multiple(uint times, cmplx *restrict pos, MoveParams *restrict p) {
cmplx v = p->velocity;
while(times--) {
move_update(pos, p);

View file

@ -16,42 +16,42 @@
*/
typedef struct MoveParams {
complex velocity, acceleration, retention;
complex attraction;
complex attraction_point;
cmplx velocity, acceleration, retention;
cmplx attraction;
cmplx attraction_point;
double attraction_max_speed;
} MoveParams;
complex move_update(complex *restrict pos, MoveParams *restrict params);
complex move_update_multiple(uint times, complex *restrict pos, MoveParams *restrict params);
cmplx move_update(cmplx *restrict pos, MoveParams *restrict params);
cmplx move_update_multiple(uint times, cmplx *restrict pos, MoveParams *restrict params);
INLINE MoveParams move_linear(complex vel) {
INLINE MoveParams move_linear(cmplx vel) {
return (MoveParams) { vel, 0, 1 };
}
INLINE MoveParams move_accelerated(complex vel, complex accel) {
INLINE MoveParams move_accelerated(cmplx vel, cmplx accel) {
return (MoveParams) { vel, accel, 1 };
}
INLINE MoveParams move_asymptotic(complex vel0, complex vel1, complex retention) {
INLINE MoveParams move_asymptotic(cmplx vel0, cmplx vel1, cmplx retention) {
// NOTE: retention could be derived by something like: exp(-1 / halflife)
return (MoveParams) { vel0, vel1 * (1 - retention), retention };
}
INLINE MoveParams move_asymptotic_simple(complex vel, double boost_factor) {
INLINE MoveParams move_asymptotic_simple(cmplx vel, double boost_factor) {
// NOTE: this matches the old asymptotic rule semantics exactly
double retention = 0.8;
return move_asymptotic(vel * (1 + boost_factor * retention), vel, retention);
}
INLINE MoveParams move_towards(complex target, complex attraction) {
INLINE MoveParams move_towards(cmplx target, cmplx attraction) {
return (MoveParams) {
.attraction = attraction,
.attraction_point = target,
};
}
INLINE MoveParams move_stop(complex retention) {
INLINE MoveParams move_stop(cmplx retention) {
return (MoveParams) { .retention = retention };
}

View file

@ -151,7 +151,7 @@ static inline int proj_call_rule(Projectile *p, int t) {
}
if(!(p->flags & PFLAG_MANUALANGLE)) {
complex delta_pos = p->pos - p->prevpos;
cmplx delta_pos = p->pos - p->prevpos;
if(delta_pos) {
p->angle = carg(delta_pos);

View file

@ -171,7 +171,7 @@ float vrng_f32_angle(rng_val_t v) {
return vrng_f32(v) * (float)(M_PI * 2.0f);
}
complex vrng_dir(rng_val_t v) {
cmplx vrng_dir(rng_val_t v) {
return cdir(vrng_f64_angle(v));
}

View file

@ -124,7 +124,7 @@ float vrng_f32_angle(rng_val_t v) attr_pure;
#define vrng_angle(v) vrng_f64_angle(v)
#define rng_angle() vrng_angle(rng_next())
complex vrng_dir(rng_val_t v) attr_pure;
cmplx vrng_dir(rng_val_t v) attr_pure;
#define rng_dir() vrng_dir(rng_next())
bool vrng_f64_chance(rng_val_t v, double chance) attr_pure;

View file

@ -21,12 +21,12 @@ TASK(laserize_proj, { BoxedProjectile p; int t; }) {
Projectile *p = TASK_BIND(ARGS.p);
WAIT(ARGS.t);
complex pos = p->pos;
cmplx pos = p->pos;
double a = p->angle;
Color clr = p->color;
kill_projectile(p);
complex aim = 12 * cexp(I * a);
cmplx aim = 12 * cexp(I * a);
create_laserline(pos, aim, 60, 80, &clr);
p = PROJECTILE(
@ -50,7 +50,7 @@ TASK(wait_event_test, { BoxedEnemy e; int rounds; int delay; int cnt; int cnt_in
// Event signaled. Since this is an enemy death event, e will be invalid
// in the next frame. Let's save its position while we can.
complex pos = e->pos;
cmplx pos = e->pos;
while(ARGS.rounds--) {
WAIT(ARGS.delay);
@ -58,7 +58,7 @@ TASK(wait_event_test, { BoxedEnemy e; int rounds; int delay; int cnt; int cnt_in
real angle_ofs = rng_angle();
for(int i = 0; i < ARGS.cnt; ++i) {
complex aim = cexp(I * (angle_ofs + M_PI * 2.0 * i / (double)ARGS.cnt));
cmplx aim = cexp(I * (angle_ofs + M_PI * 2.0 * i / (double)ARGS.cnt));
PROJECTILE(
.pos = pos,
@ -75,7 +75,7 @@ TASK(wait_event_test, { BoxedEnemy e; int rounds; int delay; int cnt; int cnt_in
}
TASK_WITH_FINALIZER(test_enemy, {
double hp; complex pos; complex dir;
double hp; cmplx pos; cmplx dir;
struct { int x; } for_finalizer;
}) {
Enemy *e = TASK_BIND_UNBOXED(create_enemy1c(ARGS.pos, ARGS.hp, BigFairy, NULL, 0));
@ -103,7 +103,7 @@ TASK_WITH_FINALIZER(test_enemy, {
WAIT(10);
// pew pew!!!
complex aim = 3 * cnormalize(global.plr.pos - e->pos);
cmplx aim = 3 * cnormalize(global.plr.pos - e->pos);
int pcount = 120;
for(int i = 0; i < pcount; ++i) {

View file

@ -14,20 +14,20 @@
#include "common_tasks.h"
TASK(glider_bullet, {
complex pos; double dir; double spacing; int interval;
cmplx pos; double dir; double spacing; int interval;
}) {
const int nproj = 5;
const int nstep = 4;
BoxedProjectile projs[nproj];
const complex positions[][5] = {
const cmplx positions[][5] = {
{1+I, -1, 1, -I, 1-I},
{2, I, 1, -I, 1-I},
{2, 1+I, 2-I, -I, 1-I},
{2, 0, 2-I, 1-I, 1-2*I},
};
complex trans = cdir(ARGS.dir+1*M_PI/4)*ARGS.spacing;
cmplx trans = cdir(ARGS.dir+1*M_PI/4)*ARGS.spacing;
for(int i = 0; i < nproj; i++) {
projs[i] = ENT_BOX(PROJECTILE(
@ -36,7 +36,7 @@ TASK(glider_bullet, {
.color = RGBA(0,0,1,1),
));
}
for(int step = 0;; step++) {
int cur_step = step%nstep;
@ -60,7 +60,7 @@ TASK(glider_bullet, {
}
TASK(glider_fairy, {
double hp; complex pos; complex dir;
double hp; cmplx pos; cmplx dir;
}) {
Enemy *e = TASK_BIND_UNBOXED(create_enemy1c(VIEWPORT_W/2-10*I, ARGS.hp, BigFairy, NULL, 0));

View file

@ -664,7 +664,7 @@ TASK(burst_fairy, { cmplx pos; cmplx dir; }) {
int n = 1.5 * global.diff - 1;
for(int i = -n; i <= n; i++) {
complex aim = cdir(carg(global.plr.pos - e->pos) + 0.2 * i);
cmplx aim = cdir(carg(global.plr.pos - e->pos) + 0.2 * i);
PROJECTILE(
.proto = pp_crystal,
@ -695,7 +695,7 @@ TASK(circletoss_shoot_circle, { BoxedEnemy e; int duration; int interval; }) {
play_loop("shot1_loop");
e->move.velocity *= 0.8;
complex aim = cdir(angle_step * i);
cmplx aim = cdir(angle_step * i);
PROJECTILE(
.proto = pp_rice,
@ -718,7 +718,7 @@ TASK(circletoss_shoot_toss, { BoxedEnemy e; int times; int duration; int period;
double aim_angle = carg(global.plr.pos - e->pos);
aim_angle += 0.05 * global.diff * rng_real();
complex aim = cdir(aim_angle);
cmplx aim = cdir(aim_angle);
aim *= rng_range(1, 3);
PROJECTILE(
@ -735,7 +735,7 @@ TASK(circletoss_shoot_toss, { BoxedEnemy e; int times; int duration; int period;
}
}
TASK(circletoss_fairy, { complex pos; complex velocity; complex exit_accel; int exit_time; }) {
TASK(circletoss_fairy, { cmplx pos; cmplx velocity; cmplx exit_accel; int exit_time; }) {
Enemy *e = TASK_BIND_UNBOXED(create_enemy1c(ARGS.pos, 1500, BigFairy, NULL, 0));
e->move = move_linear(ARGS.velocity);
@ -763,10 +763,10 @@ TASK(circletoss_fairy, { complex pos; complex velocity; complex exit_accel; int
STALL;
}
TASK(sinepass_swirl_move, { BoxedEnemy e; complex v; complex sv; }) {
TASK(sinepass_swirl_move, { BoxedEnemy e; cmplx v; cmplx sv; }) {
Enemy *e = TASK_BIND(ARGS.e);
complex sv = ARGS.sv;
complex v = ARGS.v;
cmplx sv = ARGS.sv;
cmplx v = ARGS.v;
for(;;) {
sv -= cimag(e->pos - e->pos0) * 0.03 * I;
@ -775,7 +775,7 @@ TASK(sinepass_swirl_move, { BoxedEnemy e; complex v; complex sv; }) {
}
}
TASK(sinepass_swirl, { complex pos; complex vel; complex svel; }) {
TASK(sinepass_swirl, { cmplx pos; cmplx vel; cmplx svel; }) {
Enemy *e = TASK_BIND_UNBOXED(create_enemy1c(ARGS.pos, 100, Swirl, NULL, 0));
INVOKE_TASK_WHEN(&e->events.killed, common_drop_items, &e->pos, {
@ -791,7 +791,7 @@ TASK(sinepass_swirl, { complex pos; complex vel; complex svel; }) {
for(;;) {
play_sound("shot1");
complex aim = cnormalize(global.plr.pos - e->pos);
cmplx aim = cnormalize(global.plr.pos - e->pos);
aim *= difficulty_value(2, 2, 2.5, 3);
PROJECTILE(
@ -805,7 +805,7 @@ TASK(sinepass_swirl, { complex pos; complex vel; complex svel; }) {
}
}
TASK(circle_fairy, { complex pos; complex target_pos; }) {
TASK(circle_fairy, { cmplx pos; cmplx target_pos; }) {
Enemy *e = TASK_BIND_UNBOXED(create_enemy1c(ARGS.pos, 1400, BigFairy, NULL, 0));
INVOKE_TASK_WHEN(&e->events.killed, common_drop_items, &e->pos, {
@ -827,7 +827,7 @@ TASK(circle_fairy, { complex pos; complex target_pos; }) {
double a_ofs = rng_angle();
for(int i = 0; i < shot_count; ++i) {
complex aim;
cmplx aim;
aim = circle_dir_ofs((round & 1) ? i : shot_count - i, shot_count, a_ofs);
aim *= difficulty_value(1.7, 2.0, 2.5, 2.5);
@ -854,7 +854,7 @@ TASK(circle_fairy, { complex pos; complex target_pos; }) {
STALL;
}
TASK(drop_swirl, { complex pos; complex vel; complex accel; }) {
TASK(drop_swirl, { cmplx pos; cmplx vel; cmplx accel; }) {
Enemy *e = TASK_BIND_UNBOXED(create_enemy1c(ARGS.pos, 100, Swirl, NULL, 0));
INVOKE_TASK_WHEN(&e->events.killed, common_drop_items, &e->pos, {
@ -868,7 +868,7 @@ TASK(drop_swirl, { complex pos; complex vel; complex accel; }) {
WAIT(20);
while(true) {
complex aim = cnormalize(global.plr.pos - e->pos);
cmplx aim = cnormalize(global.plr.pos - e->pos);
aim *= 1 + 0.3 * global.diff + rng_real();
play_sound("shot1");
@ -883,7 +883,7 @@ TASK(drop_swirl, { complex pos; complex vel; complex accel; }) {
}
}
TASK(multiburst_fairy, { complex pos; complex target_pos; complex exit_accel; }) {
TASK(multiburst_fairy, { cmplx pos; cmplx target_pos; cmplx exit_accel; }) {
Enemy *e = TASK_BIND_UNBOXED(create_enemy1c(ARGS.pos, 1000, Fairy, NULL, 0));
INVOKE_TASK_WHEN(&e->events.killed, common_drop_items, &e->pos, {
@ -905,7 +905,7 @@ TASK(multiburst_fairy, { complex pos; complex target_pos; complex exit_accel; })
int n = global.diff - 1;
for(int j = -n; j <= n; j++) {
complex aim = cdir(carg(global.plr.pos - e->pos) + j / 5.0);
cmplx aim = cdir(carg(global.plr.pos - e->pos) + j / 5.0);
aim *= 2.5;
PROJECTILE(
@ -930,7 +930,7 @@ TASK(instantcircle_fairy_shoot, { BoxedEnemy e; int cnt; double speed; double bo
play_sound("shot_special1");
for(int i = 0; i < ARGS.cnt; ++i) {
complex vel = ARGS.speed * circle_dir(i, ARGS.cnt);
cmplx vel = ARGS.speed * circle_dir(i, ARGS.cnt);
PROJECTILE(
.proto = pp_rice,
@ -941,7 +941,7 @@ TASK(instantcircle_fairy_shoot, { BoxedEnemy e; int cnt; double speed; double bo
}
}
TASK(instantcircle_fairy, { complex pos; complex target_pos; complex exit_accel; }) {
TASK(instantcircle_fairy, { cmplx pos; cmplx target_pos; cmplx exit_accel; }) {
Enemy *e = TASK_BIND_UNBOXED(create_enemy1c(ARGS.pos, 1200, Fairy, NULL, 0));
INVOKE_TASK_WHEN(&e->events.killed, common_drop_items, &e->pos, {
@ -1094,7 +1094,7 @@ TASK(burst_fairies_2, NO_ARGS) {
TASK(burst_fairies_3, NO_ARGS) {
for(int i = 10; i--;) {
complex pos = VIEWPORT_W/2 - 200 * sin(1.17 * global.frames);
cmplx pos = VIEWPORT_W/2 - 200 * sin(1.17 * global.frames);
INVOKE_TASK(burst_fairy, pos, rng_sign());
stage_wait(60);
}
@ -1104,7 +1104,7 @@ TASK(burst_fairies_3, NO_ARGS) {
TASK(sinepass_swirls, { int duration; double level; double dir; }) {
int duration = ARGS.duration;
double dir = ARGS.dir;
complex pos = CMPLX(ARGS.dir < 0 ? VIEWPORT_W : 0, ARGS.level);
cmplx pos = CMPLX(ARGS.dir < 0 ? VIEWPORT_W : 0, ARGS.level);
int delay = difficulty_value(30, 20, 15, 10);
for(int t = 0; t < duration; t += delay) {
@ -1127,7 +1127,7 @@ TASK(circletoss_fairies_1, NO_ARGS) {
}
}
TASK(drop_swirls, { int cnt; complex pos; complex vel; complex accel; }) {
TASK(drop_swirls, { int cnt; cmplx pos; cmplx vel; cmplx accel; }) {
for(int i = 0; i < ARGS.cnt; ++i) {
INVOKE_TASK(drop_swirl, ARGS.pos, ARGS.vel, ARGS.accel);
stage_wait(20);
@ -1162,9 +1162,9 @@ TASK(multiburst_fairies_1, NO_ARGS) {
for(int row = 0; row < 3; ++row) {
for(int col = 0; col < 5; ++col) {
log_debug("WTF %i %i", row, col);
complex pos = rng_range(0, VIEWPORT_W);
complex target_pos = 64 + 64 * col + I * (64 * row + 100);
complex exit_accel = 0.02 * I + 0.03;
cmplx pos = rng_range(0, VIEWPORT_W);
cmplx target_pos = 64 + 64 * col + I * (64 * row + 100);
cmplx exit_accel = 0.02 * I + 0.03;
INVOKE_TASK(multiburst_fairy, pos, target_pos, exit_accel);
WAIT(10);
@ -1209,7 +1209,7 @@ static int snowflake_bullet_limit(int size) {
return SNOWFLAKE_ARMS * 4 * size;
}
TASK(make_snowflake, { complex pos; MoveParams move; int size; double rot_angle; BoxedProjectileArray *array; }) {
TASK(make_snowflake, { cmplx pos; MoveParams move; int size; double rot_angle; BoxedProjectileArray *array; }) {
const double spacing = 12;
const int split = 3;
int t = 0;
@ -1219,8 +1219,8 @@ TASK(make_snowflake, { complex pos; MoveParams move; int size; double rot_angle;
for(int i = 0; i < SNOWFLAKE_ARMS; i++) {
double ang = M_TAU / SNOWFLAKE_ARMS * i + ARGS.rot_angle;
complex phase = cdir(ang);
complex pos0 = ARGS.pos + spacing * j * phase;
cmplx phase = cdir(ang);
cmplx pos0 = ARGS.pos + spacing * j * phase;
Projectile *p;
@ -1243,11 +1243,11 @@ TASK(make_snowflake, { complex pos; MoveParams move; int size; double rot_angle;
++t;
if(j > split) {
complex pos1 = ARGS.pos + spacing * split * phase;
cmplx pos1 = ARGS.pos + spacing * split * phase;
for(int side = -1; side <= 1; side += 2) {
complex phase2 = cdir(M_PI / 4 * side) * phase;
complex pos2 = pos1 + (spacing * (j - split)) * phase2;
cmplx phase2 = cdir(M_PI / 4 * side) * phase;
cmplx pos2 = pos1 + (spacing * (j - split)) * phase2;
p = PROJECTILE(
.proto = pp_crystal,
@ -1395,7 +1395,7 @@ DEFINE_EXTERN_TASK(stage1_spell_perfect_freeze) {
r2 = rng_f32();
}
complex aim = cnormalize(global.plr.pos - boss->pos);
cmplx aim = cnormalize(global.plr.pos - boss->pos);
float speed = 2+0.2*global.diff;
for(int sign = -1; sign <= 1; sign += 2) {

View file

@ -252,11 +252,11 @@ double circle_angle(double index, double max_elements) {
return (index * (M_PI * 2.0)) / max_elements;
}
complex circle_dir(double index, double max_elements) {
cmplx circle_dir(double index, double max_elements) {
return cdir(circle_angle(index, max_elements));
}
complex circle_dir_ofs(double index, double max_elements, double ofs) {
cmplx circle_dir_ofs(double index, double max_elements, double ofs) {
return cdir(circle_angle(index, max_elements) + ofs);
}

View file

@ -53,8 +53,8 @@ float smooth(float x) attr_const;
float smoothreclamp(float x, float old_min, float old_max, float new_min, float new_max) attr_const;
float sanitize_scale(float scale) attr_const;
double circle_angle(double index, double max_elements) attr_const;
complex circle_dir(double index, double max_elements) attr_const;
complex circle_dir_ofs(double index, double max_elements, double ofs) attr_const;
cmplx circle_dir(double index, double max_elements) attr_const;
cmplx circle_dir_ofs(double index, double max_elements, double ofs) attr_const;
uint64_t upow10(uint n) attr_const;
uint digitcnt(uint64_t x) attr_const;
float normpdf(float x, float sigma) attr_const;