move client networking to clientState
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2025-05-15 12:12:57 -04:00
parent eddadf8b57
commit f7790931bc
48 changed files with 94 additions and 91 deletions

View File

@ -1808,6 +1808,7 @@ Move clientScene to clientState
Move clientSceneWrapper to clientState Move clientSceneWrapper to clientState
Move clientSimulation to clientState Move clientSimulation to clientState
Move clientSynchronizationMAnager to clientState Move clientSynchronizationMAnager to clientState
Move clientConnection to clientState

View File

@ -4,6 +4,7 @@ import electrosphere.client.scene.ClientSceneWrapper;
import electrosphere.client.scene.ClientWorldData; import electrosphere.client.scene.ClientWorldData;
import electrosphere.client.sim.ClientSimulation; import electrosphere.client.sim.ClientSimulation;
import electrosphere.entity.scene.Scene; import electrosphere.entity.scene.Scene;
import electrosphere.net.client.ClientNetworking;
import electrosphere.net.synchronization.client.ClientSynchronizationManager; import electrosphere.net.synchronization.client.ClientSynchronizationManager;
/** /**
@ -36,4 +37,9 @@ public class ClientState {
*/ */
public ClientSynchronizationManager clientSynchronizationManager; public ClientSynchronizationManager clientSynchronizationManager;
/**
* The client network connection
*/
public ClientNetworking clientConnection;
} }

View File

@ -211,7 +211,7 @@ public class ClientBlockManager {
boolean rVal = false; boolean rVal = false;
lock.acquireUninterruptibly(); lock.acquireUninterruptibly();
if(this.requestedMap.size() < MAX_CONCURRENT_REQUESTS && !this.requestedMap.containsKey(this.getRequestKey(worldX, worldY, worldZ, stride))){ if(this.requestedMap.size() < MAX_CONCURRENT_REQUESTS && !this.requestedMap.containsKey(this.getRequestKey(worldX, worldY, worldZ, stride))){
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestReducedBlockDataMessage( Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestReducedBlockDataMessage(
worldX, worldX,
worldY, worldY,
worldZ, worldZ,

View File

@ -138,7 +138,7 @@ public class FluidCellManager {
){ ){
// if(!hasRequested.contains(targetKey)){ // if(!hasRequested.contains(targetKey)){
//client should request chunk data from server //client should request chunk data from server
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestFluidDataMessage( Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestFluidDataMessage(
worldPos.x, worldPos.x,
worldPos.y, worldPos.y,
worldPos.z worldPos.z

View File

@ -16,7 +16,7 @@ public class FluidEditing {
*/ */
public static void editFluid(Vector3d position, float editMagnitude, int type, float weight){ public static void editFluid(Vector3d position, float editMagnitude, int type, float weight){
if(position != null){ if(position != null){
// Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestUseTerrainPaletteMessage(position.x, position.y, position.z, editMagnitude, weight, type)); // Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestUseTerrainPaletteMessage(position.x, position.y, position.z, editMagnitude, weight, type));
//calculate kernel size //calculate kernel size
// int numPlacesToCheck = (int)((editMagnitude * 2 + 1) * (editMagnitude * 2 + 1) * (editMagnitude * 2 + 1)); // int numPlacesToCheck = (int)((editMagnitude * 2 + 1) * (editMagnitude * 2 + 1) * (editMagnitude * 2 + 1));
// //create and fill in kernel of positions to check // //create and fill in kernel of positions to check

View File

@ -56,11 +56,11 @@ public class ButtonInteraction {
} break; } break;
case InteractionData.ON_INTERACT_HARVEST: { case InteractionData.ON_INTERACT_HARVEST: {
int serverEntityId = Globals.clientState.clientSceneWrapper.mapClientToServerId(target.getId()); int serverEntityId = Globals.clientState.clientSceneWrapper.mapClientToServerId(target.getId());
Globals.clientConnection.queueOutgoingMessage(EntityMessage.constructinteractMessage(serverEntityId, InteractionData.ON_INTERACT_HARVEST)); Globals.clientState.clientConnection.queueOutgoingMessage(EntityMessage.constructinteractMessage(serverEntityId, InteractionData.ON_INTERACT_HARVEST));
} break; } break;
case InteractionData.ON_INTERACT_DOOR: { case InteractionData.ON_INTERACT_DOOR: {
int serverEntityId = Globals.clientState.clientSceneWrapper.mapClientToServerId(target.getId()); int serverEntityId = Globals.clientState.clientSceneWrapper.mapClientToServerId(target.getId());
Globals.clientConnection.queueOutgoingMessage(EntityMessage.constructinteractMessage(serverEntityId, InteractionData.ON_INTERACT_DOOR)); Globals.clientState.clientConnection.queueOutgoingMessage(EntityMessage.constructinteractMessage(serverEntityId, InteractionData.ON_INTERACT_DOOR));
} break; } break;
case InteractionData.ON_INTERACT_DIALOG: { case InteractionData.ON_INTERACT_DIALOG: {
DialogMenuGenerator.displayEntityDialog(target); DialogMenuGenerator.displayEntityDialog(target);
@ -69,7 +69,7 @@ public class ButtonInteraction {
LoggerInterface.loggerEngine.DEBUG("Interacting with inventory"); LoggerInterface.loggerEngine.DEBUG("Interacting with inventory");
InventoryMainWindow.viewInventory(target); InventoryMainWindow.viewInventory(target);
InventoryMainWindow.viewInventory(Globals.playerEntity); InventoryMainWindow.viewInventory(Globals.playerEntity);
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestWatchInventoryMessage(Globals.clientState.clientSceneWrapper.mapClientToServerId(target.getId()))); Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestWatchInventoryMessage(Globals.clientState.clientSceneWrapper.mapClientToServerId(target.getId())));
} break; } break;
default: { default: {
throw new Error("Unhandled interaction signal " + interactionData.getOnInteract()); throw new Error("Unhandled interaction signal " + interactionData.getOnInteract());

View File

@ -96,7 +96,7 @@ public class ItemActions {
if(sendServerMessage){ if(sendServerMessage){
//tell the server we want the secondary hand item to START doing something //tell the server we want the secondary hand item to START doing something
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage( Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage(
"handRight", "handRight",
ITEM_ACTION_CODE_PRIMARY, ITEM_ACTION_CODE_PRIMARY,
ITEM_ACTION_CODE_STATE_ON, ITEM_ACTION_CODE_STATE_ON,
@ -121,7 +121,7 @@ public class ItemActions {
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE)); cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
} }
//tell the server we want the secondary hand item to STOP doing something //tell the server we want the secondary hand item to STOP doing something
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage( Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage(
"handRight", "handRight",
ITEM_ACTION_CODE_PRIMARY, ITEM_ACTION_CODE_PRIMARY,
ITEM_ACTION_CODE_STATE_REPEAT, ITEM_ACTION_CODE_STATE_REPEAT,
@ -146,7 +146,7 @@ public class ItemActions {
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE)); cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
} }
//tell the server we want the secondary hand item to STOP doing something //tell the server we want the secondary hand item to STOP doing something
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage( Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage(
"handRight", "handRight",
ITEM_ACTION_CODE_PRIMARY, ITEM_ACTION_CODE_PRIMARY,
ITEM_ACTION_CODE_STATE_OFF, ITEM_ACTION_CODE_STATE_OFF,
@ -206,7 +206,7 @@ public class ItemActions {
//send server message //send server message
if(sendServerMessage){ if(sendServerMessage){
//tell the server we want the secondary hand item to START doing something //tell the server we want the secondary hand item to START doing something
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage( Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage(
"handRight", "handRight",
ITEM_ACTION_CODE_SECONDARY, ITEM_ACTION_CODE_SECONDARY,
ITEM_ACTION_CODE_STATE_ON, ITEM_ACTION_CODE_STATE_ON,
@ -258,7 +258,7 @@ public class ItemActions {
//tell the server we want the secondary hand item to STOP doing something //tell the server we want the secondary hand item to STOP doing something
if(sendServerMessage){ if(sendServerMessage){
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage( Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage(
"handRight", "handRight",
ITEM_ACTION_CODE_SECONDARY, ITEM_ACTION_CODE_SECONDARY,
ITEM_ACTION_CODE_STATE_REPEAT, ITEM_ACTION_CODE_STATE_REPEAT,
@ -283,7 +283,7 @@ public class ItemActions {
cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE)); cursorPos = new Vector3d(centerPos).add(new Vector3d(eyePos).normalize().mul(-CollisionEngine.DEFAULT_INTERACT_DISTANCE));
} }
//tell the server we want the secondary hand item to STOP doing something //tell the server we want the secondary hand item to STOP doing something
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage( Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestPerformItemActionMessage(
"handRight", "handRight",
ITEM_ACTION_CODE_SECONDARY, ITEM_ACTION_CODE_SECONDARY,
ITEM_ACTION_CODE_STATE_OFF, ITEM_ACTION_CODE_STATE_OFF,

View File

@ -129,7 +129,7 @@ public class ScriptClientVoxelUtils {
*/ */
@Export @Export
public static void clientRequestEditBlock(Vector3i chunkPos, Vector3i blockPos, short blockType, short blockMetadata, int size){ public static void clientRequestEditBlock(Vector3i chunkPos, Vector3i blockPos, short blockType, short blockMetadata, int size){
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestEditBlockMessage( Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestEditBlockMessage(
chunkPos.x, chunkPos.y, chunkPos.z, chunkPos.x, chunkPos.y, chunkPos.z,
blockPos.x, blockPos.y, blockPos.z, blockPos.x, blockPos.y, blockPos.z,
blockType, blockMetadata, size blockType, blockMetadata, size
@ -147,7 +147,7 @@ public class ScriptClientVoxelUtils {
Vector3i chunkPos = Globals.clientState.clientWorldData.convertRealToWorldSpace(fabCursorPos); Vector3i chunkPos = Globals.clientState.clientWorldData.convertRealToWorldSpace(fabCursorPos);
Vector3i voxelPos = Globals.clientState.clientWorldData.convertRealToBlockSpace(fabCursorPos); Vector3i voxelPos = Globals.clientState.clientWorldData.convertRealToBlockSpace(fabCursorPos);
int rotation = Globals.cursorState.getFabCursorRotation(); int rotation = Globals.cursorState.getFabCursorRotation();
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestPlaceFabMessage( Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestPlaceFabMessage(
chunkPos.x, chunkPos.y, chunkPos.z, chunkPos.x, chunkPos.y, chunkPos.z,
voxelPos.x, voxelPos.y, voxelPos.z, voxelPos.x, voxelPos.y, voxelPos.z,
rotation, rotation,

View File

@ -19,7 +19,7 @@ public class TerrainEditing {
*/ */
public static void editTerrain(Vector3d position, float editMagnitude, int type, float weight){ public static void editTerrain(Vector3d position, float editMagnitude, int type, float weight){
if(position != null){ if(position != null){
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestUseTerrainPaletteMessage(position.x, position.y, position.z, editMagnitude, weight, type)); Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestUseTerrainPaletteMessage(position.x, position.y, position.z, editMagnitude, weight, type));
//calculate kernel size //calculate kernel size
// int numPlacesToCheck = (int)((editMagnitude * 2 + 1) * (editMagnitude * 2 + 1) * (editMagnitude * 2 + 1)); // int numPlacesToCheck = (int)((editMagnitude * 2 + 1) * (editMagnitude * 2 + 1) * (editMagnitude * 2 + 1));
// //create and fill in kernel of positions to check // //create and fill in kernel of positions to check
@ -74,7 +74,7 @@ public class TerrainEditing {
*/ */
public static void removeTerrainGated(Vector3d position, float editMagnitude, float weight){ public static void removeTerrainGated(Vector3d position, float editMagnitude, float weight){
if(position != null){ if(position != null){
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestDestroyTerrainMessage(position.x, position.y, position.z, editMagnitude, weight)); Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestDestroyTerrainMessage(position.x, position.y, position.z, editMagnitude, weight));
} }
} }

View File

@ -226,7 +226,7 @@ public class ClientTerrainManager {
LoggerInterface.loggerEngine.WARNING("ClientTerrainManager: unhandled network message of type" + message.getMessageSubtype()); LoggerInterface.loggerEngine.WARNING("ClientTerrainManager: unhandled network message of type" + message.getMessageSubtype());
break; break;
} }
Globals.clientConnection.release(message); Globals.clientState.clientConnection.release(message);
} }
messageQueue.clear(); messageQueue.clear();
//evaluate if any terrain chunks have failed to request //evaluate if any terrain chunks have failed to request
@ -300,7 +300,7 @@ public class ClientTerrainManager {
boolean rVal = false; boolean rVal = false;
lock.acquireUninterruptibly(); lock.acquireUninterruptibly();
if(this.requestedMap.size() < MAX_CONCURRENT_REQUESTS && !this.requestedMap.containsKey(this.getRequestKey(worldX, worldY, worldZ, stride))){ if(this.requestedMap.size() < MAX_CONCURRENT_REQUESTS && !this.requestedMap.containsKey(this.getRequestKey(worldX, worldY, worldZ, stride))){
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestReducedChunkDataMessage( Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestReducedChunkDataMessage(
worldX, worldX,
worldY, worldY,
worldZ, worldZ,

View File

@ -140,7 +140,7 @@ public class NaturalInventoryPanel {
0 + "", 0 + "",
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.draggedItem.getId()) Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.draggedItem.getId())
); );
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage); Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
} }
}); });
} }

View File

@ -151,7 +151,7 @@ public class ToolbarInventoryPanel {
slotId + "", slotId + "",
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.draggedItem.getId()) Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.draggedItem.getId())
); );
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage); Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
}); });
} }

View File

@ -79,7 +79,7 @@ public class ImGuiPlayerEntity {
// //
//swap editor/noneditor //swap editor/noneditor
if(ImGui.button("Swap Entity")){ if(ImGui.button("Swap Entity")){
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructEditorSwapMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructEditorSwapMessage());
} }
ImGui.sameLine(); ImGui.sameLine();

View File

@ -45,8 +45,8 @@ public class ImGuiNetworkMonitor {
//client network pressure //client network pressure
if(Globals.clientConnection != null){ if(Globals.clientState.clientConnection != null){
long clientPressureNewTotal = Globals.clientConnection.getNumBytesRead(); long clientPressureNewTotal = Globals.clientState.clientConnection.getNumBytesRead();
long clientPressureDelta = clientPressureNewTotal - clientPressureLastValue; long clientPressureDelta = clientPressureNewTotal - clientPressureLastValue;
clientPressureDataset.addPoint(clientPressureDelta); clientPressureDataset.addPoint(clientPressureDelta);
clientPressureLastValue = clientPressureNewTotal; clientPressureLastValue = clientPressureNewTotal;

View File

@ -58,13 +58,13 @@ public class CraftingWindow {
data, data,
(RecipeData recipe) -> { (RecipeData recipe) -> {
if(Globals.interactionTarget != null){ if(Globals.interactionTarget != null){
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestCraftMessage( Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestCraftMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()),
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.interactionTarget.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.interactionTarget.getId()),
recipe.getId() recipe.getId()
)); ));
} else { } else {
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestCraftMessage( Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientRequestCraftMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()),
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()),
recipe.getId() recipe.getId()

View File

@ -41,8 +41,8 @@ public class MenuCharacterCreation {
for(CharacterDescriptionDTO description : Globals.clientCharacterManager.getCharacterList().getCharacters()){ for(CharacterDescriptionDTO description : Globals.clientCharacterManager.getCharacterList().getCharacters()){
String buttonTitle = "Character " + description.getId(); String buttonTitle = "Character " + description.getId();
Div charNameContainer = Div.createRow(Button.createButton(buttonTitle, () -> { Div charNameContainer = Div.createRow(Button.createButton(buttonTitle, () -> {
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage(description.getId())); Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage(description.getId()));
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
Globals.threadManager.start(new LoadingThread(LoadingThreadType.CLIENT_WORLD)); Globals.threadManager.start(new LoadingThread(LoadingThreadType.CLIENT_WORLD));
})); }));
selectContainer.addChild(charNameContainer); selectContainer.addChild(charNameContainer);
@ -97,7 +97,7 @@ public class MenuCharacterCreation {
FormElement rVal = new FormElement(); FormElement rVal = new FormElement();
rVal.addChild(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (ObjectTemplate template) -> { rVal.addChild(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (ObjectTemplate template) -> {
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCreateCharacterMessage(Utilities.stringify(template))); Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCreateCharacterMessage(Utilities.stringify(template)));
})); }));
return rVal; return rVal;

View File

@ -64,7 +64,7 @@ public class MenuGeneratorsMultiplayer {
rVal.addChild(createButton); rVal.addChild(createButton);
createButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){ createButton.setOnClick(new ClickableElement.ClickEventCallback(){public boolean execute(ClickEvent event){
WindowUtils.replaceMainMenuContents(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (ObjectTemplate template) -> { WindowUtils.replaceMainMenuContents(CharacterCustomizer.createCharacterCustomizerPanel(selectedRace, (ObjectTemplate template) -> {
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCreateCharacterMessage(Utilities.stringify(template))); Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCreateCharacterMessage(Utilities.stringify(template)));
})); }));
return false; return false;
}}); }});

View File

@ -151,7 +151,7 @@ public class CameraHandler {
perspectiveVal = CameraHandler.CAMERA_PERSPECTIVE_THIRD; perspectiveVal = CameraHandler.CAMERA_PERSPECTIVE_THIRD;
} }
if(Globals.cameraHandler.getTrackPlayerEntity() && Globals.playerEntity != null){ if(Globals.cameraHandler.getTrackPlayerEntity() && Globals.playerEntity != null){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
EntityMessage.constructupdateEntityViewDirMessage( EntityMessage.constructupdateEntityViewDirMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.playerEntity.getId()),
Globals.timekeeper.getNumberOfSimFramesElapsed(), Globals.timekeeper.getNumberOfSimFramesElapsed(),

View File

@ -63,7 +63,7 @@ public class ControlCategoryInGameDebug {
alwaysOnDebugControlList.add(controlMap.get(DEBUG_SWAP_EDITOR_MODE)); alwaysOnDebugControlList.add(controlMap.get(DEBUG_SWAP_EDITOR_MODE));
controlMap.get(DEBUG_SWAP_EDITOR_MODE).setOnPress(new ControlMethod(){public void execute(MouseState mouseState){ controlMap.get(DEBUG_SWAP_EDITOR_MODE).setOnPress(new ControlMethod(){public void execute(MouseState mouseState){
LoggerInterface.loggerEngine.INFO("Swap to/from editor entity"); LoggerInterface.loggerEngine.INFO("Swap to/from editor entity");
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructEditorSwapMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructEditorSwapMessage());
}}); }});
controlMap.get(DEBUG_SWAP_EDITOR_MODE).setRepeatTimeout(0.5f * Main.targetFrameRate); controlMap.get(DEBUG_SWAP_EDITOR_MODE).setRepeatTimeout(0.5f * Main.targetFrameRate);

View File

@ -54,7 +54,6 @@ import electrosphere.engine.time.Timekeeper;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.scene.Scene; import electrosphere.entity.scene.Scene;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.net.client.ClientNetworking;
import electrosphere.net.config.NetConfig; import electrosphere.net.config.NetConfig;
import electrosphere.net.monitor.NetMonitor; import electrosphere.net.monitor.NetMonitor;
import electrosphere.net.server.Server; import electrosphere.net.server.Server;
@ -169,9 +168,8 @@ public class Globals {
public static boolean EXPLICIT_SLEEP = true; public static boolean EXPLICIT_SLEEP = true;
// //
//Client connection to server //Signals for running various parts of the engine
// //
public static ClientNetworking clientConnection;
public static boolean RUN_DEMO = false; public static boolean RUN_DEMO = false;
public static boolean RUN_CLIENT = true; public static boolean RUN_CLIENT = true;
public static boolean RUN_HIDDEN = false; //glfw session will be created with hidden window public static boolean RUN_HIDDEN = false; //glfw session will be created with hidden window
@ -753,7 +751,6 @@ public class Globals {
Globals.signalSystem = null; Globals.signalSystem = null;
Globals.serviceManager = null; Globals.serviceManager = null;
Globals.fileWatcherService = null; Globals.fileWatcherService = null;
Globals.clientConnection = null;
Globals.server = null; Globals.server = null;
Globals.serverSynchronizationManager = null; Globals.serverSynchronizationManager = null;
Globals.aiManager = null; Globals.aiManager = null;

View File

@ -231,10 +231,10 @@ public class Main {
/// C L I E N T N E T W O R K I N G S T U F F /// C L I E N T N E T W O R K I N G S T U F F
/// ///
//Why is this its own function? Just to get the networking code out of main() //Why is this its own function? Just to get the networking code out of main()
if(Globals.clientConnection != null){ if(Globals.clientState.clientConnection != null){
Globals.profiler.beginCpuSample("Client networking"); Globals.profiler.beginCpuSample("Client networking");
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin parse client messages"); LoggerInterface.loggerEngine.DEBUG_LOOP("Begin parse client messages");
Globals.clientConnection.parseMessagesSynchronous(); Globals.clientState.clientConnection.parseMessagesSynchronous();
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
} }

View File

@ -81,7 +81,7 @@ public class ChunkGenerationTestLoading {
Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor"); Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor");
ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true); ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true);
//wait for player object creation //wait for player object creation
while(Globals.playerManager.getPlayers().size() < 1 || !Globals.clientConnection.isInitialized()){ while(Globals.playerManager.getPlayers().size() < 1 || !Globals.clientState.clientConnection.isInitialized()){
try { try {
TimeUnit.MILLISECONDS.sleep(1); TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -108,7 +108,7 @@ public class ChunkGenerationTestLoading {
LoadingUtils.spawnLocalPlayerTestEntity(serverPlayerConnection, true); LoadingUtils.spawnLocalPlayerTestEntity(serverPlayerConnection, true);
//request terrain data //request terrain data
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
//Run client startup process //Run client startup process
ClientLoading.loadClientWorld(params); ClientLoading.loadClientWorld(params);

View File

@ -80,9 +80,9 @@ public class ClientLoading {
while(Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces().size() == 0){ while(Globals.gameConfigCurrent.getCreatureTypeLoader().getPlayableRaces().size() == 0){
if(framesWaited % LORE_RESEND_FRAMES == (LORE_RESEND_FRAMES - 1)){ if(framesWaited % LORE_RESEND_FRAMES == (LORE_RESEND_FRAMES - 1)){
//request playable races //request playable races
Globals.clientConnection.queueOutgoingMessage(LoreMessage.constructRequestRacesMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(LoreMessage.constructRequestRacesMessage());
//request characters available to this player //request characters available to this player
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCharacterListMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCharacterListMessage());
} }
try { try {
TimeUnit.MILLISECONDS.sleep(5); TimeUnit.MILLISECONDS.sleep(5);
@ -204,8 +204,8 @@ public class ClientLoading {
private static void initClientThread(){ private static void initClientThread(){
//start client networking //start client networking
if(Globals.RUN_CLIENT){ if(Globals.RUN_CLIENT){
Globals.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort()); Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientConnection)); Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
} }
} }

View File

@ -76,7 +76,7 @@ public class DebugSPWorldLoading {
LoadingUtils.spawnLocalPlayerTestEntity(serverPlayerConnection, false); LoadingUtils.spawnLocalPlayerTestEntity(serverPlayerConnection, false);
//request terrain data //request terrain data
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
//Run client startup process //Run client startup process
ClientLoading.loadClientWorld(params); ClientLoading.loadClientWorld(params);

View File

@ -77,7 +77,7 @@ public class LevelEditorLoading {
Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor"); Globals.clientPassword = AuthenticationManager.getHashedString("leveleditor");
ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true); ServerConnectionHandler serverPlayerConnection = LoadingUtils.initLocalConnection(true);
//wait for player object creation //wait for player object creation
while(Globals.playerManager.getPlayers().size() < 1 || !Globals.clientConnection.isInitialized()){ while(Globals.playerManager.getPlayers().size() < 1 || !Globals.clientState.clientConnection.isInitialized()){
try { try {
TimeUnit.MILLISECONDS.sleep(1); TimeUnit.MILLISECONDS.sleep(1);
} catch (InterruptedException e) { } catch (InterruptedException e) {
@ -104,7 +104,7 @@ public class LevelEditorLoading {
LoadingUtils.spawnLocalPlayerTestEntity(serverPlayerConnection, true); LoadingUtils.spawnLocalPlayerTestEntity(serverPlayerConnection, true);
//request terrain data //request terrain data
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
//Run client startup process //Run client startup process
ClientLoading.loadClientWorld(params); ClientLoading.loadClientWorld(params);

View File

@ -75,7 +75,7 @@ public class LevelLoading {
LoadingUtils.spawnLocalPlayerTestEntity(serverPlayerConnection, false); LoadingUtils.spawnLocalPlayerTestEntity(serverPlayerConnection, false);
//request terrain data //request terrain data
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
//Run client startup process //Run client startup process
ClientLoading.loadClientWorld(params); ClientLoading.loadClientWorld(params);

View File

@ -71,8 +71,8 @@ public class LoadingUtils {
static void initClientThread(){ static void initClientThread(){
//start client networking //start client networking
if(Globals.RUN_CLIENT){ if(Globals.RUN_CLIENT){
Globals.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort()); Globals.clientState.clientConnection = new ClientNetworking(NetUtils.getAddress(),NetUtils.getPort());
Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientConnection)); Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
} }
} }
@ -100,8 +100,8 @@ public class LoadingUtils {
//start server communication thread //start server communication thread
rVal = Globals.server.addLocalPlayer(serverInput, serverOutput); rVal = Globals.server.addLocalPlayer(serverInput, serverOutput);
//start client communication thread //start client communication thread
Globals.clientConnection = new ClientNetworking(clientInput,clientOutput); Globals.clientState.clientConnection = new ClientNetworking(clientInput,clientOutput);
Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientConnection)); Globals.threadManager.start(ThreadLabel.NETWORKING_CLIENT, new Thread(Globals.clientState.clientConnection));
} catch (IOException e) { } catch (IOException e) {
LoggerInterface.loggerNetworking.ERROR(e); LoggerInterface.loggerNetworking.ERROR(e);
} }
@ -181,7 +181,7 @@ public class LoadingUtils {
//set player character template //set player character template
serverPlayerConnection.setCreatureTemplate(template); serverPlayerConnection.setCreatureTemplate(template);
Character chara = Globals.characterService.createCharacter(template, serverPlayerConnection.getPlayerId()); Character chara = Globals.characterService.createCharacter(template, serverPlayerConnection.getPlayerId());
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage(chara.getId() + "")); Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage(chara.getId() + ""));
//set player world-space coordinates //set player world-space coordinates
Player playerObject = Globals.playerManager.getFirstPlayer(); Player playerObject = Globals.playerManager.getFirstPlayer();

View File

@ -52,7 +52,7 @@ public class MainMenuLoading {
private static void resetClientState(){ private static void resetClientState(){
Globals.playerEntity = null; Globals.playerEntity = null;
Globals.clientState.clientSimulation = null; Globals.clientState.clientSimulation = null;
Globals.clientConnection.setShouldDisconnect(true); Globals.clientState.clientConnection.setShouldDisconnect(true);
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false); Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
} }

View File

@ -65,7 +65,7 @@ public class ViewportLoading {
LoggerInterface.loggerEngine.INFO("[Server]Finished loading level editor"); LoggerInterface.loggerEngine.INFO("[Server]Finished loading level editor");
//request terrain data //request terrain data
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
//block for client world data //block for client world data
while(Globals.clientState.clientWorldData == null){ while(Globals.clientState.clientWorldData == null){

View File

@ -129,7 +129,7 @@ public class StateTransitionUtil {
//Calculate offset to start the animation at //Calculate offset to start the animation at
double animationOffset = 0.0001; double animationOffset = 0.0001;
if(this.accountForSync){ if(this.accountForSync){
int delay = Globals.clientConnection.getDelay(); int delay = Globals.clientState.clientConnection.getDelay();
double simFrameTime = Globals.timekeeper.getSimFrameTime(); double simFrameTime = Globals.timekeeper.getSimFrameTime();
animationOffset = delay * simFrameTime; animationOffset = delay * simFrameTime;
} }

View File

@ -275,7 +275,7 @@ public class ClientAttackTree implements BehaviorTree {
this.setAttackMoveTypeActive(attackType); this.setAttackMoveTypeActive(attackType);
currentMoveset = this.getMoveset(attackType); currentMoveset = this.getMoveset(attackType);
if(currentMoveset != null){ if(currentMoveset != null){
Globals.clientConnection.queueOutgoingMessage(EntityMessage.constructstartAttackMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(EntityMessage.constructstartAttackMessage());
} }
} }
} }

View File

@ -95,7 +95,7 @@ public class ClientEquipState implements BehaviorTree {
String pointName = point.getEquipPointId(); String pointName = point.getEquipPointId();
int serverSideID = Globals.clientState.clientSceneWrapper.mapClientToServerId(toEquip.getId()); int serverSideID = Globals.clientState.clientSceneWrapper.mapClientToServerId(toEquip.getId());
NetworkMessage requestPickupMessage = InventoryMessage.constructclientRequestEquipItemMessage(pointName, serverSideID); NetworkMessage requestPickupMessage = InventoryMessage.constructclientRequestEquipItemMessage(pointName, serverSideID);
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage); Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
} }
} }
@ -314,7 +314,7 @@ public class ClientEquipState implements BehaviorTree {
if(hasEquipped){ if(hasEquipped){
//send packet to server requesting to equip //send packet to server requesting to equip
NetworkMessage requestUnequipMessage = InventoryMessage.constructclientRequestUnequipItemMessage(pointId); NetworkMessage requestUnequipMessage = InventoryMessage.constructclientRequestUnequipItemMessage(pointId);
Globals.clientConnection.queueOutgoingMessage(requestUnequipMessage); Globals.clientState.clientConnection.queueOutgoingMessage(requestUnequipMessage);
} }
} }

View File

@ -82,7 +82,7 @@ public class ClientToolbarState implements BehaviorTree {
public void attemptAddToToolbar(Entity item, int toolbarSlot){ public void attemptAddToToolbar(Entity item, int toolbarSlot){
if(item != null){ if(item != null){
NetworkMessage requestUnequipMessage = InventoryMessage.constructclientRequestAddToolbarMessage(Globals.clientState.clientSceneWrapper.mapClientToServerId(item.getId()), toolbarSlot); NetworkMessage requestUnequipMessage = InventoryMessage.constructclientRequestAddToolbarMessage(Globals.clientState.clientSceneWrapper.mapClientToServerId(item.getId()), toolbarSlot);
Globals.clientConnection.queueOutgoingMessage(requestUnequipMessage); Globals.clientState.clientConnection.queueOutgoingMessage(requestUnequipMessage);
} }
} }
@ -311,7 +311,7 @@ public class ClientToolbarState implements BehaviorTree {
value = value + MAX_TOOLBAR_SIZE; value = value + MAX_TOOLBAR_SIZE;
} }
value = value % MAX_TOOLBAR_SIZE; value = value % MAX_TOOLBAR_SIZE;
Globals.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientUpdateToolbarMessage(value)); Globals.clientState.clientConnection.queueOutgoingMessage(InventoryMessage.constructclientUpdateToolbarMessage(value));
} }

View File

@ -294,7 +294,7 @@ public class ClientInventoryState implements BehaviorTree {
NetworkMessage requestPickupMessage = InventoryMessage.constructclientRequestAddNaturalMessage( NetworkMessage requestPickupMessage = InventoryMessage.constructclientRequestAddNaturalMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(item.getId()) Globals.clientState.clientSceneWrapper.mapClientToServerId(item.getId())
); );
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage); Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
} }
/** /**
@ -309,7 +309,7 @@ public class ClientInventoryState implements BehaviorTree {
Globals.clientState.clientSceneWrapper.mapClientToServerId(item.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(item.getId()),
ItemUtils.getType(item) ItemUtils.getType(item)
); );
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage); Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
} }
/** /**
@ -352,7 +352,7 @@ public class ClientInventoryState implements BehaviorTree {
public static void clientAttemptEjectItem(Entity creature, Entity item){ public static void clientAttemptEjectItem(Entity creature, Entity item){
//if we're the client, tell the server we want to try the transform //if we're the client, tell the server we want to try the transform
NetworkMessage requestPickupMessage = InventoryMessage.constructremoveItemFromInventoryMessage(Globals.clientState.clientSceneWrapper.mapClientToServerId(item.getId())); NetworkMessage requestPickupMessage = InventoryMessage.constructremoveItemFromInventoryMessage(Globals.clientState.clientSceneWrapper.mapClientToServerId(item.getId()));
Globals.clientConnection.queueOutgoingMessage(requestPickupMessage); Globals.clientState.clientConnection.queueOutgoingMessage(requestPickupMessage);
if(Globals.virtualAudioSourceManager != null){ if(Globals.virtualAudioSourceManager != null){
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(item)); Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(item));
if(itemData != null && itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){ if(itemData != null && itemData.getItemAudio() != null && itemData.getItemAudio().getUIReleaseAudio() != null){

View File

@ -140,7 +140,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
Quaterniond rotation = EntityUtils.getRotation(parent); Quaterniond rotation = EntityUtils.getRotation(parent);
float velocity = CreatureUtils.getVelocity(parent); float velocity = CreatureUtils.getVelocity(parent);
if(this.parent == Globals.playerEntity){ if(this.parent == Globals.playerEntity){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
EntityMessage.constructmoveUpdateMessage( EntityMessage.constructmoveUpdateMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
Globals.timekeeper.getNumberOfSimFramesElapsed(), Globals.timekeeper.getNumberOfSimFramesElapsed(),
@ -170,7 +170,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
Quaterniond rotation = EntityUtils.getRotation(parent); Quaterniond rotation = EntityUtils.getRotation(parent);
float velocity = CreatureUtils.getVelocity(parent); float velocity = CreatureUtils.getVelocity(parent);
if(this.parent == Globals.playerEntity){ if(this.parent == Globals.playerEntity){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
EntityMessage.constructmoveUpdateMessage( EntityMessage.constructmoveUpdateMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
Globals.timekeeper.getNumberOfSimFramesElapsed(), Globals.timekeeper.getNumberOfSimFramesElapsed(),

View File

@ -148,7 +148,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
Quaterniond rotation = EntityUtils.getRotation(parent); Quaterniond rotation = EntityUtils.getRotation(parent);
float velocity = CreatureUtils.getVelocity(parent); float velocity = CreatureUtils.getVelocity(parent);
if(this.parent == Globals.playerEntity){ if(this.parent == Globals.playerEntity){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
EntityMessage.constructmoveUpdateMessage( EntityMessage.constructmoveUpdateMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
Globals.timekeeper.getNumberOfSimFramesElapsed(), Globals.timekeeper.getNumberOfSimFramesElapsed(),
@ -178,7 +178,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
Quaterniond rotation = EntityUtils.getRotation(parent); Quaterniond rotation = EntityUtils.getRotation(parent);
float velocity = CreatureUtils.getVelocity(parent); float velocity = CreatureUtils.getVelocity(parent);
if(this.parent == Globals.playerEntity){ if(this.parent == Globals.playerEntity){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
EntityMessage.constructmoveUpdateMessage( EntityMessage.constructmoveUpdateMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
Globals.timekeeper.getNumberOfSimFramesElapsed(), Globals.timekeeper.getNumberOfSimFramesElapsed(),
@ -296,7 +296,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
default: default:
break; break;
} }
Globals.clientConnection.release(message); Globals.clientState.clientConnection.release(message);
} }
// System.out.println(movementVector + " " + velocity * Main.deltaTime); // System.out.println(movementVector + " " + velocity * Main.deltaTime);

View File

@ -80,7 +80,7 @@ public class ClientJumpTree implements BehaviorTree {
* </p> * </p>
*/ */
public void start(){ public void start(){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
SynchronizationMessage.constructClientRequestBTreeActionMessage( SynchronizationMessage.constructClientRequestBTreeActionMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
BehaviorTreeIdEnums.BTREE_CLIENTJUMPTREE_ID, BehaviorTreeIdEnums.BTREE_CLIENTJUMPTREE_ID,
@ -299,7 +299,7 @@ public class ClientJumpTree implements BehaviorTree {
* </p> * </p>
*/ */
public void interrupt(){ public void interrupt(){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
SynchronizationMessage.constructClientRequestBTreeActionMessage( SynchronizationMessage.constructClientRequestBTreeActionMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
BehaviorTreeIdEnums.BTREE_CLIENTJUMPTREE_ID, BehaviorTreeIdEnums.BTREE_CLIENTJUMPTREE_ID,

View File

@ -61,7 +61,7 @@ public class ClientSprintTree implements BehaviorTree {
* </p> * </p>
*/ */
public void start(){ public void start(){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
SynchronizationMessage.constructClientRequestBTreeActionMessage( SynchronizationMessage.constructClientRequestBTreeActionMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
BehaviorTreeIdEnums.BTREE_CLIENTSPRINTTREE_ID, BehaviorTreeIdEnums.BTREE_CLIENTSPRINTTREE_ID,
@ -158,7 +158,7 @@ public class ClientSprintTree implements BehaviorTree {
* </p> * </p>
*/ */
public void interrupt(){ public void interrupt(){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
SynchronizationMessage.constructClientRequestBTreeActionMessage( SynchronizationMessage.constructClientRequestBTreeActionMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
BehaviorTreeIdEnums.BTREE_CLIENTSPRINTTREE_ID, BehaviorTreeIdEnums.BTREE_CLIENTSPRINTTREE_ID,

View File

@ -143,7 +143,7 @@ public class ClientWalkTree implements BehaviorTree {
* </p> * </p>
*/ */
public void start(){ public void start(){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
SynchronizationMessage.constructClientRequestBTreeActionMessage( SynchronizationMessage.constructClientRequestBTreeActionMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
BehaviorTreeIdEnums.BTREE_CLIENTWALKTREE_ID, BehaviorTreeIdEnums.BTREE_CLIENTWALKTREE_ID,
@ -159,7 +159,7 @@ public class ClientWalkTree implements BehaviorTree {
* </p> * </p>
*/ */
public void interrupt(){ public void interrupt(){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
SynchronizationMessage.constructClientRequestBTreeActionMessage( SynchronizationMessage.constructClientRequestBTreeActionMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
BehaviorTreeIdEnums.BTREE_CLIENTWALKTREE_ID, BehaviorTreeIdEnums.BTREE_CLIENTWALKTREE_ID,

View File

@ -109,7 +109,7 @@ public class ClientStanceComponent implements BehaviorTree {
* </p> * </p>
*/ */
public void start(){ public void start(){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
SynchronizationMessage.constructClientRequestBTreeActionMessage( SynchronizationMessage.constructClientRequestBTreeActionMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
BehaviorTreeIdEnums.BTREE_CLIENTSTANCECOMPONENT_ID, BehaviorTreeIdEnums.BTREE_CLIENTSTANCECOMPONENT_ID,
@ -125,7 +125,7 @@ public class ClientStanceComponent implements BehaviorTree {
* </p> * </p>
*/ */
public void interrupt(){ public void interrupt(){
Globals.clientConnection.queueOutgoingMessage( Globals.clientState.clientConnection.queueOutgoingMessage(
SynchronizationMessage.constructClientRequestBTreeActionMessage( SynchronizationMessage.constructClientRequestBTreeActionMessage(
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()), Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
BehaviorTreeIdEnums.BTREE_CLIENTSTANCECOMPONENT_ID, BehaviorTreeIdEnums.BTREE_CLIENTSTANCECOMPONENT_ID,

View File

@ -250,7 +250,7 @@ public class ClientNetworking implements Runnable {
} }
//null out global state //null out global state
Globals.clientConnection = null; Globals.clientState.clientConnection = null;
LoggerInterface.loggerNetworking.INFO("Client networking thread ended"); LoggerInterface.loggerNetworking.INFO("Client networking thread ended");

View File

@ -18,15 +18,15 @@ public class AuthProtocol implements ClientProtocolTemplate<AuthMessage> {
case AUTHREQUEST: case AUTHREQUEST:
//Try login //Try login
//TODO: actually get user/pass //TODO: actually get user/pass
Globals.clientConnection.queueOutgoingMessage(AuthMessage.constructAuthDetailsMessage(Globals.clientUsername,Globals.clientPassword)); Globals.clientState.clientConnection.queueOutgoingMessage(AuthMessage.constructAuthDetailsMessage(Globals.clientUsername,Globals.clientPassword));
break; break;
case AUTHSUCCESS: case AUTHSUCCESS:
//clean password hash from memory //clean password hash from memory
Globals.clientPassword = ""; Globals.clientPassword = "";
//request playable races //request playable races
Globals.clientConnection.queueOutgoingMessage(LoreMessage.constructRequestRacesMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(LoreMessage.constructRequestRacesMessage());
//request characters available to this player //request characters available to this player
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCharacterListMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestCharacterListMessage());
//log that we succeeded //log that we succeeded
LoggerInterface.loggerAuth.INFO("Successfully logged in"); LoggerInterface.loggerAuth.INFO("Successfully logged in");
break; break;

View File

@ -28,8 +28,8 @@ public class CharacterProtocol implements ClientProtocolTemplate<CharacterMessag
switch(message.getMessageSubtype()){ switch(message.getMessageSubtype()){
case RESPONSECREATECHARACTERSUCCESS: { case RESPONSECREATECHARACTERSUCCESS: {
//trigger request to spawn character if the character list is undefined (ie if special loading case) //trigger request to spawn character if the character list is undefined (ie if special loading case)
Globals.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage(electrosphere.net.server.protocol.CharacterProtocol.SPAWN_EXISTING_TEMPLATE + "")); Globals.clientState.clientConnection.queueOutgoingMessage(CharacterMessage.constructRequestSpawnCharacterMessage(electrosphere.net.server.protocol.CharacterProtocol.SPAWN_EXISTING_TEMPLATE + ""));
Globals.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(TerrainMessage.constructRequestMetadataMessage());
LoadingThread clientThread = new LoadingThread(LoadingThreadType.CLIENT_WORLD); LoadingThread clientThread = new LoadingThread(LoadingThreadType.CLIENT_WORLD);
Globals.threadManager.start(clientThread); Globals.threadManager.start(clientThread);
} break; } break;

View File

@ -95,7 +95,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
throw new Error("Unsupported entity type!"); throw new Error("Unsupported entity type!");
} }
} }
Globals.clientConnection.release(message); Globals.clientState.clientConnection.release(message);
} break; } break;
// //
@ -112,7 +112,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
//TODO: bounce message //TODO: bounce message
LoggerInterface.loggerNetworking.WARNING("Received property packet for entity that does not exist on client!"); LoggerInterface.loggerNetworking.WARNING("Received property packet for entity that does not exist on client!");
} }
Globals.clientConnection.release(message); Globals.clientState.clientConnection.release(message);
} break; } break;
case ATTACHENTITYTOENTITY: { case ATTACHENTITYTOENTITY: {
Entity child = Globals.clientState.clientSceneWrapper.getEntityFromServerId(message.getentityID()); Entity child = Globals.clientState.clientSceneWrapper.getEntityFromServerId(message.getentityID());
@ -127,7 +127,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
new Quaterniond() new Quaterniond()
); );
} }
Globals.clientConnection.release(message); Globals.clientState.clientConnection.release(message);
} break; } break;
case MOVEUPDATE: { case MOVEUPDATE: {
Entity target = Globals.clientState.clientSceneWrapper.getEntityFromServerId(message.getentityID()); Entity target = Globals.clientState.clientSceneWrapper.getEntityFromServerId(message.getentityID());
@ -158,7 +158,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
ClientEntityUtils.destroyEntity(entity); ClientEntityUtils.destroyEntity(entity);
} }
Globals.clientState.clientSynchronizationManager.addDeletedId(message.getentityID()); Globals.clientState.clientSynchronizationManager.addDeletedId(message.getentityID());
Globals.clientConnection.release(message); Globals.clientState.clientConnection.release(message);
} break; } break;

View File

@ -19,11 +19,11 @@ public class ServerProtocol implements ClientProtocolTemplate<ServerMessage> {
public void handleSyncMessage(ServerMessage message) { public void handleSyncMessage(ServerMessage message) {
switch(message.getMessageSubtype()){ switch(message.getMessageSubtype()){
case PING: case PING:
Globals.clientConnection.queueOutgoingMessage(ServerMessage.constructPongMessage()); Globals.clientState.clientConnection.queueOutgoingMessage(ServerMessage.constructPongMessage());
break; break;
case PONG: case PONG:
//let the networking loop know we received a pong message //let the networking loop know we received a pong message
Globals.clientConnection.markReceivedPongMessage(); Globals.clientState.clientConnection.markReceivedPongMessage();
break; break;
case DISCONNECT: { case DISCONNECT: {
LoggerInterface.loggerNetworking.WARNING("Server sent signal to disconnect!"); LoggerInterface.loggerNetworking.WARNING("Server sent signal to disconnect!");

View File

@ -46,7 +46,7 @@ public class TerrainProtocol implements ClientProtocolTemplate<TerrainMessage> {
message.getworldSizeDiscrete() message.getworldSizeDiscrete()
); );
Globals.clientState.clientSceneWrapper.getCollisionEngine().setCollisionWorldData(new CollisionWorldData()); Globals.clientState.clientSceneWrapper.getCollisionEngine().setCollisionWorldData(new CollisionWorldData());
Globals.clientConnection.getMessageProtocol().setHasReceivedWorld(true); Globals.clientState.clientConnection.getMessageProtocol().setHasReceivedWorld(true);
break; break;
case SPAWNPOSITION: case SPAWNPOSITION:
LoggerInterface.loggerNetworking.WARNING("Received spawnPosition packet on client. This is deprecated!"); LoggerInterface.loggerNetworking.WARNING("Received spawnPosition packet on client. This is deprecated!");

View File

@ -187,7 +187,7 @@ public class ClientSynchronizationManager {
} }
for(SynchronizationMessage message : messagesToClear){ for(SynchronizationMessage message : messagesToClear){
messages.remove(message); messages.remove(message);
Globals.clientConnection.release(message); Globals.clientState.clientConnection.release(message);
} }
Set<Integer> deletionKeys = this.deletedEntityIds.keySet(); Set<Integer> deletionKeys = this.deletedEntityIds.keySet();
for(int key : deletionKeys){ for(int key : deletionKeys){

View File

@ -21,7 +21,6 @@ public class StateCleanupCheckerExtension implements AfterEachCallback {
Globals.renderingEngine, Globals.renderingEngine,
Globals.audioEngine, Globals.audioEngine,
Globals.javaPID, Globals.javaPID,
Globals.clientConnection,
Globals.server, Globals.server,
Globals.serverSynchronizationManager, Globals.serverSynchronizationManager,
Globals.playerManager, Globals.playerManager,