diff options
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/compression.cpp | 2 | ||||
-rw-r--r-- | core/io/file_access_memory.cpp | 16 | ||||
-rw-r--r-- | core/io/file_access_zip.cpp | 4 | ||||
-rw-r--r-- | core/io/image.cpp | 17 | ||||
-rw-r--r-- | core/io/ip.cpp | 2 | ||||
-rw-r--r-- | core/io/marshalls.cpp | 4 | ||||
-rw-r--r-- | core/io/packed_data_container.cpp | 6 | ||||
-rw-r--r-- | core/io/packet_peer.h | 1 | ||||
-rw-r--r-- | core/io/pck_packer.cpp | 4 | ||||
-rw-r--r-- | core/io/resource_format_binary.cpp | 1 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 3 | ||||
-rw-r--r-- | core/io/resource_loader.h | 1 | ||||
-rw-r--r-- | core/io/resource_saver.cpp | 2 | ||||
-rw-r--r-- | core/io/resource_saver.h | 1 | ||||
-rw-r--r-- | core/io/stream_peer.h | 1 | ||||
-rw-r--r-- | core/io/stream_peer_gzip.cpp | 4 | ||||
-rw-r--r-- | core/io/xml_parser.cpp | 4 | ||||
-rw-r--r-- | core/io/zip_io.cpp | 14 |
18 files changed, 43 insertions, 44 deletions
diff --git a/core/io/compression.cpp b/core/io/compression.cpp index e36fb0afa4..4e4627c40b 100644 --- a/core/io/compression.cpp +++ b/core/io/compression.cpp @@ -215,7 +215,7 @@ int Compression::decompress_dynamic(Vector<uint8_t> *p_dst_vect, int p_max_dst_s #ifdef BROTLI_ENABLED BrotliDecoderResult ret; BrotliDecoderState *state = BrotliDecoderCreateInstance(nullptr, nullptr, nullptr); - ERR_FAIL_COND_V(state == nullptr, Z_DATA_ERROR); + ERR_FAIL_NULL_V(state, Z_DATA_ERROR); // Setup the stream inputs. const uint8_t *next_in = p_src; diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 14ec0be092..0983920b94 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -79,7 +79,7 @@ Error FileAccessMemory::open_custom(const uint8_t *p_data, uint64_t p_len) { } Error FileAccessMemory::open_internal(const String &p_path, int p_mode_flags) { - ERR_FAIL_COND_V(!files, ERR_FILE_NOT_FOUND); + ERR_FAIL_NULL_V(files, ERR_FILE_NOT_FOUND); String name = fix_path(p_path); //name = DirAccess::normalize_path(name); @@ -99,22 +99,22 @@ bool FileAccessMemory::is_open() const { } void FileAccessMemory::seek(uint64_t p_position) { - ERR_FAIL_COND(!data); + ERR_FAIL_NULL(data); pos = p_position; } void FileAccessMemory::seek_end(int64_t p_position) { - ERR_FAIL_COND(!data); + ERR_FAIL_NULL(data); pos = length + p_position; } uint64_t FileAccessMemory::get_position() const { - ERR_FAIL_COND_V(!data, 0); + ERR_FAIL_NULL_V(data, 0); return pos; } uint64_t FileAccessMemory::get_length() const { - ERR_FAIL_COND_V(!data, 0); + ERR_FAIL_NULL_V(data, 0); return length; } @@ -134,7 +134,7 @@ uint8_t FileAccessMemory::get_8() const { uint64_t FileAccessMemory::get_buffer(uint8_t *p_dst, uint64_t p_length) const { ERR_FAIL_COND_V(!p_dst && p_length > 0, -1); - ERR_FAIL_COND_V(!data, -1); + ERR_FAIL_NULL_V(data, -1); uint64_t left = length - pos; uint64_t read = MIN(p_length, left); @@ -154,11 +154,11 @@ Error FileAccessMemory::get_error() const { } void FileAccessMemory::flush() { - ERR_FAIL_COND(!data); + ERR_FAIL_NULL(data); } void FileAccessMemory::store_8(uint8_t p_byte) { - ERR_FAIL_COND(!data); + ERR_FAIL_NULL(data); ERR_FAIL_COND(pos >= length); data[pos++] = p_byte; } diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index c7f1a73f97..d085c29728 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -239,7 +239,7 @@ Error FileAccessZip::open_internal(const String &p_path, int p_mode_flags) { ERR_FAIL_COND_V(p_mode_flags & FileAccess::WRITE, FAILED); ZipArchive *arch = ZipArchive::get_singleton(); - ERR_FAIL_COND_V(!arch, FAILED); + ERR_FAIL_NULL_V(arch, FAILED); zfile = arch->get_file_handle(p_path); ERR_FAIL_COND_V(!zfile, FAILED); @@ -255,7 +255,7 @@ void FileAccessZip::_close() { } ZipArchive *arch = ZipArchive::get_singleton(); - ERR_FAIL_COND(!arch); + ERR_FAIL_NULL(arch); arch->close_handle(zfile); zfile = nullptr; } diff --git a/core/io/image.cpp b/core/io/image.cpp index ce2f47371a..674af6b0a6 100644 --- a/core/io/image.cpp +++ b/core/io/image.cpp @@ -2356,7 +2356,7 @@ void Image::initialize_data(const char **p_xpm) { } Color *colorptr = colormap.getptr(pixelstr); - ERR_FAIL_COND(!colorptr); + ERR_FAIL_NULL(colorptr); uint8_t pixel[4]; for (uint32_t i = 0; i < pixel_size; i++) { pixel[i] = CLAMP((*colorptr)[i] * 255, 0, 255); @@ -2646,23 +2646,23 @@ Error Image::compress_from_channels(CompressMode p_mode, UsedChannels p_channels switch (p_mode) { case COMPRESS_S3TC: { - ERR_FAIL_COND_V(!_image_compress_bc_func, ERR_UNAVAILABLE); + ERR_FAIL_NULL_V(_image_compress_bc_func, ERR_UNAVAILABLE); _image_compress_bc_func(this, p_channels); } break; case COMPRESS_ETC: { - ERR_FAIL_COND_V(!_image_compress_etc1_func, ERR_UNAVAILABLE); + ERR_FAIL_NULL_V(_image_compress_etc1_func, ERR_UNAVAILABLE); _image_compress_etc1_func(this); } break; case COMPRESS_ETC2: { - ERR_FAIL_COND_V(!_image_compress_etc2_func, ERR_UNAVAILABLE); + ERR_FAIL_NULL_V(_image_compress_etc2_func, ERR_UNAVAILABLE); _image_compress_etc2_func(this, p_channels); } break; case COMPRESS_BPTC: { - ERR_FAIL_COND_V(!_image_compress_bptc_func, ERR_UNAVAILABLE); + ERR_FAIL_NULL_V(_image_compress_bptc_func, ERR_UNAVAILABLE); _image_compress_bptc_func(this, p_channels); } break; case COMPRESS_ASTC: { - ERR_FAIL_COND_V(!_image_compress_astc_func, ERR_UNAVAILABLE); + ERR_FAIL_NULL_V(_image_compress_astc_func, ERR_UNAVAILABLE); _image_compress_astc_func(this, p_astc_format); } break; case COMPRESS_MAX: { @@ -3412,6 +3412,7 @@ void Image::_bind_methods() { ClassDB::bind_method(D_METHOD("convert", "format"), &Image::convert); + ClassDB::bind_method(D_METHOD("get_mipmap_count"), &Image::get_mipmap_count); ClassDB::bind_method(D_METHOD("get_mipmap_offset", "mipmap"), &Image::get_mipmap_offset); ClassDB::bind_method(D_METHOD("resize_to_po2", "square", "interpolation"), &Image::resize_to_po2, DEFVAL(false), DEFVAL(INTERPOLATE_BILINEAR)); @@ -3655,7 +3656,7 @@ void Image::bump_map_to_normal_map(float bump_scale) { const uint8_t *rp = data.ptr(); uint8_t *wp = result_image.ptrw(); - ERR_FAIL_COND(!rp); + ERR_FAIL_NULL(rp); unsigned char *write_ptr = wp; float *read_ptr = (float *)rp; @@ -3916,7 +3917,7 @@ Error Image::_load_from_buffer(const Vector<uint8_t> &p_array, ImageMemLoadFunc int buffer_size = p_array.size(); ERR_FAIL_COND_V(buffer_size == 0, ERR_INVALID_PARAMETER); - ERR_FAIL_COND_V(!p_loader, ERR_INVALID_PARAMETER); + ERR_FAIL_NULL_V(p_loader, ERR_INVALID_PARAMETER); const uint8_t *r = p_array.ptr(); diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 772f700916..254351897d 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -333,7 +333,7 @@ IP *(*IP::_create)() = nullptr; IP *IP::create() { ERR_FAIL_COND_V_MSG(singleton, nullptr, "IP singleton already exist."); - ERR_FAIL_COND_V(!_create, nullptr); + ERR_FAIL_NULL_V(_create, nullptr); return _create(); } diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index 6ca7b0f831..bfef9ebeaf 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -640,7 +640,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int } else { Object *obj = ClassDB::instantiate(str); - ERR_FAIL_COND_V(!obj, ERR_UNAVAILABLE); + ERR_FAIL_NULL_V(obj, ERR_UNAVAILABLE); ERR_FAIL_COND_V(len < 4, ERR_INVALID_DATA); int32_t count = decode_uint32(buf); @@ -1576,7 +1576,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo buf += len; } Variant *v = d.getptr(E); - ERR_FAIL_COND_V(!v, ERR_BUG); + ERR_FAIL_NULL_V(v, ERR_BUG); err = encode_variant(*v, buf, len, p_full_objects, p_depth + 1); ERR_FAIL_COND_V(err, err); ERR_FAIL_COND_V(len % 4, ERR_BUG); diff --git a/core/io/packed_data_container.cpp b/core/io/packed_data_container.cpp index ce4edb18fe..11b0c69774 100644 --- a/core/io/packed_data_container.cpp +++ b/core/io/packed_data_container.cpp @@ -125,7 +125,7 @@ Variant PackedDataContainer::_get_at_ofs(uint32_t p_ofs, const uint8_t *p_buf, b uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const { ERR_FAIL_COND_V(p_ofs + 4 > (uint32_t)data.size(), 0); const uint8_t *rd = data.ptr(); - ERR_FAIL_COND_V(!rd, 0); + ERR_FAIL_NULL_V(rd, 0); const uint8_t *r = &rd[p_ofs]; uint32_t type = decode_uint32(r); @@ -135,7 +135,7 @@ uint32_t PackedDataContainer::_type_at_ofs(uint32_t p_ofs) const { int PackedDataContainer::_size(uint32_t p_ofs) const { ERR_FAIL_COND_V(p_ofs + 4 > (uint32_t)data.size(), 0); const uint8_t *rd = data.ptr(); - ERR_FAIL_COND_V(!rd, 0); + ERR_FAIL_NULL_V(rd, 0); const uint8_t *r = &rd[p_ofs]; uint32_t type = decode_uint32(r); @@ -156,7 +156,7 @@ Variant PackedDataContainer::_key_at_ofs(uint32_t p_ofs, const Variant &p_key, b const uint8_t *rd = data.ptr(); if (!rd) { err = true; - ERR_FAIL_COND_V(!rd, Variant()); + ERR_FAIL_NULL_V(rd, Variant()); } const uint8_t *r = &rd[p_ofs]; uint32_t type = decode_uint32(r); diff --git a/core/io/packet_peer.h b/core/io/packet_peer.h index 7383ab84df..86ebe32cb6 100644 --- a/core/io/packet_peer.h +++ b/core/io/packet_peer.h @@ -37,7 +37,6 @@ #include "core/extension/ext_wrappers.gen.inc" #include "core/object/gdvirtual.gen.inc" -#include "core/object/script_language.h" #include "core/variant/native_ptr.h" class PacketPeer : public RefCounted { diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 9b49cc3d8c..a7c715c318 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -205,7 +205,7 @@ Error PCKPacker::flush(bool p_verbose) { int header_padding = _get_pad(alignment, file->get_position()); for (int i = 0; i < header_padding; i++) { - file->store_8(Math::rand() % 256); + file->store_8(0); } int64_t file_base = file->get_position(); @@ -244,7 +244,7 @@ Error PCKPacker::flush(bool p_verbose) { int pad = _get_pad(alignment, file->get_position()); for (int j = 0; j < pad; j++) { - file->store_8(Math::rand() % 256); + file->store_8(0); } count += 1; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 551d3268b8..ea97e5ecce 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -36,6 +36,7 @@ #include "core/io/image.h" #include "core/io/marshalls.h" #include "core/io/missing_resource.h" +#include "core/object/script_language.h" #include "core/version.h" //#define print_bl(m_what) print_line(m_what) diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index df0253349c..f7915261af 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -33,6 +33,7 @@ #include "core/config/project_settings.h" #include "core/io/file_access.h" #include "core/io/resource_importer.h" +#include "core/object/script_language.h" #include "core/os/condition_variable.h" #include "core/os/os.h" #include "core/string/print_string.h" @@ -1113,7 +1114,7 @@ bool ResourceLoader::add_custom_resource_format_loader(String script_path) { Object *obj = ClassDB::instantiate(ibt); - ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt) + "."); + ERR_FAIL_NULL_V_MSG(obj, false, "Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt) + "."); Ref<ResourceFormatLoader> crl = Object::cast_to<ResourceFormatLoader>(obj); crl->set_script(s); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 2701caa3f4..0c7d6c0feb 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -33,7 +33,6 @@ #include "core/io/resource.h" #include "core/object/gdvirtual.gen.inc" -#include "core/object/script_language.h" #include "core/object/worker_thread_pool.h" #include "core/os/semaphore.h" #include "core/os/thread.h" diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 6e377847a8..564a54b913 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -241,7 +241,7 @@ bool ResourceSaver::add_custom_resource_format_saver(String script_path) { Object *obj = ClassDB::instantiate(ibt); - ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt) + "."); + ERR_FAIL_NULL_V_MSG(obj, false, "Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt) + "."); Ref<ResourceFormatSaver> crl = Object::cast_to<ResourceFormatSaver>(obj); crl->set_script(s); diff --git a/core/io/resource_saver.h b/core/io/resource_saver.h index 572742d129..4828df297a 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -33,7 +33,6 @@ #include "core/io/resource.h" #include "core/object/gdvirtual.gen.inc" -#include "core/object/script_language.h" class ResourceFormatSaver : public RefCounted { GDCLASS(ResourceFormatSaver, RefCounted); diff --git a/core/io/stream_peer.h b/core/io/stream_peer.h index ba11144e33..29cdb82615 100644 --- a/core/io/stream_peer.h +++ b/core/io/stream_peer.h @@ -35,7 +35,6 @@ #include "core/extension/ext_wrappers.gen.inc" #include "core/object/gdvirtual.gen.inc" -#include "core/object/script_language.h" #include "core/variant/native_ptr.h" class StreamPeer : public RefCounted { diff --git a/core/io/stream_peer_gzip.cpp b/core/io/stream_peer_gzip.cpp index 74216f3cff..4daa71a22a 100644 --- a/core/io/stream_peer_gzip.cpp +++ b/core/io/stream_peer_gzip.cpp @@ -102,7 +102,7 @@ Error StreamPeerGZIP::_start(bool p_compress, bool p_is_deflate, int buffer_size } Error StreamPeerGZIP::_process(uint8_t *p_dst, int p_dst_size, const uint8_t *p_src, int p_src_size, int &r_consumed, int &r_out, bool p_close) { - ERR_FAIL_COND_V(!ctx, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(ctx, ERR_UNCONFIGURED); z_stream &strm = *(z_stream *)ctx; strm.avail_in = p_src_size; strm.avail_out = p_dst_size; @@ -132,7 +132,7 @@ Error StreamPeerGZIP::put_data(const uint8_t *p_data, int p_bytes) { } Error StreamPeerGZIP::put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent) { - ERR_FAIL_COND_V(!ctx, ERR_UNCONFIGURED); + ERR_FAIL_NULL_V(ctx, ERR_UNCONFIGURED); ERR_FAIL_COND_V(p_bytes < 0, ERR_INVALID_PARAMETER); // Ensure we have enough space in temporary buffer. diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index 958734addf..faf7d75172 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -336,7 +336,7 @@ uint64_t XMLParser::get_node_offset() const { } Error XMLParser::seek(uint64_t p_pos) { - ERR_FAIL_COND_V(!data, ERR_FILE_EOF); + ERR_FAIL_NULL_V(data, ERR_FILE_EOF); ERR_FAIL_COND_V(p_pos >= length, ERR_FILE_EOF); P = data + p_pos; @@ -474,7 +474,7 @@ Error XMLParser::open_buffer(const Vector<uint8_t> &p_buffer) { Error XMLParser::_open_buffer(const uint8_t *p_buffer, size_t p_size) { ERR_FAIL_COND_V(p_size == 0, ERR_INVALID_DATA); - ERR_FAIL_COND_V(!p_buffer, ERR_INVALID_DATA); + ERR_FAIL_NULL_V(p_buffer, ERR_INVALID_DATA); if (data_copy) { memdelete_arr(data_copy); diff --git a/core/io/zip_io.cpp b/core/io/zip_io.cpp index a0e6bd62de..a89c6253f1 100644 --- a/core/io/zip_io.cpp +++ b/core/io/zip_io.cpp @@ -74,7 +74,7 @@ int godot_unzip_locate_file(unzFile p_zip_file, String p_filepath, bool p_case_s void *zipio_open(voidpf opaque, const char *p_fname, int mode) { Ref<FileAccess> *fa = reinterpret_cast<Ref<FileAccess> *>(opaque); - ERR_FAIL_COND_V(fa == nullptr, nullptr); + ERR_FAIL_NULL_V(fa, nullptr); String fname; fname.parse_utf8(p_fname); @@ -100,7 +100,7 @@ void *zipio_open(voidpf opaque, const char *p_fname, int mode) { uLong zipio_read(voidpf opaque, voidpf stream, void *buf, uLong size) { Ref<FileAccess> *fa = reinterpret_cast<Ref<FileAccess> *>(opaque); - ERR_FAIL_COND_V(fa == nullptr, 0); + ERR_FAIL_NULL_V(fa, 0); ERR_FAIL_COND_V(fa->is_null(), 0); return (*fa)->get_buffer((uint8_t *)buf, size); @@ -108,7 +108,7 @@ uLong zipio_read(voidpf opaque, voidpf stream, void *buf, uLong size) { uLong zipio_write(voidpf opaque, voidpf stream, const void *buf, uLong size) { Ref<FileAccess> *fa = reinterpret_cast<Ref<FileAccess> *>(opaque); - ERR_FAIL_COND_V(fa == nullptr, 0); + ERR_FAIL_NULL_V(fa, 0); ERR_FAIL_COND_V(fa->is_null(), 0); (*fa)->store_buffer((uint8_t *)buf, size); @@ -117,7 +117,7 @@ uLong zipio_write(voidpf opaque, voidpf stream, const void *buf, uLong size) { long zipio_tell(voidpf opaque, voidpf stream) { Ref<FileAccess> *fa = reinterpret_cast<Ref<FileAccess> *>(opaque); - ERR_FAIL_COND_V(fa == nullptr, 0); + ERR_FAIL_NULL_V(fa, 0); ERR_FAIL_COND_V(fa->is_null(), 0); return (*fa)->get_position(); @@ -125,7 +125,7 @@ long zipio_tell(voidpf opaque, voidpf stream) { long zipio_seek(voidpf opaque, voidpf stream, uLong offset, int origin) { Ref<FileAccess> *fa = reinterpret_cast<Ref<FileAccess> *>(opaque); - ERR_FAIL_COND_V(fa == nullptr, 0); + ERR_FAIL_NULL_V(fa, 0); ERR_FAIL_COND_V(fa->is_null(), 0); uint64_t pos = offset; @@ -146,7 +146,7 @@ long zipio_seek(voidpf opaque, voidpf stream, uLong offset, int origin) { int zipio_close(voidpf opaque, voidpf stream) { Ref<FileAccess> *fa = reinterpret_cast<Ref<FileAccess> *>(opaque); - ERR_FAIL_COND_V(fa == nullptr, 0); + ERR_FAIL_NULL_V(fa, 0); ERR_FAIL_COND_V(fa->is_null(), 0); fa->unref(); @@ -155,7 +155,7 @@ int zipio_close(voidpf opaque, voidpf stream) { int zipio_testerror(voidpf opaque, voidpf stream) { Ref<FileAccess> *fa = reinterpret_cast<Ref<FileAccess> *>(opaque); - ERR_FAIL_COND_V(fa == nullptr, 1); + ERR_FAIL_NULL_V(fa, 1); ERR_FAIL_COND_V(fa->is_null(), 0); return (fa->is_valid() && (*fa)->get_error() != OK) ? 1 : 0; |