From a320333ddc4340724276bedad16c394404165d9d Mon Sep 17 00:00:00 2001 From: FatBoy-DOTC Date: Tue, 26 Mar 2024 12:43:32 -0500 Subject: [PATCH] new 3 box limit --- .../InterestManagement/InterestManager.java | 29 ++++++++++++------- src/engine/server/world/WorldServer.java | 5 ---- 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/engine/InterestManagement/InterestManager.java b/src/engine/InterestManagement/InterestManager.java index af018ec7..9ddd2ab7 100644 --- a/src/engine/InterestManagement/InterestManager.java +++ b/src/engine/InterestManagement/InterestManager.java @@ -19,12 +19,15 @@ import engine.net.AbstractNetMsg; import engine.net.Dispatch; import engine.net.DispatchMessage; import engine.net.client.ClientConnection; +import engine.net.client.ClientConnectionManager; import engine.net.client.msg.LoadCharacterMsg; import engine.net.client.msg.LoadStructureMsg; import engine.net.client.msg.MoveToPointMsg; import engine.net.client.msg.UnloadObjectsMsg; +import engine.net.client.msg.login.CharSelectScreenMsg; import engine.objects.*; import engine.server.MBServerStatics; +import engine.session.Session; import org.pmw.tinylog.Logger; import java.util.ArrayList; @@ -38,7 +41,6 @@ public enum InterestManager implements Runnable { INTERESTMANAGER; private static long lastTime; - public static HashMap> playersByMachine = new HashMap<>(); InterestManager() { Logger.info(" Interest Management thread is running."); @@ -524,18 +526,23 @@ 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); + int currentConnections = 0; + for(PlayerCharacter pc : SessionManager.getAllActivePlayerCharacters()){ + if(pc.isActive() && pc.isEnteredWorld() && pc.getClientConnection().machineID.equals(player.getClientConnection().machineID)){ + currentConnections++; + } + } + + try { + if (currentConnections >= 3) { + Session s = SessionManager.getSession(player); + if (s.getAccount() != null) { + CharSelectScreenMsg cssm = new CharSelectScreenMsg(s, false); + s.getConn().sendMsg(cssm); } } + }catch(Exception ex){ + } // Update loaded upbjects lists diff --git a/src/engine/server/world/WorldServer.java b/src/engine/server/world/WorldServer.java index 6ea3dfd6..1e683a95 100644 --- a/src/engine/server/world/WorldServer.java +++ b/src/engine/server/world/WorldServer.java @@ -711,11 +711,6 @@ 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);