-
-
Notifications
You must be signed in to change notification settings - Fork 141
Standalone snapshot persistence #875
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| namespace Multiplayer.Common; | ||
|
|
||
| public enum JoinPointRequestReason : byte | ||
| { | ||
| Unknown = 0, | ||
| Save = 1, | ||
| WorldTravel = 2, | ||
| } |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,12 @@ | ||||||||||||||||
| namespace Multiplayer.Common.Networking.Packet; | ||||||||||||||||
|
|
||||||||||||||||
| [PacketDefinition(Packets.Client_Autosaving)] | ||||||||||||||||
| public record struct ClientAutosavingPacket(JoinPointRequestReason reason) : IPacket | ||||||||||||||||
| { | ||||||||||||||||
| public JoinPointRequestReason reason = reason; | ||||||||||||||||
|
|
||||||||||||||||
| public void Bind(PacketBuffer buf) | ||||||||||||||||
| { | ||||||||||||||||
|
||||||||||||||||
| { | |
| { | |
| if (!buf.DataRemaining) | |
| { | |
| reason = JoinPointRequestReason.Unknown; | |
| return; | |
| } |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,19 @@ | ||||||||||
| namespace Multiplayer.Common.Networking.Packet; | ||||||||||
|
|
||||||||||
| [PacketDefinition(Packets.Server_ProtocolOk)] | ||||||||||
| public record struct ServerProtocolOkPacket(bool hasPassword) : IPacket | ||||||||||
| public record struct ServerProtocolOkPacket(bool hasPassword, bool isStandaloneServer = false) : IPacket | ||||||||||
| { | ||||||||||
| public bool hasPassword = hasPassword; | ||||||||||
| public bool isStandaloneServer = isStandaloneServer; | ||||||||||
| public float autosaveInterval; | ||||||||||
| public AutosaveUnit autosaveUnit; | ||||||||||
|
|
||||||||||
| public void Bind(PacketBuffer buf) | ||||||||||
| { | ||||||||||
| buf.Bind(ref hasPassword); | ||||||||||
| buf.Bind(ref isStandaloneServer); | ||||||||||
|
||||||||||
| buf.Bind(ref isStandaloneServer); | |
| if (buf.DataRemaining) | |
| buf.Bind(ref isStandaloneServer); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| namespace Multiplayer.Common.Networking.Packet; | ||
|
|
||
| [PacketDefinition(Packets.Client_StandaloneWorldSnapshotUpload, allowFragmented: true)] | ||
| public record struct ClientStandaloneWorldSnapshotPacket : IPacket | ||
| { | ||
| public int tick; | ||
| public int leaseVersion; | ||
| public byte[] worldData; | ||
| public byte[] sessionData; | ||
| public byte[] sha256Hash; | ||
|
|
||
| public void Bind(PacketBuffer buf) | ||
| { | ||
| buf.Bind(ref tick); | ||
| buf.Bind(ref leaseVersion); | ||
| buf.BindBytes(ref worldData, maxLength: -1); | ||
| buf.BindBytes(ref sessionData, maxLength: -1); | ||
| buf.BindBytes(ref sha256Hash, maxLength: 32); | ||
| } | ||
| } | ||
|
|
||
| [PacketDefinition(Packets.Client_StandaloneMapSnapshotUpload, allowFragmented: true)] | ||
| public record struct ClientStandaloneMapSnapshotPacket : IPacket | ||
| { | ||
| public int mapId; | ||
| public int tick; | ||
| public int leaseVersion; | ||
| public byte[] mapData; | ||
| public byte[] sha256Hash; | ||
|
|
||
| public void Bind(PacketBuffer buf) | ||
| { | ||
| buf.Bind(ref mapId); | ||
| buf.Bind(ref tick); | ||
| buf.Bind(ref leaseVersion); | ||
| buf.BindBytes(ref mapData, maxLength: -1); | ||
| buf.BindBytes(ref sha256Hash, maxLength: 32); | ||
| } | ||
| } |
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.
DoAutosave sends JoinPointRequestReason.Save, and ServerPlayingState treats reason==Save as forceJoinPoint (bypassing the join point cooldown). That changes autosave behavior vs. the previous implementation (autosaves were not forced). Consider adding an Autosave enum value (or using Unknown) so only manual saves force join points.