move_dir: Restrict to {-1,0,1}

This commit is contained in:
Petr Baudis 2011-11-27 02:22:14 +01:00
parent 5ed183c554
commit d44c5f5b10
2 changed files with 3 additions and 1 deletions

View file

@ -43,6 +43,8 @@ connection::actions(class agent *agent)
if (!cmd.compare("move_dir")) {
int x = 0, y = 0;
sscanf(line.c_str(), "%d %d", &x, &y);
if (x < -1) x = -1; if (x > 1) x = 1;
if (y < -1) y = -1; if (y > 1) y = 1;
agent->move_dir(x, y);
} else {
std::cout << "unknown line " << cmd << " " << line << " ...\n";