diff --git a/client/CPlayerInterface.cpp b/client/CPlayerInterface.cpp index 767091a64..5b0a37966 100644 --- a/client/CPlayerInterface.cpp +++ b/client/CPlayerInterface.cpp @@ -1069,6 +1069,19 @@ void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component { EVENT_HANDLER_CALLED_BY_CLIENT; + std::vector tmpObjects; + if(objects.size() && dynamic_cast(cb->getObj(objects[0]))) + { + // sorting towns (like in client) + std::vector Towns = LOCPLINT->localState->getOwnedTowns(); + for(auto town : Towns) + for(auto item : objects) + if(town == cb->getObj(item)) + tmpObjects.push_back(item); + } + else // other object list than town + tmpObjects = objects; + auto selectCallback = [=](int selection) { cb->sendQueryReply(selection, askID); @@ -1083,9 +1096,9 @@ void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component const std::string localDescription = description.toString(); std::vector tempList; - tempList.reserve(objects.size()); + tempList.reserve(tmpObjects.size()); - for(auto item : objects) + for(auto item : tmpObjects) tempList.push_back(item.getNum()); CComponent localIconC(icon); @@ -1094,7 +1107,7 @@ void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component localIconC.removeChild(localIcon.get(), false); std::vector> images; - for(auto & obj : objects) + for(auto & obj : tmpObjects) { if(!settings["general"]["enableUiEnhancements"].Bool()) break; @@ -1109,8 +1122,8 @@ void CPlayerInterface::showMapObjectSelectDialog(QueryID askID, const Component auto wnd = std::make_shared(tempList, localIcon, localTitle, localDescription, selectCallback, 0, images); wnd->onExit = cancelCallback; - wnd->onPopup = [this, objects](int index) { CRClickPopup::createAndPush(cb->getObj(objects[index]), GH.getCursorPosition()); }; - wnd->onClicked = [this, objects](int index) { adventureInt->centerOnObject(cb->getObj(objects[index])); GH.windows().totalRedraw(); }; + wnd->onPopup = [this, tmpObjects](int index) { CRClickPopup::createAndPush(cb->getObj(tmpObjects[index]), GH.getCursorPosition()); }; + wnd->onClicked = [this, tmpObjects](int index) { adventureInt->centerOnObject(cb->getObj(tmpObjects[index])); GH.windows().totalRedraw(); }; GH.windows().pushWindow(wnd); } diff --git a/client/windows/CCastleInterface.cpp b/client/windows/CCastleInterface.cpp index 6f9687793..5f3b261b3 100644 --- a/client/windows/CCastleInterface.cpp +++ b/client/windows/CCastleInterface.cpp @@ -873,7 +873,7 @@ void CCastleBuildings::enterCastleGate() return;//only visiting hero can use castle gates } std::vector availableTowns; - std::vector Towns = LOCPLINT->cb->getTownsInfo(true); + std::vector Towns = LOCPLINT->localState->getOwnedTowns(); for(auto & Town : Towns) { const CGTownInstance *t = Town; diff --git a/client/windows/GUIClasses.cpp b/client/windows/GUIClasses.cpp index 0adb62bd9..eae36f55c 100644 --- a/client/windows/GUIClasses.cpp +++ b/client/windows/GUIClasses.cpp @@ -1723,9 +1723,6 @@ void CObjectListWindow::CItem::showPopupWindow(const Point & cursorPosition) CObjectListWindow::CObjectListWindow(const std::vector & _items, std::shared_ptr titleWidget_, std::string _title, std::string _descr, std::function Callback, size_t initialSelection, std::vector> images) : CWindowObject(PLAYER_COLORED, ImagePath::builtin("TPGATE")), onSelect(Callback), - onExit(nullptr), - onPopup(nullptr), - onClicked(nullptr), selected(initialSelection), images(images) { @@ -1743,9 +1740,6 @@ CObjectListWindow::CObjectListWindow(const std::vector & _items, std::share CObjectListWindow::CObjectListWindow(const std::vector & _items, std::shared_ptr titleWidget_, std::string _title, std::string _descr, std::function Callback, size_t initialSelection, std::vector> images) : CWindowObject(PLAYER_COLORED, ImagePath::builtin("TPGATE")), onSelect(Callback), - onExit(nullptr), - onPopup(nullptr), - onClicked(nullptr), selected(initialSelection), images(images) {