]> git.tdb.fi Git - libs/game.git/commitdiff
Only send spawns to the target players of the replicator
authorMikko Rasa <tdb@tdb.fi>
Sat, 17 Jun 2023 21:03:54 +0000 (00:03 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 17 Jun 2023 21:44:51 +0000 (00:44 +0300)
source/game/replicator.cpp

index 64769e76b1554b936fc536e023ff028b194f2a13..dff5d482a0094be0660edcd1d53b3216ee59d90e 100644 (file)
@@ -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)