mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-03 10:23:38 +02:00
agent::move_dir(): Make sure to properly detach eaten agent from a tile
This commit is contained in:
parent
9c4adb5a3a
commit
a40cd4e87c
1 changed files with 4 additions and 1 deletions
5
agent.cc
5
agent.cc
|
@ -42,13 +42,16 @@ agent::move_dir(int dir_x, int dir_y)
|
||||||
if (t2->herb_here()) {
|
if (t2->herb_here()) {
|
||||||
class agent *a = t2->agent;
|
class agent *a = t2->agent;
|
||||||
t2->on_agent_leave(*a);
|
t2->on_agent_leave(*a);
|
||||||
|
a->tile = NULL;
|
||||||
chenergy(a->energy); /* Nom. */
|
chenergy(a->energy); /* Nom. */
|
||||||
a->die();
|
|
||||||
} else if (t2->agent->dead) {
|
} else if (t2->agent->dead) {
|
||||||
class agent *a = t2->agent;
|
class agent *a = t2->agent;
|
||||||
t2->on_agent_leave(*a);
|
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. */
|
chenergy(a->energy); /* Nom. */
|
||||||
a->energy = 0;
|
a->energy = 0;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue