diff options
Diffstat (limited to 'core')
| -rw-r--r-- | core/bind/core_bind.cpp | 6 | ||||
| -rw-r--r-- | core/color.cpp | 109 | ||||
| -rw-r--r-- | core/color.h | 12 | ||||
| -rw-r--r-- | core/io/resource_loader.cpp | 3 | ||||
| -rw-r--r-- | core/object.h | 1 | ||||
| -rw-r--r-- | core/script_debugger_local.cpp | 5 | ||||
| -rw-r--r-- | core/script_debugger_local.h | 1 | ||||
| -rw-r--r-- | core/script_debugger_remote.cpp | 83 | ||||
| -rw-r--r-- | core/script_debugger_remote.h | 1 | ||||
| -rw-r--r-- | core/script_language.h | 4 | ||||
| -rw-r--r-- | core/undo_redo.cpp | 20 | ||||
| -rw-r--r-- | core/undo_redo.h | 4 |
12 files changed, 120 insertions, 129 deletions
diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 2921626f3a..c7b08b8242 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -2466,7 +2466,13 @@ Array _ClassDB::get_method_list(StringName p_class, bool p_no_inheritance) const Array ret; for (List<MethodInfo>::Element *E = methods.front(); E; E = E->next()) { +#ifdef DEBUG_METHODS_ENABLED ret.push_back(E->get().operator Dictionary()); +#else + Dictionary dict; + dict["name"] = E->get().name; + ret.push_back(dict); +#endif } return ret; diff --git a/core/color.cpp b/core/color.cpp index 7278b5c4ee..b708f15d69 100644 --- a/core/color.cpp +++ b/core/color.cpp @@ -396,7 +396,7 @@ String Color::to_html(bool p_alpha) const { txt += _to_hex(g); txt += _to_hex(b); if (p_alpha) - txt = _to_hex(a) + txt; + txt += _to_hex(a); return txt; } @@ -413,96 +413,95 @@ Color::operator String() const { Color Color::operator+(const Color &p_color) const { return Color( - CLAMP(r + p_color.r, 0.0, 1.0), - CLAMP(g + p_color.g, 0.0, 1.0), - CLAMP(b + p_color.b, 0.0, 1.0), - CLAMP(a + p_color.a, 0.0, 1.0)); + r + p_color.r, + g + p_color.g, + b + p_color.b, + a + p_color.a); } void Color::operator+=(const Color &p_color) { - r = CLAMP(r + p_color.r, 0.0, 1.0); - g = CLAMP(g + p_color.g, 0.0, 1.0); - b = CLAMP(b + p_color.b, 0.0, 1.0); - a = CLAMP(a + p_color.a, 0.0, 1.0); + r = r + p_color.r; + g = g + p_color.g; + b = b + p_color.b; + a = a + p_color.a; } Color Color::operator-(const Color &p_color) const { return Color( - CLAMP(r - p_color.r, 0.0, 1.0), - CLAMP(g - p_color.g, 0.0, 1.0), - CLAMP(b - p_color.b, 0.0, 1.0), - CLAMP(a - p_color.a, 0.0, 1.0)); + r - p_color.r, + g - p_color.g, + b - p_color.b, + a - p_color.a); } void Color::operator-=(const Color &p_color) { - r = CLAMP(r - p_color.r, 0.0, 1.0); - g = CLAMP(g - p_color.g, 0.0, 1.0); - b = CLAMP(b - p_color.b, 0.0, 1.0); - a = CLAMP(a - p_color.a, 0.0, 1.0); + r = r - p_color.r; + g = g - p_color.g; + b = b - p_color.b; + a = a - p_color.a; } Color Color::operator*(const Color &p_color) const { return Color( - CLAMP(r * p_color.r, 0.0, 1.0), - CLAMP(g * p_color.g, 0.0, 1.0), - CLAMP(b * p_color.b, 0.0, 1.0), - CLAMP(a * p_color.a, 0.0, 1.0)); + r * p_color.r, + g * p_color.g, + b * p_color.b, + a * p_color.a); } Color Color::operator*(const real_t &rvalue) const { return Color( - CLAMP(r * rvalue, 0.0, 1.0), - CLAMP(g * rvalue, 0.0, 1.0), - CLAMP(b * rvalue, 0.0, 1.0), - CLAMP(a * rvalue, 0.0, 1.0)); + r * rvalue, + g * rvalue, + b * rvalue, + a * rvalue); } void Color::operator*=(const Color &p_color) { - r = CLAMP(r * p_color.r, 0.0, 1.0); - g = CLAMP(g * p_color.g, 0.0, 1.0); - b = CLAMP(b * p_color.b, 0.0, 1.0); - a = CLAMP(a * p_color.a, 0.0, 1.0); + r = r * p_color.r; + g = g * p_color.g; + b = b * p_color.b; + a = a * p_color.a; } void Color::operator*=(const real_t &rvalue) { - r = CLAMP(r * rvalue, 0.0, 1.0); - g = CLAMP(g * rvalue, 0.0, 1.0); - b = CLAMP(b * rvalue, 0.0, 1.0); - a = CLAMP(a * rvalue, 0.0, 1.0); -}; + r = r * rvalue; + g = g * rvalue; + b = b * rvalue; + a = a * rvalue; +} Color Color::operator/(const Color &p_color) const { return Color( - p_color.r == 0 ? 1 : CLAMP(r / p_color.r, 0.0, 1.0), - p_color.g == 0 ? 1 : CLAMP(g / p_color.g, 0.0, 1.0), - p_color.b == 0 ? 1 : CLAMP(b / p_color.b, 0.0, 1.0), - p_color.a == 0 ? 1 : CLAMP(a / p_color.a, 0.0, 1.0)); + r / p_color.r, + g / p_color.g, + b / p_color.b, + a / p_color.a); } Color Color::operator/(const real_t &rvalue) const { - if (rvalue == 0) return Color(1.0, 1.0, 1.0, 1.0); return Color( - CLAMP(r / rvalue, 0.0, 1.0), - CLAMP(g / rvalue, 0.0, 1.0), - CLAMP(b / rvalue, 0.0, 1.0), - CLAMP(a / rvalue, 0.0, 1.0)); + r / rvalue, + g / rvalue, + b / rvalue, + a / rvalue); } void Color::operator/=(const Color &p_color) { - r = p_color.r == 0 ? 1 : CLAMP(r / p_color.r, 0.0, 1.0); - g = p_color.g == 0 ? 1 : CLAMP(g / p_color.g, 0.0, 1.0); - b = p_color.b == 0 ? 1 : CLAMP(b / p_color.b, 0.0, 1.0); - a = p_color.a == 0 ? 1 : CLAMP(a / p_color.a, 0.0, 1.0); + r = r / p_color.r; + g = g / p_color.g; + b = b / p_color.b; + a = a / p_color.a; } void Color::operator/=(const real_t &rvalue) { @@ -513,18 +512,18 @@ void Color::operator/=(const real_t &rvalue) { b = 1.0; a = 1.0; } else { - r = CLAMP(r / rvalue, 0.0, 1.0); - g = CLAMP(g / rvalue, 0.0, 1.0); - b = CLAMP(b / rvalue, 0.0, 1.0); - a = CLAMP(a / rvalue, 0.0, 1.0); + r = r / rvalue; + g = g / rvalue; + b = b / rvalue; + a = a / rvalue; } }; Color Color::operator-() const { return Color( - CLAMP(1.0 - r, 0.0, 1.0), - CLAMP(1.0 - g, 0.0, 1.0), - CLAMP(1.0 - b, 0.0, 1.0), - CLAMP(1.0 - a, 0.0, 1.0)); + 1.0 - r, + 1.0 - g, + 1.0 - b, + 1.0 - a); } diff --git a/core/color.h b/core/color.h index 0ff4fe6edd..9af8fb0a78 100644 --- a/core/color.h +++ b/core/color.h @@ -105,18 +105,18 @@ struct Color { _FORCE_INLINE_ Color darkened(float p_amount) const { Color res = *this; - res.r = CLAMP(res.r * (1.0f - p_amount), 0.0, 1.0); - res.g = CLAMP(res.g * (1.0f - p_amount), 0.0, 1.0); - res.b = CLAMP(res.b * (1.0f - p_amount), 0.0, 1.0); + res.r = res.r * (1.0f - p_amount); + res.g = res.g * (1.0f - p_amount); + res.b = res.b * (1.0f - p_amount); return res; } _FORCE_INLINE_ Color lightened(float p_amount) const { Color res = *this; - res.r = CLAMP(res.r + (1.0f - res.r) * p_amount, 0.0, 1.0); - res.g = CLAMP(res.g + (1.0f - res.g) * p_amount, 0.0, 1.0); - res.b = CLAMP(res.b + (1.0f - res.b) * p_amount, 0.0, 1.0); + res.r = res.r + (1.0f - res.r) * p_amount; + res.g = res.g + (1.0f - res.g) * p_amount; + res.b = res.b + (1.0f - res.b) * p_amount; return res; } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 87add585eb..1351030d1e 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -202,7 +202,8 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p if (OS::get_singleton()->is_stdout_verbose()) print_line("load resource: " + local_path + " (cached)"); - + if (r_error) + *r_error = OK; return RES(ResourceCache::get(local_path)); } diff --git a/core/object.h b/core/object.h index 5de87b8a7d..98ce62551b 100644 --- a/core/object.h +++ b/core/object.h @@ -111,6 +111,7 @@ enum PropertyUsageFlags { PROPERTY_USAGE_CLASS_IS_ENUM = 1 << 18, PROPERTY_USAGE_NIL_IS_VARIANT = 1 << 19, PROPERTY_USAGE_INTERNAL = 1 << 20, + PROPERTY_USAGE_DO_NOT_SHARE_ON_DUPLICATE = 1 << 21, // If the object is duplicated also this property will be duplicated PROPERTY_USAGE_DEFAULT = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK, PROPERTY_USAGE_DEFAULT_INTL = PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_NETWORK | PROPERTY_USAGE_INTERNATIONALIZED, diff --git a/core/script_debugger_local.cpp b/core/script_debugger_local.cpp index 57463a662d..0da377453e 100644 --- a/core/script_debugger_local.cpp +++ b/core/script_debugger_local.cpp @@ -294,6 +294,11 @@ void ScriptDebuggerLocal::send_message(const String &p_message, const Array &p_a print_line("MESSAGE: '" + p_message + "' - " + String(Variant(p_args))); } +void ScriptDebuggerLocal::send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info) { + + print_line("ERROR: '" + (p_descr.empty() ? p_err : p_descr) + "'"); +} + ScriptDebuggerLocal::ScriptDebuggerLocal() { profiling = false; diff --git a/core/script_debugger_local.h b/core/script_debugger_local.h index c93120331d..c87bc90bb4 100644 --- a/core/script_debugger_local.h +++ b/core/script_debugger_local.h @@ -44,6 +44,7 @@ class ScriptDebuggerLocal : public ScriptDebugger { public: void debug(ScriptLanguage *p_script, bool p_can_continue); virtual void send_message(const String &p_message, const Array &p_args); + virtual void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info); virtual bool is_profiling() const { return profiling; } virtual void add_profiling_frame_data(const StringName &p_name, const Array &p_data) {} diff --git a/core/script_debugger_remote.cpp b/core/script_debugger_remote.cpp index e3dc8eb53a..a297bb738f 100644 --- a/core/script_debugger_remote.cpp +++ b/core/script_debugger_remote.cpp @@ -432,22 +432,6 @@ void ScriptDebuggerRemote::_err_handler(void *ud, const char *p_func, const char if (p_type == ERR_HANDLER_SCRIPT) return; //ignore script errors, those go through debugger - ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)ud; - - OutputError oe; - oe.error = p_err; - oe.error_descr = p_descr; - oe.source_file = p_file; - oe.source_line = p_line; - oe.source_func = p_func; - oe.warning = p_type == ERR_HANDLER_WARNING; - uint64_t time = OS::get_singleton()->get_ticks_msec(); - oe.hr = time / 3600000; - oe.min = (time / 60000) % 60; - oe.sec = (time / 1000) % 60; - oe.msec = time % 1000; - Array cstack; - Vector<ScriptLanguage::StackInfo> si; for (int i = 0; i < ScriptServer::get_language_count(); i++) { @@ -456,32 +440,8 @@ void ScriptDebuggerRemote::_err_handler(void *ud, const char *p_func, const char break; } - cstack.resize(si.size() * 2); - for (int i = 0; i < si.size(); i++) { - String path; - int line = 0; - if (si[i].script.is_valid()) { - path = si[i].script->get_path(); - line = si[i].line; - } - cstack[i * 2 + 0] = path; - cstack[i * 2 + 1] = line; - } - - oe.callstack = cstack; - - sdr->mutex->lock(); - - if (!sdr->locking && sdr->tcp_client->is_connected_to_host()) { - - if (sdr->errors.size() >= sdr->max_errors_per_frame) { - sdr->n_errors_dropped++; - } else { - sdr->errors.push_back(oe); - } - } - - sdr->mutex->unlock(); + ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)ud; + sdr->send_error(p_func, p_file, p_line, p_err, p_descr, p_type, si); } bool ScriptDebuggerRemote::_parse_live_edit(const Array &p_command) { @@ -928,6 +888,45 @@ void ScriptDebuggerRemote::send_message(const String &p_message, const Array &p_ mutex->unlock(); } +void ScriptDebuggerRemote::send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info) { + + OutputError oe; + oe.error = p_err; + oe.error_descr = p_descr; + oe.source_file = p_file; + oe.source_line = p_line; + oe.source_func = p_func; + oe.warning = p_type == ERR_HANDLER_WARNING; + uint64_t time = OS::get_singleton()->get_ticks_msec(); + oe.hr = time / 3600000; + oe.min = (time / 60000) % 60; + oe.sec = (time / 1000) % 60; + oe.msec = time % 1000; + Array cstack; + + cstack.resize(p_stack_info.size() * 3); + for (int i = 0; i < p_stack_info.size(); i++) { + cstack[i * 3 + 0] = p_stack_info[i].file; + cstack[i * 3 + 1] = p_stack_info[i].func; + cstack[i * 3 + 2] = p_stack_info[i].line; + } + + oe.callstack = cstack; + + mutex->lock(); + + if (!locking && tcp_client->is_connected_to_host()) { + + if (errors.size() >= max_errors_per_frame) { + n_errors_dropped++; + } else { + errors.push_back(oe); + } + } + + mutex->unlock(); +} + void ScriptDebuggerRemote::_print_handler(void *p_this, const String &p_string, bool p_error) { ScriptDebuggerRemote *sdr = (ScriptDebuggerRemote *)p_this; diff --git a/core/script_debugger_remote.h b/core/script_debugger_remote.h index 924d5de2c4..2c4e29f172 100644 --- a/core/script_debugger_remote.h +++ b/core/script_debugger_remote.h @@ -157,6 +157,7 @@ public: virtual void request_quit(); virtual void send_message(const String &p_message, const Array &p_args); + virtual void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info); virtual void set_request_scene_tree_message_func(RequestSceneTreeMessageFunc p_func, void *p_udata); virtual void set_live_edit_funcs(LiveEditFuncs *p_funcs); diff --git a/core/script_language.h b/core/script_language.h index 6bf2129f9b..66614a293c 100644 --- a/core/script_language.h +++ b/core/script_language.h @@ -254,7 +254,8 @@ public: virtual String debug_parse_stack_level_expression(int p_level, const String &p_expression, int p_max_subitems = -1, int p_max_depth = -1) = 0; struct StackInfo { - Ref<Script> script; + String file; + String func; int line; }; @@ -391,6 +392,7 @@ public: ScriptLanguage *get_break_language() const; virtual void send_message(const String &p_message, const Array &p_args) = 0; + virtual void send_error(const String &p_func, const String &p_file, int p_line, const String &p_err, const String &p_descr, ErrorHandlerType p_type, const Vector<ScriptLanguage::StackInfo> &p_stack_info) = 0; virtual bool is_remote() const { return false; } virtual void request_quit() {} diff --git a/core/undo_redo.cpp b/core/undo_redo.cpp index a105fba290..b3f9dd818d 100644 --- a/core/undo_redo.cpp +++ b/core/undo_redo.cpp @@ -246,13 +246,6 @@ void UndoRedo::commit_action() { redo(); // perform action - if (max_steps > 0 && actions.size() > max_steps) { - //clear early steps - - while (actions.size() > max_steps) - _pop_history_tail(); - } - if (callback && actions.size() > 0) { callback(callback_ud, actions[actions.size() - 1].name); } @@ -347,16 +340,6 @@ String UndoRedo::get_current_action_name() const { return actions[current_action].name; } -void UndoRedo::set_max_steps(int p_max_steps) { - - max_steps = p_max_steps; -} - -int UndoRedo::get_max_steps() const { - - return max_steps; -} - uint64_t UndoRedo::get_version() const { return version; @@ -385,7 +368,6 @@ UndoRedo::UndoRedo() { version = 1; action_level = 0; current_action = -1; - max_steps = -1; merge_mode = MERGE_DISABLE; callback = NULL; callback_ud = NULL; @@ -510,8 +492,6 @@ void UndoRedo::_bind_methods() { ClassDB::bind_method(D_METHOD("clear_history"), &UndoRedo::clear_history); ClassDB::bind_method(D_METHOD("get_current_action_name"), &UndoRedo::get_current_action_name); ClassDB::bind_method(D_METHOD("get_version"), &UndoRedo::get_version); - ClassDB::bind_method(D_METHOD("set_max_steps", "max_steps"), &UndoRedo::set_max_steps); - ClassDB::bind_method(D_METHOD("get_max_steps"), &UndoRedo::get_max_steps); ClassDB::bind_method(D_METHOD("redo"), &UndoRedo::redo); ClassDB::bind_method(D_METHOD("undo"), &UndoRedo::undo); diff --git a/core/undo_redo.h b/core/undo_redo.h index 5d7ab782d6..a373296b73 100644 --- a/core/undo_redo.h +++ b/core/undo_redo.h @@ -79,7 +79,6 @@ private: Vector<Action> actions; int current_action; int action_level; - int max_steps; MergeMode merge_mode; uint64_t version; @@ -115,9 +114,6 @@ public: String get_current_action_name() const; void clear_history(); - void set_max_steps(int p_max_steps); - int get_max_steps() const; - uint64_t get_version() const; void set_commit_notify_callback(CommitNotifyCallback p_callback, void *p_ud); |