connnection::actions(): Take agent&

This commit is contained in:
Petr Baudis 2011-11-27 03:25:16 +01:00
parent 415475cd26
commit e22c57c97f
3 changed files with 4 additions and 4 deletions

View file

@ -59,7 +59,7 @@ agent::on_action_takes(void)
if (!conn) if (!conn)
return; return;
conn->actions(this); conn->actions(*this);
} }
void void

View file

@ -47,7 +47,7 @@ connection::bump(void)
} }
void void
connection::actions(class agent *agent) connection::actions(class agent &agent)
{ {
pthread_mutex_lock(&buf_lock); pthread_mutex_lock(&buf_lock);
if (in_buf.find("\r\n\r\n") == std::string::npos) { if (in_buf.find("\r\n\r\n") == std::string::npos) {
@ -70,7 +70,7 @@ connection::actions(class agent *agent)
sscanf(line.c_str(), "%d %d", &x, &y); sscanf(line.c_str(), "%d %d", &x, &y);
if (x < -1) x = -1; if (x > 1) x = 1; if (x < -1) x = -1; if (x > 1) x = 1;
if (y < -1) y = -1; if (y > 1) y = 1; if (y < -1) y = -1; if (y > 1) y = 1;
if (!agent->move_dir(x, y)) if (!agent.move_dir(x, y))
bump(); bump();
} else { } else {
std::cout << "unknown line " << cmd << " " << line << " ...\n"; std::cout << "unknown line " << cmd << " " << line << " ...\n";

View file

@ -27,7 +27,7 @@ public:
} }
void senses(int tick_id, class agent &); void senses(int tick_id, class agent &);
void actions(class agent *); void actions(class agent &);
void cancel(void); void cancel(void);