StandardGame and assertDisplayCreated for HEADLESS applications

I'm having this problem with StandardGame when I use GameType.HEADLESS (for my server mode):



com.jme.system.JmeException: Window must be created during initialization.

at com.jme.app.AbstractGame.assertDisplayCreated(AbstractGame.java:112)

at com.jmex.game.StandardGame.run(StandardGame.java:132)

at java.lang.Thread.run(Unknown Source)



I'll continue debugging, there are more exceptions…

More exceptions:



ADVERTENCIA: Problem during creation of Mouse.

java.lang.IllegalStateException: Display must be created prior to creating mouse

at org.lwjgl.input.Mouse.create(Mouse.java:222)

at com.jme.input.lwjgl.LWJGLMouseInput.<init>(LWJGLMouseInput.java:66)

at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)

at java.lang.reflect.Constructor.newInstance(Unknown Source)

at com.jme.input.MouseInput.get(MouseInput.java:72)

at com.jmex.game.StandardGame.run(StandardGame.java:161)

at java.lang.Thread.run(Unknown Source)



I'll submit a patch when my server is working.

A patch for the aforesaid bugs.



EDIT: This patch is obsoleted by the DummyDisplaySystem timer issue (see:

http://www.jmonkeyengine.com/jmeforum/index.php?topic=4425.0). The patch providen there already contains this patch.



It is in Unified format and applies to the StandardGame.java file.



Index: StandardGame.java
===================================================================
RCS file: /cvs/jme/src/com/jmex/game/StandardGame.java,v
retrieving revision 1.6
diff -u -r1.6 StandardGame.java
--- StandardGame.java   17 Jan 2007 21:35:09 -0000   1.6
+++ StandardGame.java   24 Jan 2007 18:44:24 -0000
@@ -45,6 +45,7 @@
 import com.jme.renderer.ColorRGBA;
 import com.jme.system.DisplaySystem;
 import com.jme.system.GameSettings;
+import com.jme.system.JmeException;
 import com.jme.system.PreferencesGameSettings;
 import com.jme.util.GameTaskQueue;
 import com.jme.util.GameTaskQueueManager;
@@ -129,7 +130,7 @@
    public void run() {
       lock();
       initSystem();
-      assertDisplayCreated();
+      if (type == GameType.GRAPHICAL) assertDisplayCreated();
       initGame();
       if (type == GameType.GRAPHICAL) {
          timer = Timer.getTimer();
@@ -148,7 +149,7 @@
       }
 
       // Default the mouse cursor to off
-      MouseInput.get().setCursorVisible(false);
+      if (type == GameType.GRAPHICAL) MouseInput.get().setCursorVisible(false);
       
       // Main game loop
       float tpf;