From 0f2d0dc86ae9c0b63068eae6ffc2c0ea177542a0 Mon Sep 17 00:00:00 2001 From: Mathieu Oriol Date: Tue, 10 Sep 2024 17:37:41 +0200 Subject: [PATCH] back: fix #23 --- traque-back/game.js | 9 +++++++++ traque-back/util.js | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/traque-back/game.js b/traque-back/game.js index c0260f9..7a7b6d1 100644 --- a/traque-back/game.js +++ b/traque-back/game.js @@ -8,6 +8,8 @@ import { playersBroadcast, sendUpdatedTeamInformations } from "./team_socket.js" import penaltyController from "./penalty_controller.js"; import zoneManager from "./zone_manager.js"; +import { getDistanceFromLatLon } from "./map_utils.js"; + /** * The possible states of the game */ @@ -329,6 +331,13 @@ export default { if (this.state == GameState.PLAYING || this.state == GameState.FINISHED) { return false; } + var min = newSettings.min; + var max = newSettings.max; + // The end zone must be included in the start zone + var dist = getDistanceFromLatLon(min.center, max.center); + if (min.radius + dist >= max.radius) { + return false; + } return zoneManager.udpateSettings(newSettings) }, diff --git a/traque-back/util.js b/traque-back/util.js index 1699761..4c7cb75 100644 --- a/traque-back/util.js +++ b/traque-back/util.js @@ -10,4 +10,4 @@ */ export function map(value, oldMin, oldMax, newMin, newMax) { return ((value - oldMin) / (oldMax - oldMin)) * (newMax - newMin) + newMin; -} \ No newline at end of file +}