62 lines
		
	
	
		
			2.1 KiB
		
	
	
	
		
			Java
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			2.1 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.server != null){
 | |
|             Globals.server.cleanupDeadConnections();
 | |
|         }
 | |
| 
 | |
|         //
 | |
|         //Synchronous player message parsing\
 | |
|         Globals.profiler.beginCpuSample("MainServerFunctions.simulate - Server synchronous packet parsing");
 | |
|         if(Globals.server != null){
 | |
|             Globals.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();
 | |
| 
 | |
|         //
 | |
|         //Micro simulation (ie simulating each scene on the server)
 | |
|         Globals.profiler.beginCpuSample("MainServerFunctions.simulate - Server micro simulation");
 | |
|         LoggerInterface.loggerEngine.DEBUG_LOOP("Begin server micro simulation");
 | |
|         if(Globals.realmManager != null){
 | |
|             Globals.realmManager.simulate();
 | |
|         }
 | |
|         Globals.profiler.endCpuSample();
 | |
|         
 | |
|         //
 | |
|         //Macro simulation (ie simulating the larger world macro data)
 | |
|         Globals.profiler.beginCpuSample("MainServerFunctions.simulate - Server macro simulation");
 | |
|         LoggerInterface.loggerEngine.DEBUG_LOOP("MainServerFunctions.simulate - Server macro simulation");
 | |
|         if(Globals.macroSimulation != null && Globals.macroSimulation.isReady()){
 | |
|             Globals.macroSimulation.simulate();
 | |
|         }
 | |
|         Globals.profiler.endCpuSample();
 | |
| 
 | |
|         Globals.profiler.endCpuSample();
 | |
|     }
 | |
|     
 | |
| }
 |