summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/class_db.cpp6
-rw-r--r--core/class_db.h14
-rw-r--r--core/command_queue_mt.h24
-rw-r--r--core/hashfuncs.h7
-rw-r--r--core/image.cpp30
-rw-r--r--core/image.h1
-rw-r--r--core/math/a_star.cpp24
-rw-r--r--core/math/a_star.h2
-rw-r--r--core/node_path.cpp37
-rw-r--r--core/node_path.h15
-rw-r--r--core/object.h4
-rw-r--r--core/os/main_loop.cpp1
-rw-r--r--core/os/main_loop.h1
-rw-r--r--core/project_settings.cpp2
-rw-r--r--core/resource.cpp17
-rw-r--r--core/script_language.cpp14
-rw-r--r--core/script_language.h4
-rw-r--r--core/string_db.h6
-rw-r--r--core/undo_redo.cpp16
-rw-r--r--core/undo_redo.h4
-rw-r--r--core/variant_op.cpp13
21 files changed, 172 insertions, 70 deletions
diff --git a/core/class_db.cpp b/core/class_db.cpp
index 59b100e282..f97eaf6099 100644
--- a/core/class_db.cpp
+++ b/core/class_db.cpp
@@ -248,9 +248,9 @@ void ClassDB::set_current_api(APIType p_api) {
current_api = p_api;
}
-HashMap<StringName, ClassDB::ClassInfo, StringNameHasher> ClassDB::classes;
-HashMap<StringName, StringName, StringNameHasher> ClassDB::resource_base_extensions;
-HashMap<StringName, StringName, StringNameHasher> ClassDB::compat_classes;
+HashMap<StringName, ClassDB::ClassInfo> ClassDB::classes;
+HashMap<StringName, StringName> ClassDB::resource_base_extensions;
+HashMap<StringName, StringName> ClassDB::compat_classes;
ClassDB::ClassInfo::ClassInfo() {
diff --git a/core/class_db.h b/core/class_db.h
index 2c77ffe65f..f1d1879236 100644
--- a/core/class_db.h
+++ b/core/class_db.h
@@ -114,10 +114,10 @@ public:
APIType api;
ClassInfo *inherits_ptr;
- HashMap<StringName, MethodBind *, StringNameHasher> method_map;
- HashMap<StringName, int, StringNameHasher> constant_map;
+ HashMap<StringName, MethodBind *> method_map;
+ HashMap<StringName, int> constant_map;
HashMap<StringName, List<StringName> > enum_map;
- HashMap<StringName, MethodInfo, StringNameHasher> signal_map;
+ HashMap<StringName, MethodInfo> signal_map;
List<PropertyInfo> property_list;
#ifdef DEBUG_METHODS_ENABLED
List<StringName> constant_order;
@@ -126,7 +126,7 @@ public:
List<MethodInfo> virtual_methods;
StringName category;
#endif
- HashMap<StringName, PropertySetGet, StringNameHasher> property_setget;
+ HashMap<StringName, PropertySetGet> property_setget;
StringName inherits;
StringName name;
@@ -143,9 +143,9 @@ public:
}
static RWLock *lock;
- static HashMap<StringName, ClassInfo, StringNameHasher> classes;
- static HashMap<StringName, StringName, StringNameHasher> resource_base_extensions;
- static HashMap<StringName, StringName, StringNameHasher> compat_classes;
+ static HashMap<StringName, ClassInfo> classes;
+ static HashMap<StringName, StringName> resource_base_extensions;
+ static HashMap<StringName, StringName> compat_classes;
#ifdef DEBUG_METHODS_ENABLED
static MethodBind *bind_methodfi(uint32_t p_flags, MethodBind *p_bind, const MethodDefinition &method_name, const Variant **p_defs, int p_defcount);
diff --git a/core/command_queue_mt.h b/core/command_queue_mt.h
index 3942b961d3..7978eaa7bf 100644
--- a/core/command_queue_mt.h
+++ b/core/command_queue_mt.h
@@ -54,9 +54,13 @@
#define _COMMA_10 ,
#define _COMMA_11 ,
#define _COMMA_12 ,
+#define _COMMA_13 ,
// 1-based comma separated list of ITEMs
#define COMMA_SEP_LIST(ITEM, LENGTH) _COMMA_SEP_LIST_##LENGTH(ITEM)
+#define _COMMA_SEP_LIST_13(ITEM) \
+ _COMMA_SEP_LIST_12(ITEM) \
+ , ITEM(13)
#define _COMMA_SEP_LIST_12(ITEM) \
_COMMA_SEP_LIST_11(ITEM) \
, ITEM(12)
@@ -97,6 +101,9 @@
// 1-based semicolon separated list of ITEMs
#define SEMIC_SEP_LIST(ITEM, LENGTH) _SEMIC_SEP_LIST_##LENGTH(ITEM)
+#define _SEMIC_SEP_LIST_13(ITEM) \
+ _SEMIC_SEP_LIST_12(ITEM); \
+ ITEM(13)
#define _SEMIC_SEP_LIST_12(ITEM) \
_SEMIC_SEP_LIST_11(ITEM); \
ITEM(12)
@@ -137,6 +144,9 @@
// 1-based space separated list of ITEMs
#define SPACE_SEP_LIST(ITEM, LENGTH) _SPACE_SEP_LIST_##LENGTH(ITEM)
+#define _SPACE_SEP_LIST_13(ITEM) \
+ _SPACE_SEP_LIST_12(ITEM) \
+ ITEM(13)
#define _SPACE_SEP_LIST_12(ITEM) \
_SPACE_SEP_LIST_11(ITEM) \
ITEM(12)
@@ -262,7 +272,7 @@
ss->sem->wait(); \
}
-#define MAX_CMD_PARAMS 12
+#define MAX_CMD_PARAMS 13
class CommandQueueMT {
@@ -290,15 +300,15 @@ class CommandQueueMT {
};
DECL_CMD(0)
- SPACE_SEP_LIST(DECL_CMD, 12)
+ SPACE_SEP_LIST(DECL_CMD, 13)
/* comands that return */
DECL_CMD_RET(0)
- SPACE_SEP_LIST(DECL_CMD_RET, 12)
+ SPACE_SEP_LIST(DECL_CMD_RET, 13)
/* commands that don't return but sync */
DECL_CMD_SYNC(0)
- SPACE_SEP_LIST(DECL_CMD_SYNC, 12)
+ SPACE_SEP_LIST(DECL_CMD_SYNC, 13)
/***** BASE *******/
@@ -432,15 +442,15 @@ class CommandQueueMT {
public:
/* NORMAL PUSH COMMANDS */
DECL_PUSH(0)
- SPACE_SEP_LIST(DECL_PUSH, 12)
+ SPACE_SEP_LIST(DECL_PUSH, 13)
/* PUSH AND RET COMMANDS */
DECL_PUSH_AND_RET(0)
- SPACE_SEP_LIST(DECL_PUSH_AND_RET, 12)
+ SPACE_SEP_LIST(DECL_PUSH_AND_RET, 13)
/* PUSH AND RET SYNC COMMANDS*/
DECL_PUSH_AND_SYNC(0)
- SPACE_SEP_LIST(DECL_PUSH_AND_SYNC, 12)
+ SPACE_SEP_LIST(DECL_PUSH_AND_SYNC, 13)
void wait_and_flush_one() {
ERR_FAIL_COND(!sync);
diff --git a/core/hashfuncs.h b/core/hashfuncs.h
index ae99fa39c8..735e679d1e 100644
--- a/core/hashfuncs.h
+++ b/core/hashfuncs.h
@@ -33,6 +33,8 @@
#include "math_defs.h"
#include "math_funcs.h"
+#include "node_path.h"
+#include "string_db.h"
#include "typedefs.h"
#include "ustring.h"
@@ -131,6 +133,7 @@ static inline uint64_t make_uint64_t(T p_in) {
}
struct HashMapHasherDefault {
+
static _FORCE_INLINE_ uint32_t hash(const String &p_string) { return p_string.hash(); }
static _FORCE_INLINE_ uint32_t hash(const char *p_cstr) { return hash_djb2(p_cstr); }
static _FORCE_INLINE_ uint32_t hash(const uint64_t p_int) { return hash_one_uint64(p_int); }
@@ -145,6 +148,10 @@ struct HashMapHasherDefault {
static _FORCE_INLINE_ uint32_t hash(const uint8_t p_int) { return p_int; }
static _FORCE_INLINE_ uint32_t hash(const int8_t p_int) { return (uint32_t)p_int; }
static _FORCE_INLINE_ uint32_t hash(const wchar_t p_wchar) { return (uint32_t)p_wchar; }
+
+ static _FORCE_INLINE_ uint32_t hash(const StringName &p_string_name) { return p_string_name.hash(); }
+ static _FORCE_INLINE_ uint32_t hash(const NodePath &p_path) { return p_path.hash(); }
+
//static _FORCE_INLINE_ uint32_t hash(const void* p_ptr) { return uint32_t(uint64_t(p_ptr))*(0x9e3779b1L); }
};
diff --git a/core/image.cpp b/core/image.cpp
index c08b1ac39b..b0bed80a6f 100644
--- a/core/image.cpp
+++ b/core/image.cpp
@@ -1076,6 +1076,36 @@ void Image::shrink_x2() {
}
}
+void Image::normalize() {
+
+ bool used_mipmaps = has_mipmaps();
+ if (used_mipmaps) {
+ clear_mipmaps();
+ }
+
+ lock();
+
+ for (int y = 0; y < height; y++) {
+
+ for (int x = 0; x < width; x++) {
+
+ Color c = get_pixel(x, y);
+ Vector3 v(c.r * 2.0 - 1.0, c.g * 2.0 - 1.0, c.b * 2.0 - 1.0);
+ v.normalize();
+ c.r = v.x * 0.5 + 0.5;
+ c.g = v.y * 0.5 + 0.5;
+ c.b = v.z * 0.5 + 0.5;
+ set_pixel(x, y, c);
+ }
+ }
+
+ unlock();
+
+ if (used_mipmaps) {
+ generate_mipmaps(true);
+ }
+}
+
Error Image::generate_mipmaps(bool p_renormalize) {
if (!_can_modify(format)) {
diff --git a/core/image.h b/core/image.h
index e38fa19ded..43516e2c0b 100644
--- a/core/image.h
+++ b/core/image.h
@@ -220,6 +220,7 @@ public:
Error generate_mipmaps(bool p_renormalize = false);
void clear_mipmaps();
+ void normalize(); //for normal maps
/**
* Create a new image of a given size and format. Current image will be lost
diff --git a/core/math/a_star.cpp b/core/math/a_star.cpp
index 6908d7831d..021391da83 100644
--- a/core/math/a_star.cpp
+++ b/core/math/a_star.cpp
@@ -96,11 +96,11 @@ void AStar::remove_point(int p_id) {
Point *p = points[p_id];
- for (int i = 0; i < p->neighbours.size(); i++) {
+ for (Set<Point *>::Element *E = p->neighbours.front(); E; E = E->next()) {
- Segment s(p_id, p->neighbours[i]->id);
+ Segment s(p_id, E->get()->id);
segments.erase(s);
- p->neighbours[i]->neighbours.erase(p);
+ E->get()->neighbours.erase(p);
}
memdelete(p);
@@ -115,10 +115,10 @@ void AStar::connect_points(int p_id, int p_with_id, bool bidirectional) {
Point *a = points[p_id];
Point *b = points[p_with_id];
- a->neighbours.push_back(b);
+ a->neighbours.insert(b);
if (bidirectional)
- b->neighbours.push_back(a);
+ b->neighbours.insert(a);
Segment s(p_id, p_with_id);
if (s.from == p_id) {
@@ -168,8 +168,8 @@ PoolVector<int> AStar::get_point_connections(int p_id) {
Point *p = points[p_id];
- for (int i = 0; i < p->neighbours.size(); i++) {
- point_list.push_back(p->neighbours[i]->id);
+ for (Set<Point *>::Element *E = p->neighbours.front(); E; E = E->next()) {
+ point_list.push_back(E->get()->id);
}
return point_list;
@@ -242,9 +242,9 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
bool found_route = false;
- for (int i = 0; i < begin_point->neighbours.size(); i++) {
+ for (Set<Point *>::Element *E = begin_point->neighbours.front(); E; E = E->next()) {
- Point *n = begin_point->neighbours[i];
+ Point *n = E->get();
n->prev_point = begin_point;
n->distance = _compute_cost(begin_point->id, n->id) * n->weight_scale;
n->last_pass = pass;
@@ -283,12 +283,10 @@ bool AStar::_solve(Point *begin_point, Point *end_point) {
}
Point *p = least_cost_point->self();
- // Open the neighbours for search
- int es = p->neighbours.size();
- for (int i = 0; i < es; i++) {
+ for (Set<Point *>::Element *E = p->neighbours.front(); E; E = E->next()) {
- Point *e = p->neighbours[i];
+ Point *e = E->get();
real_t distance = _compute_cost(p->id, e->id) * e->weight_scale + p->distance;
diff --git a/core/math/a_star.h b/core/math/a_star.h
index f89e17c7bb..8c1b5f64cb 100644
--- a/core/math/a_star.h
+++ b/core/math/a_star.h
@@ -54,7 +54,7 @@ class AStar : public Reference {
real_t weight_scale;
uint64_t last_pass;
- Vector<Point *> neighbours;
+ Set<Point *> neighbours;
// Used for pathfinding
Point *prev_point;
diff --git a/core/node_path.cpp b/core/node_path.cpp
index 64983fc091..487d5ee8c6 100644
--- a/core/node_path.cpp
+++ b/core/node_path.cpp
@@ -32,10 +32,7 @@
#include "print_string.h"
-uint32_t NodePath::hash() const {
-
- if (!data)
- return 0;
+void NodePath::_update_hash_cache() const {
uint32_t h = data->absolute ? 1 : 0;
int pc = data->path.size();
@@ -49,13 +46,15 @@ uint32_t NodePath::hash() const {
h = h ^ ssn[i].hash();
}
- return h;
+ data->hash_cache_valid = true;
+ data->hash_cache = h;
}
void NodePath::prepend_period() {
if (data->path.size() && data->path[0].operator String() != ".") {
data->path.insert(0, ".");
+ data->hash_cache_valid = false;
}
}
@@ -114,21 +113,33 @@ bool NodePath::operator==(const NodePath &p_path) const {
if (data->absolute != p_path.data->absolute)
return false;
- if (data->path.size() != p_path.data->path.size())
+ int path_size = data->path.size();
+
+ if (path_size != p_path.data->path.size()) {
return false;
+ }
+
+ int subpath_size = data->subpath.size();
- if (data->subpath.size() != p_path.data->subpath.size())
+ if (subpath_size != p_path.data->subpath.size()) {
return false;
+ }
- for (int i = 0; i < data->path.size(); i++) {
+ const StringName *l_path_ptr = data->path.ptr();
+ const StringName *r_path_ptr = p_path.data->path.ptr();
+
+ for (int i = 0; i < path_size; i++) {
- if (data->path[i] != p_path.data->path[i])
+ if (l_path_ptr[i] != r_path_ptr[i])
return false;
}
- for (int i = 0; i < data->subpath.size(); i++) {
+ const StringName *l_subpath_ptr = data->subpath.ptr();
+ const StringName *r_subpath_ptr = p_path.data->subpath.ptr();
+
+ for (int i = 0; i < subpath_size; i++) {
- if (data->subpath[i] != p_path.data->subpath[i])
+ if (l_subpath_ptr[i] != r_subpath_ptr[i])
return false;
}
@@ -286,6 +297,7 @@ NodePath::NodePath(const Vector<StringName> &p_path, bool p_absolute) {
data->absolute = p_absolute;
data->path = p_path;
data->has_slashes = true;
+ data->hash_cache_valid = false;
}
NodePath::NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p_subpath, bool p_absolute) {
@@ -301,6 +313,7 @@ NodePath::NodePath(const Vector<StringName> &p_path, const Vector<StringName> &p
data->path = p_path;
data->subpath = p_subpath;
data->has_slashes = true;
+ data->hash_cache_valid = false;
}
void NodePath::simplify() {
@@ -324,6 +337,7 @@ void NodePath::simplify() {
}
}
}
+ data->hash_cache_valid = false;
}
NodePath NodePath::simplified() const {
@@ -396,6 +410,7 @@ NodePath::NodePath(const String &p_path) {
data->absolute = absolute ? true : false;
data->has_slashes = has_slashes;
data->subpath = subpath;
+ data->hash_cache_valid = false;
if (slices == 0)
return;
diff --git a/core/node_path.h b/core/node_path.h
index 288f39721f..71235029af 100644
--- a/core/node_path.h
+++ b/core/node_path.h
@@ -47,11 +47,15 @@ class NodePath {
StringName concatenated_subpath;
bool absolute;
bool has_slashes;
+ mutable bool hash_cache_valid;
+ mutable uint32_t hash_cache;
};
- Data *data;
+ mutable Data *data;
void unref();
+ void _update_hash_cache() const;
+
public:
_FORCE_INLINE_ StringName get_sname() const {
@@ -78,7 +82,14 @@ public:
NodePath get_parent() const;
- uint32_t hash() const;
+ _FORCE_INLINE_ uint32_t hash() const {
+ if (!data)
+ return 0;
+ if (!data->hash_cache_valid) {
+ _update_hash_cache();
+ }
+ return data->hash_cache;
+ }
operator String() const;
bool is_empty() const;
diff --git a/core/object.h b/core/object.h
index 7963a43fd6..8dc3426d1d 100644
--- a/core/object.h
+++ b/core/object.h
@@ -31,6 +31,7 @@
#ifndef OBJECT_H
#define OBJECT_H
+#include "hash_map.h"
#include "list.h"
#include "map.h"
#include "os/rw_lock.h"
@@ -85,6 +86,7 @@ enum PropertyHint {
PROPERTY_HINT_PROPERTY_OF_INSTANCE, ///< a property of an instance
PROPERTY_HINT_PROPERTY_OF_SCRIPT, ///< a property of a script & base
PROPERTY_HINT_OBJECT_TOO_BIG, ///< object is too big to send
+ PROPERTY_HINT_NODE_PATH_VALID_TYPES,
PROPERTY_HINT_MAX,
// When updating PropertyHint, also sync the hardcoded list in VisualScriptEditorVariableEdit
};
@@ -450,7 +452,7 @@ private:
Signal() { lock = 0; }
};
- HashMap<StringName, Signal, StringNameHasher> signal_map;
+ HashMap<StringName, Signal> signal_map;
List<Connection> connections;
#ifdef DEBUG_ENABLED
SafeRefCount _lock_index;
diff --git a/core/os/main_loop.cpp b/core/os/main_loop.cpp
index 916c86613e..c51801e3e2 100644
--- a/core/os/main_loop.cpp
+++ b/core/os/main_loop.cpp
@@ -58,6 +58,7 @@ void MainLoop::_bind_methods() {
BIND_CONSTANT(NOTIFICATION_OS_MEMORY_WARNING);
BIND_CONSTANT(NOTIFICATION_TRANSLATION_CHANGED);
BIND_CONSTANT(NOTIFICATION_WM_ABOUT);
+ BIND_CONSTANT(NOTIFICATION_CRASH);
};
void MainLoop::set_init_script(const Ref<Script> &p_init_script) {
diff --git a/core/os/main_loop.h b/core/os/main_loop.h
index 546e4e280c..f96e46141e 100644
--- a/core/os/main_loop.h
+++ b/core/os/main_loop.h
@@ -62,6 +62,7 @@ public:
// fixes this issue.
NOTIFICATION_TRANSLATION_CHANGED = 90,
NOTIFICATION_WM_ABOUT = 91,
+ NOTIFICATION_CRASH = 92,
};
virtual void input_event(const Ref<InputEvent> &p_event);
diff --git a/core/project_settings.cpp b/core/project_settings.cpp
index ac4a4b7d15..a7bfc8895b 100644
--- a/core/project_settings.cpp
+++ b/core/project_settings.cpp
@@ -137,7 +137,7 @@ bool ProjectSettings::_set(const StringName &p_name, const Variant &p_value) {
else {
if (p_name == CoreStringNames::get_singleton()->_custom_features) {
- Vector<String> custom_feature_array = p_value;
+ Vector<String> custom_feature_array = String(p_value).split(",");
for (int i = 0; i < custom_feature_array.size(); i++) {
custom_features.insert(custom_feature_array[i]);
diff --git a/core/resource.cpp b/core/resource.cpp
index 4cca73be5d..87ff4d3c2a 100644
--- a/core/resource.cpp
+++ b/core/resource.cpp
@@ -225,15 +225,20 @@ Ref<Resource> Resource::duplicate(bool p_subresources) const {
if (!(E->get().usage & PROPERTY_USAGE_STORAGE))
continue;
- Variant p = get(E->get().name).duplicate(true);
- if (p.get_type() == Variant::OBJECT && p_subresources) {
+ Variant p = get(E->get().name);
+
+ if ((p.get_type() == Variant::DICTIONARY || p.get_type() == Variant::ARRAY)) {
+ p = p.duplicate(p_subresources); //does not make a long of sense but should work?
+ } else if (p.get_type() == Variant::OBJECT && (p_subresources || (E->get().usage & PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE))) {
RES sr = p;
- if (sr.is_valid())
- p = sr->duplicate(true);
- }
+ if (sr.is_valid()) {
+ r->set(E->get().name, sr->duplicate(p_subresources));
+ }
+ } else {
- r->set(E->get().name, p);
+ r->set(E->get().name, p);
+ }
}
return Ref<Resource>(r);
diff --git a/core/script_language.cpp b/core/script_language.cpp
index 1dab58e29e..acbe3b34db 100644
--- a/core/script_language.cpp
+++ b/core/script_language.cpp
@@ -347,6 +347,20 @@ Variant::Type PlaceHolderScriptInstance::get_property_type(const StringName &p_n
return Variant::NIL;
}
+void PlaceHolderScriptInstance::get_method_list(List<MethodInfo> *p_list) const {
+
+ if (script.is_valid()) {
+ script->get_script_method_list(p_list);
+ }
+}
+bool PlaceHolderScriptInstance::has_method(const StringName &p_method) const {
+
+ if (script.is_valid()) {
+ return script->has_method(p_method);
+ }
+ return false;
+}
+
void PlaceHolderScriptInstance::update(const List<PropertyInfo> &p_properties, const Map<StringName, Variant> &p_values) {
Set<StringName> new_values;
diff --git a/core/script_language.h b/core/script_language.h
index ad66fc5528..e7748f93e2 100644
--- a/core/script_language.h
+++ b/core/script_language.h
@@ -304,8 +304,8 @@ public:
virtual void get_property_list(List<PropertyInfo> *p_properties) const;
virtual Variant::Type get_property_type(const StringName &p_name, bool *r_is_valid = NULL) const;
- virtual void get_method_list(List<MethodInfo> *p_list) const {}
- virtual bool has_method(const StringName &p_method) const { return false; }
+ virtual void get_method_list(List<MethodInfo> *p_list) const;
+ virtual bool has_method(const StringName &p_method) const;
virtual Variant call(const StringName &p_method, VARIANT_ARG_LIST) { return Variant(); }
virtual Variant call(const StringName &p_method, const Variant **p_args, int p_argcount, Variant::CallError &r_error) {
r_error.error = Variant::CallError::CALL_ERROR_INVALID_METHOD;
diff --git a/core/string_db.h b/core/string_db.h
index 01d1ca4033..965385b136 100644
--- a/core/string_db.h
+++ b/core/string_db.h
@@ -31,7 +31,6 @@
#ifndef STRING_DB_H
#define STRING_DB_H
-#include "hash_map.h"
#include "os/mutex.h"
#include "safe_refcount.h"
#include "ustring.h"
@@ -168,11 +167,6 @@ public:
~StringName();
};
-struct StringNameHasher {
-
- static _FORCE_INLINE_ uint32_t hash(const StringName &p_string) { return p_string.hash(); }
-};
-
StringName _scs_create(const char *p_chr);
#endif
diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp
index b3f9dd818d..b9a2fdd0ac 100644
--- a/core/undo_redo.cpp
+++ b/core/undo_redo.cpp
@@ -299,26 +299,30 @@ void UndoRedo::_process_operation_list(List<Operation>::Element *E) {
}
}
-void UndoRedo::redo() {
+bool UndoRedo::redo() {
- ERR_FAIL_COND(action_level > 0);
+ ERR_FAIL_COND_V(action_level > 0, false);
if ((current_action + 1) >= actions.size())
- return; //nothing to redo
+ return false; //nothing to redo
current_action++;
_process_operation_list(actions[current_action].do_ops.front());
version++;
+
+ return true;
}
-void UndoRedo::undo() {
+bool UndoRedo::undo() {
- ERR_FAIL_COND(action_level > 0);
+ ERR_FAIL_COND_V(action_level > 0, false);
if (current_action < 0)
- return; //nothing to redo
+ return false; //nothing to redo
_process_operation_list(actions[current_action].undo_ops.front());
current_action--;
version--;
+
+ return true;
}
void UndoRedo::clear_history() {
diff --git a/core/undo_redo.h b/core/undo_redo.h
index a373296b73..3a17c78851 100644
--- a/core/undo_redo.h
+++ b/core/undo_redo.h
@@ -109,8 +109,8 @@ public:
void commit_action();
- void redo();
- void undo();
+ bool redo();
+ bool undo();
String get_current_action_name() const;
void clear_history();
diff --git a/core/variant_op.cpp b/core/variant_op.cpp
index 621af2dfb7..bfa69b1fde 100644
--- a/core/variant_op.cpp
+++ b/core/variant_op.cpp
@@ -3417,8 +3417,17 @@ Variant Variant::iter_get(const Variant &r_iter, bool &r_valid) const {
Variant Variant::duplicate(bool deep) const {
switch (type) {
- // case OBJECT:
- // return operator Object *()->duplicate();
+ case OBJECT: {
+ /* breaks stuff :(
+ if (deep && !_get_obj().ref.is_null()) {
+ Ref<Resource> resource = _get_obj().ref;
+ if (resource.is_valid()) {
+ return resource->duplicate(true);
+ }
+ }
+ */
+ return *this;
+ } break;
case DICTIONARY:
return operator Dictionary().duplicate(deep);
case ARRAY: