Gornova/MarteEngine

Alarm update null pointer

Closed this issue · 3 comments

Hi,

I am really not sure what is causing this issue, though I am fairly new to all of this. I have been playing arround with the alarm feature of your engine and sometimes (seemingly randomly) there is a null pointer exception. It is within the Entity class where it updates the alarms specificaly here:

if (deadAlarms != null) {
for (String deadAlarm : deadAlarms) {
alarms.put(deadAlarm, null);
}
}

I am fairly certain that it is nothing I have done, though I may be wrong. I really struggle to recreate the bug as I have no idea what is causing it. Here is the stack trace:

Fri Mar 09 10:47:58 GMT 2012 ERROR:null
java.lang.NullPointerException
at java.util.Hashtable.put(Unknown Source)
at it.randomtower.engine.entity.Entity.updateAlarms(Entity.java:766)
at it.randomtower.engine.World.update(World.java:120)
at MainGameState.update(MainGameState.java:73)
at org.newdawn.slick.state.StateBasedGame.update(StateBasedGame.java:268)
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:657)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:408)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:318)
at SpaceQuest.main(SpaceQuest.java:40)
Fri Mar 09 10:47:58 GMT 2012 ERROR:Game.update() failure - check the game code.
org.newdawn.slick.SlickException: Game.update() failure - check the game code.
at org.newdawn.slick.GameContainer.updateAndRender(GameContainer.java:663)
at org.newdawn.slick.AppGameContainer.gameLoop(AppGameContainer.java:408)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:318)
at SpaceQuest.main(SpaceQuest.java:40)

Thanks,
Andy

hi! what version of Marteengine are you using? version 0.2 or maybe a snapshot of dev branch?

Version 0.2

I have modified MarteEngine to catch the exception for now, though that is a hacky fix. It appears to happen when an entity goes off the rendered section of the screen, though I am still having problems re-creating this bug.

The entity(s) in question have multiple alarms on them that could be triggered at the same time, could this be part of the problem?

Let us give and example project so we can test it