summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/bind/core_bind.cpp8
-rw-r--r--core/image.cpp10
-rw-r--r--core/io/file_access_pack.cpp2
-rw-r--r--core/io/marshalls.cpp6
-rw-r--r--core/io/resource_format_binary.cpp18
-rw-r--r--core/io/stream_peer.cpp4
-rw-r--r--core/math/triangle_mesh.cpp4
-rw-r--r--core/pool_vector.h4
-rw-r--r--core/project_settings.cpp28
-rw-r--r--core/reference.cpp4
-rw-r--r--core/variant.cpp3
-rw-r--r--core/variant_call.cpp4
12 files changed, 52 insertions, 43 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp
index 1bf3425d50..34bbdb2c75 100644
--- a/core/bind/core_bind.cpp
+++ b/core/bind/core_bind.cpp
@@ -1932,13 +1932,15 @@ PoolVector<uint8_t> _File::get_buffer(int p_length) const {
ERR_FAIL_COND_V(p_length < 0, data);
if (p_length == 0)
return data;
+
Error err = data.resize(p_length);
ERR_FAIL_COND_V(err != OK, data);
+
PoolVector<uint8_t>::Write w = data.write();
int len = f->get_buffer(&w[0], p_length);
ERR_FAIL_COND_V(len < 0, PoolVector<uint8_t>());
- w = PoolVector<uint8_t>::Write();
+ w.release();
if (len < p_length)
data.resize(p_length);
@@ -2113,11 +2115,11 @@ void _File::store_var(const Variant &p_var, bool p_full_objects) {
PoolVector<uint8_t> buff;
buff.resize(len);
- PoolVector<uint8_t>::Write w = buff.write();
+ PoolVector<uint8_t>::Write w = buff.write();
err = encode_variant(p_var, &w[0], len, p_full_objects);
ERR_FAIL_COND(err != OK);
- w = PoolVector<uint8_t>::Write();
+ w.release();
store_32(len);
store_buffer(buff);
diff --git a/core/image.cpp b/core/image.cpp
index 18a3aae88f..a88395204a 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -495,8 +495,8 @@ void Image::convert(Format p_new_format) {
case FORMAT_RGBA8 | (FORMAT_RGB8 << 8): _convert<3, true, 3, false, false, false>(width, height, rptr, wptr); break;
}
- r = PoolVector<uint8_t>::Read();
- w = PoolVector<uint8_t>::Write();
+ r.release();
+ w.release();
bool gen_mipmaps = mipmaps;
@@ -1091,8 +1091,8 @@ void Image::resize(int p_width, int p_height, Interpolation p_interpolation) {
} break;
}
- r = PoolVector<uint8_t>::Read();
- w = PoolVector<uint8_t>::Write();
+ r.release();
+ w.release();
if (interpolate_mipmaps) {
dst._copy_internals_from(dst2);
@@ -2394,7 +2394,7 @@ void Image::lock() {
void Image::unlock() {
- write_lock = PoolVector<uint8_t>::Write();
+ write_lock.release();
}
Color Image::get_pixelv(const Point2 &p_src) const {
diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp
index d38d09c6bb..ca66b34e17 100644
--- a/core/io/file_access_pack.cpp
+++ b/core/io/file_access_pack.cpp
@@ -144,7 +144,7 @@ bool PackedSourcePCK::try_open_pack(const String &p_path) {
uint32_t magic = f->get_32();
if (magic != 0x43504447) {
- //maybe at he end.... self contained exe
+ //maybe at the end.... self contained exe
f->seek_end();
f->seek(f->get_position() - 4);
magic = f->get_32();
diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp
index 17a3f52a65..dc5581ea01 100644
--- a/core/io/marshalls.cpp
+++ b/core/io/marshalls.cpp
@@ -558,8 +558,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
w[i] = buf[i];
}
-
- w = PoolVector<uint8_t>::Write();
}
r_variant = data;
@@ -590,8 +588,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
w[i] = decode_uint32(&buf[i * 4]);
}
-
- w = PoolVector<int>::Write();
}
r_variant = Variant(data);
if (r_len) {
@@ -618,8 +614,6 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int
w[i] = decode_float(&buf[i * 4]);
}
-
- w = PoolVector<float>::Write();
}
r_variant = data;
diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp
index 688dfc21e5..861e34e415 100644
--- a/core/io/resource_format_binary.cpp
+++ b/core/io/resource_format_binary.cpp
@@ -410,7 +410,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
PoolVector<uint8_t>::Write w = array.write();
f->get_buffer(w.ptr(), len);
_advance_padding(len);
- w = PoolVector<uint8_t>::Write();
+ w.release();
r_v = array;
} break;
@@ -432,7 +432,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
}
#endif
- w = PoolVector<int>::Write();
+ w.release();
r_v = array;
} break;
case VARIANT_REAL_ARRAY: {
@@ -454,7 +454,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
#endif
- w = PoolVector<real_t>::Write();
+ w.release();
r_v = array;
} break;
case VARIANT_STRING_ARRAY: {
@@ -465,7 +465,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
PoolVector<String>::Write w = array.write();
for (uint32_t i = 0; i < len; i++)
w[i] = get_unicode_string();
- w = PoolVector<String>::Write();
+ w.release();
r_v = array;
} break;
@@ -493,7 +493,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
ERR_EXPLAIN("Vector2 size is NOT 8!");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- w = PoolVector<Vector2>::Write();
+ w.release();
r_v = array;
} break;
@@ -521,7 +521,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
ERR_EXPLAIN("Vector3 size is NOT 12!");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- w = PoolVector<Vector3>::Write();
+ w.release();
r_v = array;
} break;
@@ -549,7 +549,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
ERR_EXPLAIN("Color size is NOT 16!");
ERR_FAIL_V(ERR_UNAVAILABLE);
}
- w = PoolVector<Color>::Write();
+ w.release();
r_v = array;
} break;
#ifndef DISABLE_DEPRECATED
@@ -584,7 +584,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
PoolVector<uint8_t>::Write w = imgdata.write();
f->get_buffer(w.ptr(), datalen);
_advance_padding(datalen);
- w = PoolVector<uint8_t>::Write();
+ w.release();
Ref<Image> image;
image.instance();
@@ -597,7 +597,7 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant &r_v) {
data.resize(f->get_32());
PoolVector<uint8_t>::Write w = data.write();
f->get_buffer(w.ptr(), data.size());
- w = PoolVector<uint8_t>::Write();
+ w.release();
Ref<Image> image;
diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp
index 6ad24a5f3a..acf72dbba5 100644
--- a/core/io/stream_peer.cpp
+++ b/core/io/stream_peer.cpp
@@ -79,7 +79,7 @@ Array StreamPeer::_get_data(int p_bytes) {
PoolVector<uint8_t>::Write w = data.write();
Error err = get_data(&w[0], p_bytes);
- w = PoolVector<uint8_t>::Write();
+ w.release();
ret.push_back(err);
ret.push_back(data);
return ret;
@@ -101,7 +101,7 @@ Array StreamPeer::_get_partial_data(int p_bytes) {
PoolVector<uint8_t>::Write w = data.write();
int received;
Error err = get_partial_data(&w[0], p_bytes, received);
- w = PoolVector<uint8_t>::Write();
+ w.release();
if (err != OK) {
data.resize(0);
diff --git a/core/math/triangle_mesh.cpp b/core/math/triangle_mesh.cpp
index 83784a1fa7..546981be44 100644
--- a/core/math/triangle_mesh.cpp
+++ b/core/math/triangle_mesh.cpp
@@ -182,7 +182,7 @@ void TriangleMesh::create(const PoolVector<Vector3> &p_faces) {
int max_alloc = fc;
_create_bvh(bw.ptr(), bwp.ptr(), 0, fc, 1, max_depth, max_alloc);
- bw = PoolVector<BVH>::Write(); //clearup
+ bw.release(); //clearup
bvh.resize(max_alloc); //resize back
valid = true;
@@ -751,7 +751,7 @@ PoolVector<Face3> TriangleMesh::get_faces() const {
}
}
- w = PoolVector<Face3>::Write();
+ w.release();
return faces;
}
diff --git a/core/pool_vector.h b/core/pool_vector.h
index 338de966f6..aba66e3909 100644
--- a/core/pool_vector.h
+++ b/core/pool_vector.h
@@ -301,6 +301,10 @@ public:
virtual ~Access() {
_unref();
}
+
+ void release() {
+ _unref();
+ }
};
class Read : public Access {
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index fc1a74801d..3597e2b818 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -83,6 +83,10 @@ String ProjectSettings::localize_path(const String &p_path) const {
// `plus_file("")` is an easy way to ensure we have a trailing '/'.
const String res_path = resource_path.plus_file("");
+ // DirAccess::get_current_dir() is not guaranteed to return a path that with a trailing '/',
+ // so we must make sure we have it as well in order to compare with 'res_path'.
+ cwd = cwd.plus_file("");
+
if (!cwd.begins_with(res_path)) {
return p_path;
};
@@ -343,17 +347,17 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
return err;
}
- // Attempt with exec_name.pck
- // (This is the usual case when distributing a Godot game.)
-
- // Based on the OS, it can be the exec path + '.pck' (Linux w/o extension, macOS in .app bundle)
- // or the exec path's basename + '.pck' (Windows).
- // We need to test both possibilities as extensions for Linux binaries are optional
- // (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
-
String exec_path = OS::get_singleton()->get_executable_path();
if (exec_path != "") {
+ // Attempt with exec_name.pck
+ // (This is the usual case when distributing a Godot game.)
+
+ // Based on the OS, it can be the exec path + '.pck' (Linux w/o extension, macOS in .app bundle)
+ // or the exec path's basename + '.pck' (Windows).
+ // We need to test both possibilities as extensions for Linux binaries are optional
+ // (so both 'mygame.bin' and 'mygame' should be able to find 'mygame.pck').
+
bool found = false;
String exec_dir = exec_path.get_base_dir();
@@ -375,6 +379,14 @@ Error ProjectSettings::_setup(const String &p_path, const String &p_main_pack, b
}
}
+ // Attempt with PCK bundled into executable
+
+ if (!found) {
+ if (_load_resource_pack(exec_path)) {
+ found = true;
+ }
+ }
+
// If we opened our package, try and load our project
if (found) {
Error err = _load_settings_text_or_binary("res://project.godot", "res://project.binary");
diff --git a/core/reference.cpp b/core/reference.cpp
index 7b5145184a..1984af9a34 100644
--- a/core/reference.cpp
+++ b/core/reference.cpp
@@ -70,7 +70,7 @@ bool Reference::reference() {
if (get_script_instance()) {
get_script_instance()->refcount_incremented();
}
- if (instance_binding_count > 0) {
+ if (instance_binding_count > 0 && !ScriptServer::are_languages_finished()) {
for (int i = 0; i < MAX_SCRIPT_INSTANCE_BINDINGS; i++) {
if (_script_instance_bindings[i]) {
ScriptServer::get_language(i)->refcount_incremented_instance_binding(this);
@@ -91,7 +91,7 @@ bool Reference::unreference() {
bool script_ret = get_script_instance()->refcount_decremented();
die = die && script_ret;
}
- if (instance_binding_count > 0) {
+ if (instance_binding_count > 0 && !ScriptServer::are_languages_finished()) {
for (int i = 0; i < MAX_SCRIPT_INSTANCE_BINDINGS; i++) {
if (_script_instance_bindings[i]) {
bool script_ret = ScriptServer::get_language(i)->refcount_decremented_instance_binding(this);
diff --git a/core/variant.cpp b/core/variant.cpp
index 5b51a4e513..fe9623d068 100644
--- a/core/variant.cpp
+++ b/core/variant.cpp
@@ -2418,9 +2418,6 @@ Variant::Variant(const PoolVector<Face3> &p_face_array) {
for (int j = 0; j < 3; j++)
w[i * 3 + j] = r[i].vertex[j];
}
-
- r = PoolVector<Face3>::Read();
- w = PoolVector<Vector3>::Write();
}
type = NIL;
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 4c3cbfa484..3fdd18a630 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -319,7 +319,7 @@ struct _VariantCall {
retval.resize(len);
PoolByteArray::Write w = retval.write();
copymem(w.ptr(), charstr.ptr(), len);
- w = PoolVector<uint8_t>::Write();
+ w.release();
r_ret = retval;
}
@@ -334,7 +334,7 @@ struct _VariantCall {
retval.resize(len);
PoolByteArray::Write w = retval.write();
copymem(w.ptr(), charstr.ptr(), len);
- w = PoolVector<uint8_t>::Write();
+ w.release();
r_ret = retval;
}