mirror of
https://github.com/geode-sdk/geode.git
synced 2024-11-26 17:36:05 -05:00
remove rvalue requirement, fix claimHook and claimPatch
This commit is contained in:
parent
b909bf69d8
commit
6a617789d2
5 changed files with 15 additions and 15 deletions
|
@ -271,7 +271,7 @@ namespace geode {
|
|||
* @returns Returns a pointer to the hook, or an error if the
|
||||
* hook already has an owner, or was unable to enable the hook.
|
||||
*/
|
||||
Result<Hook*> claimHook(std::shared_ptr<Hook>&& hook);
|
||||
Result<Hook*> claimHook(std::shared_ptr<Hook> hook);
|
||||
|
||||
/**
|
||||
* Disowns a hook which this mod owns, making this mod no longer its owner.
|
||||
|
@ -306,7 +306,7 @@ namespace geode {
|
|||
* @returns Returns a pointer to the patch, or an error if the
|
||||
* patch already has an owner, or was unable to enable the patch.
|
||||
*/
|
||||
Result<Patch*> claimPatch(std::shared_ptr<Patch>&& patch);
|
||||
Result<Patch*> claimPatch(std::shared_ptr<Patch> patch);
|
||||
|
||||
/**
|
||||
* Disowns a patch which this mod owns, making this mod no longer its owner.
|
||||
|
|
|
@ -96,7 +96,7 @@ namespace geode::modifier {
|
|||
ModifyDerived::Derived::onModify(*this);
|
||||
std::vector<std::string> added;
|
||||
for (auto& [uuid, hook] : m_hooks) {
|
||||
auto res = Mod::get()->claimHook(std::move(hook));
|
||||
auto res = Mod::get()->claimHook(hook);
|
||||
if (!res) {
|
||||
log::error("Failed to claim hook {}: {}", hook->getDisplayName(), res.error());
|
||||
}
|
||||
|
|
|
@ -121,8 +121,8 @@ void Mod::registerCustomSetting(std::string_view const key, std::unique_ptr<Sett
|
|||
return m_impl->registerCustomSetting(key, std::move(value));
|
||||
}
|
||||
|
||||
Result<Hook*> Mod::claimHook(std::shared_ptr<Hook>&& hook) {
|
||||
return m_impl->claimHook(std::move(hook));
|
||||
Result<Hook*> Mod::claimHook(std::shared_ptr<Hook> hook) {
|
||||
return m_impl->claimHook(hook);
|
||||
}
|
||||
|
||||
Result<> Mod::disownHook(Hook* hook) {
|
||||
|
@ -133,8 +133,8 @@ std::vector<Hook*> Mod::getHooks() const {
|
|||
return m_impl->getHooks();
|
||||
}
|
||||
|
||||
Result<Patch*> Mod::claimPatch(std::shared_ptr<Patch>&& patch) {
|
||||
return m_impl->claimPatch(std::move(patch));
|
||||
Result<Patch*> Mod::claimPatch(std::shared_ptr<Patch> patch) {
|
||||
return m_impl->claimPatch(patch);
|
||||
}
|
||||
|
||||
Result<> Mod::disownPatch(Patch* patch) {
|
||||
|
|
|
@ -454,12 +454,14 @@ bool Mod::Impl::depends(std::string_view const id) const {
|
|||
|
||||
// Hooks
|
||||
|
||||
Result<Hook*> Mod::Impl::claimHook(std::shared_ptr<Hook>&& hook) {
|
||||
Result<Hook*> Mod::Impl::claimHook(std::shared_ptr<Hook> hook) {
|
||||
auto res1 = hook->m_impl->setOwner(m_self);
|
||||
if (!res1) {
|
||||
return Err("Cannot claim hook: {}", res1.unwrapErr());
|
||||
}
|
||||
|
||||
m_hooks.push_back(hook);
|
||||
|
||||
auto ptr = hook.get();
|
||||
if (this->isEnabled() && hook->getAutoEnable()) {
|
||||
if (LoaderImpl::get()->isReadyToHook()) {
|
||||
|
@ -474,8 +476,6 @@ Result<Hook*> Mod::Impl::claimHook(std::shared_ptr<Hook>&& hook) {
|
|||
}
|
||||
}
|
||||
|
||||
m_hooks.push_back(std::move(hook));
|
||||
|
||||
return Ok(ptr);
|
||||
}
|
||||
|
||||
|
@ -510,12 +510,14 @@ Result<> Mod::Impl::disownHook(Hook* hook) {
|
|||
|
||||
// Patches
|
||||
|
||||
Result<Patch*> Mod::Impl::claimPatch(std::shared_ptr<Patch>&& patch) {
|
||||
Result<Patch*> Mod::Impl::claimPatch(std::shared_ptr<Patch> patch) {
|
||||
auto res1 = patch->m_impl->setOwner(m_self);
|
||||
if (!res1) {
|
||||
return Err("Cannot claim patch: {}", res1.unwrapErr());
|
||||
}
|
||||
|
||||
m_patches.push_back(patch);
|
||||
|
||||
auto ptr = patch.get();
|
||||
if (this->isEnabled() && patch->getAutoEnable()) {
|
||||
auto res2 = ptr->enable();
|
||||
|
@ -524,8 +526,6 @@ Result<Patch*> Mod::Impl::claimPatch(std::shared_ptr<Patch>&& patch) {
|
|||
}
|
||||
}
|
||||
|
||||
m_patches.push_back(std::move(patch));
|
||||
|
||||
return Ok(ptr);
|
||||
}
|
||||
|
||||
|
|
|
@ -113,11 +113,11 @@ namespace geode {
|
|||
SettingValue* getSetting(std::string_view const key) const;
|
||||
void registerCustomSetting(std::string_view const key, std::unique_ptr<SettingValue> value);
|
||||
|
||||
Result<Hook*> claimHook(std::shared_ptr<Hook>&& hook);
|
||||
Result<Hook*> claimHook(std::shared_ptr<Hook> hook);
|
||||
Result<> disownHook(Hook* hook);
|
||||
[[nodiscard]] std::vector<Hook*> getHooks() const;
|
||||
|
||||
Result<Patch*> claimPatch(std::shared_ptr<Patch>&& patch);
|
||||
Result<Patch*> claimPatch(std::shared_ptr<Patch> patch);
|
||||
Result<> disownPatch(Patch* patch);
|
||||
[[nodiscard]] std::vector<Patch*> getPatches() const;
|
||||
|
||||
|
|
Loading…
Reference in a new issue