Arcnor/pixel-dungeon-gdx — pull request #24 by prurigro (2014-09-10 03:28:01+00:00)
Title: Prevent simultaneous "touch" events to avoid NullPointerException

Generating two **touch** events simultaneously (eg: pressing the left mouse button and then the right mouse button, followed by releasing the left mouse button and then the right mouse button) would cause pixel-dungeon-gdx to crash with a NullPointerException, generating the following error:

```
Exception in thread "LWJGL Application" java.lang.NullPointerException
at com.watabou.input.PDInputProcessor.touchUp(PDInputProcessor.java:85)
at com.badlogic.gdx.backends.lwjgl.LwjglInput.processEvents(LwjglInput.java:320)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:199)
at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)
```
Since there is no requirement for multiple simultaneous touch events in this game, the change implemented by this pull request solves the crash by simply blocking new touch events from starting via `touchDown()` until the previous one has completed via `touchUp()`, and by blocking `touchUp()` and `touchDragged` until a touch event has been initiated.

In addition to the changes stated above, this pull request also has `touchUp()` check to ensure `pointer` exists in `pointers` before attempting to remove it, which is more of a precaution in case some future change gets added that would have triggered the NullPointerException again. I checked to see what would happen if this occurrs by removing the rest of the changes in this pull request to test, and rather than crashing the program and not saving your progress, the mouse simply stops working for the session, and you can use the keyboard to exit properly.

Cheers!