From c78eba749d36c9b1c9c7baa238bd4440162fe3b3 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Sun, 18 Jun 2023 00:03:54 +0300 Subject: [PATCH] Only send spawns to the target players of the replicator --- source/game/replicator.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/source/game/replicator.cpp b/source/game/replicator.cpp index 64769e7..dff5d48 100644 --- a/source/game/replicator.cpp +++ b/source/game/replicator.cpp @@ -65,6 +65,9 @@ void Replicator::component_created(const Events::ComponentCreated &event) void Replicator::send_spawn(const ReplicatedEntity &re, int target) { + if(target<0 && players.empty()) + return; + const SpawnInfo &info = re.zygote->get_spawn_info(); Messages::SpawnEntity message; message.type = networking.intern_string(info.type_name); @@ -76,7 +79,10 @@ void Replicator::send_spawn(const ReplicatedEntity &re, int target) if(target>=0) networking.send(target, message); else - networking.send(message); + { + for(unsigned p: players) + networking.send(p, message); + } } void Replicator::receive(const Messages::SpawnEntity &message) -- 2.45.2