Skip to content

Commit

Permalink
Merge pull request #933 from Spartan322/4.3.1-cherry-pick/enhancements
Browse files Browse the repository at this point in the history
[4.3] Cherry-picks for the 4.3 (4.3.1) branch - 1st enhancements batch
  • Loading branch information
Spartan322 authored Jan 18, 2025
2 parents d827275 + 907619a commit 66372fa
Show file tree
Hide file tree
Showing 161 changed files with 3,235 additions and 2,014 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ concurrency:

jobs:
build-android:
runs-on: "ubuntu-20.04"
runs-on: ubuntu-24.04
name: ${{ matrix.name }}
strategy:
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/godot_cpp_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ concurrency:

jobs:
godot-cpp-tests:
runs-on: "ubuntu-20.04"
name: "Build and test Godot CPP"
runs-on: ubuntu-24.04
name: Build and test Godot CPP
steps:
- uses: actions/checkout@v4
with:
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ concurrency:

jobs:
build-linux:
runs-on: "ubuntu-20.04"
# If unspecified, stay one LTS before latest to increase portability of Linux artifacts.
runs-on: ${{ matrix.os || 'ubuntu-22.04' }}
name: ${{ matrix.name }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -60,6 +61,8 @@ jobs:
artifact: false
# Test our oldest supported SCons/Python versions on one arbitrary editor build.
legacy-scons: true
# Python 3.6 unavailable on 22.04.
os: ubuntu-20.04

- name: Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)
cache-name: linux-editor-thread-sanitizer
Expand Down Expand Up @@ -99,7 +102,7 @@ jobs:
run: |
sudo rm -f /etc/apt/sources.list.d/microsoft-prod.list
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EB8B81E14DA65431D7504EA8F63F0F2B90935439
sudo add-apt-repository "deb https://ppa.launchpadcontent.net/kisak/turtle/ubuntu focal main"
sudo add-apt-repository "deb https://ppa.launchpadcontent.net/kisak/turtle/ubuntu ${{ matrix.os == 'ubuntu-20.04' && 'focal' || 'jammy' }} main"
sudo apt-get install -qq mesa-vulkan-drivers
# TODO: Figure out somehow how to embed this one.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ concurrency:
jobs:
static-checks:
name: Code style, file formatting, and docs
runs-on: ubuntu-22.04
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/web_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ concurrency:

jobs:
web-template:
runs-on: "ubuntu-22.04"
runs-on: ubuntu-24.04
name: ${{ matrix.name }}
strategy:
fail-fast: false
Expand Down
9 changes: 7 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -494,14 +494,19 @@ else:
# Disable assert() for production targets (only used in thirdparty code).
env.Append(CPPDEFINES=["NDEBUG"])

# This is not part of fast_unsafe because the only downside it has compared to
# the default is that SCons won't mark files that were changed in the last second
# as different. This is unlikely to be a problem in any real situation as just booting
# up scons takes more than that time.
# Renamed to `content-timestamp` in SCons >= 4.2, keeping MD5 for compat.
env.Decider("MD5-timestamp")

# SCons speed optimization controlled by the `fast_unsafe` option, which provide
# more than 10 s speed up for incremental rebuilds.
# Unsafe as they reduce the certainty of rebuilding all changed files, so it's
# enabled by default for `debug` builds, and can be overridden from command line.
# Ref: https://github.com/SCons/scons/wiki/GoFastButton
if methods.get_cmdline_bool("fast_unsafe", env.dev_build):
# Renamed to `content-timestamp` in SCons >= 4.2, keeping MD5 for compat.
env.Decider("MD5-timestamp")
env.SetOption("implicit_cache", 1)
env.SetOption("max_drift", 60)

Expand Down
2 changes: 2 additions & 0 deletions core/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ if env["builtin_zlib"]:
env.Prepend(CPPPATH=[thirdparty_zlib_dir])
if env.dev_build:
env_thirdparty.Append(CPPDEFINES=["ZLIB_DEBUG"])
# Affects headers so it should also be defined for Godot code
env.Append(CPPDEFINES=["ZLIB_DEBUG"])

env_thirdparty.add_source_files(thirdparty_obj, thirdparty_zlib_sources)

Expand Down
1 change: 1 addition & 0 deletions core/core_constants.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -678,6 +678,7 @@ void register_global_constants() {
BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_NODE_TYPE);
BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_HIDE_QUATERNION_EDIT);
BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_PASSWORD);
BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_ONESHOT);
BIND_CORE_ENUM_CONSTANT(PROPERTY_HINT_MAX);

BIND_CORE_BITFIELD_FLAG(PROPERTY_USAGE_NONE);
Expand Down
637 changes: 343 additions & 294 deletions core/input/gamecontrollerdb.txt

Large diffs are not rendered by default.

8 changes: 3 additions & 5 deletions core/io/file_access.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,9 @@ bool FileAccess::exists(const String &p_name) {
return true;
}

Ref<FileAccess> f = open(p_name, READ);
if (f.is_null()) {
return false;
}
return true;
// Using file_exists because it's faster than trying to open the file.
Ref<FileAccess> ret = create_for_path(p_name);
return ret->file_exists(p_name);
}

void FileAccess::_set_access_type(AccessType p_access) {
Expand Down
7 changes: 4 additions & 3 deletions core/io/http_client_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -664,15 +664,16 @@ PackedByteArray HTTPClientTCP::read_response_body_chunk() {
chunk_left -= rec;

if (chunk_left == 0) {
if (chunk[chunk.size() - 2] != '\r' || chunk[chunk.size() - 1] != '\n') {
const int chunk_size = chunk.size();
if (chunk[chunk_size - 2] != '\r' || chunk[chunk_size - 1] != '\n') {
ERR_PRINT("HTTP Invalid chunk terminator (not \\r\\n)");
status = STATUS_CONNECTION_ERROR;
break;
}

ret.resize(chunk.size() - 2);
ret.resize(chunk_size - 2);
uint8_t *w = ret.ptrw();
memcpy(w, chunk.ptr(), chunk.size() - 2);
memcpy(w, chunk.ptr(), chunk_size - 2);
chunk.clear();
}

Expand Down
18 changes: 18 additions & 0 deletions core/io/packet_peer_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ Error PacketPeerUDP::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
return ERR_UNAVAILABLE;
}

/* Bogus GCC warning here:
* In member function 'int RingBuffer<T>::read(T*, int, bool) [with T = unsigned char]',
* inlined from 'virtual Error PacketPeerUDP::get_packet(const uint8_t**, int&)' at core/io/packet_peer_udp.cpp:112:9,
* inlined from 'virtual Error PacketPeerUDP::get_packet(const uint8_t**, int&)' at core/io/packet_peer_udp.cpp:99:7:
* Error: ./core/ring_buffer.h:68:46: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
* 68 | p_buf[dst++] = read[pos + i];
* | ~~~~~~~~~~~~~^~~~~~~
*/
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic warning "-Wstringop-overflow=0"
#endif

uint32_t size = 0;
uint8_t ipv6[16] = {};
rb.read(ipv6, 16, true);
Expand All @@ -117,6 +130,11 @@ Error PacketPeerUDP::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
--queue_count;
*r_buffer = packet_buffer;
r_buffer_size = size;

#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

return OK;
}

Expand Down
17 changes: 17 additions & 0 deletions core/io/resource_importer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,23 @@ ResourceUID::ID ResourceFormatImporter::get_resource_uid(const String &p_path) c
return pat.uid;
}

Error ResourceFormatImporter::get_resource_import_info(const String &p_path, StringName &r_type, ResourceUID::ID &r_uid, String &r_import_group_file) const {
PathAndType pat;
Error err = _get_path_and_type(p_path, pat);

if (err == OK) {
r_type = pat.type;
r_uid = pat.uid;
r_import_group_file = pat.group_file;
} else {
r_type = "";
r_uid = ResourceUID::INVALID_ID;
r_import_group_file = "";
}

return err;
}

Variant ResourceFormatImporter::get_resource_metadata(const String &p_path) const {
PathAndType pat;
Error err = _get_path_and_type(p_path, pat);
Expand Down
1 change: 1 addition & 0 deletions core/io/resource_importer.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class ResourceFormatImporter : public ResourceFormatLoader {
String get_import_settings_hash() const;

String get_import_base_path(const String &p_for_file) const;
Error get_resource_import_info(const String &p_path, StringName &r_type, ResourceUID::ID &r_uid, String &r_import_group_file) const;
ResourceFormatImporter();
};

Expand Down
61 changes: 32 additions & 29 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1203,36 +1203,39 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem
new_path = path_remaps[new_path];
} else {
// Try file remap.
Error err;
Ref<FileAccess> f = FileAccess::open(new_path + ".remap", FileAccess::READ, &err);
if (f.is_valid()) {
VariantParser::StreamFile stream;
stream.f = f;

String assign;
Variant value;
VariantParser::Tag next_tag;

int lines = 0;
String error_text;
while (true) {
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();

err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true);
if (err == ERR_FILE_EOF) {
break;
} else if (err != OK) {
ERR_PRINT("Parse error: " + p_path + ".remap:" + itos(lines) + " error: " + error_text + ".");
break;
}
// Usually, there's no remap file and FileAccess::exists() is faster than FileAccess::open().
if (FileAccess::exists(new_path + ".remap")) {
Error err;
Ref<FileAccess> f = FileAccess::open(new_path + ".remap", FileAccess::READ, &err);
if (f.is_valid()) {
VariantParser::StreamFile stream;
stream.f = f;

String assign;
Variant value;
VariantParser::Tag next_tag;

int lines = 0;
String error_text;
while (true) {
assign = Variant();
next_tag.fields.clear();
next_tag.name = String();

err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true);
if (err == ERR_FILE_EOF) {
break;
} else if (err != OK) {
ERR_PRINT("Parse error: " + p_path + ".remap:" + itos(lines) + " error: " + error_text + ".");
break;
}

if (assign == "path") {
new_path = value;
break;
} else if (next_tag.name != "remap") {
break;
if (assign == "path") {
new_path = value;
break;
} else if (next_tag.name != "remap") {
break;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions core/io/stream_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,13 +225,13 @@ void StreamPeer::put_var(const Variant &p_variant, bool p_full_objects) {
}

uint8_t StreamPeer::get_u8() {
uint8_t buf[1];
uint8_t buf[1] = {};
get_data(buf, 1);
return buf[0];
}

int8_t StreamPeer::get_8() {
uint8_t buf[1];
uint8_t buf[1] = {};
get_data(buf, 1);
return buf[0];
}
Expand Down
3 changes: 3 additions & 0 deletions core/object/object.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ enum PropertyHint {
PROPERTY_HINT_HIDE_QUATERNION_EDIT, /// Only Node3D::transform should hide the quaternion editor.
PROPERTY_HINT_PASSWORD,
PROPERTY_HINT_LAYERS_AVOIDANCE,
PROPERTY_HINT_DICTIONARY_TYPE,
PROPERTY_HINT_TOOL_BUTTON,
PROPERTY_HINT_ONESHOT, ///< the property will be changed by self after setting, such as AudioStreamPlayer.playing, Particles.emitting.
PROPERTY_HINT_MAX,
};

Expand Down
8 changes: 4 additions & 4 deletions core/object/undo_redo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void UndoRedo::Operation::delete_reference() {
}
}

void UndoRedo::_discard_redo() {
void UndoRedo::discard_redo() {
if (current_action == actions.size() - 1) {
return;
}
Expand Down Expand Up @@ -91,7 +91,7 @@ void UndoRedo::create_action(const String &p_name, MergeMode p_mode, bool p_back
uint64_t ticks = OS::get_singleton()->get_ticks_msec();

if (action_level == 0) {
_discard_redo();
discard_redo();

// Check if the merge operation is valid
if (p_mode != MERGE_DISABLE && actions.size() && actions[actions.size() - 1].name == p_name && actions[actions.size() - 1].backward_undo_ops == p_backward_undo_ops && actions[actions.size() - 1].last_tick + 800 > ticks) {
Expand Down Expand Up @@ -290,7 +290,7 @@ void UndoRedo::end_force_keep_in_merge_ends() {
}

void UndoRedo::_pop_history_tail() {
_discard_redo();
discard_redo();

if (!actions.size()) {
return;
Expand Down Expand Up @@ -457,7 +457,7 @@ String UndoRedo::get_action_name(int p_id) {

void UndoRedo::clear_history(bool p_increase_version) {
ERR_FAIL_COND(action_level > 0);
_discard_redo();
discard_redo();

while (actions.size()) {
_pop_history_tail();
Expand Down
1 change: 1 addition & 0 deletions core/object/undo_redo.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ class UndoRedo : public Object {
int get_current_action();
String get_action_name(int p_id);
void clear_history(bool p_increase_version = true);
void discard_redo();

bool has_undo() const;
bool has_redo() const;
Expand Down
2 changes: 2 additions & 0 deletions core/object/worker_thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,8 @@ void WorkerThreadPool::init(int p_thread_count, float p_low_priority_task_ratio)

max_low_priority_threads = CLAMP(p_thread_count * p_low_priority_task_ratio, 1, p_thread_count - 1);

print_verbose(vformat("WorkerThreadPool: %d threads, %d max low-priority.", p_thread_count, max_low_priority_threads));

threads.resize(p_thread_count);

for (uint32_t i = 0; i < threads.size(); i++) {
Expand Down
2 changes: 1 addition & 1 deletion core/os/thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@
#include "core/templates/safe_refcount.h"

SafeNumeric<uint64_t> Thread::id_counter(1); // The first value after .increment() is 2, hence by default the main thread ID should be 1.
thread_local Thread::ID Thread::caller_id = Thread::id_counter.increment();

thread_local Thread::ID Thread::caller_id = Thread::UNASSIGNED_ID;
#endif

Thread::PlatformFunctions Thread::platform_functions;
Expand Down
6 changes: 2 additions & 4 deletions core/os/thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,22 @@ class Thread {
static PlatformFunctions platform_functions;

ID id = UNASSIGNED_ID;

static SafeNumeric<uint64_t> id_counter;
static thread_local ID caller_id;
THREADING_NAMESPACE::thread thread;

static void callback(ID p_caller_id, const Settings &p_settings, Thread::Callback p_callback, void *p_userdata);

static void make_main_thread() { caller_id = MAIN_ID; }
static void release_main_thread() { caller_id = UNASSIGNED_ID; }
static void release_main_thread() { caller_id = id_counter.increment(); }

public:
static void _set_platform_functions(const PlatformFunctions &p_functions);

_FORCE_INLINE_ ID get_id() const { return id; }
// get the ID of the caller thread
_FORCE_INLINE_ static ID get_caller_id() {
if (unlikely(caller_id == UNASSIGNED_ID)) {
caller_id = id_counter.increment();
}
return caller_id;
}
// get the ID of the main thread
Expand Down
Loading

0 comments on commit 66372fa

Please sign in to comment.