feat: Refactor MD5 hashing and update save game codec for compatibility with new payload format
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -183,9 +183,10 @@ void main() {
|
||||
final Uint8List encoded = codec.encode(file);
|
||||
final SaveGameFile decoded = codec.decode(encoded);
|
||||
|
||||
expect(decoded.slot, 0);
|
||||
expect(decoded.slot, 2);
|
||||
expect(decoded.description, 'Compatible Block Save');
|
||||
expect(decoded.createdAtMs, 0);
|
||||
expect(decoded.createdAtMs, 1234);
|
||||
expect(decoded.dataVersionName, file.dataVersionName);
|
||||
expect(
|
||||
decoded.snapshot.currentEpisodeIndex,
|
||||
file.snapshot.currentEpisodeIndex,
|
||||
@@ -193,6 +194,45 @@ void main() {
|
||||
expect(decoded.snapshot.currentLevelIndex, file.snapshot.currentLevelIndex);
|
||||
});
|
||||
|
||||
test('CompatibleSaveGameCodec preserves entity state fidelity', () {
|
||||
final WolfEngine engine = _buildEngine();
|
||||
engine.init();
|
||||
|
||||
final Guard guard =
|
||||
EntityRegistry.spawn(
|
||||
MapObject.guardStart,
|
||||
8.5,
|
||||
7.5,
|
||||
Difficulty.medium,
|
||||
engine.data.sprites.length,
|
||||
registry: engine.data.registry,
|
||||
)!
|
||||
as Guard
|
||||
..health = 5
|
||||
..state = EntityState.dead;
|
||||
engine.entities = <Entity>[guard];
|
||||
|
||||
final CompatibleSaveGameCodec codec = CompatibleSaveGameCodec();
|
||||
final SaveGameFile decoded = codec.decode(
|
||||
codec.encode(
|
||||
SaveGameFile(
|
||||
slot: 0,
|
||||
gameVersion: engine.data.version,
|
||||
dataVersionName: engine.data.dataVersion.name,
|
||||
description: 'Entity Fidelity',
|
||||
createdAtMs: 1,
|
||||
snapshot: engine.captureSaveState(),
|
||||
checksum: 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
|
||||
expect(decoded.snapshot.entities, hasLength(1));
|
||||
expect(decoded.snapshot.entities.first.kind, 'Guard');
|
||||
expect(decoded.snapshot.entities.first.state, EntityState.dead);
|
||||
expect(decoded.snapshot.entities.first.extraData['health'], 5);
|
||||
});
|
||||
|
||||
test('CompatibleSaveGameCodec decodes old envelope payload format', () {
|
||||
final WolfEngine engine = _buildEngine();
|
||||
engine.init();
|
||||
|
||||
Reference in New Issue
Block a user