dcs-liberation / dcs_liberation

DCS World dynamic campaign.
GNU Lesser General Public License v3.0
721 stars 184 forks source link

Creating fighter sweep task breaks save loading #3288

Closed osiu97 closed 11 months ago

osiu97 commented 11 months ago

Affected versions

9.0.0

Build information

DCS Liberation 9.0.0

Description

I noticed in the 9.0.0 that i cannot load some saves of mine. Loading of these saves results with

  File "qt_ui\windows\QLiberationWindow.py", line 355, in openFile
  File "game\persistence\savemanager.py", line 101, in load_player_save
  File "game\persistence\savegamebundle.py", line 77, in load_player
  File "game\persistence\savegamebundle.py", line 94, in _load_from
  File "enum.py", line 712, in __call__
  File "enum.py", line 1135, in __new__
ValueError: {'id': 'WrappedAction', 'auto': False, 'enabled': True, 'params': {'action': {'id': 'Option', 'params': {'name': 5, 'value': 65538, 'formationIndex': 1, 'variantIndex': 2}}}, 'number': 1} is not a valid Formation

So I went looking in code to see what kind of the formation it is and found out it's LineAbreastOpen which looks to have same parameters as in the log entry, so I do not know why it really doesn't deserialize correctly. Anyway I noticed that this formation is primarily used in Fighter Sweep task so i tried to create steps to recreate this bug.:

Seems from the screenshots on #bug-discussion that people have similar problems but none of them result in broken saves, only in uncloseable window, so I do not know what's wrong with mine because I tested this on 3 computers (1 with DCS installed, 1 without and 1 in wine on Linux) and had the same results.

Anyone can test if they have same problem? I attached 3 save files from the steps, the fightersweep.liberation.zip shouldn't load. I also tried the dev build from b014f2e but it looks like it doesn't take 9.0 saves and I did not try recreating the bug there.

Save game and other files (save game required, bugs without saves will be closed)

fightersweep.liberation.zip tarcap.liberation.zip clean.liberation.zip liberation.log

DanAlbert commented 11 months ago

In any case, thank you for being the first to file the bug. This is the first I've heard of it.

Starfire13 commented 11 months ago

Yep, I am seeing the same thing on my end if there is a fighter sweep mission. This would be the cause of #3255. One of those things I never encounter because I don't ever use fighter sweep.

Screenshot 2023-12-09 083606

DanAlbert commented 11 months ago

Ah, my mistake, we have seen that before, we just couldn't figure it out :)

DanAlbert commented 11 months ago

I can't repro using your steps. I:

  1. downloaded clean.liberation.zip
  2. opened that
  3. opened the DEAD flight of DEAD AUROUCHS
  4. used "Recreate as Fighter sweep" in the Waypoints tab
  5. saved as broken.liberation.zip
  6. opened broken.liberation.zip
  7. closed liberation
  8. restarted and opened broken.liberation.zip again
  9. reopened clean.liberation.zip
  10. reopened broken.liberation.zip

Your fightersweep.liberation.zip is certainly broken though. Loading that up in the debugger and inspecting the two values, they are definitely identical. Formation.LINE_ABREAST_OPEN.value.__dict__ == value.__dict__ (value is the thing in the save that won't map to the enum), but Formation.LINE_ABREAST_OPEN.value != value. I've got no idea why that isn't consistently right or wrong though.

Starfire13 commented 11 months ago

I've found that creating any fighter sweep flight and then saving will break the save. You can also hit take off and abort to trigger the bug rather than saving and reloading the save, as aborting tries to load the autosave.

DanAlbert commented 11 months ago

I do see that OptFormation in pydcs (and all Task, for that matter) don't implement __eq__, so it's kind of amazing that this works at all. Implementing that does in fact fix this.

@Starfire13 huh, I'm still not able to. Could I get you to upload a busted save from the dev branch? I want to confirm that my fix actually works.

Starfire13 commented 11 months ago

@DanAlbert Here's a save I just generated on the latest dev build which is busted.

Fighter Sweep Test 1 #5719.liberation.zip