diff --git a/include/SKSE/RegistrationMap.h b/include/SKSE/RegistrationMap.h index 3427f4c53..bb6e570af 100644 --- a/include/SKSE/RegistrationMap.h +++ b/include/SKSE/RegistrationMap.h @@ -100,8 +100,12 @@ namespace SKSE if (auto vm = RE::BSScript::Internal::VirtualMachine::GetSingleton()) { if (auto it = this->_regs.find(a_filter); it != this->_regs.end()) { for (auto& handle : it->second) { - auto args = RE::MakeFunctionArguments(std::forward(a_args)...); - vm->SendEvent(handle, eventName, args); + auto copy = std::make_tuple(a_args...); + std::apply([&](auto&&... a_copy) { + auto args = RE::MakeFunctionArguments(std::forward(a_copy)...); + vm->SendEvent(handle, eventName, args); + }, + copy); } } } diff --git a/include/SKSE/RegistrationMapUnique.h b/include/SKSE/RegistrationMapUnique.h index 515f8391f..acfd3e6f9 100644 --- a/include/SKSE/RegistrationMapUnique.h +++ b/include/SKSE/RegistrationMapUnique.h @@ -108,8 +108,12 @@ namespace SKSE for (auto& [eventFilter, handles] : it->second) { if (a_callback(eventFilter.first, eventFilter.second)) { for (auto& handle : handles) { - auto args = RE::MakeFunctionArguments(std::forward(a_args)...); - vm->SendEvent(handle, eventName, args); + auto copy = std::make_tuple(a_args...); + std::apply([&](auto&&... a_copy) { + auto args = RE::MakeFunctionArguments(std::forward(a_copy)...); + vm->SendEvent(handle, eventName, args); + }, + copy); } } } diff --git a/include/SKSE/RegistrationSet.h b/include/SKSE/RegistrationSet.h index e6411f56f..a4570e61d 100644 --- a/include/SKSE/RegistrationSet.h +++ b/include/SKSE/RegistrationSet.h @@ -87,8 +87,12 @@ namespace SKSE auto vm = RE::BSScript::Internal::VirtualMachine::GetSingleton(); for (auto& handle : _handles) { - auto args = RE::MakeFunctionArguments(std::forward(a_args)...); - vm->SendEvent(handle, eventName, args); + auto copy = std::make_tuple(a_args...); + std::apply([&](auto&&... a_copy) { + auto args = RE::MakeFunctionArguments(std::forward(a_copy)...); + vm->SendEvent(handle, eventName, args); + }, + copy); } } diff --git a/include/SKSE/RegistrationSetUnique.h b/include/SKSE/RegistrationSetUnique.h index 00f0616de..3c8038efc 100644 --- a/include/SKSE/RegistrationSetUnique.h +++ b/include/SKSE/RegistrationSetUnique.h @@ -92,8 +92,12 @@ namespace SKSE const auto targetID = a_target->GetFormID(); if (const auto it = _regs.find(targetID); it != _regs.end()) { for (auto& handle : it->second) { - auto args = RE::MakeFunctionArguments(std::forward(a_args)...); - vm->SendEvent(handle, eventName, args); + auto copy = std::make_tuple(a_args...); + std::apply([&](auto&&... a_copy) { + auto args = RE::MakeFunctionArguments(std::forward(a_copy)...); + vm->SendEvent(handle, eventName, args); + }, + copy); } } }