Skip to content

Commit

Permalink
Merge pull request #910 from Spartan322/merge/75ce426
Browse files Browse the repository at this point in the history
  • Loading branch information
Spartan322 authored Dec 29, 2024
2 parents 20b6554 + 1609981 commit 106ba51
Show file tree
Hide file tree
Showing 595 changed files with 2,436 additions and 1,943 deletions.
8 changes: 6 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,15 @@ repos:
stages: [manual] # Not automatically triggered, invoked via `pre-commit run --hook-stage manual clang-tidy`

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.7.3
rev: v0.8.4
hooks:
- id: ruff
args: [--fix]
files: (\.py|SConstruct|SCsub)$
types_or: [text]
- id: ruff-format
files: (\.py|SConstruct|SCsub)$
types_or: [text]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.13.0
Expand Down Expand Up @@ -204,7 +208,7 @@ repos:
language: python
entry: python misc/scripts/header_guards.py
files: \.(h|hpp|hh|hxx)$
exclude: ^.*/(thread|platform_config|platform_gl)\.h$
exclude: ^.*/(dummy|thread|platform_config|platform_gl)\.h$

- id: file-format
name: file-format
Expand Down
2 changes: 1 addition & 1 deletion core/input/input_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ List<StringName> InputMap::get_actions() const {
}

List<Ref<InputEvent>>::Element *InputMap::_find_event(Action &p_action, const Ref<InputEvent> &p_event, bool p_exact_match, bool *r_pressed, float *r_strength, float *r_raw_strength, int *r_event_index) const {
ERR_FAIL_COND_V(!p_event.is_valid(), nullptr);
ERR_FAIL_COND_V(p_event.is_null(), nullptr);

int i = 0;
for (List<Ref<InputEvent>>::Element *E = p_action.inputs.front(); E; E = E->next()) {
Expand Down
4 changes: 2 additions & 2 deletions core/io/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3994,7 +3994,7 @@ Error Image::load_svg_from_buffer(const Vector<uint8_t> &p_array, float scale) {
ERR_FAIL_COND_V(buffer_size == 0, ERR_INVALID_PARAMETER);

Ref<Image> image = _svg_scalable_mem_loader_func(p_array.ptr(), buffer_size, scale);
ERR_FAIL_COND_V(!image.is_valid(), ERR_PARSE_ERROR);
ERR_FAIL_COND_V(image.is_null(), ERR_PARSE_ERROR);

copy_internals_from(image);

Expand Down Expand Up @@ -4061,7 +4061,7 @@ Error Image::_load_from_buffer(const Vector<uint8_t> &p_array, ImageMemLoadFunc
const uint8_t *r = p_array.ptr();

Ref<Image> image = p_loader(r, buffer_size);
ERR_FAIL_COND_V(!image.is_valid(), ERR_PARSE_ERROR);
ERR_FAIL_COND_V(image.is_null(), ERR_PARSE_ERROR);

copy_internals_from(image);

Expand Down
14 changes: 7 additions & 7 deletions core/io/packet_peer_udp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void PacketPeerUDP::set_broadcast_enabled(bool p_enabled) {

Error PacketPeerUDP::join_multicast_group(IPAddress p_multi_address, const String &p_if_name) {
ERR_FAIL_COND_V(udp_server, ERR_LOCKED);
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!p_multi_address.is_valid(), ERR_INVALID_PARAMETER);

if (!_sock->is_open()) {
Expand All @@ -64,7 +64,7 @@ Error PacketPeerUDP::join_multicast_group(IPAddress p_multi_address, const Strin

Error PacketPeerUDP::leave_multicast_group(IPAddress p_multi_address, const String &p_if_name) {
ERR_FAIL_COND_V(udp_server, ERR_LOCKED);
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!_sock->is_open(), ERR_UNCONFIGURED);
return _sock->leave_multicast_group(p_multi_address, p_if_name);
}
Expand Down Expand Up @@ -139,7 +139,7 @@ Error PacketPeerUDP::get_packet(const uint8_t **r_buffer, int &r_buffer_size) {
}

Error PacketPeerUDP::put_packet(const uint8_t *p_buffer, int p_buffer_size) {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!peer_addr.is_valid(), ERR_UNCONFIGURED);

Error err;
Expand Down Expand Up @@ -180,7 +180,7 @@ int PacketPeerUDP::get_max_packet_size() const {
}

Error PacketPeerUDP::bind(int p_port, const IPAddress &p_bind_address, int p_recv_buffer_size) {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The local port number must be between 0 and 65535 (inclusive).");
Expand Down Expand Up @@ -229,7 +229,7 @@ void PacketPeerUDP::disconnect_shared_socket() {

Error PacketPeerUDP::connect_to_host(const IPAddress &p_host, int p_port) {
ERR_FAIL_COND_V(udp_server, ERR_LOCKED);
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(!p_host.is_valid(), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(p_port < 1 || p_port > 65535, ERR_INVALID_PARAMETER, "The remote port number must be between 1 and 65535 (inclusive).");

Expand Down Expand Up @@ -280,12 +280,12 @@ void PacketPeerUDP::close() {
}

Error PacketPeerUDP::wait() {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
return _sock->poll(NetSocket::POLL_TYPE_IN, -1);
}

Error PacketPeerUDP::_poll() {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);

if (!_sock->is_open()) {
return FAILED;
Expand Down
4 changes: 2 additions & 2 deletions core/io/plist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ bool PList::load_string(const String &p_string, String &r_err_out) {
stack.push_back(dict);
} else {
// Add root node.
if (!root.is_null()) {
if (root.is_valid()) {
r_err_out = "Root node already set.";
return false;
}
Expand Down Expand Up @@ -745,7 +745,7 @@ bool PList::load_string(const String &p_string, String &r_err_out) {
stack.push_back(arr);
} else {
// Add root node.
if (!root.is_null()) {
if (root.is_valid()) {
r_err_out = "Root node already set.";
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion core/io/remote_filesystem_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@

Vector<RemoteFilesystemClient::FileCache> RemoteFilesystemClient::_load_cache_file() {
Ref<FileAccess> fa = FileAccess::open(cache_path.path_join(FILES_CACHE_FILE), FileAccess::READ);
if (!fa.is_valid()) {
if (fa.is_null()) {
return Vector<FileCache>(); // No cache, return empty
}

Expand Down
6 changes: 3 additions & 3 deletions core/io/resource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ void Resource::reload_from_file() {

Ref<Resource> s = ResourceLoader::load(ResourceLoader::path_remap(path), get_class(), ResourceFormatLoader::CACHE_MODE_IGNORE);

if (!s.is_valid()) {
if (s.is_null()) {
return;
}

Expand Down Expand Up @@ -653,7 +653,7 @@ Ref<Resource> ResourceCache::get_ref(const String &p_path) {
ref = Ref<Resource>(*res);
}

if (res && !ref.is_valid()) {
if (res && ref.is_null()) {
// This resource is in the process of being deleted, ignore its existence
(*res)->path_cache = String();
resources.erase(p_path);
Expand All @@ -672,7 +672,7 @@ void ResourceCache::get_cached_resources(List<Ref<Resource>> *p_resources) {
for (KeyValue<String, Resource *> &E : resources) {
Ref<Resource> ref = Ref<Resource>(E.value);

if (!ref.is_valid()) {
if (ref.is_null()) {
// This resource is in the process of being deleted, ignore its existence
E.value->path_cache = String();
to_remove.push_back(E.key);
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_format_binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ Error ResourceLoaderBinary::load() {

external_resources.write[i].path = path; //remap happens here, not on load because on load it can actually be used for filesystem dock resource remap
external_resources.write[i].load_token = ResourceLoader::_load_start(path, external_resources[i].type, use_sub_threads ? ResourceLoader::LOAD_THREAD_DISTRIBUTE : ResourceLoader::LOAD_THREAD_FROM_CURRENT, cache_mode_for_external);
if (!external_resources[i].load_token.is_valid()) {
if (external_resources[i].load_token.is_null()) {
if (!ResourceLoader::get_abort_on_missing_resources()) {
ResourceLoader::notify_dependency_error(local_path, path, external_resources[i].type);
} else {
Expand Down Expand Up @@ -1389,7 +1389,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons

ERR_FAIL_COND_V(err != ERR_FILE_EOF, ERR_FILE_CORRUPT);
Ref<Resource> res = loader.get_resource();
ERR_FAIL_COND_V(!res.is_valid(), ERR_FILE_CORRUPT);
ERR_FAIL_COND_V(res.is_null(), ERR_FILE_CORRUPT);

return ResourceFormatSaverBinary::singleton->save(res, p_path);
}
Expand Down
4 changes: 2 additions & 2 deletions core/io/resource_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ Ref<Resource> ResourceLoader::load(const String &p_path, const String &p_type_hi
thread_mode = LOAD_THREAD_SPAWN_SINGLE;
}
Ref<LoadToken> load_token = _load_start(p_path, p_type_hint, thread_mode, p_cache_mode);
if (!load_token.is_valid()) {
if (load_token.is_null()) {
if (r_error) {
*r_error = FAILED;
}
Expand Down Expand Up @@ -947,7 +947,7 @@ Ref<Resource> ResourceLoader::ensure_resource_ref_override_for_outer_load(const
Object *obj = ClassDB::instantiate(p_res_type);
ERR_FAIL_NULL_V(obj, Ref<Resource>());
Ref<Resource> res(obj);
if (!res.is_valid()) {
if (res.is_null()) {
memdelete(obj);
ERR_FAIL_V(Ref<Resource>());
}
Expand Down
10 changes: 5 additions & 5 deletions core/io/stream_peer_tcp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void StreamPeerTCP::accept_socket(Ref<NetSocket> p_sock, IPAddress p_host, uint1
}

Error StreamPeerTCP::bind(int p_port, const IPAddress &p_host) {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V_MSG(p_port < 0 || p_port > 65535, ERR_INVALID_PARAMETER, "The local port number must be between 0 and 65535 (inclusive).");

Expand All @@ -108,7 +108,7 @@ Error StreamPeerTCP::bind(int p_port, const IPAddress &p_host) {
}

Error StreamPeerTCP::connect_to_host(const IPAddress &p_host, int p_port) {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(status != STATUS_NONE, ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_host.is_valid(), ERR_INVALID_PARAMETER);
ERR_FAIL_COND_V_MSG(p_port < 1 || p_port > 65535, ERR_INVALID_PARAMETER, "The remote port number must be between 1 and 65535 (inclusive).");
Expand Down Expand Up @@ -142,7 +142,7 @@ Error StreamPeerTCP::connect_to_host(const IPAddress &p_host, int p_port) {
}

Error StreamPeerTCP::write(const uint8_t *p_data, int p_bytes, int &r_sent, bool p_block) {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);

if (status != STATUS_CONNECTED) {
return FAILED;
Expand Down Expand Up @@ -240,7 +240,7 @@ Error StreamPeerTCP::read(uint8_t *p_buffer, int p_bytes, int &r_received, bool
}

void StreamPeerTCP::set_no_delay(bool p_enabled) {
ERR_FAIL_COND(!_sock.is_valid() || !_sock->is_open());
ERR_FAIL_COND(_sock.is_null() || !_sock->is_open());
_sock->set_tcp_no_delay_enabled(p_enabled);
}

Expand Down Expand Up @@ -283,7 +283,7 @@ Error StreamPeerTCP::get_partial_data(uint8_t *p_buffer, int p_bytes, int &r_rec
}

int StreamPeerTCP::get_available_bytes() const {
ERR_FAIL_COND_V(!_sock.is_valid(), -1);
ERR_FAIL_COND_V(_sock.is_null(), -1);
return _sock->get_available_bytes();
}

Expand Down
8 changes: 4 additions & 4 deletions core/io/tcp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ void TCPServer::_bind_methods() {
}

Error TCPServer::listen(uint16_t p_port, const IPAddress &p_bind_address) {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);

Expand Down Expand Up @@ -84,13 +84,13 @@ int TCPServer::get_local_port() const {
}

bool TCPServer::is_listening() const {
ERR_FAIL_COND_V(!_sock.is_valid(), false);
ERR_FAIL_COND_V(_sock.is_null(), false);

return _sock->is_open();
}

bool TCPServer::is_connection_available() const {
ERR_FAIL_COND_V(!_sock.is_valid(), false);
ERR_FAIL_COND_V(_sock.is_null(), false);

if (!_sock->is_open()) {
return false;
Expand All @@ -110,7 +110,7 @@ Ref<StreamPeerTCP> TCPServer::take_connection() {
IPAddress ip;
uint16_t port = 0;
ns = _sock->accept(ip, port);
if (!ns.is_valid()) {
if (ns.is_null()) {
return conn;
}

Expand Down
8 changes: 4 additions & 4 deletions core/io/udp_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void UDPServer::_bind_methods() {
}

Error UDPServer::poll() {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
if (!_sock->is_open()) {
return ERR_UNCONFIGURED;
}
Expand Down Expand Up @@ -90,7 +90,7 @@ Error UDPServer::poll() {
}

Error UDPServer::listen(uint16_t p_port, const IPAddress &p_bind_address) {
ERR_FAIL_COND_V(!_sock.is_valid(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock.is_null(), ERR_UNAVAILABLE);
ERR_FAIL_COND_V(_sock->is_open(), ERR_ALREADY_IN_USE);
ERR_FAIL_COND_V(!p_bind_address.is_valid() && !p_bind_address.is_wildcard(), ERR_INVALID_PARAMETER);

Expand Down Expand Up @@ -125,13 +125,13 @@ int UDPServer::get_local_port() const {
}

bool UDPServer::is_listening() const {
ERR_FAIL_COND_V(!_sock.is_valid(), false);
ERR_FAIL_COND_V(_sock.is_null(), false);

return _sock->is_open();
}

bool UDPServer::is_connection_available() const {
ERR_FAIL_COND_V(!_sock.is_valid(), false);
ERR_FAIL_COND_V(_sock.is_null(), false);

if (!_sock->is_open()) {
return false;
Expand Down
4 changes: 2 additions & 2 deletions core/object/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,7 @@ void Object::set_script(const Variant &p_script) {
script_instance = nullptr;
}

if (!s.is_null()) {
if (s.is_valid()) {
if (s->can_instantiate()) {
OBJ_DEBUG_LOCK
script_instance = s->instance_create(this);
Expand Down Expand Up @@ -1580,7 +1580,7 @@ void Object::_clear_internal_resource_paths(const Variant &p_var) {
switch (p_var.get_type()) {
case Variant::OBJECT: {
Ref<Resource> r = p_var;
if (!r.is_valid()) {
if (r.is_null()) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion core/os/keyboard.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ enum class Key {

enum class KeyModifierMask {
CODE_MASK = ((1 << 23) - 1), ///< Apply this mask to any keycode to remove modifiers.
MODIFIER_MASK = (0x7F << 22), ///< Apply this mask to isolate modifiers.
MODIFIER_MASK = (0x7F << 24), ///< Apply this mask to isolate modifiers.
//RESERVED = (1 << 23),
CMD_OR_CTRL = (1 << 24),
SHIFT = (1 << 25),
Expand Down
Loading

0 comments on commit 106ba51

Please sign in to comment.