From: Mikko Rasa Date: Sat, 17 Jun 2023 21:03:54 +0000 (+0300) Subject: Only send spawns to the target players of the replicator X-Git-Url: https://git.tdb.fi/?a=commitdiff_plain;h=c78eba749d36c9b1c9c7baa238bd4440162fe3b3;p=libs%2Fgame.git Only send spawns to the target players of the replicator --- 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)