Skip to content
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

Fix Format function to not cut of last character (fixes game save) #716

Merged
merged 1 commit into from
Oct 27, 2024

Conversation

zzam
Copy link
Contributor

@zzam zzam commented Oct 27, 2024

This fixes broke game save

The beginning of a broken saved game looks like this:

$ zcat ~/.config/stratagus/wc2/save/game.sav.gz|xxd -C|head -5
00000000: 6c6f 6361 6c20 6f6c 6443 7265 6174 6555  local oldCreateU
00000010: 6e69 7420 3d20 4372 6561 7465 556e 6974  nit = CreateUnit
00000020: 006c 6f63 616c 206f 6c64 5365 7452 6573  .local oldSetRes
00000030: 6f75 7263 6573 4865 6c64 203d 2053 6574  ourcesHeld = Set
00000040: 5265 736f 7572 6365 7348 656c 6400 6c6f  ResourcesHeld.lo

The newlines are replaced by null-characters so games could not be loaded again.

@zzam
Copy link
Contributor Author

zzam commented Oct 27, 2024

I wonder if it is possible to create a larger test that excercises SaveGame+LoadGame to detect such breakage.

@Jarod42
Copy link
Member

Jarod42 commented Oct 27, 2024

I wonder if it is possible to create a larger test that exercises SaveGame+LoadGame to detect such breakage.

Currently issue is to create such state.

Easier might be using existing savegame, and check that load+save give back same file.
But issue is backward compatibility enforcing/breaking.

This fixes broke game save

The beginning of a saved game looked like this:
00000000: 6c6f 6361 6c20 6f6c 6443 7265 6174 6555  local oldCreateU
00000010: 6e69 7420 3d20 4372 6561 7465 556e 6974  nit = CreateUnit
00000020: 006c 6f63 616c 206f 6c64 5365 7452 6573  .local oldSetRes
00000030: 6f75 7263 6573 4865 6c64 203d 2053 6574  ourcesHeld = Set
00000040: 5265 736f 7572 6365 7348 656c 6400 6c6f  ResourcesHeld.lo

The newlines are replaced by null-characters so games could not be
loaded again
@zzam zzam force-pushed the format-game-save branch from d7a987a to c861882 Compare October 27, 2024 10:00
@Jarod42 Jarod42 merged commit 06e608b into Wargus:master Oct 27, 2024
6 checks passed
@zzam zzam deleted the format-game-save branch October 27, 2024 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants