summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp5
-rw-r--r--core/bind/core_bind.h1
-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/pck_packer.cpp11
-rw-r--r--core/os/os.h1
-rw-r--r--core/resource.cpp5
-rw-r--r--core/version.h17
10 files changed, 45 insertions, 25 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 3b189be4ab..0eacffeb88 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);
diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h
index 46a5fdb5a4..7c5031cad4 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();
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/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/os/os.h b/core/os/os.h
index cdc9536653..593ea2b645 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() {}
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