fix my clearhazards fuckups

This commit is contained in:
Andrei Alexeyev 2018-01-06 20:23:38 +02:00
parent 5f17bfffd0
commit 032a3852d7
No known key found for this signature in database
GPG key ID: 363707CD4C7FE8A4
5 changed files with 16 additions and 10 deletions

View file

@ -188,7 +188,7 @@ void delete_lasers(void) {
list_foreach(&global.lasers, _delete_laser, NULL);
}
bool clear_laser(Laser *l, bool force, bool now) {
bool clear_laser(Laser **laserlist, Laser *l, bool force, bool now) {
if(!force && l->unclearable) {
return false;
}

View file

@ -67,7 +67,7 @@ void process_lasers(void);
int collision_laser_line(Laser *l);
int collision_laser_curve(Laser *l);
bool clear_laser(Laser *l, bool force, bool now);
bool clear_laser(Laser **laserlist, Laser *l, bool force, bool now);
complex las_linear(Laser *l, float t);
complex las_accel(Laser *l, float t);

View file

@ -415,7 +415,7 @@ Projectile* spawn_projectile_clear_effect(Projectile *proj) {
return spawn_projectile_death_effect(proj);
}
bool clear_projectile(Projectile *proj, bool force, bool now) {
bool clear_projectile(Projectile **projlist, Projectile *proj, bool force, bool now) {
if(!force && !projectile_is_clearable(proj)) {
return false;
}
@ -426,11 +426,12 @@ bool clear_projectile(Projectile *proj, bool force, bool now) {
}
spawn_projectile_clear_effect(proj);
delete_projectile(projlist, proj);
} else {
proj->type = DeadProj;
}
return false;
return true;
}
void process_projectiles(Projectile **projs, bool collision) {
@ -447,7 +448,10 @@ void process_projectiles(Projectile **projs, bool collision) {
if(proj->type == DeadProj && killed < 5) {
killed++;
action = ACTION_DESTROY;
clear_projectile(proj, true, true);
if(clear_projectile(projs, proj, true, true)) {
continue;
}
}
if(collision) {

View file

@ -148,7 +148,7 @@ bool projectile_is_clearable(Projectile *p);
Projectile* spawn_projectile_collision_effect(Projectile *proj);
Projectile* spawn_projectile_clear_effect(Projectile *proj);
bool clear_projectile(Projectile *proj, bool force, bool now);
bool clear_projectile(Projectile **projlist, Projectile *proj, bool force, bool now);
int linear(Projectile *p, int t);
int accelerated(Projectile *p, int t);

View file

@ -456,14 +456,16 @@ static void stage_logic(void) {
void stage_clear_hazards(ClearHazardsFlags flags) {
if(flags & CLEAR_HAZARDS_BULLETS) {
for(Projectile *p = global.projs; p; p = p->next) {
clear_projectile(p, flags & CLEAR_HAZARDS_FORCE, flags & CLEAR_HAZARDS_NOW);
for(Projectile *p = global.projs, *next; p; p = next) {
next = p->next;
clear_projectile(&global.projs, p, flags & CLEAR_HAZARDS_FORCE, flags & CLEAR_HAZARDS_NOW);
}
}
if(flags & CLEAR_HAZARDS_LASERS) {
for(Laser *l = global.lasers; l; l = l->next) {
clear_laser(l, flags & CLEAR_HAZARDS_FORCE, flags & CLEAR_HAZARDS_NOW);
for(Laser *l = global.lasers, *next; l; l = next) {
next = l->next;
clear_laser(&global.lasers, l, flags & CLEAR_HAZARDS_FORCE, flags & CLEAR_HAZARDS_NOW);
}
}
}