From f236de024d2d707529d18ed5fe44970fdb82eb37 Mon Sep 17 00:00:00 2001 From: thfr Date: Sun, 31 May 2026 22:40:21 +0000 Subject: [PATCH] Fix angelscript segfault in BarbarianAI of recoil-rts. Found by fabien@ who also came up with the fix. see https://github.com/anjo76/angelscript/pull/72 --- games/recoil-rts/Makefile | 1 + ...src_lib_angelscript_source_as_callfunc_cpp | 37 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 games/recoil-rts/patches/patch-AI_Skirmish_BARb_src_lib_angelscript_source_as_callfunc_cpp diff --git a/games/recoil-rts/Makefile b/games/recoil-rts/Makefile index bcd042922b7..2583427749b 100644 --- a/games/recoil-rts/Makefile +++ b/games/recoil-rts/Makefile @@ -10,6 +10,7 @@ COMMENT = real-time strategy game engine for Beyond All Reason V = 2025.06.24 PKGNAME = recoil-rts-${V} +REVISION = 0 DIST_TUPLE += github beyond-all-reason RecoilEngine ${V} . DIST_TUPLE += github mikke89 RmlUi \ diff --git a/games/recoil-rts/patches/patch-AI_Skirmish_BARb_src_lib_angelscript_source_as_callfunc_cpp b/games/recoil-rts/patches/patch-AI_Skirmish_BARb_src_lib_angelscript_source_as_callfunc_cpp new file mode 100644 index 00000000000..bee5617184c --- /dev/null +++ b/games/recoil-rts/patches/patch-AI_Skirmish_BARb_src_lib_angelscript_source_as_callfunc_cpp @@ -0,0 +1,37 @@ +https://github.com/anjo76/angelscript/pull/72 + +Index: AI/Skirmish/BARb/src/lib/angelscript/source/as_callfunc.cpp +--- AI/Skirmish/BARb/src/lib/angelscript/source/as_callfunc.cpp.orig ++++ AI/Skirmish/BARb/src/lib/angelscript/source/as_callfunc.cpp +@@ -675,17 +675,23 @@ int CallSystemFunction(int id, asCContext *context) + // Skip the object pointer + args += AS_PTR_SIZE; + } +- +- // Add the base offset for multiple inheritance ++ if( obj ) ++ { ++ // For composition we need to add the offset and/or dereference the pointer ++ obj = (void*)((char*)obj + sysFunc->compositeOffset); ++ if (sysFunc->isCompositeIndirect) obj = *((void**)obj); ++ ++ // Add the base offset for multiple inheritance + #if (defined(__GNUC__) && (defined(AS_ARM64) || defined(AS_ARM) || defined(AS_MIPS))) || defined(AS_PSVITA) +- // On GNUC + ARM the lsb of the offset is used to indicate a virtual function +- // and the whole offset is thus shifted one bit left to keep the original +- // offset resolution +- // MIPS also work like ARM in this regard +- obj = (void*)(asPWORD(obj) + (sysFunc->baseOffset>>1)); ++ // On GNUC + ARM the lsb of the offset is used to indicate a virtual function ++ // and the whole offset is thus shifted one bit left to keep the original ++ // offset resolution ++ // MIPS also work like ARM in this regard ++ obj = (void*)(asPWORD(obj) + (sysFunc->baseOffset>>1)); + #else +- obj = (void*)(asPWORD(obj) + sysFunc->baseOffset); ++ obj = (void*)(asPWORD(obj) + sysFunc->baseOffset); + #endif ++ } + } + #else // !defined(AS_NO_THISCALL_FUNCTOR_METHOD) +