mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-03 10:23:38 +02:00
Preserve corpses of disconnected agents
This commit is contained in:
parent
fb3a8b64b2
commit
9c4adb5a3a
2 changed files with 10 additions and 2 deletions
10
agent.cc
10
agent.cc
|
@ -110,6 +110,13 @@ agent::on_action_takes(void)
|
||||||
if (!conn)
|
if (!conn)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (conn->error) {
|
||||||
|
die();
|
||||||
|
conn->cancel();
|
||||||
|
conn = NULL;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
conn->actions(*this);
|
conn->actions(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -176,6 +183,7 @@ herb::on_tick(void)
|
||||||
spawn_herb(tile->tile_in_dir(0, 1));
|
spawn_herb(tile->tile_in_dir(0, 1));
|
||||||
spawn_herb(tile->tile_in_dir(-1, 0));
|
spawn_herb(tile->tile_in_dir(-1, 0));
|
||||||
spawn_herb(tile->tile_in_dir(0, -1));
|
spawn_herb(tile->tile_in_dir(0, -1));
|
||||||
die();
|
tile->on_agent_leave(*this);
|
||||||
|
tile = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
2
main.cc
2
main.cc
|
@ -29,7 +29,7 @@ drop_agents(void)
|
||||||
for (std::list<class agent *>::iterator agent = agents.begin(); agent != agents.end(); agent++)
|
for (std::list<class agent *>::iterator agent = agents.begin(); agent != agents.end(); agent++)
|
||||||
{
|
{
|
||||||
next_agent:
|
next_agent:
|
||||||
if ((*agent)->conn ? (*agent)->conn->error : (*agent)->dead) {
|
if (!(*agent)->conn && !(*agent)->tile) {
|
||||||
delete *agent;
|
delete *agent;
|
||||||
agent = agents.erase(agent);
|
agent = agents.erase(agent);
|
||||||
if (agent != agents.end())
|
if (agent != agents.end())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue