Skip to content

Commit

Permalink
Merge pull request #152 from Scrabx3/dev
Browse files Browse the repository at this point in the history
Fix argument forwarding in Event classes
  • Loading branch information
powerof3 authored Nov 25, 2024
2 parents 1372f92 + 9b932e0 commit 3e29894
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
8 changes: 6 additions & 2 deletions include/SKSE/RegistrationMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Args>(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<Args>(a_copy)...);
vm->SendEvent(handle, eventName, args);
},
copy);
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions include/SKSE/RegistrationMapUnique.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Args>(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<Args>(a_copy)...);
vm->SendEvent(handle, eventName, args);
},
copy);
}
}
}
Expand Down
8 changes: 6 additions & 2 deletions include/SKSE/RegistrationSet.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,12 @@ namespace SKSE

auto vm = RE::BSScript::Internal::VirtualMachine::GetSingleton();
for (auto& handle : _handles) {
auto args = RE::MakeFunctionArguments(std::forward<Args>(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<Args>(a_copy)...);
vm->SendEvent(handle, eventName, args);
},
copy);
}
}

Expand Down
8 changes: 6 additions & 2 deletions include/SKSE/RegistrationSetUnique.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<Args>(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<Args>(a_copy)...);
vm->SendEvent(handle, eventName, args);
},
copy);
}
}
}
Expand Down

0 comments on commit 3e29894

Please sign in to comment.