| 1685 | _workshopStarted = true; |
| 1686 | StartWorkshopFetch(); |
| 1687 | } |
| 1688 | if (_workshopFetch != nullptr && !_workshopMerged) |
| 1689 | { |
| 1690 | std::vector<MasterServerServiceModCatalogEntry> ready; |
| 1691 | bool take = false; |
| 1692 | { |
| 1693 | std::lock_guard<std::mutex> lk(_workshopFetch->mtx); |
| 1694 | if (_workshopFetch->done) |
| 1695 | { |
| 1696 | _workshopMerged = true; |
| 1697 | if (_workshopFetch->ok) |
| 1698 | { |
| 1699 | ready = std::move(_workshopFetch->mods); |
| 1700 | take = true; |
| 1701 | } |
| 1702 | } |
| 1703 | } |
| 1704 | if (take) |
| 1705 | MergeWorkshopMods(ready); |
| 1706 | } |
| 1707 | Display::OnSimulate(vehicle); |
| 1708 | } |
| 1709 | |
| 1710 | void DisplayMods::StartWorkshopFetch() |
| 1711 | { |
| 1712 | auto fetch = std::make_shared<ModsWorkshopFetch>(); |
| 1713 | _workshopFetch = fetch; |
| 1714 | std::string host = (const char*)GetNetworkMasterServer(); |
| 1715 | std::string proxy = (const char*)GetNetworkProxy(); |
| 1716 | std::thread( |
| 1717 | [fetch, host, proxy]() |
| 1718 | { |
| 1719 | std::vector<MasterServerServiceModCatalogEntry> mods; |
| 1720 | const bool ok = |
| 1721 | FetchMasterServerServiceModList(host.c_str(), "", proxy.empty() ? nullptr : proxy.c_str(), mods); |
| 1722 | std::lock_guard<std::mutex> lk(fetch->mtx); |
| 1723 | fetch->mods = std::move(mods); |
| 1724 | fetch->ok = ok; |
| 1725 | fetch->done = true; |
| 1726 | }) |
| 1727 | .detach(); |
| 1728 | } |
| 1729 | |
| 1730 | void DisplayMods::MergeWorkshopMods(const std::vector<MasterServerServiceModCatalogEntry>& catalog) |
| 1731 | { |
| 1732 | CModsList* list = dynamic_cast<CModsList*>(GetCtrl(IDC_MODS_LIST)); |
| 1733 | if (list == nullptr) |