diff options
author | Raul Santos <raulsntos@gmail.com> | 2022-08-06 03:51:00 +0200 |
---|---|---|
committer | Raul Santos <raulsntos@gmail.com> | 2022-08-06 15:56:46 +0200 |
commit | 6b564749111eb418243021c4b67ccdf132bbc724 (patch) | |
tree | 97dbaac4b2d155995927fa9d96ee11113ac0be79 | |
parent | c80540f9a20b45d107b9bed1e749571a83492337 (diff) |
Add conversion for `sync` and `slave` GDScript keywords
-rw-r--r-- | editor/project_converter_3_to_4.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/editor/project_converter_3_to_4.cpp b/editor/project_converter_3_to_4.cpp index 8de8f94f87..fe9c4dfc16 100644 --- a/editor/project_converter_3_to_4.cpp +++ b/editor/project_converter_3_to_4.cpp @@ -2045,6 +2045,8 @@ bool ProjectConverter3To4::test_conversion(const RegExContainer ®_container) valid = valid & test_conversion_single_additional("\n\ntool", "\n\n@tool", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); valid = valid & test_conversion_single_additional("\n\nremote func", "\n\n@rpc(any_peer) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); valid = valid & test_conversion_single_additional("\n\nremotesync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); + valid = valid & test_conversion_single_additional("\n\nsync func", "\n\n@rpc(any_peer, call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); + valid = valid & test_conversion_single_additional("\n\nslave func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); valid = valid & test_conversion_single_additional("\n\npuppet func", "\n\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); valid = valid & test_conversion_single_additional("\n\npuppetsync func", "\n\n@rpc(call_local) func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); valid = valid & test_conversion_single_additional("\n\nmaster func", "\n\nThe master and mastersync rpc behavior is not officially supported anymore. Try using another keyword or making custom logic using get_multiplayer().get_remote_sender_id()\n@rpc func", &ProjectConverter3To4::rename_gdscript_keywords, "gdscript keyword"); @@ -3237,6 +3239,22 @@ void ProjectConverter3To4::rename_gdscript_keywords(String &file_content) { file_content = reg_second.sub(file_content, "@rpc(any_peer, call_local) func", true); } { + RegEx reg_first = RegEx("([\n]+)sync func"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1@rpc(any_peer, call_local) func", true); + RegEx reg_second = RegEx("^sync func"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, "@rpc(any_peer, call_local) func", true); + } + { + RegEx reg_first = RegEx("([\n]+)slave func"); + CRASH_COND(!reg_first.is_valid()); + file_content = reg_first.sub(file_content, "$1@rpc func", true); + RegEx reg_second = RegEx("^slave func"); + CRASH_COND(!reg_second.is_valid()); + file_content = reg_second.sub(file_content, "@rpc func", true); + } + { RegEx reg_first = RegEx("([\n]+)puppet func"); CRASH_COND(!reg_first.is_valid()); file_content = reg_first.sub(file_content, "$1@rpc func", true); @@ -3328,6 +3346,24 @@ Vector<String> ProjectConverter3To4::check_for_rename_gdscript_keywords(Vector<S } old = line; { + RegEx regex = RegEx("^sync func"); + CRASH_COND(!regex.is_valid()); + line = regex.sub(line, "@rpc(any_peer, call_local)) func", true); + } + if (old != line) { + found_things.append(line_formatter(current_line, "sync func", "@rpc(any_peer, call_local)) func", line)); + } + old = line; + { + RegEx regex = RegEx("^slave func"); + CRASH_COND(!regex.is_valid()); + line = regex.sub(line, "@rpc func", true); + } + if (old != line) { + found_things.append(line_formatter(current_line, "slave func", "@rpc func", line)); + } + old = line; + { RegEx regex = RegEx("^puppet func"); CRASH_COND(!regex.is_valid()); line = regex.sub(line, "@rpc func", true); |