Renderer/src/main/java/electrosphere/server/MainServerFunctions.java
austin 4e488e43cd
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
explicit ServerState object
2025-05-15 12:57:56 -04:00

64 lines
1.9 KiB
Java

package electrosphere.server;
import electrosphere.engine.Globals;
import electrosphere.logger.LoggerInterface;
/**
* Functions that should be fired every server frame
*/
public class MainServerFunctions {
/**
* Calls the main server routines that should fire each frame
*/
public static void simulate(){
Globals.profiler.beginCpuSample("MainServerFunctions.simulate");
//
//Cleanup disconnected clients
if(Globals.serverState.server != null){
Globals.serverState.server.cleanupDeadConnections();
}
//
//Synchronous player message parsing\
Globals.profiler.beginCpuSample("MainServerFunctions.simulate - Server synchronous packet parsing");
if(Globals.serverState.server != null){
Globals.serverState.server.synchronousPacketHandling();
}
Globals.profiler.endCpuSample();
Globals.profiler.beginCpuSample("MainServerFunctions.simulate - Server process synchronization messages");
if(Globals.serverSynchronizationManager != null){
Globals.serverSynchronizationManager.processMessages();
}
Globals.profiler.endCpuSample();
//
//Update AI
Globals.aiManager.simulate();
//
//Services
MainServerFunctions.simulateServices();
//
//Simulation
Globals.profiler.beginCpuSample("MainServerFunctions.simulate - Realm simulation");
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin server realm simulation");
if(Globals.realmManager != null){
Globals.realmManager.simulate();
}
Globals.profiler.endCpuSample();
Globals.profiler.endCpuSample();
}
/**
* Simulates server services
*/
private static void simulateServices(){
Globals.structureScanningService.simulate();
}
}