agent::move_dir(): Make sure to properly detach eaten agent from a tile

This commit is contained in:
Petr Baudis 2011-11-29 23:08:49 +01:00
parent 9c4adb5a3a
commit a40cd4e87c

View file

@ -42,13 +42,16 @@ agent::move_dir(int dir_x, int dir_y)
if (t2->herb_here()) {
class agent *a = t2->agent;
t2->on_agent_leave(*a);
a->tile = NULL;
chenergy(a->energy); /* Nom. */
a->die();
} else if (t2->agent->dead) {
class agent *a = t2->agent;
t2->on_agent_leave(*a);
a->tile = NULL; // XXX: If one agent kills another while third is trying to move at that place, the killed agent never receives a DEATH.
chenergy(a->energy); /* Nom. */
a->energy = 0;
} else {
return false;
}