Fix `Camera2D.rotating` not being converted and reversed properly

Godot 3's Camera2D `rotating = true` and `rotating = false` are supposed to be converted and reversed to `ignore_rotation = false` and `ignore_rotation = true` respectively, but this wasn't the case before this PR, as the project converted was failing to properly read the `true` and `false` strings, thus resulting in `ignore_rotation = true` in all cases.

(cherry picked from commit 256b99ca40)
This commit is contained in:
Emmanouil Papadeas 2023-07-10 03:57:10 +03:00 committed by Yuri Sizov
parent 29b4ee3d97
commit 2f32a3454c
1 changed files with 5 additions and 4 deletions

View File

@ -2241,9 +2241,10 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
// rotating = true -> ignore_rotation = false # reversed "rotating" for Camera2D // rotating = true -> ignore_rotation = false # reversed "rotating" for Camera2D
if (contains_function_call(line, "rotating")) { if (contains_function_call(line, "rotating")) {
int start = line.find("rotating"); String function_name = "rotating";
int start = line.find(function_name);
bool foundNextEqual = false; bool foundNextEqual = false;
String line_to_check = line.substr(start + String("rotating").length()); String line_to_check = line.substr(start + function_name.length());
String assigned_value; String assigned_value;
for (int current_index = 0; line_to_check.length() > current_index; current_index++) { for (int current_index = 0; line_to_check.length() > current_index; current_index++) {
char32_t chr = line_to_check.get(current_index); char32_t chr = line_to_check.get(current_index);
@ -2251,14 +2252,14 @@ void ProjectConverter3To4::process_gdscript_line(String &line, const RegExContai
continue; continue;
} else if (chr == '=') { } else if (chr == '=') {
foundNextEqual = true; foundNextEqual = true;
assigned_value = line.right(current_index).strip_edges(); assigned_value = line.substr(start + function_name.length() + current_index + 1).strip_edges();
assigned_value = assigned_value == "true" ? "false" : "true"; assigned_value = assigned_value == "true" ? "false" : "true";
} else { } else {
break; break;
} }
} }
if (foundNextEqual) { if (foundNextEqual) {
line = line.substr(0, start) + "ignore_rotation =" + assigned_value + " # reversed \"rotating\" for Camera2D"; line = line.substr(0, start) + "ignore_rotation = " + assigned_value + " # reversed \"rotating\" for Camera2D";
} }
} }