Preserve corpses of disconnected agents

This commit is contained in:
Petr Baudis 2011-11-29 22:58:18 +01:00
parent fb3a8b64b2
commit 9c4adb5a3a
2 changed files with 10 additions and 2 deletions

View file

@ -110,6 +110,13 @@ agent::on_action_takes(void)
if (!conn)
return;
if (conn->error) {
die();
conn->cancel();
conn = NULL;
return;
}
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(-1, 0));
spawn_herb(tile->tile_in_dir(0, -1));
die();
tile->on_agent_leave(*this);
tile = NULL;
}
}

View file

@ -29,7 +29,7 @@ drop_agents(void)
for (std::list<class agent *>::iterator agent = agents.begin(); agent != agents.end(); agent++)
{
next_agent:
if ((*agent)->conn ? (*agent)->conn->error : (*agent)->dead) {
if (!(*agent)->conn && !(*agent)->tile) {
delete *agent;
agent = agents.erase(agent);
if (agent != agents.end())