From 3e71c37019fe583f7010cba411f77ca7de6cddb8 Mon Sep 17 00:00:00 2001
From: Tim Felgentreff <timfelgentreff@gmail.com>
Date: Tue, 15 Feb 2022 08:44:37 +0100
Subject: [PATCH] fix start location sticking to cursor

---
 src/editor/editloop.cpp | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/src/editor/editloop.cpp b/src/editor/editloop.cpp
index f06f5e791..4b2490959 100644
--- a/src/editor/editloop.cpp
+++ b/src/editor/editloop.cpp
@@ -1998,19 +1998,18 @@ void EditorMainLoop()
 	LambdaActionListener *toolDropdownListener = new LambdaActionListener([&toolListStrings](const std::string&) {
 		int selected = toolDropdown->getSelected();
 		// Click on mode area
+		Editor.CursorUnitIndex = Editor.CursorTileIndex = Editor.SelectedUnitIndex = Editor.SelectedTileIndex = -1;
+		CursorBuilding = nullptr;
+		Editor.UnitIndex = Editor.TileIndex = 0;
 		switch (selected) {
 			case 0:
 				Editor.State = EditorSelecting;
-				Editor.SelectedUnitIndex = Editor.SelectedTileIndex = -1;
 				editorSlider->setVisible(false);
 				return;
 			case 1:
-				if (EditorEditTile) {
-					Editor.State = EditorEditTile;
-				}
+				Editor.State = EditorEditTile;
 				editorSlider->setVisible(true);
 				editorSlider->setValue(0);
-				Editor.TileIndex = 0;
 				return;
 			case 2:
 				Editor.State = EditorSetStartLocation;
@@ -2021,7 +2020,6 @@ void EditorMainLoop()
 				RecalculateShownUnits();
 				editorSlider->setVisible(true);
 				editorSlider->setValue(0);
-				Editor.UnitIndex = 0;
 				return;
 			default: {
 				std::string selectedString = toolListStrings[selected];
@@ -2044,7 +2042,6 @@ void EditorMainLoop()
 				RecalculateShownUnits(startIndex, endIndex);
 				editorSlider->setVisible(true);
 				editorSlider->setValue(0);
-				Editor.UnitIndex = 0;
 				break;
 			}
 		}