@series-inc/rundot-syncplay 6.0.0-rc.85 → 6.0.0-rc.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -0
- package/core/native/physics/box3d_adapter.cpp +98 -42
- package/core/native/physics/box3d_adapter.hpp +8 -0
- package/core/native/physics/box3d_world_backend.cpp +317 -42
- package/core/native/physics/cellular_field3d.cpp +13 -0
- package/core/native/physics/cellular_field3d.hpp +288 -0
- package/core/native/physics/cellular_field3d_abi_setup.inc +323 -0
- package/core/native/physics/cellular_field3d_checkpoints.inc +260 -0
- package/core/native/physics/cellular_field3d_codec.inc +317 -0
- package/core/native/physics/cellular_field3d_dirty.inc +203 -0
- package/core/native/physics/cellular_field3d_edits.inc +277 -0
- package/core/native/physics/cellular_field3d_internal.hpp +249 -0
- package/core/native/physics/cellular_field3d_lifecycle.inc +273 -0
- package/core/native/physics/cellular_field3d_pages.inc +388 -0
- package/core/native/physics/cellular_field3d_queries.inc +400 -0
- package/core/native/physics/cellular_field3d_serialize.inc +393 -0
- package/core/native/physics/cellular_field3d_step.inc +349 -0
- package/core/native/physics/cellular_mesher3d.cpp +1118 -0
- package/core/native/physics/cellular_mesher3d.hpp +184 -0
- package/core/native/physics/cellular_teardown3d.cpp +684 -0
- package/core/native/physics/cellular_teardown3d.hpp +195 -0
- package/core/native/physics/cellular_teardown3d_islands.inc +357 -0
- package/core/native/physics/cellular_teardown3d_pages.inc +467 -0
- package/core/native/physics/cellular_teardown3d_snapshot.inc +285 -0
- package/core/native/physics/cellular_teardown3d_stream.inc +267 -0
- package/core/native/physics/voxel_cooking.cpp +48 -13
- package/core/native/physics/world.cpp +686 -174
- package/core/native/physics/world.hpp +60 -18
- package/core/render-projection.d.ts +142 -1
- package/core/runtime.d.ts +53 -0
- package/core/scripts/build-native.mjs +22 -0
- package/core/scripts/build-wasm-physics.mjs +99 -0
- package/core/src/kinetix-owned-runtime-adapter.mjs +361 -2
- package/core/src/kinetix-render-projection.mjs +414 -0
- package/core/src/kinetix-runtime-adapter-utils.mjs +240 -1
- package/core/src/kinetix-runtime-contract.mjs +19 -0
- package/core/src/physics/cellular-field3d.d.mts +261 -0
- package/core/src/physics/cellular-field3d.mjs +1406 -0
- package/core/src/physics/cellular-mesher3d.d.mts +196 -0
- package/core/src/physics/cellular-mesher3d.mjs +1291 -0
- package/core/src/physics/cellular-teardown-lz4.d.mts +17 -0
- package/core/src/physics/cellular-teardown-lz4.mjs +231 -0
- package/core/src/physics/cellular-teardown3d.d.mts +210 -0
- package/core/src/physics/cellular-teardown3d.mjs +678 -0
- package/core/src/physics/physics-profile-wasm-module.generated.mjs +5 -5
- package/core/src/physics/physics-profile.wasm +0 -0
- package/core/src/physics/physics-wasm-module.generated.mjs +5 -5
- package/core/src/physics/physics.wasm +0 -0
- package/core/src/physics/voxel-cooking.d.mts +9 -2
- package/core/src/physics/voxel-cooking.mjs +20 -8
- package/core/src/physics2d/physics2d-wasm-module.generated.mjs +1 -1
- package/core/src/runtime.mjs +1 -0
- package/dist/authority-room.d.ts +17 -1
- package/dist/authority-room.js +119 -9
- package/dist/browser.d.ts +13 -5
- package/dist/browser.js +8 -3
- package/dist/dev-authority-room.d.ts +6 -1
- package/dist/dev-authority-room.js +12 -0
- package/dist/index.d.ts +13 -6
- package/dist/index.js +8 -3
- package/dist/local-authority-wire.d.ts +24 -0
- package/dist/local-authority-wire.js +258 -4
- package/dist/networked-client.d.ts +27 -0
- package/dist/networked-client.js +622 -96
- package/dist/node.d.ts +2 -0
- package/dist/node.js +2 -0
- package/dist/physics/3d.d.ts +6 -1
- package/dist/physics/3d.js +5 -1
- package/dist/physics/cellular-field3d.d.ts +42 -0
- package/dist/physics/cellular-field3d.js +8 -0
- package/dist/physics/cellular-mesher3d.d.ts +1 -0
- package/dist/physics/cellular-mesher3d.js +1 -0
- package/dist/physics/cellular-teardown-snapshot-codec3d.d.ts +14 -0
- package/dist/physics/cellular-teardown-snapshot-codec3d.js +10 -0
- package/dist/physics/cellular-teardown-worker3d.d.ts +21 -0
- package/dist/physics/cellular-teardown-worker3d.js +245 -0
- package/dist/physics/cellular-teardown3d.d.ts +214 -0
- package/dist/physics/cellular-teardown3d.js +595 -0
- package/dist/physics/installed-checkpoint3d.d.ts +11 -1
- package/dist/physics/installed-checkpoint3d.js +130 -1
- package/dist/physics/installed-runtime3d.d.ts +16 -0
- package/dist/physics/installed-runtime3d.js +179 -18
- package/dist/physics/installed-state-commitment3d.d.ts +8 -2
- package/dist/physics/installed-state-commitment3d.js +63 -9
- package/dist/physics/voxel-body-split.d.ts +46 -0
- package/dist/physics/voxel-body-split.js +327 -0
- package/dist/physics/voxel-body-state.d.ts +49 -4
- package/dist/physics/voxel-body-state.js +236 -32
- package/dist/r3f-render-adapter.d.ts +113 -0
- package/dist/r3f-render-adapter.js +366 -0
- package/dist/run-room-transport.d.ts +6 -0
- package/dist/run-room-transport.js +88 -14
- package/dist/runtime-session.d.ts +37 -2
- package/dist/runtime-session.js +270 -4
- package/dist/session-snapshot.d.ts +60 -27
- package/dist/session-snapshot.js +565 -58
- package/dist/snapshot-baseline-delta.d.ts +65 -0
- package/dist/snapshot-baseline-delta.js +605 -0
- package/dist/snapshot-compression.d.ts +48 -0
- package/dist/snapshot-compression.js +433 -0
- package/dist/snapshot-worker.d.ts +47 -0
- package/dist/snapshot-worker.js +804 -0
- package/dist/state-digest.d.ts +8 -0
- package/dist/state-digest.js +34 -0
- package/dist/ws-frame.d.ts +7 -1
- package/dist/ws-frame.js +113 -10
- package/package.json +3 -3
- package/third_party/box3d/UPSTREAM.json +2 -2
- package/third_party/box3d/tree/src/syncplay_snapshot.c +13 -1
- package/third_party/box3d/tree/src/world_snapshot.c +143 -42
package/README.md
CHANGED
|
@@ -685,3 +685,17 @@ This absence check does not prove which world first allocated the removed ID.
|
|
|
685
685
|
`voxelBodyDigest3D(state)` returns the cached SHA-256 content digest. Creation, edits, and hydration compute this digest once per immutable root. Repeated reads do not scan cells or cooked children. The digest includes the body ID, revision, dimensions, occupancy, materials, child IDs and descriptors, next ID, cell mass, origin offset, and child limit. Hydrate a copied or decoded root before you read its digest or use it in carve, paint, or remove. These operations accept only roots registered by this module instance. If two package copies load, hydrate the root in the receiving copy.
|
|
686
686
|
|
|
687
687
|
Pass the current voxel root to each edit. Native validation detects differences in geometry and mass. It cannot detect a stale root that differs only in paint. Keep the returned root in canonical game state. Use that root for each later cut, paint, or removal.
|
|
688
|
+
|
|
689
|
+
## Voxel simulation and binary snapshots
|
|
690
|
+
|
|
691
|
+
`/physics/3d` provides native `CellularField3D`, greedy AO meshing with packed
|
|
692
|
+
16-byte vertices, and a separate sparse `CellularTeardownArena3D`. The
|
|
693
|
+
[physics reference](../sdk-docs/rundot-developer-platform/api/SYNCPLAY-PHYSICS.md#cellular-voxel-fields-and-sparse-destruction-arenas)
|
|
694
|
+
gives the APIs, ownership, and limits. The render adapter supplies dirty-chunk
|
|
695
|
+
projection and packed attribute data. The game connects those outputs to its
|
|
696
|
+
renderer.
|
|
697
|
+
|
|
698
|
+
Session snapshots use binary transfer, LZ4-style compression, seed-baseline
|
|
699
|
+
page deltas, and optional pinned asynchronous donation. Read
|
|
700
|
+
[binary snapshots](../sdk-docs/rundot-developer-platform/api/SYNCPLAY.md#binary-snapshots-and-baseline-deltas)
|
|
701
|
+
before you change the transport or the size limits.
|
|
@@ -14551,7 +14551,7 @@ b3ShapeId canonicalShapeHandle(const WorldSlot& world, std::uint32_t slot,
|
|
|
14551
14551
|
// list does not carry is a named failure: the record then has no shape to write.
|
|
14552
14552
|
bool findPrimaryShape(const WorldSlot& world, b3BodyId body, std::uint32_t shapeSlot,
|
|
14553
14553
|
b3ShapeId* outShape) {
|
|
14554
|
-
b3ShapeId shapes[kCanonicalBodyShapes]
|
|
14554
|
+
b3ShapeId shapes[kCanonicalBodyShapes];
|
|
14555
14555
|
const int shapeCount = b3Body_GetShapes(body, shapes, static_cast<int>(kCanonicalBodyShapes));
|
|
14556
14556
|
for (int index = 0; index < shapeCount; ++index) {
|
|
14557
14557
|
if (static_cast<std::uint32_t>(shapes[index].index1 - 1) != shapeSlot) continue;
|
|
@@ -14567,6 +14567,8 @@ struct CanonicalJointRef {
|
|
|
14567
14567
|
b3JointId handle = {};
|
|
14568
14568
|
};
|
|
14569
14569
|
|
|
14570
|
+
b3ShapeId g_primaryShapeScratch[kMaxBodies];
|
|
14571
|
+
|
|
14570
14572
|
// Rebuild the adapter records of a state-replacing canonical restore. The fork restore already put
|
|
14571
14573
|
// the Box3D bodies, shapes, and joints of the image in place, so a record is the image identity row
|
|
14572
14574
|
// proven against that world. Phase 1 proves every row and phase 2 writes it, so a rejected image
|
|
@@ -14584,7 +14586,7 @@ std::int32_t rebuildCanonicalRecords(WorldSlot& world, const unsigned char* byte
|
|
|
14584
14586
|
return kSyncplayAdapterCheckpointCorrupt;
|
|
14585
14587
|
}
|
|
14586
14588
|
unsigned char liveType[kMaxBodies];
|
|
14587
|
-
|
|
14589
|
+
std::memset(liveType, 0xff, sizeof(liveType));
|
|
14588
14590
|
for (std::uint32_t index = 0; index < rowCount; ++index) {
|
|
14589
14591
|
const syncplay_body_row& row = g_bodyRowScratch[index];
|
|
14590
14592
|
if (row.bodyId < 0 || static_cast<std::uint32_t>(row.bodyId) >= kMaxBodies) {
|
|
@@ -14607,7 +14609,7 @@ std::int32_t rebuildCanonicalRecords(WorldSlot& world, const unsigned char* byte
|
|
|
14607
14609
|
|
|
14608
14610
|
// Phase 1: prove every body row, then every joint row, against the restored world.
|
|
14609
14611
|
std::uint32_t slotLogical[kMaxBodies];
|
|
14610
|
-
|
|
14612
|
+
std::memset(slotLogical, 0, sizeof(slotLogical));
|
|
14611
14613
|
CanonicalBodyIdSet seenLogical;
|
|
14612
14614
|
CanonicalJointRef jointRefs[kMaxJoints];
|
|
14613
14615
|
std::uint32_t jointRefCount = 0;
|
|
@@ -14633,6 +14635,7 @@ std::int32_t rebuildCanonicalRecords(WorldSlot& world, const unsigned char* byte
|
|
|
14633
14635
|
g_canonicalError.format("shape slot %lld", static_cast<long long>(row.shapeSlot));
|
|
14634
14636
|
return kSyncplayAdapterCheckpointCorrupt;
|
|
14635
14637
|
}
|
|
14638
|
+
g_primaryShapeScratch[index] = shape;
|
|
14636
14639
|
// A mesh, height field, or compound shape points at the geometry registry of the image. The fork
|
|
14637
14640
|
// keeps that registry alive for the life of the restored world (syncplay_world_canonical_commit
|
|
14638
14641
|
// and syncplay_world_canonical_release in syncplay_snapshot.h), so a rebuilt record holds a
|
|
@@ -14643,8 +14646,11 @@ std::int32_t rebuildCanonicalRecords(WorldSlot& world, const unsigned char* byte
|
|
|
14643
14646
|
return kSyncplayAdapterCheckpointCorrupt;
|
|
14644
14647
|
}
|
|
14645
14648
|
|
|
14646
|
-
b3JointId joints[kMaxJoints]
|
|
14647
|
-
const int jointCount =
|
|
14649
|
+
b3JointId joints[kMaxJoints];
|
|
14650
|
+
const int jointCount =
|
|
14651
|
+
b3Body_GetJointCount(body) > 0
|
|
14652
|
+
? b3Body_GetJoints(body, joints, static_cast<int>(kMaxJoints))
|
|
14653
|
+
: 0;
|
|
14648
14654
|
for (int jointIndex = 0; jointIndex < jointCount; ++jointIndex) {
|
|
14649
14655
|
const std::uint32_t slot = static_cast<std::uint32_t>(joints[jointIndex].index1 - 1);
|
|
14650
14656
|
bool known = false;
|
|
@@ -14721,8 +14727,7 @@ std::int32_t rebuildCanonicalRecords(WorldSlot& world, const unsigned char* byte
|
|
|
14721
14727
|
entry.logicalId = row.logicalId;
|
|
14722
14728
|
entry.type = liveType[row.bodySlot];
|
|
14723
14729
|
entry.body = canonicalBodyHandle(world, row.bodySlot, row.bodyGeneration);
|
|
14724
|
-
b3ShapeId shape =
|
|
14725
|
-
findPrimaryShape(world, entry.body, row.shapeSlot, &shape);
|
|
14730
|
+
const b3ShapeId shape = g_primaryShapeScratch[index];
|
|
14726
14731
|
entry.shape = shape;
|
|
14727
14732
|
// A mesh and a height field own no adapter allocation after a rebuilt restore: the geometry of
|
|
14728
14733
|
// the image lives in the fork registry, which the fork keeps alive until the world is destroyed.
|
|
@@ -14792,23 +14797,56 @@ std::int32_t syncplay_adapter_canonical_size(std::uint32_t slot, std::uint32_t*
|
|
|
14792
14797
|
return kSyncplayAdapterOk;
|
|
14793
14798
|
}
|
|
14794
14799
|
|
|
14795
|
-
std::int32_t
|
|
14796
|
-
|
|
14797
|
-
|
|
14800
|
+
std::int32_t syncplay_adapter_canonical_save_ex(std::uint32_t slot, void* buffer,
|
|
14801
|
+
std::uint32_t capacity,
|
|
14802
|
+
std::uint32_t* outSize,
|
|
14803
|
+
std::uint32_t computeForkDigest) {
|
|
14798
14804
|
WorldSlot* world = getWorld(slot);
|
|
14799
14805
|
if (world == nullptr) return kSyncplayAdapterBadWorld;
|
|
14800
14806
|
if (outSize == nullptr) return kSyncplayAdapterBadArgument;
|
|
14801
14807
|
world->checkpointsCreated = true;
|
|
14802
14808
|
*outSize = 0;
|
|
14803
|
-
std::
|
|
14804
|
-
const std::
|
|
14805
|
-
if (
|
|
14806
|
-
|
|
14807
|
-
|
|
14808
|
-
return
|
|
14809
|
+
const std::uint64_t suffixBytes = canonicalSuffixSize(*world);
|
|
14810
|
+
const std::uint64_t fixedBytes = kCanonicalPrefixSize + suffixBytes;
|
|
14811
|
+
if (buffer == nullptr || static_cast<std::uint64_t>(capacity) <= fixedBytes) {
|
|
14812
|
+
std::uint32_t required = 0;
|
|
14813
|
+
const std::int32_t sizeStatus = syncplay_adapter_canonical_size(slot, &required);
|
|
14814
|
+
if (sizeStatus != kSyncplayAdapterOk) return sizeStatus;
|
|
14815
|
+
if (capacity < required) {
|
|
14816
|
+
*outSize = required;
|
|
14817
|
+
return kSyncplayAdapterCapacity;
|
|
14818
|
+
}
|
|
14819
|
+
return kSyncplayAdapterBadArgument;
|
|
14809
14820
|
}
|
|
14810
|
-
|
|
14821
|
+
|
|
14811
14822
|
auto* bytes = static_cast<unsigned char*>(buffer);
|
|
14823
|
+
const std::uint32_t forkCap =
|
|
14824
|
+
static_cast<std::uint32_t>(static_cast<std::uint64_t>(capacity) - fixedBytes);
|
|
14825
|
+
std::uint32_t forkWritten = 0;
|
|
14826
|
+
g_activeSlot = static_cast<int>(slot);
|
|
14827
|
+
std::int32_t forkStatus = SYNCPLAY_SNAPSHOT_OK;
|
|
14828
|
+
{
|
|
14829
|
+
const ScratchAllocationScope scratch;
|
|
14830
|
+
forkStatus = syncplay_world_canonical_save(
|
|
14831
|
+
world->worldIndex, bytes + kCanonicalPrefixSize, forkCap, &forkWritten);
|
|
14832
|
+
}
|
|
14833
|
+
g_activeSlot = -1;
|
|
14834
|
+
if (forkStatus == SYNCPLAY_SNAPSHOT_CAPACITY) {
|
|
14835
|
+
const std::uint64_t total = fixedBytes + static_cast<std::uint64_t>(forkWritten);
|
|
14836
|
+
if (total > 0xffffffffull) return kSyncplayAdapterCapacity;
|
|
14837
|
+
*outSize = static_cast<std::uint32_t>(total);
|
|
14838
|
+
return kSyncplayAdapterCapacity;
|
|
14839
|
+
}
|
|
14840
|
+
if (forkStatus != SYNCPLAY_SNAPSHOT_OK) {
|
|
14841
|
+
return kSyncplayAdapterCheckpointCorrupt;
|
|
14842
|
+
}
|
|
14843
|
+
const std::uint64_t total = fixedBytes + static_cast<std::uint64_t>(forkWritten);
|
|
14844
|
+
if (total > 0xffffffffull || total > static_cast<std::uint64_t>(capacity)) {
|
|
14845
|
+
return kSyncplayAdapterCheckpointCorrupt;
|
|
14846
|
+
}
|
|
14847
|
+
const std::uint32_t forkSize = forkWritten;
|
|
14848
|
+
const std::uint32_t required = static_cast<std::uint32_t>(total);
|
|
14849
|
+
|
|
14812
14850
|
std::memset(bytes, 0, kCanonicalPrefixSize);
|
|
14813
14851
|
std::memcpy(bytes, "SYNCB3C1", 8);
|
|
14814
14852
|
Cursor cursor{bytes, kCanonicalPrefixSize, 8, true};
|
|
@@ -14824,8 +14862,6 @@ std::int32_t syncplay_adapter_canonical_save(std::uint32_t slot, void* buffer,
|
|
|
14824
14862
|
putU32(cursor, world->fluidCount);
|
|
14825
14863
|
putU32(cursor, world->fluidInteractionCount);
|
|
14826
14864
|
putU32(cursor, world->nextLogicalId);
|
|
14827
|
-
const std::uint32_t forkSize = static_cast<std::uint32_t>(
|
|
14828
|
-
required - kCanonicalPrefixSize - canonicalSuffixSize(*world));
|
|
14829
14865
|
putU32(cursor, forkSize);
|
|
14830
14866
|
CheckpointIdentity identity = identityOf(*world);
|
|
14831
14867
|
if (world->canonicalSceneHash != 0) {
|
|
@@ -14847,23 +14883,13 @@ std::int32_t syncplay_adapter_canonical_save(std::uint32_t slot, void* buffer,
|
|
|
14847
14883
|
putU32(cursor, canonicalJointExtraRowCount(*world));
|
|
14848
14884
|
if (!cursor.ok) return kSyncplayAdapterCheckpointCorrupt;
|
|
14849
14885
|
|
|
14850
|
-
|
|
14851
|
-
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14855
|
-
|
|
14856
|
-
world->worldIndex, bytes + kCanonicalPrefixSize, forkSize, &forkWritten);
|
|
14857
|
-
}
|
|
14858
|
-
g_activeSlot = -1;
|
|
14859
|
-
if (forkStatus != SYNCPLAY_SNAPSHOT_OK || forkWritten != forkSize) {
|
|
14860
|
-
return kSyncplayAdapterCheckpointCorrupt;
|
|
14886
|
+
if (computeForkDigest != 0) {
|
|
14887
|
+
const std::uint64_t geometryDigest =
|
|
14888
|
+
syncplay_fnv1a64(bytes + kCanonicalPrefixSize, forkSize, SYNCPLAY_FNV1A64_OFFSET);
|
|
14889
|
+
Cursor geometryCursor{bytes, kCanonicalPrefixSize, geometryDigestOffset, true};
|
|
14890
|
+
putU64(geometryCursor, geometryDigest);
|
|
14891
|
+
if (!geometryCursor.ok) return kSyncplayAdapterCheckpointCorrupt;
|
|
14861
14892
|
}
|
|
14862
|
-
const std::uint64_t geometryDigest =
|
|
14863
|
-
syncplay_fnv1a64(bytes + kCanonicalPrefixSize, forkSize, SYNCPLAY_FNV1A64_OFFSET);
|
|
14864
|
-
Cursor geometryCursor{bytes, kCanonicalPrefixSize, geometryDigestOffset, true};
|
|
14865
|
-
putU64(geometryCursor, geometryDigest);
|
|
14866
|
-
if (!geometryCursor.ok) return kSyncplayAdapterCheckpointCorrupt;
|
|
14867
14893
|
Cursor suffix{bytes, required, kCanonicalPrefixSize + forkSize, true};
|
|
14868
14894
|
for (std::uint32_t index = 0; index < world->eventCount; ++index) {
|
|
14869
14895
|
const EventRow& event = world->events[index];
|
|
@@ -14964,6 +14990,28 @@ std::int32_t syncplay_adapter_canonical_save(std::uint32_t slot, void* buffer,
|
|
|
14964
14990
|
return kSyncplayAdapterOk;
|
|
14965
14991
|
}
|
|
14966
14992
|
|
|
14993
|
+
std::int32_t syncplay_adapter_canonical_save(std::uint32_t slot, void* buffer,
|
|
14994
|
+
std::uint32_t capacity,
|
|
14995
|
+
std::uint32_t* outSize) {
|
|
14996
|
+
return syncplay_adapter_canonical_save_ex(slot, buffer, capacity, outSize, 1u);
|
|
14997
|
+
}
|
|
14998
|
+
|
|
14999
|
+
std::int32_t syncplay_adapter_canonical_materialize_digest(void* buffer, std::uint32_t size) {
|
|
15000
|
+
if (buffer == nullptr || size < kCanonicalPrefixSize) return kSyncplayAdapterBadArgument;
|
|
15001
|
+
auto* bytes = static_cast<unsigned char*>(buffer);
|
|
15002
|
+
if (std::memcmp(bytes, "SYNCB3C1", 8) != 0) return kSyncplayAdapterCheckpointVersionMismatch;
|
|
15003
|
+
Cursor forkCursor{bytes, kCanonicalPrefixSize, 60, true};
|
|
15004
|
+
const std::uint32_t forkSize = getU32(forkCursor);
|
|
15005
|
+
if (!forkCursor.ok || forkSize == 0 || forkSize > size - kCanonicalPrefixSize) {
|
|
15006
|
+
return kSyncplayAdapterCheckpointCorrupt;
|
|
15007
|
+
}
|
|
15008
|
+
const std::uint64_t geometryDigest =
|
|
15009
|
+
syncplay_fnv1a64(bytes + kCanonicalPrefixSize, forkSize, SYNCPLAY_FNV1A64_OFFSET);
|
|
15010
|
+
Cursor digestCursor{bytes, kCanonicalPrefixSize, kCanonicalExtrasCountOffset - 8, true};
|
|
15011
|
+
putU64(digestCursor, geometryDigest);
|
|
15012
|
+
return digestCursor.ok ? kSyncplayAdapterOk : kSyncplayAdapterCheckpointCorrupt;
|
|
15013
|
+
}
|
|
15014
|
+
|
|
14967
15015
|
std::int32_t syncplay_adapter_sha256(const void* data, std::uint32_t size,
|
|
14968
15016
|
unsigned char out[32]) {
|
|
14969
15017
|
return strongDigest(data, size, out) ? kSyncplayAdapterOk : kSyncplayAdapterBadArgument;
|
|
@@ -15183,8 +15231,9 @@ std::int32_t syncplay_adapter_retained_stats(std::uint64_t* out, std::uint32_t c
|
|
|
15183
15231
|
return kSyncplayAdapterOk;
|
|
15184
15232
|
}
|
|
15185
15233
|
|
|
15186
|
-
std::int32_t
|
|
15187
|
-
|
|
15234
|
+
std::int32_t syncplay_adapter_canonical_restore_ex(std::uint32_t slot, const void* buffer,
|
|
15235
|
+
std::uint32_t size,
|
|
15236
|
+
std::uint32_t verifyForkDigest) {
|
|
15188
15237
|
g_canonicalError.clear();
|
|
15189
15238
|
WorldSlot* world = getWorld(slot);
|
|
15190
15239
|
if (world == nullptr) return kSyncplayAdapterBadWorld;
|
|
@@ -15266,11 +15315,13 @@ std::int32_t syncplay_adapter_canonical_restore(std::uint32_t slot, const void*
|
|
|
15266
15315
|
g_canonicalError.format("world index %lld != %lld", static_cast<long long>(worldIndex), static_cast<long long>(identity.worldIndex));
|
|
15267
15316
|
return kSyncplayAdapterCheckpointIdentityMismatch;
|
|
15268
15317
|
}
|
|
15269
|
-
|
|
15270
|
-
|
|
15271
|
-
|
|
15272
|
-
|
|
15273
|
-
|
|
15318
|
+
if (verifyForkDigest != 0) {
|
|
15319
|
+
const std::uint64_t actualGeometryDigest =
|
|
15320
|
+
syncplay_fnv1a64(bytes + kCanonicalPrefixSize, forkSize, SYNCPLAY_FNV1A64_OFFSET);
|
|
15321
|
+
if (geometryDigest != actualGeometryDigest) {
|
|
15322
|
+
g_canonicalError = "geometry digest";
|
|
15323
|
+
return kSyncplayAdapterCheckpointCorrupt;
|
|
15324
|
+
}
|
|
15274
15325
|
}
|
|
15275
15326
|
const std::uint64_t required =
|
|
15276
15327
|
kCanonicalPrefixSize + static_cast<std::uint64_t>(forkSize) + eventCount * 64ull +
|
|
@@ -15629,6 +15680,11 @@ std::int32_t syncplay_adapter_canonical_restore(std::uint32_t slot, const void*
|
|
|
15629
15680
|
return kSyncplayAdapterOk;
|
|
15630
15681
|
}
|
|
15631
15682
|
|
|
15683
|
+
std::int32_t syncplay_adapter_canonical_restore(std::uint32_t slot, const void* buffer,
|
|
15684
|
+
std::uint32_t size) {
|
|
15685
|
+
return syncplay_adapter_canonical_restore_ex(slot, buffer, size, 1u);
|
|
15686
|
+
}
|
|
15687
|
+
|
|
15632
15688
|
std::int32_t syncplay_adapter_hash_bytes(const void* data, std::uint32_t size, std::uint64_t seed,
|
|
15633
15689
|
std::uint64_t* outDigest) {
|
|
15634
15690
|
if (outDigest == nullptr) return kSyncplayAdapterBadArgument;
|
|
@@ -1113,6 +1113,11 @@ std::int32_t syncplay_adapter_canonical_size(std::uint32_t slot, std::uint32_t*
|
|
|
1113
1113
|
std::int32_t syncplay_adapter_canonical_save(std::uint32_t slot, void* buffer,
|
|
1114
1114
|
std::uint32_t capacity,
|
|
1115
1115
|
std::uint32_t* outSize);
|
|
1116
|
+
std::int32_t syncplay_adapter_canonical_save_ex(std::uint32_t slot, void* buffer,
|
|
1117
|
+
std::uint32_t capacity,
|
|
1118
|
+
std::uint32_t* outSize,
|
|
1119
|
+
std::uint32_t computeForkDigest);
|
|
1120
|
+
std::int32_t syncplay_adapter_canonical_materialize_digest(void* buffer, std::uint32_t size);
|
|
1116
1121
|
std::int32_t syncplay_adapter_sha256(const void* data, std::uint32_t size,
|
|
1117
1122
|
unsigned char out[32]);
|
|
1118
1123
|
std::int32_t syncplay_adapter_canonical_strong_digest(std::uint32_t slot,
|
|
@@ -1134,6 +1139,9 @@ std::int32_t syncplay_adapter_arena_stats(std::uint32_t slot, std::uint64_t* out
|
|
|
1134
1139
|
|
|
1135
1140
|
std::int32_t syncplay_adapter_canonical_restore(std::uint32_t slot, const void* buffer,
|
|
1136
1141
|
std::uint32_t size);
|
|
1142
|
+
std::int32_t syncplay_adapter_canonical_restore_ex(std::uint32_t slot, const void* buffer,
|
|
1143
|
+
std::uint32_t size,
|
|
1144
|
+
std::uint32_t verifyForkDigest);
|
|
1137
1145
|
const char* syncplay_adapter_canonical_error();
|
|
1138
1146
|
|
|
1139
1147
|
std::int32_t syncplay_adapter_hash_bytes(const void* data, std::uint32_t size, std::uint64_t seed,
|