Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently we only do entity mapping when we deserialize a message, by looking at the
remote_to_local
map.We didn't do the reverse, which meant that sending a message referring to a local entity on the entity-receiver side was annoying on because the remote is the entity-sender so it wouldn't apply entity mapping.
Now we also apply entity mapping when we serialize a message, by using the
local_to_remote
map.I didn't implement this previously because of potential conflicts but I think that the risk of those is pretty small. It would require a user to have both client->server and server->client in the same game.
In the long-term I want to solve those conflicts by using pre-defined ID ranges.
In the meantime we can greatly improve ergonomics by enabling this feature.
The conflicts could be for example:
(basically the conflict happens if the server and client both spawn and replicate an entity with the same
Entity
)Client sends a message containing E2.
It maps it from local to remote: E1
Server receives the message with E1, it maps it from remote_to_local -> E3. (instead of just using the original E1)
Solutions to avoid these kinds of conflicts:
On the receiving side we would check this bit to know it entity-mapping has already been applied or not?
(or just 1 bit per message, but that seems expensive)