maptool
maptool copied to clipboard
[Bug]: ClassCastException generated by Tokens with AStarCellPoints in LastPath
Describe the Bug
When loading older campaigns the tokens may have LastPath data using AStarCellPoints. This produces an exception causing the campaign load to fail.
java.lang.ClassCastException: class net.rptools.maptool.client.walker.astar.AStarCellPoint cannot be cast to class net.rptools.maptool.model.AbstractPoint (net.rptools.maptool.client.walker.astar.AStarCellPoint and net.rptools.maptool.model.AbstractPoint are in unnamed module of loader 'app')
at java.lang.Iterable.forEach(Iterable.java:75) ~[?:?]
at java.util.Collections$UnmodifiableCollection.forEach(Collections.java:1092) ~[?:?]
at net.rptools.maptool.model.Path.toDto(Path.java:288) ~[main/:?]
at net.rptools.maptool.model.Token.toDto(Token.java:2916) ~[main/:?]
at net.rptools.maptool.model.Zone.lambda$toDto$29(Zone.java:2273) ~[main/:?]
at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197) ~[?:?]
...
To Reproduce
- Load attached campaign file in 1.12 beta or current dev branch.
- See exception
Expected Behaviour
Bad path data should be corrected on load
Remove .zip from filename.
AStarCellPointError2.cmpgn.zip
.
Screenshots
No response
MapTool Info
Current Dev and 1.12.0 beta 1
Desktop
Windows 10
Additional Context
Partially corrected in PR #3504.
@Irarara you got this?
👍
Since it was brought up on discord, is there any desire to actually restore the data? It still doesn't really seem necessary to me (since any token with this issue literally hasn't been touched in years), but I can make it happen if others think it's worthwhile.
It guess it's the nice thing to do. In general I think it is handy to have last path preserved between sessions but as time goes on the information is probably less relevant. @kwvanderlinde @cwisniew @Azhrei thoughts?
I'm always in favour of backwards compatibility unless it is onerous to do so. In this case it shouldn't be too hard if we do the touch-ups in Path.readResolve() where we can modify the lists instead of in Token.readResolve() where we can't.
And just so it's out there, our hunch is correct and we are seeing AStarCellPoint come after CellPoint, like in this path:
[CellPoint[9,10], net.rptools.maptool.client.walker.astar.AStarCellPoint@896, net.rptools.maptool.client.walker.astar.AStarCellPoint@896]
Agreed. One thing MapTool has always been really good about is being able to read (even if not write) old campaigns, maps, and tokens.
I feel bad saying this after I oh so confidently declared I'd make it happen, but I'm actually running into all sorts of issues trying to restore the data. Modifying the list seems like a no-go, and I'm having issues with even just generating a new path using the old points. Does anyone have any ideas on how to approach this properly? Or would like to just take a stab at it themselves?
I'll take a look see if I can come up with something.
Hmm, this is going to be tricky. Since the structure of AStarCellPoint has changed, it's not as simple as just reading x/y from an AStarCellPoint instance. It may be time for some xstream magic.
@Irarara I'm happy to pick this up if you want. It is my fault for introducing this problem ...
Sounds good, thanks. 🙂
Tested. Example campaign no longer produces errors.