joulupunikki / Phoenix

Java clone/remake/patch of the game Emperor of the Fading Suns
https://joulupunikki.github.io/Phoenix/
37 stars 14 forks source link

City Info Null Pointer on exit with selected space stack #105

Closed joulupunikki closed 7 years ago

joulupunikki commented 7 years ago
java.lang.NullPointerException
at util.Util.drawStackDisplay(Util.java:846)
at gui.SpaceWindow.renderSpaceWindow(SpaceWindow.java:250)

Fixed by noting that saved coordinates are already in space, so conversion must not be done in CIW::restoreCurrentSelectedStack(). After this, if the city is switched while in in CIW, on exit we may get

Thread[AWT-EventQueue-0,6,main]
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
    at java.util.LinkedList.checkElementIndex(LinkedList.java:555)
    at java.util.LinkedList.get(LinkedList.java:476)
    at util.Util.drawStackDisplay(Util.java:850)
    at gui.SpaceWindow.renderSpaceWindow(SpaceWindow.java:250)
    at gui.SpaceWindow.paintComponent(SpaceWindow.java:239)

which is fixed by copying the relevant Point-objects instead of the references in CIW::saveCurrentSelectedStack()

joulupunikki commented 7 years ago

Seems that we now get NPE:s when we try to copy the non-existent Point-objects of an unselected stack in CIW::saveCurrentSelectedStack()