work on resetting scene on escaping to main menu
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-08-24 17:24:20 -04:00
parent 1c92462888
commit 9bd2b6b38f
18 changed files with 269 additions and 62 deletions

View File

@ -626,7 +626,10 @@ Fix entity scene test spinup by preventing networking sockets from closing
Thread manager/tracker + properly closing threads on engine close Thread manager/tracker + properly closing threads on engine close
(08/24/2024) (08/24/2024)
Disable anime outlines effect Resetting globals for multiple test runs from coding environment
Return to main menu from ingame
Tagging threads in manager
Quitting to main menu
# TODO # TODO

View File

@ -31,6 +31,7 @@ import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.assetmanager.AssetManager; import electrosphere.engine.assetmanager.AssetManager;
import electrosphere.engine.loadingthreads.InitialAssetLoading; import electrosphere.engine.loadingthreads.InitialAssetLoading;
import electrosphere.engine.profiler.Profiler; import electrosphere.engine.profiler.Profiler;
import electrosphere.engine.threads.ThreadManager;
import electrosphere.engine.time.Timekeeper; import electrosphere.engine.time.Timekeeper;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.Scene; import electrosphere.entity.Scene;
@ -587,6 +588,15 @@ public class Globals {
Globals.assetManager.loadAssetsInQueue(); Globals.assetManager.loadAssetsInQueue();
} }
/**
* Resets global values
*/
public static void resetGlobals(){
Globals.playerEntity = null;
Globals.playerCamera = null;
Globals.firstPersonEntity = null;
}
} }

View File

@ -17,6 +17,7 @@ import electrosphere.controls.ControlHandler.ControlsState;
import electrosphere.engine.cli.CLIParser; import electrosphere.engine.cli.CLIParser;
import electrosphere.engine.loadingthreads.LoadingThread; import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType; import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.engine.time.Timekeeper; import electrosphere.engine.time.Timekeeper;
import electrosphere.game.config.UserSettings; import electrosphere.game.config.UserSettings;
import electrosphere.game.server.world.MacroData; import electrosphere.game.server.world.MacroData;
@ -80,7 +81,8 @@ public class Main {
Globals.initGlobals(); Globals.initGlobals();
//init scripting engine //init scripting engine
Globals.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE)); Globals.scriptEngine.init();
// Globals.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
//controls //controls
if(Globals.RUN_CLIENT){ if(Globals.RUN_CLIENT){
@ -154,7 +156,7 @@ public class Main {
Globals.controlHandler.hintUpdateControlState(ControlsState.TITLE_MENU); Globals.controlHandler.hintUpdateControlState(ControlsState.TITLE_MENU);
//start initial asset loading //start initial asset loading
Globals.threadManager.start(new Thread(Globals.initialAssetLoadingThread)); Globals.threadManager.start(ThreadLabel.ASSET_LOADING, new Thread(Globals.initialAssetLoadingThread));
} }
//Sets a hook that fires when the engine process stops //Sets a hook that fires when the engine process stops
@ -443,9 +445,7 @@ public class Main {
//shutdown ode //shutdown ode
OdeHelper.closeODE(); OdeHelper.closeODE();
//reset globals //reset globals
Globals.playerEntity = null; Globals.resetGlobals();
Globals.playerCamera = null;
Globals.firstPersonEntity = null;
} }
static void sleep(int i) { static void sleep(int i) {

View File

@ -11,6 +11,7 @@ import electrosphere.client.targeting.crosshair.Crosshair;
import electrosphere.client.terrain.cells.DrawCellManager; import electrosphere.client.terrain.cells.DrawCellManager;
import electrosphere.controls.ControlHandler; import electrosphere.controls.ControlHandler;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.entity.DrawableUtils; import electrosphere.entity.DrawableUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityCreationUtils; import electrosphere.entity.EntityCreationUtils;
@ -27,22 +28,6 @@ import electrosphere.renderer.ui.elements.Window;
public class ClientLoading { public class ClientLoading {
/**
* Loads the main menu
* @param params Params (this thread type does not accept any)
*/
protected static void loadMainMenu(Object[] params){
Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
if(loadingWindow != null){
WindowUtils.recursiveSetVisible(loadingWindow,false);
}
WindowUtils.focusWindow(WindowStrings.WINDOW_MENU_MAIN);
Window mainMenuWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN);
if(mainMenuWindow != null){
WindowUtils.recursiveSetVisible(mainMenuWindow, true);
}
}
protected static void loadCharacterServer(Object[] params){ protected static void loadCharacterServer(Object[] params){
Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING); Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
@ -129,7 +114,7 @@ public class ClientLoading {
//start client networking //start client networking
if(Globals.RUN_CLIENT){ if(Globals.RUN_CLIENT){
Globals.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort()); Globals.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
Globals.threadManager.start(new Thread(Globals.clientConnection)); Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientConnection));
} }
} }

View File

@ -74,9 +74,9 @@ public class LevelEditorLoading {
Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor"); Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor");
ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true); ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true);
//wait for player object creation //wait for player object creation
while(Globals.playerManager.getPlayers().size() < 1){ while(Globals.playerManager.getPlayers().size() < 1 || !Globals.clientConnection.isInitialized()){
try { try {
TimeUnit.MILLISECONDS.sleep(10); TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -93,7 +93,7 @@ public class LevelEditorLoading {
//the less juicy client setup part //the less juicy client setup part
while(Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces().size() == 0){ while(Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces().size() == 0){
try { try {
TimeUnit.MILLISECONDS.sleep(5); TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException ex) {} } catch (InterruptedException ex) {}
} }

View File

@ -15,6 +15,11 @@ public class LoadingThread extends Thread {
*/ */
TITLE_MENU, TITLE_MENU,
/**
* Loads the main game title menu
*/
RETURN_TITLE_MENU,
/** /**
* Loads the main game * Loads the main game
*/ */
@ -83,7 +88,11 @@ public class LoadingThread extends Thread {
switch(threadType){ switch(threadType){
case TITLE_MENU: { case TITLE_MENU: {
ClientLoading.loadMainMenu(this.params); MainMenuLoading.loadMainMenu(this.params);
} break;
case RETURN_TITLE_MENU: {
MainMenuLoading.returnToMainMenu(this.params);
} break; } break;
case MAIN_GAME: { case MAIN_GAME: {

View File

@ -10,10 +10,12 @@ import org.joml.Vector3i;
import electrosphere.auth.AuthenticationManager; import electrosphere.auth.AuthenticationManager;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.entity.types.creature.CreatureTemplate; import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.game.data.creature.type.CreatureData; import electrosphere.game.data.creature.type.CreatureData;
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute; import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
import electrosphere.game.server.world.MacroData; import electrosphere.game.server.world.MacroData;
import electrosphere.logger.LoggerInterface;
import electrosphere.net.NetUtils; import electrosphere.net.NetUtils;
import electrosphere.net.client.ClientNetworking; import electrosphere.net.client.ClientNetworking;
import electrosphere.net.parser.net.message.CharacterMessage; import electrosphere.net.parser.net.message.CharacterMessage;
@ -64,7 +66,7 @@ public class LoadingUtils {
if(Globals.RUN_SERVER){ if(Globals.RUN_SERVER){
Globals.server = new Server(NetUtils.getPort()); Globals.server = new Server(NetUtils.getPort());
Thread serverThread = new Thread(Globals.server); Thread serverThread = new Thread(Globals.server);
Globals.threadManager.start(serverThread); Globals.threadManager.start(ThreadLabel.NETWORKING_SERVER, serverThread);
} }
} }
@ -80,7 +82,7 @@ public class LoadingUtils {
//start client networking //start client networking
if(Globals.RUN_CLIENT){ if(Globals.RUN_CLIENT){
Globals.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort()); Globals.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
Globals.threadManager.start(new Thread(Globals.clientConnection)); Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientConnection));
} }
} }
@ -104,10 +106,9 @@ public class LoadingUtils {
rVal = Globals.server.addLocalPlayer(serverInput, serverOutput); rVal = Globals.server.addLocalPlayer(serverInput, serverOutput);
//start client communication thread //start client communication thread
Globals.clientConnection = new ClientNetworking(clientInput,clientOutput); Globals.clientConnection = new ClientNetworking(clientInput,clientOutput);
Globals.threadManager.start(new Thread(Globals.clientConnection)); Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientConnection));
} catch (IOException e) { } catch (IOException e) {
// TODO Auto-generated catch block LoggerInterface.loggerNetworking.ERROR(e);
e.printStackTrace();
} }
return rVal; return rVal;
} }

View File

@ -0,0 +1,83 @@
package electrosphere.engine.loadingthreads;
import electrosphere.engine.Globals;
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.menu.WindowStrings;
import electrosphere.menu.WindowUtils;
import electrosphere.menu.mainmenu.MenuGeneratorsTitleMenu;
import electrosphere.renderer.ui.elements.Window;
import electrosphere.server.datacell.RealmManager;
/**
* Loading thread that returns the client to the main menu
*/
public class MainMenuLoading {
/**
* Resets all state to main menu
* @param params not necessary
*/
protected static void returnToMainMenu(Object[] params){
//
//stop rendering game
Globals.RENDER_FLAG_RENDER_SHADOW_MAP = false;
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER_CONTENT = false;
Globals.RENDER_FLAG_RENDER_SCREEN_FRAMEBUFFER = false;
Globals.RENDER_FLAG_RENDER_UI = true;
Globals.RENDER_FLAG_RENDER_BLACK_BACKGROUND = true;
//
//reset state
MainMenuLoading.resetClientState();
MainMenuLoading.resetServerState();
Globals.resetGlobals();
Globals.threadManager.interruptLabel(ThreadLabel.NETWORKING_CLIENT);
Globals.threadManager.interruptLabel(ThreadLabel.NETWORKING_SERVER);
//
//reveal in game main menu
Window inGameMainMenu = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_INGAME_MAIN);
if(inGameMainMenu != null){
WindowUtils.recursiveSetVisible(inGameMainMenu,false);
}
MainMenuLoading.loadMainMenu(params);
}
/**
* Resets the client state
*/
private static void resetClientState(){
Globals.clientSimulation = null;
Globals.clientConnection.setShouldDisconnect(true);
}
/**
* Resets the server state
*/
private static void resetServerState(){
Globals.server.close();
Globals.server = null;
Globals.serverSynchronizationManager = null;
Globals.realmManager = new RealmManager();
Globals.macroSimulation = null;
}
/**
* Loads the main menu
* @param params Params (this thread type does not accept any)
*/
protected static void loadMainMenu(Object[] params){
Window loadingWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_LOADING);
if(loadingWindow != null){
WindowUtils.recursiveSetVisible(loadingWindow,false);
}
WindowUtils.focusWindow(WindowStrings.WINDOW_MENU_MAIN);
Window mainMenuWindow = (Window)Globals.elementManager.getWindow(WindowStrings.WINDOW_MENU_MAIN);
WindowUtils.replaceMainMenuContents(MenuGeneratorsTitleMenu.createTitleMenu());
if(mainMenuWindow != null){
WindowUtils.recursiveSetVisible(mainMenuWindow, true);
}
}
}

View File

@ -0,0 +1,54 @@
package electrosphere.engine.threads;
/**
* A thread with an associated label
*/
public class LabeledThread {
/**
* The label associated with the thread
*/
public static enum ThreadLabel {
NETWORKING_SERVER,
NETWORKING_CLIENT,
ASSET_LOADING,
LOADING,
}
/**
* The label
*/
ThreadLabel label;
/**
* The actual thread
*/
Thread thread;
/**
* Constructor
* @param label
* @param thread
*/
public LabeledThread(ThreadLabel label, Thread thread){
this.label = label;
this.thread = thread;
}
/**
* Gets the label
* @return The label
*/
public ThreadLabel getLabel(){
return label;
}
/**
* Gets the thread
* @return The thread
*/
public Thread getThread(){
return thread;
}
}

View File

@ -1,11 +1,13 @@
package electrosphere.engine; package electrosphere.engine.threads;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.Semaphore; import java.util.concurrent.Semaphore;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import electrosphere.engine.Globals;
import electrosphere.engine.loadingthreads.LoadingThread; import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.util.CodeUtils; import electrosphere.util.CodeUtils;
/** /**
@ -17,7 +19,7 @@ public class ThreadManager {
Semaphore threadLock = new Semaphore(1); Semaphore threadLock = new Semaphore(1);
//All threads that are actively running //All threads that are actively running
private List<Thread> activeThreads = new LinkedList<Thread>(); private List<LabeledThread> activeThreads = new LinkedList<LabeledThread>();
//All loading threads that are actively running //All loading threads that are actively running
private List<LoadingThread> loadingThreads = new LinkedList<LoadingThread>(); private List<LoadingThread> loadingThreads = new LinkedList<LoadingThread>();
@ -53,9 +55,9 @@ public class ThreadManager {
* Starts a new thread with tracking * Starts a new thread with tracking
* @param thread The thread to start * @param thread The thread to start
*/ */
public void start(Thread thread){ public void start(ThreadLabel label, Thread thread){
threadLock.acquireUninterruptibly(); threadLock.acquireUninterruptibly();
activeThreads.add(thread); activeThreads.add(new LabeledThread(label, thread));
thread.start(); thread.start();
threadLock.release(); threadLock.release();
} }
@ -66,7 +68,7 @@ public class ThreadManager {
*/ */
public void start(LoadingThread thread){ public void start(LoadingThread thread){
threadLock.acquireUninterruptibly(); threadLock.acquireUninterruptibly();
activeThreads.add(thread); activeThreads.add(new LabeledThread(ThreadLabel.LOADING, thread));
loadingThreads.add(thread); loadingThreads.add(thread);
thread.start(); thread.start();
threadLock.release(); threadLock.release();
@ -95,8 +97,8 @@ public class ThreadManager {
// //
//interrupt all threads //interrupt all threads
for(int i = 0; i < 3; i++){ for(int i = 0; i < 3; i++){
for(Thread thread : activeThreads){ for(LabeledThread thread : activeThreads){
thread.interrupt(); thread.getThread().interrupt();
} }
try { try {
TimeUnit.MILLISECONDS.sleep(3); TimeUnit.MILLISECONDS.sleep(3);
@ -115,4 +117,20 @@ public class ThreadManager {
return this.shouldKeepRunning; return this.shouldKeepRunning;
} }
/**
* Interrupts all thread under a label
* @param label The label
*/
public void interruptLabel(ThreadLabel label){
threadLock.acquireUninterruptibly();
//
//interrupt threads
for(LabeledThread thread : activeThreads){
if(thread.getLabel() == label){
thread.getThread().interrupt();
}
}
threadLock.release();
}
} }

View File

@ -67,6 +67,19 @@ public class Logger {
} }
} }
/**
* Logs a debug message.
* This should be used for debugging messages that are executed on a given condition that won't necessarily be every loop (ie all network messages)
* @param message The message to report
* @param e The exception to also log
*/
public void DEBUG(String message, Exception e){
if(level == LogLevel.LOOP_DEBUG || level == LogLevel.DEBUG){
System.out.println(message);
e.printStackTrace();
}
}
/** /**
* Logs an info message. * Logs an info message.

View File

@ -5,6 +5,8 @@ import org.joml.Vector3f;
import electrosphere.controls.ControlHandler.ControlsState; import electrosphere.controls.ControlHandler.ControlsState;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.Main; import electrosphere.engine.Main;
import electrosphere.engine.loadingthreads.LoadingThread;
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
@ -104,7 +106,7 @@ public class MenuGeneratorsInGame {
quitButton.addChild(quitLabel); quitButton.addChild(quitLabel);
div.addChild(quitButton); div.addChild(quitButton);
quitButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){ quitButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
Main.running = false; Globals.threadManager.start(new LoadingThread(LoadingThreadType.RETURN_TITLE_MENU));
return false; return false;
}}); }});

View File

@ -44,7 +44,7 @@ public class ClientNetworking implements Runnable {
// CryptoOutputStream outputStream; // CryptoOutputStream outputStream;
InputStream inputStream; InputStream inputStream;
OutputStream outputStream; OutputStream outputStream;
boolean initialized; boolean initialized = false;
NetworkParser parser; NetworkParser parser;
/** /**
@ -70,12 +70,16 @@ public class ClientNetworking implements Runnable {
//debugging stuff //debugging stuff
String netMonitorHandle = null; String netMonitorHandle = null;
//Signals the thread to stop
boolean shouldDisconnect = false;
/** /**
* Creates a ClientNetworking object with a server address and port * Creates a ClientNetworking object with a server address and port
* @param address The address of the server * @param address The address of the server
* @param port The port to connect to on the server * @param port The port to connect to on the server
*/ */
public ClientNetworking(String address, int port){ public ClientNetworking(String address, int port){
this.shouldDisconnect = false;
this.address = address; this.address = address;
this.port = port; this.port = port;
} }
@ -87,6 +91,7 @@ public class ClientNetworking implements Runnable {
*/ */
public ClientNetworking(InputStream clientInputStream, OutputStream clientOutputStream){ public ClientNetworking(InputStream clientInputStream, OutputStream clientOutputStream){
this.local = true; this.local = true;
this.shouldDisconnect = false;
this.inputStream = clientInputStream; this.inputStream = clientInputStream;
this.outputStream = clientOutputStream; this.outputStream = clientOutputStream;
} }
@ -168,7 +173,7 @@ public class ClientNetworking implements Runnable {
//start parsing messages //start parsing messages
initialized = true; initialized = true;
while(Globals.threadManager.shouldKeepRunning()){ while(Globals.threadManager.shouldKeepRunning() && !this.shouldDisconnect){
//attempt poll incoming messages //attempt poll incoming messages
parser.readMessagesIn(); parser.readMessagesIn();
//outgoing messages //outgoing messages
@ -294,4 +299,21 @@ public class ClientNetworking implements Runnable {
lastPongTime = System.currentTimeMillis(); lastPongTime = System.currentTimeMillis();
} }
/**
* Alerts the client networking that it should stop
* @param shouldDisconnect true to disconnect, false to stay connected
*/
public void setShouldDisconnect(boolean shouldDisconnect){
this.shouldDisconnect = shouldDisconnect;
}
/**
* Gets whether the client networking is intiialized or not
* @return true if initialized, false otherwise
*/
public boolean isInitialized(){
return initialized;
}
} }

View File

@ -1,6 +1,7 @@
package electrosphere.net.server; package electrosphere.net.server;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.entity.ServerEntityUtils; import electrosphere.entity.ServerEntityUtils;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.net.NetUtils; import electrosphere.net.NetUtils;
@ -74,7 +75,7 @@ public class Server implements Runnable {
} catch (IOException ex) { } catch (IOException ex) {
LoggerInterface.loggerNetworking.ERROR("Failed to start server socket!",ex); LoggerInterface.loggerNetworking.ERROR("Failed to start server socket!",ex);
} }
while(Globals.threadManager.shouldKeepRunning()){ while(Globals.threadManager.shouldKeepRunning() && !serverSocket.isClosed()){
Socket newSocket; Socket newSocket;
try { try {
newSocket = serverSocket.accept(); newSocket = serverSocket.accept();
@ -83,10 +84,10 @@ public class Server implements Runnable {
// clientMap.put(newSocket.getInetAddress().getHostAddress(), newClient); // clientMap.put(newSocket.getInetAddress().getHostAddress(), newClient);
socketConnectionMap.put(newSocket, newClient); socketConnectionMap.put(newSocket, newClient);
activeConnections.add(newClient); activeConnections.add(newClient);
Globals.threadManager.start(new Thread(newClient)); Globals.threadManager.start(ThreadLabel.NETWORKING_SERVER, new Thread(newClient));
connectListLock.release(); connectListLock.release();
} catch (SocketException ex){ } catch (SocketException ex){
LoggerInterface.loggerNetworking.ERROR("Socket closed!",ex); LoggerInterface.loggerNetworking.DEBUG("Server Socket closed!",ex);
} catch (IOException ex) { } catch (IOException ex) {
LoggerInterface.loggerNetworking.ERROR("Socket error on client socket!",ex); LoggerInterface.loggerNetworking.ERROR("Socket error on client socket!",ex);
} }
@ -142,7 +143,7 @@ public class Server implements Runnable {
connectListLock.acquireUninterruptibly(); connectListLock.acquireUninterruptibly();
ServerConnectionHandler newClient = new ServerConnectionHandler(serverInputStream,serverOutputStream); ServerConnectionHandler newClient = new ServerConnectionHandler(serverInputStream,serverOutputStream);
activeConnections.add(newClient); activeConnections.add(newClient);
Globals.threadManager.start(new Thread(newClient)); Globals.threadManager.start(ThreadLabel.NETWORKING_SERVER, new Thread(newClient));
connectListLock.release(); connectListLock.release();
return newClient; return newClient;
} }

View File

@ -8,7 +8,6 @@ import electrosphere.net.parser.net.message.NetworkMessage;
import electrosphere.net.parser.net.message.ServerMessage; import electrosphere.net.parser.net.message.ServerMessage;
import electrosphere.net.parser.net.raw.NetworkParser; import electrosphere.net.parser.net.raw.NetworkParser;
import electrosphere.net.server.player.Player; import electrosphere.net.server.player.Player;
import electrosphere.util.CodeUtils;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -308,7 +307,8 @@ public class ServerConnectionHandler implements Runnable {
//sleep //sleep
TimeUnit.MILLISECONDS.sleep(1); TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
CodeUtils.todo(ex, "Handle sleep interrupt on server connection"); //silently ignore
// CodeUtils.todo(ex, "Handle sleep interrupt on server connection");
} }
} }
@ -411,7 +411,9 @@ public class ServerConnectionHandler implements Runnable {
} }
this.isConnected = false; this.isConnected = false;
//add connection to server list of connections to cleanup //add connection to server list of connections to cleanup
Globals.server.addClientToCleanup(this); if(Globals.server != null){
Globals.server.addClientToCleanup(this);
}
} }
} }

View File

@ -38,6 +38,9 @@ public class Player {
} }
public int getId() { public int getId() {
if(connectionHandler != null){
return this.connectionHandler.getPlayerId();
}
return id; return id;
} }

View File

@ -28,20 +28,20 @@ public class CompositePipeline implements RenderPipeline {
// //
//Draw anime outline //Draw anime outline
// //
// openGLState.setActiveShader(renderPipelineState, RenderingEngine.compositeAnimeOutline); openGLState.setActiveShader(renderPipelineState, RenderingEngine.compositeAnimeOutline);
// openGLState.glActiveTexture(GL40.GL_TEXTURE0); openGLState.glActiveTexture(GL40.GL_TEXTURE0);
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0); openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
// openGLState.glActiveTexture(GL40.GL_TEXTURE1); openGLState.glActiveTexture(GL40.GL_TEXTURE1);
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0); openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
// openGLState.glActiveTexture(GL40.GL_TEXTURE2); openGLState.glActiveTexture(GL40.GL_TEXTURE2);
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0); openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
// openGLState.glActiveTexture(GL40.GL_TEXTURE3); openGLState.glActiveTexture(GL40.GL_TEXTURE3);
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0); openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
// openGLState.glActiveTexture(GL40.GL_TEXTURE0); openGLState.glActiveTexture(GL40.GL_TEXTURE0);
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, RenderingEngine.normalsOutlineTexture.getTexturePointer()); openGLState.glBindTexture(GL40.GL_TEXTURE_2D, RenderingEngine.normalsOutlineTexture.getTexturePointer());
// GL40.glDrawArrays(GL40.GL_TRIANGLES, 0, 6); GL40.glDrawArrays(GL40.GL_TRIANGLES, 0, 6);
// //
//Composite transparency on top of solids //Composite transparency on top of solids

View File

@ -11,6 +11,7 @@ import org.joml.Vector3d;
import org.joml.Vector3i; import org.joml.Vector3i;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.game.server.world.ServerWorldData; import electrosphere.game.server.world.ServerWorldData;
@ -439,7 +440,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
} }
}); });
groundDataCells.get(getServerDataCellKey(worldPos)).setReady(false); groundDataCells.get(getServerDataCellKey(worldPos)).setReady(false);
Globals.threadManager.start(thread); Globals.threadManager.start(ThreadLabel.ASSET_LOADING, thread);
} }
/** /**