From 5e8927245bc5732e6b5d49bf7b7ab0ebd4ba0dc8 Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 31 Dec 2024 17:33:26 -0600 Subject: [PATCH] bane mechanic thread --- src/engine/gameManager/SimulationManager.java | 6 -- src/engine/server/world/WorldServer.java | 3 + src/engine/workthreads/BaneThread.java | 69 +++++++++++++++++++ 3 files changed, 72 insertions(+), 6 deletions(-) create mode 100644 src/engine/workthreads/BaneThread.java diff --git a/src/engine/gameManager/SimulationManager.java b/src/engine/gameManager/SimulationManager.java index d68c02d5..3d00bf0b 100644 --- a/src/engine/gameManager/SimulationManager.java +++ b/src/engine/gameManager/SimulationManager.java @@ -204,12 +204,6 @@ public enum SimulationManager { if(mine != null && mine.isActive) mine.onEnter(); } - for(int baneId : Bane.banes.keySet()){ - Bane bane = Bane.banes.get(baneId); - if(bane.getSiegePhase().equals(Enum.SiegePhase.WAR)){ - bane.applyZergBuffs(); - } - } _cityPulseTime = System.currentTimeMillis() + CITY_PULSE; } diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index f57d2989..c400bc06 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -513,6 +513,9 @@ public class WorldServer { Logger.info("Running garbage collection..."); System.gc(); + + + return true; } diff --git a/src/engine/workthreads/BaneThread.java b/src/engine/workthreads/BaneThread.java new file mode 100644 index 00000000..e015a790 --- /dev/null +++ b/src/engine/workthreads/BaneThread.java @@ -0,0 +1,69 @@ +// • ▌ ▄ ·. ▄▄▄· ▄▄ • ▪ ▄▄· ▄▄▄▄· ▄▄▄· ▐▄▄▄ ▄▄▄ . +// ·██ ▐███▪▐█ ▀█ ▐█ ▀ ▪██ ▐█ ▌▪▐█ ▀█▪▐█ ▀█ •█▌ ▐█▐▌· +// ▐█ ▌▐▌▐█·▄█▀▀█ ▄█ ▀█▄▐█·██ ▄▄▐█▀▀█▄▄█▀▀█ ▐█▐ ▐▌▐▀▀▀ +// ██ ██▌▐█▌▐█ ▪▐▌▐█▄▪▐█▐█▌▐███▌██▄▪▐█▐█ ▪▐▌██▐ █▌▐█▄▄▌ +// ▀▀ █▪▀▀▀ ▀ ▀ ·▀▀▀▀ ▀▀▀·▀▀▀ ·▀▀▀▀ ▀ ▀ ▀▀ █▪ ▀▀▀ +// Magicbane Emulator Project © 2013 - 2022 +// www.magicbane.com + + +package engine.workthreads; + +import engine.Enum; +import engine.InterestManagement.WorldGrid; +import engine.db.archive.DataWarehouse; +import engine.db.archive.MineRecord; +import engine.gameManager.BuildingManager; +import engine.gameManager.ChatManager; +import engine.gameManager.StrongholdManager; +import engine.mobileAI.Threads.MobAIThread; +import engine.net.DispatchMessage; +import engine.net.client.msg.chat.ChatSystemMsg; +import engine.objects.*; +import org.pmw.tinylog.Logger; + +import java.time.LocalDateTime; +import java.util.ArrayList; + +public class BaneThread implements Runnable { + + public Long lastRun; + public static int instancedelay = 10000; + public BaneThread() { + Logger.info(" BaneThread thread has started!"); + } + + + public static void processBanesWindow() { + + try { + for(int baneId : Bane.banes.keySet()){ + Bane bane = Bane.banes.get(baneId); + if(bane.getSiegePhase().equals(Enum.SiegePhase.WAR)){ + bane.applyZergBuffs(); + } + } + } catch (Exception e) { + Logger.error("BANE ERROR"); + } + + + } + + public void run() { + lastRun = System.currentTimeMillis(); + while (true) { + if(lastRun + instancedelay < System.currentTimeMillis()) + processBanesWindow(); + lastRun = System.currentTimeMillis(); + } + + } + + public static void startBaneThread() { + Thread baneThread; + baneThread = new Thread(new BaneThread()); + baneThread.setName("baneThread"); + baneThread.start(); + } +}