fix macro data checks breaking on macro-less realm
This commit is contained in:
		
							parent
							
								
									26355baec4
								
							
						
					
					
						commit
						6ac45b47a2
					
				| @ -815,7 +815,9 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager | ||||
|             ServerEntityUtils.destroyEntity(blockEntity); | ||||
|         } | ||||
| 
 | ||||
|         MacroDataUpdater.update(parent, parent.getMacroData(), realPos); | ||||
|         if(parent.getMacroData() != null){ | ||||
|             MacroDataUpdater.update(parent, parent.getMacroData(), realPos); | ||||
|         } | ||||
|         this.generationService.submit(() -> { | ||||
|             try { | ||||
|                 BlockChunkData blockChunkData = realm.getServerWorldData().getServerBlockManager().getChunk(worldPos.x, worldPos.y, worldPos.z); | ||||
|  | ||||
| @ -1,6 +1,7 @@ | ||||
| package electrosphere.server.entity; | ||||
| 
 | ||||
| import java.util.Collection; | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| 
 | ||||
| @ -75,24 +76,26 @@ public class ServerContentManager { | ||||
|         //Block for macro data generation if relevant | ||||
|         // | ||||
|         List<MacroObject> objects = null; | ||||
|         if(macroData != null){ | ||||
|         if(macroData == null){ | ||||
|             objects = new LinkedList<MacroObject>(); | ||||
|         } else { | ||||
|             objects = macroData.getNearbyObjects(ServerWorldData.convertChunkToRealSpace(worldPos.x, worldPos.y, worldPos.z)); | ||||
|         } | ||||
|         //if any of this macro data isn't ready, return a null chunk | ||||
|         long notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count(); | ||||
|         int waitCount = 0; | ||||
|         while(notFullResCount > 0 && waitCount < MAX_TIME_TO_WAIT){ | ||||
|             try { | ||||
|                 TimeUnit.MILLISECONDS.sleep(1); | ||||
|             } catch (InterruptedException e) { | ||||
|                 e.printStackTrace(); | ||||
|                 break; | ||||
|             //if any of this macro data isn't ready, return a null chunk | ||||
|             long notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count(); | ||||
|             int waitCount = 0; | ||||
|             while(notFullResCount > 0 && waitCount < MAX_TIME_TO_WAIT){ | ||||
|                 try { | ||||
|                     TimeUnit.MILLISECONDS.sleep(1); | ||||
|                 } catch (InterruptedException e) { | ||||
|                     e.printStackTrace(); | ||||
|                     break; | ||||
|                 } | ||||
|                 notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count(); | ||||
|                 waitCount++; | ||||
|             } | ||||
|             if(notFullResCount > 0){ | ||||
|                 throw new Error("Failed to generate content " + notFullResCount + " " + waitCount); | ||||
|             } | ||||
|             notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count(); | ||||
|             waitCount++; | ||||
|         } | ||||
|         if(notFullResCount > 0){ | ||||
|             throw new Error("Failed to generate content " + notFullResCount + " " + waitCount); | ||||
|         } | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| package electrosphere.server.physics.block.manager; | ||||
| 
 | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.function.Consumer; | ||||
| @ -150,13 +151,15 @@ public class ServerBlockChunkGenerationThread implements Runnable { | ||||
|     ){ | ||||
|         //get the macro data that affects this chunk | ||||
|         List<MacroObject> objects = null; | ||||
|         if(macroData != null){ | ||||
|         if(macroData == null){ | ||||
|             objects = new LinkedList<MacroObject>(); | ||||
|         } else { | ||||
|             objects = macroData.getNearbyObjects(ServerWorldData.convertChunkToRealSpace(worldX, worldY, worldZ)); | ||||
|         } | ||||
|         //if any of this macro data isn't ready, return a null chunk | ||||
|         long notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count(); | ||||
|         if(notFullResCount > 0){ | ||||
|             return null; | ||||
|             //if any of this macro data isn't ready, return a null chunk | ||||
|             long notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count(); | ||||
|             if(notFullResCount > 0){ | ||||
|                 return null; | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         BlockChunkData chunk = null; | ||||
|  | ||||
| @ -1,5 +1,6 @@ | ||||
| package electrosphere.server.physics.terrain.manager; | ||||
| 
 | ||||
| import java.util.LinkedList; | ||||
| import java.util.List; | ||||
| import java.util.concurrent.TimeUnit; | ||||
| import java.util.function.Consumer; | ||||
| @ -158,19 +159,23 @@ public class ChunkGenerationThread implements Runnable { | ||||
| 
 | ||||
|         //get the macro data that affects this chunk | ||||
|         List<MacroObject> objects = null; | ||||
|         if(macroData != null){ | ||||
|             objects = macroData.getNearbyObjects(ServerWorldData.convertChunkToRealSpace(worldX, worldY, worldZ)); | ||||
|         } | ||||
|         //if any of this macro data isn't ready, return a null chunk | ||||
|         long notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count(); | ||||
|         if(notFullResCount > 0){ | ||||
|             return null; | ||||
|         } | ||||
|         List<MacroObject> towns = objects.stream().filter((MacroObject obj) -> obj instanceof Town).collect(Collectors.toList()); | ||||
|         for(MacroObject currObj : towns){ | ||||
|             Town town = (Town)currObj; | ||||
|             List<VirtualStructure> structs = town.getStructures(macroData); | ||||
|             objects.addAll(structs); | ||||
|         if(macroData == null){ | ||||
|             objects = new LinkedList<MacroObject>(); | ||||
|         } else { | ||||
|             if(macroData != null){ | ||||
|                 objects = macroData.getNearbyObjects(ServerWorldData.convertChunkToRealSpace(worldX, worldY, worldZ)); | ||||
|             } | ||||
|             //if any of this macro data isn't ready, return a null chunk | ||||
|             long notFullResCount = objects.stream().filter((MacroObject macroObj) -> macroObj instanceof MacroLODObject).map((MacroObject oldView) -> (MacroLODObject)oldView).filter((MacroLODObject lodObj) -> !lodObj.isFullRes()).count(); | ||||
|             if(notFullResCount > 0){ | ||||
|                 return null; | ||||
|             } | ||||
|             List<MacroObject> towns = objects.stream().filter((MacroObject obj) -> obj instanceof Town).collect(Collectors.toList()); | ||||
|             for(MacroObject currObj : towns){ | ||||
|                 Town town = (Town)currObj; | ||||
|                 List<VirtualStructure> structs = town.getStructures(macroData); | ||||
|                 objects.addAll(structs); | ||||
|             } | ||||
|         } | ||||
| 
 | ||||
|         if(chunkCache.containsChunk(worldX, worldY, worldZ, stride)){ | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user