void doDebris(void) { int i; Debris *d, *prev; memset(debrisToDraw, 0, sizeof(Debris*) * drawCapacity); prev = &battle.debrisHead; i = 0; for (d = battle.debrisHead.next ; d != NULL ; d = d->next) { d->x += d->dx; d->y += d->dy; if (--d->thinkTime <= 0) { changeCourse(d); } d->angle = mod(d->angle + 1, 360); addDebrisFire(d->x, d->y); if (--d->health <= 0) { if (d == battle.debrisTail) { battle.debrisTail = prev; } prev->next = d->next; free(d); d = prev; } else { if (isOnBattleScreen(d->x, d->y, 32, 32)) { debrisToDraw[i++] = d; if (i == drawCapacity) { resizeDrawList(); } } } prev = d; } }
void doEffects(void) { int i, onScreen; Effect *e; Effect *prev = &battle.effectHead; i = 0; memset(effectsToDraw, 0, sizeof(Effect*) * drawCapacity); for (e = battle.effectHead.next ; e != NULL ; e = e->next) { e->x += e->dx; e->y += e->dy; e->a -= (e->type != EFFECT_ECM) ? 1 : 3; e->a = MAX(0, e->a); e->health--; e->size += e->scaleAmount; if (e->health <= 0) { if (e == battle.effectTail) { battle.effectTail = prev; } prev->next = e->next; free(e); e = prev; } else { onScreen = 0; switch (e->type) { case EFFECT_LINE: onScreen = pointOnScreen(e->x - battle.camera.x, e->y - battle.camera.y) || pointOnScreen(e->x + (e->dx * 3) - battle.camera.x, e->y + (e->dy * 3) - battle.camera.y); break; case EFFECT_POINT: onScreen = pointOnScreen(e->x - battle.camera.x, e->y - battle.camera.y); break; default: onScreen = isOnBattleScreen(e->x, e->y, e->size, e->size); break; } if (onScreen) { effectsToDraw[i++] = e; if (i == drawCapacity) { resizeDrawList(); } } } prev = e; } }