diff options
Diffstat (limited to 'core/io')
40 files changed, 169 insertions, 152 deletions
diff --git a/core/io/SCsub b/core/io/SCsub index 1c5f954470..19a6549225 100644 --- a/core/io/SCsub +++ b/core/io/SCsub @@ -1,5 +1,5 @@ #!/usr/bin/env python -Import('env') +Import("env") env.add_source_files(env.core_sources, "*.cpp") diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index 351e2941e8..73230e3a3c 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -290,7 +290,7 @@ Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream) next_tag.fields.clear(); next_tag.name = String(); - Error err = VariantParser::parse_tag_assign_eof(p_stream, lines, error_text, next_tag, assign, value, NULL, true); + Error err = VariantParser::parse_tag_assign_eof(p_stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { return OK; } else if (err != OK) { diff --git a/core/io/dtls_server.cpp b/core/io/dtls_server.cpp index 07e6abb1c9..5bda06e5b9 100644 --- a/core/io/dtls_server.cpp +++ b/core/io/dtls_server.cpp @@ -32,7 +32,7 @@ #include "core/os/file_access.h" #include "core/project_settings.h" -DTLSServer *(*DTLSServer::_create)() = NULL; +DTLSServer *(*DTLSServer::_create)() = nullptr; bool DTLSServer::available = false; DTLSServer *DTLSServer::create() { diff --git a/core/io/file_access_compressed.cpp b/core/io/file_access_compressed.cpp index 17cc6ce58f..c76142d22d 100644 --- a/core/io/file_access_compressed.cpp +++ b/core/io/file_access_compressed.cpp @@ -64,7 +64,7 @@ Error FileAccessCompressed::open_after_magic(FileAccess *p_base) { cmode = (Compression::Mode)f->get_32(); block_size = f->get_32(); if (block_size == 0) { - f = NULL; // Let the caller to handle the FileAccess object if failed to open as compressed file. + f = nullptr; // Let the caller to handle the FileAccess object if failed to open as compressed file. ERR_FAIL_V_MSG(ERR_FILE_CORRUPT, "Can't open compressed file '" + p_base->get_path() + "' with block size 0, it is corrupted."); } read_total = f->get_32(); @@ -109,7 +109,7 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) { if (err != OK) { //not openable - f = NULL; + f = nullptr; return err; } @@ -131,7 +131,7 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) { rmagic[4] = 0; if (magic != rmagic || open_after_magic(f) != OK) { memdelete(f); - f = NULL; + f = nullptr; return ERR_FILE_UNRECOGNIZED; } } @@ -187,12 +187,12 @@ void FileAccessCompressed::close() { } memdelete(f); - f = NULL; + f = nullptr; } bool FileAccessCompressed::is_open() const { - return f != NULL; + return f != nullptr; } void FileAccessCompressed::seek(size_t p_position) { @@ -392,20 +392,20 @@ Error FileAccessCompressed::_set_unix_permissions(const String &p_file, uint32_t FileAccessCompressed::FileAccessCompressed() : cmode(Compression::MODE_ZSTD), writing(false), - write_ptr(0), + write_ptr(nullptr), write_buffer_size(0), write_max(0), block_size(0), read_eof(false), at_end(false), - read_ptr(NULL), + read_ptr(nullptr), read_block(0), read_block_count(0), read_block_size(0), read_pos(0), read_total(0), magic("GCMP"), - f(NULL) { + f(nullptr) { } FileAccessCompressed::~FileAccessCompressed() { diff --git a/core/io/file_access_encrypted.cpp b/core/io/file_access_encrypted.cpp index 20b6fc81dc..a5b3807789 100644 --- a/core/io/file_access_encrypted.cpp +++ b/core/io/file_access_encrypted.cpp @@ -41,7 +41,7 @@ Error FileAccessEncrypted::open_and_parse(FileAccess *p_base, const Vector<uint8_t> &p_key, Mode p_mode) { - ERR_FAIL_COND_V_MSG(file != NULL, ERR_ALREADY_IN_USE, "Can't open file while another file from path '" + file->get_path_absolute() + "' is open."); + ERR_FAIL_COND_V_MSG(file != nullptr, ERR_ALREADY_IN_USE, "Can't open file while another file from path '" + file->get_path_absolute() + "' is open."); ERR_FAIL_COND_V(p_key.size() != 32, ERR_INVALID_PARAMETER); pos = 0; @@ -159,7 +159,7 @@ void FileAccessEncrypted::close() { file->store_buffer(compressed.ptr(), compressed.size()); file->close(); memdelete(file); - file = NULL; + file = nullptr; data.clear(); } else { @@ -167,13 +167,13 @@ void FileAccessEncrypted::close() { file->close(); memdelete(file); data.clear(); - file = NULL; + file = nullptr; } } bool FileAccessEncrypted::is_open() const { - return file != NULL; + return file != nullptr; } String FileAccessEncrypted::get_path() const { @@ -319,7 +319,7 @@ Error FileAccessEncrypted::_set_unix_permissions(const String &p_file, uint32_t FileAccessEncrypted::FileAccessEncrypted() { - file = NULL; + file = nullptr; pos = 0; eofed = false; mode = MODE_MAX; diff --git a/core/io/file_access_memory.cpp b/core/io/file_access_memory.cpp index 9e707678c0..a2379ce88f 100644 --- a/core/io/file_access_memory.cpp +++ b/core/io/file_access_memory.cpp @@ -35,7 +35,7 @@ #include "core/os/dir_access.h" #include "core/project_settings.h" -static Map<String, Vector<uint8_t>> *files = NULL; +static Map<String, Vector<uint8_t>> *files = nullptr; void FileAccessMemory::register_file(String p_name, Vector<uint8_t> p_data) { @@ -71,7 +71,7 @@ bool FileAccessMemory::file_exists(const String &p_name) { String name = fix_path(p_name); //name = DirAccess::normalize_path(name); - return files && (files->find(name) != NULL); + return files && (files->find(name) != nullptr); } Error FileAccessMemory::open_custom(const uint8_t *p_data, int p_len) { @@ -101,12 +101,12 @@ Error FileAccessMemory::_open(const String &p_path, int p_mode_flags) { void FileAccessMemory::close() { - data = NULL; + data = nullptr; } bool FileAccessMemory::is_open() const { - return data != NULL; + return data != nullptr; } void FileAccessMemory::seek(size_t p_position) { @@ -196,5 +196,5 @@ void FileAccessMemory::store_buffer(const uint8_t *p_src, int p_length) { FileAccessMemory::FileAccessMemory() { - data = NULL; + data = nullptr; } diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 370dd8f982..a3f307393f 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -114,7 +114,7 @@ void FileAccessNetworkClient::_thread_func() { int response = get_32(); DEBUG_PRINT("GET RESPONSE: " + itos(response)); - FileAccessNetwork *fa = NULL; + FileAccessNetwork *fa = nullptr; if (response != FileAccessNetwork::RESPONSE_DATA) { if (!accesses.has(id)) { @@ -219,11 +219,11 @@ Error FileAccessNetworkClient::connect(const String &p_host, int p_port, const S return OK; } -FileAccessNetworkClient *FileAccessNetworkClient::singleton = NULL; +FileAccessNetworkClient *FileAccessNetworkClient::singleton = nullptr; FileAccessNetworkClient::FileAccessNetworkClient() { - thread = NULL; + thread = nullptr; quit = false; singleton = this; last_id = 0; @@ -295,7 +295,7 @@ Error FileAccessNetwork::_open(const String &p_path, int p_mode_flags) { pos = 0; eof_flag = false; last_page = -1; - last_page_buff = NULL; + last_page_buff = nullptr; //buffers.clear(); nc->unlock_mutex(); diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 055ce816ad..0a7dee9444 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -98,18 +98,18 @@ void PackedData::add_path(const String &pkg_path, const String &path, uint64_t o void PackedData::add_pack_source(PackSource *p_source) { - if (p_source != NULL) { + if (p_source != nullptr) { sources.push_back(p_source); } }; -PackedData *PackedData::singleton = NULL; +PackedData *PackedData::singleton = nullptr; PackedData::PackedData() { singleton = this; root = memnew(PackedDir); - root->parent = NULL; + root->parent = nullptr; disabled = false; add_pack_source(memnew(PackedSourcePCK)); diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index e1f35aabdd..8df6826ac9 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -185,9 +185,9 @@ FileAccess *PackedData::try_open_path(const String &p_path) { PathMD5 pmd5(p_path.md5_buffer()); Map<PathMD5, PackedFile>::Element *E = files.find(pmd5); if (!E) - return NULL; //not found + return nullptr; //not found if (E->get().offset == 0) - return NULL; //was erased + return nullptr; //was erased return E->get().src->get_file(p_path, &E->get()); } diff --git a/core/io/file_access_zip.cpp b/core/io/file_access_zip.cpp index 680450ba43..57de66afaf 100644 --- a/core/io/file_access_zip.cpp +++ b/core/io/file_access_zip.cpp @@ -35,20 +35,20 @@ #include "core/os/copymem.h" #include "core/os/file_access.h" -ZipArchive *ZipArchive::instance = NULL; +ZipArchive *ZipArchive::instance = nullptr; extern "C" { static void *godot_open(void *data, const char *p_fname, int mode) { if (mode & ZLIB_FILEFUNC_MODE_WRITE) { - return NULL; + return nullptr; } FileAccess *f = (FileAccess *)data; f->open(p_fname, FileAccess::READ); - return f->is_open() ? data : NULL; + return f->is_open() ? data : nullptr; } static uLong godot_read(void *data, void *fdata, void *buf, uLong size) { @@ -126,11 +126,11 @@ void ZipArchive::close_handle(unzFile p_file) const { unzFile ZipArchive::get_file_handle(String p_file) const { - ERR_FAIL_COND_V_MSG(!file_exists(p_file), NULL, "File '" + p_file + " doesn't exist."); + ERR_FAIL_COND_V_MSG(!file_exists(p_file), nullptr, "File '" + p_file + " doesn't exist."); File file = files[p_file]; FileAccess *f = FileAccess::open(packages[file.package].filename, FileAccess::READ); - ERR_FAIL_COND_V_MSG(!f, NULL, "Cannot open file '" + packages[file.package].filename + "'."); + ERR_FAIL_COND_V_MSG(!f, nullptr, "Cannot open file '" + packages[file.package].filename + "'."); zlib_filefunc_def io; zeromem(&io, sizeof(io)); @@ -149,12 +149,12 @@ unzFile ZipArchive::get_file_handle(String p_file) const { io.free_mem = godot_free; unzFile pkg = unzOpen2(packages[file.package].filename.utf8().get_data(), &io); - ERR_FAIL_COND_V(!pkg, NULL); + ERR_FAIL_COND_V(!pkg, nullptr); int unz_err = unzGoToFilePos(pkg, &file.file_pos); if (unz_err != UNZ_OK || unzOpenCurrentFile(pkg) != UNZ_OK) { unzClose(pkg); - ERR_FAIL_V(NULL); + ERR_FAIL_V(nullptr); } return pkg; @@ -199,7 +199,7 @@ bool ZipArchive::try_open_pack(const String &p_path, bool p_replace_files) { char filename_inzip[256]; unz_file_info64 file_info; - err = unzGetCurrentFileInfo64(zfile, &file_info, filename_inzip, sizeof(filename_inzip), NULL, 0, NULL, 0); + err = unzGetCurrentFileInfo64(zfile, &file_info, filename_inzip, sizeof(filename_inzip), nullptr, 0, nullptr, 0); ERR_CONTINUE(err != UNZ_OK); File f; @@ -233,7 +233,7 @@ FileAccess *ZipArchive::get_file(const String &p_path, PackedData::PackedFile *p ZipArchive *ZipArchive::get_singleton() { - if (instance == NULL) { + if (instance == nullptr) { instance = memnew(ZipArchive); } @@ -268,7 +268,7 @@ Error FileAccessZip::_open(const String &p_path, int p_mode_flags) { zfile = arch->get_file_handle(p_path); ERR_FAIL_COND_V(!zfile, FAILED); - int err = unzGetCurrentFileInfo64(zfile, &file_info, NULL, 0, NULL, 0, NULL, 0); + int err = unzGetCurrentFileInfo64(zfile, &file_info, nullptr, 0, nullptr, 0, nullptr, 0); ERR_FAIL_COND_V(err != UNZ_OK, FAILED); return OK; @@ -282,12 +282,12 @@ void FileAccessZip::close() { ZipArchive *arch = ZipArchive::get_singleton(); ERR_FAIL_COND(!arch); arch->close_handle(zfile); - zfile = NULL; + zfile = nullptr; } bool FileAccessZip::is_open() const { - return zfile != NULL; + return zfile != nullptr; } void FileAccessZip::seek(size_t p_position) { @@ -370,7 +370,7 @@ bool FileAccessZip::file_exists(const String &p_name) { } FileAccessZip::FileAccessZip(const String &p_path, const PackedData::PackedFile &p_file) : - zfile(NULL) { + zfile(nullptr) { _open(p_path, FileAccess::READ); } diff --git a/core/io/image_loader.cpp b/core/io/image_loader.cpp index 99ac5bcdd9..01e6bb5618 100644 --- a/core/io/image_loader.cpp +++ b/core/io/image_loader.cpp @@ -100,7 +100,7 @@ ImageFormatLoader *ImageLoader::recognize(const String &p_extension) { return loader[i]; } - return NULL; + return nullptr; } Vector<ImageFormatLoader *> ImageLoader::loader; @@ -129,7 +129,7 @@ void ImageLoader::cleanup() { ///////////////// -RES ResourceFormatLoaderImage::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) { +RES ResourceFormatLoaderImage::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { FileAccess *f = FileAccess::open(p_path, FileAccess::READ); if (!f) { diff --git a/core/io/image_loader.h b/core/io/image_loader.h index 3ba028b99c..15ce6031d7 100644 --- a/core/io/image_loader.h +++ b/core/io/image_loader.h @@ -59,7 +59,7 @@ class ImageLoader { protected: public: - static Error load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom = NULL, bool p_force_linear = false, float p_scale = 1.0); + static Error load_image(String p_file, Ref<Image> p_image, FileAccess *p_custom = nullptr, bool p_force_linear = false, float p_scale = 1.0); static void get_recognized_extensions(List<String> *p_extensions); static ImageFormatLoader *recognize(const String &p_extension); @@ -73,10 +73,10 @@ public: class ResourceFormatLoaderImage : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; }; -#endif +#endif // IMAGE_LOADER_H diff --git a/core/io/ip.cpp b/core/io/ip.cpp index 2143b84d15..5de7fb7186 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -280,19 +280,19 @@ void IP::_bind_methods() { BIND_ENUM_CONSTANT(TYPE_ANY); } -IP *IP::singleton = NULL; +IP *IP::singleton = nullptr; IP *IP::get_singleton() { return singleton; } -IP *(*IP::_create)() = NULL; +IP *(*IP::_create)() = nullptr; IP *IP::create() { - ERR_FAIL_COND_V_MSG(singleton, NULL, "IP singleton already exist."); - ERR_FAIL_COND_V(!_create, NULL); + ERR_FAIL_COND_V_MSG(singleton, nullptr, "IP singleton already exist."); + ERR_FAIL_COND_V(!_create, nullptr); return _create(); } @@ -307,7 +307,7 @@ IP::IP() { resolver->thread = Thread::create(_IP_ResolverPrivate::_thread_function, resolver); #else - resolver->thread = NULL; + resolver->thread = nullptr; #endif } diff --git a/core/io/logger.cpp b/core/io/logger.cpp index 4d732332d5..48aebeda3d 100644 --- a/core/io/logger.cpp +++ b/core/io/logger.cpp @@ -108,7 +108,7 @@ Logger::~Logger() {} void RotatedFileLogger::close_file() { if (file) { memdelete(file); - file = NULL; + file = nullptr; } } @@ -182,7 +182,7 @@ void RotatedFileLogger::rotate_file() { RotatedFileLogger::RotatedFileLogger(const String &p_base_path, int p_max_files) : base_path(p_base_path.simplify_path()), max_files(p_max_files > 0 ? p_max_files : 1), - file(NULL) { + file(nullptr) { rotate_file(); } diff --git a/core/io/logger.h b/core/io/logger.h index ab2f9d8bc7..7028551185 100644 --- a/core/io/logger.h +++ b/core/io/logger.h @@ -107,4 +107,4 @@ public: virtual ~CompositeLogger(); }; -#endif +#endif // LOGGER_H diff --git a/core/io/marshalls.cpp b/core/io/marshalls.cpp index fbcaa582b7..81bc45b2f7 100644 --- a/core/io/marshalls.cpp +++ b/core/io/marshalls.cpp @@ -439,7 +439,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int (*r_len) += 8; if (val.is_null()) { - r_variant = (Object *)NULL; + r_variant = (Object *)nullptr; } else { Ref<EncodedObjectAsID> obj_as_id; obj_as_id.instance(); @@ -457,7 +457,7 @@ Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int return err; if (str == String()) { - r_variant = (Object *)NULL; + r_variant = (Object *)nullptr; } else { Object *obj = ClassDB::instance(str); @@ -917,7 +917,7 @@ Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bo // Test for potential wrong values sent by the debugger when it breaks. Object *obj = p_variant.get_validated_object(); if (!obj) { - // Object is invalid, send a NULL instead. + // Object is invalid, send a nullptr instead. if (buf) { encode_uint32(Variant::NIL, buf); } diff --git a/core/io/marshalls.h b/core/io/marshalls.h index 484f0755de..d029ed238c 100644 --- a/core/io/marshalls.h +++ b/core/io/marshalls.h @@ -199,7 +199,7 @@ public: EncodedObjectAsID(); }; -Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = NULL, bool p_allow_objects = false); +Error decode_variant(Variant &r_variant, const uint8_t *p_buffer, int p_len, int *r_len = nullptr, bool p_allow_objects = false); Error encode_variant(const Variant &p_variant, uint8_t *r_buffer, int &r_len, bool p_full_objects = false); -#endif +#endif // MARSHALLS_H diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index c29df07624..3bec52416e 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -207,7 +207,7 @@ int get_packet_len(uint32_t p_node_target, int p_packet_len) { void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_packet_len) { - ERR_FAIL_COND_MSG(root_node == NULL, "Multiplayer root node was not initialized. If you are using custom multiplayer, remember to set the root node via MultiplayerAPI.set_root_node before using it."); + ERR_FAIL_COND_MSG(root_node == nullptr, "Multiplayer root node was not initialized. If you are using custom multiplayer, remember to set the root node via MultiplayerAPI.set_root_node before using it."); ERR_FAIL_COND_MSG(p_packet_len < 1, "Invalid packet received. Size too small."); #ifdef DEBUG_ENABLED @@ -285,7 +285,7 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_ } Node *node = _process_get_node(p_from, p_packet, node_target, p_packet_len); - ERR_FAIL_COND_MSG(node == NULL, "Invalid packet received. Requested node was not found."); + ERR_FAIL_COND_MSG(node == nullptr, "Invalid packet received. Requested node was not found."); uint16_t name_id = 0; switch (name_id_compression) { @@ -321,14 +321,14 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, uint32_t p_node_target, int p_packet_len) { - Node *node = NULL; + Node *node = nullptr; if (p_node_target & 0x80000000) { // Use full path (not cached yet). int ofs = p_node_target & 0x7FFFFFFF; - ERR_FAIL_COND_V_MSG(ofs >= p_packet_len, NULL, "Invalid packet received. Size smaller than declared."); + ERR_FAIL_COND_V_MSG(ofs >= p_packet_len, nullptr, "Invalid packet received. Size smaller than declared."); String paths; paths.parse_utf8((const char *)&p_packet[ofs], p_packet_len - ofs); @@ -344,10 +344,10 @@ Node *MultiplayerAPI::_process_get_node(int p_from, const uint8_t *p_packet, uin int id = p_node_target; Map<int, PathGetCache>::Element *E = path_get_cache.find(p_from); - ERR_FAIL_COND_V_MSG(!E, NULL, "Invalid packet received. Requests invalid peer cache."); + ERR_FAIL_COND_V_MSG(!E, nullptr, "Invalid packet received. Requests invalid peer cache."); Map<int, PathGetCache::NodeInfo>::Element *F = E->get().nodes.find(id); - ERR_FAIL_COND_V_MSG(!F, NULL, "Invalid packet received. Unabled to find requested cached node."); + ERR_FAIL_COND_V_MSG(!F, nullptr, "Invalid packet received. Unabled to find requested cached node."); PathGetCache::NodeInfo *ni = &F->get(); // Do proper caching later. @@ -456,7 +456,7 @@ void MultiplayerAPI::_process_rset(Node *p_node, const uint16_t p_rpc_property_i #endif Variant value; - Error err = _decode_and_decompress_variant(value, &p_packet[p_offset], p_packet_len - p_offset, NULL); + Error err = _decode_and_decompress_variant(value, &p_packet[p_offset], p_packet_len - p_offset, nullptr); ERR_FAIL_COND_MSG(err != OK, "Invalid packet received. Unable to decode RSET value."); @@ -491,7 +491,7 @@ void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet, } Node *node = root_node->get_node(path); - ERR_FAIL_COND(node == NULL); + ERR_FAIL_COND(node == nullptr); const bool valid_rpc_checksum = node->get_rpc_md5() == methods_md5; if (valid_rpc_checksum == false) { ERR_PRINT("The rpc node checksum failed. Make sure to have the same methods on both nodes. Node path: " + path); @@ -504,7 +504,7 @@ void MultiplayerAPI::_process_simplify_path(int p_from, const uint8_t *p_packet, // Encode path to send ack. CharString pname = String(path).utf8(); - int len = encode_cstring(pname.get_data(), NULL); + int len = encode_cstring(pname.get_data(), nullptr); Vector<uint8_t> packet; @@ -572,7 +572,7 @@ bool MultiplayerAPI::_send_confirm_path(Node *p_node, NodePath p_path, PathSentC // Encode function name. const CharString path = String(p_path).utf8(); - const int path_len = encode_cstring(path.get_data(), NULL); + const int path_len = encode_cstring(path.get_data(), nullptr); // Extract MD5 from rpc methods list. const String methods_md5 = p_node->get_rpc_md5(); @@ -862,7 +862,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p // Set argument. int len(0); - Error err = _encode_and_compress_variant(*p_arg[0], NULL, len); + Error err = _encode_and_compress_variant(*p_arg[0], nullptr, len); ERR_FAIL_COND_MSG(err != OK, "Unable to encode RSET value. THIS IS LIKELY A BUG IN THE ENGINE!"); MAKE_ROOM(ofs + len); _encode_and_compress_variant(*p_arg[0], &(packet_cache.write[ofs]), len); @@ -907,7 +907,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p ofs += 1; for (int i = 0; i < p_argcount; i++) { int len(0); - Error err = _encode_and_compress_variant(*p_arg[i], NULL, len); + Error err = _encode_and_compress_variant(*p_arg[i], nullptr, len); ERR_FAIL_COND_MSG(err != OK, "Unable to encode RPC argument. THIS IS LIKELY A BUG IN THE ENGINE!"); MAKE_ROOM(ofs + len); _encode_and_compress_variant(*p_arg[i], &(packet_cache.write[ofs]), len); @@ -943,7 +943,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p // Append path at the end, since we will need it for some packets. CharString pname = String(from_path).utf8(); - int path_len = encode_cstring(pname.get_data(), NULL); + int path_len = encode_cstring(pname.get_data(), nullptr); MAKE_ROOM(ofs + path_len); encode_cstring(pname.get_data(), &(packet_cache.write[ofs])); @@ -1262,7 +1262,7 @@ void MultiplayerAPI::_bind_methods() { MultiplayerAPI::MultiplayerAPI() : allow_object_decoding(false) { rpc_sender_id = 0; - root_node = NULL; + root_node = nullptr; clear(); } diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h index 52f918aefa..4eb4a53e99 100644 --- a/core/io/multiplayer_api.h +++ b/core/io/multiplayer_api.h @@ -28,8 +28,8 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /*************************************************************************/ -#ifndef MULTIPLAYER_PROTOCOL_H -#define MULTIPLAYER_PROTOCOL_H +#ifndef MULTIPLAYER_API_H +#define MULTIPLAYER_API_H #include "core/io/networked_multiplayer_peer.h" #include "core/reference.h" @@ -148,4 +148,4 @@ public: VARIANT_ENUM_CAST(MultiplayerAPI::RPCMode); -#endif // MULTIPLAYER_PROTOCOL_H +#endif // MULTIPLAYER_API_H diff --git a/core/io/net_socket.cpp b/core/io/net_socket.cpp index 23edbc7d64..838c674cec 100644 --- a/core/io/net_socket.cpp +++ b/core/io/net_socket.cpp @@ -30,7 +30,7 @@ #include "net_socket.h" -NetSocket *(*NetSocket::_create)() = NULL; +NetSocket *(*NetSocket::_create)() = nullptr; NetSocket *NetSocket::create() { @@ -38,5 +38,5 @@ NetSocket *NetSocket::create() { return _create(); ERR_PRINT("Unable to create network socket, platform not supported"); - return NULL; + return nullptr; } diff --git a/core/io/networked_multiplayer_peer.h b/core/io/networked_multiplayer_peer.h index bffd544589..c1f1924051 100644 --- a/core/io/networked_multiplayer_peer.h +++ b/core/io/networked_multiplayer_peer.h @@ -80,4 +80,4 @@ public: VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::TransferMode) VARIANT_ENUM_CAST(NetworkedMultiplayerPeer::ConnectionStatus) -#endif // NetworkedMultiplayerPeer_H +#endif // NETWORKED_MULTIPLAYER_PEER_H diff --git a/core/io/packet_peer.cpp b/core/io/packet_peer.cpp index 2f5c493c2c..38abb5c0d6 100644 --- a/core/io/packet_peer.cpp +++ b/core/io/packet_peer.cpp @@ -90,13 +90,13 @@ Error PacketPeer::get_var(Variant &r_variant, bool p_allow_objects) { if (err) return err; - return decode_variant(r_variant, buffer, buffer_size, NULL, p_allow_objects); + return decode_variant(r_variant, buffer, buffer_size, nullptr, p_allow_objects); } Error PacketPeer::put_var(const Variant &p_packet, bool p_full_objects) { int len; - Error err = encode_variant(p_packet, NULL, len, p_full_objects); // compute len first + Error err = encode_variant(p_packet, nullptr, len, p_full_objects); // compute len first if (err) return err; diff --git a/core/io/packet_peer_dtls.cpp b/core/io/packet_peer_dtls.cpp index 01218a6881..6da115eed2 100644 --- a/core/io/packet_peer_dtls.cpp +++ b/core/io/packet_peer_dtls.cpp @@ -32,7 +32,7 @@ #include "core/os/file_access.h" #include "core/project_settings.h" -PacketPeerDTLS *(*PacketPeerDTLS::_create)() = NULL; +PacketPeerDTLS *(*PacketPeerDTLS::_create)() = nullptr; bool PacketPeerDTLS::available = false; PacketPeerDTLS *PacketPeerDTLS::create() { diff --git a/core/io/pck_packer.cpp b/core/io/pck_packer.cpp index 11e537c10b..5c4b3379ee 100644 --- a/core/io/pck_packer.cpp +++ b/core/io/pck_packer.cpp @@ -63,7 +63,7 @@ void PCKPacker::_bind_methods() { Error PCKPacker::pck_start(const String &p_file, int p_alignment) { - if (file != NULL) { + if (file != nullptr) { memdelete(file); } @@ -182,12 +182,12 @@ Error PCKPacker::flush(bool p_verbose) { PCKPacker::PCKPacker() { - file = NULL; + file = nullptr; }; PCKPacker::~PCKPacker() { - if (file != NULL) { + if (file != nullptr) { memdelete(file); }; - file = NULL; + file = nullptr; }; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index efd452191a..8c7559479b 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -337,12 +337,16 @@ Error ResourceLoaderBinary::parse_variant(Variant &r_v) { } break; case OBJECT_INTERNAL_RESOURCE: { uint32_t index = f->get_32(); - String path = res_path + "::" + itos(index); - RES res = ResourceLoader::load(path); - if (res.is_null()) { - WARN_PRINT(String("Couldn't load resource: " + path).utf8().get_data()); + if (use_nocache) { + r_v = internal_resources[index].cache; + } else { + String path = res_path + "::" + itos(index); + RES res = ResourceLoader::load(path); + if (res.is_null()) { + WARN_PRINT(String("Couldn't load resource: " + path).utf8().get_data()); + } + r_v = res; } - r_v = res; } break; case OBJECT_EXTERNAL_RESOURCE: { @@ -716,22 +720,24 @@ Error ResourceLoaderBinary::load() { if (!main) { - path = internal_resources[i].path; - if (path.begins_with("local://")) { - path = path.replace_first("local://", ""); - subindex = path.to_int(); - path = res_path + "::" + path; - } + if (!use_nocache) { + path = internal_resources[i].path; + if (path.begins_with("local://")) { + path = path.replace_first("local://", ""); + subindex = path.to_int(); + path = res_path + "::" + path; + } - if (ResourceCache::has(path)) { - //already loaded, don't do anything - stage++; - error = OK; - continue; + if (ResourceCache::has(path)) { + //already loaded, don't do anything + stage++; + error = OK; + continue; + } } } else { - if (!ResourceCache::has(res_path)) + if (!use_nocache && !ResourceCache::has(res_path)) path = res_path; } @@ -757,9 +763,15 @@ Error ResourceLoaderBinary::load() { RES res = RES(r); - r->set_path(path); + if (path != String()) { + r->set_path(path); + } r->set_subindex(subindex); + if (!main) { + internal_resources.write[i].cache = res; + } + int pc = f->get_32(); //set properties @@ -1009,10 +1021,11 @@ String ResourceLoaderBinary::recognize(FileAccess *p_f) { ResourceLoaderBinary::ResourceLoaderBinary() : translation_remapped(false), ver_format(0), - f(NULL), + f(nullptr), importmd_ofs(0), error(OK) { + use_nocache = false; progress = nullptr; use_sub_threads = false; } @@ -1023,7 +1036,7 @@ ResourceLoaderBinary::~ResourceLoaderBinary() { memdelete(f); } -RES ResourceFormatLoaderBinary::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) { +RES ResourceFormatLoaderBinary::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { if (r_error) *r_error = ERR_FILE_CANT_OPEN; @@ -1034,6 +1047,7 @@ RES ResourceFormatLoaderBinary::load(const String &p_path, const String &p_origi ERR_FAIL_COND_V_MSG(err != OK, RES(), "Cannot open file '" + p_path + "'."); ResourceLoaderBinary loader; + loader.use_nocache = p_no_cache; loader.use_sub_threads = p_use_sub_threads; loader.progress = r_progress; String path = p_original_path != "" ? p_original_path : p_path; @@ -1107,7 +1121,7 @@ Error ResourceFormatLoaderBinary::rename_dependencies(const String &p_path, cons FileAccess *f = FileAccess::open(p_path, FileAccess::READ); ERR_FAIL_COND_V_MSG(!f, ERR_CANT_OPEN, "Cannot open file '" + p_path + "'."); - FileAccess *fw = NULL; //=FileAccess::open(p_path+".depren"); + FileAccess *fw = nullptr; //=FileAccess::open(p_path+".depren"); String local_path = p_path.get_base_dir(); @@ -2095,7 +2109,7 @@ void ResourceFormatSaverBinary::get_recognized_extensions(const RES &p_resource, p_extensions->push_back("res"); } -ResourceFormatSaverBinary *ResourceFormatSaverBinary::singleton = NULL; +ResourceFormatSaverBinary *ResourceFormatSaverBinary::singleton = nullptr; ResourceFormatSaverBinary::ResourceFormatSaverBinary() { diff --git a/core/io/resource_format_binary.h b/core/io/resource_format_binary.h index 0ffa2c3626..0f8fc9445b 100644 --- a/core/io/resource_format_binary.h +++ b/core/io/resource_format_binary.h @@ -68,6 +68,7 @@ class ResourceLoaderBinary { struct IntResource { String path; uint64_t offset; + RES cache; }; Vector<IntResource> internal_resources; @@ -78,6 +79,8 @@ class ResourceLoaderBinary { Map<String, String> remaps; Error error; + bool use_nocache; + friend class ResourceFormatLoaderBinary; Error parse_variant(Variant &r_v); @@ -101,7 +104,7 @@ public: class ResourceFormatLoaderBinary : public ResourceFormatLoader { public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const; virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; diff --git a/core/io/resource_importer.cpp b/core/io/resource_importer.cpp index 452514a588..643df53f8c 100644 --- a/core/io/resource_importer.cpp +++ b/core/io/resource_importer.cpp @@ -69,7 +69,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { memdelete(f); return OK; @@ -117,7 +117,7 @@ Error ResourceFormatImporter::_get_path_and_type(const String &p_path, PathAndTy return OK; } -RES ResourceFormatImporter::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) { +RES ResourceFormatImporter::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { PathAndType pat; Error err = _get_path_and_type(p_path, pat); @@ -130,7 +130,7 @@ RES ResourceFormatImporter::load(const String &p_path, const String &p_original_ return RES(); } - RES res = ResourceLoader::_load(pat.path, p_path, pat.type, false, r_error, p_use_sub_threads, r_progress); + RES res = ResourceLoader::_load(pat.path, p_path, pat.type, p_no_cache, r_error, p_use_sub_threads, r_progress); #ifdef TOOLS_ENABLED if (res.is_valid()) { @@ -274,7 +274,7 @@ void ResourceFormatImporter::get_internal_resource_path_list(const String &p_pat next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, nullptr, true); if (err == ERR_FILE_EOF) { memdelete(f); return; @@ -434,7 +434,7 @@ String ResourceFormatImporter::get_import_settings_hash() const { return hash.md5_text(); } -ResourceFormatImporter *ResourceFormatImporter::singleton = NULL; +ResourceFormatImporter *ResourceFormatImporter::singleton = nullptr; ResourceFormatImporter::ResourceFormatImporter() { singleton = this; diff --git a/core/io/resource_importer.h b/core/io/resource_importer.h index 369efbe83c..6b76912494 100644 --- a/core/io/resource_importer.h +++ b/core/io/resource_importer.h @@ -45,7 +45,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { Variant metadata; }; - Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid = NULL) const; + Error _get_path_and_type(const String &p_path, PathAndType &r_path_and_type, bool *r_valid = nullptr) const; static ResourceFormatImporter *singleton; @@ -58,7 +58,7 @@ class ResourceFormatImporter : public ResourceFormatLoader { public: static ResourceFormatImporter *get_singleton() { return singleton; } - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const; virtual bool recognize_path(const String &p_path, const String &p_for_type = String()) const; @@ -123,7 +123,7 @@ public: virtual bool get_option_visibility(const String &p_option, const Map<StringName, Variant> &p_options) const = 0; virtual String get_option_group_file() const { return String(); } - virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = NULL, Variant *r_metadata = NULL) = 0; + virtual Error import(const String &p_source_file, const String &p_save_path, const Map<StringName, Variant> &p_options, List<String> *r_platform_variants, List<String> *r_gen_files = nullptr, Variant *r_metadata = nullptr) = 0; virtual Error import_group_file(const String &p_group_file, const Map<String, Map<StringName, Variant>> &p_source_file_options, const Map<String, String> &p_base_paths) { return ERR_UNAVAILABLE; } virtual bool are_import_settings_valid(const String &p_path) const { return true; } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index b150df5f40..d90802d7e2 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -119,7 +119,7 @@ void ResourceFormatLoader::get_recognized_extensions(List<String> *p_extensions) } } -RES ResourceFormatLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) { +RES ResourceFormatLoader::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { if (get_script_instance() && get_script_instance()->has_method("load")) { Variant res = get_script_instance()->call("load", p_path, p_original_path, p_use_sub_threads); @@ -200,7 +200,7 @@ RES ResourceLoader::_load(const String &p_path, const String &p_original_path, c continue; } found = true; - RES res = loader[i]->load(p_path, p_original_path != String() ? p_original_path : p_path, r_error, p_use_sub_threads, r_progress); + RES res = loader[i]->load(p_path, p_original_path != String() ? p_original_path : p_path, r_error, p_use_sub_threads, r_progress, p_no_cache); if (res.is_null()) { continue; } @@ -936,7 +936,7 @@ String ResourceLoader::_path_remap(const String &p_path, bool *r_translation_rem next_tag.fields.clear(); next_tag.name = String(); - err = VariantParser::parse_tag_assign_eof(&stream, lines, error_text, next_tag, assign, value, NULL, true); + 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) { @@ -1048,7 +1048,7 @@ void ResourceLoader::set_load_callback(ResourceLoadedCallback p_callback) { _loaded_callback = p_callback; } -ResourceLoadedCallback ResourceLoader::_loaded_callback = NULL; +ResourceLoadedCallback ResourceLoader::_loaded_callback = nullptr; Ref<ResourceFormatLoader> ResourceLoader::_find_custom_resource_format_loader(String path) { for (int i = 0; i < loader_count; ++i) { @@ -1075,7 +1075,7 @@ bool ResourceLoader::add_custom_resource_format_loader(String script_path) { Object *obj = ClassDB::instance(ibt); - ERR_FAIL_COND_V_MSG(obj == NULL, false, "Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt) + "."); + ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource loader, expected 'ResourceFormatLoader' inheritance, got: " + String(ibt) + "."); ResourceFormatLoader *crl = Object::cast_to<ResourceFormatLoader>(obj); crl->set_script(s); @@ -1140,11 +1140,11 @@ void ResourceLoader::finalize() { memdelete(thread_load_semaphore); } -ResourceLoadErrorNotify ResourceLoader::err_notify = NULL; -void *ResourceLoader::err_notify_ud = NULL; +ResourceLoadErrorNotify ResourceLoader::err_notify = nullptr; +void *ResourceLoader::err_notify_ud = nullptr; -DependencyErrorNotify ResourceLoader::dep_err_notify = NULL; -void *ResourceLoader::dep_err_notify_ud = NULL; +DependencyErrorNotify ResourceLoader::dep_err_notify = nullptr; +void *ResourceLoader::dep_err_notify_ud = nullptr; bool ResourceLoader::abort_on_missing_resource = true; bool ResourceLoader::timestamp_on_load = false; @@ -1162,4 +1162,4 @@ SelfList<Resource>::List ResourceLoader::remapped_list; HashMap<String, Vector<String>> ResourceLoader::translation_remaps; HashMap<String, String> ResourceLoader::path_remaps; -ResourceLoaderImport ResourceLoader::import = NULL; +ResourceLoaderImport ResourceLoader::import = nullptr; diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 5ba9e26858..2d95d5545f 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -43,7 +43,7 @@ protected: static void _bind_methods(); public: - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); virtual bool exists(const String &p_path) const; virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions) const; @@ -93,7 +93,7 @@ private: static HashMap<String, Vector<String>> translation_remaps; static HashMap<String, String> path_remaps; - static String _path_remap(const String &p_path, bool *r_translation_remapped = NULL); + static String _path_remap(const String &p_path, bool *r_translation_remapped = nullptr); friend class Resource; static SelfList<Resource>::List remapped_list; @@ -140,9 +140,9 @@ private: public: static Error load_threaded_request(const String &p_path, const String &p_type_hint = "", bool p_use_sub_threads = false, const String &p_source_resource = String()); static ThreadLoadStatus load_threaded_get_status(const String &p_path, float *r_progress = nullptr); - static RES load_threaded_get(const String &p_path, Error *r_error = NULL); + static RES load_threaded_get(const String &p_path, Error *r_error = nullptr); - static RES load(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false, Error *r_error = NULL); + static RES load(const String &p_path, const String &p_type_hint = "", bool p_no_cache = false, Error *r_error = nullptr); static bool exists(const String &p_path, const String &p_type_hint = ""); static void get_recognized_extensions_for_type(const String &p_type, List<String> *p_extensions); @@ -200,4 +200,4 @@ public: static void finalize(); }; -#endif +#endif // RESOURCE_LOADER_H diff --git a/core/io/resource_saver.cpp b/core/io/resource_saver.cpp index 80d2c5e471..09128adb50 100644 --- a/core/io/resource_saver.cpp +++ b/core/io/resource_saver.cpp @@ -38,7 +38,7 @@ Ref<ResourceFormatSaver> ResourceSaver::saver[MAX_SAVERS]; int ResourceSaver::saver_count = 0; bool ResourceSaver::timestamp_on_save = false; -ResourceSavedCallback ResourceSaver::save_callback = 0; +ResourceSavedCallback ResourceSaver::save_callback = nullptr; Error ResourceFormatSaver::save(const String &p_path, const RES &p_resource, uint32_t p_flags) { @@ -218,7 +218,7 @@ bool ResourceSaver::add_custom_resource_format_saver(String script_path) { Object *obj = ClassDB::instance(ibt); - ERR_FAIL_COND_V_MSG(obj == NULL, false, "Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt) + "."); + ERR_FAIL_COND_V_MSG(obj == nullptr, false, "Cannot instance script as custom resource saver, expected 'ResourceFormatSaver' inheritance, got: " + String(ibt) + "."); 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 e749f54cfa..2ddebf0581 100644 --- a/core/io/resource_saver.h +++ b/core/io/resource_saver.h @@ -90,4 +90,4 @@ public: static void remove_custom_savers(); }; -#endif +#endif // RESOURCE_SAVER_H diff --git a/core/io/stream_peer.cpp b/core/io/stream_peer.cpp index 3c695c18fc..b28b17aa95 100644 --- a/core/io/stream_peer.cpp +++ b/core/io/stream_peer.cpp @@ -224,7 +224,7 @@ void StreamPeer::put_var(const Variant &p_variant, bool p_full_objects) { int len = 0; Vector<uint8_t> buf; - encode_variant(p_variant, NULL, len, p_full_objects); + encode_variant(p_variant, nullptr, len, p_full_objects); buf.resize(len); put_32(len); encode_variant(p_variant, buf.ptrw(), len, p_full_objects); @@ -368,7 +368,7 @@ Variant StreamPeer::get_var(bool p_allow_objects) { ERR_FAIL_COND_V(err != OK, Variant()); Variant ret; - err = decode_variant(ret, var.ptr(), len, NULL, p_allow_objects); + err = decode_variant(ret, var.ptr(), len, nullptr, p_allow_objects); ERR_FAIL_COND_V_MSG(err != OK, Variant(), "Error when trying to decode Variant."); return ret; diff --git a/core/io/stream_peer_ssl.cpp b/core/io/stream_peer_ssl.cpp index 03ca726619..d98935f77c 100644 --- a/core/io/stream_peer_ssl.cpp +++ b/core/io/stream_peer_ssl.cpp @@ -32,13 +32,13 @@ #include "core/engine.h" -StreamPeerSSL *(*StreamPeerSSL::_create)() = NULL; +StreamPeerSSL *(*StreamPeerSSL::_create)() = nullptr; StreamPeerSSL *StreamPeerSSL::create() { if (_create) return _create(); - return NULL; + return nullptr; } bool StreamPeerSSL::available = false; diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index 327aa3cc3b..86df9ab8cf 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -93,4 +93,4 @@ public: VARIANT_ENUM_CAST(StreamPeerTCP::Status); -#endif +#endif // STREAM_PEER_TCP_H diff --git a/core/io/translation_loader_po.cpp b/core/io/translation_loader_po.cpp index 5da236d029..bce5361c76 100644 --- a/core/io/translation_loader_po.cpp +++ b/core/io/translation_loader_po.cpp @@ -185,7 +185,7 @@ RES TranslationLoaderPO::load_translation(FileAccess *f, Error *r_error) { return translation; } -RES TranslationLoaderPO::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress) { +RES TranslationLoaderPO::load(const String &p_path, const String &p_original_path, Error *r_error, bool p_use_sub_threads, float *r_progress, bool p_no_cache) { if (r_error) *r_error = ERR_CANT_OPEN; diff --git a/core/io/translation_loader_po.h b/core/io/translation_loader_po.h index d280729e94..137dfd1768 100644 --- a/core/io/translation_loader_po.h +++ b/core/io/translation_loader_po.h @@ -37,8 +37,8 @@ class TranslationLoaderPO : public ResourceFormatLoader { public: - static RES load_translation(FileAccess *f, Error *r_error = NULL); - virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = NULL, bool p_use_sub_threads = false, float *r_progress = nullptr); + static RES load_translation(FileAccess *f, Error *r_error = nullptr); + virtual RES load(const String &p_path, const String &p_original_path = "", Error *r_error = nullptr, bool p_use_sub_threads = false, float *r_progress = nullptr, bool p_no_cache = false); virtual void get_recognized_extensions(List<String> *p_extensions) const; virtual bool handles_type(const String &p_type) const; virtual String get_resource_type(const String &p_path) const; diff --git a/core/io/xml_parser.cpp b/core/io/xml_parser.cpp index bd450dd84f..9613ad3f10 100644 --- a/core/io/xml_parser.cpp +++ b/core/io/xml_parser.cpp @@ -165,7 +165,7 @@ bool XMLParser::_parse_cdata() { return true; char *cDataBegin = P; - char *cDataEnd = 0; + char *cDataEnd = nullptr; // find end of CDATA while (*P && !cDataEnd) { @@ -529,9 +529,9 @@ void XMLParser::close() { if (data) memdelete_arr(data); - data = NULL; + data = nullptr; length = 0; - P = NULL; + P = nullptr; node_empty = false; node_type = NODE_NONE; node_offset = 0; @@ -544,7 +544,7 @@ int XMLParser::get_current_line() const { XMLParser::XMLParser() { - data = NULL; + data = nullptr; close(); special_characters.push_back("&"); special_characters.push_back("<lt;"); diff --git a/core/io/xml_parser.h b/core/io/xml_parser.h index 47e276da28..26c3e6802f 100644 --- a/core/io/xml_parser.h +++ b/core/io/xml_parser.h @@ -121,4 +121,4 @@ public: ~XMLParser(); }; -#endif +#endif // XML_PARSER_H diff --git a/core/io/zip_io.cpp b/core/io/zip_io.cpp index 40e902d874..3a2a207d22 100644 --- a/core/io/zip_io.cpp +++ b/core/io/zip_io.cpp @@ -47,7 +47,7 @@ void *zipio_open(void *data, const char *p_fname, int mode) { } if (!f) - return NULL; + return nullptr; return data; } @@ -98,7 +98,7 @@ int zipio_close(voidpf opaque, voidpf stream) { if (f) { f->close(); memdelete(f); - f = NULL; + f = nullptr; } return 0; } |