JPII / NavalBattle

Strategic turn-based naval game.
http://jpii.github.io/NavalBattle
GNU General Public License v3.0
3 stars 3 forks source link

ArrayIndexOutOfBoundsException #214

Closed Matthis5point0 closed 11 years ago

Matthis5point0 commented 11 years ago

Found this error after closing a game of naval battle "Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 5228 at com.jpii.navalbattle.pavo.World.getChunk(World.java:95) at com.jpii.navalbattle.pavo.World.getChunk(World.java:98) at com.jpii.navalbattle.pavo.grid.EntityManager.findEntity(EntityManager.java:170) at com.jpii.navalbattle.game.NavalGame.mouseDown(NavalGame.java:261) at com.jpii.navalbattle.game.GameComponent$1.mousePressed(GameComponent.java:71) at java.awt.Component.processMouseEvent(Unknown Source) at javax.swing.JComponent.processMouseEvent(Unknown Source) at java.awt.Component.processEvent(Unknown Source) at java.awt.Container.processEvent(Unknown Source) at java.awt.Component.dispatchEventImpl(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source) at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source) at java.awt.Container.dispatchEventImpl(Unknown Source) at java.awt.Window.dispatchEventImpl(Unknown Source) at java.awt.Component.dispatchEvent(Unknown Source) at java.awt.EventQueue.dispatchEventImpl(Unknown Source) at java.awt.EventQueue.access$000(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.awt.EventQueue$3.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.awt.EventQueue$4.run(Unknown Source) at java.security.AccessController.doPrivileged(Native Method) at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source) at java.awt.EventQueue.dispatchEvent(Unknown Source) at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source) at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.pumpEvents(Unknown Source) at java.awt.EventDispatchThread.run(Unknown Source)"

No clue what it does but I'm sure it's not good.

maximusvladimir commented 11 years ago

The source of this is the setEntity in the HUD (I'm serious).

abauer commented 11 years ago

ok so null bugss.... would checking for Location.Unknown work?

maximusvladimir commented 11 years ago

It depends on how you have it set up.... I'm checking now.

No, actually all you need to do is make sure chx and chy are greater than 0 and less than the width and height of the world (times 2). (NavalGame:261).

abauer commented 11 years ago

does getWorld.getHeight()_2 and getWorld.getWidth()_2 work?

abauer commented 11 years ago

nope those don't work

abauer commented 11 years ago

fixed!