Fix adventure quest dialogs repeating after load - #11719
Conversation
I believe when a similar issue came up previously, someone mentioned that the auto-calculated serial UIDs can vary between desktop and Android. What's going to happen if it doesn't match? |
|
@Jetz72 Good catch. If it didn't match then old saves would fail to load. I'm not positive the Android UID will be the same so I'll change the implementation to not rely on that. |
|
Ok, I believe this is a better solution. I revised the implementation so AdventureQuestData no longer pins the desktop-calculated UID or adds serialized fields. The private transient fields are excluded from both the serialized layout and automatic UID calculation, so removing them preserves each platform’s previous UID. Displayed state is now stored in DialogData, which already has an explicit cross-platform serialVersionUID = 1L. I also confirmed that AdventureQuestData retains its original calculated desktop UID so old saves will load just fine. |
Jetz72
left a comment
There was a problem hiding this comment.
Seems alright for now. The automatic UIDs are a problem that should be addressed at some point, but that'll need to be handled delicately.
Description
Quest-level prologue and epilogue dialogs were shown again after loading an Adventure save because their
prologueDisplayedandepilogueDisplayedflags were markedtransient. Java serialization therefore reset both flags tofalseon every load.Persist these flags so dialogs that have already been displayed remain dismissed across save/load cycles.
Why the explicit
serialVersionUID?AdventureQuestDatapreviously relied on Java's automatically generated serialization UID. Changing these fields from transient to persistent changes that generated UID, which would make existing Adventure saves fail to deserialize with anInvalidClassException.The explicit value
-859190699184917225Lis the UID calculated from the class before this change. Preserving that exact value keeps existing save files compatible; it is not a newly chosen or arbitrary identifier.Testing
mvn -pl forge-gui-mobile -am testAI assisted with development.