1) In TerasologyEngine.mainLoop() there's the following code block. Note the comment at the beginning talking about "once a second". Then note the line "Thread.sleep(100)". My guess is that either the comment should be talking about 1/10th of a second or the Thread.sleep() parameter should be 1000 (ms). Right?
// Only process rendering and updating once a second
if (!display.isActive() && isHibernationAllowed()) {
2) In engine/subsystems/LWJGLInput.preUpdate() I stumbled upon these two lines:
NUIManager nuiManager = CoreRegistry.get(NUIManager.class);
GameEngine engine = CoreRegistry.get(GameEngine.class);
Now, as the LWJGLInput class is an engine's subystem, this preUpdate() method gets called every frame, from the main loop. While I doubt it would be a significant optimization, would I be right in saying that perhaps these variables should be private members updated every frame rather than method-local variables recreated every frame?
3) Again in TerasologyEngine.mainLoop() there's the code:
if (currentState == null) {
The question is: what sets currentState to null? cleanup() does but is called after the main loop is interrupted. switchState() cannot, as calling init() on a null object would trigger a NPE? So, I'm wondering if the shutdown() call in this block is ever reachable.
// Only process rendering and updating once a second
if (!display.isActive() && isHibernationAllowed()) {
time.setPaused(true);
Iterator<Float> updateCycles = time.tick();
while (updateCycles.hasNext()) {
try {
display.processMessages();
time.setPaused(false);
continue;
}Iterator<Float> updateCycles = time.tick();
while (updateCycles.hasNext()) {
updateCycles.next();
}try {
Thread.sleep(100);
} catch (InterruptedException e) {logger.warn("Display inactivity sleep interrupted", e);
}display.processMessages();
time.setPaused(false);
continue;
2) In engine/subsystems/LWJGLInput.preUpdate() I stumbled upon these two lines:
NUIManager nuiManager = CoreRegistry.get(NUIManager.class);
GameEngine engine = CoreRegistry.get(GameEngine.class);
Now, as the LWJGLInput class is an engine's subystem, this preUpdate() method gets called every frame, from the main loop. While I doubt it would be a significant optimization, would I be right in saying that perhaps these variables should be private members updated every frame rather than method-local variables recreated every frame?
3) Again in TerasologyEngine.mainLoop() there's the code:
if (currentState == null) {
shutdown();
break;
}break;
The question is: what sets currentState to null? cleanup() does but is called after the main loop is interrupted. switchState() cannot, as calling init() on a null object would trigger a NPE? So, I'm wondering if the shutdown() call in this block is ever reachable.