Skip to content

Commit

Permalink
Update ant.hpp
Browse files Browse the repository at this point in the history
  • Loading branch information
johnBuffer committed Aug 16, 2021
1 parent bd1166a commit 261fe92
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions include/simulation/ant/ant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,17 @@ struct Ant

void addToWorldGrid(World& world)
{
ColonyCell& cell = world.map.get(position).markers[col_id];
if (!cell.fighting) {
cell.current_ant = id;
cell.fighting = isFighting();
WorldCell* cell = world.map.getSafe(position);
if (!cell) {
// Set as dead if outside the world
terminate();
return;
}

ColonyCell& colony_cell = cell->markers[col_id];
if (!colony_cell.fighting) {
colony_cell.current_ant = id;
colony_cell.fighting = isFighting();
}
}

Expand Down

0 comments on commit 261fe92

Please sign in to comment.