changeset 62:caf67c7e0814

Fix a possible null pointer exception under certain circumstances.
author Matti Hamalainen <ccr@tnsp.org>
date Thu, 24 Feb 2011 03:59:46 +0200
parents ceaf645ed930
children 1c7a97d80120
files game/Engine.java
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/game/Engine.java	Thu Feb 24 03:58:33 2011 +0200
+++ b/game/Engine.java	Thu Feb 24 03:59:46 2011 +0200
@@ -494,10 +494,13 @@
 
         if (!lauta.flagGameOver)
         {
-            // Draw next piece
-            AffineTransform save = g2.getTransform();
-            lauta.nextPiece.paint(g2, 830, 325, 90);
-            g2.setTransform(save);
+            if (lauta.nextPiece != null)
+            {
+                // Draw next piece
+                AffineTransform save = g2.getTransform();
+                lauta.nextPiece.paint(g2, 830, 325, 90);
+                g2.setTransform(save);
+            }
         }
         else
         {
@@ -631,7 +634,8 @@
 
             // Animate components
             lauta.animate(gameClock);
-            lauta.nextPiece.animate(gameClock);
+            if (lauta.nextPiece != null)
+                lauta.nextPiece.animate(gameClock);
             
             // Repaint with a frame limiter
             if (gameClock % 4 == 1)