diff options
Diffstat (limited to 'main')
-rw-r--r-- | main/input_default.cpp | 4 | ||||
-rw-r--r-- | main/input_default.h | 1 | ||||
-rw-r--r-- | main/main.cpp | 68 | ||||
-rw-r--r-- | main/main.h | 4 | ||||
-rw-r--r-- | main/tests/test_gdscript.cpp | 14 | ||||
-rw-r--r-- | main/tests/test_gui.h | 3 | ||||
-rw-r--r-- | main/tests/test_math.cpp | 6 | ||||
-rw-r--r-- | main/tests/test_physics.h | 4 | ||||
-rw-r--r-- | main/tests/test_render.h | 4 | ||||
-rw-r--r-- | main/tests/test_string.cpp | 5 |
10 files changed, 39 insertions, 74 deletions
diff --git a/main/input_default.cpp b/main/input_default.cpp index 5ba98c20e2..60675f1115 100644 --- a/main/input_default.cpp +++ b/main/input_default.cpp @@ -472,6 +472,10 @@ void InputDefault::stop_joy_vibration(int p_device) { joy_vibration[p_device] = vibration; } +void InputDefault::vibrate_handheld(int p_duration_ms) { + OS::get_singleton()->vibrate_handheld(p_duration_ms); +} + void InputDefault::set_gravity(const Vector3 &p_gravity) { _THREAD_SAFE_METHOD_ diff --git a/main/input_default.h b/main/input_default.h index 80ee17656c..4fc4ad6506 100644 --- a/main/input_default.h +++ b/main/input_default.h @@ -226,6 +226,7 @@ public: virtual void start_joy_vibration(int p_device, float p_weak_magnitude, float p_strong_magnitude, float p_duration = 0); virtual void stop_joy_vibration(int p_device); + virtual void vibrate_handheld(int p_duration_ms = 500); void set_main_loop(MainLoop *p_main_loop); void set_mouse_position(const Point2 &p_posf); diff --git a/main/main.cpp b/main/main.cpp index 7e69864e1e..582df4e866 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -30,6 +30,7 @@ #include "main.h" +#include "core/crypto/crypto.h" #include "core/input_map.h" #include "core/io/file_access_network.h" #include "core/io/file_access_pack.h" @@ -37,8 +38,6 @@ #include "core/io/image_loader.h" #include "core/io/ip.h" #include "core/io/resource_loader.h" -#include "core/io/stream_peer_ssl.h" -#include "core/io/stream_peer_tcp.h" #include "core/message_queue.h" #include "core/os/dir_access.h" #include "core/os/os.h" @@ -783,8 +782,10 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph ProjectSettings::get_singleton()->set_custom_property_info("network/limits/debugger_stdout/max_chars_per_second", PropertyInfo(Variant::INT, "network/limits/debugger_stdout/max_chars_per_second", PROPERTY_HINT_RANGE, "0, 4096, 1, or_greater")); GLOBAL_DEF("network/limits/debugger_stdout/max_messages_per_frame", 10); ProjectSettings::get_singleton()->set_custom_property_info("network/limits/debugger_stdout/max_messages_per_frame", PropertyInfo(Variant::INT, "network/limits/debugger_stdout/max_messages_per_frame", PROPERTY_HINT_RANGE, "0, 20, 1, or_greater")); - GLOBAL_DEF("network/limits/debugger_stdout/max_errors_per_frame", 10); - ProjectSettings::get_singleton()->set_custom_property_info("network/limits/debugger_stdout/max_errors_per_frame", PropertyInfo(Variant::INT, "network/limits/debugger_stdout/max_errors_per_frame", PROPERTY_HINT_RANGE, "0, 20, 1, or_greater")); + GLOBAL_DEF("network/limits/debugger_stdout/max_errors_per_second", 100); + ProjectSettings::get_singleton()->set_custom_property_info("network/limits/debugger_stdout/max_errors_per_second", PropertyInfo(Variant::INT, "network/limits/debugger_stdout/max_errors_per_second", PROPERTY_HINT_RANGE, "0, 200, 1, or_greater")); + GLOBAL_DEF("network/limits/debugger_stdout/max_warnings_per_second", 100); + ProjectSettings::get_singleton()->set_custom_property_info("network/limits/debugger_stdout/max_warnings_per_second", PropertyInfo(Variant::INT, "network/limits/debugger_stdout/max_warnings_per_second", PROPERTY_HINT_RANGE, "0, 200, 1, or_greater")); if (debug_mode == "remote") { @@ -814,10 +815,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph String bp = breakpoints[i]; int sp = bp.find_last(":"); - if (sp == -1) { - ERR_EXPLAIN("Invalid breakpoint: '" + bp + "', expected file:line format."); - ERR_CONTINUE(true); - } + ERR_CONTINUE_MSG(sp == -1, "Invalid breakpoint: '" + bp + "', expected file:line format."); script_debugger->insert_breakpoint(bp.substr(sp + 1, bp.length()).to_int(), bp.substr(0, sp)); } @@ -1373,10 +1371,7 @@ bool Main::start() { { DirAccessRef da = DirAccess::open(doc_tool); - if (!da) { - ERR_EXPLAIN("Argument supplied to --doctool must be a base Godot build directory"); - ERR_FAIL_V(false); - } + ERR_FAIL_COND_V_MSG(!da, false, "Argument supplied to --doctool must be a base Godot build directory."); } DocData doc; doc.generate(doc_base); @@ -1460,8 +1455,7 @@ bool Main::start() { } else if (script != "") { Ref<Script> script_res = ResourceLoader::load(script); - ERR_EXPLAIN("Can't load script: " + script); - ERR_FAIL_COND_V(script_res.is_null(), false); + ERR_FAIL_COND_V_MSG(script_res.is_null(), false, "Can't load script: " + script); if (check_only) { return false; @@ -1475,8 +1469,7 @@ bool Main::start() { if (!script_loop) { if (obj) memdelete(obj); - ERR_EXPLAIN("Can't load script '" + script + "', it does not inherit from a MainLoop type"); - ERR_FAIL_V(false); + ERR_FAIL_V_MSG(false, "Can't load script '" + script + "', it does not inherit from a MainLoop type."); } script_loop->set_init_script(script_res); @@ -1500,17 +1493,13 @@ bool Main::start() { } else { Object *ml = ClassDB::instance(main_loop_type); - if (!ml) { - ERR_EXPLAIN("Can't instance MainLoop type"); - ERR_FAIL_V(false); - } + ERR_FAIL_COND_V_MSG(!ml, false, "Can't instance MainLoop type."); main_loop = Object::cast_to<MainLoop>(ml); if (!main_loop) { memdelete(ml); - ERR_EXPLAIN("Invalid MainLoop type"); - ERR_FAIL_V(false); + ERR_FAIL_V_MSG(false, "Invalid MainLoop type."); } } } @@ -1573,8 +1562,7 @@ bool Main::start() { } RES res = ResourceLoader::load(path); - ERR_EXPLAIN("Can't autoload: " + path); - ERR_CONTINUE(res.is_null()); + ERR_CONTINUE_MSG(res.is_null(), "Can't autoload: " + path); Node *n = NULL; if (res->is_class("PackedScene")) { Ref<PackedScene> ps = res; @@ -1583,20 +1571,17 @@ bool Main::start() { Ref<Script> script_res = res; StringName ibt = script_res->get_instance_base_type(); bool valid_type = ClassDB::is_parent_class(ibt, "Node"); - ERR_EXPLAIN("Script does not inherit a Node: " + path); - ERR_CONTINUE(!valid_type); + ERR_CONTINUE_MSG(!valid_type, "Script does not inherit a Node: " + path); Object *obj = ClassDB::instance(ibt); - ERR_EXPLAIN("Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt)); - ERR_CONTINUE(obj == NULL); + ERR_CONTINUE_MSG(obj == NULL, "Cannot instance script for autoload, expected 'Node' inheritance, got: " + String(ibt)); n = Object::cast_to<Node>(obj); n->set_script(script_res.get_ref_ptr()); } - ERR_EXPLAIN("Path in autoload not a node or script: " + path); - ERR_CONTINUE(!n); + ERR_CONTINUE_MSG(!n, "Path in autoload not a node or script: " + path); n->set_name(name); //defer so references are all valid on _ready() @@ -1754,8 +1739,8 @@ bool Main::start() { if (!project_manager && !editor) { // game - // Load SSL Certificates from Project Settings (or builtin) - StreamPeerSSL::load_certs_from_memory(StreamPeerSSL::get_project_cert_array()); + // Load SSL Certificates from Project Settings (or builtin). + Crypto::load_default_certificates(GLOBAL_DEF("network/ssl/certificates", "")); if (game_path != "") { Node *scene = NULL; @@ -1763,8 +1748,7 @@ bool Main::start() { if (scenedata.is_valid()) scene = scenedata->instance(); - ERR_EXPLAIN("Failed loading scene: " + local_game_path); - ERR_FAIL_COND_V(!scene, false); + ERR_FAIL_COND_V_MSG(!scene, false, "Failed loading scene: " + local_game_path); sml->add_current_scene(scene); #ifdef OSX_ENABLED @@ -1808,17 +1792,15 @@ bool Main::start() { } if (project_manager || editor) { - // Load SSL Certificates from Editor Settings (or builtin) - String certs = EditorSettings::get_singleton()->get_setting("network/ssl/editor_ssl_certificates").operator String(); - if (certs != "") - StreamPeerSSL::load_certs_from_file(certs); - else - StreamPeerSSL::load_certs_from_memory(StreamPeerSSL::get_project_cert_array()); - - // Hide console window if requested (Windows-only) + // Hide console window if requested (Windows-only). bool hide_console = EditorSettings::get_singleton()->get_setting("interface/editor/hide_console_window"); OS::get_singleton()->set_console_visible(!hide_console); } + + if (project_manager || editor) { + // Load SSL Certificates from Editor Settings (or builtin) + Crypto::load_default_certificates(EditorSettings::get_singleton()->get_setting("network/ssl/editor_ssl_certificates").operator String()); + } #endif } @@ -1852,7 +1834,7 @@ bool Main::is_iterating() { return iterating > 0; } -// For performance metrics +// For performance metrics. static uint64_t physics_process_max = 0; static uint64_t idle_process_max = 0; diff --git a/main/main.h b/main/main.h index 694305526a..b0b90dc0fe 100644 --- a/main/main.h +++ b/main/main.h @@ -31,10 +31,6 @@ #ifndef MAIN_H #define MAIN_H -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - #include "core/error_list.h" #include "core/os/thread.h" #include "core/typedefs.h" diff --git a/main/tests/test_gdscript.cpp b/main/tests/test_gdscript.cpp index e82af93293..b2b2c22bf9 100644 --- a/main/tests/test_gdscript.cpp +++ b/main/tests/test_gdscript.cpp @@ -300,14 +300,11 @@ static String _parser_expr(const GDScriptParser::Node *p_expr) { } break; default: { - String error = "Parser bug at " + itos(p_expr->line) + ", invalid expression type: " + itos(p_expr->type); - ERR_EXPLAIN(error); - ERR_FAIL_V(""); + ERR_FAIL_V_MSG("", "Parser bug at " + itos(p_expr->line) + ", invalid expression type: " + itos(p_expr->type)); } } return txt; - //return "("+txt+")"; } static void _parser_show_block(const GDScriptParser::BlockNode *p_block, int p_indent) { @@ -910,8 +907,7 @@ static void _disassemble_class(const Ref<GDScript> &p_class, const Vector<String if (incr == 0) { - ERR_EXPLAIN("unhandled opcode: " + itos(code[ip])); - ERR_BREAK(true); + ERR_BREAK_MSG(true, "Unhandled opcode: " + itos(code[ip])); } ip += incr; @@ -936,11 +932,7 @@ MainLoop *test(TestType p_type) { } FileAccess *fa = FileAccess::open(test, FileAccess::READ); - - if (!fa) { - ERR_EXPLAIN("Could not open file: " + test); - ERR_FAIL_V(NULL); - } + ERR_FAIL_COND_V_MSG(!fa, NULL, "Could not open file: " + test); Vector<uint8_t> buf; int flen = fa->get_len(); diff --git a/main/tests/test_gui.h b/main/tests/test_gui.h index 1752818981..075bc40aa7 100644 --- a/main/tests/test_gui.h +++ b/main/tests/test_gui.h @@ -33,9 +33,6 @@ #include "core/os/main_loop.h" -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ namespace TestGUI { MainLoop *test(); diff --git a/main/tests/test_math.cpp b/main/tests/test_math.cpp index f341159079..68ecb2b1b2 100644 --- a/main/tests/test_math.cpp +++ b/main/tests/test_math.cpp @@ -494,11 +494,7 @@ MainLoop *test() { } FileAccess *fa = FileAccess::open(test, FileAccess::READ); - - if (!fa) { - ERR_EXPLAIN("Could not open file: " + test); - ERR_FAIL_V(NULL); - } + ERR_FAIL_COND_V_MSG(!fa, NULL, "Could not open file: " + test); Vector<uint8_t> buf; int flen = fa->get_len(); diff --git a/main/tests/test_physics.h b/main/tests/test_physics.h index 699e31f492..a281f669e0 100644 --- a/main/tests/test_physics.h +++ b/main/tests/test_physics.h @@ -31,10 +31,6 @@ #ifndef TEST_PHYSICS_H #define TEST_PHYSICS_H -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - #include "core/os/main_loop.h" namespace TestPhysics { diff --git a/main/tests/test_render.h b/main/tests/test_render.h index 3810760b56..6dda57db5b 100644 --- a/main/tests/test_render.h +++ b/main/tests/test_render.h @@ -31,10 +31,6 @@ #ifndef TEST_RENDER_H #define TEST_RENDER_H -/** - @author Juan Linietsky <reduzio@gmail.com> -*/ - #include "core/os/main_loop.h" namespace TestRender { diff --git a/main/tests/test_string.cpp b/main/tests/test_string.cpp index ab5fb64252..7a41880645 100644 --- a/main/tests/test_string.cpp +++ b/main/tests/test_string.cpp @@ -432,6 +432,10 @@ bool test_26() { OS::get_singleton()->print("\n\nTest 26: RegEx substitution\n"); +#ifndef MODULE_REGEX_ENABLED + OS::get_singleton()->print("\tRegEx module disabled, can't run test."); + return false; +#else String s = "Double all the vowels."; OS::get_singleton()->print("\tString: %ls\n", s.c_str()); @@ -443,6 +447,7 @@ bool test_26() { OS::get_singleton()->print("\tResult: %ls\n", s.c_str()); return (s == "Doouublee aall thee vooweels."); +#endif } struct test_27_data { |