diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2021-09-14 21:27:12 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-14 21:27:12 +0200 |
commit | c5a979eba54fea9b68b76012c89b9095129473a8 (patch) | |
tree | f0541acbc92e16b4600633f91542a828081047da /core/multiplayer | |
parent | 3d577f065a873a4b8eabbad20ebd562a713a5a60 (diff) | |
parent | dace12082b0604037f6d78299ae5928567aa800a (diff) |
Merge pull request #52613 from V-Sekai/fix_custom_sync_commands
Fix custom multiplayer sync commands
Diffstat (limited to 'core/multiplayer')
-rw-r--r-- | core/multiplayer/multiplayer_replicator.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/core/multiplayer/multiplayer_replicator.cpp b/core/multiplayer/multiplayer_replicator.cpp index 17af2c5ef8..a4ea74327c 100644 --- a/core/multiplayer/multiplayer_replicator.cpp +++ b/core/multiplayer/multiplayer_replicator.cpp @@ -350,9 +350,9 @@ void MultiplayerReplicator::process_sync(int p_from, const uint8_t *p_packet, in } } PackedByteArray pba; - pba.resize(p_packet_len - SPAWN_CMD_OFFSET); + pba.resize(p_packet_len - SYNC_CMD_OFFSET); if (pba.size()) { - memcpy(pba.ptrw(), p_packet, p_packet_len - SPAWN_CMD_OFFSET); + memcpy(pba.ptrw(), p_packet + SYNC_CMD_OFFSET, p_packet_len - SYNC_CMD_OFFSET); } Variant args[4] = { p_from, id, objs, pba }; Variant *argp[4] = { args, &args[1], &args[2], &args[3] }; @@ -749,6 +749,9 @@ Error MultiplayerReplicator::send_sync(int p_peer_id, const ResourceUID::ID &p_s uint8_t *ptr = packet_cache.ptrw(); ptr[0] = MultiplayerAPI::NETWORK_COMMAND_SYNC; encode_uint64(p_scene_id, &ptr[1]); + if (p_data.size()) { + memcpy(&ptr[SYNC_CMD_OFFSET], p_data.ptr(), p_data.size()); + } Ref<MultiplayerPeer> peer = multiplayer->get_multiplayer_peer(); peer->set_target_peer(p_peer_id); peer->set_transfer_channel(p_channel); |