work on resetting scene on escaping to main menu
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
1c92462888
commit
9bd2b6b38f
@ -626,7 +626,10 @@ Fix entity scene test spinup by preventing networking sockets from closing
|
||||
Thread manager/tracker + properly closing threads on engine close
|
||||
|
||||
(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
|
||||
|
||||
@ -31,6 +31,7 @@ import electrosphere.engine.assetmanager.AssetDataStrings;
|
||||
import electrosphere.engine.assetmanager.AssetManager;
|
||||
import electrosphere.engine.loadingthreads.InitialAssetLoading;
|
||||
import electrosphere.engine.profiler.Profiler;
|
||||
import electrosphere.engine.threads.ThreadManager;
|
||||
import electrosphere.engine.time.Timekeeper;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.Scene;
|
||||
@ -587,6 +588,15 @@ public class Globals {
|
||||
Globals.assetManager.loadAssetsInQueue();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets global values
|
||||
*/
|
||||
public static void resetGlobals(){
|
||||
Globals.playerEntity = null;
|
||||
Globals.playerCamera = null;
|
||||
Globals.firstPersonEntity = null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import electrosphere.controls.ControlHandler.ControlsState;
|
||||
import electrosphere.engine.cli.CLIParser;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
import electrosphere.engine.time.Timekeeper;
|
||||
import electrosphere.game.config.UserSettings;
|
||||
import electrosphere.game.server.world.MacroData;
|
||||
@ -80,7 +81,8 @@ public class Main {
|
||||
Globals.initGlobals();
|
||||
|
||||
//init scripting engine
|
||||
Globals.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
|
||||
Globals.scriptEngine.init();
|
||||
// Globals.threadManager.start(new LoadingThread(LoadingThreadType.SCRIPT_ENGINE));
|
||||
|
||||
//controls
|
||||
if(Globals.RUN_CLIENT){
|
||||
@ -154,7 +156,7 @@ public class Main {
|
||||
Globals.controlHandler.hintUpdateControlState(ControlsState.TITLE_MENU);
|
||||
|
||||
//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
|
||||
@ -443,9 +445,7 @@ public class Main {
|
||||
//shutdown ode
|
||||
OdeHelper.closeODE();
|
||||
//reset globals
|
||||
Globals.playerEntity = null;
|
||||
Globals.playerCamera = null;
|
||||
Globals.firstPersonEntity = null;
|
||||
Globals.resetGlobals();
|
||||
}
|
||||
|
||||
static void sleep(int i) {
|
||||
|
||||
@ -11,6 +11,7 @@ import electrosphere.client.targeting.crosshair.Crosshair;
|
||||
import electrosphere.client.terrain.cells.DrawCellManager;
|
||||
import electrosphere.controls.ControlHandler;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
import electrosphere.entity.DrawableUtils;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityCreationUtils;
|
||||
@ -26,22 +27,6 @@ import electrosphere.net.client.ClientNetworking;
|
||||
import electrosphere.renderer.ui.elements.Window;
|
||||
|
||||
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){
|
||||
@ -129,7 +114,7 @@ public class ClientLoading {
|
||||
//start client networking
|
||||
if(Globals.RUN_CLIENT){
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -74,9 +74,9 @@ public class LevelEditorLoading {
|
||||
Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor");
|
||||
ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true);
|
||||
//wait for player object creation
|
||||
while(Globals.playerManager.getPlayers().size() < 1){
|
||||
while(Globals.playerManager.getPlayers().size() < 1 || !Globals.clientConnection.isInitialized()){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(10);
|
||||
TimeUnit.MILLISECONDS.sleep(1);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@ -93,7 +93,7 @@ public class LevelEditorLoading {
|
||||
//the less juicy client setup part
|
||||
while(Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces().size() == 0){
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(5);
|
||||
TimeUnit.MILLISECONDS.sleep(1);
|
||||
} catch (InterruptedException ex) {}
|
||||
}
|
||||
|
||||
|
||||
@ -15,6 +15,11 @@ public class LoadingThread extends Thread {
|
||||
*/
|
||||
TITLE_MENU,
|
||||
|
||||
/**
|
||||
* Loads the main game title menu
|
||||
*/
|
||||
RETURN_TITLE_MENU,
|
||||
|
||||
/**
|
||||
* Loads the main game
|
||||
*/
|
||||
@ -83,7 +88,11 @@ public class LoadingThread extends Thread {
|
||||
switch(threadType){
|
||||
|
||||
case TITLE_MENU: {
|
||||
ClientLoading.loadMainMenu(this.params);
|
||||
MainMenuLoading.loadMainMenu(this.params);
|
||||
} break;
|
||||
|
||||
case RETURN_TITLE_MENU: {
|
||||
MainMenuLoading.returnToMainMenu(this.params);
|
||||
} break;
|
||||
|
||||
case MAIN_GAME: {
|
||||
|
||||
@ -10,10 +10,12 @@ import org.joml.Vector3i;
|
||||
|
||||
import electrosphere.auth.AuthenticationManager;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||
import electrosphere.game.data.creature.type.CreatureData;
|
||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||
import electrosphere.game.server.world.MacroData;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.net.NetUtils;
|
||||
import electrosphere.net.client.ClientNetworking;
|
||||
import electrosphere.net.parser.net.message.CharacterMessage;
|
||||
@ -64,7 +66,7 @@ public class LoadingUtils {
|
||||
if(Globals.RUN_SERVER){
|
||||
Globals.server = new Server(NetUtils.getPort());
|
||||
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
|
||||
if(Globals.RUN_CLIENT){
|
||||
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);
|
||||
//start client communication thread
|
||||
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) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
LoggerInterface.loggerNetworking.ERROR(e);
|
||||
}
|
||||
return rVal;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1,11 +1,13 @@
|
||||
package electrosphere.engine;
|
||||
package electrosphere.engine.threads;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Semaphore;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
import electrosphere.util.CodeUtils;
|
||||
|
||||
/**
|
||||
@ -17,7 +19,7 @@ public class ThreadManager {
|
||||
Semaphore threadLock = new Semaphore(1);
|
||||
|
||||
//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
|
||||
private List<LoadingThread> loadingThreads = new LinkedList<LoadingThread>();
|
||||
@ -53,9 +55,9 @@ public class ThreadManager {
|
||||
* Starts a new thread with tracking
|
||||
* @param thread The thread to start
|
||||
*/
|
||||
public void start(Thread thread){
|
||||
public void start(ThreadLabel label, Thread thread){
|
||||
threadLock.acquireUninterruptibly();
|
||||
activeThreads.add(thread);
|
||||
activeThreads.add(new LabeledThread(label, thread));
|
||||
thread.start();
|
||||
threadLock.release();
|
||||
}
|
||||
@ -66,7 +68,7 @@ public class ThreadManager {
|
||||
*/
|
||||
public void start(LoadingThread thread){
|
||||
threadLock.acquireUninterruptibly();
|
||||
activeThreads.add(thread);
|
||||
activeThreads.add(new LabeledThread(ThreadLabel.LOADING, thread));
|
||||
loadingThreads.add(thread);
|
||||
thread.start();
|
||||
threadLock.release();
|
||||
@ -95,8 +97,8 @@ public class ThreadManager {
|
||||
//
|
||||
//interrupt all threads
|
||||
for(int i = 0; i < 3; i++){
|
||||
for(Thread thread : activeThreads){
|
||||
thread.interrupt();
|
||||
for(LabeledThread thread : activeThreads){
|
||||
thread.getThread().interrupt();
|
||||
}
|
||||
try {
|
||||
TimeUnit.MILLISECONDS.sleep(3);
|
||||
@ -115,4 +117,20 @@ public class ThreadManager {
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
@ -66,6 +66,19 @@ public class Logger {
|
||||
System.out.println(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -5,6 +5,8 @@ import org.joml.Vector3f;
|
||||
import electrosphere.controls.ControlHandler.ControlsState;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread;
|
||||
import electrosphere.engine.loadingthreads.LoadingThread.LoadingThreadType;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
@ -104,7 +106,7 @@ public class MenuGeneratorsInGame {
|
||||
quitButton.addChild(quitLabel);
|
||||
div.addChild(quitButton);
|
||||
quitButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
|
||||
Main.running = false;
|
||||
Globals.threadManager.start(new LoadingThread(LoadingThreadType.RETURN_TITLE_MENU));
|
||||
return false;
|
||||
}});
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ public class ClientNetworking implements Runnable {
|
||||
// CryptoOutputStream outputStream;
|
||||
InputStream inputStream;
|
||||
OutputStream outputStream;
|
||||
boolean initialized;
|
||||
boolean initialized = false;
|
||||
NetworkParser parser;
|
||||
|
||||
/**
|
||||
@ -69,6 +69,9 @@ public class ClientNetworking implements Runnable {
|
||||
|
||||
//debugging stuff
|
||||
String netMonitorHandle = null;
|
||||
|
||||
//Signals the thread to stop
|
||||
boolean shouldDisconnect = false;
|
||||
|
||||
/**
|
||||
* Creates a ClientNetworking object with a server address and port
|
||||
@ -76,6 +79,7 @@ public class ClientNetworking implements Runnable {
|
||||
* @param port The port to connect to on the server
|
||||
*/
|
||||
public ClientNetworking(String address, int port){
|
||||
this.shouldDisconnect = false;
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
}
|
||||
@ -87,6 +91,7 @@ public class ClientNetworking implements Runnable {
|
||||
*/
|
||||
public ClientNetworking(InputStream clientInputStream, OutputStream clientOutputStream){
|
||||
this.local = true;
|
||||
this.shouldDisconnect = false;
|
||||
this.inputStream = clientInputStream;
|
||||
this.outputStream = clientOutputStream;
|
||||
}
|
||||
@ -168,7 +173,7 @@ public class ClientNetworking implements Runnable {
|
||||
|
||||
//start parsing messages
|
||||
initialized = true;
|
||||
while(Globals.threadManager.shouldKeepRunning()){
|
||||
while(Globals.threadManager.shouldKeepRunning() && !this.shouldDisconnect){
|
||||
//attempt poll incoming messages
|
||||
parser.readMessagesIn();
|
||||
//outgoing messages
|
||||
@ -293,5 +298,22 @@ public class ClientNetworking implements Runnable {
|
||||
public void markReceivedPongMessage(){
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.net.server;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.net.NetUtils;
|
||||
@ -74,7 +75,7 @@ public class Server implements Runnable {
|
||||
} catch (IOException ex) {
|
||||
LoggerInterface.loggerNetworking.ERROR("Failed to start server socket!",ex);
|
||||
}
|
||||
while(Globals.threadManager.shouldKeepRunning()){
|
||||
while(Globals.threadManager.shouldKeepRunning() && !serverSocket.isClosed()){
|
||||
Socket newSocket;
|
||||
try {
|
||||
newSocket = serverSocket.accept();
|
||||
@ -83,10 +84,10 @@ public class Server implements Runnable {
|
||||
// clientMap.put(newSocket.getInetAddress().getHostAddress(), newClient);
|
||||
socketConnectionMap.put(newSocket, newClient);
|
||||
activeConnections.add(newClient);
|
||||
Globals.threadManager.start(new Thread(newClient));
|
||||
Globals.threadManager.start(ThreadLabel.NETWORKING_SERVER, new Thread(newClient));
|
||||
connectListLock.release();
|
||||
} catch (SocketException ex){
|
||||
LoggerInterface.loggerNetworking.ERROR("Socket closed!",ex);
|
||||
LoggerInterface.loggerNetworking.DEBUG("Server Socket closed!",ex);
|
||||
} catch (IOException ex) {
|
||||
LoggerInterface.loggerNetworking.ERROR("Socket error on client socket!",ex);
|
||||
}
|
||||
@ -142,7 +143,7 @@ public class Server implements Runnable {
|
||||
connectListLock.acquireUninterruptibly();
|
||||
ServerConnectionHandler newClient = new ServerConnectionHandler(serverInputStream,serverOutputStream);
|
||||
activeConnections.add(newClient);
|
||||
Globals.threadManager.start(new Thread(newClient));
|
||||
Globals.threadManager.start(ThreadLabel.NETWORKING_SERVER, new Thread(newClient));
|
||||
connectListLock.release();
|
||||
return newClient;
|
||||
}
|
||||
|
||||
@ -8,7 +8,6 @@ import electrosphere.net.parser.net.message.NetworkMessage;
|
||||
import electrosphere.net.parser.net.message.ServerMessage;
|
||||
import electrosphere.net.parser.net.raw.NetworkParser;
|
||||
import electrosphere.net.server.player.Player;
|
||||
import electrosphere.util.CodeUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@ -308,7 +307,8 @@ public class ServerConnectionHandler implements Runnable {
|
||||
//sleep
|
||||
TimeUnit.MILLISECONDS.sleep(1);
|
||||
} 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;
|
||||
//add connection to server list of connections to cleanup
|
||||
Globals.server.addClientToCleanup(this);
|
||||
if(Globals.server != null){
|
||||
Globals.server.addClientToCleanup(this);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -38,6 +38,9 @@ public class Player {
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
if(connectionHandler != null){
|
||||
return this.connectionHandler.getPlayerId();
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
|
||||
@ -28,20 +28,20 @@ public class CompositePipeline implements RenderPipeline {
|
||||
//
|
||||
//Draw anime outline
|
||||
//
|
||||
// openGLState.setActiveShader(renderPipelineState, RenderingEngine.compositeAnimeOutline);
|
||||
openGLState.setActiveShader(renderPipelineState, RenderingEngine.compositeAnimeOutline);
|
||||
|
||||
// openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
||||
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
||||
// openGLState.glActiveTexture(GL40.GL_TEXTURE1);
|
||||
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
||||
// openGLState.glActiveTexture(GL40.GL_TEXTURE2);
|
||||
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
||||
// openGLState.glActiveTexture(GL40.GL_TEXTURE3);
|
||||
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
||||
// openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
||||
// openGLState.glBindTexture(GL40.GL_TEXTURE_2D, RenderingEngine.normalsOutlineTexture.getTexturePointer());
|
||||
openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
||||
openGLState.glActiveTexture(GL40.GL_TEXTURE1);
|
||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
||||
openGLState.glActiveTexture(GL40.GL_TEXTURE2);
|
||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
||||
openGLState.glActiveTexture(GL40.GL_TEXTURE3);
|
||||
openGLState.glBindTexture(GL40.GL_TEXTURE_2D, 0);
|
||||
openGLState.glActiveTexture(GL40.GL_TEXTURE0);
|
||||
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
|
||||
|
||||
@ -11,6 +11,7 @@ import org.joml.Vector3d;
|
||||
import org.joml.Vector3i;
|
||||
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.game.server.world.ServerWorldData;
|
||||
@ -439,7 +440,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
||||
}
|
||||
});
|
||||
groundDataCells.get(getServerDataCellKey(worldPos)).setReady(false);
|
||||
Globals.threadManager.start(thread);
|
||||
Globals.threadManager.start(ThreadLabel.ASSET_LOADING, thread);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
Reference in New Issue
Block a user