From 8cbcb15b50706c03728552819b0d8d80f652935c Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Sun, 24 Mar 2024 20:33:23 -0500 Subject: [PATCH] hard cap 3 box limit --- .../InterestManagement/InterestManager.java | 16 +++++++++++++++- src/engine/server/world/WorldServer.java | 7 ++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index 13f29c87..af018ec7 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -28,6 +28,7 @@ import engine.server.MBServerStatics; import org.pmw.tinylog.Logger; import java.util.ArrayList; +import java.util.HashMap; import java.util.HashSet; import static engine.math.FastMath.sqr; @@ -37,6 +38,7 @@ public enum InterestManager implements Runnable { INTERESTMANAGER; private static long lastTime; + public static HashMap> playersByMachine = new HashMap<>(); InterestManager() { Logger.info(" Interest Management thread is running."); @@ -522,12 +524,24 @@ public enum InterestManager implements Runnable { if (origin == null) return; + if(playersByMachine.containsKey(origin.machineID)){ + if(playersByMachine.get(origin.machineID) == null){ + ArrayList newList = new ArrayList<>(); + newList.add(player); + playersByMachine.put(origin.machineID,newList); + } else{ + if(playersByMachine.get(origin.machineID).size() >= 3){ + origin.disconnect(); + }else{ + playersByMachine.get(origin.machineID).add(player); + } + } + } // Update loaded upbjects lists player.setDirtyLoad(true); updateStaticList(player, origin); updateMobileList(player, origin); - } public synchronized void HandleLoadForTeleport(PlayerCharacter playerCharacter) { diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index eafae89b..6ea3dfd6 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -15,6 +15,7 @@ import engine.Enum.DispatchChannel; import engine.Enum.MinionType; import engine.Enum.SupportMsgType; import engine.InterestManagement.HeightMap; +import engine.InterestManagement.InterestManager; import engine.InterestManagement.RealmMap; import engine.InterestManagement.WorldGrid; import engine.db.archive.DataWarehouse; @@ -710,7 +711,11 @@ public class WorldServer { } player.getTimestamps().put("logout", System.currentTimeMillis()); player.setEnteredWorld(false); - + if(InterestManager.playersByMachine.containsKey(player.getClientConnection().machineID)){ + if(InterestManager.playersByMachine.get(player.getClientConnection().machineID).contains(player)){ + InterestManager.playersByMachine.get(player.getClientConnection().machineID).remove(player); + } + } // remove from simulation and zero current loc WorldGrid.RemoveWorldObject(player);