summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSaracenOne <SaracenOne@gmail.com>2021-09-12 21:20:10 +0100
committerSaracenOne <SaracenOne@gmail.com>2021-09-12 21:20:10 +0100
commitdace12082b0604037f6d78299ae5928567aa800a (patch)
tree06225489cf30e93726a95a14fe94ec748e3a8f08 /core
parent5f69218edc4f4af574c7a65f077e2e0bf1f28365 (diff)
Fix custom multiplayer sync commands
Diffstat (limited to 'core')
-rw-r--r--core/multiplayer/multiplayer_replicator.cpp7
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);