KeenSoftwareHouse / SpaceEngineers

2.94k stars 894 forks source link

cannot sync created ships to clients. game/Mod API bug #42

Open fabricator77 opened 9 years ago

fabricator77 commented 9 years ago

Ongoing bug which means spawning prefab ships on a server/hosted game, doesn't work as only the host sees the spawned ship. This applies to Mod API calls, and to Exploration ship spawns.

I'm not able to debug this myself, so I'll document what I discovered so far. Not sure if this is a client or server problem. Also questions over if this is a design flaw relating to entity.Save = false creating a paradox (ship not saved to map, nor broadcast when clients first connect).

Let me know if you need an example mod to test this against.

MyAPIGateway.Multiplayer.SendEntitiesCreated(entitiesList); which ends up calling MySyncCreate.SendEntitiesCreated(entitiesList); which calls MySyncCreate.BuildCompressedMessage(...)

Tyrsis commented 9 years ago

I am not sure what you're seeing, but I use this heavily and if it didn't work a lot of my mods would not work. This function synchronizes grid creation just fine. So I think you need to expand on what you're experiencing and provide code you've tried.

fabricator77 commented 9 years ago

Simply put the problem is when a ship isn't saved to the map, and a client connects. In theory it should send the client that ship on connection, but it doesn't.

You already have the code, it's called Exploration. Simply put some debug code in MySyncCreate.SendEntitiesCreated, set up a server and a client. Find an exploration ship, log off and back on again.

There are a lot of bug reports on Keen's forum that involve Exploration ships vanishing on clients reconnecting, being invisible to some players and not others. Someone make an effort to debug this, as Keen don't seem to care.

Tyrsis commented 9 years ago

Ah I see, the problem you're reporting here is actually not in SendEntitiesCreated, but how exploration ships are sent to the client. This is a different issue. SendEntitiesCreated simply sends a grid to other clients that a grid has been created (and synchronizing the client to make that grid appear in the world for them). The exploration / procedural generated ship portion is completely different and tracked differently. I am not saying this is not a bug, just has nothing to do with this functionality.

No-Brain commented 9 years ago

The problem could be that the creation of exploration ships is not sent from the server at all but instead is inferred from the procedural settings of the world on the side of the client. This is to avoid sending massive amounts of data over the network to spawn the exploration ships. Since the client is too busy loading the world, it is possible for him to miss the conditions needed for the creation of the exploration ship. If this is the case, there are ways to fix it.

As for the SendEntitiesCreated(), could you create a script that demonstrates this issue?

midspace commented 9 years ago

I'm the same with @Tyrsis, my admin scripts use the SendEntitiesCreated and haven't had any issues with it.

Tyrsis commented 9 years ago

Yeah the real problem is probably as NoBrain said above in that there is a problem with the client possibly creating an exploration ship along with the server, and they are colliding? There is definitely something funky client-server wise with exploration ships (and why I disabled them, besides the huge amount of UPS drag it added to a server). They will regularly duplicate. I haven't looked at that part of the code really, but that sounds about what I've seen.