From e30361d9a08305b18a1e8c62a5cd392e3d898ca5 Mon Sep 17 00:00:00 2001 From: Stjepan Bakrac Date: Sat, 29 Nov 2025 01:47:08 +0100 Subject: [PATCH 1/3] Updated to VS2026 and latest C++ toolset --- core/core.vcxproj | 4 ++-- core/src/hooks/ffximain.cpp | 4 ++-- core/src/scanner.hpp | 2 +- extern/luajit/luajit.vcxproj | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) mode change 100644 => 100755 core/core.vcxproj mode change 100644 => 100755 core/src/hooks/ffximain.cpp mode change 100644 => 100755 core/src/scanner.hpp mode change 100644 => 100755 extern/luajit/luajit.vcxproj diff --git a/core/core.vcxproj b/core/core.vcxproj old mode 100644 new mode 100755 index 30145a0..eeed18a --- a/core/core.vcxproj +++ b/core/core.vcxproj @@ -354,13 +354,13 @@ DynamicLibrary true - v143 + v145 Unicode DynamicLibrary false - v143 + v145 true Unicode diff --git a/core/src/hooks/ffximain.cpp b/core/src/hooks/ffximain.cpp old mode 100644 new mode 100755 index 482633e..890fe64 --- a/core/src/hooks/ffximain.cpp +++ b/core/src/hooks/ffximain.cpp @@ -594,9 +594,9 @@ void const* windower::ffximain::menu( for (auto it = hooks::menu_ptr; it && it->data; std::advance(it, 1)) { auto const name_ptr = static_cast(it->name); - auto const name_size = std::size(it->name); + auto constexpr name_size = std::size(it->name); auto const type_ptr = static_cast(it->type); - auto const type_size = std::size(it->type); + auto constexpr type_size = std::size(it->type); if (std::u8string_view{name_ptr, name_size} == name && std::u8string_view{type_ptr, type_size} == type) diff --git a/core/src/scanner.hpp b/core/src/scanner.hpp old mode 100644 new mode 100755 index 7652d62..924f217 --- a/core/src/scanner.hpp +++ b/core/src/scanner.hpp @@ -198,7 +198,7 @@ class signature inline namespace signature_literals { -consteval signature operator"" _sig(char8_t const* string, std::size_t size) +consteval signature operator ""_sig(char8_t const* string, std::size_t size) { return signature{std::u8string_view{string, size}}; } diff --git a/extern/luajit/luajit.vcxproj b/extern/luajit/luajit.vcxproj old mode 100644 new mode 100755 index 3dad982..34f1b40 --- a/extern/luajit/luajit.vcxproj +++ b/extern/luajit/luajit.vcxproj @@ -20,13 +20,13 @@ StaticLibrary true - v143 + v145 Unicode StaticLibrary false - v143 + v145 true Unicode @@ -81,7 +81,7 @@ - + var compilePattern = new Regex(@"^@set LJCOMPILE=cl\b"); var linkPattern = new Regex(@"^@set LJLINK=link\b"); From 4e13d1ae646fb7865ef780e4b0a60cfbfc49135d Mon Sep 17 00:00:00 2001 From: Stjepan Bakrac Date: Thu, 26 Mar 2026 23:26:35 +0100 Subject: [PATCH 2/3] Adjusted coroutine usage to new standard --- core/core.vcxproj | 7 +- core/src/addon/package_manager.cpp | 1 + core/src/addon/scheduler.cpp | 5 +- core/src/addon/scheduler.hpp | 16 ++--- core/src/command_handlers.cpp | 1 + core/src/downloader.cpp | 8 +-- core/src/downloader.hpp | 5 +- core/src/utilities/coroutine.hpp | 112 +++++++++++++++++++++++++++++ 8 files changed, 133 insertions(+), 22 deletions(-) mode change 100644 => 100755 core/src/addon/scheduler.cpp mode change 100644 => 100755 core/src/addon/scheduler.hpp mode change 100644 => 100755 core/src/command_handlers.cpp mode change 100644 => 100755 core/src/downloader.cpp mode change 100644 => 100755 core/src/downloader.hpp create mode 100755 core/src/utilities/coroutine.hpp diff --git a/core/core.vcxproj b/core/core.vcxproj index eeed18a..fb32895 100755 --- a/core/core.vcxproj +++ b/core/core.vcxproj @@ -153,6 +153,7 @@ + @@ -397,7 +398,7 @@ true MultiThreadedDebug true - /await /utf-8 /Zc:externConstexpr /Zc:throwingNew /Zc:__cplusplus + /utf-8 /Zc:externConstexpr /Zc:throwingNew /Zc:__cplusplus Async $(IntDir)\%(RelativeDir) stdcpplatest @@ -431,7 +432,7 @@ true MultiThreaded true - /await /utf-8 /Zc:externConstexpr /Zc:throwingNew /Zc:__cplusplus + /utf-8 /Zc:externConstexpr /Zc:throwingNew /Zc:__cplusplus @@ -640,4 +641,4 @@ - + \ No newline at end of file diff --git a/core/src/addon/package_manager.cpp b/core/src/addon/package_manager.cpp index c9134d3..01a32ab 100755 --- a/core/src/addon/package_manager.cpp +++ b/core/src/addon/package_manager.cpp @@ -28,6 +28,7 @@ #include "core.hpp" #include "downloader.hpp" #include "utilities/xml.hpp" +#include "utilities/coroutine.hpp" #include "utility.hpp" #include diff --git a/core/src/addon/scheduler.cpp b/core/src/addon/scheduler.cpp old mode 100644 new mode 100755 index c704977..002b3d6 --- a/core/src/addon/scheduler.cpp +++ b/core/src/addon/scheduler.cpp @@ -35,11 +35,10 @@ #include #include #include +#include #include #include -#include - bool windower::operator<=(wait_state const& lhs, wait_state const& rhs) noexcept { static_assert( @@ -65,7 +64,7 @@ windower::task::task(task&& other) noexcept : m_coroutine{other.m_coroutine} } windower::task::task( - std::experimental::coroutine_handle coroutine) noexcept : + std::coroutine_handle coroutine) noexcept : m_coroutine{coroutine} {} diff --git a/core/src/addon/scheduler.hpp b/core/src/addon/scheduler.hpp old mode 100644 new mode 100755 index 0530145..555b55e --- a/core/src/addon/scheduler.hpp +++ b/core/src/addon/scheduler.hpp @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -37,8 +38,6 @@ #include #include -#include - namespace windower { @@ -75,18 +74,17 @@ class task auto get_return_object() noexcept { return task{ - std::experimental::coroutine_handle::from_promise( - *this)}; + std::coroutine_handle::from_promise(*this)}; } auto initial_suspend() noexcept { - return std::experimental::suspend_always{}; + return std::suspend_always{}; } auto final_suspend() noexcept { - return std::experimental::suspend_always{}; + return std::suspend_always{}; } void return_void() noexcept {} @@ -118,7 +116,7 @@ class task bool await_ready() const noexcept { return !m_condition; } void - await_suspend(std::experimental::coroutine_handle<>) const noexcept + await_suspend(std::coroutine_handle<>) const noexcept {} bool await_resume() const noexcept { return m_condition; } @@ -152,9 +150,9 @@ class task void tag(void const*) const noexcept; private: - std::experimental::coroutine_handle m_coroutine; + std::coroutine_handle m_coroutine; - explicit task(std::experimental::coroutine_handle) noexcept; + explicit task(std::coroutine_handle) noexcept; }; class scheduler diff --git a/core/src/command_handlers.cpp b/core/src/command_handlers.cpp old mode 100644 new mode 100755 index e1a7e59..47ca822 --- a/core/src/command_handlers.cpp +++ b/core/src/command_handlers.cpp @@ -28,6 +28,7 @@ #include "core.hpp" #include "errors/command_error.hpp" #include "unicode.hpp" +#include "utilities/coroutine.hpp" #include "utility.hpp" #include diff --git a/core/src/downloader.cpp b/core/src/downloader.cpp old mode 100644 new mode 100755 index db7a0c5..9626613 --- a/core/src/downloader.cpp +++ b/core/src/downloader.cpp @@ -27,6 +27,7 @@ #include "core.hpp" #include "handle.hpp" #include "unicode.hpp" +#include "utilities/coroutine.hpp" #include "version.hpp" #include @@ -35,6 +36,7 @@ #include #include +#include #include #include #include @@ -43,8 +45,6 @@ #include #include -#include - namespace { @@ -388,7 +388,7 @@ struct windower::downloader::job::impl std::vector const files; std::mutex mutex; std::atomic complete = false; - std::experimental::coroutine_handle<> resumable = nullptr; + std::coroutine_handle<> resumable = nullptr; }; windower::downloader::job::awaiter::awaiter(job const& job) noexcept : @@ -401,7 +401,7 @@ bool windower::downloader::job::awaiter::await_ready() const noexcept } void windower::downloader::job::awaiter::await_suspend( - std::experimental::coroutine_handle<> resumable) const + std::coroutine_handle<> resumable) const { std::lock_guard lock{m_job.m_impl->mutex}; if (m_job.m_impl->complete) diff --git a/core/src/downloader.hpp b/core/src/downloader.hpp old mode 100644 new mode 100755 index 1678fea..67d0ee2 --- a/core/src/downloader.hpp +++ b/core/src/downloader.hpp @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -36,8 +37,6 @@ #include #include -#include - namespace windower { @@ -103,7 +102,7 @@ class downloader bool await_ready() const noexcept; - void await_suspend(std::experimental::coroutine_handle<>) const; + void await_suspend(std::coroutine_handle<>) const; std::vector await_resume() const; diff --git a/core/src/utilities/coroutine.hpp b/core/src/utilities/coroutine.hpp new file mode 100755 index 0000000..5447303 --- /dev/null +++ b/core/src/utilities/coroutine.hpp @@ -0,0 +1,112 @@ +/* + * Copyright © Windower Dev Team + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation files + * (the "Software"),to deal in the Software without restriction, + * including without limitation the rights to use, copy, modify, merge, + * publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#pragma once + +#include +#include +#include + +template + requires(!std::is_void_v && !std::is_reference_v) +struct std::coroutine_traits< + std::future, T&, Args...> +{ + struct promise_type : std::promise + { + std::future get_return_object() noexcept + { + return this->get_future(); + } + + std::suspend_never initial_suspend() const noexcept { return {}; } + std::suspend_never final_suspend() const noexcept { return {}; } + + void return_value(R const& value) noexcept( + std::is_nothrow_copy_constructible_v) + { + this->set_value(value); + } + + void return_value(R&& value) noexcept( + std::is_nothrow_move_constructible_v) + { + this->set_value(std::move(value)); + } + + void unhandled_exception() noexcept + { + this->set_exception(std::current_exception()); + } + }; +}; + +template +struct std::coroutine_traits< + std::future, T&, Args...> +{ + struct promise_type : std::promise + { + std::future get_return_object() noexcept + { + return this->get_future(); + } + + std::suspend_never initial_suspend() const noexcept { return {}; } + std::suspend_never final_suspend() const noexcept { return {}; } + + void return_void() noexcept { this->set_value(); } + + void unhandled_exception() noexcept + { + this->set_exception(std::current_exception()); + } + }; +}; + +template +auto operator co_await(std::future future) noexcept + requires(!std::is_reference_v) +{ + struct awaiter : std::future + { + bool await_ready() const noexcept + { + return this->wait_for(std::chrono::seconds(0)) != + std::future_status::timeout; + } + + void await_suspend(std::coroutine_handle<> continuation) const + { + std::thread([this, continuation] { + this->await_ready(); + continuation(); + }).detach(); + } + + R await_resume() { return this->get(); } + }; + + return awaiter{std::move(future)}; +} From e084f9bac4505753813d21195aeb36d849d019a7 Mon Sep 17 00:00:00 2001 From: Stjepan Bakrac Date: Thu, 26 Mar 2026 23:26:53 +0100 Subject: [PATCH 3/3] Fixed minor copy issues --- core/src/addon/package_manager.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/src/addon/package_manager.cpp b/core/src/addon/package_manager.cpp index 01a32ab..08d4ba4 100755 --- a/core/src/addon/package_manager.cpp +++ b/core/src/addon/package_manager.cpp @@ -595,9 +595,9 @@ std::future windower::package_manager::update_sources(bool force) {} std::vector files; - for (auto source : m_package_sources) + for (auto const& source : m_package_sources) { - auto url = source.url; + auto url{source.url}; auto path = staging_path / source.guid; if (url.empty() || url.back() != u8'/') { @@ -651,7 +651,7 @@ windower::package_manager::update_source(source source, bool force) std::vector files; { - auto url = source.url; + auto url{source.url}; auto path = staging_path / source.guid; if (url.empty() || url.back() != u8'/') { @@ -767,7 +767,7 @@ windower::package_manager::install_or_update( std::vector jobs; for (auto const& p : packages) { - auto root_url = p.root_url; + auto root_url{p.root_url}; if (root_url.empty() || root_url.back() != u8'/') { root_url.append(1, u8'/'); @@ -777,7 +777,8 @@ windower::package_manager::install_or_update( for (auto const& file : p.files) { auto url = root_url + file.generic_u8string(); - auto path = (staging_path / file).make_preferred(); + auto path = staging_path / file; + path.make_preferred(); fs::create_directories(path.parent_path()); auto const time = last_modified(m_installed_package_directory / file, force); @@ -802,7 +803,7 @@ windower::package_manager::install_or_update( it2->name + u8"\""; if (windower::core::instance().settings.verbose_logging) { - for (auto r : results) + for (auto const& r : results) { ::check(r); } @@ -829,7 +830,7 @@ windower::package_manager::install_or_update( } std::lock_guard lock{m_mutex}; - for (auto r : results) + for (auto const& r : results) { auto path = m_installed_package_directory / relative(r.file().path, staging_path);