Browse Source

bane mechanic thread

lakebane2
FatBoy-DOTC 3 weeks ago
parent
commit
5e8927245b
  1. 6
      src/engine/gameManager/SimulationManager.java
  2. 3
      src/engine/server/world/WorldServer.java
  3. 69
      src/engine/workthreads/BaneThread.java

6
src/engine/gameManager/SimulationManager.java

@ -204,12 +204,6 @@ public enum SimulationManager {
if(mine != null && mine.isActive) if(mine != null && mine.isActive)
mine.onEnter(); 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; _cityPulseTime = System.currentTimeMillis() + CITY_PULSE;
} }

3
src/engine/server/world/WorldServer.java

@ -513,6 +513,9 @@ public class WorldServer {
Logger.info("Running garbage collection..."); Logger.info("Running garbage collection...");
System.gc(); System.gc();
return true; return true;
} }

69
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();
}
}
Loading…
Cancel
Save