diff --git a/src/main/java/org/terasology/dynamicCities/settlements/DistrictFacetOverlaySystem.java b/src/main/java/org/terasology/dynamicCities/settlements/DistrictFacetOverlaySystem.java index 1c97286..cd6ab06 100644 --- a/src/main/java/org/terasology/dynamicCities/settlements/DistrictFacetOverlaySystem.java +++ b/src/main/java/org/terasology/dynamicCities/settlements/DistrictFacetOverlaySystem.java @@ -33,7 +33,9 @@ import org.terasology.network.NetworkSystem; import org.terasology.registry.In; +import java.util.HashMap; import java.util.Iterator; +import java.util.Map; @RegisterSystem(RegisterMode.CLIENT) public class DistrictFacetOverlaySystem extends BaseComponentSystem { @@ -55,28 +57,29 @@ public class DistrictFacetOverlaySystem extends BaseComponentSystem { private EntityRef clientEntity; - private boolean isOverlayAdded; + private Map isOverlayAdded; @Override public void initialise() { if (networkSystem.getMode() == NetworkMode.CLIENT) { clientEntity = networkSystem.getServer().getClientEntity(); } + isOverlayAdded = new HashMap<>(); } @ReceiveEvent public void onAddOverlayEvent(AddDistrictOverlayEvent event, EntityRef entityRef) { if (networkSystem.getMode() == NetworkMode.CLIENT) { - if (clientEntity.getComponent(ClientComponent.class).character.getId() == entityRef.getId() && !isOverlayAdded) { + if (clientEntity.getComponent(ClientComponent.class).character.getId() == entityRef.getId() && !isOverlayAdded.getOrDefault(entityRef, false)) { Iterator entityRefs = entityManager.getEntitiesWith(SettlementsCacheComponent.class).iterator(); if (entityRefs.hasNext()) { minimapSystem.addOverlay(new DistrictOverlay((entityRefs.next()))); - isOverlayAdded = true; + isOverlayAdded.put(entityRef, true); } else { logger.error("No SettlementCache found! Unable to create district overlay"); } } } - if (networkSystem.getMode() == NetworkMode.DEDICATED_SERVER && !isOverlayAdded) { + if (networkSystem.getMode() == NetworkMode.DEDICATED_SERVER && !isOverlayAdded.getOrDefault(entityRef, false)) { if (localPlayer.getCharacterEntity() == entityRef) { Iterator entityRefs = entityManager.getEntitiesWith(SettlementsCacheComponent.class).iterator(); if (entityRefs.hasNext()) { diff --git a/src/main/java/org/terasology/dynamicCities/settlements/components/DistrictFacetComponent.java b/src/main/java/org/terasology/dynamicCities/settlements/components/DistrictFacetComponent.java index b744dc8..3aac9d9 100644 --- a/src/main/java/org/terasology/dynamicCities/settlements/components/DistrictFacetComponent.java +++ b/src/main/java/org/terasology/dynamicCities/settlements/components/DistrictFacetComponent.java @@ -160,7 +160,8 @@ else if (tempZoneArea.get(zone) / totalAssignedArea > culturalNeedsPercentage.ge diff += TeraMath.fastAbs(tempZoneArea.get(zone) / totalAssignedArea - culturalNeedsPercentage.get(zone)); } } - diff = 1 / diff; + + diff = (diff == 0) ? 0 : 1 / diff; probabilites.put(districtType, diff); totalDiff += diff; }