1
0
Fork 0
mirror of synced 2025-03-06 20:53:27 +01:00

Server/Robot: Check if position is in range

This commit is contained in:
niansa/tuxifan 2022-05-10 15:10:03 +02:00
parent 3b1136e7e0
commit 2f2dabe817

View file

@ -84,6 +84,9 @@ boost::asio::awaitable<void> Playfield::updateRobot(const Connection::Client *se
if (localRobot->health() != newRobot.health()) {
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
if (newRobot.state() == Generic::Robot::Heal) {
newRobot.set_health(localRobot->health() + settings.healperturn());