diff --git a/src/engine/gameManager/MaintenanceManager.java b/src/engine/gameManager/MaintenanceManager.java index f92d531e..c8265fc6 100644 --- a/src/engine/gameManager/MaintenanceManager.java +++ b/src/engine/gameManager/MaintenanceManager.java @@ -49,19 +49,15 @@ public enum MaintenanceManager { if (chargeUpkeep(building) == false) derankList.add(building); + else + setMaintDateTime(building, LocalDateTime.now().plusDays(7)); } - // Reset maintenance dates for these buildings - for (Building building : maintList) { - setMaintDateTime(building, LocalDateTime.now().plusDays(7)); - - } - // Derak or destroy buildings that did not - // have funds available. - - for (Building building : derankList) + for (Building building : derankList) { building.destroyOrDerank(null); - + if(building.getRank() > 0) + setMaintDateTime(building, LocalDateTime.now().plusDays(1)); + } Logger.info("Structures: " + buildingList.size() + " Maint: " + maintList.size() + " Derank: " + derankList.size()); } @@ -98,6 +94,10 @@ public enum MaintenanceManager { continue; } + //only ToL pays maintenance + if(building.getBlueprint().getBuildingGroup() != null && !building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.TOL)) + continue; + // No maintenance on banestones omfg if (building.getBlueprint().getBuildingGroup().equals(Enum.BuildingGroup.BANESTONE)) diff --git a/src/engine/objects/Building.java b/src/engine/objects/Building.java index d625234c..e7fe266d 100644 --- a/src/engine/objects/Building.java +++ b/src/engine/objects/Building.java @@ -780,24 +780,9 @@ public class Building extends AbstractWorldObject { public int getMaintCost() { - int maintCost = 0; - - // Add cost for building structure - - maintCost += this.getBlueprint().getMaintCost(rank); - - // Add costs associated with hirelings - - for (AbstractCharacter npc : this.hirelings.keySet()) { - - if (npc.getObjectType() != GameObjectType.NPC) - continue; - - - maintCost += Blueprint.getNpcMaintCost(npc.getRank()); - } - - return maintCost; + if(this.getBlueprint() != null && this.getBlueprint().getBuildingGroup().equals(BuildingGroup.TOL)) + return 3000000; + else return 0; } public final void submitOpenDoorJob(int doorID) { diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index afc06004..29182e4c 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -490,8 +490,8 @@ public class WorldServer { MobRespawnThread.startRespawnThread(); // Run maintenance - - MaintenanceManager.dailyMaintenance(); + //moved this to hourly job thread to sustain no reboot system + //MaintenanceManager.dailyMaintenance(); Logger.info("Starting Orphan Item Purge"); PurgeOprhans.startPurgeThread(); diff --git a/src/engine/workthreads/HalfHourlyJobThread.java b/src/engine/workthreads/HalfHourlyJobThread.java index 7fd89f60..87de4df1 100644 --- a/src/engine/workthreads/HalfHourlyJobThread.java +++ b/src/engine/workthreads/HalfHourlyJobThread.java @@ -162,20 +162,5 @@ public class HalfHourlyJobThread implements Runnable { processMineWindow(); - // Mines can only be claimed once per cycle. - // This will reset at 1am after the last mine - // window closes. - - if (LocalDateTime.now().getHour() == 1) { - - for (Mine mine : Mine.getMines()) { - try { - mine.depositMineResources(); - } catch (Exception e) { - Logger.info(e.getMessage() + " for Mine " + mine.getObjectUUID()); - } - mine.wasClaimed = false; - } - } } } diff --git a/src/engine/workthreads/HourlyJobThread.java b/src/engine/workthreads/HourlyJobThread.java index 723b8d8e..742f7152 100644 --- a/src/engine/workthreads/HourlyJobThread.java +++ b/src/engine/workthreads/HourlyJobThread.java @@ -15,6 +15,8 @@ import engine.net.MessageDispatcher; import engine.objects.*; import engine.server.world.WorldServer; import org.pmw.tinylog.Logger; + +import java.time.LocalDateTime; import java.util.ArrayList; import java.util.concurrent.ConcurrentHashMap; @@ -51,6 +53,21 @@ public class HourlyJobThread implements Runnable { Logger.error("missing city map"); } + //run maintenance every day at 1 am + if(LocalDateTime.now().getHour() == 1) { + MaintenanceManager.dailyMaintenance(); + + //produce mine resources once a day + for (Mine mine : Mine.getMines()) { + try { + mine.depositMineResources(); + } catch (Exception e) { + Logger.info(e.getMessage() + " for Mine " + mine.getObjectUUID()); + } + mine.wasClaimed = false; + } + } + // Log metrics to console Logger.info(WorldServer.getUptimeString()); Logger.info(SimulationManager.getPopulationString());