From 2396615d4a0664f506054f32fbab11f69d389fa3 Mon Sep 17 00:00:00 2001 From: Deukhoofd Date: Sun, 21 Nov 2021 12:59:11 +0100 Subject: [PATCH] Fixes MoveData::HasFlag using OBJLAST instead of OBJFIRST, causing memory corruption. --- src/ScriptResolving/AngelScript/AngelScriptScript.cpp | 2 +- .../AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp index 91662fe..3a2c4dc 100644 --- a/src/ScriptResolving/AngelScript/AngelScriptScript.cpp +++ b/src/ScriptResolving/AngelScript/AngelScriptScript.cpp @@ -345,7 +345,7 @@ CreatureLib::Battling::BattleScript* AngelScriptScript::Clone(const ArbUt::Optio void AngelScriptScript::OnFaint(CreatureLib::Battling::Creature* creature, CreatureLib::Battling::DamageSource source) { CALL_HOOK(OnFaint, { ctx->SetArgObject(0, (void*)creature); - ctx->SetArgDWord(1, static_cast(source)); + ctx->SetArgDWord(1, (i32)source); }) } void AngelScriptScript::BlockWeather(CreatureLib::Battling::Battle* battle, bool* blockWeather) { diff --git a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp index 0a082a5..bad3402 100644 --- a/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp +++ b/src/ScriptResolving/AngelScript/TypeRegistry/Library/RegisterMoveTypes.cpp @@ -39,7 +39,7 @@ void RegisterMoveTypes::RegisterMoveType(asIScriptEngine* engine) { REGISTER_GETTER("MoveData", "int8 get_Priority() const property", CreatureLib::Library::AttackData, GetPriority); r = engine->RegisterObjectMethod("MoveData", "bool HasFlag(const constString &in flag) const", asFUNCTION(HasFlag), - asCALL_CDECL_OBJLAST); + asCALL_CDECL_OBJFIRST); Ensure(r >= 0); } void RegisterMoveTypes::RegisterMoveLibrary(asIScriptEngine* engine) {