From c671bb64316e7b43688f9cfb19ca66ad9a15eb1a Mon Sep 17 00:00:00 2001 From: Fabio Schick <58027418+mrschick@users.noreply.github.com> Date: Mon, 13 Jan 2025 20:30:04 +0100 Subject: [PATCH] Map Tools - Fix drawing straight lines (#10635) --- addons/maptools/XEH_postInitClient.sqf | 7 +++++++ addons/maptools/functions/fnc_handleMouseButton.sqf | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/addons/maptools/XEH_postInitClient.sqf b/addons/maptools/XEH_postInitClient.sqf index 5ce1e68892f..8635c8020ab 100644 --- a/addons/maptools/XEH_postInitClient.sqf +++ b/addons/maptools/XEH_postInitClient.sqf @@ -7,6 +7,7 @@ if (!hasInterface) exitWith {}; // Init variables GVAR(mapGpsShow) = true; GVAR(mapGpsNextUpdate) = -1; +GVAR(lastDrawnLine) = ""; GVAR(mapTool_Shown) = 0; GVAR(mapTool_pos) = [0, 0]; @@ -47,6 +48,12 @@ GVAR(plottingBoard_markers) = createHashMap; addMissionEventHandler ["MarkerCreated", { [_this, false] call FUNC(handlePlottingBoardMarkers); + + // Cache last user-drawn polyline marker + private _marker = _this select 0; + if ((markerPolyline _marker) isNotEqualTo []) then { + GVAR(lastDrawnLine) = _marker; + }; }]; addMissionEventHandler ["MarkerDeleted", { diff --git a/addons/maptools/functions/fnc_handleMouseButton.sqf b/addons/maptools/functions/fnc_handleMouseButton.sqf index 5a00b1ab1b9..d0876b9e737 100644 --- a/addons/maptools/functions/fnc_handleMouseButton.sqf +++ b/addons/maptools/functions/fnc_handleMouseButton.sqf @@ -38,7 +38,7 @@ if ((_button == 0) && {GVAR(freedrawing) || _ctrlKey}) exitWith { if (_allMarkers isEqualTo []) exitWith {}; - private _markerName = _allMarkers select -1; + private _markerName = GVAR(lastDrawnLine); private _markerPos = getMarkerPos _markerName; private _distanceCheck = _markerPos distance2D GVAR(drawPosStart);