Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.x #29

Merged
merged 30 commits into from
Nov 14, 2024
Merged

3.x #29

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
699a48d
[3.x] Bind Array and Pool*Array get and set functions
aaronfranke Aug 26, 2024
df74f14
Fix random multithreaded crash that happens when setting the audio st…
jitspoe Aug 29, 2024
354e656
Backport 65910 for Godot 3
Capital-EX Sep 25, 2024
287bc6f
Add warning when calling `is_action_just_pressed()` from `_input()`
lawnjelly Sep 28, 2024
019ca01
Merge pull request #97575 from lawnjelly/warn_input_just_pressed
lawnjelly Oct 1, 2024
e91dc0a
Merge pull request #24 from godotengine/3.x
illlustr Oct 1, 2024
62a8b7c
[3.x] Do not auto add default script and country codes to the locale.
jitspoe Oct 12, 2024
54b7231
Merge pull request #98109 from jitspoe/3.x.fix_localization_default_c…
lawnjelly Oct 13, 2024
910b55f
Merge branch 'godotengine:3.x' into 3.x
illlustr Oct 15, 2024
7ebb636
Cache results for `TranslationServer.compare_locales()`
timothyqiu Oct 16, 2024
147f032
Merge pull request #96261 from jitspoe/3.x.audio_random_pitch_crash_fix
lawnjelly Oct 16, 2024
3ee8ecd
Merge pull request #96135 from aaronfranke/3.x-bind-array-get-set
lawnjelly Oct 16, 2024
3841d76
Merge pull request #98234 from timothyqiu/locale-compare-cache
lawnjelly Oct 17, 2024
93c5146
Fix button click detection when `Tree` is rotated
timothyqiu Oct 18, 2024
d36d55c
Merge pull request #25 from godotengine/3.x
illlustr Oct 19, 2024
51b03b8
Fix `PopupMenu` margin and separation calculations
timothyqiu Oct 23, 2024
cc11089
Fix Button not listing `hover_pressed` stylebox
timothyqiu Oct 25, 2024
51eb2f8
Merge pull request #98452 from timothyqiu/menu-margins
lawnjelly Oct 28, 2024
e8b4fe3
Merge pull request #98300 from timothyqiu/tree-coordinate-3.x
lawnjelly Oct 28, 2024
c31800b
Merge pull request #98511 from timothyqiu/button-hover-pressed
lawnjelly Oct 28, 2024
373075f
Merge pull request #97464 from Capital-EX/backport-65910-3.x
lawnjelly Oct 28, 2024
85e6494
Merge pull request #26 from godotengine/3.x
illlustr Oct 29, 2024
a75460f
Fix error when non-ASCII characters in resource pack path
kilian-diener Nov 5, 2024
c50cae2
Merge pull request #98843 from kilian-diener/zip-path-utf8
lawnjelly Nov 5, 2024
960898c
certs: Sync with Mozilla bundle as of Oct 19, 2024
akien-mga Nov 5, 2024
ac45af5
Merge pull request #27 from godotengine/3.x
illlustr Nov 7, 2024
fd9bd10
CI: Update Ubuntu runners to 24.04, but keep 22.04 for Linux builds
akien-mga Nov 6, 2024
2200e5a
Merge pull request #98896 from akien-mga/3.x-ci-ubuntu-24.04
akien-mga Nov 7, 2024
12e9b22
CI: Remove now unused sources.list file
akien-mga Nov 7, 2024
72c72d7
Merge pull request #28 from godotengine/3.x
illlustr Nov 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/android_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@ concurrency:

jobs:
android-template:
runs-on: "ubuntu-20.04"
runs-on: "ubuntu-24.04"
name: Template (target=release, tools=no)

steps:
- uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
run: |
sudo rm -f /etc/apt/sources.list.d/*
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
sudo apt-get update

- name: Set up Java 17
uses: actions/setup-java@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/javascript_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ concurrency:

jobs:
javascript-template:
runs-on: "ubuntu-22.04"
runs-on: "ubuntu-24.04"
name: Template (target=release, tools=no)

steps:
Expand Down
16 changes: 8 additions & 8 deletions .github/workflows/linux_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ concurrency:

jobs:
build-linux:
runs-on: "ubuntu-20.04"
# Stay one LTS before latest to increase portability of Linux artifacts.
runs-on: "ubuntu-22.04"
name: ${{ matrix.name }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -42,14 +43,13 @@ jobs:
- name: Linux dependencies
shell: bash
run: |
# Azure repositories are not reliable, we need to prevent azure giving us packages.
sudo rm -f /etc/apt/sources.list.d/*
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
# Azure repositories are flaky, remove them.
sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}*
sudo apt-get update
# The actual dependencies
sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \
libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev \
libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip \
# The actual dependencies.
sudo apt-get install --no-install-recommends build-essential pkg-config libx11-dev \
libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev \
libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip \
libspeechd-dev speech-dispatcher

- name: Free disk space on runner
Expand Down
17 changes: 9 additions & 8 deletions .github/workflows/server_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ concurrency:

jobs:
build-server:
runs-on: "ubuntu-20.04"
# Stay one LTS before latest to increase portability of Linux artifacts.
runs-on: "ubuntu-22.04"
name: ${{ matrix.name }}
strategy:
fail-fast: false
Expand All @@ -36,14 +37,14 @@ jobs:
- name: Linux dependencies
shell: bash
run: |
# Azure repositories are not reliable, we need to prevent azure giving us packages.
sudo rm -f /etc/apt/sources.list.d/*
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
# Azure repositories are flaky, remove them.
sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}*
sudo apt-get update
# The actual dependencies
sudo apt-get install build-essential pkg-config libx11-dev libxcursor-dev \
libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev libpulse-dev \
libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip
# The actual dependencies.
sudo apt-get install --no-install-recommends build-essential pkg-config libx11-dev \
libxcursor-dev libxinerama-dev libgl1-mesa-dev libglu-dev libasound2-dev \
libpulse-dev libdbus-1-dev libudev-dev libxi-dev libxrandr-dev yasm xvfb wget unzip \
libspeechd-dev speech-dispatcher

- name: Restore Godot build cache
uses: ./.github/actions/godot-cache-restore
Expand Down
20 changes: 7 additions & 13 deletions .github/workflows/static_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,20 @@ concurrency:
jobs:
static-checks:
name: Static Checks (clang-format, black format, file format, documentation checks)
runs-on: ubuntu-20.04
runs-on: "ubuntu-24.04"
steps:
- name: Checkout
uses: actions/checkout@v4

# Azure repositories are not reliable, we need to prevent Azure giving us packages.
- name: Make apt sources.list use the default Ubuntu repositories
run: |
sudo rm -f /etc/apt/sources.list.d/*
sudo cp -f misc/ci/sources.list /etc/apt/sources.list
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo apt-add-repository "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-15 main"
sudo apt-get update

- name: Install dependencies
run: |
sudo apt-get install -qq dos2unix clang-format-15 libxml2-utils python3-pip moreutils
# Azure repositories are flaky, remove them.
sudo rm -f /etc/apt/sources.list.d/{azure,microsoft}*
sudo apt-get update
sudo apt-get install -qq dos2unix libxml2-utils python3-pip moreutils
sudo update-alternatives --remove-all clang-format || true
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-15 100
sudo pip3 install black==22.3.0 pygments
sudo update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-16 100
sudo pip3 install black==24.10.0 pygments

# This needs to happen before Python and npm execution; it must happen before any extra files are written.
- name: .gitignore checks (gitignore_check.sh)
Expand Down
4 changes: 4 additions & 0 deletions core/dictionary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ Variant Dictionary::get_or_add(const Variant &p_key, const Variant &p_default) {
return *result;
}

void Dictionary::set(const Variant &p_key, const Variant &p_value) {
operator[](p_key) = p_value;
}

int Dictionary::size() const {
return _p->variant_map.size();
}
Expand Down
1 change: 1 addition & 0 deletions core/dictionary.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ class Dictionary {
Variant get_valid(const Variant &p_key) const;
Variant get(const Variant &p_key, const Variant &p_default) const;
Variant get_or_add(const Variant &p_key, const Variant &p_default);
void set(const Variant &p_key, const Variant &p_value);

int size() const;
bool empty() const;
Expand Down
2 changes: 1 addition & 1 deletion core/io/file_access_zip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void *godot_open(void *data, const char *p_fname, int mode) {
return nullptr;
}

FileAccess *f = FileAccess::open(p_fname, FileAccess::READ);
FileAccess *f = FileAccess::open(String::utf8(p_fname), FileAccess::READ);
ERR_FAIL_COND_V(!f, nullptr);

return f;
Expand Down
7 changes: 4 additions & 3 deletions core/io/http_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,15 +713,16 @@ PoolByteArray HTTPClient::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);
PoolByteArray::Write w = ret.write();
memcpy(w.ptr(), chunk.ptr(), chunk.size() - 2);
memcpy(w.ptr(), chunk.ptr(), chunk_size - 2);
chunk.clear();
}

Expand Down
20 changes: 19 additions & 1 deletion core/io/packet_peer_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,21 @@ 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];
uint8_t ipv6[16] = {};
rb.read(ipv6, 16, true);
packet_ip.set_ipv6(ipv6);
rb.read((uint8_t *)&packet_port, 4, true);
Expand All @@ -115,6 +128,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
4 changes: 2 additions & 2 deletions core/io/stream_peer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,12 @@ 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
80 changes: 50 additions & 30 deletions core/translation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ void TranslationServer::init_locale_info() {
}

String TranslationServer::standardize_locale(const String &p_locale) const {
return _standardize_locale(p_locale, false);
}

String TranslationServer::_standardize_locale(const String &p_locale, bool p_add_defaults) const {
// Replaces '-' with '_' for macOS style locales.
String univ_locale = p_locale.replace("-", "_");

Expand Down Expand Up @@ -322,24 +326,26 @@ String TranslationServer::standardize_locale(const String &p_locale) const {
}

// Add script code base on language and country codes for some ambiguous cases.
if (script.empty()) {
for (int i = 0; i < locale_script_info.size(); i++) {
const LocaleScriptInfo &info = locale_script_info[i];
if (info.name == lang) {
if (country.empty() || info.supported_countries.has(country)) {
script = info.script;
break;
if (p_add_defaults) {
if (script.empty()) {
for (int i = 0; i < locale_script_info.size(); i++) {
const LocaleScriptInfo &info = locale_script_info[i];
if (info.name == lang) {
if (country.empty() || info.supported_countries.has(country)) {
script = info.script;
break;
}
}
}
}
}
if (!script.empty() && country.empty()) {
// Add conntry code based on script for some ambiguous cases.
for (int i = 0; i < locale_script_info.size(); i++) {
const LocaleScriptInfo &info = locale_script_info[i];
if (info.name == lang && info.script == script) {
country = info.default_country;
break;
if (!script.empty() && country.empty()) {
// Add conntry code based on script for some ambiguous cases.
for (int i = 0; i < locale_script_info.size(); i++) {
const LocaleScriptInfo &info = locale_script_info[i];
if (info.name == lang && info.script == script) {
country = info.default_country;
break;
}
}
}
}
Expand All @@ -359,32 +365,46 @@ String TranslationServer::standardize_locale(const String &p_locale) const {
}

int TranslationServer::compare_locales(const String &p_locale_a, const String &p_locale_b) const {
String locale_a = standardize_locale(p_locale_a);
String locale_b = standardize_locale(p_locale_b);
if (p_locale_a == p_locale_b) {
// Exact match.
return 10;
}

const String cache_key = p_locale_a + "|" + p_locale_b;
const int *cached_result = locale_compare_cache.getptr(cache_key);
if (cached_result) {
return *cached_result;
}

String locale_a = _standardize_locale(p_locale_a, true);
String locale_b = _standardize_locale(p_locale_b, true);

if (locale_a == locale_b) {
// Exact match.
locale_compare_cache.set(cache_key, 10);
return 10;
}

Vector<String> locale_a_elements = locale_a.split("_");
Vector<String> locale_b_elements = locale_b.split("_");
if (locale_a_elements[0] == locale_b_elements[0]) {
// Matching language, both locales have extra parts.
// Return number of matching elements.
int matching_elements = 1;
for (int i = 1; i < locale_a_elements.size(); i++) {
for (int j = 1; j < locale_b_elements.size(); j++) {
if (locale_a_elements[i] == locale_b_elements[j]) {
matching_elements++;
}
}
}
return matching_elements;
} else {
if (locale_a_elements[0] != locale_b_elements[0]) {
// No match.
locale_compare_cache.set(cache_key, 0);
return 0;
}

// Matching language, both locales have extra parts.
// Return number of matching elements.
int matching_elements = 1;
for (int i = 1; i < locale_a_elements.size(); i++) {
for (int j = 1; j < locale_b_elements.size(); j++) {
if (locale_a_elements[i] == locale_b_elements[j]) {
matching_elements++;
}
}
}
locale_compare_cache.set(cache_key, matching_elements);
return matching_elements;
}

String TranslationServer::get_locale_name(const String &p_locale) const {
Expand Down
3 changes: 3 additions & 0 deletions core/translation.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class TranslationServer : public Object {
Ref<Translation> tool_translation;
Ref<Translation> doc_translation;

mutable HashMap<String, int> locale_compare_cache;

bool enabled;

static TranslationServer *singleton;
Expand Down Expand Up @@ -122,6 +124,7 @@ class TranslationServer : public Object {

int compare_locales(const String &p_locale_a, const String &p_locale_b) const;
String standardize_locale(const String &p_locale) const;
String _standardize_locale(const String &p_locale, bool p_add_defaults) const;

Vector<String> get_all_languages() const;
String get_language_name(const String &p_language) const;
Expand Down
Loading
Loading