diff --git a/src/battle/entities.c b/src/battle/entities.c index 6ce6c11..daa133e 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -52,14 +52,14 @@ void doEntities(void) numAllies = numEnemies = numActiveAllies = numActiveEnemies = 0; + destroyGrid(); + for (e = battle.entityHead.next ; e != NULL ; e = e->next) { if (e->active) { self = e; - removeFromGrid(e); - e->reload = MAX(e->reload - 1, 0); e->shieldRecharge = MAX(e->shieldRecharge - 1, 0); e->armourHit = MAX(e->armourHit - 25, 0); diff --git a/src/battle/entities.h b/src/battle/entities.h index c01a117..721369b 100644 --- a/src/battle/entities.h +++ b/src/battle/entities.h @@ -29,6 +29,7 @@ extern void doRope(Entity *e); extern void drawRope(Entity *e); extern void cutRope(Entity *e); extern void drawShieldHitEffect(Entity *e); +extern void destroyGrid(void); extern App app; extern Battle battle; diff --git a/src/battle/grid.c b/src/battle/grid.c index 66aeb3f..25d4a5c 100644 --- a/src/battle/grid.c +++ b/src/battle/grid.c @@ -56,40 +56,6 @@ void addToGrid(Entity *e) } } -void removeFromGrid(Entity *e) -{ - GridCell *cell, *prev; - int x, y, x1, y1, x2, y2; - - x1 = (e->x - e->w / 2) / GRID_CELL_WIDTH; - y1 = (e->y - e->h / 2) / GRID_CELL_HEIGHT; - x2 = (e->x + e->w / 2) / GRID_CELL_WIDTH; - y2 = (e->y + e->h / 2) / GRID_CELL_HEIGHT; - - for (x = x1 ; x <= x2 ; x++) - { - for (y = y1 ; y <= y2 ; y++) - { - if (x >= 0 && y >= 0 && x < GRID_SIZE && y < GRID_SIZE) - { - prev = &battle.grid[x][y]; - - for (cell = battle.grid[x][y].next ; cell != NULL ; cell = cell->next) - { - if (cell->entity == e) - { - prev->next = cell->next; - free(cell); - cell = prev; - } - - prev = cell; - } - } - } - } -} - Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore) { GridCell *cell;