-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
State deltas for game updates of players and projectiles #888
Conversation
d56b809
to
e9f322d
Compare
e143d64
to
d2e2a11
Compare
22ff26e
to
fad6e0b
Compare
float radius = 6; | ||
repeated Position vertices = 7; | ||
optional float radius = 6; | ||
optional ListPositionPB vertices = 7; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting change that is needed for diffing lists under a specific scenario, otherwise its a near impossible task. So the scenarios
- If
new_list
is different thanold_list
(meaning not an exact match) the resulting delta isnew_list
- If
new_list
is exactly the same asold_list
the resulting delta isnil
(no delta)
To allow for that second scenario we would have needed a sort of optional repeated
field in protobuf, but this is not supported. So the second best thing is this solution where we wrap the list in another message. This wrapper becomes optional
and the inner only have the repeated
field
ACTIVE = 0; | ||
EXPLODED = 1; | ||
CONSUMED = 2; | ||
PROJECTILE_STATUS_UNDEFINED = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This new enum value PROJECTILE_STATUS_UNDEFINED
and the similar one in CrateStatus
is a protobuf best practice cause it been the 0 value will serve as the default for the enum. You are not supposed to actually have business logic tied to it, for example I only use it in the client as a null check
Additionally you probably noticed that its called PROJECTILE_STATUS_UNDEFINED
rather than UNDEFINED
that's cause the protobuf C# compiler didn't like 2 enums with a value named the same 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Warning
Needs to be merged with https://github.com/lambdaclass/champions_of_mirra/pull/2084
Motivation
Part of #494
Summary of changes
optional
, this allows to check if there are set or not. Otherwise default value for the type is implied (e.g. 0 for integers)vertices
to support deltasUNDEFINED
enums to use asnull
valuediff/2
to receive any 2 terms and output the resulting delta, check the code for a more thorough explanation and edge casesnil
due to the result of diffingobstacles
,bushes
, andcrates
. This 3 things represented more than 80% of the delta reduction that we could expect to achievegame_client
is broken due to this change. Fixing it should be a follow up to thisHow to test it?
Test with this client branch https://github.com/lambdaclass/champions_of_mirra/pull/2084
To test play as usual
We should be doing some load tests and profiling in apps to compare against not doing deltas
Checklist