2023-01-24 11:27:46 -05:00
|
|
|
#include <Geode/DefaultInclude.hpp>
|
2023-10-02 09:50:10 -04:00
|
|
|
#include <Geode/loader/Mod.hpp>
|
2023-01-24 11:27:46 -05:00
|
|
|
|
2023-03-10 14:33:24 -05:00
|
|
|
using namespace geode::prelude;
|
2023-01-24 11:27:46 -05:00
|
|
|
|
|
|
|
$execute {
|
|
|
|
// this replaces the call to __dynamic_cast with a call to our own
|
|
|
|
// this is needed because the transitions in cocos uses dynamic cast to check
|
|
|
|
// layers, which fail on user layers due to typeinfo not matching
|
|
|
|
|
2023-10-02 09:50:10 -04:00
|
|
|
#if defined(GEODE_IS_MACOS)
|
|
|
|
(void)Mod::get()->patch(
|
|
|
|
reinterpret_cast<void*>(base::get() + 0x603948), toByteArray(&cast::typeinfoCastInternal)
|
|
|
|
);
|
2024-01-15 21:48:24 -05:00
|
|
|
#elif defined(GEODE_IS_ANDROID)
|
|
|
|
void* handle = dlopen("libcocos2dcpp.so", RTLD_LAZY | RTLD_NOLOAD);
|
|
|
|
void* dynamicCastAddr = dlsym(handle, "__dynamic_cast");
|
2023-10-02 09:50:10 -04:00
|
|
|
|
2024-01-16 00:19:54 -05:00
|
|
|
(void)Mod::get()->hook(dynamicCastAddr, &cast::typeinfoCastInternal, "__dynamic_cast");
|
2023-10-02 09:50:10 -04:00
|
|
|
|
2024-01-15 21:48:24 -05:00
|
|
|
dlclose(handle);
|
2023-10-02 09:50:10 -04:00
|
|
|
#endif
|
2024-01-14 16:47:02 -05:00
|
|
|
}
|