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
|
||||
- Fix character creation menu
|
||||
- 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
|
||||
- Cache loaded typescript
|
||||
|
||||
@ -596,6 +596,7 @@ public class Globals {
|
||||
Globals.playerCamera = null;
|
||||
Globals.firstPersonEntity = null;
|
||||
Globals.clientPlayer = null;
|
||||
Globals.playerManager = new PlayerManager();
|
||||
clientScene = new Scene();
|
||||
clientSceneWrapper = new ClientSceneWrapper(clientScene, new CollisionEngine());
|
||||
}
|
||||
|
||||
@ -25,6 +25,9 @@ import java.util.concurrent.Semaphore;
|
||||
* Lowest level networking class for the server
|
||||
*/
|
||||
public class Server implements Runnable {
|
||||
|
||||
//tracks whether the server is open or not
|
||||
private boolean isOpen = false;
|
||||
|
||||
//the port the server is running on
|
||||
int port;
|
||||
@ -70,6 +73,7 @@ public class Server implements Runnable {
|
||||
if(port == 0){
|
||||
NetUtils.setPort(serverSocket.getLocalPort());
|
||||
}
|
||||
this.isOpen = true;
|
||||
} catch(BindException ex){
|
||||
LoggerInterface.loggerNetworking.ERROR("Failed to bind server socket!",ex);
|
||||
} catch (IOException ex) {
|
||||
@ -92,6 +96,7 @@ public class Server implements Runnable {
|
||||
LoggerInterface.loggerNetworking.ERROR("Socket error on client socket!",ex);
|
||||
}
|
||||
}
|
||||
this.isOpen = false;
|
||||
LoggerInterface.loggerNetworking.WARNING("Server socket thread ended");
|
||||
}
|
||||
|
||||
@ -114,6 +119,7 @@ public class Server implements Runnable {
|
||||
if(serverSocket != null){
|
||||
serverSocket.close();
|
||||
}
|
||||
this.isOpen = false;
|
||||
} catch (IOException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -173,4 +179,14 @@ public class Server implements Runnable {
|
||||
}
|
||||
this.connectListLock.release();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whether the server is open or not
|
||||
* @return true if is open, false otherwise
|
||||
*/
|
||||
public boolean isOpen(){
|
||||
return isOpen;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -24,9 +24,6 @@ import java.util.concurrent.TimeUnit;
|
||||
* A connection to the server
|
||||
*/
|
||||
public class ServerConnectionHandler implements Runnable {
|
||||
|
||||
//the player id associated with this connection
|
||||
static int playerIdIncrementer = 0;
|
||||
|
||||
//local carrier variables
|
||||
boolean local = false;
|
||||
@ -96,7 +93,7 @@ public class ServerConnectionHandler implements Runnable {
|
||||
*/
|
||||
public ServerConnectionHandler(Socket socket) {
|
||||
this.socket = socket;
|
||||
playerID = getNewPlayerID();
|
||||
this.playerID = Player.getNewId();
|
||||
LoggerInterface.loggerNetworking.INFO("Player ID: " + playerID);
|
||||
this.messageProtocol = new MessageProtocol(this);
|
||||
}
|
||||
@ -108,7 +105,7 @@ public class ServerConnectionHandler implements Runnable {
|
||||
*/
|
||||
public ServerConnectionHandler(InputStream serverInputStream, OutputStream serverOutputStream){
|
||||
this.local = true;
|
||||
playerID = getNewPlayerID();
|
||||
this.playerID = Player.getNewId();
|
||||
LoggerInterface.loggerNetworking.INFO("Player ID: " + playerID);
|
||||
inputStream = serverInputStream;
|
||||
outputStream = serverOutputStream;
|
||||
@ -192,7 +189,7 @@ public class ServerConnectionHandler implements Runnable {
|
||||
|
||||
|
||||
initialized = true;
|
||||
while(Globals.threadManager.shouldKeepRunning() && this.isConnected == true){
|
||||
while(Globals.threadManager.shouldKeepRunning() && this.isConnected == true && Globals.server != null && Globals.server.isOpen()){
|
||||
|
||||
//
|
||||
// Main Loop
|
||||
@ -318,19 +315,10 @@ public class ServerConnectionHandler implements Runnable {
|
||||
public void handleSynchronousPacketQueue(){
|
||||
this.messageProtocol.handleSyncMessages();
|
||||
}
|
||||
|
||||
public void setPlayerId(int id){
|
||||
playerID = id;
|
||||
}
|
||||
|
||||
public int getPlayerId(){
|
||||
return playerID;
|
||||
}
|
||||
|
||||
static int getNewPlayerID(){
|
||||
playerIdIncrementer++;
|
||||
return playerIdIncrementer;
|
||||
}
|
||||
|
||||
public void setPlayerEntityId(int id){
|
||||
LoggerInterface.loggerNetworking.DEBUG("Set player(" + this.playerID + ")'s entity ID to be " + id);
|
||||
|
||||
@ -24,11 +24,7 @@ public class Player {
|
||||
|
||||
public Player(ServerConnectionHandler connectionHandler){
|
||||
this.connectionHandler = connectionHandler;
|
||||
idIncrementerLock.acquireUninterruptibly();
|
||||
id = idIncrementer;
|
||||
idIncrementer++;
|
||||
idIncrementerLock.release();
|
||||
connectionHandler.setPlayerId(id);
|
||||
id = connectionHandler.getPlayerId();
|
||||
this.simulationRadius = Globals.userSettings.getGameplayPhysicsCellRadius();
|
||||
}
|
||||
|
||||
@ -71,6 +67,19 @@ public class Player {
|
||||
public void setPlayerEntity(Entity 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