Make herbs die properly on energy depletion

This commit is contained in:
Petr Baudis 2011-12-08 00:26:20 +01:00
parent 5435014c1d
commit 343762c3bb
2 changed files with 11 additions and 3 deletions

View file

@ -181,6 +181,14 @@ agent::~agent()
}
void
herb::die(void)
{
/* No corpse, just clean up tile. */
tile->on_agent_leave(*this);
tile = NULL;
}
static void
spawn_herb(class tile &t)
{
@ -211,8 +219,7 @@ herb::on_tick(void)
spawn_herb(tile->tile_in_dir(0, 1));
spawn_herb(tile->tile_in_dir(-1, 0));
spawn_herb(tile->tile_in_dir(0, -1));
tile->on_agent_leave(*this);
tile = NULL;
die();
} else {
smell_herb(tile->tile_in_dir(1, 0));
smell_herb(tile->tile_in_dir(0, 1));