You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Ability to save objects to binary format
This commit is contained in:
@@ -35,9 +35,20 @@
|
||||
|
||||
PacketPeer::PacketPeer() {
|
||||
|
||||
allow_object_decoding = false;
|
||||
last_get_error = OK;
|
||||
}
|
||||
|
||||
void PacketPeer::set_allow_object_decoding(bool p_enable) {
|
||||
|
||||
allow_object_decoding = p_enable;
|
||||
}
|
||||
|
||||
bool PacketPeer::is_object_decoding_allowed() const {
|
||||
|
||||
return allow_object_decoding;
|
||||
}
|
||||
|
||||
Error PacketPeer::get_packet_buffer(PoolVector<uint8_t> &r_buffer) const {
|
||||
|
||||
const uint8_t *buffer;
|
||||
@@ -75,7 +86,7 @@ Error PacketPeer::get_var(Variant &r_variant) const {
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
return decode_variant(r_variant, buffer, buffer_size);
|
||||
return decode_variant(r_variant, buffer, buffer_size, NULL, allow_object_decoding);
|
||||
}
|
||||
|
||||
Error PacketPeer::put_var(const Variant &p_packet) {
|
||||
@@ -126,6 +137,9 @@ void PacketPeer::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("put_packet", "buffer"), &PacketPeer::_put_packet);
|
||||
ClassDB::bind_method(D_METHOD("get_packet_error"), &PacketPeer::_get_packet_error);
|
||||
ClassDB::bind_method(D_METHOD("get_available_packet_count"), &PacketPeer::get_available_packet_count);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_allow_object_decoding", "enable"), &PacketPeer::set_allow_object_decoding);
|
||||
ClassDB::bind_method(D_METHOD("is_object_decoding_allowed"), &PacketPeer::is_object_decoding_allowed);
|
||||
};
|
||||
|
||||
/***************/
|
||||
|
||||
Reference in New Issue
Block a user