clean up main file by removing globals
This commit is contained in:
parent
70f54fefd5
commit
0bd0c00f27
@ -11,6 +11,7 @@
|
|||||||
"graphicsPerformanceLODChunkRadius" : 3,
|
"graphicsPerformanceLODChunkRadius" : 3,
|
||||||
"graphicsPerformanceEnableVSync" : false,
|
"graphicsPerformanceEnableVSync" : false,
|
||||||
"graphicsPerformanceDrawShadows" : true,
|
"graphicsPerformanceDrawShadows" : true,
|
||||||
|
"graphicsViewRange" : 20000.0,
|
||||||
|
|
||||||
"graphicsDebugDrawCollisionSpheres" : false,
|
"graphicsDebugDrawCollisionSpheres" : false,
|
||||||
"graphicsDebugDrawPhysicsObjects" : false,
|
"graphicsDebugDrawPhysicsObjects" : false,
|
||||||
|
|||||||
@ -40,6 +40,8 @@ public class UserSettings {
|
|||||||
boolean graphicsDebugDrawMovementVectors;
|
boolean graphicsDebugDrawMovementVectors;
|
||||||
boolean graphicsDebugDrawNavmesh;
|
boolean graphicsDebugDrawNavmesh;
|
||||||
|
|
||||||
|
float graphicsViewRange;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -91,6 +93,10 @@ public class UserSettings {
|
|||||||
return graphicsPerformanceLODChunkRadius;
|
return graphicsPerformanceLODChunkRadius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getGraphicsViewDistance(){
|
||||||
|
return graphicsViewRange;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean graphicsDebugDrawNavmesh() {
|
public boolean graphicsDebugDrawNavmesh() {
|
||||||
return graphicsDebugDrawNavmesh;
|
return graphicsDebugDrawNavmesh;
|
||||||
}
|
}
|
||||||
@ -112,6 +118,10 @@ public class UserSettings {
|
|||||||
this.graphicsDebugDrawNavmesh = draw;
|
this.graphicsDebugDrawNavmesh = draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setGraphicsViewRange(float range){
|
||||||
|
graphicsViewRange = range;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -110,7 +110,7 @@ public class ServerDataCell {
|
|||||||
*/
|
*/
|
||||||
public void broadcastNetworkMessage(NetworkMessage message){
|
public void broadcastNetworkMessage(NetworkMessage message){
|
||||||
for(Player player : activePlayers){
|
for(Player player : activePlayers){
|
||||||
if(player != Globals.serverPlayer){
|
if(player != Globals.clientPlayer){
|
||||||
player.addMessage(message);
|
player.addMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,7 +121,7 @@ public class ServerDataCell {
|
|||||||
* Commonly, this should be called when a player is added to the cell
|
* Commonly, this should be called when a player is added to the cell
|
||||||
*/
|
*/
|
||||||
void serializeStateToPlayer(Player player){
|
void serializeStateToPlayer(Player player){
|
||||||
if(player != Globals.serverPlayer){
|
if(player != Globals.clientPlayer){
|
||||||
for(Entity entity : loadedEntities){
|
for(Entity entity : loadedEntities){
|
||||||
if(CreatureUtils.isCreature(entity)){
|
if(CreatureUtils.isCreature(entity)){
|
||||||
CreatureUtils.sendEntityToPlayer(player, entity);
|
CreatureUtils.sendEntityToPlayer(player, entity);
|
||||||
|
|||||||
@ -174,7 +174,7 @@ public class Globals {
|
|||||||
//Player manager
|
//Player manager
|
||||||
//
|
//
|
||||||
public static PlayerManager playerManager;
|
public static PlayerManager playerManager;
|
||||||
public static Player serverPlayer;
|
public static Player clientPlayer;
|
||||||
|
|
||||||
//
|
//
|
||||||
//Generic OpenGL Statements
|
//Generic OpenGL Statements
|
||||||
|
|||||||
@ -71,42 +71,9 @@ public class Main {
|
|||||||
static double lastFrame = 0.0f;
|
static double lastFrame = 0.0f;
|
||||||
static long frameCount = 0;
|
static long frameCount = 0;
|
||||||
public static float deltaFrames = 0;
|
public static float deltaFrames = 0;
|
||||||
//View Controls
|
|
||||||
public static float view_Range = 200000.0f;
|
|
||||||
/*
|
|
||||||
Mouse Controls
|
|
||||||
*/
|
|
||||||
// static float mouse_lastX = 400;
|
|
||||||
// static float mouse_lastY = 300;
|
|
||||||
// static double xpos = 400;
|
|
||||||
// static double ypos = 300;
|
|
||||||
// static float mouseSensitivity = .1f;
|
|
||||||
// static double mouse_X_Buffer[] = new double[1];
|
|
||||||
// static double mouse_Y_Buffer[] = new double[1];
|
|
||||||
// static float cameraSpeed;
|
|
||||||
// static float yaw = 150;
|
|
||||||
// static float pitch = 50;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static int playerStartRealX = 0;
|
|
||||||
static int playerStartRealY = 0;
|
|
||||||
|
|
||||||
// public static Camera cam_Player_Orbit;
|
|
||||||
//Camera angles using theta-phi system
|
|
||||||
//Euler angles where theta is applied, then phi
|
|
||||||
//There is no bank applied to the camera
|
|
||||||
|
|
||||||
public static Model model;
|
|
||||||
|
|
||||||
public static int playerId = -1;
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean running = true;
|
public static boolean running = true;
|
||||||
|
|
||||||
public static Entity letterEntity;
|
|
||||||
|
|
||||||
//target amount of time per frame
|
//target amount of time per frame
|
||||||
public static float targetFrameRate = 60.0f;
|
public static float targetFrameRate = 60.0f;
|
||||||
static float targetFramePeriod = 1.0f/targetFrameRate;
|
static float targetFramePeriod = 1.0f/targetFrameRate;
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class EntityProtocol {
|
|||||||
Entity target = Globals.entityManager.getEntityFromId(message.getentityID());
|
Entity target = Globals.entityManager.getEntityFromId(message.getentityID());
|
||||||
if(target != null){
|
if(target != null){
|
||||||
CreatureUtils.setControllerPlayerId(target, message.getpropertyValue());
|
CreatureUtils.setControllerPlayerId(target, message.getpropertyValue());
|
||||||
if(message.getpropertyValue() == Main.playerId){
|
if(Globals.clientPlayer != null && message.getpropertyValue() == Globals.clientPlayer.getId()){
|
||||||
Globals.clientCharacterID = message.getentityID();
|
Globals.clientCharacterID = message.getentityID();
|
||||||
Globals.playerEntity = target;
|
Globals.playerEntity = target;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,14 +4,15 @@ import electrosphere.logger.LoggerInterface;
|
|||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import electrosphere.main.Main;
|
import electrosphere.main.Main;
|
||||||
import electrosphere.net.parser.net.message.PlayerMessage;
|
import electrosphere.net.parser.net.message.PlayerMessage;
|
||||||
|
import electrosphere.net.server.player.Player;
|
||||||
|
|
||||||
public class PlayerProtocol {
|
public class PlayerProtocol {
|
||||||
|
|
||||||
protected static void handlePlayerMessage(PlayerMessage message){
|
protected static void handlePlayerMessage(PlayerMessage message){
|
||||||
switch(message.getMessageSubtype()){
|
switch(message.getMessageSubtype()){
|
||||||
case SET_ID:
|
case SET_ID:
|
||||||
Main.playerId = message.getplayerID();
|
Globals.clientPlayer = new Player(message.getplayerID());
|
||||||
LoggerInterface.loggerNetworking.DEBUG("Player ID is " + Main.playerId);
|
LoggerInterface.loggerNetworking.DEBUG("Player ID is " + Globals.clientPlayer.getId());
|
||||||
break;
|
break;
|
||||||
case SETINITIALDISCRETEPOSITION:
|
case SETINITIALDISCRETEPOSITION:
|
||||||
Globals.clientPlayerData.setWorldPosition(message.getinitialDiscretePositionX(), message.getinitialDiscretePositionY());
|
Globals.clientPlayerData.setWorldPosition(message.getinitialDiscretePositionX(), message.getinitialDiscretePositionY());
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package electrosphere.net.server;
|
package electrosphere.net.server;
|
||||||
|
|
||||||
|
import electrosphere.main.Globals;
|
||||||
import electrosphere.main.Main;
|
import electrosphere.main.Main;
|
||||||
import electrosphere.net.NetUtils;
|
import electrosphere.net.NetUtils;
|
||||||
import electrosphere.net.parser.net.message.NetworkMessage;
|
import electrosphere.net.parser.net.message.NetworkMessage;
|
||||||
@ -74,7 +75,7 @@ public class Server implements Runnable{
|
|||||||
|
|
||||||
public void broadcastMessage(NetworkMessage message){
|
public void broadcastMessage(NetworkMessage message){
|
||||||
for(ServerConnectionHandler client : clientMap.values()){
|
for(ServerConnectionHandler client : clientMap.values()){
|
||||||
if(client.playerID != Main.playerId){
|
if(Globals.clientPlayer == null || client.playerID != Globals.clientPlayer.getId()){
|
||||||
client.addMessagetoOutgoingQueue(message);
|
client.addMessagetoOutgoingQueue(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -32,6 +32,11 @@ public class Player {
|
|||||||
this.simulationRadius = Globals.userSettings.getGameplayPhysicsCellRadius();
|
this.simulationRadius = Globals.userSettings.getGameplayPhysicsCellRadius();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//used for when client is creating a player object for itself
|
||||||
|
public Player(int id){
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -19,7 +19,7 @@ public class AuthProtocol {
|
|||||||
Player newPlayer = new Player(connectionHandler);
|
Player newPlayer = new Player(connectionHandler);
|
||||||
Globals.playerManager.registerPlayer(newPlayer);
|
Globals.playerManager.registerPlayer(newPlayer);
|
||||||
if(connectionHandler.getIPAddress().contains("127.0.0.1")){
|
if(connectionHandler.getIPAddress().contains("127.0.0.1")){
|
||||||
Globals.serverPlayer = newPlayer;
|
Globals.clientPlayer = newPlayer;
|
||||||
}
|
}
|
||||||
connectionHandler.addMessagetoOutgoingQueue(PlayerMessage.constructSet_IDMessage(connectionHandler.getPlayerId()));
|
connectionHandler.addMessagetoOutgoingQueue(PlayerMessage.constructSet_IDMessage(connectionHandler.getPlayerId()));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -60,7 +60,7 @@ public class CharacterProtocol {
|
|||||||
// Entity sword = ItemUtils.spawnBasicItem("Katana");
|
// Entity sword = ItemUtils.spawnBasicItem("Katana");
|
||||||
// AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031");
|
// AttachUtils.attachEntityToEntityAtBone(newPlayerCharacter, sword, "Bone.031");
|
||||||
//set controller id
|
//set controller id
|
||||||
if(playerObject == Globals.serverPlayer){
|
if(playerObject == Globals.clientPlayer){
|
||||||
Globals.playerEntity = newPlayerEntity;
|
Globals.playerEntity = newPlayerEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -53,7 +53,7 @@ public class EntityProtocol {
|
|||||||
|
|
||||||
void queueChunkState(ServerConnectionHandler connectionHandler){
|
void queueChunkState(ServerConnectionHandler connectionHandler){
|
||||||
//queue messages for that chunk
|
//queue messages for that chunk
|
||||||
if(Globals.RUN_SERVER && Main.playerId == -1){
|
if(Globals.RUN_SERVER && Globals.clientPlayer == null){
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
for(Entity currentEntity : Globals.entityManager.getMoveable()){
|
for(Entity currentEntity : Globals.entityManager.getMoveable()){
|
||||||
|
|||||||
@ -14,7 +14,6 @@ import electrosphere.game.server.pathfinding.navmesh.NavMesh;
|
|||||||
import electrosphere.game.server.pathfinding.navmesh.NavShape;
|
import electrosphere.game.server.pathfinding.navmesh.NavShape;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
import static electrosphere.main.Main.view_Range;
|
|
||||||
import static electrosphere.renderer.RenderUtils.createScreenTextureVAO;
|
import static electrosphere.renderer.RenderUtils.createScreenTextureVAO;
|
||||||
|
|
||||||
import electrosphere.renderer.actor.Actor;
|
import electrosphere.renderer.actor.Actor;
|
||||||
@ -392,7 +391,7 @@ public class RenderingEngine {
|
|||||||
float verticalFOV = (float)(Globals.verticalFOV * Math.PI /180.0f);
|
float verticalFOV = (float)(Globals.verticalFOV * Math.PI /180.0f);
|
||||||
float aspectRatio = (float)Globals.WINDOW_WIDTH / (float)Globals.WINDOW_HEIGHT;
|
float aspectRatio = (float)Globals.WINDOW_WIDTH / (float)Globals.WINDOW_HEIGHT;
|
||||||
float nearClip = 0.001f;
|
float nearClip = 0.001f;
|
||||||
Globals.projectionMatrix.setPerspective(verticalFOV, aspectRatio, nearClip, view_Range);
|
Globals.projectionMatrix.setPerspective(verticalFOV, aspectRatio, nearClip, Globals.userSettings.getGraphicsViewDistance());
|
||||||
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
|
Globals.viewMatrix.translation(new Vector3f(0.0f,0.0f,-3.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user