From cf34563a563a7bef2a3eda940c495fe3e31a3da3 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sat, 14 May 2022 16:50:20 +0200 Subject: [PATCH] Update to latest CreatureLib --- .../AngelScript/AngelScriptResolver.cpp | 2 +- src/Battling/Battle/Battle.cpp | 16 ++++++++-------- src/Battling/Battle/Battle.hpp | 15 ++++++++------- src/Battling/Library/CaptureLibrary.cpp | 4 ++-- src/Battling/Pokemon/Pokemon.cpp | 8 ++++---- .../AngelScript/AngelScriptResolver.cpp | 11 ++++++----- .../AngelScript/AngelScriptResolver.hpp | 9 +++++---- .../WASM/WebAssemblyFunctionCall.hpp | 2 +- .../WASM/WebAssemblyScriptResolver.cpp | 2 +- .../WASM/WebAssemblyScriptResolver.hpp | 2 +- .../Angelscript/BaseScriptClassTests.cpp | 2 +- .../Angelscript/ItemUseScriptTests.cpp | 2 +- .../Angelscript/ScriptOwnerTest.cpp | 2 +- .../Angelscript/ScriptResolverTests.cpp | 19 ++++++++++--------- .../ScriptTypeTests/Battle/BattleTests.cpp | 2 +- .../ScriptTypeTests/Battle/PokemonTests.cpp | 2 +- .../ScriptTypeTests/Library/FormesTests.cpp | 2 +- .../ScriptTypeTests/Library/ItemDataTests.cpp | 2 +- .../ScriptTypeTests/Library/MoveTests.cpp | 2 +- .../ScriptTypeTests/Library/SpeciesTests.cpp | 2 +- .../Library/StaticLibraryTests.cpp | 2 +- .../ScriptTests/WASM/ScriptResolverTests.cpp | 2 +- 22 files changed, 58 insertions(+), 54 deletions(-) diff --git a/CInterface/AngelScript/AngelScriptResolver.cpp b/CInterface/AngelScript/AngelScriptResolver.cpp index 9e03125..f317d59 100644 --- a/CInterface/AngelScript/AngelScriptResolver.cpp +++ b/CInterface/AngelScript/AngelScriptResolver.cpp @@ -15,7 +15,7 @@ export_func uint8_t PkmnLib_AngelScriptResolver_CreateScript(AngelScriptResolver export_func uint8_t PkmnLib_AngelScriptResolver_FinalizeModule(AngelScriptResolver* p) { Try(p->FinalizeModule();) } export_func uint8_t PkmnLib_AngelScriptResolver_LoadScript(CreatureLib::Battling::BattleScript*& out, AngelScriptResolver* p, void* owner, ScriptCategory category, const char* scriptName) { - Try(out = p->LoadScript(owner, category, ArbUt::StringView(scriptName));) + Try(out = p->LoadScript(owner, category, ArbUt::StringView(scriptName)).TakeOwnership();) } export_func uint8_t PkmnLib_AngelScriptResolver_LoadEvolutionScript(PkmnLib::Battling::EvolutionScript const*& out, AngelScriptResolver* p, const char* scriptName) { diff --git a/src/Battling/Battle/Battle.cpp b/src/Battling/Battle/Battle.cpp index 3cbef4f..7b283e2 100644 --- a/src/Battling/Battle/Battle.cpp +++ b/src/Battling/Battle/Battle.cpp @@ -6,18 +6,18 @@ bool PkmnLib::Battling::Battle::SetWeather(const ArbUt::StringView& name) { if (blockWeather) { return false; } - if (_weatherScript != nullptr) { - _weatherScript->OnRemove(); + if (_weatherScript.HasValue()) { + _weatherScript.GetValue()->OnRemove(); } - _weatherScript = std::unique_ptr( - _library->LoadScript(this, static_cast(PkmnScriptCategory::Weather), name)); + _weatherScript = + _library->LoadScript(this, static_cast(PkmnScriptCategory::Weather), name).TakeOwnership(); _eventHook.Trigger(name); return true; } void PkmnLib::Battling::Battle::ClearWeather() { - if (_weatherScript == nullptr) + if (!_weatherScript.HasValue()) return; - _weatherScript->OnRemove(); + _weatherScript.GetValue()->OnRemove(); _weatherScript = nullptr; _eventHook.Trigger(""_cnc); } @@ -65,8 +65,8 @@ PkmnLib::Battling::Battle* PkmnLib::Battling::Battle::Clone() const { battle->_battleResult = _battleResult; battle->_currentTurn = _currentTurn; _volatile.Clone(battle, battle->_volatile); - if (_weatherScript != nullptr) { - battle->_weatherScript = std::unique_ptr(_weatherScript->Clone(battle)); + if (_weatherScript.HasValue()) { + battle->_weatherScript = _weatherScript.GetValue()->Clone(battle); } return battle; diff --git a/src/Battling/Battle/Battle.hpp b/src/Battling/Battle/Battle.hpp index 96c77e5..d583ec6 100644 --- a/src/Battling/Battle/Battle.hpp +++ b/src/Battling/Battle/Battle.hpp @@ -10,7 +10,7 @@ namespace PkmnLib::Battling { class Battle : public CreatureLib::Battling::Battle { private: - std::unique_ptr _weatherScript = nullptr; + ArbUt::OptionalUniquePtr _weatherScript = nullptr; public: Battle(const BattleLibrary* non_null library, @@ -26,20 +26,21 @@ namespace PkmnLib::Battling { bool SetWeather(const ArbUt::StringView& name); void ClearWeather(); void SuppressWeather() { - if (_weatherScript != nullptr) { - _weatherScript->Suppress(); + if (_weatherScript.HasValue()) { + _weatherScript.GetValue()->Suppress(); } } void UnsuppressWeather() { - if (_weatherScript != nullptr) { - _weatherScript->Unsuppress(); + if (_weatherScript.HasValue()) { + _weatherScript.GetValue()->Unsuppress(); } } const ArbUt::StringView& GetWeatherName() noexcept { - if (_weatherScript == nullptr) + if (!_weatherScript.HasValue()) { return ArbUt::StringView::EmptyString(); - return _weatherScript->GetName(); + } + return _weatherScript.GetValue()->GetName(); } size_t ScriptCount() const override { return CreatureLib::Battling::Battle::ScriptCount() + 1; } diff --git a/src/Battling/Library/CaptureLibrary.cpp b/src/Battling/Library/CaptureLibrary.cpp index 275246f..3d6889c 100644 --- a/src/Battling/Library/CaptureLibrary.cpp +++ b/src/Battling/Library/CaptureLibrary.cpp @@ -11,8 +11,8 @@ namespace PkmnLib::Battling { auto rate = pokemon->GetSpecies()->GetCaptureRate(); u8 bonusBall = 1; - auto* itemScript = - dynamic_cast(pokemon->GetLibrary()->GetScriptResolver()->LoadItemScript(catchItem)); + auto* itemScript = dynamic_cast( + pokemon->GetLibrary()->GetScriptResolver()->LoadItemScript(catchItem).GetValue()); itemScript->ModifyPokeballCatchBonus(pokemon, &bonusBall); u8 bonusStatus = 1; diff --git a/src/Battling/Pokemon/Pokemon.cpp b/src/Battling/Pokemon/Pokemon.cpp index 1ceee50..c0634c4 100644 --- a/src/Battling/Pokemon/Pokemon.cpp +++ b/src/Battling/Pokemon/Pokemon.cpp @@ -53,13 +53,13 @@ CreatureLib::Battling::Creature* PkmnLib::Battling::Pokemon::Clone() const { c->_battleData.Side = _battleData.Side; c->_battleData.OnBattleField = _battleData.OnBattleField; c->_battleData.Index = _battleData.Index; - if (_activeTalent != nullptr) { - c->_activeTalent = std::unique_ptr(_activeTalent->Clone(c)); + if (_activeTalent.HasValue()) { + c->_activeTalent = _activeTalent.GetValue()->Clone(c); } c->_hasOverridenTalent = _hasOverridenTalent; c->_overridenTalent = _overridenTalent; - if (_status != nullptr) { - c->_status = std::unique_ptr(_status->Clone(c)); + if (_status.HasValue()) { + c->_status = _status.GetValue()->Clone(c); } _volatile.Clone(c, c->_volatile); c->_types = std::vector(_types); diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp index d9fd12a..3beff00 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.cpp @@ -165,9 +165,9 @@ void AngelScriptResolver::MessageCallback(const asSMessageInfo* msg, void*) { printf("%s (%d, %d) : %s : %s\n", msg->section, msg->row, msg->col, type, msg->message); } -CreatureLib::Battling::BattleScript* AngelScriptResolver::LoadScript(const ArbUt::OptionalBorrowedPtr& owner, - ScriptCategory category, - const ArbUt::StringView& scriptName) { +ArbUt::OptionalUniquePtr +AngelScriptResolver::LoadScript(const ArbUt::OptionalBorrowedPtr& owner, ScriptCategory category, + const ArbUt::StringView& scriptName) { ArbUt::Dictionary innerDb; auto v = _typeDatabase.TryGet(category); if (!v.has_value()) { @@ -193,10 +193,11 @@ CreatureLib::Battling::BattleScript* AngelScriptResolver::LoadScript(const ArbUt return new AngelScriptScript(owner, ownerType, this, t.value(), obj, _contextPool); } -PkmnLib::Battling::PkmnItemUseScript* AngelScriptResolver::LoadItemScript(const CreatureLib::Library::Item* item) { +ArbUt::OptionalUniquePtr +AngelScriptResolver::LoadItemScript(const CreatureLib::Library::Item* item) { auto v = this->_itemUseScripts.TryGet(item); if (v.has_value()) { - return v.value(); + return {v.value()}; } if (!item->GetEffect().HasValue()) { return nullptr; diff --git a/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp b/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp index 73f8cc1..5c2758c 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp +++ b/src/ScriptResolving/AngelScript/AngelScriptResolver.hpp @@ -66,10 +66,11 @@ public: void DefineWord(const std::string& word) { _builder.DefineWord(word.c_str()); } - CreatureLib::Battling::BattleScript* LoadScript(const ArbUt::OptionalBorrowedPtr& owner, - ScriptCategory category, - const ArbUt::StringView& scriptName) override; - PkmnLib::Battling::PkmnItemUseScript* LoadItemScript(const CreatureLib::Library::Item* item) override; + ArbUt::OptionalUniquePtr + LoadScript(const ArbUt::OptionalBorrowedPtr& owner, ScriptCategory category, + const ArbUt::StringView& scriptName) override; + ArbUt::OptionalUniquePtr + LoadItemScript(const CreatureLib::Library::Item* item) override; ArbUt::OptionalBorrowedPtr LoadEvolutionScript(const ArbUt::StringView& view) override; diff --git a/src/ScriptResolving/WASM/WebAssemblyFunctionCall.hpp b/src/ScriptResolving/WASM/WebAssemblyFunctionCall.hpp index 9b4c30c..5c1d593 100644 --- a/src/ScriptResolving/WASM/WebAssemblyFunctionCall.hpp +++ b/src/ScriptResolving/WASM/WebAssemblyFunctionCall.hpp @@ -11,7 +11,7 @@ class WebAssemblyFunctionCall { public: WebAssemblyFunctionCall(const ArbUt::BorrowedPtr& func) : _func(func) {} - NO_COPY_OR_MOVE(WebAssemblyFunctionCall) + NO_COPY_OR_MOVE(WebAssemblyFunctionCall); void Call() { wasm_val_vec_t args = {argsCount, _arguments.Data}; diff --git a/src/ScriptResolving/WASM/WebAssemblyScriptResolver.cpp b/src/ScriptResolving/WASM/WebAssemblyScriptResolver.cpp index 6836678..a1af21a 100644 --- a/src/ScriptResolving/WASM/WebAssemblyScriptResolver.cpp +++ b/src/ScriptResolving/WASM/WebAssemblyScriptResolver.cpp @@ -132,7 +132,7 @@ void WebAssemblyScriptResolver::Finalize() { } } -CreatureLib::Battling::BattleScript* +ArbUt::OptionalUniquePtr WebAssemblyScriptResolver::LoadScript(const ArbUt::OptionalBorrowedPtr& owner, ScriptCategory category, const ArbUt::StringView& scriptName) { auto loadScriptOpt = GetFunction<2, 1>("load_script"_cnc); diff --git a/src/ScriptResolving/WASM/WebAssemblyScriptResolver.hpp b/src/ScriptResolving/WASM/WebAssemblyScriptResolver.hpp index 03c516b..7d19a6e 100644 --- a/src/ScriptResolving/WASM/WebAssemblyScriptResolver.hpp +++ b/src/ScriptResolving/WASM/WebAssemblyScriptResolver.hpp @@ -44,7 +44,7 @@ public: [[nodiscard]] inline wasm_memory_t* GetMemory() const noexcept { return _memory; } - CreatureLib::Battling::BattleScript* LoadScript(const ArbUt::OptionalBorrowedPtr& owner, + ArbUt::OptionalUniquePtr LoadScript(const ArbUt::OptionalBorrowedPtr& owner, ScriptCategory category, const ArbUt::StringView& scriptName) nullable override; diff --git a/tests/ScriptTests/Angelscript/BaseScriptClassTests.cpp b/tests/ScriptTests/Angelscript/BaseScriptClassTests.cpp index 4753f59..ea9ba71 100644 --- a/tests/ScriptTests/Angelscript/BaseScriptClassTests.cpp +++ b/tests/ScriptTests/Angelscript/BaseScriptClassTests.cpp @@ -112,7 +112,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* static AngelScriptScript* GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ArbUt::StringView& scriptName) { auto lib = GetScriptResolver(mainLib); - auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, scriptName); + auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, scriptName).TakeOwnership(); auto script = dynamic_cast(s); REQUIRE(script != nullptr); diff --git a/tests/ScriptTests/Angelscript/ItemUseScriptTests.cpp b/tests/ScriptTests/Angelscript/ItemUseScriptTests.cpp index b304cab..42723dc 100644 --- a/tests/ScriptTests/Angelscript/ItemUseScriptTests.cpp +++ b/tests/ScriptTests/Angelscript/ItemUseScriptTests.cpp @@ -45,7 +45,7 @@ static AngelScriptItemUseScript* GetScript(PkmnLib::Battling::BattleLibrary* mai new CreatureLib::Library::SecondaryEffect(100, name, {}), nullptr, {}); auto s = lib->LoadItemScript(&item); - auto script = dynamic_cast(s); + auto script = dynamic_cast(s.TakeOwnership()); REQUIRE(script != nullptr); return script; } diff --git a/tests/ScriptTests/Angelscript/ScriptOwnerTest.cpp b/tests/ScriptTests/Angelscript/ScriptOwnerTest.cpp index 6653ce6..39047af 100644 --- a/tests/ScriptTests/Angelscript/ScriptOwnerTest.cpp +++ b/tests/ScriptTests/Angelscript/ScriptOwnerTest.cpp @@ -55,7 +55,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* static AngelScriptScript* GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ArbUt::StringView& scriptName, PkmnLib::Battling::Pokemon* owner) { auto* lib = GetScriptResolver(mainLib); - auto* s = lib->LoadScript(owner, ScriptCategory::Creature, scriptName); + auto* s = lib->LoadScript(owner, ScriptCategory::Creature, scriptName).TakeOwnership(); auto* script = dynamic_cast(s); REQUIRE(script != nullptr); diff --git a/tests/ScriptTests/Angelscript/ScriptResolverTests.cpp b/tests/ScriptTests/Angelscript/ScriptResolverTests.cpp index 0bdc8c3..3f079cd 100644 --- a/tests/ScriptTests/Angelscript/ScriptResolverTests.cpp +++ b/tests/ScriptTests/Angelscript/ScriptResolverTests.cpp @@ -1,8 +1,8 @@ #if TESTS_BUILD && ANGELSCRIPT #include +#include "../../TestLibrary/TestLibrary.hpp" #include "../../src/ScriptResolving/AngelScript/AngelScriptResolver.hpp" #include "../../src/ScriptResolving/AngelScript/ContextPool.hpp" -#include "../../TestLibrary/TestLibrary.hpp" static std::unordered_map _scripts = std::unordered_map{{"testScript1", R"( @@ -44,8 +44,7 @@ TEST_CASE("Build script resolver, then create object") { lib->CreateScript("testScript1", _scripts["testScript1"]); lib->FinalizeModule(); - auto obj = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc); - + auto obj = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership(); delete obj; delete lib; } @@ -56,7 +55,8 @@ TEST_CASE("Build script resolver, create object, invoke addition method") { lib->CreateScript("testScript1", _scripts["testScript1"]); lib->FinalizeModule(); - auto obj = dynamic_cast(lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc)); + auto obj = dynamic_cast( + lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership()); REQUIRE(obj != nullptr); auto ctxPool = obj->GetContextPool(); auto ctx = ctxPool->RequestContext(); @@ -86,8 +86,8 @@ TEST_CASE("Get a script resolver, save the byte code to memory, create new scrip originLib->Initialize(TestLibrary::GetLibrary()); originLib->CreateScript("testScript1", _scripts["testScript1"]); originLib->FinalizeModule(); - auto obj = - dynamic_cast(originLib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc)); + auto obj = dynamic_cast( + originLib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership()); REQUIRE(obj != nullptr); REQUIRE(obj->GetType()->GetOnInitialize().Exists); delete obj; @@ -97,7 +97,8 @@ TEST_CASE("Get a script resolver, save the byte code to memory, create new scrip auto newLib = dynamic_cast(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); newLib->Initialize(TestLibrary::GetLibrary()); newLib->LoadByteCodeFromMemory(byteCode, size); - obj = dynamic_cast(newLib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc)); + obj = dynamic_cast( + newLib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership()); REQUIRE(obj != nullptr); REQUIRE(obj->GetType()->GetOnInitialize().Exists); delete obj; @@ -115,8 +116,8 @@ TEST_CASE("Get a script resolver, save the byte code to file, create new script auto newLib = dynamic_cast(PkmnLib::Battling::BattleLibrary::CreateScriptResolver()); newLib->Initialize(TestLibrary::GetLibrary()); newLib->LoadByteCodeFromFile("foo.bin"); - auto obj = - dynamic_cast(newLib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc)); + auto obj = dynamic_cast( + newLib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership()); REQUIRE(obj != nullptr); delete obj; delete originLib; diff --git a/tests/ScriptTests/Angelscript/ScriptTypeTests/Battle/BattleTests.cpp b/tests/ScriptTests/Angelscript/ScriptTypeTests/Battle/BattleTests.cpp index 9317f52..b6363da 100644 --- a/tests/ScriptTests/Angelscript/ScriptTypeTests/Battle/BattleTests.cpp +++ b/tests/ScriptTests/Angelscript/ScriptTypeTests/Battle/BattleTests.cpp @@ -44,7 +44,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ArbUt::StringView& funcName) { auto lib = GetScriptResolver(mainLib); - auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc); + auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership(); auto script = dynamic_cast(s); REQUIRE(script != nullptr); diff --git a/tests/ScriptTests/Angelscript/ScriptTypeTests/Battle/PokemonTests.cpp b/tests/ScriptTests/Angelscript/ScriptTypeTests/Battle/PokemonTests.cpp index 6b773e5..e5470c9 100644 --- a/tests/ScriptTests/Angelscript/ScriptTypeTests/Battle/PokemonTests.cpp +++ b/tests/ScriptTests/Angelscript/ScriptTypeTests/Battle/PokemonTests.cpp @@ -57,7 +57,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ArbUt::StringView& funcName) { auto lib = GetScriptResolver(mainLib); - auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc); + auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership(); auto script = dynamic_cast(s); REQUIRE(script != nullptr); diff --git a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/FormesTests.cpp b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/FormesTests.cpp index eefc507..75838d6 100644 --- a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/FormesTests.cpp +++ b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/FormesTests.cpp @@ -45,7 +45,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ArbUt::StringView& funcName) { auto lib = GetScriptResolver(mainLib); - auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc); + auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership(); auto script = dynamic_cast(s); REQUIRE(script != nullptr); diff --git a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/ItemDataTests.cpp b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/ItemDataTests.cpp index 22bac27..17196f3 100644 --- a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/ItemDataTests.cpp +++ b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/ItemDataTests.cpp @@ -41,7 +41,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ArbUt::StringView& funcName) { auto lib = GetScriptResolver(mainLib); - auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc); + auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership(); auto script = dynamic_cast(s); REQUIRE(script != nullptr); diff --git a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/MoveTests.cpp b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/MoveTests.cpp index 69af80e..8161f59 100644 --- a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/MoveTests.cpp +++ b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/MoveTests.cpp @@ -45,7 +45,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ArbUt::StringView& funcName) { auto lib = GetScriptResolver(mainLib); - auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc); + auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership(); auto script = dynamic_cast(s); REQUIRE(script != nullptr); diff --git a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/SpeciesTests.cpp b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/SpeciesTests.cpp index b95256d..06f6a5f 100644 --- a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/SpeciesTests.cpp +++ b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/SpeciesTests.cpp @@ -43,7 +43,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ArbUt::StringView& funcName) { auto lib = GetScriptResolver(mainLib); - auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc); + auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership(); auto script = dynamic_cast(s); REQUIRE(script != nullptr); diff --git a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/StaticLibraryTests.cpp b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/StaticLibraryTests.cpp index 982158a..908e7b7 100644 --- a/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/StaticLibraryTests.cpp +++ b/tests/ScriptTests/Angelscript/ScriptTypeTests/Library/StaticLibraryTests.cpp @@ -44,7 +44,7 @@ static AngelScriptResolver* GetScriptResolver(PkmnLib::Battling::BattleLibrary* static ScriptData GetScript(PkmnLib::Battling::BattleLibrary* mainLib, const ArbUt::StringView& funcName) { auto lib = GetScriptResolver(mainLib); - auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc); + auto s = lib->LoadScript(nullptr, ScriptCategory::Creature, "testScript1"_cnc).TakeOwnership(); auto script = dynamic_cast(s); REQUIRE(script != nullptr); diff --git a/tests/ScriptTests/WASM/ScriptResolverTests.cpp b/tests/ScriptTests/WASM/ScriptResolverTests.cpp index 9f0b140..98da026 100644 --- a/tests/ScriptTests/WASM/ScriptResolverTests.cpp +++ b/tests/ScriptTests/WASM/ScriptResolverTests.cpp @@ -56,7 +56,7 @@ TEST_CASE("Get a script resolver, load a real wasm script, load test script") { lib->Finalize(); auto script = lib->LoadScript(nullptr, ScriptCategory::Attack, "test"_cnc); EnsureNotNull(script); - script->OnInitialize(TestLibrary::GetLibrary(), {}); + script.GetValue()->OnInitialize(TestLibrary::GetLibrary(), {}); delete script; }