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);