From 0745b063c8510cb11a5b9f630fd227d45cc80e23 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 24 Oct 2021 11:16:29 +0200 Subject: [PATCH] Adds optional max turn parameters to HistoryHolder interface in Angelscript. --- .../Battling/RegisterBattleHistory.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleHistory.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleHistory.cpp index 7972f10..ab53a5f 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleHistory.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Battling/RegisterBattleHistory.cpp @@ -50,19 +50,22 @@ void RegisterBattleHistory::RegisterHistoryElement(asIScriptEngine* engine) { asFunctionPtr(GetAttackWrapper), asCALL_CDECL_OBJFIRST) >= 0); } -OPTIONAL_BORROWED_PTR_GETTER_FUNC(HistoryHolder, const HistoryElement, GetLastUsedAttack); +const HistoryElement* GetLastUsedAttackWrapper(const HistoryHolder* holder, u32 maxTurns) { + return holder->GetLastUsedAttack(maxTurns).GetValue(); +} -const HistoryElement* GetLastDamageOnTargetWrapper(const HistoryHolder* holder, const Creature* c) { - return holder->GetLastDamageOnTarget(c).GetValue(); +const HistoryElement* GetLastDamageOnTargetWrapper(const HistoryHolder* holder, const Creature* c, u32 maxTurns) { + return holder->GetLastDamageOnTarget(c, maxTurns).GetValue(); } void RegisterBattleHistory::RegisterHistoryHolder(asIScriptEngine* engine) { Ensure(engine->RegisterObjectType("BattleHistory", 0, asOBJ_REF | asOBJ_NOCOUNT) >= 0); REGISTER_GETTER("BattleHistory", "const HistoryElement@ get_TopElement() const property", HistoryHolder, GetTopElement); - Ensure(engine->RegisterObjectMethod("BattleHistory", "const AttackUseHistory@ GetLastUsedAttack() const", - asFunctionPtr(GetLastUsedAttackWrapper), asCALL_CDECL_OBJFIRST) >= 0); Ensure(engine->RegisterObjectMethod("BattleHistory", - "const DamageHistory@ GetLastDamageOnTarget(Pokemon@ target) const", - asFunctionPtr(GetLastDamageOnTargetWrapper), asCALL_CDECL_OBJFIRST) >= 0); + "const AttackUseHistory@ GetLastUsedAttack(uint maxTurns = 0) const", + asFunctionPtr(GetLastUsedAttackWrapper), asCALL_CDECL_OBJFIRST) >= 0); + Ensure(engine->RegisterObjectMethod( + "BattleHistory", "const DamageHistory@ GetLastDamageOnTarget(Pokemon@ target, uint maxTurns = 0) const", + asFunctionPtr(GetLastDamageOnTargetWrapper), asCALL_CDECL_OBJFIRST) >= 0); }