Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More compiler warning fixes #273

Merged
merged 9 commits into from
Dec 25, 2020
Prev Previous commit
Next Next commit
a handful of small fixes to silence gcc compiler warnings, mostly pot…
…entiall null pointers and style deficiencies
  • Loading branch information
StarWitch committed Dec 24, 2020
commit 5d3ee1a2e8ff8e48fa1073ad1e9f8bc55b188875
2 changes: 1 addition & 1 deletion src/plrmodes/reimu_a.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ TASK(reimu_spirit_bomb_orb_visual, { BoxedProjectile orb; }) {
TASK(reimu_spirit_bomb_orb, { BoxedPlayer plr; int index; real angle; }) {
int index = ARGS.index;

Player *plr = ENT_UNBOX(ARGS.plr);
Player *plr = NOT_NULL(ENT_UNBOX(ARGS.plr));
Projectile *orb = TASK_BIND(PROJECTILE(
.pos = plr->pos,
.timeout = 160 + 20 * index,
Expand Down
9 changes: 6 additions & 3 deletions src/plrmodes/youmu_b.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ TASK(youmu_haunting_shot_homing, { YoumuBController *ctrl; }) {
}

TASK(youmu_orb_homing_spirit_expire, { BoxedProjectile p; }) {
Projectile *p = ENT_UNBOX(ARGS.p);
Projectile *p = NOT_NULL(ENT_UNBOX(ARGS.p));

PARTICLE(
.sprite_ptr = p->sprite,
Expand All @@ -246,7 +246,10 @@ TASK(youmu_orb_homing_spirit_expire, { BoxedProjectile p; }) {
}

static int youmu_orb_homing_spirit_timeout(Projectile *orb) {
return orb->timeout - projectile_time(orb);
if(orb) {
return orb->timeout - projectile_time(orb);
}
return 0;
}
StarWitch marked this conversation as resolved.
Show resolved Hide resolved

TASK(youmu_orb_homing_spirit, { YoumuBController *ctrl; cmplx pos; cmplx velocity; cmplx target; real charge; real damage; real spin; BoxedProjectile orb; }) {
Expand Down Expand Up @@ -387,7 +390,7 @@ TASK(youmu_orb_update, { YoumuBController *ctrl; BoxedProjectile orb; }) {

TASK(youmu_orb_death, { BoxedProjectile orb; BoxedTask control_task; }) {
CANCEL_TASK(ARGS.control_task);
Projectile *orb = ENT_UNBOX(ARGS.orb);
Projectile *orb = NOT_NULL(ENT_UNBOX(ARGS.orb));

PARTICLE(
.proto = pp_blast,
Expand Down
4 changes: 2 additions & 2 deletions src/stages/stage2/spells/amulet_of_harm.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ TASK(amulet_fire_spinners, { BoxedEnemy core; BoxedProjectileArray *spinners; })

ENT_ARRAY_FOREACH(ARGS.spinners, Projectile *p, {
int cnt = difficulty_value(12, 16, 22, 24);
for(int i = 0; i < cnt; ++i) {
cmplx ca = circle_dir(i, cnt);
for(int x = 0; x < cnt; ++x) {
cmplx ca = circle_dir(x, cnt);
Akaricchi marked this conversation as resolved.
Show resolved Hide resolved
cmplx o = p->pos + 42 * ca;
cmplx aim = cnormalize(o - core->pos);

Expand Down
9 changes: 2 additions & 7 deletions src/stages/stage2/timeline.c
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,14 @@ TASK(spinshot_fairy_attack, {
)
);

cmplx ref_pos;
Enemy *e;

for(int t = 0; t < ARGS.activate_time; ++t, YIELD) {
int live_count = 0;
e = ENT_UNBOX(ARGS.e);

if(e) {
ref_pos = e->pos;
}
e = NOT_NULL(ENT_UNBOX(ARGS.e));

ENT_ARRAY_FOREACH_COUNTER(&projs, int i, Projectile *p, {
cmplx ofs = ref_pos - proj_origins[i];
cmplx ofs = e->pos - proj_origins[i];
StarWitch marked this conversation as resolved.
Show resolved Hide resolved
proj_origins[i] += ofs;
p->pos += ofs;
p->move.attraction_point += ofs;
Expand Down
2 changes: 1 addition & 1 deletion src/stages/stage3_events.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ static int stage3_burstfairy(Enemy *e, int t) {

charge_effect(e, t, bursttime);

FROM_TO_SND("shot1_loop", bursttime, bursttime + burstspan, step) {
FROM_TO_SND("shot1_loop", bursttime, bursttime + burstspan * step - 1, step) {
StarWitch marked this conversation as resolved.
Show resolved Hide resolved
double phase = (t - bursttime) / (double)burstspan;
cmplx dir = cexp(I*M_PI*phase);

Expand Down
1 change: 0 additions & 1 deletion src/util/strbuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ int strbuf_vprintf(StringBuffer *strbuf, const char *format, va_list args) {
strbuf->buf_size = new_size;
size_available = new_size - offset;

va_list args_copy;
va_copy(args_copy, args);
size_required = vsnprintf(strbuf->pos, size_available, format, args_copy);
va_end(args_copy);
Expand Down