diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/main.cpp | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/main/main.cpp b/main/main.cpp index 3765f91acc..1efe3ccd94 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -50,7 +50,6 @@ #include "core/register_core_types.h" #include "core/string/translation.h" #include "core/version.h" -#include "core/version_hash.gen.h" #include "drivers/register_driver_types.h" #include "main/app_icon.gen.h" #include "main/main_timer_sync.h" @@ -200,7 +199,7 @@ static String unescape_cmdline(const String &p_str) { static String get_full_version_string() { String hash = String(VERSION_HASH); - if (hash.length() != 0) { + if (!hash.is_empty()) { hash = "." + hash.left(9); } return String(VERSION_FULL_BUILD) + hash; @@ -2250,9 +2249,8 @@ bool Main::start() { } } - if (main_loop->is_class("SceneTree")) { - SceneTree *sml = Object::cast_to<SceneTree>(main_loop); - + SceneTree *sml = Object::cast_to<SceneTree>(main_loop); + if (sml) { #ifdef DEBUG_ENABLED if (debug_collisions) { sml->set_debug_collisions_hint(true); @@ -2294,20 +2292,18 @@ bool Main::start() { RES res = ResourceLoader::load(info.path); ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + info.path); Node *n = nullptr; - if (res->is_class("PackedScene")) { - Ref<PackedScene> ps = res; - n = ps->instantiate(); - } else if (res->is_class("Script")) { - Ref<Script> script_res = res; + Ref<PackedScene> scn = res; + Ref<Script> script_res = res; + if (scn.is_valid()) { + n = scn->instantiate(); + } else if (script_res.is_valid()) { StringName ibt = script_res->get_instance_base_type(); bool valid_type = ClassDB::is_parent_class(ibt, "Node"); ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + info.path); Object *obj = ClassDB::instantiate(ibt); - ERR_CONTINUE_MSG(obj == nullptr, - "Cannot instance script for autoload, expected 'Node' inheritance, got: " + - String(ibt)); + ERR_CONTINUE_MSG(!obj, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt) + "."); n = Object::cast_to<Node>(obj); n->set_script(script_res); |