From e4b818c799b9f63f980440809453e1463fba605d Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Tue, 7 Jun 2022 23:12:55 +0200 Subject: [PATCH] Fixes angelscript build with new stat getter changes on Pokemon class. --- .../Battling/RegisterPokemonClass.cpp | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp index 7a13139..a3c6851 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterPokemonClass.cpp @@ -96,6 +96,19 @@ static float GetEffectivenessHelper(CreatureLib::Library::TypeLibrary* typeLib, return typeLib->GetEffectiveness(attackingType, pokemon->GetTypes()); } +static u32 GetFlatStat(PkmnLib::Battling::Pokemon* obj, CreatureLib::Library::Statistic stat) { + return obj->GetFlatStat(stat); +} +static u32 GetBoostedStat(PkmnLib::Battling::Pokemon* obj, CreatureLib::Library::Statistic stat) { + return obj->GetBoostedStat(stat); +} +static u32 GetBaseStat(PkmnLib::Battling::Pokemon* obj, CreatureLib::Library::Statistic stat) { + return obj->GetBaseStat(stat); +} +static i8 GetStatBoost(PkmnLib::Battling::Pokemon* obj, CreatureLib::Library::Statistic stat) { + return obj->GetStatBoost(stat); +} + void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { Ensure(engine->RegisterObjectType("Pokemon", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0); REGISTER_GETTER("Pokemon", "const Species@ get_Species() const property", CreatureLib::Battling::Creature, @@ -180,17 +193,17 @@ void RegisterPokemonClass::RegisterPokemonType(asIScriptEngine* engine) { r = engine->RegisterObjectMethod("Pokemon", "void ChangeStatBoost(Statistic stat, int8 amount, bool selfInflicted)", asMETHOD(PkmnLib::Battling::Pokemon, ChangeStatBoost), asCALL_THISCALL); Ensure(r >= 0); - r = engine->RegisterObjectMethod("Pokemon", "uint32 GetFlatStat(Statistic stat) const", - asMETHOD(PkmnLib::Battling::Pokemon, GetFlatStat), asCALL_THISCALL); + r = engine->RegisterObjectMethod("Pokemon", "uint32 GetFlatStat(Statistic stat) const", asFUNCTION(GetFlatStat), + asCALL_CDECL_OBJFIRST); Ensure(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "uint32 GetBoostedStat(Statistic stat) const", - asMETHOD(PkmnLib::Battling::Pokemon, GetBoostedStat), asCALL_THISCALL); + asFUNCTION(GetBoostedStat), asCALL_CDECL_OBJFIRST); Ensure(r >= 0); - r = engine->RegisterObjectMethod("Pokemon", "uint32 GetBaseStat(Statistic stat) const", - asMETHOD(PkmnLib::Battling::Pokemon, GetBaseStat), asCALL_THISCALL); + r = engine->RegisterObjectMethod("Pokemon", "uint32 GetBaseStat(Statistic stat) const", asFUNCTION(GetBaseStat), + asCALL_CDECL_OBJFIRST); Ensure(r >= 0); - r = engine->RegisterObjectMethod("Pokemon", "int8 GetStatBoost(Statistic stat) const", - asMETHOD(PkmnLib::Battling::Pokemon, GetStatBoost), asCALL_THISCALL); + r = engine->RegisterObjectMethod("Pokemon", "int8 GetStatBoost(Statistic stat) const", asFUNCTION(GetStatBoost), + asCALL_CDECL_OBJFIRST); Ensure(r >= 0); r = engine->RegisterObjectMethod("Pokemon", "bool HasVolatile(const constString &in name) const", asMETHOD(PkmnLib::Battling::Pokemon, HasVolatileScript), asCALL_THISCALL);