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

Crash when ending a one game duel. #611

Closed
lodici opened this issue Dec 28, 2015 · 10 comments
Closed

Crash when ending a one game duel. #611

lodici opened this issue Dec 28, 2015 · 10 comments
Assignees
Labels

Comments

@lodici
Copy link
Member

lodici commented Dec 28, 2015

Raised in forum.

To replicate

  • New Duel.
  • Set Max games. to 1.
  • Start duel.
  • Concede and click next to end.
Exception from controller.runGame: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 2
java.lang.RuntimeException: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 2
    at magic.ui.screen.DuelDecksScreen$StartupWorker.getNextGame(DuelDecksScreen.java:329)
    at magic.ui.screen.DuelDecksScreen$StartupWorker.done(DuelDecksScreen.java:321)
    at javax.swing.SwingWorker$5.run(SwingWorker.java:737)
    at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.run(SwingWorker.java:832)
    at sun.swing.AccumulativeRunnable.run(AccumulativeRunnable.java:112)
    at javax.swing.SwingWorker$DoSubmitAccumulativeRunnable.actionPerformed(SwingWorker.java:842)
    at javax.swing.Timer.fireActionPerformed(Timer.java:313)
    at javax.swing.Timer$DoPostEvent.run(Timer.java:245)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
Caused by: java.util.concurrent.ExecutionException: java.lang.ArrayIndexOutOfBoundsException: 2
    at java.util.concurrent.FutureTask.report(FutureTask.java:122)
    at java.util.concurrent.FutureTask.get(FutureTask.java:192)
    at javax.swing.SwingWorker.get(SwingWorker.java:602)
    at magic.ui.screen.DuelDecksScreen$StartupWorker.getNextGame(DuelDecksScreen.java:327)
    ... 21 more
Caused by: java.lang.ArrayIndexOutOfBoundsException: 2
    at magic.data.DuelConfig.getPlayerConfig(DuelConfig.java:148)
    at magic.model.MagicDuel.nextGame(MagicDuel.java:114)
    at magic.ui.screen.DuelDecksScreen$StartupWorker.doInBackground(DuelDecksScreen.java:316)
    at magic.ui.screen.DuelDecksScreen$StartupWorker.doInBackground(DuelDecksScreen.java:306)
    at javax.swing.SwingWorker$1.call(SwingWorker.java:295)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at javax.swing.SwingWorker.run(SwingWorker.java:334)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
@lodici lodici added the bug label Dec 28, 2015
@lodici lodici self-assigned this Dec 28, 2015
@lodici lodici closed this as completed in 7ca1020 Dec 28, 2015
@lodici
Copy link
Member Author

lodici commented Dec 28, 2015

@melvinzhang please can you review this update. The crash was caused by opponentIndex being set to 2 when the deciding game of a duel was ended. So in a one game duel that would be the first, in a 3 game duel that would be the third game etc.

However, looking at where opponentIndex is used it seems to be a pointless variable. Why would it ever be anything other than 1?

@ShawnieBoy
Copy link
Member

Could it be do determine who the starting player is? The first player in the first duel should be the second player in the second. So on the third it should be the first player again?

edit: Meaning the player who decides whether to play or draw.

@lodici
Copy link
Member Author

lodici commented Dec 28, 2015

That is done by determineStartPlayer().

I thought it might be to implement rule 103.2 which describes how to determine who plays first but the only place I can see where that might happen is here and I cannot see how it can ever be anything other than 1.

@ShawnieBoy
Copy link
Member

Very true - that is strange.

@melvinzhang
Copy link
Contributor

This is before I was involved but if you trace the history of MagicDuel, it was originally called MagicTournament and there is mention of things like BOOSTER_PACK_SIZE and getGamesTotal =
(playerDefinitions.length-1)*configuration.getNrOfGames();

My best guess is that at the start, there was an attempt to model a limited tournament where folks sit around a table and open booster packs. After finishing a duel with one opponent, you would move on to the next one.

Looks like the tournament idea never really got fleshed out and the program eventually settled on the current format we know today.

@lodici
Copy link
Member Author

lodici commented Dec 29, 2015

@melvinzhang , thanks for looking at this. This is a fairly major usability issue in that anyone who plays a duel which goes to a deciding game will crash out at the end of that duel. I would be inclined to release a patch for it since we have a whole month ahead of us. However we have never done this is my experience so I don't know how difficult it would be to do. Alternatively, we should post something on the forum recommending everyone will need to win their duels by at least two clear games!

@melvinzhang
Copy link
Contributor

Good suggestion. I've backported the fix onto the release branch as fdc0aca and updated the release zips to include the fix.

@lodici
Copy link
Member Author

lodici commented Dec 29, 2015

As simple as that! 👍

@ShawnieBoy
Copy link
Member

Now that's cool - could that mean that bug-fixes could now be separate from version releases? Some card-bugs create crashes instead of unexpected/wrong behaviour.

@melvinzhang
Copy link
Contributor

It would depend on the severity of the bug. The steps of updating a release are straightforward but rather tedious.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants