Server/Robot: Check if position is in range
This commit is contained in:
parent
3b1136e7e0
commit
2f2dabe817
1 changed files with 3 additions and 0 deletions
|
@ -84,6 +84,9 @@ boost::asio::awaitable<void> Playfield::updateRobot(const Connection::Client *se
|
||||||
if (localRobot->health() != newRobot.health()) {
|
if (localRobot->health() != newRobot.health()) {
|
||||||
throw Connection::Error("Can't change value", Generic::Error::IllegalOperation);
|
throw Connection::Error("Can't change value", Generic::Error::IllegalOperation);
|
||||||
}
|
}
|
||||||
|
if (newRobot.position().x() > 1.0f || newRobot.position().x() < 0.0f || newRobot.position().y() > 1.0f || newRobot.position().y() < 0.0f) {
|
||||||
|
throw Connection::Error("Position is out of range", Generic::Error::OutOfRange);
|
||||||
|
}
|
||||||
// Apply heal
|
// Apply heal
|
||||||
if (newRobot.state() == Generic::Robot::Heal) {
|
if (newRobot.state() == Generic::Robot::Heal) {
|
||||||
newRobot.set_health(localRobot->health() + settings.healperturn());
|
newRobot.set_health(localRobot->health() + settings.healperturn());
|
||||||
|
|
Loading…
Add table
Reference in a new issue