summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp17
-rw-r--r--core/bind/core_bind.h3
-rw-r--r--core/class_db.cpp7
-rw-r--r--core/engine.cpp4
-rw-r--r--core/io/file_access_pack.cpp14
-rw-r--r--core/io/file_access_pack.h5
-rw-r--r--core/io/marshalls.cpp12
-rw-r--r--core/io/pck_packer.cpp11
-rw-r--r--core/io/resource_loader.cpp5
-rw-r--r--core/object.cpp16
-rw-r--r--core/os/os.cpp6
-rw-r--r--core/os/os.h2
-rw-r--r--core/project_settings.cpp10
-rw-r--r--core/resource.cpp5
-rw-r--r--core/version.h17
15 files changed, 97 insertions, 37 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 3b189be4ab..68650019a2 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -400,6 +400,10 @@ bool _OS::is_window_always_on_top() const {
return OS::get_singleton()->is_window_always_on_top();
}
+bool _OS::is_window_focused() const {
+ return OS::get_singleton()->is_window_focused();
+}
+
void _OS::set_borderless_window(bool p_borderless) {
OS::get_singleton()->set_borderless_window(p_borderless);
}
@@ -1226,6 +1230,7 @@ void _OS::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_window_maximized"), &_OS::is_window_maximized);
ClassDB::bind_method(D_METHOD("set_window_always_on_top", "enabled"), &_OS::set_window_always_on_top);
ClassDB::bind_method(D_METHOD("is_window_always_on_top"), &_OS::is_window_always_on_top);
+ ClassDB::bind_method(D_METHOD("is_window_focused"), &_OS::is_window_focused);
ClassDB::bind_method(D_METHOD("request_attention"), &_OS::request_attention);
ClassDB::bind_method(D_METHOD("get_real_window_size"), &_OS::get_real_window_size);
ClassDB::bind_method(D_METHOD("center_window"), &_OS::center_window);
@@ -3019,6 +3024,16 @@ float _Engine::get_frames_per_second() const {
return Engine::get_singleton()->get_frames_per_second();
}
+uint64_t _Engine::get_physics_frames() const {
+
+ return Engine::get_singleton()->get_physics_frames();
+}
+
+uint64_t _Engine::get_idle_frames() const {
+
+ return Engine::get_singleton()->get_idle_frames();
+}
+
void _Engine::set_time_scale(float p_scale) {
Engine::get_singleton()->set_time_scale(p_scale);
}
@@ -3103,6 +3118,8 @@ void _Engine::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_frames_drawn"), &_Engine::get_frames_drawn);
ClassDB::bind_method(D_METHOD("get_frames_per_second"), &_Engine::get_frames_per_second);
+ ClassDB::bind_method(D_METHOD("get_physics_frames"), &_Engine::get_physics_frames);
+ ClassDB::bind_method(D_METHOD("get_idle_frames"), &_Engine::get_idle_frames);
ClassDB::bind_method(D_METHOD("get_main_loop"), &_Engine::get_main_loop);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 46a5fdb5a4..65f20c375e 100644
--- a/core/bind/core_bind.h
+++ b/core/bind/core_bind.h
@@ -198,6 +198,7 @@ public:
virtual bool is_window_maximized() const;
virtual void set_window_always_on_top(bool p_enabled);
virtual bool is_window_always_on_top() const;
+ virtual bool is_window_focused() const;
virtual void request_attention();
virtual void center_window();
virtual void move_window_to_foreground();
@@ -746,6 +747,8 @@ public:
int get_target_fps() const;
float get_frames_per_second() const;
+ uint64_t get_physics_frames() const;
+ uint64_t get_idle_frames() const;
int get_frames_drawn();
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 3cd04c6573..65f0c6008c 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -389,6 +389,13 @@ uint64_t ClassDB::get_api_hash(APIType p_api) {
while ((k = t->method_map.next(k))) {
+ String name = k->operator String();
+
+ ERR_CONTINUE(name.empty());
+
+ if (name[0] == '_')
+ continue; // Ignore non-virtual methods that start with an underscore
+
snames.push_back(*k);
}
diff --git a/core/engine.cpp b/core/engine.cpp
index e461bfe44a..1772cc7c48 100644
--- a/core/engine.cpp
+++ b/core/engine.cpp
@@ -94,11 +94,7 @@ Dictionary Engine::get_version_info() const {
Dictionary dict;
dict["major"] = VERSION_MAJOR;
dict["minor"] = VERSION_MINOR;
-#ifdef VERSION_PATCH
dict["patch"] = VERSION_PATCH;
-#else
- dict["patch"] = 0;
-#endif
dict["hex"] = VERSION_HEX;
dict["status"] = VERSION_STATUS;
dict["build"] = VERSION_BUILD;
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index bef92b938b..83ce03418a 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -34,8 +34,6 @@
#include <stdio.h>
-#define PACK_VERSION 1
-
Error PackedData::add_pack(const String &p_path, bool p_replace_files) {
for (int i = 0; i < sources.size(); i++) {
@@ -140,16 +138,14 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
if (!f)
return false;
- //printf("try open %ls!\n", p_path.c_str());
-
uint32_t magic = f->get_32();
- if (magic != 0x43504447) {
+ if (magic != PACK_HEADER_MAGIC) {
//maybe at the end.... self contained exe
f->seek_end();
f->seek(f->get_position() - 4);
magic = f->get_32();
- if (magic != 0x43504447) {
+ if (magic != PACK_HEADER_MAGIC) {
f->close();
memdelete(f);
@@ -161,7 +157,7 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
f->seek(f->get_position() - ds - 8);
magic = f->get_32();
- if (magic != 0x43504447) {
+ if (magic != PACK_HEADER_MAGIC) {
f->close();
memdelete(f);
@@ -172,9 +168,9 @@ bool PackedSourcePCK::try_open_pack(const String &p_path, bool p_replace_files)
uint32_t version = f->get_32();
uint32_t ver_major = f->get_32();
uint32_t ver_minor = f->get_32();
- f->get_32(); // ver_rev
+ f->get_32(); // patch number, not used for validation.
- if (version != PACK_VERSION) {
+ if (version != PACK_FORMAT_VERSION) {
f->close();
memdelete(f);
ERR_FAIL_V_MSG(false, "Pack version unsupported: " + itos(version) + ".");
diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h
index 6ced2b2d4d..b6ea9c158f 100644
--- a/core/io/file_access_pack.h
+++ b/core/io/file_access_pack.h
@@ -37,6 +37,11 @@
#include "core/os/file_access.h"
#include "core/print_string.h"
+// Godot's packed file magic header ("GDPC" in ASCII).
+#define PACK_HEADER_MAGIC 0x43504447
+// The current packed file format version number.
+#define PACK_FORMAT_VERSION 1
+
class PackSource;
class PackedData {
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 8c8f65c3a0..e847a9cf0c 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -803,6 +803,18 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo
}
} break;
case Variant::OBJECT: {
+#ifdef DEBUG_ENABLED
+ // Test for potential wrong values sent by the debugger when it breaks.
+ Object *obj = p_variant;
+ if (!obj || !ObjectDB::instance_validate(obj)) {
+ // Object is invalid, send a NULL instead.
+ if (buf) {
+ encode_uint32(Variant::NIL, buf);
+ }
+ r_len += 4;
+ return OK;
+ }
+#endif // DEBUG_ENABLED
if (!p_full_objects) {
flags |= ENCODE_FLAG_OBJECT_AS_ID;
}
diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp
index c317125c28..8bc73103e9 100644
--- a/core/io/pck_packer.cpp
+++ b/core/io/pck_packer.cpp
@@ -30,6 +30,7 @@
#include "pck_packer.h"
+#include "core/io/file_access_pack.h" // PACK_HEADER_MAGIC, PACK_FORMAT_VERSION
#include "core/os/file_access.h"
#include "core/version.h"
@@ -68,11 +69,11 @@ Error PCKPacker::pck_start(const String &p_file, int p_alignment) {
alignment = p_alignment;
- file->store_32(0x43504447); // MAGIC
- file->store_32(1); // # version
- file->store_32(VERSION_MAJOR); // # major
- file->store_32(VERSION_MINOR); // # minor
- file->store_32(0); // # revision
+ file->store_32(PACK_HEADER_MAGIC);
+ file->store_32(PACK_FORMAT_VERSION);
+ file->store_32(VERSION_MAJOR);
+ file->store_32(VERSION_MINOR);
+ file->store_32(VERSION_PATCH);
for (int i = 0; i < 16; i++) {
diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp
index 5d85634895..7471ab4241 100644
--- a/core/io/resource_loader.cpp
+++ b/core/io/resource_loader.cpp
@@ -277,6 +277,11 @@ RES ResourceLoader::_load(const String &p_path, const String &p_original_path, c
ERR_FAIL_COND_V_MSG(found, RES(), "Failed loading resource: " + p_path + ".");
+#ifdef TOOLS_ENABLED
+ FileAccessRef file_check = FileAccess::create(FileAccess::ACCESS_RESOURCES);
+ ERR_FAIL_COND_V_MSG(!file_check->file_exists(p_path), RES(), "Resource file not found: " + p_path + ".");
+#endif
+
ERR_FAIL_V_MSG(RES(), "No loader found for resource: " + p_path + ".");
}
diff --git a/core/object.cpp b/core/object.cpp
index 35ccc38d4e..21666a334c 100644
--- a/core/object.cpp
+++ b/core/object.cpp
@@ -1185,13 +1185,11 @@ Error Object::emit_signal(const StringName &p_name, const Variant **p_args, int
const Connection &c = slot_map.getv(i).conn;
- Object *target;
-#ifdef DEBUG_ENABLED
- target = ObjectDB::get_instance(slot_map.getk(i)._id);
- ERR_CONTINUE(!target);
-#else
- target = c.target;
-#endif
+ Object *target = ObjectDB::get_instance(slot_map.getk(i)._id);
+ if (!target) {
+ // Target might have been deleted during signal callback, this is expected and OK.
+ continue;
+ }
const Variant **args = p_args;
int argc = p_argcount;
@@ -1519,10 +1517,6 @@ void Object::_disconnect(const StringName &p_signal, Object *p_to_object, const
Signal *s = signal_map.getptr(p_signal);
ERR_FAIL_COND_MSG(!s, vformat("Nonexistent signal '%s' in %s.", p_signal, to_string()));
- ERR_FAIL_COND_MSG(s->lock > 0,
- vformat("Attempt to disconnect %s signal '%s' while in emission callback '%s' (in target %s). Use CONNECT_DEFERRED (to be able to safely disconnect) or CONNECT_ONESHOT (for automatic disconnection) as connection flags.",
- to_string(), p_signal, p_to_method, p_to_object->to_string()));
-
Signal::Target target(p_to_object->get_instance_id(), p_to_method);
ERR_FAIL_COND_MSG(!s->slot_map.has(target), "Disconnecting nonexistent signal '" + p_signal + "', slot: " + itos(target._id) + ":" + target.method + ".");
diff --git a/core/os/os.cpp b/core/os/os.cpp
index edb2416b67..81dea159a6 100644
--- a/core/os/os.cpp
+++ b/core/os/os.cpp
@@ -343,6 +343,12 @@ String OS::get_cache_path() const {
return ".";
}
+// Path to macOS .app bundle resources
+String OS::get_bundle_resource_dir() const {
+
+ return ".";
+};
+
// OS specific path for user://
String OS::get_user_data_dir() const {
diff --git a/core/os/os.h b/core/os/os.h
index cdc9536653..714c4e3f09 100644
--- a/core/os/os.h
+++ b/core/os/os.h
@@ -222,6 +222,7 @@ public:
virtual bool is_window_maximized() const { return true; }
virtual void set_window_always_on_top(bool p_enabled) {}
virtual bool is_window_always_on_top() const { return false; }
+ virtual bool is_window_focused() const { return true; }
virtual void set_console_visible(bool p_enabled) {}
virtual bool is_console_visible() const { return false; }
virtual void request_attention() {}
@@ -410,6 +411,7 @@ public:
virtual String get_data_path() const;
virtual String get_config_path() const;
virtual String get_cache_path() const;
+ virtual String get_bundle_resource_dir() const;
virtual String get_user_data_dir() const;
virtual String get_resource_dir() const;
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index a30967dcca..a01a8a35c6 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -383,8 +383,16 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
}
}
- // Attempt with PCK bundled into executable
+#ifdef OSX_ENABLED
+ // Attempt to load PCK from macOS .app bundle resources
+ if (!found) {
+ if (_load_resource_pack(OS::get_singleton()->get_bundle_resource_dir().plus_file(exec_basename + ".pck"))) {
+ found = true;
+ }
+ }
+#endif
+ // Attempt with PCK bundled into executable
if (!found) {
if (_load_resource_pack(exec_path)) {
found = true;
diff --git a/core/resource.cpp b/core/resource.cpp
index 1c9d3f8d49..30e09716aa 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -68,7 +68,10 @@ void Resource::set_path(const String &p_path, bool p_take_over) {
if (p_take_over) {
ResourceCache::lock->write_lock();
- ResourceCache::resources.get(p_path)->set_name("");
+ Resource **res = ResourceCache::resources.getptr(p_path);
+ if (res) {
+ (*res)->set_name("");
+ }
ResourceCache::lock->write_unlock();
} else {
ResourceCache::lock->read_lock();
diff --git a/core/version.h b/core/version.h
index a790152ca4..42c85c1b13 100644
--- a/core/version.h
+++ b/core/version.h
@@ -28,6 +28,9 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
+#ifndef GODOT_VERSION_H
+#define GODOT_VERSION_H
+
#include "core/version_generated.gen.h"
// Godot versions are of the form <major>.<minor> for the initial release,
@@ -38,18 +41,18 @@
// forward-compatible.
// Example: "3.1"
#define VERSION_BRANCH "" _MKSTR(VERSION_MAJOR) "." _MKSTR(VERSION_MINOR)
-#ifdef VERSION_PATCH
+#if VERSION_PATCH
// Example: "3.1.4"
#define VERSION_NUMBER "" VERSION_BRANCH "." _MKSTR(VERSION_PATCH)
+#else // patch is 0, we don't include it in the "pretty" version number.
+// Example: "3.1" instead of "3.1.0"
+#define VERSION_NUMBER "" VERSION_BRANCH
+#endif // VERSION_PATCH
+
// Version number encoded as hexadecimal int with one byte for each number,
// for easy comparison from code.
// Example: 3.1.4 will be 0x030104, making comparison easy from script.
#define VERSION_HEX 0x10000 * VERSION_MAJOR + 0x100 * VERSION_MINOR + VERSION_PATCH
-#else
-// Example: "3.1"
-#define VERSION_NUMBER "" VERSION_BRANCH
-#define VERSION_HEX 0x10000 * VERSION_MAJOR + 0x100 * VERSION_MINOR
-#endif // VERSION_PATCH
// Describes the full configuration of that Godot version, including the version number,
// the status (beta, stable, etc.) and potential module-specific features (e.g. mono).
@@ -64,3 +67,5 @@
// Same as above, but prepended with Godot's name and a cosmetic "v" for "version".
// Example: "Godot v3.1.4.stable.official.mono"
#define VERSION_FULL_NAME "" VERSION_NAME " v" VERSION_FULL_BUILD
+
+#endif // GODOT_VERSION_H