Merge branch 'dev' of ssh://git.austinwhoover.com:222/gitadmin/Renderer into dev

This commit is contained in:
austin 2021-05-16 19:00:12 -04:00
commit 631bdea776
2 changed files with 33 additions and 21 deletions

View File

@ -16,6 +16,8 @@ import electrosphere.entity.EntityUtil;
import electrosphere.entity.state.MovementTree;
import electrosphere.game.cell.CellManager;
import electrosphere.game.terrain.TerrainManager;
import electrosphere.net.client.Connection;
import electrosphere.net.server.Server;
import electrosphere.renderer.ModelUtils;
import electrosphere.terraingen.TerrainGen;
import electrosphere.terraingen.models.TerrainModel;
@ -125,19 +127,25 @@ public class Main {
initWorld();
//run initialization stuff
initTerrainManager();
//Create opengl
RenderUtils.createOpenglContext();
if(Globals.mainConfig.runRenderer){
//Create opengl
RenderUtils.createOpenglContext();
}
//init global variables
Globals.initGlobals();
if(Globals.mainConfig.runRenderer){
forkConnection();
}
initWorld();
initCellManager();
if(Globals.mainConfig.runRenderer){
initCellManager();
}
initSkybox();
@ -157,10 +165,10 @@ public class Main {
Camera camera_player_chase = new Camera();
Camera cam_Player_Orbit = new Camera();
boolean running = true;
//main loop
while (!glfwWindowShouldClose(Globals.window)) {
while (running) {
/*
Frame calculation
@ -272,6 +280,10 @@ public class Main {
//check and call events and swap the buffers
glfwSwapBuffers(Globals.window);
glfwPollEvents();
if(glfwWindowShouldClose(Globals.window)){
running = false;
}
}
//Terminate the program.
glfwTerminate();
@ -337,7 +349,7 @@ public class Main {
static void initWorld(){
static void initTerrainManager(){
float[][] elevation;
terrainManager = new TerrainManager(2000,200,100,0.25f);
@ -422,12 +434,12 @@ public class Main {
}
public static void initServer(){
public static void forkServer(){
Server.startServerThread();
}
public static void initClient(){
public static void forkConnection(){
Connection.startConnection();
}
}

View File

@ -37,18 +37,18 @@ public class Server {
ex.printStackTrace();
System.exit(1);
}
try {
serverSocket.bind(new InetSocketAddress(port));
boolean running = true;
while(running){
Socket newSocket = serverSocket.accept();
boolean running = true;
while(running){
Socket newSocket;
try {
newSocket = serverSocket.accept();
Client newClient = new Client(newSocket);
clientMap.put(newSocket.getInetAddress().getHostAddress(), newClient);
new Thread(newClient).start();
} catch (IOException ex) {
System.err.println("Socket error on client socket!");
ex.printStackTrace();
}
} catch (IOException ex){
System.err.println("Socket error on client socket!");
ex.printStackTrace();
}
}