From a43dc456652d5f79438bc51e117dd4e094fb980c Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 19 Sep 2021 13:02:24 +0200 Subject: [PATCH] Fixes Pokemon::get_DisplaySpecies and get_DisplayForme segfaulting in angelscript. --- .../TypeRegistry/Battling/RegisterPokemonClass.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index 5078dff..8630f19 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -90,6 +90,11 @@ static std::string NicknameWrapper(const PkmnLib::Battling::Pokemon* obj) { BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::CreatureSpecies, GetSpecies); BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const PkmnLib::Library::PokemonForme, GetForme); +OPTIONAL_BORROWED_PTR_GETTER_FUNC(CreatureLib::Battling::Creature, const CreatureLib::Library::CreatureSpecies, + GetDisplaySpecies); +OPTIONAL_BORROWED_PTR_GETTER_FUNC(CreatureLib::Battling::Creature, const CreatureLib::Library::SpeciesVariant, + GetDisplayVariant); + OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, const CreatureLib::Library::Item, GetHeldItem); OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::Battle, GetBattle); OPTIONAL_BORROWED_PTR_GETTER_FUNC(PkmnLib::Battling::Pokemon, CreatureLib::Battling::BattleSide, GetBattleSide); @@ -143,8 +148,8 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("Pokemon", "uint32 get_CurrentHealth() const property", asMETHOD(PkmnLib::Battling::Pokemon, GetCurrentHealth), asCALL_THISCALL); Ensure(r >= 0); - r = engine->RegisterObjectMethod("Pokemon", "string get_Nickname() const property", - asFUNCTION(NicknameWrapper), asCALL_CDECL_OBJFIRST); + r = engine->RegisterObjectMethod("Pokemon", "string get_Nickname() const property", asFUNCTION(NicknameWrapper), + asCALL_CDECL_OBJFIRST); Ensure(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "const constString& get_ActiveAbility() const property", asMETHOD(PkmnLib::Battling::Pokemon, GetActiveTalent), asCALL_THISCALL); @@ -174,10 +179,10 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { asMETHOD(PkmnLib::Battling::Pokemon, ChangeStatBoost), asCALL_THISCALL); Ensure(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "const Species@ get_DisplaySpecies() const property", - asMETHOD(PkmnLib::Battling::Pokemon, GetDisplaySpecies), asCALL_THISCALL); + asFUNCTION(GetDisplaySpeciesWrapper), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "const Species@ get_DisplayForme() const property", - asMETHOD(PkmnLib::Battling::Pokemon, GetDisplayVariant), asCALL_THISCALL); + asFUNCTION(GetDisplayVariantWrapper), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "uint32 GetFlatStat(Statistic stat) const", asMETHOD(PkmnLib::Battling::Pokemon, GetFlatStat), asCALL_THISCALL);