diff options
Diffstat (limited to 'core/io')
-rw-r--r-- | core/io/config_file.cpp | 18 | ||||
-rw-r--r-- | core/io/config_file.h | 2 | ||||
-rw-r--r-- | core/io/file_access_network.cpp | 37 | ||||
-rw-r--r-- | core/io/file_access_network.h | 6 | ||||
-rw-r--r-- | core/io/file_access_pack.cpp | 2 | ||||
-rw-r--r-- | core/io/file_access_pack.h | 2 | ||||
-rw-r--r-- | core/io/ip.cpp | 23 | ||||
-rw-r--r-- | core/io/multiplayer_api.cpp | 151 | ||||
-rw-r--r-- | core/io/multiplayer_api.h | 34 | ||||
-rw-r--r-- | core/io/resource_format_binary.cpp | 2 | ||||
-rw-r--r-- | core/io/resource_loader.cpp | 1 | ||||
-rw-r--r-- | core/io/resource_loader.h | 2 | ||||
-rw-r--r-- | core/io/stream_peer_tcp.cpp | 5 | ||||
-rw-r--r-- | core/io/stream_peer_tcp.h | 3 |
14 files changed, 75 insertions, 213 deletions
diff --git a/core/io/config_file.cpp b/core/io/config_file.cpp index b44ac16a87..531467ecd6 100644 --- a/core/io/config_file.cpp +++ b/core/io/config_file.cpp @@ -86,7 +86,8 @@ void ConfigFile::set_value(const String &p_section, const String &p_key, const V Variant ConfigFile::get_value(const String &p_section, const String &p_key, Variant p_default) const { if (!values.has(p_section) || !values[p_section].has(p_key)) { - ERR_FAIL_COND_V_MSG(p_default.get_type() == Variant::NIL, Variant(), "Couldn't find the given section '" + p_section + "', key '" + p_key + "' and no default was given."); + ERR_FAIL_COND_V_MSG(p_default.get_type() == Variant::NIL, Variant(), + vformat("Couldn't find the given section \"%s\" and key \"%s\", and no default was given.", p_section, p_key)); return p_default; } @@ -112,7 +113,7 @@ void ConfigFile::get_sections(List<String> *r_sections) const { } void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) const { - ERR_FAIL_COND_MSG(!values.has(p_section), "Cannont get keys from nonexistent section '" + p_section + "'."); + ERR_FAIL_COND_MSG(!values.has(p_section), vformat("Cannot get keys from nonexistent section \"%s\".", p_section)); for (OrderedHashMap<String, Variant>::ConstElement E = values[p_section].front(); E; E = E.next()) { r_keys->push_back(E.key()); @@ -121,12 +122,14 @@ void ConfigFile::get_section_keys(const String &p_section, List<String> *r_keys) void ConfigFile::erase_section(const String &p_section) { + ERR_FAIL_COND_MSG(!values.has(p_section), vformat("Cannot erase nonexistent section \"%s\".", p_section)); values.erase(p_section); } void ConfigFile::erase_section_key(const String &p_section, const String &p_key) { - ERR_FAIL_COND_MSG(!values.has(p_section), "Cannot erase key from nonexistent section '" + p_section + "'."); + ERR_FAIL_COND_MSG(!values.has(p_section), vformat("Cannot erase key \"%s\" from nonexistent section \"%s\".", p_key, p_section)); + ERR_FAIL_COND_MSG(!values[p_section].has(p_key), vformat("Cannot erase nonexistent key \"%s\" from section \"%s\".", p_key, p_section)); values[p_section].erase(p_key); } @@ -291,7 +294,7 @@ Error ConfigFile::_parse(const String &p_path, VariantParser::Stream *p_stream) if (err == ERR_FILE_EOF) { return OK; } else if (err != OK) { - ERR_PRINT("ConfgFile - " + p_path + ":" + itos(lines) + " error: " + error_text + "."); + ERR_PRINT(vformat("ConfigFile parse error at %s:%d: %s.", p_path, lines, error_text)); return err; } @@ -324,11 +327,8 @@ void ConfigFile::_bind_methods() { ClassDB::bind_method(D_METHOD("save", "path"), &ConfigFile::save); ClassDB::bind_method(D_METHOD("load_encrypted", "path", "key"), &ConfigFile::load_encrypted); - ClassDB::bind_method(D_METHOD("load_encrypted_pass", "path", "pass"), &ConfigFile::load_encrypted_pass); + ClassDB::bind_method(D_METHOD("load_encrypted_pass", "path", "password"), &ConfigFile::load_encrypted_pass); ClassDB::bind_method(D_METHOD("save_encrypted", "path", "key"), &ConfigFile::save_encrypted); - ClassDB::bind_method(D_METHOD("save_encrypted_pass", "path", "pass"), &ConfigFile::save_encrypted_pass); -} - -ConfigFile::ConfigFile() { + ClassDB::bind_method(D_METHOD("save_encrypted_pass", "path", "password"), &ConfigFile::save_encrypted_pass); } diff --git a/core/io/config_file.h b/core/io/config_file.h index 150fd24693..7efcb5a04c 100644 --- a/core/io/config_file.h +++ b/core/io/config_file.h @@ -74,8 +74,6 @@ public: Error save_encrypted(const String &p_path, const Vector<uint8_t> &p_key); Error save_encrypted_pass(const String &p_path, const String &p_pass); - - ConfigFile(); }; #endif // CONFIG_FILE_H diff --git a/core/io/file_access_network.cpp b/core/io/file_access_network.cpp index 7f1eb6fd90..370dd8f982 100644 --- a/core/io/file_access_network.cpp +++ b/core/io/file_access_network.cpp @@ -88,9 +88,7 @@ void FileAccessNetworkClient::_thread_func() { while (!quit) { DEBUG_PRINT("SEM WAIT - " + itos(sem->get())); - Error err = sem->wait(); - if (err != OK) - ERR_PRINT("sem->wait() failed"); + sem.wait(); DEBUG_TIME("sem_unlock"); //DEBUG_PRINT("semwait returned "+itos(werr)); DEBUG_PRINT("MUTEX LOCK " + itos(lockcount)); @@ -141,7 +139,7 @@ void FileAccessNetworkClient::_thread_func() { fa->_respond(len, Error(status)); } - fa->sem->post(); + fa->sem.post(); } break; case FileAccessNetwork::RESPONSE_DATA: { @@ -161,14 +159,14 @@ void FileAccessNetworkClient::_thread_func() { int status = get_32(); fa->exists_modtime = status != 0; - fa->sem->post(); + fa->sem.post(); } break; case FileAccessNetwork::RESPONSE_GET_MODTIME: { uint64_t status = get_64(); fa->exists_modtime = status; - fa->sem->post(); + fa->sem.post(); } break; } @@ -230,7 +228,6 @@ FileAccessNetworkClient::FileAccessNetworkClient() { singleton = this; last_id = 0; client.instance(); - sem = SemaphoreOld::create(); lockcount = 0; } @@ -238,12 +235,10 @@ FileAccessNetworkClient::~FileAccessNetworkClient() { if (thread) { quit = true; - sem->post(); + sem.post(); Thread::wait_to_finish(thread); memdelete(thread); } - - memdelete(sem); } void FileAccessNetwork::_set_block(int p_offset, const Vector<uint8_t> &p_block) { @@ -264,7 +259,7 @@ void FileAccessNetwork::_set_block(int p_offset, const Vector<uint8_t> &p_block) if (waiting_on_page == page) { waiting_on_page = -1; - page_sem->post(); + page_sem.post(); } } @@ -306,9 +301,9 @@ Error FileAccessNetwork::_open(const String &p_path, int p_mode_flags) { nc->unlock_mutex(); DEBUG_PRINT("OPEN POST"); DEBUG_TIME("open_post"); - nc->sem->post(); //awaiting answer + nc->sem.post(); //awaiting answer DEBUG_PRINT("WAIT..."); - sem->wait(); + sem.wait(); DEBUG_TIME("open_end"); DEBUG_PRINT("WAIT ENDED..."); @@ -393,7 +388,7 @@ void FileAccessNetwork::_queue_page(int p_page) const { pages.write[p_page].queued = true; } DEBUG_PRINT("QUEUE PAGE POST"); - nc->sem->post(); + nc->sem.post(); DEBUG_PRINT("queued " + itos(p_page)); } } @@ -426,7 +421,7 @@ int FileAccessNetwork::get_buffer(uint8_t *p_dst, int p_length) const { } buffer_mutex.unlock(); DEBUG_PRINT("wait"); - page_sem->wait(); + page_sem.wait(); DEBUG_PRINT("done"); } else { @@ -475,8 +470,8 @@ bool FileAccessNetwork::file_exists(const String &p_path) { nc->client->put_data((const uint8_t *)cs.ptr(), cs.length()); nc->unlock_mutex(); DEBUG_PRINT("FILE EXISTS POST"); - nc->sem->post(); - sem->wait(); + nc->sem.post(); + sem.wait(); return exists_modtime != 0; } @@ -492,8 +487,8 @@ uint64_t FileAccessNetwork::_get_modified_time(const String &p_file) { nc->client->put_data((const uint8_t *)cs.ptr(), cs.length()); nc->unlock_mutex(); DEBUG_PRINT("MODTIME POST"); - nc->sem->post(); - sem->wait(); + nc->sem.post(); + sem.wait(); return exists_modtime; } @@ -521,8 +516,6 @@ FileAccessNetwork::FileAccessNetwork() { eof_flag = false; opened = false; pos = 0; - sem = SemaphoreOld::create(); - page_sem = SemaphoreOld::create(); FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton; nc->lock_mutex(); id = nc->last_id++; @@ -538,8 +531,6 @@ FileAccessNetwork::FileAccessNetwork() { FileAccessNetwork::~FileAccessNetwork() { close(); - memdelete(sem); - memdelete(page_sem); FileAccessNetworkClient *nc = FileAccessNetworkClient::singleton; nc->lock_mutex(); diff --git a/core/io/file_access_network.h b/core/io/file_access_network.h index 38d9b8e8a6..7f664b46f7 100644 --- a/core/io/file_access_network.h +++ b/core/io/file_access_network.h @@ -49,7 +49,7 @@ class FileAccessNetworkClient { List<BlockRequest> block_requests; - SemaphoreOld *sem; + Semaphore sem; Thread *thread; bool quit; Mutex mutex; @@ -85,8 +85,8 @@ public: class FileAccessNetwork : public FileAccess { - SemaphoreOld *sem; - SemaphoreOld *page_sem; + Semaphore sem; + Semaphore page_sem; Mutex buffer_mutex; bool opened; size_t total_size; diff --git a/core/io/file_access_pack.cpp b/core/io/file_access_pack.cpp index 83ce03418a..055ce816ad 100644 --- a/core/io/file_access_pack.cpp +++ b/core/io/file_access_pack.cpp @@ -454,7 +454,7 @@ Error DirAccessPack::change_dir(String p_dir) { return OK; } -String DirAccessPack::get_current_dir() { +String DirAccessPack::get_current_dir(bool p_include_drive) { PackedData::PackedDir *pd = current; String p = current->name; diff --git a/core/io/file_access_pack.h b/core/io/file_access_pack.h index b6ea9c158f..e1f35aabdd 100644 --- a/core/io/file_access_pack.h +++ b/core/io/file_access_pack.h @@ -216,7 +216,7 @@ public: virtual String get_drive(int p_drive); virtual Error change_dir(String p_dir); - virtual String get_current_dir(); + virtual String get_current_dir(bool p_include_drive = true); virtual bool file_exists(String p_file); virtual bool dir_exists(String p_dir); diff --git a/core/io/ip.cpp b/core/io/ip.cpp index af534e4bb7..2143b84d15 100644 --- a/core/io/ip.cpp +++ b/core/io/ip.cpp @@ -71,7 +71,7 @@ struct _IP_ResolverPrivate { } Mutex mutex; - SemaphoreOld *sem; + Semaphore sem; Thread *thread; //Semaphore* semaphore; @@ -98,7 +98,7 @@ struct _IP_ResolverPrivate { while (!ipr->thread_abort) { - ipr->sem->wait(); + ipr->sem.wait(); MutexLock lock(ipr->mutex); ipr->resolve_queues(); @@ -148,7 +148,7 @@ IP::ResolverID IP::resolve_hostname_queue_item(const String &p_hostname, IP::Typ resolver->queue[id].response = IP_Address(); resolver->queue[id].status = IP::RESOLVER_STATUS_WAITING; if (resolver->thread) - resolver->sem->post(); + resolver->sem.post(); else resolver->resolve_queues(); } @@ -300,23 +300,13 @@ IP::IP() { singleton = this; resolver = memnew(_IP_ResolverPrivate); - resolver->sem = NULL; #ifndef NO_THREADS - resolver->sem = SemaphoreOld::create(); - if (resolver->sem) { - resolver->thread_abort = false; + resolver->thread_abort = false; - resolver->thread = Thread::create(_IP_ResolverPrivate::_thread_function, resolver); - - if (!resolver->thread) - memdelete(resolver->sem); //wtf - } else { - resolver->thread = NULL; - } + resolver->thread = Thread::create(_IP_ResolverPrivate::_thread_function, resolver); #else - resolver->sem = NULL; resolver->thread = NULL; #endif } @@ -326,10 +316,9 @@ IP::~IP() { #ifndef NO_THREADS if (resolver->thread) { resolver->thread_abort = true; - resolver->sem->post(); + resolver->sem.post(); Thread::wait_to_finish(resolver->thread); memdelete(resolver->thread); - memdelete(resolver->sem); } #endif diff --git a/core/io/multiplayer_api.cpp b/core/io/multiplayer_api.cpp index d7c82fddd9..4b864f0dd7 100644 --- a/core/io/multiplayer_api.cpp +++ b/core/io/multiplayer_api.cpp @@ -30,6 +30,7 @@ #include "multiplayer_api.h" +#include "core/debugger/engine_debugger.h" #include "core/io/marshalls.h" #include "scene/main/node.h" #include <stdint.h> @@ -172,6 +173,28 @@ Ref<NetworkedMultiplayerPeer> MultiplayerAPI::get_network_peer() const { return network_peer; } +#ifdef DEBUG_ENABLED +void _profile_node_data(const String &p_what, ObjectID p_id) { + if (EngineDebugger::is_profiling("multiplayer")) { + Array values; + values.push_back("node"); + values.push_back(p_id); + values.push_back(p_what); + EngineDebugger::profiler_add_frame_data("multiplayer", values); + } +} +void _profile_bandwidth_data(const String &p_inout, int p_size) { + if (EngineDebugger::is_profiling("multiplayer")) { + Array values; + values.push_back("bandwidth"); + values.push_back(p_inout); + values.push_back(OS::get_singleton()->get_ticks_msec()); + values.push_back(p_size); + EngineDebugger::profiler_add_frame_data("multiplayer", values); + } +} +#endif + // Returns the packet size stripping the node path added when the node is not yet cached. int get_packet_len(uint32_t p_node_target, int p_packet_len) { if (p_node_target & 0x80000000) { @@ -188,11 +211,7 @@ void MultiplayerAPI::_process_packet(int p_from, const uint8_t *p_packet, int p_ ERR_FAIL_COND_MSG(p_packet_len < 1, "Invalid packet received. Size too small."); #ifdef DEBUG_ENABLED - if (profiling) { - bandwidth_incoming_data.write[bandwidth_incoming_pointer].timestamp = OS::get_singleton()->get_ticks_msec(); - bandwidth_incoming_data.write[bandwidth_incoming_pointer].packet_size = p_packet_len; - bandwidth_incoming_pointer = (bandwidth_incoming_pointer + 1) % bandwidth_incoming_data.size(); - } + _profile_bandwidth_data("in", p_packet_len); #endif // Extract the `packet_type` from the LSB three bits: @@ -381,11 +400,7 @@ void MultiplayerAPI::_process_rpc(Node *p_node, const uint16_t p_rpc_method_id, argp.resize(argc); #ifdef DEBUG_ENABLED - if (profiling) { - ObjectID id = p_node->get_instance_id(); - _init_node_profile(id); - profiler_frame_data[id].incoming_rpc += 1; - } + _profile_node_data("in_rpc", p_node->get_instance_id()); #endif if (byte_only) { @@ -437,11 +452,7 @@ void MultiplayerAPI::_process_rset(Node *p_node, const uint16_t p_rpc_property_i ERR_FAIL_COND_MSG(!can_call, "RSET '" + String(name) + "' is not allowed on node " + p_node->get_path() + " from: " + itos(p_from) + ". Mode is " + itos((int)rset_mode) + ", master is " + itos(p_node->get_network_master()) + "."); #ifdef DEBUG_ENABLED - if (profiling) { - ObjectID id = p_node->get_instance_id(); - _init_node_profile(id); - profiler_frame_data[id].incoming_rset += 1; - } + _profile_node_data("in_rset", p_node->get_instance_id()); #endif Variant value; @@ -912,11 +923,7 @@ void MultiplayerAPI::_send_rpc(Node *p_from, int p_to, bool p_unreliable, bool p packet_cache.write[0] = command_type + (node_id_compression << NODE_ID_COMPRESSION_SHIFT) + (name_id_compression << NAME_ID_COMPRESSION_SHIFT) + ((byte_only_or_no_args ? 1 : 0) << BYTE_ONLY_OR_NO_ARGS_SHIFT); #ifdef DEBUG_ENABLED - if (profiling) { - bandwidth_outgoing_data.write[bandwidth_outgoing_pointer].timestamp = OS::get_singleton()->get_ticks_msec(); - bandwidth_outgoing_data.write[bandwidth_outgoing_pointer].packet_size = ofs; - bandwidth_outgoing_pointer = (bandwidth_outgoing_pointer + 1) % bandwidth_outgoing_data.size(); - } + _profile_bandwidth_data("out", ofs); #endif // Take chance and set transfer mode, since all send methods will use it. @@ -1031,11 +1038,7 @@ void MultiplayerAPI::rpcp(Node *p_node, int p_peer_id, bool p_unreliable, const if (!skip_rpc) { #ifdef DEBUG_ENABLED - if (profiling) { - ObjectID id = p_node->get_instance_id(); - _init_node_profile(id); - profiler_frame_data[id].outgoing_rpc += 1; - } + _profile_node_data("out_rpc", p_node->get_instance_id()); #endif _send_rpc(p_node, p_peer_id, p_unreliable, false, p_method, p_arg, p_argcount); @@ -1130,11 +1133,7 @@ void MultiplayerAPI::rsetp(Node *p_node, int p_peer_id, bool p_unreliable, const } #ifdef DEBUG_ENABLED - if (profiling) { - ObjectID id = p_node->get_instance_id(); - _init_node_profile(id); - profiler_frame_data[id].outgoing_rset += 1; - } + _profile_node_data("out_rset", p_node->get_instance_id()); #endif const Variant *vptr = &p_value; @@ -1220,95 +1219,6 @@ bool MultiplayerAPI::is_object_decoding_allowed() const { return allow_object_decoding; } -void MultiplayerAPI::profiling_start() { -#ifdef DEBUG_ENABLED - profiling = true; - profiler_frame_data.clear(); - - bandwidth_incoming_pointer = 0; - bandwidth_incoming_data.resize(16384); // ~128kB - for (int i = 0; i < bandwidth_incoming_data.size(); ++i) { - bandwidth_incoming_data.write[i].packet_size = -1; - } - - bandwidth_outgoing_pointer = 0; - bandwidth_outgoing_data.resize(16384); // ~128kB - for (int i = 0; i < bandwidth_outgoing_data.size(); ++i) { - bandwidth_outgoing_data.write[i].packet_size = -1; - } -#endif -} - -void MultiplayerAPI::profiling_end() { -#ifdef DEBUG_ENABLED - profiling = false; - bandwidth_incoming_data.clear(); - bandwidth_outgoing_data.clear(); -#endif -} - -int MultiplayerAPI::get_profiling_frame(ProfilingInfo *r_info) { - int i = 0; -#ifdef DEBUG_ENABLED - for (Map<ObjectID, ProfilingInfo>::Element *E = profiler_frame_data.front(); E; E = E->next()) { - r_info[i] = E->get(); - ++i; - } - profiler_frame_data.clear(); -#endif - return i; -} - -int MultiplayerAPI::get_incoming_bandwidth_usage() { -#ifdef DEBUG_ENABLED - return _get_bandwidth_usage(bandwidth_incoming_data, bandwidth_incoming_pointer); -#else - return 0; -#endif -} - -int MultiplayerAPI::get_outgoing_bandwidth_usage() { -#ifdef DEBUG_ENABLED - return _get_bandwidth_usage(bandwidth_outgoing_data, bandwidth_outgoing_pointer); -#else - return 0; -#endif -} - -#ifdef DEBUG_ENABLED -int MultiplayerAPI::_get_bandwidth_usage(const Vector<BandwidthFrame> &p_buffer, int p_pointer) { - int total_bandwidth = 0; - - uint32_t timestamp = OS::get_singleton()->get_ticks_msec(); - uint32_t final_timestamp = timestamp - 1000; - - int i = (p_pointer + p_buffer.size() - 1) % p_buffer.size(); - - while (i != p_pointer && p_buffer[i].packet_size > 0) { - if (p_buffer[i].timestamp < final_timestamp) { - return total_bandwidth; - } - total_bandwidth += p_buffer[i].packet_size; - i = (i + p_buffer.size() - 1) % p_buffer.size(); - } - - ERR_FAIL_COND_V_MSG(i == p_pointer, total_bandwidth, "Reached the end of the bandwidth profiler buffer, values might be inaccurate."); - return total_bandwidth; -} - -void MultiplayerAPI::_init_node_profile(ObjectID p_node) { - if (profiler_frame_data.has(p_node)) - return; - profiler_frame_data.insert(p_node, ProfilingInfo()); - profiler_frame_data[p_node].node = p_node; - profiler_frame_data[p_node].node_path = Object::cast_to<Node>(ObjectDB::get_instance(p_node))->get_path(); - profiler_frame_data[p_node].incoming_rpc = 0; - profiler_frame_data[p_node].incoming_rset = 0; - profiler_frame_data[p_node].outgoing_rpc = 0; - profiler_frame_data[p_node].outgoing_rset = 0; -} -#endif - void MultiplayerAPI::_bind_methods() { ClassDB::bind_method(D_METHOD("set_root_node", "node"), &MultiplayerAPI::set_root_node); ClassDB::bind_method(D_METHOD("send_bytes", "bytes", "id", "mode"), &MultiplayerAPI::send_bytes, DEFVAL(NetworkedMultiplayerPeer::TARGET_PEER_BROADCAST), DEFVAL(NetworkedMultiplayerPeer::TRANSFER_MODE_RELIABLE)); @@ -1352,9 +1262,6 @@ MultiplayerAPI::MultiplayerAPI() : allow_object_decoding(false) { rpc_sender_id = 0; root_node = NULL; -#ifdef DEBUG_ENABLED - profiling = false; -#endif clear(); } diff --git a/core/io/multiplayer_api.h b/core/io/multiplayer_api.h index a706a0e450..52f918aefa 100644 --- a/core/io/multiplayer_api.h +++ b/core/io/multiplayer_api.h @@ -38,16 +38,6 @@ class MultiplayerAPI : public Reference { GDCLASS(MultiplayerAPI, Reference); -public: - struct ProfilingInfo { - ObjectID node; - String node_path; - int incoming_rpc; - int incoming_rset; - int outgoing_rpc; - int outgoing_rset; - }; - private: //path sent caches struct PathSentCache { @@ -65,23 +55,6 @@ private: Map<int, NodeInfo> nodes; }; -#ifdef DEBUG_ENABLED - struct BandwidthFrame { - uint32_t timestamp; - int packet_size; - }; - - int bandwidth_incoming_pointer; - Vector<BandwidthFrame> bandwidth_incoming_data; - int bandwidth_outgoing_pointer; - Vector<BandwidthFrame> bandwidth_outgoing_data; - Map<ObjectID, ProfilingInfo> profiler_frame_data; - bool profiling; - - void _init_node_profile(ObjectID p_node); - int _get_bandwidth_usage(const Vector<BandwidthFrame> &p_buffer, int p_pointer); -#endif - Ref<NetworkedMultiplayerPeer> network_peer; int rpc_sender_id; Set<int> connected_peers; @@ -169,13 +142,6 @@ public: void set_allow_object_decoding(bool p_enable); bool is_object_decoding_allowed() const; - void profiling_start(); - void profiling_end(); - - int get_profiling_frame(ProfilingInfo *r_info); - int get_incoming_bandwidth_usage(); - int get_outgoing_bandwidth_usage(); - MultiplayerAPI(); ~MultiplayerAPI(); }; diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index 54b75cc29d..efd452191a 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -1008,7 +1008,9 @@ String ResourceLoaderBinary::recognize(FileAccess *p_f) { ResourceLoaderBinary::ResourceLoaderBinary() : translation_remapped(false), + ver_format(0), f(NULL), + importmd_ofs(0), error(OK) { progress = nullptr; diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 504dbe2d63..5dca8b3b89 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -538,6 +538,7 @@ RES ResourceLoader::load(const String &p_path, const String &p_type_hint, bool p if (r_error) { *r_error = err; } + thread_load_mutex->unlock(); return RES(); } thread_load_mutex->unlock(); diff --git a/core/io/resource_loader.h b/core/io/resource_loader.h index 3b7a27f551..ea89917a5f 100644 --- a/core/io/resource_loader.h +++ b/core/io/resource_loader.h @@ -116,7 +116,7 @@ private: String type_hint; float progress = 0.0; ThreadLoadStatus status = THREAD_LOAD_IN_PROGRESS; - Error error; + Error error = OK; RES resource; bool xl_remapped = false; bool use_sub_threads = false; diff --git a/core/io/stream_peer_tcp.cpp b/core/io/stream_peer_tcp.cpp index 044431743a..f0c5816d73 100644 --- a/core/io/stream_peer_tcp.cpp +++ b/core/io/stream_peer_tcp.cpp @@ -288,6 +288,11 @@ void StreamPeerTCP::disconnect_from_host() { peer_port = 0; } +Error StreamPeerTCP::poll(NetSocket::PollType p_type, int timeout) { + ERR_FAIL_COND_V(_sock.is_null() || !_sock->is_open(), ERR_UNAVAILABLE); + return _sock->poll(p_type, timeout); +} + Error StreamPeerTCP::put_data(const uint8_t *p_data, int p_bytes) { int total; diff --git a/core/io/stream_peer_tcp.h b/core/io/stream_peer_tcp.h index f16d4a2bd4..327aa3cc3b 100644 --- a/core/io/stream_peer_tcp.h +++ b/core/io/stream_peer_tcp.h @@ -78,6 +78,9 @@ public: void set_no_delay(bool p_enabled); + // Poll functions (wait or check for writable, readable) + Error poll(NetSocket::PollType p_type, int timeout = 0); + // Read/Write from StreamPeer Error put_data(const uint8_t *p_data, int p_bytes); Error put_partial_data(const uint8_t *p_data, int p_bytes, int &r_sent); |