Skip to content

Commit

Permalink
Merge pull request #58681 from akien-mga/3.x-cherrypicks
Browse files Browse the repository at this point in the history
  • Loading branch information
akien-mga authored Mar 2, 2022
2 parents a58ae4c + c63ab66 commit cf970aa
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 156 deletions.
12 changes: 5 additions & 7 deletions core/io/pck_packer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,13 +154,11 @@ Error PCKPacker::flush(bool p_verbose) {
src->close();
memdelete(src);
count += 1;
if (p_verbose && files.size() > 0) {
if (count % 100 == 0) {
printf("%i/%i (%.2f)\r", count, files.size(), float(count) / files.size() * 100);
fflush(stdout);
};
};
};
const int file_num = files.size();
if (p_verbose && (file_num > 0)) {
print_line(vformat("[%d/%d - %d%%] PCKPacker flush: %s -> %s", count, file_num, float(count) / file_num * 100, files[i].src_path, files[i].path));
}
}

if (p_verbose) {
printf("\n");
Expand Down
45 changes: 17 additions & 28 deletions core/undo_redo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,28 @@
#include "core/os/os.h"
#include "core/resource.h"

void UndoRedo::Operation::delete_reference() {
if (type != Operation::TYPE_REFERENCE) {
return;
}
if (ref.is_valid()) {
ref.unref();
} else {
Object *obj = ObjectDB::get_instance(object);
if (obj) {
memdelete(obj);
}
}
}

void UndoRedo::_discard_redo() {
if (current_action == actions.size() - 1) {
return;
}

for (int i = current_action + 1; i < actions.size(); i++) {
for (List<Operation>::Element *E = actions.write[i].do_ops.front(); E; E = E->next()) {
if (E->get().type == Operation::TYPE_REFERENCE) {
if (E->get().ref.is_valid()) {
E->get().ref.unref();
} else {
Object *obj = ObjectDB::get_instance(E->get().object);
if (obj) {
memdelete(obj);
}
}
}
E->get().delete_reference();
}
//ERASE do data
}
Expand All @@ -72,14 +77,7 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode) {
List<Operation>::Element *E = actions.write[current_action + 1].do_ops.front();

while (E) {
if (E->get().type == Operation::TYPE_REFERENCE) {
Object *obj = ObjectDB::get_instance(E->get().object);

if (obj) {
memdelete(obj);
}
}

E->get().delete_reference();
E = E->next();
actions.write[current_action + 1].do_ops.pop_front();
}
Expand Down Expand Up @@ -224,16 +222,7 @@ void UndoRedo::_pop_history_tail() {
}

for (List<Operation>::Element *E = actions.write[0].undo_ops.front(); E; E = E->next()) {
if (E->get().type == Operation::TYPE_REFERENCE) {
if (E->get().ref.is_valid()) {
E->get().ref.unref();
} else {
Object *obj = ObjectDB::get_instance(E->get().object);
if (obj) {
memdelete(obj);
}
}
}
E->get().delete_reference();
}

actions.remove(0);
Expand Down
2 changes: 2 additions & 0 deletions core/undo_redo.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ class UndoRedo : public Object {
ObjectID object;
String name;
Variant args[VARIANT_ARG_MAX];

void delete_reference();
};

struct Action {
Expand Down
38 changes: 33 additions & 5 deletions doc/classes/String.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,10 @@
<method name="bigrams">
<return type="PoolStringArray" />
<description>
Returns the bigrams (pairs of consecutive letters) of this string.
Returns an array containing the bigrams (pairs of consecutive letters) of this string.
[codeblock]
print("Bigrams".bigrams()) # Prints "[Bi, ig, gr, ra, am, ms]"
[/codeblock]
</description>
</method>
<method name="c_escape">
Expand Down Expand Up @@ -447,7 +450,14 @@
<method name="is_valid_float">
<return type="bool" />
<description>
Returns [code]true[/code] if this string contains a valid float.
Returns [code]true[/code] if this string contains a valid float. This is inclusive of integers, and also supports exponents:
[codeblock]
print("1.7".is_valid_float()) # Prints "true"
print("24".is_valid_float()) # Prints "true"
print("7e3".is_valid_float()) # Prints "true"
print("24".is_valid_float()) # Prints "true"
print("Hello".is_valid_float()) # Prints "false"
[/codeblock]
</description>
</method>
<method name="is_valid_hex_number">
Expand All @@ -467,12 +477,24 @@
<return type="bool" />
<description>
Returns [code]true[/code] if this string is a valid identifier. A valid identifier may contain only letters, digits and underscores ([code]_[/code]) and the first character may not be a digit.
[codeblock]
print("good_ident_1".is_valid_identifier()) # Prints "true"
print("1st_bad_ident".is_valid_identifier()) # Prints "false"
print("bad_ident_#2".is_valid_identifier()) # Prints "false"
[/codeblock]
</description>
</method>
<method name="is_valid_integer">
<return type="bool" />
<description>
Returns [code]true[/code] if this string contains a valid integer.
[codeblock]
print("7".is_valid_int()) # Prints "true"
print("14.6".is_valid_int()) # Prints "false"
print("L".is_valid_int()) # Prints "false"
print("+3".is_valid_int()) # Prints "true"
print("-12".is_valid_int()) # Prints "true"
[/codeblock]
</description>
</method>
<method name="is_valid_ip_address">
Expand Down Expand Up @@ -523,14 +545,14 @@
<return type="bool" />
<argument index="0" name="expr" type="String" />
<description>
Does a simple case-sensitive expression match, where [code]"*"[/code] matches zero or more arbitrary characters and [code]"?"[/code] matches any single character except a period ([code]"."[/code]).
Does a simple case-sensitive expression match, where [code]"*"[/code] matches zero or more arbitrary characters and [code]"?"[/code] matches any single character except a period ([code]"."[/code]). An empty string or empty expression always evaluates to [code]false[/code].
</description>
</method>
<method name="matchn">
<return type="bool" />
<argument index="0" name="expr" type="String" />
<description>
Does a simple case-insensitive expression match, where [code]"*"[/code] matches zero or more arbitrary characters and [code]"?"[/code] matches any single character except a period ([code]"."[/code]).
Does a simple case-insensitive expression match, where [code]"*"[/code] matches zero or more arbitrary characters and [code]"?"[/code] matches any single character except a period ([code]"."[/code]). An empty string or empty expression always evaluates to [code]false[/code].
</description>
</method>
<method name="md5_buffer">
Expand Down Expand Up @@ -707,7 +729,13 @@
<return type="float" />
<argument index="0" name="text" type="String" />
<description>
Returns the similarity index of the text compared to this string. 1 means totally similar and 0 means totally dissimilar.
Returns the similarity index ([url=https://en.wikipedia.org/wiki/S%C3%B8rensen%E2%80%93Dice_coefficient]Sorensen-Dice coefficient[/url]) this string compared to another. 1.0 means totally similar and 0.0 means totally dissimilar.
[codeblock]
print("ABC123".similarity("ABC123")) # Prints "1"
print("ABC123".similarity("XYZ456")) # Prints "0"
print("ABC123".similarity("123ABC")) # Prints "0.8"
print("ABC123".similarity("abc123")) # Prints "0.4"
[/codeblock]
</description>
</method>
<method name="simplify_path">
Expand Down
2 changes: 2 additions & 0 deletions platform/iphone/godot_view.mm
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,8 @@ - (void)godot_commonInit {

[self initTouches];

self.multipleTouchEnabled = YES;

// Configure and start accelerometer
if (!self.motionManager) {
self.motionManager = [[CMMotionManager alloc] init];
Expand Down
10 changes: 5 additions & 5 deletions scene/2d/animated_sprite.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -364,14 +364,14 @@ void AnimatedSprite::_notification(int p_what) {
return;
}

float speed = frames->get_animation_speed(animation) * speed_scale;
if (speed == 0) {
return; //do nothing
}

float remaining = get_process_delta_time();

while (remaining) {
float speed = frames->get_animation_speed(animation) * speed_scale;
if (speed == 0) {
return; //do nothing
}

if (timeout <= 0) {
timeout = _get_frame_duration();

Expand Down
10 changes: 5 additions & 5 deletions scene/3d/sprite_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,14 +980,14 @@ void AnimatedSprite3D::_notification(int p_what) {
return;
}

float speed = frames->get_animation_speed(animation);
if (speed == 0) {
return; //do nothing
}

float remaining = get_process_delta_time();

while (remaining) {
float speed = frames->get_animation_speed(animation);
if (speed == 0) {
return; // Do nothing.
}

if (timeout <= 0) {
timeout = 1.0 / speed;

Expand Down
6 changes: 3 additions & 3 deletions scene/gui/rich_text_label.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
cw = tab_size * font->get_char_size(' ').width;
}

if (end > 0 && w + cw + begin > p_width) {
if (end > 0 && fw + cw + begin > p_width) {
break; //don't allow lines longer than assigned width
}

Expand All @@ -437,13 +437,12 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &
was_separatable = separatable;
just_breaked_in_middle = false;

w += cw;
fw += cw;

end++;
}
CHECK_HEIGHT(fh);
ENSURE_WIDTH(w);
ENSURE_WIDTH(fw);

line_ascent = MAX(line_ascent, ascent);
line_descent = MAX(line_descent, descent);
Expand Down Expand Up @@ -579,6 +578,7 @@ int RichTextLabel::_process_line(ItemFrame *p_frame, const Vector2 &p_ofs, int &

if (visible) {
line_is_blank = false;
w += font->get_char_size(c[i], c[i + 1]).x;
}

if (c[i] == '\t') {
Expand Down
Loading

0 comments on commit cf970aa

Please sign in to comment.