ability to return to main menu from in game
This commit is contained in:
parent
3ece6523f3
commit
337da83070
@ -654,6 +654,7 @@ Bug Fixes
|
|||||||
- Calculate bounding sphere for meshes by deforming vertices with bone default pose instead of no bone deform
|
- Calculate bounding sphere for meshes by deforming vertices with bone default pose instead of no bone deform
|
||||||
- Fix character creation menu
|
- Fix character creation menu
|
||||||
- Fix text input collapsing while typing
|
- Fix text input collapsing while typing
|
||||||
|
- Fix threads not synchronizing when returning to main menu (rendering still running when player entity deleted, race condition)
|
||||||
|
|
||||||
Startup Performance
|
Startup Performance
|
||||||
- Cache loaded typescript
|
- Cache loaded typescript
|
||||||
|
|||||||
@ -596,6 +596,7 @@ public class Globals {
|
|||||||
Globals.playerCamera = null;
|
Globals.playerCamera = null;
|
||||||
Globals.firstPersonEntity = null;
|
Globals.firstPersonEntity = null;
|
||||||
Globals.clientPlayer = null;
|
Globals.clientPlayer = null;
|
||||||
|
Globals.playerManager = new PlayerManager();
|
||||||
clientScene = new Scene();
|
clientScene = new Scene();
|
||||||
clientSceneWrapper = new ClientSceneWrapper(clientScene, new CollisionEngine());
|
clientSceneWrapper = new ClientSceneWrapper(clientScene, new CollisionEngine());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,6 +26,9 @@ import java.util.concurrent.Semaphore;
|
|||||||
*/
|
*/
|
||||||
public class Server implements Runnable {
|
public class Server implements Runnable {
|
||||||
|
|
||||||
|
//tracks whether the server is open or not
|
||||||
|
private boolean isOpen = false;
|
||||||
|
|
||||||
//the port the server is running on
|
//the port the server is running on
|
||||||
int port;
|
int port;
|
||||||
|
|
||||||
@ -70,6 +73,7 @@ public class Server implements Runnable {
|
|||||||
if(port == 0){
|
if(port == 0){
|
||||||
NetUtils.setPort(serverSocket.getLocalPort());
|
NetUtils.setPort(serverSocket.getLocalPort());
|
||||||
}
|
}
|
||||||
|
this.isOpen = true;
|
||||||
} catch(BindException ex){
|
} catch(BindException ex){
|
||||||
LoggerInterface.loggerNetworking.ERROR("Failed to bind server socket!",ex);
|
LoggerInterface.loggerNetworking.ERROR("Failed to bind server socket!",ex);
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
@ -92,6 +96,7 @@ public class Server implements Runnable {
|
|||||||
LoggerInterface.loggerNetworking.ERROR("Socket error on client socket!",ex);
|
LoggerInterface.loggerNetworking.ERROR("Socket error on client socket!",ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
this.isOpen = false;
|
||||||
LoggerInterface.loggerNetworking.WARNING("Server socket thread ended");
|
LoggerInterface.loggerNetworking.WARNING("Server socket thread ended");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,6 +119,7 @@ public class Server implements Runnable {
|
|||||||
if(serverSocket != null){
|
if(serverSocket != null){
|
||||||
serverSocket.close();
|
serverSocket.close();
|
||||||
}
|
}
|
||||||
|
this.isOpen = false;
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@ -173,4 +179,14 @@ public class Server implements Runnable {
|
|||||||
}
|
}
|
||||||
this.connectListLock.release();
|
this.connectListLock.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets whether the server is open or not
|
||||||
|
* @return true if is open, false otherwise
|
||||||
|
*/
|
||||||
|
public boolean isOpen(){
|
||||||
|
return isOpen;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -25,9 +25,6 @@ import java.util.concurrent.TimeUnit;
|
|||||||
*/
|
*/
|
||||||
public class ServerConnectionHandler implements Runnable {
|
public class ServerConnectionHandler implements Runnable {
|
||||||
|
|
||||||
//the player id associated with this connection
|
|
||||||
static int playerIdIncrementer = 0;
|
|
||||||
|
|
||||||
//local carrier variables
|
//local carrier variables
|
||||||
boolean local = false;
|
boolean local = false;
|
||||||
|
|
||||||
@ -96,7 +93,7 @@ public class ServerConnectionHandler implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public ServerConnectionHandler(Socket socket) {
|
public ServerConnectionHandler(Socket socket) {
|
||||||
this.socket = socket;
|
this.socket = socket;
|
||||||
playerID = getNewPlayerID();
|
this.playerID = Player.getNewId();
|
||||||
LoggerInterface.loggerNetworking.INFO("Player ID: " + playerID);
|
LoggerInterface.loggerNetworking.INFO("Player ID: " + playerID);
|
||||||
this.messageProtocol = new MessageProtocol(this);
|
this.messageProtocol = new MessageProtocol(this);
|
||||||
}
|
}
|
||||||
@ -108,7 +105,7 @@ public class ServerConnectionHandler implements Runnable {
|
|||||||
*/
|
*/
|
||||||
public ServerConnectionHandler(InputStream serverInputStream, OutputStream serverOutputStream){
|
public ServerConnectionHandler(InputStream serverInputStream, OutputStream serverOutputStream){
|
||||||
this.local = true;
|
this.local = true;
|
||||||
playerID = getNewPlayerID();
|
this.playerID = Player.getNewId();
|
||||||
LoggerInterface.loggerNetworking.INFO("Player ID: " + playerID);
|
LoggerInterface.loggerNetworking.INFO("Player ID: " + playerID);
|
||||||
inputStream = serverInputStream;
|
inputStream = serverInputStream;
|
||||||
outputStream = serverOutputStream;
|
outputStream = serverOutputStream;
|
||||||
@ -192,7 +189,7 @@ public class ServerConnectionHandler implements Runnable {
|
|||||||
|
|
||||||
|
|
||||||
initialized = true;
|
initialized = true;
|
||||||
while(Globals.threadManager.shouldKeepRunning() && this.isConnected == true){
|
while(Globals.threadManager.shouldKeepRunning() && this.isConnected == true && Globals.server != null && Globals.server.isOpen()){
|
||||||
|
|
||||||
//
|
//
|
||||||
// Main Loop
|
// Main Loop
|
||||||
@ -319,19 +316,10 @@ public class ServerConnectionHandler implements Runnable {
|
|||||||
this.messageProtocol.handleSyncMessages();
|
this.messageProtocol.handleSyncMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPlayerId(int id){
|
|
||||||
playerID = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getPlayerId(){
|
public int getPlayerId(){
|
||||||
return playerID;
|
return playerID;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int getNewPlayerID(){
|
|
||||||
playerIdIncrementer++;
|
|
||||||
return playerIdIncrementer;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setPlayerEntityId(int id){
|
public void setPlayerEntityId(int id){
|
||||||
LoggerInterface.loggerNetworking.DEBUG("Set player(" + this.playerID + ")'s entity ID to be " + id);
|
LoggerInterface.loggerNetworking.DEBUG("Set player(" + this.playerID + ")'s entity ID to be " + id);
|
||||||
playerEntityID = id;
|
playerEntityID = id;
|
||||||
|
|||||||
@ -24,11 +24,7 @@ public class Player {
|
|||||||
|
|
||||||
public Player(ServerConnectionHandler connectionHandler){
|
public Player(ServerConnectionHandler connectionHandler){
|
||||||
this.connectionHandler = connectionHandler;
|
this.connectionHandler = connectionHandler;
|
||||||
idIncrementerLock.acquireUninterruptibly();
|
id = connectionHandler.getPlayerId();
|
||||||
id = idIncrementer;
|
|
||||||
idIncrementer++;
|
|
||||||
idIncrementerLock.release();
|
|
||||||
connectionHandler.setPlayerId(id);
|
|
||||||
this.simulationRadius = Globals.userSettings.getGameplayPhysicsCellRadius();
|
this.simulationRadius = Globals.userSettings.getGameplayPhysicsCellRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,5 +68,18 @@ public class Player {
|
|||||||
this.playerEntity = playerEntity;
|
this.playerEntity = playerEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the next available id
|
||||||
|
* @return The id
|
||||||
|
*/
|
||||||
|
public static int getNewId(){
|
||||||
|
int rVal = -1;
|
||||||
|
idIncrementerLock.acquireUninterruptibly();
|
||||||
|
rVal = idIncrementer;
|
||||||
|
idIncrementer++;
|
||||||
|
idIncrementerLock.release();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user