From 4ff33d09851e9e0e8c0230904b12ad918c8bf40a Mon Sep 17 00:00:00 2001
From: camila314 <47485054+camila314@users.noreply.github.com>
Date: Fri, 18 Nov 2022 23:15:01 -0600
Subject: [PATCH] fix bad impl

---
 loader/include/Geode/utils/cocos.hpp | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/loader/include/Geode/utils/cocos.hpp b/loader/include/Geode/utils/cocos.hpp
index e04f3db8..92965ee1 100644
--- a/loader/include/Geode/utils/cocos.hpp
+++ b/loader/include/Geode/utils/cocos.hpp
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "Ref.hpp"
+#include "casts.hpp"
 
 #include <Geode/DefaultInclude.hpp>
 #include <cocos2d.h>
@@ -179,13 +180,14 @@ namespace geode::cocos {
      */
     template <class Type = cocos2d::CCNode>
     Type* findFirstChildRecursive(cocos2d::CCNode* node, std::function<bool(Type*)> predicate) {
-        if (predicate(node))return node;
+        if (cast::safe_cast<Type*>(node) && predicate(node))
+            return node;
 
         auto children = node->getChildren();
         if (!children) return nullptr;
 
         for (int i = 0; i < children->count(); ++i) {
-            auto newParent = reinterpret_cast<cocos2d::CCNode*>(children->objectAtIndex(i));
+            auto newParent = static_cast<cocos2d::CCNode*>(children->objectAtIndex(i));
             auto child = findFirstChildRecursive(newParent, predicate);
             if (child)
                 return child;